@github/copilot-sdk 1.0.29-preview.9 → 1.0.30-preview.0
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 +100 -7
- package/dist/cjs/cliVersion.js +1 -1
- package/dist/cjs/client.js +619 -93
- package/dist/cjs/decisions.js +139 -0
- package/dist/cjs/generated/rpc.js +164 -14
- package/dist/cjs/index.js +7 -0
- package/dist/cjs/session.js +102 -10
- package/dist/cliVersion.d.ts +1 -1
- package/dist/cliVersion.js +1 -1
- package/dist/client.d.ts +36 -3
- package/dist/client.js +621 -93
- package/dist/decisions.d.ts +65 -0
- package/dist/decisions.js +113 -0
- package/dist/generated/rpc.d.ts +1429 -127
- package/dist/generated/rpc.js +164 -14
- package/dist/generated/session-events.d.ts +213 -19
- package/dist/index.d.ts +4 -2
- package/dist/index.js +8 -0
- package/dist/session.d.ts +11 -2
- package/dist/session.js +102 -10
- package/dist/types.d.ts +141 -22
- package/docs/agent-author.md +5 -4
- package/docs/examples.md +77 -17
- package/package.json +12 -12
package/dist/session.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createSessionRpc } from "./generated/rpc.js";
|
|
2
|
-
import type { ModelSwitchAutoTierResult, SessionManagementPolicy } from "./generated/rpc.js";
|
|
2
|
+
import type { ModelSwitchAutoTierResult, PermissionsSetModeResult, SessionManagementPolicy } from "./generated/rpc.js";
|
|
3
3
|
import type { OpenCanvasInstance } from "./generated/rpc.js";
|
|
4
4
|
import type { MessageOptions, ResponseSchema, ContextTier, ReasoningEffort, ReasoningSummary, AutoTier, ModelCapabilitiesOverride, SessionCapabilities, SessionConfig, SessionEvent, SessionEventHandler, SessionEventType, SessionUiApi, SessionCreationHandler, TranscriptRecovery, TypedSessionEventHandler } from "./types.js";
|
|
5
5
|
import { type SessionWorkflowApi } from "./workflow.js";
|
|
@@ -38,10 +38,11 @@ export type AssistantMessageEvent = Extract<SessionEvent, {
|
|
|
38
38
|
* `overridesBuiltInTool: true`.
|
|
39
39
|
*/
|
|
40
40
|
export declare class CopilotSession {
|
|
41
|
-
|
|
41
|
+
private _sessionId;
|
|
42
42
|
private connection;
|
|
43
43
|
private _workspacePath?;
|
|
44
44
|
private _transcriptRecovery?;
|
|
45
|
+
private _permissionModeResult?;
|
|
45
46
|
private eventHandlers;
|
|
46
47
|
private typedEventHandlers;
|
|
47
48
|
private toolHandlers;
|
|
@@ -62,6 +63,7 @@ export declare class CopilotSession {
|
|
|
62
63
|
private autoModeSwitchHandler?;
|
|
63
64
|
private skillProvider?;
|
|
64
65
|
private sessionCreationHandler?;
|
|
66
|
+
private memoryStoreHandler?;
|
|
65
67
|
private hooks?;
|
|
66
68
|
private transformCallbacks?;
|
|
67
69
|
private _rpc;
|
|
@@ -95,6 +97,7 @@ export declare class CopilotSession {
|
|
|
95
97
|
* dropped invalidation from leaving the wait pending forever.
|
|
96
98
|
*/
|
|
97
99
|
private waitForWorkflowRun;
|
|
100
|
+
get sessionId(): string;
|
|
98
101
|
/**
|
|
99
102
|
* Typed session-scoped RPC methods.
|
|
100
103
|
*/
|
|
@@ -107,6 +110,12 @@ export declare class CopilotSession {
|
|
|
107
110
|
get workspacePath(): string | undefined;
|
|
108
111
|
/** Recovery observed while loading this session; undefined on a clean resume. */
|
|
109
112
|
get transcriptRecovery(): TranscriptRecovery | undefined;
|
|
113
|
+
/**
|
|
114
|
+
* Outcome of the `permissionMode` requested when this session was created
|
|
115
|
+
* or resumed: whether it was applied, and the authoritative mode the
|
|
116
|
+
* session started in. Undefined when no mode was requested.
|
|
117
|
+
*/
|
|
118
|
+
get permissionModeResult(): PermissionsSetModeResult | undefined;
|
|
110
119
|
/**
|
|
111
120
|
* Host capabilities reported when the session was created or resumed.
|
|
112
121
|
* Use this to check feature support before calling capability-gated APIs.
|
package/dist/session.js
CHANGED
|
@@ -270,8 +270,8 @@ class CopilotSession {
|
|
|
270
270
|
* @param traceContextProvider - Optional callback to get W3C Trace Context for outbound RPCs
|
|
271
271
|
* @internal This constructor is internal. Use {@link CopilotClient.createSession} to create sessions.
|
|
272
272
|
*/
|
|
273
|
-
constructor(
|
|
274
|
-
this.
|
|
273
|
+
constructor(_sessionId, connection, _workspacePath, traceContextProvider, options) {
|
|
274
|
+
this._sessionId = _sessionId;
|
|
275
275
|
this.connection = connection;
|
|
276
276
|
this._workspacePath = _workspacePath;
|
|
277
277
|
this.traceContextProvider = traceContextProvider;
|
|
@@ -279,10 +279,11 @@ class CopilotSession {
|
|
|
279
279
|
this.managedSettingsEnabled = options?.managedSettingsEnabled === true;
|
|
280
280
|
this.onDisconnected = options?.onDisconnected;
|
|
281
281
|
}
|
|
282
|
-
|
|
282
|
+
_sessionId;
|
|
283
283
|
connection;
|
|
284
284
|
_workspacePath;
|
|
285
285
|
_transcriptRecovery;
|
|
286
|
+
_permissionModeResult;
|
|
286
287
|
eventHandlers = /* @__PURE__ */ new Set();
|
|
287
288
|
typedEventHandlers = /* @__PURE__ */ new Map();
|
|
288
289
|
toolHandlers = /* @__PURE__ */ new Map();
|
|
@@ -303,6 +304,7 @@ class CopilotSession {
|
|
|
303
304
|
autoModeSwitchHandler;
|
|
304
305
|
skillProvider;
|
|
305
306
|
sessionCreationHandler;
|
|
307
|
+
memoryStoreHandler;
|
|
306
308
|
hooks;
|
|
307
309
|
transformCallbacks;
|
|
308
310
|
_rpc = null;
|
|
@@ -455,6 +457,15 @@ class CopilotSession {
|
|
|
455
457
|
void read();
|
|
456
458
|
});
|
|
457
459
|
}
|
|
460
|
+
get sessionId() {
|
|
461
|
+
return this._sessionId;
|
|
462
|
+
}
|
|
463
|
+
/** @internal */
|
|
464
|
+
_setSessionId(sessionId) {
|
|
465
|
+
this._sessionId = sessionId;
|
|
466
|
+
this._rpc = null;
|
|
467
|
+
this._internalRpc = null;
|
|
468
|
+
}
|
|
458
469
|
/**
|
|
459
470
|
* Typed session-scoped RPC methods.
|
|
460
471
|
*/
|
|
@@ -487,6 +498,18 @@ class CopilotSession {
|
|
|
487
498
|
setTranscriptRecovery(recovery) {
|
|
488
499
|
this._transcriptRecovery = recovery;
|
|
489
500
|
}
|
|
501
|
+
/**
|
|
502
|
+
* Outcome of the `permissionMode` requested when this session was created
|
|
503
|
+
* or resumed: whether it was applied, and the authoritative mode the
|
|
504
|
+
* session started in. Undefined when no mode was requested.
|
|
505
|
+
*/
|
|
506
|
+
get permissionModeResult() {
|
|
507
|
+
return this._permissionModeResult;
|
|
508
|
+
}
|
|
509
|
+
/** @internal */
|
|
510
|
+
setPermissionModeResult(result) {
|
|
511
|
+
this._permissionModeResult = result;
|
|
512
|
+
}
|
|
490
513
|
/**
|
|
491
514
|
* Host capabilities reported when the session was created or resumed.
|
|
492
515
|
* Use this to check feature support before calling capability-gated APIs.
|
|
@@ -535,6 +558,7 @@ class CopilotSession {
|
|
|
535
558
|
prompt: options.prompt,
|
|
536
559
|
source: options.source,
|
|
537
560
|
displayPrompt: options.displayPrompt,
|
|
561
|
+
clientTurnId: options.clientTurnId,
|
|
538
562
|
attachments: options.attachments,
|
|
539
563
|
mode: options.mode,
|
|
540
564
|
agentMode: options.agentMode,
|
|
@@ -894,6 +918,7 @@ class CopilotSession {
|
|
|
894
918
|
controller.abort();
|
|
895
919
|
}
|
|
896
920
|
this.pendingSessionCreations.clear();
|
|
921
|
+
this._clearMemoryStore();
|
|
897
922
|
this.eventHandlers.clear();
|
|
898
923
|
this.typedEventHandlers.clear();
|
|
899
924
|
this.toolHandlers.clear();
|
|
@@ -905,6 +930,7 @@ class CopilotSession {
|
|
|
905
930
|
this.autoModeSwitchHandler = void 0;
|
|
906
931
|
this.skillProvider = void 0;
|
|
907
932
|
this.sessionCreationHandler = void 0;
|
|
933
|
+
this.memoryStoreHandler = void 0;
|
|
908
934
|
this.hooks = void 0;
|
|
909
935
|
this.traceContextProvider = void 0;
|
|
910
936
|
this.bearerTokenProviders.clear();
|
|
@@ -1122,6 +1148,7 @@ class CopilotSession {
|
|
|
1122
1148
|
return;
|
|
1123
1149
|
}
|
|
1124
1150
|
this.pendingExternalTools.set(requestId, controller);
|
|
1151
|
+
let claimed = false;
|
|
1125
1152
|
try {
|
|
1126
1153
|
let availableTools;
|
|
1127
1154
|
if (toolName === TOOL_SEARCH_TOOL_NAME) {
|
|
@@ -1178,17 +1205,45 @@ class CopilotSession {
|
|
|
1178
1205
|
if (!this._claimExternalTool(requestId, controller)) {
|
|
1179
1206
|
return;
|
|
1180
1207
|
}
|
|
1208
|
+
claimed = true;
|
|
1181
1209
|
await this.rpc.tools.handlePendingToolCall({ requestId, result });
|
|
1182
1210
|
} catch (error) {
|
|
1183
|
-
if (
|
|
1211
|
+
if (claimed) {
|
|
1212
|
+
if (this.disconnected) {
|
|
1213
|
+
return;
|
|
1214
|
+
}
|
|
1215
|
+
console.error("External tool result delivery failed", {
|
|
1216
|
+
sessionId: this.sessionId,
|
|
1217
|
+
requestId,
|
|
1218
|
+
toolName,
|
|
1219
|
+
error
|
|
1220
|
+
});
|
|
1221
|
+
} else if (!this._claimExternalTool(requestId, controller)) {
|
|
1184
1222
|
return;
|
|
1185
1223
|
}
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
}
|
|
1190
|
-
|
|
1191
|
-
|
|
1224
|
+
let message = error instanceof Error ? error.message : String(error);
|
|
1225
|
+
if (!message) {
|
|
1226
|
+
message = error instanceof Error && error.name || "Error";
|
|
1227
|
+
}
|
|
1228
|
+
for (let attempt = 0; attempt < (claimed ? 1 : 2); attempt++) {
|
|
1229
|
+
try {
|
|
1230
|
+
await this.rpc.tools.handlePendingToolCall({ requestId, error: message });
|
|
1231
|
+
return;
|
|
1232
|
+
} catch (rpcError) {
|
|
1233
|
+
const retryable = !claimed && attempt === 0 && !this.disconnected;
|
|
1234
|
+
if (!retryable) {
|
|
1235
|
+
if (!(rpcError instanceof ConnectionError || rpcError instanceof ResponseError)) {
|
|
1236
|
+
throw rpcError;
|
|
1237
|
+
}
|
|
1238
|
+
return;
|
|
1239
|
+
}
|
|
1240
|
+
console.error("External tool error delivery failed", {
|
|
1241
|
+
sessionId: this.sessionId,
|
|
1242
|
+
requestId,
|
|
1243
|
+
toolName,
|
|
1244
|
+
error: rpcError
|
|
1245
|
+
});
|
|
1246
|
+
message = (rpcError instanceof Error ? rpcError.message || rpcError.name : "") || String(rpcError) || "Error";
|
|
1192
1247
|
}
|
|
1193
1248
|
}
|
|
1194
1249
|
} finally {
|
|
@@ -1891,6 +1946,43 @@ class CopilotSession {
|
|
|
1891
1946
|
throw error;
|
|
1892
1947
|
}
|
|
1893
1948
|
}
|
|
1949
|
+
/**
|
|
1950
|
+
* Registers the callback the runtime calls through `memoryStore.store`.
|
|
1951
|
+
* Registered before create or resume declares `hasMemoryStore`.
|
|
1952
|
+
* @internal
|
|
1953
|
+
*/
|
|
1954
|
+
_registerMemoryStore(handler) {
|
|
1955
|
+
this.assertConnected();
|
|
1956
|
+
this.memoryStoreHandler = handler;
|
|
1957
|
+
}
|
|
1958
|
+
/** @internal */
|
|
1959
|
+
_clearMemoryStore() {
|
|
1960
|
+
this.memoryStoreHandler = void 0;
|
|
1961
|
+
}
|
|
1962
|
+
/** @internal */
|
|
1963
|
+
async _handleMemoryStore(memory, signal) {
|
|
1964
|
+
this.assertConnected();
|
|
1965
|
+
const handler = this.memoryStoreHandler;
|
|
1966
|
+
if (!handler) throw new Error("No memory store is registered");
|
|
1967
|
+
try {
|
|
1968
|
+
await handler(
|
|
1969
|
+
{
|
|
1970
|
+
sessionId: memory.sessionId,
|
|
1971
|
+
subject: memory.subject,
|
|
1972
|
+
fact: memory.fact,
|
|
1973
|
+
citations: memory.citations,
|
|
1974
|
+
reason: memory.reason
|
|
1975
|
+
},
|
|
1976
|
+
{ signal }
|
|
1977
|
+
);
|
|
1978
|
+
} catch (error) {
|
|
1979
|
+
if (signal.aborted) {
|
|
1980
|
+
throw new ResponseError(-32800, "Memory store call cancelled");
|
|
1981
|
+
}
|
|
1982
|
+
console.warn("Memory store callback failed", error);
|
|
1983
|
+
throw new Error("Memory store callback failed");
|
|
1984
|
+
}
|
|
1985
|
+
}
|
|
1894
1986
|
/** @internal */
|
|
1895
1987
|
async _handleSessionManagementCreate(request, token) {
|
|
1896
1988
|
this.assertConnected();
|
package/dist/types.d.ts
CHANGED
|
@@ -6,12 +6,12 @@ import type { SessionFsProvider } from "./sessionFsProvider.js";
|
|
|
6
6
|
import type { CopilotRequestHandler } from "./copilotRequestHandler.js";
|
|
7
7
|
import type { InstallationConfirmationHandler } from "./installationConfirmation.js";
|
|
8
8
|
export type { InstallationConfirmationHandler } from "./installationConfirmation.js";
|
|
9
|
-
import type { AgentModelPolicy, AttachmentExtensionContext as GeneratedExtensionContextAttachment, AutoTier, ModelProviderRef, PermissionRequest as GeneratedPermissionRequest, PermissionRequestedData as GeneratedPermissionRequestedData, PermissionRequestedEvent as GeneratedPermissionRequestedEvent, ReasoningSummary, SessionLimitsConfig, SessionEvent as GeneratedSessionEvent } from "./generated/session-events.js";
|
|
9
|
+
import type { AgentModelPolicy, AttachmentExtensionContext as GeneratedExtensionContextAttachment, AutoTier, ModelProviderRef, PermissionMode, PermissionRequest as GeneratedPermissionRequest, PermissionRequestedData as GeneratedPermissionRequestedData, PermissionRequestedEvent as GeneratedPermissionRequestedEvent, ReasoningSummary, SessionLimitsConfig, SessionEvent as GeneratedSessionEvent } from "./generated/session-events.js";
|
|
10
10
|
import type { CopilotSession } from "./session.js";
|
|
11
11
|
import type { JsonValue } from "./workflow.js";
|
|
12
|
-
import type { ExtensionLaunchProviderHandler as GeneratedExtensionLaunchProvider, AutopilotOptions, GitHubTokenAcquireRequest, GitHubTokenAcquireResult, GitHubTelemetryNotification, HostDiagnostics, ModelBillingTokenPrices, DiagnosticsConfiguration, OpenCanvasInstance, ProtocolExternalToolNamespace, CurrentToolMetadata,
|
|
12
|
+
import type { ExtensionLaunchProviderHandler as GeneratedExtensionLaunchProvider, AutopilotOptions, GitHubTokenAcquireRequest, GitHubTokenAcquireResult, GitHubTelemetryNotification, HostDiagnostics, ModelBillingTokenPrices, DiagnosticsConfiguration, OpenCanvasInstance, ProtocolExternalToolNamespace, CurrentToolMetadata, NetworkAuthenticateNegotiateRequest, NetworkResolveProxyRequest, NetworkScope, SandboxConfig, SessionManagementCreateHostRequest, SessionManagementCreateResult } from "./generated/rpc.js";
|
|
13
13
|
import type { ToolSet } from "./toolSet.js";
|
|
14
|
-
export type {
|
|
14
|
+
export type { NetworkAuthenticateNegotiateRequest, NetworkResolveProxyRequest, NetworkScope, } from "./generated/rpc.js";
|
|
15
15
|
export type { RemoteSessionMode } from "./generated/rpc.js";
|
|
16
16
|
export type { AutopilotOptions } from "./generated/rpc.js";
|
|
17
17
|
export type { CurrentToolMetadata } from "./generated/rpc.js";
|
|
@@ -341,9 +341,11 @@ export interface CopilotClientOptions {
|
|
|
341
341
|
*/
|
|
342
342
|
extensionLaunchProvider?: ExtensionLaunchProvider;
|
|
343
343
|
/**
|
|
344
|
-
*
|
|
344
|
+
* Network callbacks through which the SDK host decides the runtime's proxies and supplies its
|
|
345
|
+
* Kerberos tokens. Registered before sessions start.
|
|
346
|
+
* @experimental
|
|
345
347
|
*/
|
|
346
|
-
|
|
348
|
+
network?: NetworkConfig;
|
|
347
349
|
/**
|
|
348
350
|
* Connection-global human review for experimental installation operations.
|
|
349
351
|
* Does not register or enable installation capabilities on the runtime.
|
|
@@ -473,25 +475,49 @@ export interface CopilotClientOptions {
|
|
|
473
475
|
}
|
|
474
476
|
/** Resolves launch profiles for extension entrypoints discovered by the runtime. */
|
|
475
477
|
export type ExtensionLaunchProvider = GeneratedExtensionLaunchProvider;
|
|
476
|
-
/**
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
478
|
+
/**
|
|
479
|
+
* Network callbacks through which the SDK host takes over parts of the runtime's networking, for
|
|
480
|
+
* example when the runtime runs in WSL or a container and should use VS Code's proxy settings and
|
|
481
|
+
* the host's Kerberos tickets. Each registered callback replaces the runtime's own handling for the
|
|
482
|
+
* traffic in {@link NetworkConfig.scope}; without it, the runtime handles that part itself.
|
|
483
|
+
*
|
|
484
|
+
* Each callback receives a `signal` that aborts when the runtime stops waiting: it cancels the
|
|
485
|
+
* request (for example when its wait times out) or the connection closes. The SDK then stops
|
|
486
|
+
* awaiting the callback and ignores any later result.
|
|
487
|
+
* @experimental
|
|
488
|
+
*/
|
|
489
|
+
export interface NetworkConfig {
|
|
480
490
|
/**
|
|
481
|
-
* `connection` (the default)
|
|
482
|
-
* `runtime` also
|
|
491
|
+
* `connection` (the default) serves only requests made for sessions this client creates or resumes;
|
|
492
|
+
* `runtime` also serves the runtime's shared background traffic. Only one connection at a time can
|
|
483
493
|
* hold `runtime` scope, so startup fails if another client holds it. The registration ends when the
|
|
484
494
|
* connection closes.
|
|
485
495
|
*/
|
|
486
|
-
scope?:
|
|
496
|
+
scope?: NetworkScope;
|
|
487
497
|
/**
|
|
488
|
-
* Returns
|
|
489
|
-
*
|
|
490
|
-
* `
|
|
491
|
-
*
|
|
492
|
-
*
|
|
498
|
+
* Returns the proxies for `request.url` as a PAC-style list such as
|
|
499
|
+
* `PROXY proxy.example:8080; HTTPS proxy.example:443; DIRECT` (the format of Electron's
|
|
500
|
+
* `session.resolveProxy`); return `DIRECT` for a direct connection, or `undefined` to let the runtime
|
|
501
|
+
* resolve the proxy itself, as if no callback were registered. Entry types the runtime doesn't
|
|
502
|
+
* support, such as SOCKS and QUIC, are skipped.
|
|
503
|
+
* `request.url` is the request target as a PAC script sees it: without credentials or fragment, and for
|
|
504
|
+
* `https` and `wss` also without path and query.
|
|
505
|
+
*
|
|
506
|
+
* The callback decides every request that would otherwise follow ambient proxy settings: proxy
|
|
507
|
+
* environment variables, `NO_PROXY` and operating-system proxy settings are not consulted unless it
|
|
508
|
+
* returns `undefined`, and a failing callback fails the request rather than connecting directly.
|
|
509
|
+
* Requests to loopback targets, and requests with an explicitly configured proxy, never consult it. The
|
|
510
|
+
* runtime caches answers, including `undefined`, for a few seconds.
|
|
511
|
+
*/
|
|
512
|
+
resolveProxy?: (request: NetworkResolveProxyRequest, signal: AbortSignal) => Promise<string | undefined>;
|
|
513
|
+
/**
|
|
514
|
+
* Returns a fresh, single-use base64 SPNEGO token without the `Negotiate ` prefix for a proxy's Negotiate
|
|
515
|
+
* challenge, or `undefined` when unavailable. The runtime then does not look up Kerberos credentials
|
|
516
|
+
* itself, so a missing token or a failing callback fails the request.
|
|
517
|
+
* The SPN uses the platform-independent `service/host[@REALM]` form; validate it before issuing
|
|
518
|
+
* credentials. Never log or persist tokens.
|
|
493
519
|
*/
|
|
494
|
-
|
|
520
|
+
authenticateNegotiate?: (request: NetworkAuthenticateNegotiateRequest, signal: AbortSignal) => Promise<string | undefined>;
|
|
495
521
|
}
|
|
496
522
|
/**
|
|
497
523
|
* Configuration for creating a session
|
|
@@ -816,6 +842,8 @@ export interface SessionCapabilities {
|
|
|
816
842
|
mcpApps?: boolean;
|
|
817
843
|
/** Whether the host supports canvas rendering. */
|
|
818
844
|
canvases?: boolean;
|
|
845
|
+
/** Whether the runtime acknowledges retained-request Auto recovery. Absence means unsupported. */
|
|
846
|
+
autoModeRecovery?: boolean;
|
|
819
847
|
};
|
|
820
848
|
}
|
|
821
849
|
/**
|
|
@@ -1251,13 +1279,26 @@ export type ExitPlanModeHandler = (request: ExitPlanModeRequest, invocation: {
|
|
|
1251
1279
|
sessionId: string;
|
|
1252
1280
|
}) => Promise<ExitPlanModeResult> | ExitPlanModeResult;
|
|
1253
1281
|
/**
|
|
1254
|
-
*
|
|
1282
|
+
* Context for an offer to recover the active request using Auto.
|
|
1283
|
+
*/
|
|
1284
|
+
export interface AutoModeRecoveryContext {
|
|
1285
|
+
requestId: string;
|
|
1286
|
+
originalModel: string;
|
|
1287
|
+
/** Whether this offer permits remembering consent. Currently true only for per-model rate limits. */
|
|
1288
|
+
allowAlways: boolean;
|
|
1289
|
+
interactionId?: string;
|
|
1290
|
+
originatingMessageId?: string;
|
|
1291
|
+
}
|
|
1292
|
+
/**
|
|
1293
|
+
* Request to switch to Auto after a rate limit or recover an eligible active request.
|
|
1255
1294
|
*/
|
|
1256
1295
|
export interface AutoModeSwitchRequest {
|
|
1257
|
-
/** The
|
|
1296
|
+
/** The upstream error code that triggered the request. */
|
|
1258
1297
|
errorCode?: string;
|
|
1259
1298
|
/** Seconds until the rate limit resets, when known. */
|
|
1260
1299
|
retryAfterSeconds?: number;
|
|
1300
|
+
/** Present only for retained-request recovery, not legacy future-message switching. */
|
|
1301
|
+
autoModeRecovery?: AutoModeRecoveryContext;
|
|
1261
1302
|
}
|
|
1262
1303
|
/**
|
|
1263
1304
|
* Response to an auto-mode-switch request.
|
|
@@ -1334,7 +1375,9 @@ export interface PreMcpToolCallHookOutput {
|
|
|
1334
1375
|
* Hook-controlled metadata to use for the outgoing MCP request.
|
|
1335
1376
|
* - undefined/absent: preserve the current request `_meta`
|
|
1336
1377
|
* - object: use this object as request `_meta`
|
|
1337
|
-
* - null:
|
|
1378
|
+
* - null: drop hook-controlled `_meta`; the runtime still sends its own keys,
|
|
1379
|
+
* `com.github.copilot/toolCallId` and `com.github.copilot/turnId` (present only
|
|
1380
|
+
* when the turn was started with a `clientTurnId`)
|
|
1338
1381
|
*/
|
|
1339
1382
|
metaToUse?: Record<string, unknown> | null;
|
|
1340
1383
|
}
|
|
@@ -1848,6 +1891,46 @@ export interface MemoryConfiguration {
|
|
|
1848
1891
|
* @experimental This option may change or be removed in a future release.
|
|
1849
1892
|
*/
|
|
1850
1893
|
mode?: "system-prompt" | "user-prompt";
|
|
1894
|
+
/**
|
|
1895
|
+
* Stores memories in the app instead of the built-in memory backends.
|
|
1896
|
+
*
|
|
1897
|
+
* The runtime validates the memory, filters secrets and requests approval,
|
|
1898
|
+
* then calls this callback. `store_memory` succeeds only after the returned
|
|
1899
|
+
* promise resolves; a rejection fails the tool call with a generic message
|
|
1900
|
+
* and nothing is stored elsewhere. `options.signal` aborts when the runtime
|
|
1901
|
+
* stops waiting, for example after its 60-second timeout. While set, the
|
|
1902
|
+
* runtime retrieves no memories and `vote_memory` is unavailable, so supply
|
|
1903
|
+
* recall yourself, for example through `systemMessage`.
|
|
1904
|
+
* @experimental This option may change or be removed in a future release.
|
|
1905
|
+
*/
|
|
1906
|
+
storeMemory?: (memory: StoredMemory, options: MemoryStoreCallOptions) => Promise<void>;
|
|
1907
|
+
}
|
|
1908
|
+
/**
|
|
1909
|
+
* Per-call options passed to {@link MemoryConfiguration.storeMemory}.
|
|
1910
|
+
* @experimental This type may change or be removed in a future release.
|
|
1911
|
+
*/
|
|
1912
|
+
export interface MemoryStoreCallOptions {
|
|
1913
|
+
/**
|
|
1914
|
+
* Aborted when the runtime cancels the call, for example when it times out
|
|
1915
|
+
* or the session disconnects. The runtime ignores any later result.
|
|
1916
|
+
*/
|
|
1917
|
+
signal: AbortSignal;
|
|
1918
|
+
}
|
|
1919
|
+
/**
|
|
1920
|
+
* A memory the agent asked to store, after validation, secret filtering and approval.
|
|
1921
|
+
* @experimental This type may change or be removed in a future release.
|
|
1922
|
+
*/
|
|
1923
|
+
export interface StoredMemory {
|
|
1924
|
+
/** ID of the session that stored the memory. */
|
|
1925
|
+
sessionId: string;
|
|
1926
|
+
/** Short topic the memory is about. */
|
|
1927
|
+
subject: string;
|
|
1928
|
+
/** The fact to remember. */
|
|
1929
|
+
fact: string;
|
|
1930
|
+
/** Sources supporting the fact, such as file paths with line numbers. */
|
|
1931
|
+
citations: string;
|
|
1932
|
+
/** Why the agent considers the fact worth remembering. */
|
|
1933
|
+
reason: string;
|
|
1851
1934
|
}
|
|
1852
1935
|
/**
|
|
1853
1936
|
* Configuration for handling large tool outputs.
|
|
@@ -1864,7 +1947,8 @@ export interface LargeToolOutputConfig {
|
|
|
1864
1947
|
enabled?: boolean;
|
|
1865
1948
|
/**
|
|
1866
1949
|
* Maximum size in bytes before output is written to a temp file.
|
|
1867
|
-
*
|
|
1950
|
+
* Uses the runtime's configured threshold when unset.
|
|
1951
|
+
* @default 20480
|
|
1868
1952
|
*/
|
|
1869
1953
|
maxSizeBytes?: number;
|
|
1870
1954
|
/**
|
|
@@ -2182,6 +2266,12 @@ export interface SkillProviderCallOptions {
|
|
|
2182
2266
|
* an existing one).
|
|
2183
2267
|
*/
|
|
2184
2268
|
export interface SessionConfigBase {
|
|
2269
|
+
/**
|
|
2270
|
+
* Whether the model may request multiple tool calls per response. Defaults to true.
|
|
2271
|
+
* False sends a provider hint, not an execution guarantee: all returned calls
|
|
2272
|
+
* are still handled and handlers may run concurrently. Re-supply on cold resume.
|
|
2273
|
+
*/
|
|
2274
|
+
allowMultipleToolCalls?: boolean;
|
|
2185
2275
|
/** Exact model IDs allowed by the host. Omission preserves runtime policy. */
|
|
2186
2276
|
allowedModels?: string[];
|
|
2187
2277
|
/**
|
|
@@ -2535,6 +2625,15 @@ export interface SessionConfigBase {
|
|
|
2535
2625
|
* When provided, enables `autoModeSwitch.request` callbacks.
|
|
2536
2626
|
*/
|
|
2537
2627
|
onAutoModeSwitchRequest?: AutoModeSwitchHandler;
|
|
2628
|
+
/**
|
|
2629
|
+
* Opt in to runtime-owned recovery of an eligible active request using Auto.
|
|
2630
|
+
* Requires `onAutoModeSwitchRequest` and a runtime acknowledgment in
|
|
2631
|
+
* `session.capabilities.ui.autoModeRecovery`; unsupported enrollment rejects
|
|
2632
|
+
* create/resume and detaches the session. Re-supply when resuming.
|
|
2633
|
+
* Consent has no runtime deadline. The handler must not resend or rewind.
|
|
2634
|
+
* @default false
|
|
2635
|
+
*/
|
|
2636
|
+
autoModeRecovery?: boolean;
|
|
2538
2637
|
/**
|
|
2539
2638
|
* Hook handlers for intercepting session lifecycle events.
|
|
2540
2639
|
* When provided, enables hooks callback allowing custom logic at various points.
|
|
@@ -2752,6 +2851,16 @@ export interface SessionConfigBase {
|
|
|
2752
2851
|
* for cloud sessions and when resuming a session that is already active.
|
|
2753
2852
|
*/
|
|
2754
2853
|
interactiveUser?: boolean;
|
|
2854
|
+
/**
|
|
2855
|
+
* Permission mode applied before the session's first turn: before
|
|
2856
|
+
* `createSession` returns, and before a resume continues pending work.
|
|
2857
|
+
* Uses the same checks as `session.rpc.permissions.setMode`; a mode that
|
|
2858
|
+
* managed policy or session capabilities refuse leaves the current mode in
|
|
2859
|
+
* place. `session.permissionModeResult` reports whether it was applied and
|
|
2860
|
+
* the authoritative mode. Omit to keep the default mode on create, or the
|
|
2861
|
+
* restored mode on resume. Not supported for cloud sessions.
|
|
2862
|
+
*/
|
|
2863
|
+
permissionMode?: PermissionMode;
|
|
2755
2864
|
/**
|
|
2756
2865
|
* Host-injected enterprise managed settings for this session.
|
|
2757
2866
|
*
|
|
@@ -3271,6 +3380,16 @@ export interface MessageOptions {
|
|
|
3271
3380
|
* If provided, this is shown in the timeline instead of `prompt`.
|
|
3272
3381
|
*/
|
|
3273
3382
|
displayPrompt?: string;
|
|
3383
|
+
/**
|
|
3384
|
+
* Opaque caller-chosen ID for the turn this message starts. The runtime copies it unchanged
|
|
3385
|
+
* into `_meta["com.github.copilot/turnId"]` on every MCP `tools/call` made while serving that
|
|
3386
|
+
* turn, including calls from sub-agents and Autopilot continuations. When a running turn
|
|
3387
|
+
* consumes the message as visible user steering, the value (or its absence) replaces the
|
|
3388
|
+
* turn's ID from the next model call onward. The `user.message` event for the message echoes
|
|
3389
|
+
* it as `clientTurnId` and is persisted like other events; the value stamped on MCP calls is
|
|
3390
|
+
* held in memory only and is not restored on resume.
|
|
3391
|
+
*/
|
|
3392
|
+
clientTurnId?: string;
|
|
3274
3393
|
/**
|
|
3275
3394
|
* JSON Schema or a Zod schema for this run's output, including requests after tool calls.
|
|
3276
3395
|
* Independent sends do not inherit it. Ordinary immediate steering retains the active
|
package/docs/agent-author.md
CHANGED
|
@@ -131,6 +131,7 @@ hooks: {
|
|
|
131
131
|
```
|
|
132
132
|
|
|
133
133
|
All hook inputs include `sessionId`, `timestamp` (`Date`) and `workingDirectory`.
|
|
134
|
+
Tool hooks also receive `toolCallId` when the runtime supplies one; correlate a call's hooks with `(input.sessionId, input.toolCallId)`.
|
|
134
135
|
All handlers receive `invocation: { sessionId: string }` as the second argument.
|
|
135
136
|
All handlers may return `void`/`undefined` (no-op) or an output object.
|
|
136
137
|
|
|
@@ -162,7 +163,7 @@ runtime-generated context.
|
|
|
162
163
|
|
|
163
164
|
### onPreToolUse
|
|
164
165
|
|
|
165
|
-
**Input:** `{ toolName: string, toolArgs: unknown, timestamp, workingDirectory }`
|
|
166
|
+
**Input:** `{ toolCallId?: string, toolName: string, toolArgs: unknown, timestamp, workingDirectory }`
|
|
166
167
|
|
|
167
168
|
**Output (all fields optional):**
|
|
168
169
|
| Field | Type | Effect |
|
|
@@ -183,11 +184,11 @@ object sent with the request; to allow, deny or change the call itself, use
|
|
|
183
184
|
**Output (all fields optional):**
|
|
184
185
|
| Field | Type | Effect |
|
|
185
186
|
|-------|------|--------|
|
|
186
|
-
| `metaToUse` | `Record<string, unknown> \| null` | An object becomes the request's `_meta`; `null` omits it; leaving it out keeps the current `_meta` |
|
|
187
|
+
| `metaToUse` | `Record<string, unknown> \| null` | An object becomes the request's `_meta`; `null` omits it, except for the runtime's `com.github.copilot/toolCallId` and `com.github.copilot/turnId` keys; leaving it out keeps the current `_meta` |
|
|
187
188
|
|
|
188
189
|
### onPostToolUse
|
|
189
190
|
|
|
190
|
-
**Input:** `{ toolName: string, toolArgs: unknown, toolResult: ToolResultObject, timestamp, workingDirectory }`
|
|
191
|
+
**Input:** `{ toolCallId?: string, toolName: string, toolArgs: unknown, toolResult: ToolResultObject, timestamp, workingDirectory }`
|
|
191
192
|
|
|
192
193
|
Fires only when the tool returned a successful result. To observe non-success
|
|
193
194
|
outcomes, register `onPostToolUseFailure` as well.
|
|
@@ -200,7 +201,7 @@ outcomes, register `onPostToolUseFailure` as well.
|
|
|
200
201
|
|
|
201
202
|
### onPostToolUseFailure
|
|
202
203
|
|
|
203
|
-
**Input:** `{ toolName: string, toolArgs: unknown, error: string, timestamp, workingDirectory }`
|
|
204
|
+
**Input:** `{ toolCallId?: string, toolName: string, toolArgs: unknown, error: string, timestamp, workingDirectory }`
|
|
204
205
|
|
|
205
206
|
Fires after a tool execution whose result was `"failure"`. `onPostToolUse`
|
|
206
207
|
does **not** fire for these outcomes, so register this handler to observe or
|