@github/copilot-sdk 0.3.0-preview.0 → 0.3.0-preview.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/cjs/client.js +21 -12
- package/dist/cjs/generated/rpc.js +16 -5
- package/dist/cjs/session.js +3 -3
- package/dist/cjs/types.js +1 -1
- package/dist/client.js +21 -12
- package/dist/generated/rpc.d.ts +222 -65
- package/dist/generated/rpc.js +16 -5
- package/dist/generated/session-events.d.ts +379 -6
- package/dist/session.js +3 -3
- package/dist/types.d.ts +24 -4
- package/dist/types.js +1 -1
- package/package.json +2 -2
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* AUTO-GENERATED FILE - DO NOT EDIT
|
|
3
3
|
* Generated from: session-events.schema.json
|
|
4
4
|
*/
|
|
5
|
-
export type SessionEvent = StartEvent | ResumeEvent | RemoteSteerableChangedEvent | ErrorEvent | IdleEvent | TitleChangedEvent | InfoEvent | WarningEvent | ModelChangeEvent | ModeChangedEvent | PlanChangedEvent | WorkspaceFileChangedEvent | HandoffEvent | TruncationEvent | SnapshotRewindEvent | ShutdownEvent | ContextChangedEvent | UsageInfoEvent | CompactionStartEvent | CompactionCompleteEvent | TaskCompleteEvent | UserMessageEvent | PendingMessagesModifiedEvent | AssistantTurnStartEvent | AssistantIntentEvent | AssistantReasoningEvent | AssistantReasoningDeltaEvent | AssistantStreamingDeltaEvent | AssistantMessageEvent | AssistantMessageDeltaEvent | AssistantTurnEndEvent | AssistantUsageEvent | AbortEvent | ToolUserRequestedEvent | ToolExecutionStartEvent | ToolExecutionPartialResultEvent | ToolExecutionProgressEvent | ToolExecutionCompleteEvent | SkillInvokedEvent | SubagentStartedEvent | SubagentCompletedEvent | SubagentFailedEvent | SubagentSelectedEvent | SubagentDeselectedEvent | HookStartEvent | HookEndEvent | SystemMessageEvent | SystemNotificationEvent | PermissionRequestedEvent | PermissionCompletedEvent | UserInputRequestedEvent | UserInputCompletedEvent | ElicitationRequestedEvent | ElicitationCompletedEvent | SamplingRequestedEvent | SamplingCompletedEvent | McpOauthRequiredEvent | McpOauthCompletedEvent | ExternalToolRequestedEvent | ExternalToolCompletedEvent | CommandQueuedEvent | CommandExecuteEvent | CommandCompletedEvent | CommandsChangedEvent | CapabilitiesChangedEvent | ExitPlanModeRequestedEvent | ExitPlanModeCompletedEvent | ToolsUpdatedEvent | BackgroundTasksChangedEvent | SkillsLoadedEvent | CustomAgentsUpdatedEvent | McpServersLoadedEvent | McpServerStatusChangedEvent | ExtensionsLoadedEvent;
|
|
5
|
+
export type SessionEvent = StartEvent | ResumeEvent | RemoteSteerableChangedEvent | ErrorEvent | IdleEvent | TitleChangedEvent | InfoEvent | WarningEvent | ModelChangeEvent | ModeChangedEvent | PlanChangedEvent | WorkspaceFileChangedEvent | HandoffEvent | TruncationEvent | SnapshotRewindEvent | ShutdownEvent | ContextChangedEvent | UsageInfoEvent | CompactionStartEvent | CompactionCompleteEvent | TaskCompleteEvent | UserMessageEvent | PendingMessagesModifiedEvent | AssistantTurnStartEvent | AssistantIntentEvent | AssistantReasoningEvent | AssistantReasoningDeltaEvent | AssistantStreamingDeltaEvent | AssistantMessageEvent | AssistantMessageDeltaEvent | AssistantTurnEndEvent | AssistantUsageEvent | AbortEvent | ToolUserRequestedEvent | ToolExecutionStartEvent | ToolExecutionPartialResultEvent | ToolExecutionProgressEvent | ToolExecutionCompleteEvent | SkillInvokedEvent | SubagentStartedEvent | SubagentCompletedEvent | SubagentFailedEvent | SubagentSelectedEvent | SubagentDeselectedEvent | HookStartEvent | HookEndEvent | SystemMessageEvent | SystemNotificationEvent | PermissionRequestedEvent | PermissionCompletedEvent | UserInputRequestedEvent | UserInputCompletedEvent | ElicitationRequestedEvent | ElicitationCompletedEvent | SamplingRequestedEvent | SamplingCompletedEvent | McpOauthRequiredEvent | McpOauthCompletedEvent | ExternalToolRequestedEvent | ExternalToolCompletedEvent | CommandQueuedEvent | CommandExecuteEvent | CommandCompletedEvent | AutoModeSwitchRequestedEvent | AutoModeSwitchCompletedEvent | CommandsChangedEvent | CapabilitiesChangedEvent | ExitPlanModeRequestedEvent | ExitPlanModeCompletedEvent | ToolsUpdatedEvent | BackgroundTasksChangedEvent | SkillsLoadedEvent | CustomAgentsUpdatedEvent | McpServersLoadedEvent | McpServerStatusChangedEvent | ExtensionsLoadedEvent;
|
|
6
6
|
/**
|
|
7
7
|
* Hosting platform type of the repository (github or ado)
|
|
8
8
|
*/
|
|
@@ -75,10 +75,26 @@ export type PermissionRequestMemoryAction = "store" | "vote";
|
|
|
75
75
|
* Vote direction (vote only)
|
|
76
76
|
*/
|
|
77
77
|
export type PermissionRequestMemoryDirection = "upvote" | "downvote";
|
|
78
|
+
/**
|
|
79
|
+
* Derived user-facing permission prompt details for UI consumers
|
|
80
|
+
*/
|
|
81
|
+
export type PermissionPromptRequest = PermissionPromptRequestCommands | PermissionPromptRequestWrite | PermissionPromptRequestRead | PermissionPromptRequestMcp | PermissionPromptRequestUrl | PermissionPromptRequestMemory | PermissionPromptRequestCustomTool | PermissionPromptRequestPath | PermissionPromptRequestHook;
|
|
82
|
+
/**
|
|
83
|
+
* Whether this is a store or vote memory operation
|
|
84
|
+
*/
|
|
85
|
+
export type PermissionPromptRequestMemoryAction = "store" | "vote";
|
|
86
|
+
/**
|
|
87
|
+
* Vote direction (vote only)
|
|
88
|
+
*/
|
|
89
|
+
export type PermissionPromptRequestMemoryDirection = "upvote" | "downvote";
|
|
90
|
+
/**
|
|
91
|
+
* Underlying permission kind that needs path approval
|
|
92
|
+
*/
|
|
93
|
+
export type PermissionPromptRequestPathAccessKind = "read" | "shell" | "write";
|
|
78
94
|
/**
|
|
79
95
|
* The outcome of the permission request
|
|
80
96
|
*/
|
|
81
|
-
export type PermissionCompletedKind = "approved" | "denied-by-rules" | "denied-no-approval-rule-and-could-not-request-from-user" | "denied-interactively-by-user" | "denied-by-content-exclusion-policy" | "denied-by-permission-request-hook";
|
|
97
|
+
export type PermissionCompletedKind = "approved" | "approved-for-session" | "approved-for-location" | "denied-by-rules" | "denied-no-approval-rule-and-could-not-request-from-user" | "denied-interactively-by-user" | "denied-by-content-exclusion-policy" | "denied-by-permission-request-hook";
|
|
82
98
|
/**
|
|
83
99
|
* Elicitation mode; "form" for structured input, "url" for browser-based. Defaults to "form" when absent.
|
|
84
100
|
*/
|
|
@@ -1133,21 +1149,68 @@ export interface CompactionCompleteData {
|
|
|
1133
1149
|
toolDefinitionsTokens?: number;
|
|
1134
1150
|
}
|
|
1135
1151
|
/**
|
|
1136
|
-
* Token usage breakdown for the compaction LLM call
|
|
1152
|
+
* Token usage breakdown for the compaction LLM call (aligned with assistant.usage format)
|
|
1137
1153
|
*/
|
|
1138
1154
|
export interface CompactionCompleteCompactionTokensUsed {
|
|
1139
1155
|
/**
|
|
1140
1156
|
* Cached input tokens reused in the compaction LLM call
|
|
1141
1157
|
*/
|
|
1142
|
-
|
|
1158
|
+
cacheReadTokens?: number;
|
|
1159
|
+
/**
|
|
1160
|
+
* Tokens written to prompt cache in the compaction LLM call
|
|
1161
|
+
*/
|
|
1162
|
+
cacheWriteTokens?: number;
|
|
1163
|
+
copilotUsage?: CompactionCompleteCompactionTokensUsedCopilotUsage;
|
|
1164
|
+
/**
|
|
1165
|
+
* Duration of the compaction LLM call in milliseconds
|
|
1166
|
+
*/
|
|
1167
|
+
duration?: number;
|
|
1143
1168
|
/**
|
|
1144
1169
|
* Input tokens consumed by the compaction LLM call
|
|
1145
1170
|
*/
|
|
1146
|
-
|
|
1171
|
+
inputTokens?: number;
|
|
1172
|
+
/**
|
|
1173
|
+
* Model identifier used for the compaction LLM call
|
|
1174
|
+
*/
|
|
1175
|
+
model?: string;
|
|
1147
1176
|
/**
|
|
1148
1177
|
* Output tokens produced by the compaction LLM call
|
|
1149
1178
|
*/
|
|
1150
|
-
|
|
1179
|
+
outputTokens?: number;
|
|
1180
|
+
}
|
|
1181
|
+
/**
|
|
1182
|
+
* Per-request cost and usage data from the CAPI copilot_usage response field
|
|
1183
|
+
*/
|
|
1184
|
+
export interface CompactionCompleteCompactionTokensUsedCopilotUsage {
|
|
1185
|
+
/**
|
|
1186
|
+
* Itemized token usage breakdown
|
|
1187
|
+
*/
|
|
1188
|
+
tokenDetails: CompactionCompleteCompactionTokensUsedCopilotUsageTokenDetail[];
|
|
1189
|
+
/**
|
|
1190
|
+
* Total cost in nano-AIU (AI Units) for this request
|
|
1191
|
+
*/
|
|
1192
|
+
totalNanoAiu: number;
|
|
1193
|
+
}
|
|
1194
|
+
/**
|
|
1195
|
+
* Token usage detail for a single billing category
|
|
1196
|
+
*/
|
|
1197
|
+
export interface CompactionCompleteCompactionTokensUsedCopilotUsageTokenDetail {
|
|
1198
|
+
/**
|
|
1199
|
+
* Number of tokens in this billing batch
|
|
1200
|
+
*/
|
|
1201
|
+
batchSize: number;
|
|
1202
|
+
/**
|
|
1203
|
+
* Cost per batch of tokens
|
|
1204
|
+
*/
|
|
1205
|
+
costPerBatch: number;
|
|
1206
|
+
/**
|
|
1207
|
+
* Total token count for this entry
|
|
1208
|
+
*/
|
|
1209
|
+
tokenCount: number;
|
|
1210
|
+
/**
|
|
1211
|
+
* Token category (e.g., "input", "output")
|
|
1212
|
+
*/
|
|
1213
|
+
tokenType: string;
|
|
1151
1214
|
}
|
|
1152
1215
|
export interface TaskCompleteEvent {
|
|
1153
1216
|
/**
|
|
@@ -2966,6 +3029,7 @@ export interface PermissionRequestedEvent {
|
|
|
2966
3029
|
*/
|
|
2967
3030
|
export interface PermissionRequestedData {
|
|
2968
3031
|
permissionRequest: PermissionRequest;
|
|
3032
|
+
promptRequest?: PermissionPromptRequest;
|
|
2969
3033
|
/**
|
|
2970
3034
|
* Unique identifier for this permission request; used to respond via session.respondToPermission()
|
|
2971
3035
|
*/
|
|
@@ -3231,6 +3295,243 @@ export interface PermissionRequestHook {
|
|
|
3231
3295
|
*/
|
|
3232
3296
|
toolName: string;
|
|
3233
3297
|
}
|
|
3298
|
+
/**
|
|
3299
|
+
* Shell command permission prompt
|
|
3300
|
+
*/
|
|
3301
|
+
export interface PermissionPromptRequestCommands {
|
|
3302
|
+
/**
|
|
3303
|
+
* Whether the UI can offer session-wide approval for this command pattern
|
|
3304
|
+
*/
|
|
3305
|
+
canOfferSessionApproval: boolean;
|
|
3306
|
+
/**
|
|
3307
|
+
* Command identifiers covered by this approval prompt
|
|
3308
|
+
*/
|
|
3309
|
+
commandIdentifiers: string[];
|
|
3310
|
+
/**
|
|
3311
|
+
* The complete shell command text to be executed
|
|
3312
|
+
*/
|
|
3313
|
+
fullCommandText: string;
|
|
3314
|
+
/**
|
|
3315
|
+
* Human-readable description of what the command intends to do
|
|
3316
|
+
*/
|
|
3317
|
+
intention: string;
|
|
3318
|
+
/**
|
|
3319
|
+
* Prompt kind discriminator
|
|
3320
|
+
*/
|
|
3321
|
+
kind: "commands";
|
|
3322
|
+
/**
|
|
3323
|
+
* Tool call ID that triggered this permission request
|
|
3324
|
+
*/
|
|
3325
|
+
toolCallId?: string;
|
|
3326
|
+
/**
|
|
3327
|
+
* Optional warning message about risks of running this command
|
|
3328
|
+
*/
|
|
3329
|
+
warning?: string;
|
|
3330
|
+
}
|
|
3331
|
+
/**
|
|
3332
|
+
* File write permission prompt
|
|
3333
|
+
*/
|
|
3334
|
+
export interface PermissionPromptRequestWrite {
|
|
3335
|
+
/**
|
|
3336
|
+
* Whether the UI can offer session-wide approval for file write operations
|
|
3337
|
+
*/
|
|
3338
|
+
canOfferSessionApproval: boolean;
|
|
3339
|
+
/**
|
|
3340
|
+
* Unified diff showing the proposed changes
|
|
3341
|
+
*/
|
|
3342
|
+
diff: string;
|
|
3343
|
+
/**
|
|
3344
|
+
* Path of the file being written to
|
|
3345
|
+
*/
|
|
3346
|
+
fileName: string;
|
|
3347
|
+
/**
|
|
3348
|
+
* Human-readable description of the intended file change
|
|
3349
|
+
*/
|
|
3350
|
+
intention: string;
|
|
3351
|
+
/**
|
|
3352
|
+
* Prompt kind discriminator
|
|
3353
|
+
*/
|
|
3354
|
+
kind: "write";
|
|
3355
|
+
/**
|
|
3356
|
+
* Complete new file contents for newly created files
|
|
3357
|
+
*/
|
|
3358
|
+
newFileContents?: string;
|
|
3359
|
+
/**
|
|
3360
|
+
* Tool call ID that triggered this permission request
|
|
3361
|
+
*/
|
|
3362
|
+
toolCallId?: string;
|
|
3363
|
+
}
|
|
3364
|
+
/**
|
|
3365
|
+
* File read permission prompt
|
|
3366
|
+
*/
|
|
3367
|
+
export interface PermissionPromptRequestRead {
|
|
3368
|
+
/**
|
|
3369
|
+
* Human-readable description of why the file is being read
|
|
3370
|
+
*/
|
|
3371
|
+
intention: string;
|
|
3372
|
+
/**
|
|
3373
|
+
* Prompt kind discriminator
|
|
3374
|
+
*/
|
|
3375
|
+
kind: "read";
|
|
3376
|
+
/**
|
|
3377
|
+
* Path of the file or directory being read
|
|
3378
|
+
*/
|
|
3379
|
+
path: string;
|
|
3380
|
+
/**
|
|
3381
|
+
* Tool call ID that triggered this permission request
|
|
3382
|
+
*/
|
|
3383
|
+
toolCallId?: string;
|
|
3384
|
+
}
|
|
3385
|
+
/**
|
|
3386
|
+
* MCP tool invocation permission prompt
|
|
3387
|
+
*/
|
|
3388
|
+
export interface PermissionPromptRequestMcp {
|
|
3389
|
+
args?: unknown;
|
|
3390
|
+
/**
|
|
3391
|
+
* Prompt kind discriminator
|
|
3392
|
+
*/
|
|
3393
|
+
kind: "mcp";
|
|
3394
|
+
/**
|
|
3395
|
+
* Name of the MCP server providing the tool
|
|
3396
|
+
*/
|
|
3397
|
+
serverName: string;
|
|
3398
|
+
/**
|
|
3399
|
+
* Tool call ID that triggered this permission request
|
|
3400
|
+
*/
|
|
3401
|
+
toolCallId?: string;
|
|
3402
|
+
/**
|
|
3403
|
+
* Internal name of the MCP tool
|
|
3404
|
+
*/
|
|
3405
|
+
toolName: string;
|
|
3406
|
+
/**
|
|
3407
|
+
* Human-readable title of the MCP tool
|
|
3408
|
+
*/
|
|
3409
|
+
toolTitle: string;
|
|
3410
|
+
}
|
|
3411
|
+
/**
|
|
3412
|
+
* URL access permission prompt
|
|
3413
|
+
*/
|
|
3414
|
+
export interface PermissionPromptRequestUrl {
|
|
3415
|
+
/**
|
|
3416
|
+
* Human-readable description of why the URL is being accessed
|
|
3417
|
+
*/
|
|
3418
|
+
intention: string;
|
|
3419
|
+
/**
|
|
3420
|
+
* Prompt kind discriminator
|
|
3421
|
+
*/
|
|
3422
|
+
kind: "url";
|
|
3423
|
+
/**
|
|
3424
|
+
* Tool call ID that triggered this permission request
|
|
3425
|
+
*/
|
|
3426
|
+
toolCallId?: string;
|
|
3427
|
+
/**
|
|
3428
|
+
* URL to be fetched
|
|
3429
|
+
*/
|
|
3430
|
+
url: string;
|
|
3431
|
+
}
|
|
3432
|
+
/**
|
|
3433
|
+
* Memory operation permission prompt
|
|
3434
|
+
*/
|
|
3435
|
+
export interface PermissionPromptRequestMemory {
|
|
3436
|
+
action?: PermissionPromptRequestMemoryAction;
|
|
3437
|
+
/**
|
|
3438
|
+
* Source references for the stored fact (store only)
|
|
3439
|
+
*/
|
|
3440
|
+
citations?: string;
|
|
3441
|
+
direction?: PermissionPromptRequestMemoryDirection;
|
|
3442
|
+
/**
|
|
3443
|
+
* The fact being stored or voted on
|
|
3444
|
+
*/
|
|
3445
|
+
fact: string;
|
|
3446
|
+
/**
|
|
3447
|
+
* Prompt kind discriminator
|
|
3448
|
+
*/
|
|
3449
|
+
kind: "memory";
|
|
3450
|
+
/**
|
|
3451
|
+
* Reason for the vote (vote only)
|
|
3452
|
+
*/
|
|
3453
|
+
reason?: string;
|
|
3454
|
+
/**
|
|
3455
|
+
* Topic or subject of the memory (store only)
|
|
3456
|
+
*/
|
|
3457
|
+
subject?: string;
|
|
3458
|
+
/**
|
|
3459
|
+
* Tool call ID that triggered this permission request
|
|
3460
|
+
*/
|
|
3461
|
+
toolCallId?: string;
|
|
3462
|
+
}
|
|
3463
|
+
/**
|
|
3464
|
+
* Custom tool invocation permission prompt
|
|
3465
|
+
*/
|
|
3466
|
+
export interface PermissionPromptRequestCustomTool {
|
|
3467
|
+
/**
|
|
3468
|
+
* Arguments to pass to the custom tool
|
|
3469
|
+
*/
|
|
3470
|
+
args?: {
|
|
3471
|
+
[k: string]: unknown;
|
|
3472
|
+
};
|
|
3473
|
+
/**
|
|
3474
|
+
* Prompt kind discriminator
|
|
3475
|
+
*/
|
|
3476
|
+
kind: "custom-tool";
|
|
3477
|
+
/**
|
|
3478
|
+
* Tool call ID that triggered this permission request
|
|
3479
|
+
*/
|
|
3480
|
+
toolCallId?: string;
|
|
3481
|
+
/**
|
|
3482
|
+
* Description of what the custom tool does
|
|
3483
|
+
*/
|
|
3484
|
+
toolDescription: string;
|
|
3485
|
+
/**
|
|
3486
|
+
* Name of the custom tool
|
|
3487
|
+
*/
|
|
3488
|
+
toolName: string;
|
|
3489
|
+
}
|
|
3490
|
+
/**
|
|
3491
|
+
* Path access permission prompt
|
|
3492
|
+
*/
|
|
3493
|
+
export interface PermissionPromptRequestPath {
|
|
3494
|
+
accessKind: PermissionPromptRequestPathAccessKind;
|
|
3495
|
+
/**
|
|
3496
|
+
* Prompt kind discriminator
|
|
3497
|
+
*/
|
|
3498
|
+
kind: "path";
|
|
3499
|
+
/**
|
|
3500
|
+
* File paths that require explicit approval
|
|
3501
|
+
*/
|
|
3502
|
+
paths: string[];
|
|
3503
|
+
/**
|
|
3504
|
+
* Tool call ID that triggered this permission request
|
|
3505
|
+
*/
|
|
3506
|
+
toolCallId?: string;
|
|
3507
|
+
}
|
|
3508
|
+
/**
|
|
3509
|
+
* Hook confirmation permission prompt
|
|
3510
|
+
*/
|
|
3511
|
+
export interface PermissionPromptRequestHook {
|
|
3512
|
+
/**
|
|
3513
|
+
* Optional message from the hook explaining why confirmation is needed
|
|
3514
|
+
*/
|
|
3515
|
+
hookMessage?: string;
|
|
3516
|
+
/**
|
|
3517
|
+
* Prompt kind discriminator
|
|
3518
|
+
*/
|
|
3519
|
+
kind: "hook";
|
|
3520
|
+
/**
|
|
3521
|
+
* Arguments of the tool call being gated
|
|
3522
|
+
*/
|
|
3523
|
+
toolArgs?: {
|
|
3524
|
+
[k: string]: unknown;
|
|
3525
|
+
};
|
|
3526
|
+
/**
|
|
3527
|
+
* Tool call ID that triggered this permission request
|
|
3528
|
+
*/
|
|
3529
|
+
toolCallId?: string;
|
|
3530
|
+
/**
|
|
3531
|
+
* Name of the tool the hook is gating
|
|
3532
|
+
*/
|
|
3533
|
+
toolName: string;
|
|
3534
|
+
}
|
|
3234
3535
|
export interface PermissionCompletedEvent {
|
|
3235
3536
|
/**
|
|
3236
3537
|
* Sub-agent instance identifier. Absent for events from the root/main agent and session-level events.
|
|
@@ -3261,6 +3562,10 @@ export interface PermissionCompletedData {
|
|
|
3261
3562
|
*/
|
|
3262
3563
|
requestId: string;
|
|
3263
3564
|
result: PermissionCompletedResult;
|
|
3565
|
+
/**
|
|
3566
|
+
* Optional tool call ID associated with this permission prompt; clients may use it to correlate UI created from tool-scoped prompts
|
|
3567
|
+
*/
|
|
3568
|
+
toolCallId?: string;
|
|
3264
3569
|
}
|
|
3265
3570
|
/**
|
|
3266
3571
|
* The result of the permission request
|
|
@@ -3800,6 +4105,74 @@ export interface CommandCompletedData {
|
|
|
3800
4105
|
*/
|
|
3801
4106
|
requestId: string;
|
|
3802
4107
|
}
|
|
4108
|
+
export interface AutoModeSwitchRequestedEvent {
|
|
4109
|
+
/**
|
|
4110
|
+
* Sub-agent instance identifier. Absent for events from the root/main agent and session-level events.
|
|
4111
|
+
*/
|
|
4112
|
+
agentId?: string;
|
|
4113
|
+
data: AutoModeSwitchRequestedData;
|
|
4114
|
+
ephemeral: true;
|
|
4115
|
+
/**
|
|
4116
|
+
* Unique event identifier (UUID v4), generated when the event is emitted
|
|
4117
|
+
*/
|
|
4118
|
+
id: string;
|
|
4119
|
+
/**
|
|
4120
|
+
* ID of the chronologically preceding event in the session, forming a linked chain. Null for the first event.
|
|
4121
|
+
*/
|
|
4122
|
+
parentId: string | null;
|
|
4123
|
+
/**
|
|
4124
|
+
* ISO 8601 timestamp when the event was created
|
|
4125
|
+
*/
|
|
4126
|
+
timestamp: string;
|
|
4127
|
+
type: "auto_mode_switch.requested";
|
|
4128
|
+
}
|
|
4129
|
+
/**
|
|
4130
|
+
* Auto mode switch request notification requiring user approval
|
|
4131
|
+
*/
|
|
4132
|
+
export interface AutoModeSwitchRequestedData {
|
|
4133
|
+
/**
|
|
4134
|
+
* The rate limit error code that triggered this request
|
|
4135
|
+
*/
|
|
4136
|
+
errorCode?: string;
|
|
4137
|
+
/**
|
|
4138
|
+
* Unique identifier for this request; used to respond via session.respondToAutoModeSwitch()
|
|
4139
|
+
*/
|
|
4140
|
+
requestId: string;
|
|
4141
|
+
}
|
|
4142
|
+
export interface AutoModeSwitchCompletedEvent {
|
|
4143
|
+
/**
|
|
4144
|
+
* Sub-agent instance identifier. Absent for events from the root/main agent and session-level events.
|
|
4145
|
+
*/
|
|
4146
|
+
agentId?: string;
|
|
4147
|
+
data: AutoModeSwitchCompletedData;
|
|
4148
|
+
ephemeral: true;
|
|
4149
|
+
/**
|
|
4150
|
+
* Unique event identifier (UUID v4), generated when the event is emitted
|
|
4151
|
+
*/
|
|
4152
|
+
id: string;
|
|
4153
|
+
/**
|
|
4154
|
+
* ID of the chronologically preceding event in the session, forming a linked chain. Null for the first event.
|
|
4155
|
+
*/
|
|
4156
|
+
parentId: string | null;
|
|
4157
|
+
/**
|
|
4158
|
+
* ISO 8601 timestamp when the event was created
|
|
4159
|
+
*/
|
|
4160
|
+
timestamp: string;
|
|
4161
|
+
type: "auto_mode_switch.completed";
|
|
4162
|
+
}
|
|
4163
|
+
/**
|
|
4164
|
+
* Auto mode switch completion notification
|
|
4165
|
+
*/
|
|
4166
|
+
export interface AutoModeSwitchCompletedData {
|
|
4167
|
+
/**
|
|
4168
|
+
* Request ID of the resolved request; clients should dismiss any UI for this request
|
|
4169
|
+
*/
|
|
4170
|
+
requestId: string;
|
|
4171
|
+
/**
|
|
4172
|
+
* The user's choice: 'yes', 'yes_always', or 'no'
|
|
4173
|
+
*/
|
|
4174
|
+
response: string;
|
|
4175
|
+
}
|
|
3803
4176
|
export interface CommandsChangedEvent {
|
|
3804
4177
|
/**
|
|
3805
4178
|
* Sub-agent instance identifier. Absent for events from the root/main agent and session-level events.
|
package/dist/session.js
CHANGED
|
@@ -325,7 +325,7 @@ class CopilotSession {
|
|
|
325
325
|
await this.rpc.permissions.handlePendingPermissionRequest({
|
|
326
326
|
requestId,
|
|
327
327
|
result: {
|
|
328
|
-
kind: "
|
|
328
|
+
kind: "user-not-available"
|
|
329
329
|
}
|
|
330
330
|
});
|
|
331
331
|
} catch (rpcError) {
|
|
@@ -603,7 +603,7 @@ class CopilotSession {
|
|
|
603
603
|
*/
|
|
604
604
|
async _handlePermissionRequestV2(request) {
|
|
605
605
|
if (!this.permissionHandler) {
|
|
606
|
-
return { kind: "
|
|
606
|
+
return { kind: "user-not-available" };
|
|
607
607
|
}
|
|
608
608
|
try {
|
|
609
609
|
const result = await this.permissionHandler(request, {
|
|
@@ -617,7 +617,7 @@ class CopilotSession {
|
|
|
617
617
|
if (error instanceof Error && error.message === NO_RESULT_PERMISSION_V2_ERROR) {
|
|
618
618
|
throw error;
|
|
619
619
|
}
|
|
620
|
-
return { kind: "
|
|
620
|
+
return { kind: "user-not-available" };
|
|
621
621
|
}
|
|
622
622
|
}
|
|
623
623
|
/**
|
package/dist/types.d.ts
CHANGED
|
@@ -105,12 +105,12 @@ export interface CopilotClientOptions {
|
|
|
105
105
|
* When provided, the token is passed to the CLI server via environment variable.
|
|
106
106
|
* This takes priority over other authentication methods.
|
|
107
107
|
*/
|
|
108
|
-
|
|
108
|
+
gitHubToken?: string;
|
|
109
109
|
/**
|
|
110
110
|
* Whether to use the logged-in user for authentication.
|
|
111
111
|
* When true, the CLI server will attempt to use stored OAuth tokens or gh CLI auth.
|
|
112
|
-
* When false, only explicit tokens (
|
|
113
|
-
* @default true (but defaults to false when
|
|
112
|
+
* When false, only explicit tokens (gitHubToken or environment variables) are used.
|
|
113
|
+
* @default true (but defaults to false when gitHubToken is provided)
|
|
114
114
|
*/
|
|
115
115
|
useLoggedInUser?: boolean;
|
|
116
116
|
/**
|
|
@@ -158,6 +158,15 @@ export interface CopilotClientOptions {
|
|
|
158
158
|
* instead of the server's default local filesystem storage.
|
|
159
159
|
*/
|
|
160
160
|
sessionFs?: SessionFsConfig;
|
|
161
|
+
/**
|
|
162
|
+
* Server-wide idle timeout for sessions in seconds.
|
|
163
|
+
* Sessions without activity for this duration are automatically cleaned up.
|
|
164
|
+
* Set to 0 or omit to disable (sessions live indefinitely).
|
|
165
|
+
* This option is only used when the SDK spawns the CLI process; it is ignored
|
|
166
|
+
* when connecting to an external server via {@link cliUrl}.
|
|
167
|
+
* @default undefined (disabled)
|
|
168
|
+
*/
|
|
169
|
+
sessionIdleTimeoutSeconds?: number;
|
|
161
170
|
}
|
|
162
171
|
/**
|
|
163
172
|
* Configuration for creating a session
|
|
@@ -1060,6 +1069,17 @@ export interface SessionConfig {
|
|
|
1060
1069
|
* Set to `{ enabled: false }` to disable.
|
|
1061
1070
|
*/
|
|
1062
1071
|
infiniteSessions?: InfiniteSessionConfig;
|
|
1072
|
+
/**
|
|
1073
|
+
* GitHub token for per-session authentication.
|
|
1074
|
+
* When provided, the runtime resolves this token into a full GitHub identity
|
|
1075
|
+
* (login, Copilot plan, endpoints) and stores it on the session. This enables
|
|
1076
|
+
* multitenancy — different sessions can have different GitHub identities.
|
|
1077
|
+
*
|
|
1078
|
+
* This is independent of the client-level `gitHubToken` in {@link CopilotClientOptions},
|
|
1079
|
+
* which authenticates the CLI process itself. The session-level token determines
|
|
1080
|
+
* the identity used for content exclusion, model routing, and quota checks.
|
|
1081
|
+
*/
|
|
1082
|
+
gitHubToken?: string;
|
|
1063
1083
|
/**
|
|
1064
1084
|
* Optional event handler that is registered on the session before the
|
|
1065
1085
|
* session.create RPC is issued. This guarantees that early events emitted
|
|
@@ -1079,7 +1099,7 @@ export interface SessionConfig {
|
|
|
1079
1099
|
/**
|
|
1080
1100
|
* Configuration for resuming a session
|
|
1081
1101
|
*/
|
|
1082
|
-
export type ResumeSessionConfig = Pick<SessionConfig, "clientName" | "model" | "tools" | "commands" | "systemMessage" | "availableTools" | "excludedTools" | "provider" | "modelCapabilities" | "streaming" | "includeSubAgentStreamingEvents" | "reasoningEffort" | "onPermissionRequest" | "onUserInputRequest" | "onElicitationRequest" | "hooks" | "workingDirectory" | "configDir" | "enableConfigDiscovery" | "mcpServers" | "customAgents" | "defaultAgent" | "agent" | "skillDirectories" | "disabledSkills" | "infiniteSessions" | "onEvent" | "createSessionFsHandler"> & {
|
|
1102
|
+
export type ResumeSessionConfig = Pick<SessionConfig, "clientName" | "model" | "tools" | "commands" | "systemMessage" | "availableTools" | "excludedTools" | "provider" | "modelCapabilities" | "streaming" | "includeSubAgentStreamingEvents" | "reasoningEffort" | "onPermissionRequest" | "onUserInputRequest" | "onElicitationRequest" | "hooks" | "workingDirectory" | "configDir" | "enableConfigDiscovery" | "mcpServers" | "customAgents" | "defaultAgent" | "agent" | "skillDirectories" | "disabledSkills" | "infiniteSessions" | "gitHubToken" | "onEvent" | "createSessionFsHandler"> & {
|
|
1083
1103
|
/**
|
|
1084
1104
|
* When true, skips emitting the session.resume event.
|
|
1085
1105
|
* Useful for reconnecting to a session without triggering resume-related side effects.
|
package/dist/types.js
CHANGED
|
@@ -57,7 +57,7 @@ const SYSTEM_PROMPT_SECTIONS = {
|
|
|
57
57
|
description: "End-of-prompt instructions: parallel tool calling, persistence, task completion"
|
|
58
58
|
}
|
|
59
59
|
};
|
|
60
|
-
const approveAll = () => ({ kind: "
|
|
60
|
+
const approveAll = () => ({ kind: "approve-once" });
|
|
61
61
|
const defaultJoinSessionPermissionHandler = () => ({
|
|
62
62
|
kind: "no-result"
|
|
63
63
|
});
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"type": "git",
|
|
5
5
|
"url": "https://github.com/github/copilot-sdk.git"
|
|
6
6
|
},
|
|
7
|
-
"version": "0.3.0-preview.
|
|
7
|
+
"version": "0.3.0-preview.1",
|
|
8
8
|
"description": "TypeScript SDK for programmatic control of GitHub Copilot CLI via JSON-RPC",
|
|
9
9
|
"main": "./dist/cjs/index.js",
|
|
10
10
|
"types": "./dist/index.d.ts",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"author": "GitHub",
|
|
57
57
|
"license": "MIT",
|
|
58
58
|
"dependencies": {
|
|
59
|
-
"@github/copilot": "^1.0.
|
|
59
|
+
"@github/copilot": "^1.0.36-0",
|
|
60
60
|
"vscode-jsonrpc": "^8.2.1",
|
|
61
61
|
"zod": "^4.3.6"
|
|
62
62
|
},
|