@github/copilot-sdk 1.0.18-preview.3 → 1.0.18-preview.4
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 +5 -0
- package/dist/cjs/cliVersion.js +1 -1
- package/dist/cjs/generated/rpc.js +41 -1
- package/dist/cjs/session.js +52 -3
- package/dist/cliVersion.d.ts +1 -1
- package/dist/cliVersion.js +1 -1
- package/dist/generated/rpc.d.ts +452 -245
- package/dist/generated/rpc.js +41 -1
- package/dist/generated/session-events.d.ts +528 -1
- package/dist/session.d.ts +3 -0
- package/dist/session.js +52 -3
- package/package.json +12 -12
|
@@ -9,7 +9,7 @@ export type JsonValue = null | boolean | number | string | JsonValue[] | {
|
|
|
9
9
|
/**
|
|
10
10
|
* Union of all session event variants emitted by the Copilot CLI runtime.
|
|
11
11
|
*/
|
|
12
|
-
export type SessionEvent = StartEvent | ResumeEvent | RemoteSteerableChangedEvent | ErrorEvent | IdleEvent | TitleChangedEvent | ScheduleCreatedEvent | ScheduleCancelledEvent | ScheduleRearmedEvent | AutopilotObjectiveChangedEvent | InfoEvent | IndexedSearchEvent | WarningEvent | ModelChangeEvent | ModelDeselectedEvent | AutoTierRecommendationEvent | AutoTierSwitchFailedEvent | ModeChangedEvent | ModeNoticeDeliveredEvent | SessionLimitsChangedEvent | PermissionsChangedEvent | PlanChangedEvent | TodosChangedEvent | WorkspaceFileChangedEvent | HandoffEvent | TruncationEvent | SnapshotRewindEvent | ShutdownEvent | UsageCheckpointEvent | ContextChangedEvent | UsageInfoEvent | ContextClearedEvent | CompactionStartEvent | CompactionCompleteEvent | TaskCompleteEvent | CompletionReceiptEvent | FusionRouteStartedEvent | FusionRouteFailedEvent | FusionResolvedEvent | FusionCompletedEvent | PermissionRecoveryEvent | UserMessageEvent | PendingMessagesModifiedEvent | AssistantTurnStartEvent | AssistantIntentEvent | AssistantFusionPhaseStartedEvent | AssistantFusionPhaseActivityEvent | AssistantFusionPhaseCompletedEvent | AssistantFusionPhaseFailedEvent | AssistantServerToolProgressEvent | AssistantReasoningEvent | AssistantReasoningDeltaEvent | AssistantToolCallDeltaEvent | AssistantStreamingDeltaEvent | AssistantMessageEvent | AssistantMessageStartEvent | AssistantMessageDeltaEvent | AssistantTurnEndEvent | AssistantIdleEvent | AssistantUsageEvent | ModelCallFailureEvent | ModelCallFinishedEvent | AbortEvent | ToolUserRequestedEvent | ToolExecutionStartEvent | ToolExecutionPartialResultEvent | ToolShellOutputEvent | ToolExecutionProgressEvent | ToolExecutionCompleteEvent | ToolSearchActivatedEvent | SkillInvokedEvent | SubagentStartedEvent | SubagentConfiguredEvent | SubagentCompletedEvent | SubagentFailedEvent | SubagentSelectedEvent | SubagentDeselectedEvent | HookStartEvent | HookEndEvent | HookProgressEvent | BinaryAssetEvent | SystemMessageEvent | SystemNotificationEvent | PermissionRequestedEvent | PermissionCompletedEvent | PermissionCarriedForwardEvent | PermissionMessageAuthorizationEvent | PermissionMessageAuthorizationReadEvent | PermissionMessageAuthorizationDegradedEvent | PermissionAssentDetectedEvent | PermissionContextualAuthorizationEvent | UserInputRequestedEvent | UserInputCompletedEvent | ElicitationRequestedEvent | ElicitationCompletedEvent | SamplingRequestedEvent | SamplingCompletedEvent | McpOauthRequiredEvent | McpOauthCompletedEvent | McpHeadersRefreshRequiredEvent | McpHeadersRefreshCompletedEvent | CustomNotificationEvent | UIEphemeralQueryEvent | ExternalToolRequestedEvent | ExternalToolCompletedEvent | CommandQueuedEvent | CommandExecuteEvent | CommandCompletedEvent | AutoModeSwitchRequestedEvent | AutoModeSwitchCompletedEvent | SessionLimitsExhaustedRequestedEvent | SessionLimitsExhaustedCompletedEvent | AutoModeResolvedEvent | ManagedSettingsResolvedEvent | ManagedSettingsEnforcedEvent | CommandsChangedEvent | CapabilitiesChangedEvent | ExitPlanModeRequestedEvent | ExitPlanModeCompletedEvent | HumanResponseRecordedEvent | ToolsUpdatedEvent | BackgroundTasksChangedEvent | WorkflowRunUpdatedEvent | WorkflowRunStartedEvent | WorkflowRunSettledEvent | SkillsLoadedEvent | CustomAgentsUpdatedEvent | McpServersLoadedEvent | McpServerStatusChangedEvent | McpServerRemovedEvent | McpServerNeedsReconnectEvent | McpToolsListChangedEvent | McpResourcesListChangedEvent | McpPromptsListChangedEvent | ExtensionsLoadedEvent | CanvasOpenedEvent | CanvasRegistryChangedEvent | CanvasClosedEvent | CanvasUnavailableEvent | CanvasRecordedEvent | CanvasRemovedEvent | ExtensionsAttachmentsPushedEvent | McpAppToolCallCompleteEvent;
|
|
12
|
+
export type SessionEvent = StartEvent | ResumeEvent | RemoteSteerableChangedEvent | ErrorEvent | IdleEvent | TitleChangedEvent | ScheduleCreatedEvent | ScheduleCancelledEvent | ScheduleRearmedEvent | AutopilotObjectiveChangedEvent | InfoEvent | IndexedSearchEvent | WarningEvent | ModelChangeEvent | ModelDeselectedEvent | AutoTierRecommendationEvent | AutoTierSwitchFailedEvent | ModeChangedEvent | ModeNoticeDeliveredEvent | SessionLimitsChangedEvent | PermissionsChangedEvent | PlanChangedEvent | TodosChangedEvent | WorkspaceFileChangedEvent | HandoffEvent | TruncationEvent | SnapshotRewindEvent | ShutdownEvent | UsageCheckpointEvent | ProviderQuotaObservationEvent | ContextChangedEvent | UsageInfoEvent | ContextClearedEvent | CompactionStartEvent | CompactionCompleteEvent | TaskCompleteEvent | CompletionReceiptEvent | FusionRouteStartedEvent | FusionRouteFailedEvent | FusionResolvedEvent | FusionCompletedEvent | PermissionRecoveryEvent | UserMessageEvent | PendingMessagesModifiedEvent | AssistantTurnStartEvent | AssistantIntentEvent | AssistantFusionPhaseStartedEvent | AssistantFusionPhaseActivityEvent | AssistantFusionPhaseCompletedEvent | AssistantFusionPhaseFailedEvent | AssistantServerToolProgressEvent | AssistantReasoningEvent | AssistantReasoningDeltaEvent | AssistantToolCallDeltaEvent | AssistantStreamingDeltaEvent | AssistantMessageEvent | AssistantMessageStartEvent | AssistantMessageDeltaEvent | AssistantTurnEndEvent | AssistantIdleEvent | AssistantUsageEvent | ModelCallFailureEvent | ModelCallFinishedEvent | AbortEvent | ToolUserRequestedEvent | ToolExecutionStartEvent | ToolExecutionPartialResultEvent | ToolShellOutputEvent | ToolExecutionProgressEvent | ToolExecutionCompleteEvent | ToolSearchActivatedEvent | SkillInvokedEvent | SubagentStartedEvent | SubagentConfiguredEvent | SubagentCompletedEvent | SubagentFailedEvent | SubagentSelectedEvent | SubagentDeselectedEvent | HookStartEvent | HookEndEvent | HookProgressEvent | BinaryAssetEvent | SystemMessageEvent | SystemNotificationEvent | PermissionRequestedEvent | PermissionCompletedEvent | PermissionCarriedForwardEvent | PermissionMessageAuthorizationEvent | PermissionMessageAuthorizationReadEvent | PermissionMessageAuthorizationDegradedEvent | PermissionAssentDetectedEvent | PermissionContextualAuthorizationEvent | UserInputRequestedEvent | UserInputCompletedEvent | ElicitationRequestedEvent | ElicitationCompletedEvent | SamplingRequestedEvent | SamplingCompletedEvent | McpOauthRequiredEvent | McpOauthCompletedEvent | McpHeadersRefreshRequiredEvent | McpHeadersRefreshCompletedEvent | CustomNotificationEvent | UIEphemeralQueryEvent | ExternalToolRequestedEvent | ExternalToolCompletedEvent | CommandQueuedEvent | CommandExecuteEvent | CommandCompletedEvent | AutoModeSwitchRequestedEvent | AutoModeSwitchCompletedEvent | SessionLimitsExhaustedRequestedEvent | SessionLimitsExhaustedCompletedEvent | AutoModeResolvedEvent | ManagedSettingsResolvedEvent | ManagedSettingsEnforcedEvent | CommandsChangedEvent | CapabilitiesChangedEvent | ExitPlanModeRequestedEvent | ExitPlanModeCompletedEvent | HumanResponseRecordedEvent | ToolsUpdatedEvent | BackgroundTasksChangedEvent | WorkflowRunUpdatedEvent | WorkflowRunStartedEvent | WorkflowRunSettledEvent | SkillsLoadedEvent | CustomAgentsUpdatedEvent | McpServersLoadedEvent | McpServerStatusChangedEvent | McpServerRemovedEvent | McpServerNeedsReconnectEvent | McpToolsListChangedEvent | McpResourcesListChangedEvent | McpPromptsListChangedEvent | ExtensionsLoadedEvent | CanvasOpenedEvent | CanvasRegistryChangedEvent | CanvasClosedEvent | CanvasUnavailableEvent | CanvasRecordedEvent | CanvasRemovedEvent | ExtensionsAttachmentsPushedEvent | McpAppToolCallCompleteEvent;
|
|
13
13
|
/**
|
|
14
14
|
* Extensible routing preference for the virtual `auto` model. New identifiers must be advertised and enabled by the provider. `fast` is an integrator-only latency preset.
|
|
15
15
|
*/
|
|
@@ -366,6 +366,25 @@ export type HandoffSourceType =
|
|
|
366
366
|
"remote"
|
|
367
367
|
/** The handoff originated from a local session. */
|
|
368
368
|
| "local";
|
|
369
|
+
/**
|
|
370
|
+
* Whether the accumulated numeric AI-credit subtotal covers the observed calls.
|
|
371
|
+
*/
|
|
372
|
+
export type AiCreditsStatus =
|
|
373
|
+
/** Every observed call supplied an AI-credit amount, including an explicit zero. */
|
|
374
|
+
"complete"
|
|
375
|
+
/** Some calls supplied amounts and some did not; the numeric value is only a reported subtotal. */
|
|
376
|
+
| "partial"
|
|
377
|
+
/** No AI-credit amount was reported for the observed calls. Numeric zero is not a zero-cost claim. */
|
|
378
|
+
| "unavailable";
|
|
379
|
+
/**
|
|
380
|
+
* The neutral kind of a model provider — the model analog of `AccountKind`. A model provider is the live, entitled source a model came from; central code never branches on this beyond a single dispatch.
|
|
381
|
+
*/
|
|
382
|
+
/** @experimental */
|
|
383
|
+
export type ModelProviderKind =
|
|
384
|
+
/** GitHub Copilot / CAPI models, spawned by a github-resolving account that holds a Copilot seat. */
|
|
385
|
+
"copilot"
|
|
386
|
+
/** Microsoft 365 Copilot (Loki) inference models, spawned by a resolvable Entra-derived Loki account. */
|
|
387
|
+
| "loki";
|
|
369
388
|
/**
|
|
370
389
|
* Whether the session ended normally ("routine") or due to a crash/fatal error ("error")
|
|
371
390
|
*/
|
|
@@ -374,6 +393,78 @@ export type ShutdownType =
|
|
|
374
393
|
"routine"
|
|
375
394
|
/** The session ended because of a crash or fatal error. */
|
|
376
395
|
| "error";
|
|
396
|
+
/**
|
|
397
|
+
* Access policy reported by the quota service.
|
|
398
|
+
*/
|
|
399
|
+
export type ProviderQuotaAccessState =
|
|
400
|
+
/** Access is allowed. */
|
|
401
|
+
"allowed"
|
|
402
|
+
/** Access is denied. */
|
|
403
|
+
| "denied"
|
|
404
|
+
/** Quota is not required for this access. */
|
|
405
|
+
| "not_required"
|
|
406
|
+
/** The service did not supply a recognized access state. */
|
|
407
|
+
| "unknown"
|
|
408
|
+
/** Client-only compatibility placeholder when acquisitionStatus is unavailable or failed; not an observed service verdict. */
|
|
409
|
+
| "unavailable";
|
|
410
|
+
/**
|
|
411
|
+
* Acquisition state, independent of the service's business access/capacity verdict.
|
|
412
|
+
*/
|
|
413
|
+
export type ProviderQuotaAcquisitionStatus =
|
|
414
|
+
/** A service quota observation was received. */
|
|
415
|
+
"succeeded"
|
|
416
|
+
/** No service snapshot is available for this caller or surface. */
|
|
417
|
+
| "unavailable"
|
|
418
|
+
/** Acquisition failed; inspect httpStatus/acquisitionError without inferring a business verdict. */
|
|
419
|
+
| "failed";
|
|
420
|
+
/**
|
|
421
|
+
* Capacity is independent of whether a numeric balance was supplied.
|
|
422
|
+
*/
|
|
423
|
+
export type ProviderQuotaCapacityState =
|
|
424
|
+
/** Capacity is available. */
|
|
425
|
+
"available"
|
|
426
|
+
/** The service explicitly reports exhaustion. */
|
|
427
|
+
| "exhausted"
|
|
428
|
+
/** The reported entitlement is unlimited. */
|
|
429
|
+
| "unlimited"
|
|
430
|
+
/** No billable quota is required. */
|
|
431
|
+
| "not_required"
|
|
432
|
+
/** The service reports that capacity is not applicable. */
|
|
433
|
+
| "not_applicable"
|
|
434
|
+
/** No recognized capacity state was supplied. */
|
|
435
|
+
| "unknown"
|
|
436
|
+
/** Client-only compatibility placeholder when acquisitionStatus is unavailable or failed; not an observed service verdict. */
|
|
437
|
+
| "unavailable";
|
|
438
|
+
/**
|
|
439
|
+
* Timing and purpose of a provider quota observation.
|
|
440
|
+
*/
|
|
441
|
+
export type ProviderQuotaObservationKind =
|
|
442
|
+
/** An explicit account read; consumption may still be subject to service aggregation delay. */
|
|
443
|
+
"account_snapshot"
|
|
444
|
+
/** A verdict attached before an inference response. May be cached; never a post-charge balance. */
|
|
445
|
+
| "admission_state";
|
|
446
|
+
/**
|
|
447
|
+
* Interpretation permitted for independently reported quantities.
|
|
448
|
+
*/
|
|
449
|
+
export type ProviderQuotaQuantityKind =
|
|
450
|
+
/** Quantities form an authoritative available-of-entitled budget suitable for percentage presentation. */
|
|
451
|
+
"authoritative_budget"
|
|
452
|
+
/** Raw advisory quantities; do not infer permission, usage percentage, reset cadence, or post-charge balance. */
|
|
453
|
+
| "advisory_balance"
|
|
454
|
+
/** No quantity measurement, as with admission-only response headers. */
|
|
455
|
+
| "none";
|
|
456
|
+
/**
|
|
457
|
+
* Units explicitly reported by a quota provider.
|
|
458
|
+
*/
|
|
459
|
+
export type ProviderQuotaUnit =
|
|
460
|
+
/** AI credits, not tokens or currency. */
|
|
461
|
+
"ai_credits"
|
|
462
|
+
/** Requests charged against an entitlement. */
|
|
463
|
+
| "requests"
|
|
464
|
+
/** Model tokens. */
|
|
465
|
+
| "tokens"
|
|
466
|
+
/** The observation does not establish a quantity unit. */
|
|
467
|
+
| "unknown";
|
|
377
468
|
/**
|
|
378
469
|
* What initiated a conversation compaction
|
|
379
470
|
*/
|
|
@@ -1487,6 +1578,10 @@ export interface StartData {
|
|
|
1487
1578
|
* Identifier of the software producing the events (e.g., "copilot-agent")
|
|
1488
1579
|
*/
|
|
1489
1580
|
producer: string;
|
|
1581
|
+
/**
|
|
1582
|
+
* Provider of selectedModel at creation time, when explicitly selected.
|
|
1583
|
+
*/
|
|
1584
|
+
providerId?: string;
|
|
1490
1585
|
/**
|
|
1491
1586
|
* Reasoning effort level used for model calls, if applicable (e.g. "none", "low", "medium", "high", "xhigh", "max")
|
|
1492
1587
|
*/
|
|
@@ -1655,6 +1750,10 @@ export interface ResumeData {
|
|
|
1655
1750
|
* On-disk byte size of the session's persisted events.jsonl file at resume time; omitted when the file does not exist or cannot be stat'd
|
|
1656
1751
|
*/
|
|
1657
1752
|
eventsFileSizeBytes?: number;
|
|
1753
|
+
/**
|
|
1754
|
+
* Provider of selectedModel at resume time, when explicitly selected.
|
|
1755
|
+
*/
|
|
1756
|
+
providerId?: string;
|
|
1658
1757
|
/**
|
|
1659
1758
|
* Reasoning effort level used for model calls, if applicable (e.g. "none", "low", "medium", "high", "xhigh", "max")
|
|
1660
1759
|
*/
|
|
@@ -2267,12 +2366,20 @@ export interface ModelChangeData {
|
|
|
2267
2366
|
* Model that was previously selected, if any
|
|
2268
2367
|
*/
|
|
2269
2368
|
previousModel?: string;
|
|
2369
|
+
/**
|
|
2370
|
+
* Provider of previousModel, when known. A provider-only change is a model selection change even when the model identifiers are equal.
|
|
2371
|
+
*/
|
|
2372
|
+
previousProviderId?: string;
|
|
2270
2373
|
/**
|
|
2271
2374
|
* Reasoning effort level before the model change, if applicable
|
|
2272
2375
|
*/
|
|
2273
2376
|
previousReasoningEffort?: string;
|
|
2274
2377
|
previousReasoningSummary?: ReasoningSummary;
|
|
2275
2378
|
previousVerbosity?: Verbosity;
|
|
2379
|
+
/**
|
|
2380
|
+
* Provider selected for newModel. Omitted for legacy or unattributed selections; never inferred from a later selection.
|
|
2381
|
+
*/
|
|
2382
|
+
providerId?: string;
|
|
2276
2383
|
/**
|
|
2277
2384
|
* Reasoning effort level after the model change, if applicable
|
|
2278
2385
|
*/
|
|
@@ -2945,6 +3052,10 @@ export interface ShutdownData {
|
|
|
2945
3052
|
modelMetrics: {
|
|
2946
3053
|
[k: string]: ShutdownModelMetric | undefined;
|
|
2947
3054
|
};
|
|
3055
|
+
/**
|
|
3056
|
+
* Provider/model accounting preserved for replay without consulting current provider selection.
|
|
3057
|
+
*/
|
|
3058
|
+
providerModelMetrics?: UsageMetricsProviderModelMetric[];
|
|
2948
3059
|
/**
|
|
2949
3060
|
* Unix timestamp (milliseconds) when the session started
|
|
2950
3061
|
*/
|
|
@@ -2974,6 +3085,233 @@ export interface ShutdownData {
|
|
|
2974
3085
|
* @experimental
|
|
2975
3086
|
*/
|
|
2976
3087
|
totalNanoAiu?: number;
|
|
3088
|
+
/**
|
|
3089
|
+
* Per-source accounting sequence watermarks subsuming preceding usage receipts.
|
|
3090
|
+
*/
|
|
3091
|
+
usageAccountingWatermarks?: {
|
|
3092
|
+
[k: string]: number | undefined;
|
|
3093
|
+
};
|
|
3094
|
+
}
|
|
3095
|
+
/**
|
|
3096
|
+
* Accumulated session usage metrics, including premium request cost, token counts, model breakdown, and code-change totals.
|
|
3097
|
+
*/
|
|
3098
|
+
export interface UsageGetMetricsResult {
|
|
3099
|
+
/**
|
|
3100
|
+
* Per-agent usage metrics, keyed by agent instance identifier. The main conversation uses the stable key `main`.
|
|
3101
|
+
*/
|
|
3102
|
+
agentMetrics?: {
|
|
3103
|
+
[k: string]: UsageMetricsAgentMetric | undefined;
|
|
3104
|
+
};
|
|
3105
|
+
aiCreditsStatus?: AiCreditsStatus;
|
|
3106
|
+
codeChanges: UsageMetricsCodeChanges;
|
|
3107
|
+
/**
|
|
3108
|
+
* Currently active model identifier
|
|
3109
|
+
*/
|
|
3110
|
+
currentModel?: string;
|
|
3111
|
+
/**
|
|
3112
|
+
* Input tokens from the most recent main-agent API call
|
|
3113
|
+
*/
|
|
3114
|
+
lastCallInputTokens: number;
|
|
3115
|
+
/**
|
|
3116
|
+
* Output tokens from the most recent main-agent API call
|
|
3117
|
+
*/
|
|
3118
|
+
lastCallOutputTokens: number;
|
|
3119
|
+
/**
|
|
3120
|
+
* Per-model token and request metrics, keyed by model identifier
|
|
3121
|
+
*/
|
|
3122
|
+
modelMetrics: {
|
|
3123
|
+
[k: string]: UsageMetricsModelMetric | undefined;
|
|
3124
|
+
};
|
|
3125
|
+
/**
|
|
3126
|
+
* Provider-attributed model metrics, ordered by first observed provider and model.
|
|
3127
|
+
* Null attribution preserves historical usage whose provider or model was not recorded.
|
|
3128
|
+
*/
|
|
3129
|
+
providerModelMetrics?: UsageMetricsProviderModelMetric[];
|
|
3130
|
+
/**
|
|
3131
|
+
* ISO 8601 timestamp when the session started
|
|
3132
|
+
*/
|
|
3133
|
+
sessionStartTime: string;
|
|
3134
|
+
/**
|
|
3135
|
+
* Session-wide per-token-type accumulated token counts
|
|
3136
|
+
*/
|
|
3137
|
+
tokenDetails?: {
|
|
3138
|
+
[k: string]: UsageMetricsTokenDetail | undefined;
|
|
3139
|
+
};
|
|
3140
|
+
/**
|
|
3141
|
+
* Total time spent in model API calls (milliseconds)
|
|
3142
|
+
*/
|
|
3143
|
+
totalApiDurationMs: number;
|
|
3144
|
+
/**
|
|
3145
|
+
* Session-wide accumulated nano-AI units cost
|
|
3146
|
+
*/
|
|
3147
|
+
totalNanoAiu?: number;
|
|
3148
|
+
/**
|
|
3149
|
+
* Total user-initiated premium request cost across all models (may be fractional due to multipliers)
|
|
3150
|
+
*/
|
|
3151
|
+
totalPremiumRequestCost: number;
|
|
3152
|
+
/**
|
|
3153
|
+
* Raw count of user-initiated API requests
|
|
3154
|
+
*/
|
|
3155
|
+
totalUserRequests: number;
|
|
3156
|
+
}
|
|
3157
|
+
/**
|
|
3158
|
+
* Usage attributed to one agent instance, including its identity, API duration, AI units, and per-model breakdown.
|
|
3159
|
+
*/
|
|
3160
|
+
export interface UsageMetricsAgentMetric {
|
|
3161
|
+
/**
|
|
3162
|
+
* Human-readable label for this subagent invocation, copied from the originating `subagent.started` event. For task-tool subagents this is the invocation's task description rather than the agent's configured display name, so group by `agentName` for stable per-agent labels.
|
|
3163
|
+
*/
|
|
3164
|
+
agentDisplayName?: string;
|
|
3165
|
+
/**
|
|
3166
|
+
* Configured agent name, when this is a subagent
|
|
3167
|
+
*/
|
|
3168
|
+
agentName?: string;
|
|
3169
|
+
/**
|
|
3170
|
+
* Per-model usage for this agent, keyed by model identifier
|
|
3171
|
+
*/
|
|
3172
|
+
modelMetrics: {
|
|
3173
|
+
[k: string]: UsageMetricsModelMetric | undefined;
|
|
3174
|
+
};
|
|
3175
|
+
/**
|
|
3176
|
+
* Time spent in model API calls by this agent, in milliseconds
|
|
3177
|
+
*/
|
|
3178
|
+
totalApiDurationMs: number;
|
|
3179
|
+
/**
|
|
3180
|
+
* Accumulated nano-AI units cost for this agent
|
|
3181
|
+
*/
|
|
3182
|
+
totalNanoAiu: number;
|
|
3183
|
+
}
|
|
3184
|
+
/**
|
|
3185
|
+
* Per-model usage metrics, including request counts/costs, token usage, nano-AI units, and per-token-type details.
|
|
3186
|
+
*/
|
|
3187
|
+
export interface UsageMetricsModelMetric {
|
|
3188
|
+
aiCreditsStatus?: AiCreditsStatus;
|
|
3189
|
+
/**
|
|
3190
|
+
* Latest known prompt-cache expiration for this model. A timestamp in the past indicates that the observed cache has expired.
|
|
3191
|
+
*/
|
|
3192
|
+
cacheExpiresAt?: string;
|
|
3193
|
+
requests: UsageMetricsModelMetricRequests;
|
|
3194
|
+
/**
|
|
3195
|
+
* Token count details per type
|
|
3196
|
+
*/
|
|
3197
|
+
tokenDetails?: {
|
|
3198
|
+
[k: string]: UsageMetricsModelMetricTokenDetail | undefined;
|
|
3199
|
+
};
|
|
3200
|
+
/**
|
|
3201
|
+
* Accumulated nano-AI units cost for this model
|
|
3202
|
+
*/
|
|
3203
|
+
totalNanoAiu?: number;
|
|
3204
|
+
usage: UsageMetricsModelMetricUsage;
|
|
3205
|
+
}
|
|
3206
|
+
/**
|
|
3207
|
+
* Request count and cost metrics for this model
|
|
3208
|
+
*/
|
|
3209
|
+
export interface UsageMetricsModelMetricRequests {
|
|
3210
|
+
/**
|
|
3211
|
+
* User-initiated premium request cost (with multiplier applied)
|
|
3212
|
+
*/
|
|
3213
|
+
cost: number;
|
|
3214
|
+
/**
|
|
3215
|
+
* Number of API requests made with this model
|
|
3216
|
+
*/
|
|
3217
|
+
count: number;
|
|
3218
|
+
}
|
|
3219
|
+
/**
|
|
3220
|
+
* Per-model token-detail entry containing the accumulated token count for one token type.
|
|
3221
|
+
*/
|
|
3222
|
+
export interface UsageMetricsModelMetricTokenDetail {
|
|
3223
|
+
/**
|
|
3224
|
+
* Accumulated token count for this token type
|
|
3225
|
+
*/
|
|
3226
|
+
tokenCount: number;
|
|
3227
|
+
}
|
|
3228
|
+
/**
|
|
3229
|
+
* Token usage metrics for this model
|
|
3230
|
+
*/
|
|
3231
|
+
export interface UsageMetricsModelMetricUsage {
|
|
3232
|
+
/**
|
|
3233
|
+
* Total tokens read from prompt cache
|
|
3234
|
+
*/
|
|
3235
|
+
cacheReadTokens: number;
|
|
3236
|
+
/**
|
|
3237
|
+
* Total tokens written to prompt cache
|
|
3238
|
+
*/
|
|
3239
|
+
cacheWriteTokens: number;
|
|
3240
|
+
/**
|
|
3241
|
+
* Total input tokens consumed
|
|
3242
|
+
*/
|
|
3243
|
+
inputTokens: number;
|
|
3244
|
+
/**
|
|
3245
|
+
* Total output tokens produced
|
|
3246
|
+
*/
|
|
3247
|
+
outputTokens: number;
|
|
3248
|
+
/**
|
|
3249
|
+
* Total output tokens used for reasoning
|
|
3250
|
+
*/
|
|
3251
|
+
reasoningTokens?: number;
|
|
3252
|
+
}
|
|
3253
|
+
/**
|
|
3254
|
+
* Aggregated code change metrics
|
|
3255
|
+
*/
|
|
3256
|
+
export interface UsageMetricsCodeChanges {
|
|
3257
|
+
/**
|
|
3258
|
+
* Distinct file paths modified during the session
|
|
3259
|
+
*/
|
|
3260
|
+
filesModified: string[];
|
|
3261
|
+
/**
|
|
3262
|
+
* Number of distinct files modified
|
|
3263
|
+
*/
|
|
3264
|
+
filesModifiedCount: number;
|
|
3265
|
+
/**
|
|
3266
|
+
* Total lines of code added
|
|
3267
|
+
*/
|
|
3268
|
+
linesAdded: number;
|
|
3269
|
+
/**
|
|
3270
|
+
* Total lines of code removed
|
|
3271
|
+
*/
|
|
3272
|
+
linesRemoved: number;
|
|
3273
|
+
}
|
|
3274
|
+
/**
|
|
3275
|
+
* Usage for one recorded provider and model, without merging identical model IDs across providers.
|
|
3276
|
+
*/
|
|
3277
|
+
export interface UsageMetricsProviderModelMetric {
|
|
3278
|
+
metrics: UsageMetricsModelMetric | undefined;
|
|
3279
|
+
/**
|
|
3280
|
+
* Model display name captured at call time, when known.
|
|
3281
|
+
*/
|
|
3282
|
+
modelDisplayName?: string;
|
|
3283
|
+
/**
|
|
3284
|
+
* Model identity, or null for legacy aggregate-only usage.
|
|
3285
|
+
*/
|
|
3286
|
+
modelId: string | null;
|
|
3287
|
+
/**
|
|
3288
|
+
* Provider identity and product label captured when the call was dispatched; null when unknown.
|
|
3289
|
+
*/
|
|
3290
|
+
provider: ModelProviderRef | null;
|
|
3291
|
+
}
|
|
3292
|
+
/**
|
|
3293
|
+
* A neutral reference to the model provider that produced a model: an opaque id, a human-readable label, and the provider kind. Carried on each enumerated Model so consumers can group by provider without reaching into a provider-shaped internal type.
|
|
3294
|
+
*/
|
|
3295
|
+
/** @experimental */
|
|
3296
|
+
export interface ModelProviderRef {
|
|
3297
|
+
/**
|
|
3298
|
+
* Opaque, stable id of the provider that produced this model. Matches the enumerated `ModelProviderDescriptor.id`.
|
|
3299
|
+
*/
|
|
3300
|
+
id: string;
|
|
3301
|
+
kind: ModelProviderKind;
|
|
3302
|
+
/**
|
|
3303
|
+
* Human-readable provider label, owned by the runtime so every consumer renders identical text.
|
|
3304
|
+
*/
|
|
3305
|
+
label: string;
|
|
3306
|
+
}
|
|
3307
|
+
/**
|
|
3308
|
+
* Session-wide token-detail entry containing the accumulated token count for one token type.
|
|
3309
|
+
*/
|
|
3310
|
+
export interface UsageMetricsTokenDetail {
|
|
3311
|
+
/**
|
|
3312
|
+
* Accumulated token count for this token type
|
|
3313
|
+
*/
|
|
3314
|
+
tokenCount: number;
|
|
2977
3315
|
}
|
|
2978
3316
|
/**
|
|
2979
3317
|
* Usage attributed to one agent instance at session shutdown.
|
|
@@ -3132,10 +3470,165 @@ export interface UsageCheckpointEvent {
|
|
|
3132
3470
|
* Durable session usage checkpoint for reconstructing aggregate accounting on resume
|
|
3133
3471
|
*/
|
|
3134
3472
|
export interface UsageCheckpointData {
|
|
3473
|
+
/**
|
|
3474
|
+
* Provider/model accounting snapshot that subsumes preceding usage receipts.
|
|
3475
|
+
*/
|
|
3476
|
+
providerModelMetrics?: UsageMetricsProviderModelMetric[];
|
|
3135
3477
|
/**
|
|
3136
3478
|
* Session-wide accumulated nano-AI units cost at checkpoint time
|
|
3137
3479
|
*/
|
|
3138
3480
|
totalNanoAiu: number;
|
|
3481
|
+
/**
|
|
3482
|
+
* Highest accounted sequence per source session; no per-call deduplication history is retained.
|
|
3483
|
+
*/
|
|
3484
|
+
usageAccountingWatermarks?: {
|
|
3485
|
+
[k: string]: number | undefined;
|
|
3486
|
+
};
|
|
3487
|
+
}
|
|
3488
|
+
/**
|
|
3489
|
+
* Session event "session.quota_observation". A provider-owned quota observation, distinct from per-call usage and charge accounting.
|
|
3490
|
+
*/
|
|
3491
|
+
/** @experimental */
|
|
3492
|
+
export interface ProviderQuotaObservationEvent {
|
|
3493
|
+
/**
|
|
3494
|
+
* Sub-agent instance identifier. Absent for events from the root/main agent and session-level events.
|
|
3495
|
+
*/
|
|
3496
|
+
agentId?: string;
|
|
3497
|
+
data: ProviderQuotaObservationData;
|
|
3498
|
+
/**
|
|
3499
|
+
* Always true for events that are transient and not persisted to the session event log on disk.
|
|
3500
|
+
*/
|
|
3501
|
+
ephemeral: true;
|
|
3502
|
+
/**
|
|
3503
|
+
* Unique event identifier (UUID v4), generated when the event is emitted
|
|
3504
|
+
*/
|
|
3505
|
+
id: string;
|
|
3506
|
+
/**
|
|
3507
|
+
* ID of the chronologically preceding event in the session, forming a linked chain. Null for the first event.
|
|
3508
|
+
*/
|
|
3509
|
+
parentId: string | null;
|
|
3510
|
+
/**
|
|
3511
|
+
* ISO 8601 timestamp when the event was created
|
|
3512
|
+
*/
|
|
3513
|
+
timestamp: string;
|
|
3514
|
+
/**
|
|
3515
|
+
* Type discriminator. Always "session.quota_observation".
|
|
3516
|
+
*/
|
|
3517
|
+
type: "session.quota_observation";
|
|
3518
|
+
}
|
|
3519
|
+
/**
|
|
3520
|
+
* A provider-owned quota observation, distinct from per-call usage and charge accounting.
|
|
3521
|
+
*/
|
|
3522
|
+
/** @experimental */
|
|
3523
|
+
export interface ProviderQuotaObservationData {
|
|
3524
|
+
observation: ProviderQuotaState;
|
|
3525
|
+
}
|
|
3526
|
+
/**
|
|
3527
|
+
* An account quota reading. Absence of a quantity is unknown, never zero.
|
|
3528
|
+
*/
|
|
3529
|
+
/** @experimental */
|
|
3530
|
+
export interface ProviderQuotaState {
|
|
3531
|
+
accessState: ProviderQuotaAccessState;
|
|
3532
|
+
/**
|
|
3533
|
+
* Service error code or client acquisition category, separate from the business-state reason.
|
|
3534
|
+
*/
|
|
3535
|
+
acquisitionError?: string;
|
|
3536
|
+
acquisitionStatus?: ProviderQuotaAcquisitionStatus;
|
|
3537
|
+
/**
|
|
3538
|
+
* Independently reported signed 64-bit available quantity. Zero does not override the service access/capacity verdict; omission and null are preserved.
|
|
3539
|
+
*/
|
|
3540
|
+
availableQuantity?: number | null;
|
|
3541
|
+
budgetMetadata?: ProviderQuotaBudgetMetadata;
|
|
3542
|
+
capacityState: ProviderQuotaCapacityState;
|
|
3543
|
+
/**
|
|
3544
|
+
* Key for the backwards-compatible snapshots projection, when the authoritative budget supports that contract.
|
|
3545
|
+
*/
|
|
3546
|
+
compatibilityKey?: string;
|
|
3547
|
+
/**
|
|
3548
|
+
* Independently reported signed 64-bit entitlement. -1 is an unlimited sentinel, not a capacity-state rewrite; omission and null are preserved.
|
|
3549
|
+
*/
|
|
3550
|
+
entitledQuantity?: number | null;
|
|
3551
|
+
/**
|
|
3552
|
+
* Explicit service admission flag, when reported.
|
|
3553
|
+
*/
|
|
3554
|
+
hasQuota?: boolean | null;
|
|
3555
|
+
/**
|
|
3556
|
+
* HTTP status from acquisition, when available.
|
|
3557
|
+
*/
|
|
3558
|
+
httpStatus?: number;
|
|
3559
|
+
observationKind?: ProviderQuotaObservationKind;
|
|
3560
|
+
/**
|
|
3561
|
+
* When the runtime observed this reading, not a charge timestamp or guarantee that consumption has settled.
|
|
3562
|
+
*/
|
|
3563
|
+
observedAt?: string;
|
|
3564
|
+
provider: ModelProviderRef;
|
|
3565
|
+
quantityKind?: ProviderQuotaQuantityKind;
|
|
3566
|
+
/**
|
|
3567
|
+
* Service-owned quota identifier within this provider.
|
|
3568
|
+
*/
|
|
3569
|
+
quotaId: string;
|
|
3570
|
+
/**
|
|
3571
|
+
* Service-reported explanation for the state.
|
|
3572
|
+
*/
|
|
3573
|
+
reason?: string | null;
|
|
3574
|
+
/**
|
|
3575
|
+
* Service name owning this reading.
|
|
3576
|
+
*/
|
|
3577
|
+
service?: string | null;
|
|
3578
|
+
/**
|
|
3579
|
+
* Service-reported quota source.
|
|
3580
|
+
*/
|
|
3581
|
+
source?: string | null;
|
|
3582
|
+
unit: ProviderQuotaUnit;
|
|
3583
|
+
}
|
|
3584
|
+
/**
|
|
3585
|
+
* Authoritative budget measurements and policy metadata, independent of provider.
|
|
3586
|
+
*/
|
|
3587
|
+
export interface ProviderQuotaBudgetMetadata {
|
|
3588
|
+
/**
|
|
3589
|
+
* Exact measured consumption in the budget's unit.
|
|
3590
|
+
*/
|
|
3591
|
+
consumed: number;
|
|
3592
|
+
/**
|
|
3593
|
+
* Exact budget entitlement, retaining incumbent fractional-unit compatibility.
|
|
3594
|
+
*/
|
|
3595
|
+
entitlement: number;
|
|
3596
|
+
/**
|
|
3597
|
+
* Usage beyond entitlement, in the budget's unit.
|
|
3598
|
+
*/
|
|
3599
|
+
overage: number;
|
|
3600
|
+
/**
|
|
3601
|
+
* Whether additional usage is allowed when the budget is exhausted.
|
|
3602
|
+
*/
|
|
3603
|
+
overageAllowedWhenExhausted: boolean;
|
|
3604
|
+
/**
|
|
3605
|
+
* Optional additional-usage budget cap.
|
|
3606
|
+
*/
|
|
3607
|
+
overageLimit?: number;
|
|
3608
|
+
/**
|
|
3609
|
+
* Service-reported remaining percentage for authoritative budget presentation.
|
|
3610
|
+
*/
|
|
3611
|
+
remainingPercentage: number;
|
|
3612
|
+
/**
|
|
3613
|
+
* Reset instant in epoch milliseconds when this budget actually defines a window.
|
|
3614
|
+
*/
|
|
3615
|
+
resetAtEpochMs?: number;
|
|
3616
|
+
/**
|
|
3617
|
+
* Whether the reset instant is an estimate.
|
|
3618
|
+
*/
|
|
3619
|
+
resetEstimated?: boolean;
|
|
3620
|
+
/**
|
|
3621
|
+
* Whether this budget uses token-based billing.
|
|
3622
|
+
*/
|
|
3623
|
+
tokenBasedBilling?: boolean;
|
|
3624
|
+
/**
|
|
3625
|
+
* Whether the budget has unlimited entitlement.
|
|
3626
|
+
*/
|
|
3627
|
+
unlimited: boolean;
|
|
3628
|
+
/**
|
|
3629
|
+
* Whether service policy allows continued usage after exhaustion.
|
|
3630
|
+
*/
|
|
3631
|
+
usageAllowedWhenExhausted: boolean;
|
|
3139
3632
|
}
|
|
3140
3633
|
/**
|
|
3141
3634
|
* Session event "session.context_changed". Updated working directory and git context after the change
|
|
@@ -3451,6 +3944,7 @@ export interface CompactionCompleteData {
|
|
|
3451
3944
|
* Token usage breakdown for the compaction LLM call (aligned with assistant.usage format)
|
|
3452
3945
|
*/
|
|
3453
3946
|
export interface CompactionCompleteCompactionTokensUsed {
|
|
3947
|
+
aiCreditsStatus?: AiCreditsStatus;
|
|
3454
3948
|
/**
|
|
3455
3949
|
* Cached input tokens reused in the compaction LLM call
|
|
3456
3950
|
*/
|
|
@@ -3471,10 +3965,15 @@ export interface CompactionCompleteCompactionTokensUsed {
|
|
|
3471
3965
|
* Model identifier used for the compaction LLM call
|
|
3472
3966
|
*/
|
|
3473
3967
|
model?: string;
|
|
3968
|
+
/**
|
|
3969
|
+
* Model display name captured for the compaction call.
|
|
3970
|
+
*/
|
|
3971
|
+
modelDisplayName?: string;
|
|
3474
3972
|
/**
|
|
3475
3973
|
* Output tokens produced by the compaction LLM call
|
|
3476
3974
|
*/
|
|
3477
3975
|
outputTokens?: number;
|
|
3976
|
+
provider?: ModelProviderRef;
|
|
3478
3977
|
}
|
|
3479
3978
|
/**
|
|
3480
3979
|
* Token usage detail for a single billing category
|
|
@@ -5451,6 +5950,10 @@ export interface AssistantMessageData {
|
|
|
5451
5950
|
* Generation phase for phased-output models (e.g., thinking vs. response phases)
|
|
5452
5951
|
*/
|
|
5453
5952
|
phase?: string;
|
|
5953
|
+
/**
|
|
5954
|
+
* Opaque origin provider identity captured at dispatch. Only an exact match with the target provider permits replay of reasoningOpaque, encryptedContent, reasoningBlocks, serverTools, and provider response/item identifiers. Matching model ids or wire protocols is insufficient. Omitted for legacy or unattributed messages; the runtime excludes unproven opaque state when projecting to a known provider. Text content and client tool requests/results remain portable semantic history.
|
|
5955
|
+
*/
|
|
5956
|
+
providerId?: string;
|
|
5454
5957
|
reasoningBlocks?: AssistantMessageReasoningBlocks;
|
|
5455
5958
|
/**
|
|
5456
5959
|
* Opaque/encrypted extended thinking data from Anthropic models. Session-bound and stripped on resume.
|
|
@@ -5974,6 +6477,8 @@ export interface AssistantUsageData {
|
|
|
5974
6477
|
* Number of accepted speculative prediction tokens
|
|
5975
6478
|
*/
|
|
5976
6479
|
acceptedPredictionTokens?: number;
|
|
6480
|
+
accounting?: UsageAccountingIdentity;
|
|
6481
|
+
aiCreditsStatus?: AiCreditsStatus;
|
|
5977
6482
|
/**
|
|
5978
6483
|
* Completion ID from the model provider (e.g., chatcmpl-abc123)
|
|
5979
6484
|
*/
|
|
@@ -6056,6 +6561,10 @@ export interface AssistantUsageData {
|
|
|
6056
6561
|
* Model identifier used for this API call
|
|
6057
6562
|
*/
|
|
6058
6563
|
model: string;
|
|
6564
|
+
/**
|
|
6565
|
+
* Model display name captured for this call, not derived from the current selection.
|
|
6566
|
+
*/
|
|
6567
|
+
modelDisplayName?: string;
|
|
6059
6568
|
/**
|
|
6060
6569
|
* Fixed-set provider family serving the bring-your-own-key model (for example "openai", "anthropic", "azure_openai", "ollama", "llama_cpp", or "other"). Never the caller-supplied provider name. Absent for Copilot-served models.
|
|
6061
6570
|
*/
|
|
@@ -6073,6 +6582,7 @@ export interface AssistantUsageData {
|
|
|
6073
6582
|
* Parent tool call ID when this usage originates from a sub-agent
|
|
6074
6583
|
*/
|
|
6075
6584
|
parentToolCallId?: string;
|
|
6585
|
+
provider?: ModelProviderRef;
|
|
6076
6586
|
/**
|
|
6077
6587
|
* GitHub request tracing ID (x-github-request-id header) for server-side log correlation
|
|
6078
6588
|
*/
|
|
@@ -6113,6 +6623,23 @@ export interface AssistantUsageData {
|
|
|
6113
6623
|
websocketFallbackAfterMs?: number;
|
|
6114
6624
|
websocketFallbackReason?: ModelCallWebSocketFallbackReason;
|
|
6115
6625
|
}
|
|
6626
|
+
/**
|
|
6627
|
+
* Ordered accounting identity assigned under the source session's emission lock.
|
|
6628
|
+
*/
|
|
6629
|
+
export interface UsageAccountingIdentity {
|
|
6630
|
+
/**
|
|
6631
|
+
* Monotonically increasing sequence within the source session.
|
|
6632
|
+
*/
|
|
6633
|
+
sequence: number;
|
|
6634
|
+
/**
|
|
6635
|
+
* Session that assigned this accounting sequence.
|
|
6636
|
+
*/
|
|
6637
|
+
sourceSessionId: string;
|
|
6638
|
+
/**
|
|
6639
|
+
* Existing API call identifier, or a runtime-generated identity when none was supplied.
|
|
6640
|
+
*/
|
|
6641
|
+
usageId: string;
|
|
6642
|
+
}
|
|
6116
6643
|
/**
|
|
6117
6644
|
* Per-request cost and usage data from the CAPI copilot_usage response field
|
|
6118
6645
|
*/
|
package/dist/session.d.ts
CHANGED
|
@@ -69,6 +69,7 @@ export declare class CopilotSession {
|
|
|
69
69
|
private _capabilities;
|
|
70
70
|
private openCanvasInstances;
|
|
71
71
|
private disconnected;
|
|
72
|
+
private readonly pendingResponseWaits;
|
|
72
73
|
private readonly pendingStructuredWaits;
|
|
73
74
|
private disconnecting;
|
|
74
75
|
private onDisconnected?;
|
|
@@ -173,6 +174,7 @@ export declare class CopilotSession {
|
|
|
173
174
|
sendAndWait<TResult>(options: MessageOptions | string, responseSchema: ResponseSchema<TResult>, timeout?: number): Promise<TResult>;
|
|
174
175
|
sendAndWait(options: MessageOptions, timeout?: number): Promise<AssistantMessageEvent | undefined>;
|
|
175
176
|
private sendAndWaitForStructuredMessage;
|
|
177
|
+
private assertConnected;
|
|
176
178
|
/**
|
|
177
179
|
* Subscribes to events from this session.
|
|
178
180
|
*
|
|
@@ -399,6 +401,7 @@ export declare class CopilotSession {
|
|
|
399
401
|
* replace tools while the session is idle.
|
|
400
402
|
*
|
|
401
403
|
* @param tools - The complete set of tools this client supplies
|
|
404
|
+
* @throws Error if the session disconnects before the replacement is applied
|
|
402
405
|
*
|
|
403
406
|
* @experimental Wraps the experimental `session.tools.set` RPC and may change
|
|
404
407
|
* or be removed in a future release.
|