@github/copilot-sdk 1.0.29 → 1.0.30-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 +98 -7
- package/dist/cjs/cliVersion.js +1 -1
- package/dist/cjs/client.js +651 -96
- 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 +113 -9
- package/dist/cliVersion.d.ts +1 -1
- package/dist/cliVersion.js +1 -1
- package/dist/client.d.ts +38 -3
- package/dist/client.js +653 -96
- package/dist/decisions.d.ts +65 -0
- package/dist/decisions.js +113 -0
- package/dist/generated/rpc.d.ts +1432 -130
- 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 +12 -2
- package/dist/session.js +113 -9
- package/dist/types.d.ts +143 -28
- package/docs/agent-author.md +1 -1
- package/docs/examples.md +77 -17
- package/package.json +14 -13
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;
|
|
@@ -76,6 +78,7 @@ export declare class CopilotSession {
|
|
|
76
78
|
private completionRpcUnsupported;
|
|
77
79
|
private disconnecting;
|
|
78
80
|
private onDisconnected?;
|
|
81
|
+
private releaseFromClient?;
|
|
79
82
|
/**
|
|
80
83
|
* Friendly workflow API for running registered workflows by name or handle.
|
|
81
84
|
*
|
|
@@ -95,6 +98,7 @@ export declare class CopilotSession {
|
|
|
95
98
|
* dropped invalidation from leaving the wait pending forever.
|
|
96
99
|
*/
|
|
97
100
|
private waitForWorkflowRun;
|
|
101
|
+
get sessionId(): string;
|
|
98
102
|
/**
|
|
99
103
|
* Typed session-scoped RPC methods.
|
|
100
104
|
*/
|
|
@@ -107,6 +111,12 @@ export declare class CopilotSession {
|
|
|
107
111
|
get workspacePath(): string | undefined;
|
|
108
112
|
/** Recovery observed while loading this session; undefined on a clean resume. */
|
|
109
113
|
get transcriptRecovery(): TranscriptRecovery | undefined;
|
|
114
|
+
/**
|
|
115
|
+
* Outcome of the `permissionMode` requested when this session was created
|
|
116
|
+
* or resumed: whether it was applied, and the authoritative mode the
|
|
117
|
+
* session started in. Undefined when no mode was requested.
|
|
118
|
+
*/
|
|
119
|
+
get permissionModeResult(): PermissionsSetModeResult | undefined;
|
|
110
120
|
/**
|
|
111
121
|
* Host capabilities reported when the session was created or resumed.
|
|
112
122
|
* 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;
|
|
@@ -317,6 +319,7 @@ class CopilotSession {
|
|
|
317
319
|
completionRpcUnsupported = false;
|
|
318
320
|
disconnecting = false;
|
|
319
321
|
onDisconnected;
|
|
322
|
+
releaseFromClient;
|
|
320
323
|
/** @internal Client session API handlers, populated by CopilotClient during create/resume. */
|
|
321
324
|
clientSessionApis = {};
|
|
322
325
|
/**
|
|
@@ -455,6 +458,15 @@ class CopilotSession {
|
|
|
455
458
|
void read();
|
|
456
459
|
});
|
|
457
460
|
}
|
|
461
|
+
get sessionId() {
|
|
462
|
+
return this._sessionId;
|
|
463
|
+
}
|
|
464
|
+
/** @internal */
|
|
465
|
+
_setSessionId(sessionId) {
|
|
466
|
+
this._sessionId = sessionId;
|
|
467
|
+
this._rpc = null;
|
|
468
|
+
this._internalRpc = null;
|
|
469
|
+
}
|
|
458
470
|
/**
|
|
459
471
|
* Typed session-scoped RPC methods.
|
|
460
472
|
*/
|
|
@@ -487,6 +499,18 @@ class CopilotSession {
|
|
|
487
499
|
setTranscriptRecovery(recovery) {
|
|
488
500
|
this._transcriptRecovery = recovery;
|
|
489
501
|
}
|
|
502
|
+
/**
|
|
503
|
+
* Outcome of the `permissionMode` requested when this session was created
|
|
504
|
+
* or resumed: whether it was applied, and the authoritative mode the
|
|
505
|
+
* session started in. Undefined when no mode was requested.
|
|
506
|
+
*/
|
|
507
|
+
get permissionModeResult() {
|
|
508
|
+
return this._permissionModeResult;
|
|
509
|
+
}
|
|
510
|
+
/** @internal */
|
|
511
|
+
setPermissionModeResult(result) {
|
|
512
|
+
this._permissionModeResult = result;
|
|
513
|
+
}
|
|
490
514
|
/**
|
|
491
515
|
* Host capabilities reported when the session was created or resumed.
|
|
492
516
|
* Use this to check feature support before calling capability-gated APIs.
|
|
@@ -535,6 +559,7 @@ class CopilotSession {
|
|
|
535
559
|
prompt: options.prompt,
|
|
536
560
|
source: options.source,
|
|
537
561
|
displayPrompt: options.displayPrompt,
|
|
562
|
+
clientTurnId: options.clientTurnId,
|
|
538
563
|
attachments: options.attachments,
|
|
539
564
|
mode: options.mode,
|
|
540
565
|
agentMode: options.agentMode,
|
|
@@ -878,6 +903,7 @@ class CopilotSession {
|
|
|
878
903
|
return;
|
|
879
904
|
}
|
|
880
905
|
this.disconnected = true;
|
|
906
|
+
this.releaseFromClient = void 0;
|
|
881
907
|
for (const fail of this.pendingResponseWaits) {
|
|
882
908
|
fail(new Error("Session disconnected while waiting for a response"));
|
|
883
909
|
}
|
|
@@ -894,6 +920,7 @@ class CopilotSession {
|
|
|
894
920
|
controller.abort();
|
|
895
921
|
}
|
|
896
922
|
this.pendingSessionCreations.clear();
|
|
923
|
+
this._clearMemoryStore();
|
|
897
924
|
this.eventHandlers.clear();
|
|
898
925
|
this.typedEventHandlers.clear();
|
|
899
926
|
this.toolHandlers.clear();
|
|
@@ -905,6 +932,7 @@ class CopilotSession {
|
|
|
905
932
|
this.autoModeSwitchHandler = void 0;
|
|
906
933
|
this.skillProvider = void 0;
|
|
907
934
|
this.sessionCreationHandler = void 0;
|
|
935
|
+
this.memoryStoreHandler = void 0;
|
|
908
936
|
this.hooks = void 0;
|
|
909
937
|
this.traceContextProvider = void 0;
|
|
910
938
|
this.bearerTokenProviders.clear();
|
|
@@ -935,6 +963,17 @@ class CopilotSession {
|
|
|
935
963
|
this.assertConnected();
|
|
936
964
|
this.onDisconnected = callback;
|
|
937
965
|
}
|
|
966
|
+
/**
|
|
967
|
+
* @internal Lets the owning client stop tracking this session once `disconnect()`
|
|
968
|
+
* succeeds. Failed create/resume paths unregister the session themselves.
|
|
969
|
+
*/
|
|
970
|
+
_setReleaseFromClient(callback) {
|
|
971
|
+
this.releaseFromClient = callback;
|
|
972
|
+
}
|
|
973
|
+
/** @internal */
|
|
974
|
+
_isDisconnected() {
|
|
975
|
+
return this.disconnected;
|
|
976
|
+
}
|
|
938
977
|
on(eventTypeOrHandler, handler) {
|
|
939
978
|
if (this.disconnected) {
|
|
940
979
|
throw new Error("Session is disconnected");
|
|
@@ -1122,6 +1161,7 @@ class CopilotSession {
|
|
|
1122
1161
|
return;
|
|
1123
1162
|
}
|
|
1124
1163
|
this.pendingExternalTools.set(requestId, controller);
|
|
1164
|
+
let claimed = false;
|
|
1125
1165
|
try {
|
|
1126
1166
|
let availableTools;
|
|
1127
1167
|
if (toolName === TOOL_SEARCH_TOOL_NAME) {
|
|
@@ -1178,20 +1218,45 @@ class CopilotSession {
|
|
|
1178
1218
|
if (!this._claimExternalTool(requestId, controller)) {
|
|
1179
1219
|
return;
|
|
1180
1220
|
}
|
|
1221
|
+
claimed = true;
|
|
1181
1222
|
await this.rpc.tools.handlePendingToolCall({ requestId, result });
|
|
1182
1223
|
} catch (error) {
|
|
1183
|
-
if (
|
|
1224
|
+
if (claimed) {
|
|
1225
|
+
if (this.disconnected) {
|
|
1226
|
+
return;
|
|
1227
|
+
}
|
|
1228
|
+
console.error("External tool result delivery failed", {
|
|
1229
|
+
sessionId: this.sessionId,
|
|
1230
|
+
requestId,
|
|
1231
|
+
toolName,
|
|
1232
|
+
error
|
|
1233
|
+
});
|
|
1234
|
+
} else if (!this._claimExternalTool(requestId, controller)) {
|
|
1184
1235
|
return;
|
|
1185
1236
|
}
|
|
1186
1237
|
let message = error instanceof Error ? error.message : String(error);
|
|
1187
1238
|
if (!message) {
|
|
1188
1239
|
message = error instanceof Error && error.name || "Error";
|
|
1189
1240
|
}
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1241
|
+
for (let attempt = 0; attempt < (claimed ? 1 : 2); attempt++) {
|
|
1242
|
+
try {
|
|
1243
|
+
await this.rpc.tools.handlePendingToolCall({ requestId, error: message });
|
|
1244
|
+
return;
|
|
1245
|
+
} catch (rpcError) {
|
|
1246
|
+
const retryable = !claimed && attempt === 0 && !this.disconnected;
|
|
1247
|
+
if (!retryable) {
|
|
1248
|
+
if (!(rpcError instanceof ConnectionError || rpcError instanceof ResponseError)) {
|
|
1249
|
+
throw rpcError;
|
|
1250
|
+
}
|
|
1251
|
+
return;
|
|
1252
|
+
}
|
|
1253
|
+
console.error("External tool error delivery failed", {
|
|
1254
|
+
sessionId: this.sessionId,
|
|
1255
|
+
requestId,
|
|
1256
|
+
toolName,
|
|
1257
|
+
error: rpcError
|
|
1258
|
+
});
|
|
1259
|
+
message = (rpcError instanceof Error ? rpcError.message || rpcError.name : "") || String(rpcError) || "Error";
|
|
1195
1260
|
}
|
|
1196
1261
|
}
|
|
1197
1262
|
} finally {
|
|
@@ -1894,6 +1959,43 @@ class CopilotSession {
|
|
|
1894
1959
|
throw error;
|
|
1895
1960
|
}
|
|
1896
1961
|
}
|
|
1962
|
+
/**
|
|
1963
|
+
* Registers the callback the runtime calls through `memoryStore.store`.
|
|
1964
|
+
* Registered before create or resume declares `hasMemoryStore`.
|
|
1965
|
+
* @internal
|
|
1966
|
+
*/
|
|
1967
|
+
_registerMemoryStore(handler) {
|
|
1968
|
+
this.assertConnected();
|
|
1969
|
+
this.memoryStoreHandler = handler;
|
|
1970
|
+
}
|
|
1971
|
+
/** @internal */
|
|
1972
|
+
_clearMemoryStore() {
|
|
1973
|
+
this.memoryStoreHandler = void 0;
|
|
1974
|
+
}
|
|
1975
|
+
/** @internal */
|
|
1976
|
+
async _handleMemoryStore(memory, signal) {
|
|
1977
|
+
this.assertConnected();
|
|
1978
|
+
const handler = this.memoryStoreHandler;
|
|
1979
|
+
if (!handler) throw new Error("No memory store is registered");
|
|
1980
|
+
try {
|
|
1981
|
+
await handler(
|
|
1982
|
+
{
|
|
1983
|
+
sessionId: memory.sessionId,
|
|
1984
|
+
subject: memory.subject,
|
|
1985
|
+
fact: memory.fact,
|
|
1986
|
+
citations: memory.citations,
|
|
1987
|
+
reason: memory.reason
|
|
1988
|
+
},
|
|
1989
|
+
{ signal }
|
|
1990
|
+
);
|
|
1991
|
+
} catch (error) {
|
|
1992
|
+
if (signal.aborted) {
|
|
1993
|
+
throw new ResponseError(-32800, "Memory store call cancelled");
|
|
1994
|
+
}
|
|
1995
|
+
console.warn("Memory store callback failed", error);
|
|
1996
|
+
throw new Error("Memory store callback failed");
|
|
1997
|
+
}
|
|
1998
|
+
}
|
|
1897
1999
|
/** @internal */
|
|
1898
2000
|
async _handleSessionManagementCreate(request, token) {
|
|
1899
2001
|
this.assertConnected();
|
|
@@ -2140,7 +2242,9 @@ class CopilotSession {
|
|
|
2140
2242
|
`Failed to disconnect session ${this.sessionId}: ${response.error || "Unknown error"}`
|
|
2141
2243
|
);
|
|
2142
2244
|
}
|
|
2245
|
+
const release = this.releaseFromClient;
|
|
2143
2246
|
this._markDisconnected();
|
|
2247
|
+
release?.();
|
|
2144
2248
|
} catch (error) {
|
|
2145
2249
|
this.disconnecting = false;
|
|
2146
2250
|
throw error;
|
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
|
*
|
|
@@ -2993,9 +3102,7 @@ export interface ProviderConfig {
|
|
|
2993
3102
|
transport?: "http" | "websockets";
|
|
2994
3103
|
/**
|
|
2995
3104
|
* Product serving the model, such as "ollama" or "lm_studio", reported in
|
|
2996
|
-
* telemetry as `model_provider`.
|
|
2997
|
-
* prompt-cache breakpoints, which limit cross-turn cache reuse on Azure; set
|
|
2998
|
-
* it for a proxy or custom domain in front of Azure OpenAI.
|
|
3105
|
+
* telemetry as `model_provider`. Only affects telemetry.
|
|
2999
3106
|
*/
|
|
3000
3107
|
modelProvider?: ProviderConfigModelProvider;
|
|
3001
3108
|
/**
|
|
@@ -3099,9 +3206,7 @@ export interface NamedProviderConfig {
|
|
|
3099
3206
|
wireApi?: "completions" | "responses";
|
|
3100
3207
|
/**
|
|
3101
3208
|
* Product serving this provider's models, such as "ollama" or "lm_studio",
|
|
3102
|
-
* reported in telemetry as `model_provider`.
|
|
3103
|
-
* explicit prompt-cache breakpoints, which limit cross-turn cache reuse on
|
|
3104
|
-
* Azure; set it for a proxy or custom domain in front of Azure OpenAI.
|
|
3209
|
+
* reported in telemetry as `model_provider`. Only affects telemetry.
|
|
3105
3210
|
*/
|
|
3106
3211
|
modelProvider?: ProviderConfigModelProvider;
|
|
3107
3212
|
/**
|
|
@@ -3271,6 +3376,16 @@ export interface MessageOptions {
|
|
|
3271
3376
|
* If provided, this is shown in the timeline instead of `prompt`.
|
|
3272
3377
|
*/
|
|
3273
3378
|
displayPrompt?: string;
|
|
3379
|
+
/**
|
|
3380
|
+
* Opaque caller-chosen ID for the turn this message starts. The runtime copies it unchanged
|
|
3381
|
+
* into `_meta["com.github.copilot/turnId"]` on every MCP `tools/call` made while serving that
|
|
3382
|
+
* turn, including calls from sub-agents and Autopilot continuations. When a running turn
|
|
3383
|
+
* consumes the message as visible user steering, the value (or its absence) replaces the
|
|
3384
|
+
* turn's ID from the next model call onward. The `user.message` event for the message echoes
|
|
3385
|
+
* it as `clientTurnId` and is persisted like other events; the value stamped on MCP calls is
|
|
3386
|
+
* held in memory only and is not restored on resume.
|
|
3387
|
+
*/
|
|
3388
|
+
clientTurnId?: string;
|
|
3274
3389
|
/**
|
|
3275
3390
|
* JSON Schema or a Zod schema for this run's output, including requests after tool calls.
|
|
3276
3391
|
* Independent sends do not inherit it. Ordinary immediate steering retains the active
|
package/docs/agent-author.md
CHANGED
|
@@ -184,7 +184,7 @@ object sent with the request; to allow, deny or change the call itself, use
|
|
|
184
184
|
**Output (all fields optional):**
|
|
185
185
|
| Field | Type | Effect |
|
|
186
186
|
|-------|------|--------|
|
|
187
|
-
| `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` |
|
|
188
188
|
|
|
189
189
|
### onPostToolUse
|
|
190
190
|
|