Skip to content

Commit 0adcbc0

Browse files
authored
Merge pull request #186 from copilot-community-sdk/docs/fix-documentation-coverage-gaps
Fix documentation coverage gaps
2 parents 4e0f289 + 7215df0 commit 0adcbc0

File tree

3 files changed

+89
-0
lines changed

3 files changed

+89
-0
lines changed

src/site/markdown/advanced.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ This guide covers advanced scenarios for extending and customizing your Copilot
2424
- [Loading Skills](#Loading_Skills)
2525
- [Disabling Skills](#Disabling_Skills)
2626
- [Custom Configuration Directory](#Custom_Configuration_Directory)
27+
- [Session Logging](#Session_Logging)
28+
- [Early Event Registration](#Early_Event_Registration)
2729
- [User Input Handling](#User_Input_Handling)
2830
- [Permission Handling](#Permission_Handling)
2931
- [Session Hooks](#Session_Hooks)
@@ -506,6 +508,54 @@ This is useful when you need to isolate session configuration or use different s
506508

507509
---
508510

511+
## Session Logging
512+
513+
Send log messages to the session for debugging, status updates, or UI feedback.
514+
515+
```java
516+
// Simple log message (defaults to "info" level)
517+
session.log("Processing step 1 of 3").get();
518+
519+
// Log with explicit level and ephemeral flag
520+
session.log("Downloading dependencies...", "info", true).get();
521+
```
522+
523+
| Parameter | Type | Description |
524+
|-----------|------|-------------|
525+
| `message` | String | The log message text |
526+
| `level` | String | Log level: `"info"`, `"warning"`, `"error"` |
527+
| `ephemeral` | Boolean | If `true`, the message is transient and may not be persisted |
528+
529+
Use cases:
530+
- Displaying progress in a UI while the session processes a request
531+
- Sending status updates to the session log
532+
- Debugging session behavior with contextual messages
533+
534+
See [CopilotSession.log()](apidocs/com/github/copilot/sdk/CopilotSession.html#log(java.lang.String)) Javadoc for details.
535+
536+
---
537+
538+
## Early Event Registration
539+
540+
Register an event handler *before* the `session.create` RPC is issued, ensuring no early events are missed.
541+
542+
When you register handlers with `session.on()` after `createSession()` returns, you may miss events emitted during session creation (e.g., `SessionStartEvent`). Use `SessionConfig.setOnEvent()` to guarantee delivery of all events from the very start:
543+
544+
```java
545+
var events = new CopyOnWriteArrayList<AbstractSessionEvent>();
546+
547+
var session = client.createSession(
548+
new SessionConfig().setOnPermissionRequest(PermissionHandler.APPROVE_ALL)
549+
.setOnEvent(events::add) // Registered before session.create RPC
550+
).get();
551+
552+
// events list now includes SessionStartEvent and any other early events
553+
```
554+
555+
This is equivalent to calling `session.on(handler)` immediately after creation, but executes earlier in the lifecycle. The same option is available on `ResumeSessionConfig.setOnEvent()` for resumed sessions.
556+
557+
---
558+
509559
## User Input Handling
510560

511561
Handle user input requests when the AI uses the `ask_user` tool to gather information from the user.

src/site/markdown/documentation.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,9 @@ The SDK supports event types organized by category. All events extend `AbstractS
162162
| `SessionInfoEvent` | `session.info` | Informational message from the session |
163163
| `SessionShutdownEvent` | `session.shutdown` | Session is shutting down (includes reason and exit code) |
164164
| `SessionModelChangeEvent` | `session.model_change` | The model was changed mid-session |
165+
| `SessionModeChangedEvent` | `session.mode_changed` | Session mode changed (e.g., plan mode) |
166+
| `SessionPlanChangedEvent` | `session.plan_changed` | Session plan was updated |
167+
| `SessionWorkspaceFileChangedEvent` | `session.workspace_file_changed` | A file in the workspace was modified |
165168
| `SessionHandoffEvent` | `session.handoff` | Session handed off to another agent |
166169
| `SessionTruncationEvent` | `session.truncation` | Context was truncated due to limits |
167170
| `SessionSnapshotRewindEvent` | `session.snapshot_rewind` | Session rewound to a previous snapshot |
@@ -220,8 +223,37 @@ The SDK supports event types organized by category. All events extend `AbstractS
220223
| `HookStartEvent` | `hook.start` | Hook execution started |
221224
| `HookEndEvent` | `hook.end` | Hook execution completed |
222225
| `SystemMessageEvent` | `system.message` | System-level message |
226+
| `SystemNotificationEvent` | `system.notification` | System notification (informational) |
223227
| `SkillInvokedEvent` | `skill.invoked` | A skill was invoked |
224228

229+
### External Tool Events
230+
231+
| Event | Type String | Description |
232+
|-------|-------------|-------------|
233+
| `ExternalToolRequestedEvent` | `external_tool.requested` | An external tool invocation was requested |
234+
| `ExternalToolCompletedEvent` | `external_tool.completed` | An external tool invocation completed |
235+
236+
### Permission Events
237+
238+
| Event | Type String | Description |
239+
|-------|-------------|-------------|
240+
| `PermissionRequestedEvent` | `permission.requested` | A permission request was issued |
241+
| `PermissionCompletedEvent` | `permission.completed` | A permission request was resolved |
242+
243+
### Command Events
244+
245+
| Event | Type String | Description |
246+
|-------|-------------|-------------|
247+
| `CommandQueuedEvent` | `command.queued` | A command was queued for execution |
248+
| `CommandCompletedEvent` | `command.completed` | A queued command completed |
249+
250+
### Plan Mode Events
251+
252+
| Event | Type String | Description |
253+
|-------|-------------|-------------|
254+
| `ExitPlanModeRequestedEvent` | `exit_plan_mode.requested` | Exit from plan mode was requested |
255+
| `ExitPlanModeCompletedEvent` | `exit_plan_mode.completed` | Exit from plan mode completed |
256+
225257
See the [events package Javadoc](apidocs/com/github/copilot/sdk/events/package-summary.html) for detailed event data structures.
226258

227259
---
@@ -598,9 +630,12 @@ When resuming a session, you can optionally reconfigure many settings. This is u
598630
| `configDir` | Override configuration directory |
599631
| `mcpServers` | Configure MCP servers |
600632
| `customAgents` | Configure custom agents |
633+
| `agent` | Pre-select a custom agent at session start |
601634
| `skillDirectories` | Directories to load skills from |
602635
| `disabledSkills` | Skills to disable |
603636
| `infiniteSessions` | Configure infinite session behavior |
637+
| `disableResume` | When `true`, resumes without emitting a `session.resume` event |
638+
| `onEvent` | Event handler registered before session resumption |
604639

605640
**Example: Changing Model on Resume**
606641

@@ -637,6 +672,7 @@ Complete list of all `SessionConfig` options for `createSession()`:
637672
| Option | Type | Description | Guide |
638673
|--------|------|-------------|-------|
639674
| `sessionId` | String | Custom session ID (auto-generated if omitted) ||
675+
| `clientName` | String | Client name for User-Agent identification ||
640676
| `model` | String | AI model to use | [Choosing a Model](#Choosing_a_Model) |
641677
| `reasoningEffort` | String | Reasoning depth: `"low"`, `"medium"`, `"high"`, `"xhigh"` | [Reasoning Effort](#Reasoning_Effort) |
642678
| `tools` | List&lt;ToolDefinition&gt; | Custom tools the assistant can invoke | [Custom Tools](advanced.html#Custom_Tools) |
@@ -651,10 +687,12 @@ Complete list of all `SessionConfig` options for `createSession()`:
651687
| `streaming` | boolean | Enable streaming response chunks | [Streaming Responses](#Streaming_Responses) |
652688
| `mcpServers` | Map&lt;String, Object&gt; | MCP server configurations | [MCP Servers](mcp.html) |
653689
| `customAgents` | List&lt;CustomAgentConfig&gt; | Custom agent definitions | [Custom Agents](advanced.html#Custom_Agents) |
690+
| `agent` | String | Pre-select a custom agent at session start | [Custom Agents](advanced.html#Custom_Agents) |
654691
| `infiniteSessions` | InfiniteSessionConfig | Auto-compaction for long conversations | [Infinite Sessions](advanced.html#Infinite_Sessions) |
655692
| `skillDirectories` | List&lt;String&gt; | Directories to load skills from | [Skills](advanced.html#Skills_Configuration) |
656693
| `disabledSkills` | List&lt;String&gt; | Skills to disable by name | [Skills](advanced.html#Skills_Configuration) |
657694
| `configDir` | String | Custom configuration directory | [Config Dir](advanced.html#Custom_Configuration_Directory) |
695+
| `onEvent` | Consumer&lt;AbstractSessionEvent&gt; | Event handler registered before session creation | [Early Event Registration](advanced.html#Early_Event_Registration) |
658696

659697
### Cloning SessionConfig
660698

src/site/markdown/setup.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,7 @@ Complete list of `CopilotClientOptions` settings:
349349
| `logLevel` | String | CLI log level | `"info"` |
350350
| `environment` | Map | Environment variables | inherited |
351351
| `cwd` | String | Working directory | current dir |
352+
| `onListModels` | Supplier | Custom model listing implementation | `null` (use CLI) |
352353

353354
### Extra CLI Arguments
354355

0 commit comments

Comments
 (0)