@github/copilot-sdk-win32-x64 1.0.17-preview.3 → 1.0.17-preview.5
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/copilot-sdk/canvas.d.ts +6 -1
- package/copilot-sdk/docs/agent-author.md +29 -2
- package/copilot-sdk/extension.js +233 -20
- package/copilot-sdk/generated/rpc.d.ts +1218 -410
- package/copilot-sdk/generated/session-events.d.ts +240 -5
- package/copilot-sdk/index.d.ts +2 -2
- package/copilot-sdk/index.js +236 -22
- package/copilot-sdk/sessionFsProvider.d.ts +9 -1
- package/copilot-sdk/types.d.ts +67 -2
- package/package.json +1 -1
- package/prebuilds/win32-x64/copilot-runtime.exe +0 -0
- package/prebuilds/win32-x64/dpapi.node +0 -0
- package/prebuilds/win32-x64/msal-node-runtime.node +0 -0
- package/prebuilds/win32-x64/msalruntime.dll +0 -0
- package/prebuilds/win32-x64/runtime.node +2 -2
- package/ripgrep/bin/win32-x64/rg.exe +0 -0
- package/schemas/api.schema.json +1518 -131
- package/schemas/session-events.schema.json +419 -8
- package/tgrep/bin/win32-x64/tgrep.exe +0 -0
- package/prebuilds/win32-x64/OneAuthInterop.LICENSE.txt +0 -192
- package/prebuilds/win32-x64/OneAuthInterop.dll +0 -0
- package/prebuilds/win32-x64/OneAuthInterop.dll.stamp.json +0 -4
package/copilot-sdk/canvas.d.ts
CHANGED
|
@@ -32,7 +32,12 @@ export interface CanvasAction {
|
|
|
32
32
|
description?: string;
|
|
33
33
|
/** Optional JSON Schema for the action's `input` payload. */
|
|
34
34
|
inputSchema?: CanvasJsonSchema;
|
|
35
|
-
/**
|
|
35
|
+
/**
|
|
36
|
+
* Required per-action dispatch handler. The returned value becomes the
|
|
37
|
+
* `invoke_canvas_action` tool result. Return a `ToolResultObject`
|
|
38
|
+
* (with `binaryResultsForLlm`) to send text and images to the model, as a
|
|
39
|
+
* tool handler would; any other value is rendered to the model as JSON text.
|
|
40
|
+
*/
|
|
36
41
|
handler: (ctx: CanvasProviderInvokeActionRequest) => Promise<unknown> | unknown;
|
|
37
42
|
}
|
|
38
43
|
/**
|
|
@@ -122,10 +122,12 @@ hooks: {
|
|
|
122
122
|
onSessionStart: async (input, invocation) => { ... },
|
|
123
123
|
onSessionEnd: async (input, invocation) => { ... },
|
|
124
124
|
onErrorOccurred: async (input, invocation) => { ... },
|
|
125
|
+
onSubagentStart: async (input, invocation) => { ... },
|
|
126
|
+
onSubagentStop: async (input, invocation) => { ... },
|
|
125
127
|
}
|
|
126
128
|
```
|
|
127
129
|
|
|
128
|
-
All hook inputs include `timestamp` (`Date`) and `workingDirectory`.
|
|
130
|
+
All hook inputs include `sessionId`, `timestamp` (`Date`) and `workingDirectory`.
|
|
129
131
|
All handlers receive `invocation: { sessionId: string }` as the second argument.
|
|
130
132
|
All handlers may return `void`/`undefined` (no-op) or an output object.
|
|
131
133
|
|
|
@@ -214,7 +216,32 @@ fire it.
|
|
|
214
216
|
| `retryCount` | `number` | Max retries (when errorHandling is "retry") |
|
|
215
217
|
| `userNotification` | `string` | Message shown to the user |
|
|
216
218
|
|
|
217
|
-
|
|
219
|
+
### onSubagentStart
|
|
220
|
+
|
|
221
|
+
Fires before a sub-agent's first turn. The input's `sessionId` and the
|
|
222
|
+
invocation's `sessionId` identify the parent session, not the child.
|
|
223
|
+
|
|
224
|
+
**Input:** `{ sessionId: string, transcriptPath: string, agentName: string, agentDisplayName?: string, agentDescription?: string, timestamp, workingDirectory }`
|
|
225
|
+
|
|
226
|
+
**Output (optional):**
|
|
227
|
+
| Field | Type | Effect |
|
|
228
|
+
|-------|------|--------|
|
|
229
|
+
| `additionalContext` | `string` | Prepended to the child's initial prompt |
|
|
230
|
+
|
|
231
|
+
### onSubagentStop
|
|
232
|
+
|
|
233
|
+
Fires after a sub-agent completes a turn. The input includes the child's last
|
|
234
|
+
assistant `response` and the parent's session metadata. `agentId` is available
|
|
235
|
+
when the task registry supplies one. This is distinct from `onAgentStop`, which
|
|
236
|
+
only runs for the top-level agent.
|
|
237
|
+
|
|
238
|
+
**Input:** `{ sessionId: string, transcriptPath: string, agentName: string, agentDisplayName?: string, agentDescription?: string, agentId?: string, agentType: string, stopReason: "end_turn", response: string, timestamp, workingDirectory }`
|
|
239
|
+
|
|
240
|
+
**Output (choose one, or return nothing):**
|
|
241
|
+
| Field | Type | Effect |
|
|
242
|
+
|-------|------|--------|
|
|
243
|
+
| `decision` and `reason` | `"block"` and `string` | Continue the child for another turn using `reason` |
|
|
244
|
+
| `modifiedResponse` | `string` | Replace the child's response reported to the parent |
|
|
218
245
|
|
|
219
246
|
## Session Object
|
|
220
247
|
|
package/copilot-sdk/extension.js
CHANGED
|
@@ -4151,7 +4151,48 @@ function createServerRpc(connection) {
|
|
|
4151
4151
|
*
|
|
4152
4152
|
* @returns Whether the host running this runtime can run the command sandbox. The runtime checks `supported` once per process. A capability answer can change while the process runs, for example after the user installs a missing package.
|
|
4153
4153
|
*/
|
|
4154
|
-
getHostSupport: async () => connection.sendRequest("sandbox.getHostSupport", {})
|
|
4154
|
+
getHostSupport: async () => connection.sendRequest("sandbox.getHostSupport", {}),
|
|
4155
|
+
/** @experimental */
|
|
4156
|
+
proxyCa: {
|
|
4157
|
+
/**
|
|
4158
|
+
* Reports whether the persistent certificate authority of the sandbox credential proxy exists, whether OS trust includes it, and whether it must be rotated. Changes nothing.
|
|
4159
|
+
*
|
|
4160
|
+
* @param params Identifies the credential hosts that the persistent certificate authority of the sandbox credential proxy must cover. The runtime always adds the hosts from the saved user settings.
|
|
4161
|
+
*
|
|
4162
|
+
* @returns Status of the persistent certificate authority of the sandbox credential proxy.
|
|
4163
|
+
*/
|
|
4164
|
+
getStatus: async (params) => connection.sendRequest("sandbox.proxyCa.getStatus", params),
|
|
4165
|
+
/**
|
|
4166
|
+
* Creates the persistent certificate authority of the sandbox credential proxy if none is stored, without changing OS trust, and returns the path of its public certificate. Keeps an existing certificate authority, even one that must be rotated. Fails where OS trust is unsupported. Trust it with sandbox.proxyCa.trust: the CLI trusts only the hosts in the saved user settings, so it refuses a certificate authority that also covers hosts from sandboxConfig.
|
|
4167
|
+
*
|
|
4168
|
+
* @param params Identifies the credential hosts that the persistent certificate authority of the sandbox credential proxy must cover. The runtime always adds the hosts from the saved user settings.
|
|
4169
|
+
*
|
|
4170
|
+
* @returns Result of creating the persistent certificate authority of the sandbox credential proxy.
|
|
4171
|
+
*/
|
|
4172
|
+
create: async (params) => connection.sendRequest("sandbox.proxyCa.create", params),
|
|
4173
|
+
/**
|
|
4174
|
+
* Replaces the persistent certificate authority of the sandbox credential proxy with a new one for the current credential hosts. If OS trust included the old one, removes it and trusts the new one, which can show an OS authentication prompt. Running sandboxed tools keep the old certificate authority until they restart.
|
|
4175
|
+
*
|
|
4176
|
+
* @param params Identifies the credential hosts that the persistent certificate authority of the sandbox credential proxy must cover. The runtime always adds the hosts from the saved user settings.
|
|
4177
|
+
*
|
|
4178
|
+
* @returns Status of the persistent certificate authority of the sandbox credential proxy.
|
|
4179
|
+
*/
|
|
4180
|
+
rotate: async (params) => connection.sendRequest("sandbox.proxyCa.rotate", params),
|
|
4181
|
+
/**
|
|
4182
|
+
* Adds the persistent certificate authority of the sandbox credential proxy to OS trust, so sandboxed clients that read only OS trust accept the proxy. Call create first. Refuses a certificate authority that is not constrained to the current credential hosts. Can show an OS authentication prompt.
|
|
4183
|
+
*
|
|
4184
|
+
* @param params Identifies the credential hosts that the persistent certificate authority of the sandbox credential proxy must cover. The runtime always adds the hosts from the saved user settings.
|
|
4185
|
+
*
|
|
4186
|
+
* @returns Status of the persistent certificate authority of the sandbox credential proxy.
|
|
4187
|
+
*/
|
|
4188
|
+
trust: async (params) => connection.sendRequest("sandbox.proxyCa.trust", params),
|
|
4189
|
+
/**
|
|
4190
|
+
* Removes the persistent certificate authority of the sandbox credential proxy from OS trust. Keeps the stored certificate authority. Can show an OS authentication prompt. Sandboxed clients that read only OS trust then reject the proxy; clients that read the per-process certificate bundle continue to work.
|
|
4191
|
+
*
|
|
4192
|
+
* @returns Status of the persistent certificate authority of the sandbox credential proxy.
|
|
4193
|
+
*/
|
|
4194
|
+
remove: async () => connection.sendRequest("sandbox.proxyCa.remove", {})
|
|
4195
|
+
}
|
|
4155
4196
|
},
|
|
4156
4197
|
/** @experimental */
|
|
4157
4198
|
tools: {
|
|
@@ -5071,22 +5112,55 @@ function createInternalServerRpc(connection) {
|
|
|
5071
5112
|
* @param params Params to attach or detach an in-process ExtensionController delegate.
|
|
5072
5113
|
*/
|
|
5073
5114
|
configureSessionExtensions: async (params) => connection.sendRequest("sessions.configureSessionExtensions", params)
|
|
5074
|
-
},
|
|
5075
|
-
/** @experimental */
|
|
5076
|
-
accounts: {
|
|
5077
|
-
/**
|
|
5078
|
-
* Acquire a Microsoft Entra access token through the runtime's OneAuth broker. Account-scoped because it uses the same native broker as the account stack: a trusted host application mints a scoped Entra token for its own use, most notably to authenticate to a remote MCP server whose authorization server is Entra ID (in place of the generic browser-OAuth flow).
|
|
5079
|
-
*
|
|
5080
|
-
* @param params OneAuth token request supplied by a trusted host application.
|
|
5081
|
-
*
|
|
5082
|
-
* @returns Result of a OneAuth token acquisition.
|
|
5083
|
-
*/
|
|
5084
|
-
acquireEntraToken: async (params) => connection.sendRequest("accounts.acquireEntraToken", params)
|
|
5085
5115
|
}
|
|
5086
5116
|
};
|
|
5087
5117
|
}
|
|
5088
5118
|
function createSessionRpc(connection, sessionId) {
|
|
5089
5119
|
return {
|
|
5120
|
+
/** @experimental */
|
|
5121
|
+
providers: {
|
|
5122
|
+
/**
|
|
5123
|
+
* Returns adapter definitions and supported operations in this session's effective provider catalog, without running discovery. Does not list provider instances or select inference models.
|
|
5124
|
+
*
|
|
5125
|
+
* @returns Normalized model-provider adapter definitions available to the session, not discovered instances.
|
|
5126
|
+
*/
|
|
5127
|
+
getCatalog: async () => connection.sendRequest("session.providers.getCatalog", { sessionId }),
|
|
5128
|
+
/**
|
|
5129
|
+
* Discovers reachable instances using an adapter from this session's effective provider catalog and provider-specific discovery input.
|
|
5130
|
+
*
|
|
5131
|
+
* @param params Provider discovery parameters.
|
|
5132
|
+
*
|
|
5133
|
+
* @returns Provider instances found by a discovery operation.
|
|
5134
|
+
*/
|
|
5135
|
+
discover: async (params) => connection.sendRequest("session.providers.discover", { ...params, sessionId }),
|
|
5136
|
+
/**
|
|
5137
|
+
* Gets current health and version information for a discovered model-provider instance.
|
|
5138
|
+
*
|
|
5139
|
+
* @param params Provider status request parameters.
|
|
5140
|
+
*
|
|
5141
|
+
* @returns Current health information for a provider instance.
|
|
5142
|
+
*/
|
|
5143
|
+
getStatus: async (params) => connection.sendRequest("session.providers.getStatus", { ...params, sessionId }),
|
|
5144
|
+
/** @experimental */
|
|
5145
|
+
models: {
|
|
5146
|
+
/**
|
|
5147
|
+
* Lists models installed or otherwise available from a discovered model-provider instance.
|
|
5148
|
+
*
|
|
5149
|
+
* @param params Provider model inventory request parameters.
|
|
5150
|
+
*
|
|
5151
|
+
* @returns Models offered for agent conversations by one provider instance. Adapters exclude known-incompatible models, but retain candidates with unknown capabilities. Listing does not guarantee compatibility.
|
|
5152
|
+
*/
|
|
5153
|
+
list: async (params) => connection.sendRequest("session.providers.models.list", { ...params, sessionId }),
|
|
5154
|
+
/**
|
|
5155
|
+
* Translates a discovered model into the provider and model configuration needed to use it, and reports whether each is already registered in this session. Prepares only: it registers nothing, writes nothing, and performs no provider requests.
|
|
5156
|
+
*
|
|
5157
|
+
* @param params A discovered instance and one of its models to translate into provider configuration. Pass back the instance and model as returned by `session.providers.discover` and `session.providers.models.list`.
|
|
5158
|
+
*
|
|
5159
|
+
* @returns Provider configuration prepared from a discovered model. Preparing a plan changes nothing: it neither registers the model with the session nor writes durable configuration. To apply it, pass `provider` and `model` to `session.provider.add`, omitting whichever the dispositions report as already configured.
|
|
5160
|
+
*/
|
|
5161
|
+
prepareConfiguration: async (params) => connection.sendRequest("session.providers.models.prepareConfiguration", { ...params, sessionId })
|
|
5162
|
+
}
|
|
5163
|
+
},
|
|
5090
5164
|
/**
|
|
5091
5165
|
* Suspends the session while preserving persisted state for later resume.
|
|
5092
5166
|
*
|
|
@@ -5694,16 +5768,18 @@ function createSessionRpc(connection, sessionId) {
|
|
|
5694
5768
|
*/
|
|
5695
5769
|
getSources: async () => connection.sendRequest("session.instructions.getSources", { sessionId }),
|
|
5696
5770
|
/**
|
|
5697
|
-
*
|
|
5771
|
+
* For local sessions, invalidates instruction discovery and the model-facing prompt, then returns freshly discovered sources. The updated prompt takes effect on the next turn. Remote sessions must reload on their agent host instead.
|
|
5772
|
+
*
|
|
5773
|
+
* @returns Instruction sources loaded for the session, in merge order.
|
|
5698
5774
|
*/
|
|
5699
5775
|
reload: async () => connection.sendRequest("session.instructions.reload", { sessionId })
|
|
5700
5776
|
},
|
|
5701
5777
|
/** @experimental */
|
|
5702
5778
|
customizations: {
|
|
5703
5779
|
/**
|
|
5704
|
-
*
|
|
5780
|
+
* For local sessions, reconciles repository context and discovered instructions, plugins, skills, agents, hooks, MCP servers, and extensions after files appear or change under the working directory. Independent component failures are returned in outcomes and errors; a rejected call can have partially applied earlier steps. Remote sessions must reload on their agent host instead. The model-facing context is rebuilt on the next turn.
|
|
5705
5781
|
*
|
|
5706
|
-
* @returns
|
|
5782
|
+
* @returns Results of reloading discovered session customizations. Inspect outcomes for reloaded, skipped, or failed subsystems; a rejection may follow partial mutation. Changes to the model-facing prompt and tools apply on the next turn.
|
|
5707
5783
|
*/
|
|
5708
5784
|
reload: async () => connection.sendRequest("session.customizations.reload", { sessionId })
|
|
5709
5785
|
},
|
|
@@ -5896,11 +5972,17 @@ function createSessionRpc(connection, sessionId) {
|
|
|
5896
5972
|
/** @experimental */
|
|
5897
5973
|
mcp: {
|
|
5898
5974
|
/**
|
|
5899
|
-
* Lists MCP servers
|
|
5975
|
+
* Lists materialized MCP servers and their connection status. Cache misses may start and wait for MCP servers.
|
|
5900
5976
|
*
|
|
5901
5977
|
* @returns MCP servers configured for the session, with their connection status and host-level state.
|
|
5902
5978
|
*/
|
|
5903
5979
|
list: async () => connection.sendRequest("session.mcp.list", { sessionId }),
|
|
5980
|
+
/**
|
|
5981
|
+
* Lists effective MCP configuration without starting, restarting, authenticating, or waiting for servers. An optional live observation is from an already materialized matching server; this is not a readiness guarantee.
|
|
5982
|
+
*
|
|
5983
|
+
* @returns Effective MCP configuration with optional live observations from matching already materialized servers.
|
|
5984
|
+
*/
|
|
5985
|
+
listConfigured: async () => connection.sendRequest("session.mcp.listConfigured", { sessionId }),
|
|
5904
5986
|
/**
|
|
5905
5987
|
* Lists the tools exposed by a connected MCP server on this session's host. This performs a live `tools/list` request. Tool UI metadata is returned independently of whether MCP Apps rendering is enabled for the session.
|
|
5906
5988
|
*
|
|
@@ -7407,6 +7489,33 @@ function createInternalSessionRpc(connection, sessionId) {
|
|
|
7407
7489
|
finalizeInvocationEffect: async (params) => connection.sendRequest("session.commands.finalizeInvocationEffect", { ...params, sessionId })
|
|
7408
7490
|
},
|
|
7409
7491
|
/** @experimental */
|
|
7492
|
+
ui: {
|
|
7493
|
+
/**
|
|
7494
|
+
* Resolves a pending elicitation request after direct interaction in the trusted in-process client. Only an accepted response to the built-in ask_user tool can become trusted human evidence.
|
|
7495
|
+
*
|
|
7496
|
+
* @param params Pending elicitation request ID and the user's response (accept/decline/cancel + form values).
|
|
7497
|
+
*
|
|
7498
|
+
* @returns Indicates whether the elicitation response was accepted; false if it was already resolved by another client.
|
|
7499
|
+
*/
|
|
7500
|
+
handleHumanAskUser: async (params) => connection.sendRequest("session.ui.handleHumanAskUser", { ...params, sessionId }),
|
|
7501
|
+
/**
|
|
7502
|
+
* Resolves a pending `user_input.requested` event after direct interaction in the trusted in-process client.
|
|
7503
|
+
*
|
|
7504
|
+
* @param params Request ID of a pending `user_input.requested` event and the user's response.
|
|
7505
|
+
*
|
|
7506
|
+
* @returns Indicates whether the pending UI request was resolved by this call.
|
|
7507
|
+
*/
|
|
7508
|
+
handleHumanUserInput: async (params) => connection.sendRequest("session.ui.handleHumanUserInput", { ...params, sessionId }),
|
|
7509
|
+
/**
|
|
7510
|
+
* Resolves a pending `exit_plan_mode.requested` event after direct interaction in the trusted in-process client.
|
|
7511
|
+
*
|
|
7512
|
+
* @param params Request ID of a pending `exit_plan_mode.requested` event and the user's response.
|
|
7513
|
+
*
|
|
7514
|
+
* @returns Indicates whether the pending UI request was resolved by this call.
|
|
7515
|
+
*/
|
|
7516
|
+
handleHumanExitPlanMode: async (params) => connection.sendRequest("session.ui.handleHumanExitPlanMode", { ...params, sessionId })
|
|
7517
|
+
},
|
|
7518
|
+
/** @experimental */
|
|
7410
7519
|
settings: {
|
|
7411
7520
|
/**
|
|
7412
7521
|
* Returns a redacted snapshot of session runtime settings, with secrets and raw feature flags excluded. Internal: the runtime settings shape is a runtime-internal surface and is deliberately kept out of the public SDK, because consumers should not depend on the runtime's internal settings layout. It remains callable in-process and is expected to be reworked as the runtime internals are consolidated.
|
|
@@ -7559,11 +7668,21 @@ function registerClientSessionApiHandlers(connection, getHandlers) {
|
|
|
7559
7668
|
if (!handler) throw new Error(`No sessionFs handler registered for session: ${params.sessionId}`);
|
|
7560
7669
|
return handler.readFile(params);
|
|
7561
7670
|
});
|
|
7671
|
+
connection.onRequest("sessionFs.readFileBytes", async (params) => {
|
|
7672
|
+
const handler = getHandlers(params.sessionId).sessionFs;
|
|
7673
|
+
if (!handler) throw new Error(`No sessionFs handler registered for session: ${params.sessionId}`);
|
|
7674
|
+
return handler.readFileBytes(params);
|
|
7675
|
+
});
|
|
7562
7676
|
connection.onRequest("sessionFs.writeFile", async (params) => {
|
|
7563
7677
|
const handler = getHandlers(params.sessionId).sessionFs;
|
|
7564
7678
|
if (!handler) throw new Error(`No sessionFs handler registered for session: ${params.sessionId}`);
|
|
7565
7679
|
return handler.writeFile(params);
|
|
7566
7680
|
});
|
|
7681
|
+
connection.onRequest("sessionFs.writeFileBytes", async (params) => {
|
|
7682
|
+
const handler = getHandlers(params.sessionId).sessionFs;
|
|
7683
|
+
if (!handler) throw new Error(`No sessionFs handler registered for session: ${params.sessionId}`);
|
|
7684
|
+
return handler.writeFileBytes(params);
|
|
7685
|
+
});
|
|
7567
7686
|
connection.onRequest("sessionFs.appendFile", async (params) => {
|
|
7568
7687
|
const handler = getHandlers(params.sessionId).sessionFs;
|
|
7569
7688
|
if (!handler) throw new Error(`No sessionFs handler registered for session: ${params.sessionId}`);
|
|
@@ -7752,6 +7871,8 @@ function isResponseSchema(value) {
|
|
|
7752
7871
|
}
|
|
7753
7872
|
|
|
7754
7873
|
// src/sdk/nodejs/dist/sessionFsProvider.js
|
|
7874
|
+
var MAX_BINARY_BYTES = (64 * 1024 * 1024 - 1024) / 4 * 3;
|
|
7875
|
+
var MAX_BINARY_CONTENT_LENGTH = Math.ceil(MAX_BINARY_BYTES / 3) * 4;
|
|
7755
7876
|
var SessionFsSqliteTransactionFailure = class extends Error {
|
|
7756
7877
|
/** Failure classification reported to the runtime. */
|
|
7757
7878
|
errorClass;
|
|
@@ -7761,6 +7882,9 @@ var SessionFsSqliteTransactionFailure = class extends Error {
|
|
|
7761
7882
|
this.errorClass = errorClass;
|
|
7762
7883
|
}
|
|
7763
7884
|
};
|
|
7885
|
+
var SessionFsWriteFailure = class extends Error {
|
|
7886
|
+
writeChanged = true;
|
|
7887
|
+
};
|
|
7764
7888
|
function normalizeSqliteParams(params) {
|
|
7765
7889
|
if (!params) {
|
|
7766
7890
|
return void 0;
|
|
@@ -7783,10 +7907,60 @@ function createSessionFsAdapter(provider) {
|
|
|
7783
7907
|
return { content: "", error: toSessionFsError(err) };
|
|
7784
7908
|
}
|
|
7785
7909
|
},
|
|
7910
|
+
readFileBytes: async ({ path }) => {
|
|
7911
|
+
if (!provider.readFileBytes) {
|
|
7912
|
+
return {
|
|
7913
|
+
content: "",
|
|
7914
|
+
error: { code: "UNKNOWN", message: "Binary reads are not supported" }
|
|
7915
|
+
};
|
|
7916
|
+
}
|
|
7917
|
+
try {
|
|
7918
|
+
const bytes = await provider.readFileBytes(path);
|
|
7919
|
+
if (bytes.length > MAX_BINARY_BYTES) {
|
|
7920
|
+
return {
|
|
7921
|
+
content: "",
|
|
7922
|
+
error: {
|
|
7923
|
+
code: "UNKNOWN",
|
|
7924
|
+
message: "sessionFs.readFileBytes content exceeds the binary read limit"
|
|
7925
|
+
}
|
|
7926
|
+
};
|
|
7927
|
+
}
|
|
7928
|
+
return {
|
|
7929
|
+
content: Buffer.from(bytes).toString("base64")
|
|
7930
|
+
};
|
|
7931
|
+
} catch (err) {
|
|
7932
|
+
return { content: "", error: toSessionFsError(err) };
|
|
7933
|
+
}
|
|
7934
|
+
},
|
|
7786
7935
|
writeFile: async ({ path, content, mode }) => {
|
|
7787
7936
|
try {
|
|
7788
7937
|
await provider.writeFile(path, content, mode);
|
|
7789
7938
|
return void 0;
|
|
7939
|
+
} catch (err) {
|
|
7940
|
+
const error = toSessionFsError(err);
|
|
7941
|
+
return err instanceof SessionFsWriteFailure ? { ...error, writeChanged: true } : error;
|
|
7942
|
+
}
|
|
7943
|
+
},
|
|
7944
|
+
writeFileBytes: async ({ path, content, mode }) => {
|
|
7945
|
+
if (!provider.writeFileBytes) {
|
|
7946
|
+
return { code: "UNKNOWN", message: "Binary writes are not supported" };
|
|
7947
|
+
}
|
|
7948
|
+
if (content.length > MAX_BINARY_CONTENT_LENGTH) {
|
|
7949
|
+
return {
|
|
7950
|
+
code: "UNKNOWN",
|
|
7951
|
+
message: "sessionFs.writeFileBytes content exceeds the binary write limit"
|
|
7952
|
+
};
|
|
7953
|
+
}
|
|
7954
|
+
const bytes = Buffer.from(content, "base64");
|
|
7955
|
+
if (bytes.toString("base64") !== content || bytes.length > MAX_BINARY_BYTES) {
|
|
7956
|
+
return {
|
|
7957
|
+
code: "UNKNOWN",
|
|
7958
|
+
message: "invalid sessionFs.writeFileBytes base64 content"
|
|
7959
|
+
};
|
|
7960
|
+
}
|
|
7961
|
+
try {
|
|
7962
|
+
await provider.writeFileBytes(path, bytes, mode);
|
|
7963
|
+
return void 0;
|
|
7790
7964
|
} catch (err) {
|
|
7791
7965
|
return toSessionFsError(err);
|
|
7792
7966
|
}
|
|
@@ -9827,7 +10001,20 @@ var CopilotSession = class {
|
|
|
9827
10001
|
}
|
|
9828
10002
|
for (const tool of tools) {
|
|
9829
10003
|
if (tool.handler) {
|
|
9830
|
-
|
|
10004
|
+
const handler = tool.handler;
|
|
10005
|
+
if (tool.name === "apply_patch" && tool.overridesBuiltInTool && toJsonSchema(tool.parameters)?.type === "string") {
|
|
10006
|
+
this.toolHandlers.set(tool.name, (args, invocation) => {
|
|
10007
|
+
if (typeof args === "string") {
|
|
10008
|
+
return handler(args, invocation);
|
|
10009
|
+
}
|
|
10010
|
+
if (typeof args === "object" && args !== null && "input" in args && typeof args.input === "string") {
|
|
10011
|
+
return handler(args.input, invocation);
|
|
10012
|
+
}
|
|
10013
|
+
throw new TypeError("apply_patch string override requires a string input");
|
|
10014
|
+
});
|
|
10015
|
+
} else {
|
|
10016
|
+
this.toolHandlers.set(tool.name, handler);
|
|
10017
|
+
}
|
|
9831
10018
|
}
|
|
9832
10019
|
}
|
|
9833
10020
|
}
|
|
@@ -10422,7 +10609,9 @@ var CopilotSession = class {
|
|
|
10422
10609
|
sessionStart: this.hooks.onSessionStart,
|
|
10423
10610
|
sessionEnd: this.hooks.onSessionEnd,
|
|
10424
10611
|
errorOccurred: this.hooks.onErrorOccurred,
|
|
10425
|
-
agentStop: this.hooks.onAgentStop
|
|
10612
|
+
agentStop: this.hooks.onAgentStop,
|
|
10613
|
+
subagentStart: this.hooks.onSubagentStart,
|
|
10614
|
+
subagentStop: this.hooks.onSubagentStop
|
|
10426
10615
|
};
|
|
10427
10616
|
const handler = handlerMap[hookType];
|
|
10428
10617
|
if (!handler) {
|
|
@@ -10894,6 +11083,7 @@ var EXCLUDED_TOP_LEVEL = /* @__PURE__ */ new Set([
|
|
|
10894
11083
|
"app.js",
|
|
10895
11084
|
"assets",
|
|
10896
11085
|
"changelog.json",
|
|
11086
|
+
"cli-main.js",
|
|
10897
11087
|
"copilot",
|
|
10898
11088
|
"copilot.exe",
|
|
10899
11089
|
"foundry-local-sdk",
|
|
@@ -11212,6 +11402,7 @@ var ToolSet = class {
|
|
|
11212
11402
|
// src/sdk/nodejs/dist/client.js
|
|
11213
11403
|
var MIN_PROTOCOL_VERSION = 3;
|
|
11214
11404
|
var RUNTIME_SHUTDOWN_TIMEOUT_MS = 1e4;
|
|
11405
|
+
var CLOUD_SESSION_CLEANUP_TIMEOUT_MS = 1e4;
|
|
11215
11406
|
function createMessageConnection(reader, writer) {
|
|
11216
11407
|
let dispatch;
|
|
11217
11408
|
let finishDrain;
|
|
@@ -11740,6 +11931,11 @@ var CopilotClient = class _CopilotClient {
|
|
|
11740
11931
|
"SessionFsConfig declares capabilities.sqlite but the provider does not implement sqlite."
|
|
11741
11932
|
);
|
|
11742
11933
|
}
|
|
11934
|
+
if (this.sessionFsConfig.capabilities?.binary && (!provider.readFileBytes || !provider.writeFileBytes)) {
|
|
11935
|
+
throw new Error(
|
|
11936
|
+
"SessionFsConfig declares capabilities.binary but the provider does not implement readFileBytes and writeFileBytes."
|
|
11937
|
+
);
|
|
11938
|
+
}
|
|
11743
11939
|
session.clientSessionApis.sessionFs = createSessionFsAdapter(provider);
|
|
11744
11940
|
}
|
|
11745
11941
|
setupClientGlobalHandlers() {
|
|
@@ -12423,12 +12619,13 @@ var CopilotClient = class _CopilotClient {
|
|
|
12423
12619
|
if (config.onEvent) {
|
|
12424
12620
|
s.on(config.onEvent);
|
|
12425
12621
|
}
|
|
12426
|
-
this.sessions.set(sessionId, s);
|
|
12427
12622
|
this.setupSessionFs(s, config);
|
|
12623
|
+
this.sessions.set(sessionId, s);
|
|
12428
12624
|
return s;
|
|
12429
12625
|
};
|
|
12430
12626
|
let session;
|
|
12431
12627
|
let registeredId;
|
|
12628
|
+
let uninitializedCloudSessionId;
|
|
12432
12629
|
if (localSessionId !== void 0) {
|
|
12433
12630
|
try {
|
|
12434
12631
|
session = initializeSession(localSessionId);
|
|
@@ -12551,7 +12748,9 @@ var CopilotClient = class _CopilotClient {
|
|
|
12551
12748
|
);
|
|
12552
12749
|
}
|
|
12553
12750
|
if (session === void 0) {
|
|
12751
|
+
uninitializedCloudSessionId = returnedSessionId;
|
|
12554
12752
|
session = initializeSession(returnedSessionId);
|
|
12753
|
+
uninitializedCloudSessionId = void 0;
|
|
12555
12754
|
registeredId = returnedSessionId;
|
|
12556
12755
|
}
|
|
12557
12756
|
this.assignGitHubTokenProvider(gitHubTokenProviderRegistrationId, returnedSessionId);
|
|
@@ -12573,6 +12772,20 @@ var CopilotClient = class _CopilotClient {
|
|
|
12573
12772
|
if (gitHubTokenProviderRegistrationId !== void 0) {
|
|
12574
12773
|
this.githubTokenProviders.delete(gitHubTokenProviderRegistrationId);
|
|
12575
12774
|
}
|
|
12775
|
+
if (uninitializedCloudSessionId !== void 0) {
|
|
12776
|
+
try {
|
|
12777
|
+
await withTimeout(
|
|
12778
|
+
this.deleteSession(uninitializedCloudSessionId),
|
|
12779
|
+
CLOUD_SESSION_CLEANUP_TIMEOUT_MS,
|
|
12780
|
+
`session.delete timed out after ${CLOUD_SESSION_CLEANUP_TIMEOUT_MS}ms`
|
|
12781
|
+
);
|
|
12782
|
+
} catch (cleanupError) {
|
|
12783
|
+
throw new AggregateError(
|
|
12784
|
+
[e, cleanupError],
|
|
12785
|
+
"Failed to initialize and delete cloud session"
|
|
12786
|
+
);
|
|
12787
|
+
}
|
|
12788
|
+
}
|
|
12576
12789
|
throw e;
|
|
12577
12790
|
}
|
|
12578
12791
|
for (const entry of this.hostHandoffs.values()) {
|
|
@@ -12672,8 +12885,8 @@ var CopilotClient = class _CopilotClient {
|
|
|
12672
12885
|
if (config.onEvent) {
|
|
12673
12886
|
session.on(config.onEvent);
|
|
12674
12887
|
}
|
|
12675
|
-
this.sessions.set(sessionId, session);
|
|
12676
12888
|
this.setupSessionFs(session, config);
|
|
12889
|
+
this.sessions.set(sessionId, session);
|
|
12677
12890
|
const toolFilterOptions = this.resolveToolFilterOptions(config);
|
|
12678
12891
|
const gitHubTokenProviderRegistrationId = this.registerGitHubTokenProvider(
|
|
12679
12892
|
config.gitHubTokenProvider,
|