@github/copilot-sdk 1.0.23-preview.0 → 1.0.23-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 +9 -5
- package/dist/cjs/cliVersion.js +1 -1
- package/dist/cjs/generated/rpc.js +1 -1
- package/dist/cjs/session.js +8 -6
- package/dist/cliVersion.d.ts +1 -1
- package/dist/cliVersion.js +1 -1
- package/dist/generated/rpc.d.ts +162 -11
- package/dist/generated/rpc.js +1 -1
- package/dist/generated/session-events.d.ts +98 -0
- package/dist/session.js +8 -6
- package/dist/types.d.ts +20 -6
- package/package.json +16 -12
package/README.md
CHANGED
|
@@ -128,11 +128,13 @@ await using host = await client.startAhpHost({
|
|
|
128
128
|
...config,
|
|
129
129
|
onPermissionRequest: approveAll,
|
|
130
130
|
systemMessage: { mode: "append", content: "Use the app's greeting tool." },
|
|
131
|
-
tools: [
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
131
|
+
tools: [
|
|
132
|
+
defineTool("greeting", {
|
|
133
|
+
description: "Get the application's greeting",
|
|
134
|
+
parameters: { type: "object", properties: {} },
|
|
135
|
+
handler: () => "Hello from the application!",
|
|
136
|
+
}),
|
|
137
|
+
],
|
|
136
138
|
});
|
|
137
139
|
},
|
|
138
140
|
onSessionReleased: async (originalSession) => {
|
|
@@ -1353,6 +1355,8 @@ Inbound trace context from the CLI is available on the `ToolInvocation` object p
|
|
|
1353
1355
|
|
|
1354
1356
|
An `onPermissionRequest` handler is optional when you create or resume a session. When provided, it is called before the agent executes each tool (file writes, shell commands, custom tools, etc.) and returns a decision. When omitted, permission requests are emitted as events and left pending for the consumer to resolve with the pending permission RPC.
|
|
1355
1357
|
|
|
1358
|
+
Callbacks receive optional derived prompt context as `invocation.promptRequest`. The raw request's `managedApprovalRequired` remains managed-policy provenance and enforces one-shot restrictions. Only derived `commands`, `read`, `write`, `url`, and `workflow` prompts can clear the human requirement after Assisted approval; for missing or other prompt kinds, keep the raw marker authoritative.
|
|
1359
|
+
|
|
1356
1360
|
### Approve All (simplest)
|
|
1357
1361
|
|
|
1358
1362
|
Use the built-in `approveAll` helper when managed settings are disabled:
|
package/dist/cjs/cliVersion.js
CHANGED
|
@@ -22,7 +22,7 @@ __export(cliVersion_exports, {
|
|
|
22
22
|
COPILOT_CLI_VERSION: () => COPILOT_CLI_VERSION
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(cliVersion_exports);
|
|
25
|
-
const COPILOT_CLI_VERSION = "1.0.99-
|
|
25
|
+
const COPILOT_CLI_VERSION = "1.0.99-1";
|
|
26
26
|
const COPILOT_CLI_USE_NPM_PACKAGE = false;
|
|
27
27
|
// Annotate the CommonJS export names for ESM import in node:
|
|
28
28
|
0 && (module.exports = {
|
|
@@ -2156,7 +2156,7 @@ function createSessionRpc(connection, sessionId) {
|
|
|
2156
2156
|
/**
|
|
2157
2157
|
* Begin an interactive login flow for a provider kind (dispatch is kind-only) and return its opaque flow id and first step.
|
|
2158
2158
|
*
|
|
2159
|
-
* @param params Begin an interactive login flow for a provider kind
|
|
2159
|
+
* @param params Begin an interactive login flow for a provider kind, optionally reusing a cached base identity or explicitly requesting provider account selection.
|
|
2160
2160
|
*
|
|
2161
2161
|
* @returns A started login flow: its opaque id and first step.
|
|
2162
2162
|
*/
|
package/dist/cjs/session.js
CHANGED
|
@@ -843,12 +843,12 @@ class CopilotSession {
|
|
|
843
843
|
}
|
|
844
844
|
}
|
|
845
845
|
} else if (event.type === "permission.requested") {
|
|
846
|
-
const { requestId, permissionRequest, resolvedByHook } = event.data;
|
|
846
|
+
const { requestId, permissionRequest, promptRequest, resolvedByHook } = event.data;
|
|
847
847
|
if (resolvedByHook) {
|
|
848
848
|
return;
|
|
849
849
|
}
|
|
850
850
|
if (this.permissionHandler) {
|
|
851
|
-
void this._executePermissionAndRespond(requestId, permissionRequest);
|
|
851
|
+
void this._executePermissionAndRespond(requestId, permissionRequest, promptRequest);
|
|
852
852
|
}
|
|
853
853
|
} else if (event.type === "mcp.oauth_required") {
|
|
854
854
|
const data = event.data;
|
|
@@ -1007,12 +1007,14 @@ class CopilotSession {
|
|
|
1007
1007
|
* Executes a permission handler and sends the result back via RPC.
|
|
1008
1008
|
* @internal
|
|
1009
1009
|
*/
|
|
1010
|
-
async _executePermissionAndRespond(requestId, permissionRequest) {
|
|
1010
|
+
async _executePermissionAndRespond(requestId, permissionRequest, promptRequest) {
|
|
1011
1011
|
try {
|
|
1012
|
-
const
|
|
1012
|
+
const invocation = {
|
|
1013
1013
|
sessionId: this.sessionId,
|
|
1014
|
-
managedSettingsEnabled: this.managedSettingsEnabled
|
|
1015
|
-
|
|
1014
|
+
managedSettingsEnabled: this.managedSettingsEnabled,
|
|
1015
|
+
...promptRequest === void 0 ? {} : { promptRequest }
|
|
1016
|
+
};
|
|
1017
|
+
const handlerResult = await this.permissionHandler(permissionRequest, invocation);
|
|
1016
1018
|
const isAttributed = (0, import_types.isAttributedPermissionResult)(handlerResult);
|
|
1017
1019
|
const result = isAttributed ? handlerResult.result : handlerResult;
|
|
1018
1020
|
const decisionContext = isAttributed ? handlerResult.decisionContext : void 0;
|
package/dist/cliVersion.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const COPILOT_CLI_VERSION = "1.0.99-
|
|
1
|
+
export declare const COPILOT_CLI_VERSION = "1.0.99-1";
|
|
2
2
|
export declare const COPILOT_CLI_USE_NPM_PACKAGE = false;
|
package/dist/cliVersion.js
CHANGED
package/dist/generated/rpc.d.ts
CHANGED
|
@@ -91,7 +91,27 @@ export type AuthEnumerateQuery = {
|
|
|
91
91
|
* Account-collection query variant discriminator.
|
|
92
92
|
*/
|
|
93
93
|
kind: "providers";
|
|
94
|
+
} | {
|
|
95
|
+
provider: LoginProviderKind;
|
|
96
|
+
/**
|
|
97
|
+
* Account-collection query variant discriminator.
|
|
98
|
+
*/
|
|
99
|
+
kind: "loginAccounts";
|
|
94
100
|
};
|
|
101
|
+
/**
|
|
102
|
+
* A provider a consumer may interactively sign in with.
|
|
103
|
+
*
|
|
104
|
+
* This interface was referenced by `_RpcSchemaRoot`'s JSON-Schema
|
|
105
|
+
* via the `definition` "LoginProviderKind".
|
|
106
|
+
*/
|
|
107
|
+
/** @experimental */
|
|
108
|
+
export type LoginProviderKind =
|
|
109
|
+
/** OAuth github.com sign-in via the browser (web loopback + PKCE). */
|
|
110
|
+
"githubDotCom"
|
|
111
|
+
/** A GitHub Enterprise Cloud account — a GitHub account on a non-github.com host, e.g. *.ghe.com; the host is supplied interactively through the neutral input-required step. */
|
|
112
|
+
| "proxima"
|
|
113
|
+
/** Microsoft Entra sign-in that derives a GitHub (EMU) credential. */
|
|
114
|
+
| "entra";
|
|
95
115
|
/**
|
|
96
116
|
* Selects which typed accounts datum to read.
|
|
97
117
|
*
|
|
@@ -380,21 +400,28 @@ export type AuthEnumerateValue = {
|
|
|
380
400
|
* Enumerated account-collection variant discriminator.
|
|
381
401
|
*/
|
|
382
402
|
kind: "providers";
|
|
403
|
+
} | {
|
|
404
|
+
/**
|
|
405
|
+
* Cached base identities reusable by the selected login provider, active first.
|
|
406
|
+
*/
|
|
407
|
+
items: AuthLoginIdentity[];
|
|
408
|
+
/**
|
|
409
|
+
* Enumerated account-collection variant discriminator.
|
|
410
|
+
*/
|
|
411
|
+
kind: "loginAccounts";
|
|
383
412
|
};
|
|
384
413
|
/**
|
|
385
|
-
*
|
|
414
|
+
* How an interactive provider login should choose its base identity.
|
|
386
415
|
*
|
|
387
416
|
* This interface was referenced by `_RpcSchemaRoot`'s JSON-Schema
|
|
388
|
-
* via the `definition` "
|
|
417
|
+
* via the `definition` "AuthLoginMode".
|
|
389
418
|
*/
|
|
390
419
|
/** @experimental */
|
|
391
|
-
export type
|
|
392
|
-
/**
|
|
393
|
-
"
|
|
394
|
-
/**
|
|
395
|
-
| "
|
|
396
|
-
/** Microsoft Entra sign-in that derives a GitHub (EMU) credential. */
|
|
397
|
-
| "entra";
|
|
420
|
+
export type AuthLoginMode =
|
|
421
|
+
/** Use normal provider behavior, optionally pinned to accountId. */
|
|
422
|
+
"default"
|
|
423
|
+
/** Explicitly ask the provider to present its account-selection UI instead of serving from a retained identity. */
|
|
424
|
+
| "selectAccount";
|
|
398
425
|
/**
|
|
399
426
|
* One step in an interactive login flow. The consumer acts on the step and calls advance to proceed. Browser-open is encoded as two distinct steps by design: `open-url` is CONSUMER-driven (the provider surfaces the authorize URL and the consumer opens it — github.com/GHEC web), while `needs-interaction` is PROVIDER-driven (the provider opens the browser or broker UI itself and does not surface a URL — Entra).
|
|
400
427
|
*
|
|
@@ -2433,6 +2460,30 @@ export type HostExitReason =
|
|
|
2433
2460
|
| "ownerDisconnected"
|
|
2434
2461
|
/** The runtime is shutting down. */
|
|
2435
2462
|
| "runtimeShutdown";
|
|
2463
|
+
/**
|
|
2464
|
+
* A supported image-service operation.
|
|
2465
|
+
*
|
|
2466
|
+
* This interface was referenced by `_RpcSchemaRoot`'s JSON-Schema
|
|
2467
|
+
* via the `definition` "ImageToolModelOperation".
|
|
2468
|
+
*/
|
|
2469
|
+
/** @experimental */
|
|
2470
|
+
export type ImageToolModelOperation =
|
|
2471
|
+
/** Generate an image from a text prompt. */
|
|
2472
|
+
"generate"
|
|
2473
|
+
/** Generate or edit an image using explicitly selected image inputs. */
|
|
2474
|
+
| "edit";
|
|
2475
|
+
/**
|
|
2476
|
+
* Account availability of the runtime image model. Discovery errors are returned as errors, not converted to unavailable.
|
|
2477
|
+
*
|
|
2478
|
+
* This interface was referenced by `_RpcSchemaRoot`'s JSON-Schema
|
|
2479
|
+
* via the `definition` "ImageToolModelAvailability".
|
|
2480
|
+
*/
|
|
2481
|
+
/** @experimental */
|
|
2482
|
+
export type ImageToolModelAvailability =
|
|
2483
|
+
/** The account has access to a supported image operation. */
|
|
2484
|
+
"available"
|
|
2485
|
+
/** The runtime default is not available to this account; enabling the tool cannot grant access. */
|
|
2486
|
+
| "unavailable";
|
|
2436
2487
|
/**
|
|
2437
2488
|
* Only resource kinds with an implemented installation engine have a review variant.
|
|
2438
2489
|
*
|
|
@@ -7731,6 +7782,27 @@ export interface ProviderDescriptor {
|
|
|
7731
7782
|
*/
|
|
7732
7783
|
available: boolean;
|
|
7733
7784
|
}
|
|
7785
|
+
/**
|
|
7786
|
+
* A cached base identity a provider can reuse for login without asking the user to choose an account again.
|
|
7787
|
+
*
|
|
7788
|
+
* This interface was referenced by `_RpcSchemaRoot`'s JSON-Schema
|
|
7789
|
+
* via the `definition` "AuthLoginIdentity".
|
|
7790
|
+
*/
|
|
7791
|
+
/** @experimental */
|
|
7792
|
+
export interface AuthLoginIdentity {
|
|
7793
|
+
/**
|
|
7794
|
+
* Opaque provider-owned identity id. Pass it back to accounts.login.begin; consumers must not parse it.
|
|
7795
|
+
*/
|
|
7796
|
+
accountId: string;
|
|
7797
|
+
/**
|
|
7798
|
+
* Human-readable sign-in label owned by the runtime.
|
|
7799
|
+
*/
|
|
7800
|
+
label: string;
|
|
7801
|
+
/**
|
|
7802
|
+
* Whether this base identity owns the session's active derived account.
|
|
7803
|
+
*/
|
|
7804
|
+
active: boolean;
|
|
7805
|
+
}
|
|
7734
7806
|
/**
|
|
7735
7807
|
* Credential-free identity metadata.
|
|
7736
7808
|
*
|
|
@@ -7789,7 +7861,7 @@ export interface AuthLoginAdvanceRequest {
|
|
|
7789
7861
|
input?: string;
|
|
7790
7862
|
}
|
|
7791
7863
|
/**
|
|
7792
|
-
* Begin an interactive login flow for a provider kind
|
|
7864
|
+
* Begin an interactive login flow for a provider kind, optionally reusing a cached base identity or explicitly requesting provider account selection.
|
|
7793
7865
|
*
|
|
7794
7866
|
* This interface was referenced by `_RpcSchemaRoot`'s JSON-Schema
|
|
7795
7867
|
* via the `definition` "AuthLoginBeginRequest".
|
|
@@ -7797,6 +7869,11 @@ export interface AuthLoginAdvanceRequest {
|
|
|
7797
7869
|
/** @experimental */
|
|
7798
7870
|
export interface AuthLoginBeginRequest {
|
|
7799
7871
|
kind: LoginProviderKind;
|
|
7872
|
+
mode?: AuthLoginMode;
|
|
7873
|
+
/**
|
|
7874
|
+
* Opaque cached base identity id returned by accounts.enumerate loginAccounts. Valid only with default mode; consumers must not parse it.
|
|
7875
|
+
*/
|
|
7876
|
+
accountId?: string;
|
|
7800
7877
|
}
|
|
7801
7878
|
/**
|
|
7802
7879
|
* A started login flow: its opaque id and first step.
|
|
@@ -13668,6 +13745,62 @@ export interface HostUnregisterSessionRequest {
|
|
|
13668
13745
|
*/
|
|
13669
13746
|
sessionId: string;
|
|
13670
13747
|
}
|
|
13748
|
+
/**
|
|
13749
|
+
* The runtime-selected image model and its account availability. Availability is independent of per-session image-generation enablement and does not override session policy or permissions.
|
|
13750
|
+
*
|
|
13751
|
+
* This interface was referenced by `_RpcSchemaRoot`'s JSON-Schema
|
|
13752
|
+
* via the `definition` "ImageToolModel".
|
|
13753
|
+
*/
|
|
13754
|
+
/** @experimental */
|
|
13755
|
+
export interface ImageToolModel {
|
|
13756
|
+
/**
|
|
13757
|
+
* Image model identifier selected by the runtime.
|
|
13758
|
+
*/
|
|
13759
|
+
id: string;
|
|
13760
|
+
/**
|
|
13761
|
+
* Human-readable model name, supplied by the runtime when unavailable from the catalog.
|
|
13762
|
+
*/
|
|
13763
|
+
name: string;
|
|
13764
|
+
/**
|
|
13765
|
+
* Image operations supported by the model's available versioned endpoints.
|
|
13766
|
+
*/
|
|
13767
|
+
supportedOperations: ImageToolModelOperation[];
|
|
13768
|
+
/**
|
|
13769
|
+
* Whether this is the model the runtime currently uses for its native image tool.
|
|
13770
|
+
*/
|
|
13771
|
+
isDefault: boolean;
|
|
13772
|
+
availability: ImageToolModelAvailability;
|
|
13773
|
+
pricing?: ImageToolModelPricing;
|
|
13774
|
+
}
|
|
13775
|
+
/**
|
|
13776
|
+
* Default-tier text and image token prices reported for an image model, in AI credits per billing batch. Missing rates remain absent; these are not per-image quotes or actual billed usage.
|
|
13777
|
+
*
|
|
13778
|
+
* This interface was referenced by `_RpcSchemaRoot`'s JSON-Schema
|
|
13779
|
+
* via the `definition` "ImageToolModelPricing".
|
|
13780
|
+
*/
|
|
13781
|
+
/** @experimental */
|
|
13782
|
+
export interface ImageToolModelPricing {
|
|
13783
|
+
/**
|
|
13784
|
+
* Number of tokens per billing batch.
|
|
13785
|
+
*/
|
|
13786
|
+
batchSize: number;
|
|
13787
|
+
/**
|
|
13788
|
+
* AI credits per batch of text-input tokens, including a reported zero.
|
|
13789
|
+
*/
|
|
13790
|
+
textInputPrice?: number;
|
|
13791
|
+
/**
|
|
13792
|
+
* AI credits per batch of text-output tokens, not generated image tokens.
|
|
13793
|
+
*/
|
|
13794
|
+
textOutputPrice?: number;
|
|
13795
|
+
/**
|
|
13796
|
+
* Distinct AI credits per batch of image-input tokens, when reported, including zero.
|
|
13797
|
+
*/
|
|
13798
|
+
imageInputPrice?: number;
|
|
13799
|
+
/**
|
|
13800
|
+
* Distinct AI credits per batch of image-output tokens, when reported, including zero.
|
|
13801
|
+
*/
|
|
13802
|
+
imageOutputPrice?: number;
|
|
13803
|
+
}
|
|
13671
13804
|
/**
|
|
13672
13805
|
* One connection-owned, expiring request for a trusted host's explicit user decision.
|
|
13673
13806
|
*
|
|
@@ -18132,6 +18265,10 @@ export interface ModelList {
|
|
|
18132
18265
|
*/
|
|
18133
18266
|
models: Model[];
|
|
18134
18267
|
auto?: AutoTierMetadata;
|
|
18268
|
+
/**
|
|
18269
|
+
* The runtime's default image model, separate from conversation models, with its availability for the resolved account. The default is reported even when unavailable; clients choose whether to display it. These entries must not be selected as chat models. Absent on runtimes that do not expose this catalog.
|
|
18270
|
+
*/
|
|
18271
|
+
imageModels?: ImageToolModel[];
|
|
18135
18272
|
}
|
|
18136
18273
|
/** @experimental */
|
|
18137
18274
|
export interface ModelPickerPersistenceRequest {
|
|
@@ -21257,6 +21394,19 @@ export interface ProtocolExternalToolDefinition {
|
|
|
21257
21394
|
[k: string]: JsonValue | undefined;
|
|
21258
21395
|
};
|
|
21259
21396
|
}
|
|
21397
|
+
/**
|
|
21398
|
+
* Opt into native CAPI image generation.
|
|
21399
|
+
*
|
|
21400
|
+
* This interface was referenced by `_RpcSchemaRoot`'s JSON-Schema
|
|
21401
|
+
* via the `definition` "ProtocolImageGenerationOptions".
|
|
21402
|
+
*/
|
|
21403
|
+
/** @experimental */
|
|
21404
|
+
export interface ProtocolImageGenerationOptions {
|
|
21405
|
+
/**
|
|
21406
|
+
* Disabled by default for SDK sessions. CAPI model access and permissions still apply.
|
|
21407
|
+
*/
|
|
21408
|
+
enabled?: boolean;
|
|
21409
|
+
}
|
|
21260
21410
|
/**
|
|
21261
21411
|
* BYOK providers and/or models to add to the session's registry at runtime. Both fields are optional; provide providers, models, or both.
|
|
21262
21412
|
*
|
|
@@ -26839,6 +26989,7 @@ export interface SessionTelemetryEngagement {
|
|
|
26839
26989
|
*/
|
|
26840
26990
|
/** @experimental */
|
|
26841
26991
|
export interface SessionUpdateOptionsParams {
|
|
26992
|
+
imageGeneration?: ProtocolImageGenerationOptions;
|
|
26842
26993
|
/**
|
|
26843
26994
|
* The model ID to use for assistant turns.
|
|
26844
26995
|
*/
|
|
@@ -33649,7 +33800,7 @@ export declare function createSessionRpc(connection: MessageConnection, sessionI
|
|
|
33649
33800
|
/**
|
|
33650
33801
|
* Begin an interactive login flow for a provider kind (dispatch is kind-only) and return its opaque flow id and first step.
|
|
33651
33802
|
*
|
|
33652
|
-
* @param params Begin an interactive login flow for a provider kind
|
|
33803
|
+
* @param params Begin an interactive login flow for a provider kind, optionally reusing a cached base identity or explicitly requesting provider account selection.
|
|
33653
33804
|
*
|
|
33654
33805
|
* @returns A started login flow: its opaque id and first step.
|
|
33655
33806
|
*/
|
package/dist/generated/rpc.js
CHANGED
|
@@ -2128,7 +2128,7 @@ function createSessionRpc(connection, sessionId) {
|
|
|
2128
2128
|
/**
|
|
2129
2129
|
* Begin an interactive login flow for a provider kind (dispatch is kind-only) and return its opaque flow id and first step.
|
|
2130
2130
|
*
|
|
2131
|
-
* @param params Begin an interactive login flow for a provider kind
|
|
2131
|
+
* @param params Begin an interactive login flow for a provider kind, optionally reusing a cached base identity or explicitly requesting provider account selection.
|
|
2132
2132
|
*
|
|
2133
2133
|
* @returns A started login flow: its opaque id and first step.
|
|
2134
2134
|
*/
|
|
@@ -3907,6 +3907,10 @@ export interface CompactionStartEvent {
|
|
|
3907
3907
|
* Context window breakdown at the start of LLM-powered conversation compaction
|
|
3908
3908
|
*/
|
|
3909
3909
|
export interface CompactionStartData {
|
|
3910
|
+
/**
|
|
3911
|
+
* Identifier shared with the matching compaction completion event
|
|
3912
|
+
*/
|
|
3913
|
+
compactionAttemptId?: string;
|
|
3910
3914
|
/**
|
|
3911
3915
|
* Token count from non-system messages (user, assistant, tool) at compaction start
|
|
3912
3916
|
*/
|
|
@@ -3919,10 +3923,18 @@ export interface CompactionStartData {
|
|
|
3919
3923
|
* Model identifier used for compaction, when known
|
|
3920
3924
|
*/
|
|
3921
3925
|
model?: string;
|
|
3926
|
+
/**
|
|
3927
|
+
* Destination model for a model-switch compaction when it differs from the compacting model
|
|
3928
|
+
*/
|
|
3929
|
+
switchTargetModel?: string;
|
|
3922
3930
|
/**
|
|
3923
3931
|
* Token count from system message(s) at compaction start
|
|
3924
3932
|
*/
|
|
3925
3933
|
systemTokens?: number;
|
|
3934
|
+
/**
|
|
3935
|
+
* Destination prompt-token budget when it differs from the effective compaction token limit
|
|
3936
|
+
*/
|
|
3937
|
+
targetPromptTokenLimit?: number;
|
|
3926
3938
|
/**
|
|
3927
3939
|
* Model context window token limit the compaction is targeting, when known
|
|
3928
3940
|
*/
|
|
@@ -3979,6 +3991,10 @@ export interface CompactionCompleteData {
|
|
|
3979
3991
|
* File path where the checkpoint was stored
|
|
3980
3992
|
*/
|
|
3981
3993
|
checkpointPath?: string;
|
|
3994
|
+
/**
|
|
3995
|
+
* Identifier shared with the matching compaction start event
|
|
3996
|
+
*/
|
|
3997
|
+
compactionAttemptId?: string;
|
|
3982
3998
|
compactionTokensUsed?: CompactionCompleteCompactionTokensUsed;
|
|
3983
3999
|
/**
|
|
3984
4000
|
* Token count from non-system messages (user, assistant, tool) after compaction
|
|
@@ -3992,10 +4008,30 @@ export interface CompactionCompleteData {
|
|
|
3992
4008
|
* Error message if compaction failed
|
|
3993
4009
|
*/
|
|
3994
4010
|
error?: string;
|
|
4011
|
+
/**
|
|
4012
|
+
* Bounded reason for a typed failed outcome. Unknown future values are preserved.
|
|
4013
|
+
*/
|
|
4014
|
+
failureReason?: string;
|
|
4015
|
+
/**
|
|
4016
|
+
* Model identifier at admission when routing later changed to the reported compaction model
|
|
4017
|
+
*/
|
|
4018
|
+
initialModel?: string;
|
|
3995
4019
|
/**
|
|
3996
4020
|
* Number of messages removed during compaction
|
|
3997
4021
|
*/
|
|
3998
4022
|
messagesRemoved?: number;
|
|
4023
|
+
/**
|
|
4024
|
+
* Model identifier used for compaction when provider usage does not already supply it
|
|
4025
|
+
*/
|
|
4026
|
+
model?: string;
|
|
4027
|
+
/**
|
|
4028
|
+
* Typed terminal outcome for this observed compaction completion. Unknown future values are preserved.
|
|
4029
|
+
*/
|
|
4030
|
+
outcome?: string;
|
|
4031
|
+
/**
|
|
4032
|
+
* Bounded reason for an expected non-application outcome such as cancellation or no applicable history. Unknown future values are preserved.
|
|
4033
|
+
*/
|
|
4034
|
+
outcomeReason?: string;
|
|
3999
4035
|
/**
|
|
4000
4036
|
* Total tokens in conversation after compaction
|
|
4001
4037
|
*/
|
|
@@ -4029,10 +4065,22 @@ export interface CompactionCompleteData {
|
|
|
4029
4065
|
* LLM-generated summary of the compacted conversation history
|
|
4030
4066
|
*/
|
|
4031
4067
|
summaryContent?: string;
|
|
4068
|
+
/**
|
|
4069
|
+
* Destination model for a model-switch compaction when it differs from the compacting model
|
|
4070
|
+
*/
|
|
4071
|
+
switchTargetModel?: string;
|
|
4032
4072
|
/**
|
|
4033
4073
|
* Token count from system message(s) after compaction
|
|
4034
4074
|
*/
|
|
4035
4075
|
systemTokens?: number;
|
|
4076
|
+
/**
|
|
4077
|
+
* Destination prompt-token budget when it differs from the effective compaction token limit
|
|
4078
|
+
*/
|
|
4079
|
+
targetPromptTokenLimit?: number;
|
|
4080
|
+
/**
|
|
4081
|
+
* Open accounting-basis identifier for trustworthy paired pre/post token measurements. The current runtime emits local_full_context_estimate.
|
|
4082
|
+
*/
|
|
4083
|
+
tokenAccountingBasis?: string;
|
|
4036
4084
|
/**
|
|
4037
4085
|
* Model context window token limit the compaction was targeting, when known
|
|
4038
4086
|
*/
|
|
@@ -7559,6 +7607,12 @@ export interface ToolExecutionCompleteData {
|
|
|
7559
7607
|
toolTelemetry?: {
|
|
7560
7608
|
[k: string]: JsonValue | undefined;
|
|
7561
7609
|
};
|
|
7610
|
+
/**
|
|
7611
|
+
* Provider-reported usage of a separately metered runtime-owned tool operation, independent of the conversation model. Present on success or failure when usage is known. Experimental.
|
|
7612
|
+
*
|
|
7613
|
+
* @experimental
|
|
7614
|
+
*/
|
|
7615
|
+
toolUsage?: ToolExecutionUsage;
|
|
7562
7616
|
/**
|
|
7563
7617
|
* Identifier for the agent loop turn this tool was invoked in, matching the corresponding assistant.turn_start event
|
|
7564
7618
|
*/
|
|
@@ -8071,6 +8125,50 @@ export interface ToolExecutionCompleteToolDescriptionMetaUI {
|
|
|
8071
8125
|
*/
|
|
8072
8126
|
visibility?: ToolExecutionCompleteToolDescriptionMetaUIVisibility[];
|
|
8073
8127
|
}
|
|
8128
|
+
/**
|
|
8129
|
+
* Authoritative usage reported by a separately metered runtime-owned tool operation. May be present on a failed tool when the service reported usage before local result processing failed. Missing token counts or billing mean unavailable, not zero.
|
|
8130
|
+
*/
|
|
8131
|
+
/** @experimental */
|
|
8132
|
+
export interface ToolExecutionUsage {
|
|
8133
|
+
accounting?: UsageAccountingIdentity;
|
|
8134
|
+
copilotUsage?: AssistantUsageCopilotUsage;
|
|
8135
|
+
/**
|
|
8136
|
+
* Total provider-reported input tokens across all modalities.
|
|
8137
|
+
*/
|
|
8138
|
+
inputTokens?: number;
|
|
8139
|
+
inputTokensDetails?: ToolExecutionUsageTokenDetails;
|
|
8140
|
+
/**
|
|
8141
|
+
* Requested model for the tool operation, independent of the conversation model. Not a provider-confirmed serving model.
|
|
8142
|
+
*/
|
|
8143
|
+
model: string;
|
|
8144
|
+
/**
|
|
8145
|
+
* Total provider-reported output tokens across all modalities.
|
|
8146
|
+
*/
|
|
8147
|
+
outputTokens?: number;
|
|
8148
|
+
outputTokensDetails?: ToolExecutionUsageTokenDetails;
|
|
8149
|
+
provider?: ModelProviderRef;
|
|
8150
|
+
/**
|
|
8151
|
+
* Runtime-generated identifier for this metered operation. Deduplicates repeated delivery or replay; not an upstream billing identifier.
|
|
8152
|
+
*/
|
|
8153
|
+
requestId: string;
|
|
8154
|
+
/**
|
|
8155
|
+
* Provider-reported sum of input and output tokens.
|
|
8156
|
+
*/
|
|
8157
|
+
totalTokens?: number;
|
|
8158
|
+
}
|
|
8159
|
+
/**
|
|
8160
|
+
* Provider-reported image and text token counts, which are subsets of the corresponding total rather than additional tokens.
|
|
8161
|
+
*/
|
|
8162
|
+
export interface ToolExecutionUsageTokenDetails {
|
|
8163
|
+
/**
|
|
8164
|
+
* Image tokens included in the corresponding input or output total.
|
|
8165
|
+
*/
|
|
8166
|
+
imageTokens: number;
|
|
8167
|
+
/**
|
|
8168
|
+
* Text tokens included in the corresponding input or output total.
|
|
8169
|
+
*/
|
|
8170
|
+
textTokens: number;
|
|
8171
|
+
}
|
|
8074
8172
|
/**
|
|
8075
8173
|
* Session event "tool_search.activated". Persisted generic client-side tool activations restored when a session resumes.
|
|
8076
8174
|
*/
|
package/dist/session.js
CHANGED
|
@@ -825,12 +825,12 @@ class CopilotSession {
|
|
|
825
825
|
}
|
|
826
826
|
}
|
|
827
827
|
} else if (event.type === "permission.requested") {
|
|
828
|
-
const { requestId, permissionRequest, resolvedByHook } = event.data;
|
|
828
|
+
const { requestId, permissionRequest, promptRequest, resolvedByHook } = event.data;
|
|
829
829
|
if (resolvedByHook) {
|
|
830
830
|
return;
|
|
831
831
|
}
|
|
832
832
|
if (this.permissionHandler) {
|
|
833
|
-
void this._executePermissionAndRespond(requestId, permissionRequest);
|
|
833
|
+
void this._executePermissionAndRespond(requestId, permissionRequest, promptRequest);
|
|
834
834
|
}
|
|
835
835
|
} else if (event.type === "mcp.oauth_required") {
|
|
836
836
|
const data = event.data;
|
|
@@ -989,12 +989,14 @@ class CopilotSession {
|
|
|
989
989
|
* Executes a permission handler and sends the result back via RPC.
|
|
990
990
|
* @internal
|
|
991
991
|
*/
|
|
992
|
-
async _executePermissionAndRespond(requestId, permissionRequest) {
|
|
992
|
+
async _executePermissionAndRespond(requestId, permissionRequest, promptRequest) {
|
|
993
993
|
try {
|
|
994
|
-
const
|
|
994
|
+
const invocation = {
|
|
995
995
|
sessionId: this.sessionId,
|
|
996
|
-
managedSettingsEnabled: this.managedSettingsEnabled
|
|
997
|
-
|
|
996
|
+
managedSettingsEnabled: this.managedSettingsEnabled,
|
|
997
|
+
...promptRequest === void 0 ? {} : { promptRequest }
|
|
998
|
+
};
|
|
999
|
+
const handlerResult = await this.permissionHandler(permissionRequest, invocation);
|
|
998
1000
|
const isAttributed = isAttributedPermissionResult(handlerResult);
|
|
999
1001
|
const result = isAttributed ? handlerResult.result : handlerResult;
|
|
1000
1002
|
const decisionContext = isAttributed ? handlerResult.decisionContext : void 0;
|
package/dist/types.d.ts
CHANGED
|
@@ -988,10 +988,11 @@ import type { PermissionDecisionRequest, PermissionDecisionContext } from "./gen
|
|
|
988
988
|
* access the variant-specific fields (e.g. shell `commands`, write
|
|
989
989
|
* `fileName`/`diff`, mcp `toolName`/`args`).
|
|
990
990
|
*
|
|
991
|
-
* `managedApprovalRequired`
|
|
992
|
-
*
|
|
993
|
-
*
|
|
994
|
-
*
|
|
991
|
+
* On the raw `permissionRequest`, `managedApprovalRequired` preserves managed
|
|
992
|
+
* policy provenance and one-shot restrictions. To determine whether a human
|
|
993
|
+
* response is still required, hosts should prefer
|
|
994
|
+
* `event.data.promptRequest?.managedApprovalRequired` when `promptRequest` is
|
|
995
|
+
* present, and fall back to the raw marker for older runtimes.
|
|
995
996
|
*/
|
|
996
997
|
export type PermissionRequest = GeneratedPermissionRequest & {
|
|
997
998
|
readonly managedApprovalRequired?: boolean;
|
|
@@ -1036,10 +1037,23 @@ export declare function isAttributedPermissionResult(result: PermissionRequestRe
|
|
|
1036
1037
|
* permission behavior.
|
|
1037
1038
|
*/
|
|
1038
1039
|
export declare function createAttributedPermissionResult(result: PermissionRequestResult | AttributedPermissionResult, decisionContext: PermissionDecisionContext): AttributedPermissionResult;
|
|
1039
|
-
|
|
1040
|
+
/**
|
|
1041
|
+
* Context supplied with a permission request callback.
|
|
1042
|
+
*/
|
|
1043
|
+
export interface PermissionHandlerInvocation {
|
|
1040
1044
|
sessionId: string;
|
|
1041
1045
|
managedSettingsEnabled?: boolean;
|
|
1042
|
-
|
|
1046
|
+
/**
|
|
1047
|
+
* Derived user-facing prompt context when supplied by the runtime.
|
|
1048
|
+
*
|
|
1049
|
+
* Managed requests retain their raw `managedApprovalRequired` marker. Only
|
|
1050
|
+
* standard prompt kinds (`commands`, `read`, `write`, `url`, and
|
|
1051
|
+
* `workflow`) can clear that human requirement after Assisted approval.
|
|
1052
|
+
* For missing or other prompt kinds, keep the raw marker authoritative.
|
|
1053
|
+
*/
|
|
1054
|
+
promptRequest?: PermissionRequestedData["promptRequest"];
|
|
1055
|
+
}
|
|
1056
|
+
export type PermissionHandler = (request: PermissionRequest, invocation: PermissionHandlerInvocation) => Promise<PermissionRequestResult | AttributedPermissionResult> | PermissionRequestResult | AttributedPermissionResult;
|
|
1043
1057
|
/**
|
|
1044
1058
|
* Approves permission requests when managed settings are disabled.
|
|
1045
1059
|
*/
|
package/package.json
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
"url": "https://github.com/github/copilot-agent-runtime.git",
|
|
6
6
|
"directory": "src/sdk/nodejs"
|
|
7
7
|
},
|
|
8
|
-
"version": "1.0.23-preview.
|
|
9
|
-
"copilotCliVersion": "1.0.99-
|
|
8
|
+
"version": "1.0.23-preview.1",
|
|
9
|
+
"copilotCliVersion": "1.0.99-1",
|
|
10
10
|
"description": "TypeScript SDK for programmatic control of GitHub Copilot CLI via JSON-RPC",
|
|
11
11
|
"main": "./dist/cjs/index.js",
|
|
12
12
|
"types": "./dist/index.d.ts",
|
|
@@ -81,6 +81,7 @@
|
|
|
81
81
|
"@typescript-eslint/parser": "^8.54.0",
|
|
82
82
|
"esbuild": "^0.28.1",
|
|
83
83
|
"eslint": "^9.0.0",
|
|
84
|
+
"file-entry-cache": "file:./scripts/eslint-file-cache",
|
|
84
85
|
"glob": "^13.0.1",
|
|
85
86
|
"hpke-js": "^1.8.0",
|
|
86
87
|
"json-schema": "^0.4.0",
|
|
@@ -97,6 +98,9 @@
|
|
|
97
98
|
"engines": {
|
|
98
99
|
"node": "^20.19.0 || >=22.12.0"
|
|
99
100
|
},
|
|
101
|
+
"overrides": {
|
|
102
|
+
"file-entry-cache": "$file-entry-cache"
|
|
103
|
+
},
|
|
100
104
|
"files": [
|
|
101
105
|
"dist/**/*",
|
|
102
106
|
"!dist/tsconfig.tsbuildinfo",
|
|
@@ -104,18 +108,18 @@
|
|
|
104
108
|
"README.md"
|
|
105
109
|
],
|
|
106
110
|
"copilotRuntime": {
|
|
107
|
-
"sourceSha": "
|
|
108
|
-
"version": "1.0.99-
|
|
111
|
+
"sourceSha": "7ea4e663f9dbacf776b91d6f8f2ff30b3a5b46eb",
|
|
112
|
+
"version": "1.0.99-1",
|
|
109
113
|
"visibility": "public"
|
|
110
114
|
},
|
|
111
115
|
"optionalDependencies": {
|
|
112
|
-
"@github/copilot-sdk-darwin-arm64": "1.0.23-preview.
|
|
113
|
-
"@github/copilot-sdk-darwin-x64": "1.0.23-preview.
|
|
114
|
-
"@github/copilot-sdk-linux-arm64": "1.0.23-preview.
|
|
115
|
-
"@github/copilot-sdk-linux-x64": "1.0.23-preview.
|
|
116
|
-
"@github/copilot-sdk-linuxmusl-arm64": "1.0.23-preview.
|
|
117
|
-
"@github/copilot-sdk-linuxmusl-x64": "1.0.23-preview.
|
|
118
|
-
"@github/copilot-sdk-win32-arm64": "1.0.23-preview.
|
|
119
|
-
"@github/copilot-sdk-win32-x64": "1.0.23-preview.
|
|
116
|
+
"@github/copilot-sdk-darwin-arm64": "1.0.23-preview.1",
|
|
117
|
+
"@github/copilot-sdk-darwin-x64": "1.0.23-preview.1",
|
|
118
|
+
"@github/copilot-sdk-linux-arm64": "1.0.23-preview.1",
|
|
119
|
+
"@github/copilot-sdk-linux-x64": "1.0.23-preview.1",
|
|
120
|
+
"@github/copilot-sdk-linuxmusl-arm64": "1.0.23-preview.1",
|
|
121
|
+
"@github/copilot-sdk-linuxmusl-x64": "1.0.23-preview.1",
|
|
122
|
+
"@github/copilot-sdk-win32-arm64": "1.0.23-preview.1",
|
|
123
|
+
"@github/copilot-sdk-win32-x64": "1.0.23-preview.1"
|
|
120
124
|
}
|
|
121
125
|
}
|