@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/index.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
|
}
|
|
@@ -8764,10 +8938,10 @@ var SYSTEM_MESSAGE_SECTIONS = {
|
|
|
8764
8938
|
tool_instructions: { description: "Per-tool usage instructions" },
|
|
8765
8939
|
custom_instructions: { description: "Repository and organization custom instructions" },
|
|
8766
8940
|
runtime_instructions: {
|
|
8767
|
-
description: "Runtime-provided context and instructions
|
|
8941
|
+
description: "Runtime-provided system-prompt context and instructions, such as system notifications, memories, workspace context, and content-exclusion policy. Mode-specific instructions can travel in transition messages instead."
|
|
8768
8942
|
},
|
|
8769
8943
|
last_instructions: {
|
|
8770
|
-
description: "End-of-prompt instructions: parallel tool calling, persistence, task completion"
|
|
8944
|
+
description: "End-of-prompt instructions: parallel tool calling, persistence, task completion, and configured subagent-model guidance when the task tool is available"
|
|
8771
8945
|
}
|
|
8772
8946
|
};
|
|
8773
8947
|
function isAttributedPermissionResult(result) {
|
|
@@ -9955,7 +10129,20 @@ var CopilotSession = class {
|
|
|
9955
10129
|
}
|
|
9956
10130
|
for (const tool of tools) {
|
|
9957
10131
|
if (tool.handler) {
|
|
9958
|
-
|
|
10132
|
+
const handler = tool.handler;
|
|
10133
|
+
if (tool.name === "apply_patch" && tool.overridesBuiltInTool && toJsonSchema(tool.parameters)?.type === "string") {
|
|
10134
|
+
this.toolHandlers.set(tool.name, (args, invocation) => {
|
|
10135
|
+
if (typeof args === "string") {
|
|
10136
|
+
return handler(args, invocation);
|
|
10137
|
+
}
|
|
10138
|
+
if (typeof args === "object" && args !== null && "input" in args && typeof args.input === "string") {
|
|
10139
|
+
return handler(args.input, invocation);
|
|
10140
|
+
}
|
|
10141
|
+
throw new TypeError("apply_patch string override requires a string input");
|
|
10142
|
+
});
|
|
10143
|
+
} else {
|
|
10144
|
+
this.toolHandlers.set(tool.name, handler);
|
|
10145
|
+
}
|
|
9959
10146
|
}
|
|
9960
10147
|
}
|
|
9961
10148
|
}
|
|
@@ -10550,7 +10737,9 @@ var CopilotSession = class {
|
|
|
10550
10737
|
sessionStart: this.hooks.onSessionStart,
|
|
10551
10738
|
sessionEnd: this.hooks.onSessionEnd,
|
|
10552
10739
|
errorOccurred: this.hooks.onErrorOccurred,
|
|
10553
|
-
agentStop: this.hooks.onAgentStop
|
|
10740
|
+
agentStop: this.hooks.onAgentStop,
|
|
10741
|
+
subagentStart: this.hooks.onSubagentStart,
|
|
10742
|
+
subagentStop: this.hooks.onSubagentStop
|
|
10554
10743
|
};
|
|
10555
10744
|
const handler = handlerMap[hookType];
|
|
10556
10745
|
if (!handler) {
|
|
@@ -11022,6 +11211,7 @@ var EXCLUDED_TOP_LEVEL = /* @__PURE__ */ new Set([
|
|
|
11022
11211
|
"app.js",
|
|
11023
11212
|
"assets",
|
|
11024
11213
|
"changelog.json",
|
|
11214
|
+
"cli-main.js",
|
|
11025
11215
|
"copilot",
|
|
11026
11216
|
"copilot.exe",
|
|
11027
11217
|
"foundry-local-sdk",
|
|
@@ -11365,6 +11555,7 @@ var BuiltInTools = {
|
|
|
11365
11555
|
// src/sdk/nodejs/dist/client.js
|
|
11366
11556
|
var MIN_PROTOCOL_VERSION = 3;
|
|
11367
11557
|
var RUNTIME_SHUTDOWN_TIMEOUT_MS = 1e4;
|
|
11558
|
+
var CLOUD_SESSION_CLEANUP_TIMEOUT_MS = 1e4;
|
|
11368
11559
|
function createMessageConnection(reader, writer) {
|
|
11369
11560
|
let dispatch;
|
|
11370
11561
|
let finishDrain;
|
|
@@ -11893,6 +12084,11 @@ var CopilotClient = class _CopilotClient {
|
|
|
11893
12084
|
"SessionFsConfig declares capabilities.sqlite but the provider does not implement sqlite."
|
|
11894
12085
|
);
|
|
11895
12086
|
}
|
|
12087
|
+
if (this.sessionFsConfig.capabilities?.binary && (!provider.readFileBytes || !provider.writeFileBytes)) {
|
|
12088
|
+
throw new Error(
|
|
12089
|
+
"SessionFsConfig declares capabilities.binary but the provider does not implement readFileBytes and writeFileBytes."
|
|
12090
|
+
);
|
|
12091
|
+
}
|
|
11896
12092
|
session.clientSessionApis.sessionFs = createSessionFsAdapter(provider);
|
|
11897
12093
|
}
|
|
11898
12094
|
setupClientGlobalHandlers() {
|
|
@@ -12576,12 +12772,13 @@ var CopilotClient = class _CopilotClient {
|
|
|
12576
12772
|
if (config.onEvent) {
|
|
12577
12773
|
s.on(config.onEvent);
|
|
12578
12774
|
}
|
|
12579
|
-
this.sessions.set(sessionId, s);
|
|
12580
12775
|
this.setupSessionFs(s, config);
|
|
12776
|
+
this.sessions.set(sessionId, s);
|
|
12581
12777
|
return s;
|
|
12582
12778
|
};
|
|
12583
12779
|
let session;
|
|
12584
12780
|
let registeredId;
|
|
12781
|
+
let uninitializedCloudSessionId;
|
|
12585
12782
|
if (localSessionId !== void 0) {
|
|
12586
12783
|
try {
|
|
12587
12784
|
session = initializeSession(localSessionId);
|
|
@@ -12704,7 +12901,9 @@ var CopilotClient = class _CopilotClient {
|
|
|
12704
12901
|
);
|
|
12705
12902
|
}
|
|
12706
12903
|
if (session === void 0) {
|
|
12904
|
+
uninitializedCloudSessionId = returnedSessionId;
|
|
12707
12905
|
session = initializeSession(returnedSessionId);
|
|
12906
|
+
uninitializedCloudSessionId = void 0;
|
|
12708
12907
|
registeredId = returnedSessionId;
|
|
12709
12908
|
}
|
|
12710
12909
|
this.assignGitHubTokenProvider(gitHubTokenProviderRegistrationId, returnedSessionId);
|
|
@@ -12726,6 +12925,20 @@ var CopilotClient = class _CopilotClient {
|
|
|
12726
12925
|
if (gitHubTokenProviderRegistrationId !== void 0) {
|
|
12727
12926
|
this.githubTokenProviders.delete(gitHubTokenProviderRegistrationId);
|
|
12728
12927
|
}
|
|
12928
|
+
if (uninitializedCloudSessionId !== void 0) {
|
|
12929
|
+
try {
|
|
12930
|
+
await withTimeout(
|
|
12931
|
+
this.deleteSession(uninitializedCloudSessionId),
|
|
12932
|
+
CLOUD_SESSION_CLEANUP_TIMEOUT_MS,
|
|
12933
|
+
`session.delete timed out after ${CLOUD_SESSION_CLEANUP_TIMEOUT_MS}ms`
|
|
12934
|
+
);
|
|
12935
|
+
} catch (cleanupError) {
|
|
12936
|
+
throw new AggregateError(
|
|
12937
|
+
[e, cleanupError],
|
|
12938
|
+
"Failed to initialize and delete cloud session"
|
|
12939
|
+
);
|
|
12940
|
+
}
|
|
12941
|
+
}
|
|
12729
12942
|
throw e;
|
|
12730
12943
|
}
|
|
12731
12944
|
for (const entry of this.hostHandoffs.values()) {
|
|
@@ -12825,8 +13038,8 @@ var CopilotClient = class _CopilotClient {
|
|
|
12825
13038
|
if (config.onEvent) {
|
|
12826
13039
|
session.on(config.onEvent);
|
|
12827
13040
|
}
|
|
12828
|
-
this.sessions.set(sessionId, session);
|
|
12829
13041
|
this.setupSessionFs(session, config);
|
|
13042
|
+
this.sessions.set(sessionId, session);
|
|
12830
13043
|
const toolFilterOptions = this.resolveToolFilterOptions(config);
|
|
12831
13044
|
const gitHubTokenProviderRegistrationId = this.registerGitHubTokenProvider(
|
|
12832
13045
|
config.gitHubTokenProvider,
|
|
@@ -14133,6 +14346,7 @@ export {
|
|
|
14133
14346
|
RuntimeConnection,
|
|
14134
14347
|
SYSTEM_MESSAGE_SECTIONS,
|
|
14135
14348
|
SessionFsSqliteTransactionFailure,
|
|
14349
|
+
SessionFsWriteFailure,
|
|
14136
14350
|
ToolSet,
|
|
14137
14351
|
WorkflowResumeError,
|
|
14138
14352
|
approveAll,
|
|
@@ -37,6 +37,10 @@ export declare class SessionFsSqliteTransactionFailure extends Error {
|
|
|
37
37
|
readonly errorClass: SessionFsSqliteTransactionErrorClass;
|
|
38
38
|
constructor(message: string, errorClass?: SessionFsSqliteTransactionErrorClass);
|
|
39
39
|
}
|
|
40
|
+
/** Throw from `writeFile` only when the provider changed the target before failing. */
|
|
41
|
+
export declare class SessionFsWriteFailure extends Error {
|
|
42
|
+
readonly writeChanged = true;
|
|
43
|
+
}
|
|
40
44
|
/**
|
|
41
45
|
* SQLite operations for the per-session database.
|
|
42
46
|
* Implementers provide query execution and existence checking.
|
|
@@ -78,7 +82,11 @@ export interface SessionFsSqliteProvider {
|
|
|
78
82
|
export interface SessionFsProvider {
|
|
79
83
|
/** Reads the full content of a file. Throw if the file does not exist. */
|
|
80
84
|
readFile(path: string): Promise<string>;
|
|
81
|
-
/**
|
|
85
|
+
/** Read exact file bytes. Required when capabilities.binary is enabled. */
|
|
86
|
+
readFileBytes?(path: string): Promise<Uint8Array>;
|
|
87
|
+
/** Write exact file bytes. Required when capabilities.binary is enabled. */
|
|
88
|
+
writeFileBytes?(path: string, content: Uint8Array, mode?: number): Promise<void>;
|
|
89
|
+
/** Writes content to a file, creating parent directories if needed. Throw {@link SessionFsWriteFailure} if a failed write changed the target. */
|
|
82
90
|
writeFile(path: string, content: string, mode?: number): Promise<void>;
|
|
83
91
|
/** Appends content to a file, creating parent directories if needed. */
|
|
84
92
|
appendFile(path: string, content: string, mode?: number): Promise<void>;
|
package/copilot-sdk/types.d.ts
CHANGED
|
@@ -48,6 +48,7 @@ export type { SessionFsSqliteProvider } from "./sessionFsProvider.js";
|
|
|
48
48
|
export type { SessionFsSqliteStatement } from "./sessionFsProvider.js";
|
|
49
49
|
export type { SessionFsSqliteTransactionErrorClass } from "./sessionFsProvider.js";
|
|
50
50
|
export { SessionFsSqliteTransactionFailure } from "./sessionFsProvider.js";
|
|
51
|
+
export { SessionFsWriteFailure } from "./sessionFsProvider.js";
|
|
51
52
|
export type { LlmInferenceHeaders } from "./generated/rpc.js";
|
|
52
53
|
export type { PermissionDecisionContext, PermissionDecisionOutcome, PermissionDecisionSurface, PermissionResponseCapability, } from "./generated/rpc.js";
|
|
53
54
|
export type { PermissionDecisionSource } from "./generated/session-events.js";
|
|
@@ -922,6 +923,8 @@ export interface SystemMessageReplaceConfig {
|
|
|
922
923
|
/**
|
|
923
924
|
* Customize mode: Override individual sections of the system prompt.
|
|
924
925
|
* Keeps the SDK-managed prompt structure while allowing targeted modifications.
|
|
926
|
+
* The `last_instructions` section includes configured subagent-model guidance.
|
|
927
|
+
* Its overrides and transforms control that prose, not runtime model selection or tool availability.
|
|
925
928
|
*/
|
|
926
929
|
export interface SystemMessageCustomizeConfig {
|
|
927
930
|
mode: "customize";
|
|
@@ -1098,8 +1101,9 @@ export type AutoModeSwitchHandler = (request: AutoModeSwitchRequest, invocation:
|
|
|
1098
1101
|
* Base interface for all hook inputs
|
|
1099
1102
|
*/
|
|
1100
1103
|
export interface BaseHookInput {
|
|
1101
|
-
/** The runtime session ID
|
|
1102
|
-
*
|
|
1104
|
+
/** The runtime session ID associated with the hook. Child tool hooks use
|
|
1105
|
+
* the child session ID; sub-agent lifecycle hooks use the parent session ID,
|
|
1106
|
+
* matching `invocation.sessionId`. */
|
|
1103
1107
|
sessionId: string;
|
|
1104
1108
|
/** Time at which the hook event was emitted by the runtime. */
|
|
1105
1109
|
timestamp: Date;
|
|
@@ -1366,6 +1370,54 @@ export interface AgentStopHookOutput {
|
|
|
1366
1370
|
export type AgentStopHandler = (input: AgentStopHookInput, invocation: {
|
|
1367
1371
|
sessionId: string;
|
|
1368
1372
|
}) => Promise<AgentStopHookOutput | void> | AgentStopHookOutput | void;
|
|
1373
|
+
/**
|
|
1374
|
+
* Input for the hook fired before a sub-agent's first turn.
|
|
1375
|
+
*
|
|
1376
|
+
* The session metadata belongs to the parent session, not the child.
|
|
1377
|
+
*/
|
|
1378
|
+
export interface SubagentStartHookInput extends BaseHookInput {
|
|
1379
|
+
transcriptPath: string;
|
|
1380
|
+
agentName: string;
|
|
1381
|
+
agentDisplayName?: string;
|
|
1382
|
+
agentDescription?: string;
|
|
1383
|
+
}
|
|
1384
|
+
/** Output for the sub-agent start hook. Context is prepended to the child's initial prompt. */
|
|
1385
|
+
export interface SubagentStartHookOutput {
|
|
1386
|
+
additionalContext?: string;
|
|
1387
|
+
}
|
|
1388
|
+
/** Handler for the sub-agent start hook. */
|
|
1389
|
+
export type SubagentStartHandler = (input: SubagentStartHookInput, invocation: {
|
|
1390
|
+
sessionId: string;
|
|
1391
|
+
}) => Promise<SubagentStartHookOutput | void> | SubagentStartHookOutput | void;
|
|
1392
|
+
/**
|
|
1393
|
+
* Input for the hook fired after a sub-agent completes a turn.
|
|
1394
|
+
*
|
|
1395
|
+
* The response is the child's last assistant message before any hook rewrite.
|
|
1396
|
+
*/
|
|
1397
|
+
export interface SubagentStopHookInput extends SubagentStartHookInput {
|
|
1398
|
+
agentId?: string;
|
|
1399
|
+
agentType: string;
|
|
1400
|
+
stopReason: "end_turn";
|
|
1401
|
+
response: string;
|
|
1402
|
+
}
|
|
1403
|
+
/**
|
|
1404
|
+
* Output for the sub-agent stop hook. `"block"` with a nonempty `reason` continues
|
|
1405
|
+
* the child; otherwise `modifiedResponse` replaces the response reported to the parent.
|
|
1406
|
+
* When both are supplied, a valid block takes precedence over the rewrite.
|
|
1407
|
+
*/
|
|
1408
|
+
export type SubagentStopHookOutput = {
|
|
1409
|
+
decision: "block";
|
|
1410
|
+
reason: string;
|
|
1411
|
+
modifiedResponse?: string;
|
|
1412
|
+
} | {
|
|
1413
|
+
decision?: "allow";
|
|
1414
|
+
reason?: never;
|
|
1415
|
+
modifiedResponse?: string;
|
|
1416
|
+
};
|
|
1417
|
+
/** Handler for the sub-agent stop hook. */
|
|
1418
|
+
export type SubagentStopHandler = (input: SubagentStopHookInput, invocation: {
|
|
1419
|
+
sessionId: string;
|
|
1420
|
+
}) => Promise<SubagentStopHookOutput | void> | SubagentStopHookOutput | void;
|
|
1369
1421
|
/**
|
|
1370
1422
|
* Configuration for session hooks
|
|
1371
1423
|
*/
|
|
@@ -1422,6 +1474,13 @@ export interface SessionHooks {
|
|
|
1422
1474
|
* agent stop.
|
|
1423
1475
|
*/
|
|
1424
1476
|
onAgentStop?: AgentStopHandler;
|
|
1477
|
+
/** Called before a sub-agent's first turn. Return context to prepend to its prompt. */
|
|
1478
|
+
onSubagentStart?: SubagentStartHandler;
|
|
1479
|
+
/**
|
|
1480
|
+
* Called after a sub-agent completes a turn. Return a block reason to
|
|
1481
|
+
* continue the child, or a replacement response to report to the parent.
|
|
1482
|
+
*/
|
|
1483
|
+
onSubagentStop?: SubagentStopHandler;
|
|
1425
1484
|
}
|
|
1426
1485
|
/**
|
|
1427
1486
|
* Base interface for MCP server configuration.
|
|
@@ -2894,6 +2953,12 @@ export interface SessionFsConfig {
|
|
|
2894
2953
|
* @default false
|
|
2895
2954
|
*/
|
|
2896
2955
|
sqlite?: boolean;
|
|
2956
|
+
/**
|
|
2957
|
+
* Whether this provider supports exact binary reads and writes through readFileBytes and writeFileBytes.
|
|
2958
|
+
* Required to view images stored only in the provider.
|
|
2959
|
+
* @default false
|
|
2960
|
+
*/
|
|
2961
|
+
binary?: boolean;
|
|
2897
2962
|
};
|
|
2898
2963
|
}
|
|
2899
2964
|
/**
|
package/package.json
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
[diffend] Oversized file quarantined before diffing.
|
|
2
2
|
name: package/prebuilds/win32-x64/runtime.node
|
|
3
|
-
size:
|
|
4
|
-
sha256:
|
|
3
|
+
size: 107126048 bytes
|
|
4
|
+
sha256: 144ede5b5f9f80d9f748663abe5d1b9e4e088965b607e801bb53cc435d4eea42
|
|
Binary file
|