@github/copilot-sdk 1.0.7-preview.2 → 1.0.7-preview.3
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 +4 -2
- package/dist/cjs/client.js +71 -16
- package/dist/cjs/ffiRuntimeHost.js +8 -5
- package/dist/cjs/generated/rpc.js +7 -9
- package/dist/cjs/session.js +12 -1
- package/dist/cjs/types.js +3 -2
- package/dist/client.d.ts +4 -12
- package/dist/client.js +71 -16
- package/dist/ffiRuntimeHost.d.ts +3 -2
- package/dist/ffiRuntimeHost.js +8 -5
- package/dist/generated/rpc.d.ts +68 -24
- package/dist/generated/rpc.js +7 -9
- package/dist/generated/session-events.d.ts +26 -2
- package/dist/index.d.ts +1 -1
- package/dist/session.d.ts +6 -1
- package/dist/session.js +12 -1
- package/dist/types.d.ts +69 -10
- package/dist/types.js +3 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -84,9 +84,11 @@ new CopilotClient(options?: CopilotClientOptions)
|
|
|
84
84
|
**Options:**
|
|
85
85
|
|
|
86
86
|
- `connection?: RuntimeConnection` - How to connect to the Copilot runtime. Construct via the factory functions on `RuntimeConnection`:
|
|
87
|
-
- `RuntimeConnection.forStdio({ path?, args? })` (default) — spawn the runtime and communicate over its stdin/stdout.
|
|
88
|
-
- `RuntimeConnection.forTcp({ port?, connectionToken?, path?, args? })` — spawn the runtime as a TCP server.
|
|
87
|
+
- `RuntimeConnection.forStdio({ path?, args?, env? })` (default) — spawn the runtime and communicate over its stdin/stdout.
|
|
88
|
+
- `RuntimeConnection.forTcp({ port?, connectionToken?, path?, args?, env? })` — spawn the runtime as a TCP server.
|
|
89
89
|
- `RuntimeConnection.forUri(url, { connectionToken? })` — connect to an already-running runtime (mutually exclusive with `gitHubToken`/`useLoggedInUser`). There is no top-level `cliUrl` shortcut; use this factory for URL-based connections.
|
|
90
|
+
- `RuntimeConnection.forInProcess()` — host the runtime in-process over its native C ABI (FFI). **Experimental.** Because the runtime shares this process, `env`, `telemetry`, and `workingDirectory` are rejected with this transport; set them on the host process instead.
|
|
91
|
+
- The child-process transports (`forStdio`/`forTcp`) also accept a per-connection `env`. Set it there or via the top-level `env` option — not both (setting both throws).
|
|
90
92
|
- `mode?: "empty" | "copilot-cli"` - Defaulting strategy. Use `"empty"` for multi-user server mode; defaults to `"copilot-cli"`.
|
|
91
93
|
- `workingDirectory?: string` - Working directory for the runtime process (default: current process cwd).
|
|
92
94
|
- `baseDirectory?: string` - Base directory for Copilot data (session state, config, etc.). Sets `COPILOT_HOME` on the spawned runtime. When not set, the runtime defaults to `~/.copilot`. Ignored when connecting via `RuntimeConnection.forUri`.
|
package/dist/cjs/client.js
CHANGED
|
@@ -395,6 +395,21 @@ class CopilotClient {
|
|
|
395
395
|
"workingDirectory is not supported with RuntimeConnection.forInProcess(): the in-process transport hosts the runtime in this process, so honoring it would require mutating the shared process-global cwd. Change the host process's working directory before constructing the client instead."
|
|
396
396
|
);
|
|
397
397
|
}
|
|
398
|
+
if (conn.kind === "inprocess" && options.env !== void 0) {
|
|
399
|
+
throw new Error(
|
|
400
|
+
"env is not supported with RuntimeConnection.forInProcess(): the in-process transport loads the native runtime into the shared host process, whose single environment block cannot carry per-client values. Set the variables on the host process environment instead."
|
|
401
|
+
);
|
|
402
|
+
}
|
|
403
|
+
if (conn.kind === "inprocess" && options.telemetry !== void 0) {
|
|
404
|
+
throw new Error(
|
|
405
|
+
"telemetry is not supported with RuntimeConnection.forInProcess(): telemetry configuration is lowered to environment variables read by native runtime code running in the shared host process, so per-client telemetry cannot be honored in-process. Configure telemetry via the host process environment, or use a child-process transport."
|
|
406
|
+
);
|
|
407
|
+
}
|
|
408
|
+
if ((conn.kind === "stdio" || conn.kind === "tcp") && conn.env !== void 0 && options.env !== void 0) {
|
|
409
|
+
throw new Error(
|
|
410
|
+
"Set environment variables via either the client-level env option or the connection's env (RuntimeConnection.forStdio/forTcp), not both. Prefer the connection-level env for child-process transports."
|
|
411
|
+
);
|
|
412
|
+
}
|
|
398
413
|
if (conn.kind === "tcp" && conn.connectionToken !== void 0) {
|
|
399
414
|
if (typeof conn.connectionToken !== "string" || conn.connectionToken.length === 0) {
|
|
400
415
|
throw new Error("connectionToken must be a non-empty string");
|
|
@@ -423,7 +438,8 @@ class CopilotClient {
|
|
|
423
438
|
this.requestHandler = options.requestHandler ?? null;
|
|
424
439
|
this.onGitHubTelemetry = options.onGitHubTelemetry;
|
|
425
440
|
this.setupClientGlobalHandlers();
|
|
426
|
-
const
|
|
441
|
+
const connEnv = conn.kind === "stdio" || conn.kind === "tcp" ? conn.env : void 0;
|
|
442
|
+
const effectiveEnv = connEnv ?? options.env ?? process.env;
|
|
427
443
|
this.resolvedEnv = effectiveEnv;
|
|
428
444
|
this.resolvedCliPath = conn.kind === "stdio" || conn.kind === "tcp" ? conn.path ?? effectiveEnv.COPILOT_CLI_PATH ?? getBundledCliPath() : void 0;
|
|
429
445
|
const connArgs = conn.kind === "stdio" || conn.kind === "tcp" ? conn.args ?? [] : [];
|
|
@@ -1060,6 +1076,7 @@ class CopilotClient {
|
|
|
1060
1076
|
skipPermission: tool.skipPermission,
|
|
1061
1077
|
defer: tool.defer
|
|
1062
1078
|
})),
|
|
1079
|
+
toolSearch: config.toolSearch,
|
|
1063
1080
|
canvases: config.canvases?.map((canvas) => canvas.declaration),
|
|
1064
1081
|
requestCanvasRenderer: config.requestCanvasRenderer,
|
|
1065
1082
|
requestExtensions: config.requestExtensions,
|
|
@@ -1258,6 +1275,7 @@ class CopilotClient {
|
|
|
1258
1275
|
skipPermission: tool.skipPermission,
|
|
1259
1276
|
defer: tool.defer
|
|
1260
1277
|
})),
|
|
1278
|
+
toolSearch: config.toolSearch,
|
|
1261
1279
|
canvases: config.canvases?.map((canvas) => canvas.declaration),
|
|
1262
1280
|
requestCanvasRenderer: config.requestCanvasRenderer,
|
|
1263
1281
|
requestExtensions: config.requestExtensions,
|
|
@@ -1861,21 +1879,42 @@ stderr: ${stderrOutput}`
|
|
|
1861
1879
|
return this.connectViaTcp();
|
|
1862
1880
|
}
|
|
1863
1881
|
}
|
|
1864
|
-
/**
|
|
1865
|
-
* Start the in-process FFI runtime host: resolve the CLI entrypoint and native
|
|
1866
|
-
* runtime library, then let the native host spawn the CLI worker.
|
|
1867
|
-
*
|
|
1868
|
-
* The worker inherits this host process's ambient environment; per-client options
|
|
1869
|
-
* that lower to environment variables (`env`, `telemetry`, `gitHubToken`,
|
|
1870
|
-
* `baseDirectory`) are intentionally not applied here, because the native runtime
|
|
1871
|
-
* loads into the shared host process and a single env block cannot carry per-client
|
|
1872
|
-
* values. Configure the in-process runtime via the host process environment instead.
|
|
1873
|
-
* See https://github.com/github/copilot-sdk/issues/1934.
|
|
1874
|
-
*/
|
|
1882
|
+
/** Starts the in-process FFI runtime with SDK-managed typed options. */
|
|
1875
1883
|
async startInProcessFfi() {
|
|
1876
1884
|
const entrypoint = this.resolveCliPathForFfi();
|
|
1877
1885
|
const { FfiRuntimeHost } = await import("./ffiRuntimeHost.js");
|
|
1878
|
-
const
|
|
1886
|
+
const environment = {};
|
|
1887
|
+
if (this.options.gitHubToken) {
|
|
1888
|
+
environment.COPILOT_SDK_AUTH_TOKEN = this.options.gitHubToken;
|
|
1889
|
+
}
|
|
1890
|
+
if (this.options.baseDirectory) {
|
|
1891
|
+
environment.COPILOT_HOME = this.options.baseDirectory;
|
|
1892
|
+
}
|
|
1893
|
+
if (this.options.mode === "empty") {
|
|
1894
|
+
environment.COPILOT_DISABLE_KEYTAR = "1";
|
|
1895
|
+
}
|
|
1896
|
+
const args = [];
|
|
1897
|
+
if (this.options.logLevel) {
|
|
1898
|
+
args.push("--log-level", this.options.logLevel);
|
|
1899
|
+
}
|
|
1900
|
+
if (this.options.gitHubToken) {
|
|
1901
|
+
args.push("--auth-token-env", "COPILOT_SDK_AUTH_TOKEN");
|
|
1902
|
+
}
|
|
1903
|
+
if (!this.options.useLoggedInUser) {
|
|
1904
|
+
args.push("--no-auto-login");
|
|
1905
|
+
}
|
|
1906
|
+
if (this.options.sessionIdleTimeoutSeconds > 0) {
|
|
1907
|
+
args.push("--session-idle-timeout", this.options.sessionIdleTimeoutSeconds.toString());
|
|
1908
|
+
}
|
|
1909
|
+
if (this.options.enableRemoteSessions) {
|
|
1910
|
+
args.push("--remote");
|
|
1911
|
+
}
|
|
1912
|
+
const host = FfiRuntimeHost.create(
|
|
1913
|
+
entrypoint,
|
|
1914
|
+
CopilotClient.getNapiPrebuildsFolder(entrypoint),
|
|
1915
|
+
environment,
|
|
1916
|
+
args
|
|
1917
|
+
);
|
|
1879
1918
|
this.ffiHost = host;
|
|
1880
1919
|
await host.start();
|
|
1881
1920
|
}
|
|
@@ -1905,14 +1944,30 @@ stderr: ${stderrOutput}`
|
|
|
1905
1944
|
/**
|
|
1906
1945
|
* Returns the napi prebuilds folder name for the current host — the
|
|
1907
1946
|
* `<node-platform>-<arch>` convention (e.g. `win32-x64`, `darwin-arm64`,
|
|
1908
|
-
* `linux-x64`) under which the runtime ships
|
|
1947
|
+
* `linux-x64`, `linuxmusl-x64`) under which the runtime ships
|
|
1948
|
+
* `prebuilds/<folder>/runtime.node`.
|
|
1909
1949
|
*/
|
|
1910
|
-
static getNapiPrebuildsFolder() {
|
|
1950
|
+
static getNapiPrebuildsFolder(entrypoint) {
|
|
1911
1951
|
const arch = process.arch;
|
|
1912
1952
|
if (arch !== "x64" && arch !== "arm64") {
|
|
1913
1953
|
throw new Error(`Unsupported architecture '${arch}' for in-process FFI hosting.`);
|
|
1914
1954
|
}
|
|
1915
|
-
|
|
1955
|
+
let platform = process.platform;
|
|
1956
|
+
if (platform === "linux" && CopilotClient.isMusl(entrypoint)) {
|
|
1957
|
+
platform = "linuxmusl";
|
|
1958
|
+
}
|
|
1959
|
+
return `${platform}-${arch}`;
|
|
1960
|
+
}
|
|
1961
|
+
static isMusl(entrypoint) {
|
|
1962
|
+
if (entrypoint.includes(`copilot-linuxmusl-${process.arch}`)) {
|
|
1963
|
+
return true;
|
|
1964
|
+
}
|
|
1965
|
+
if (entrypoint.includes(`copilot-linux-${process.arch}`)) {
|
|
1966
|
+
return false;
|
|
1967
|
+
}
|
|
1968
|
+
const report = process.report?.getReport();
|
|
1969
|
+
const header = report && "header" in report ? report.header : void 0;
|
|
1970
|
+
return header !== void 0 && header.glibcVersionRuntime === void 0;
|
|
1916
1971
|
}
|
|
1917
1972
|
/**
|
|
1918
1973
|
* Connect to child via stdio pipes
|
|
@@ -84,8 +84,9 @@ function loadLibrary(libraryPath) {
|
|
|
84
84
|
loadedLibraryPath = libraryPath;
|
|
85
85
|
return loadedLibrary;
|
|
86
86
|
}
|
|
87
|
-
function buildArgvJson(cliEntrypoint) {
|
|
87
|
+
function buildArgvJson(cliEntrypoint, args) {
|
|
88
88
|
const argv = cliEntrypoint.toLowerCase().endsWith(".js") ? ["node", cliEntrypoint, "--embedded-host", "--no-auto-update"] : [cliEntrypoint, "--embedded-host", "--no-auto-update"];
|
|
89
|
+
argv.push(...args);
|
|
89
90
|
return Buffer.from(JSON.stringify(argv), "utf8");
|
|
90
91
|
}
|
|
91
92
|
function buildEnvJson(environment) {
|
|
@@ -104,10 +105,11 @@ function buildEnvJson(environment) {
|
|
|
104
105
|
return Buffer.from(JSON.stringify(obj), "utf8");
|
|
105
106
|
}
|
|
106
107
|
class FfiRuntimeHost {
|
|
107
|
-
constructor(libraryPath, cliEntrypoint, environment) {
|
|
108
|
+
constructor(libraryPath, cliEntrypoint, environment, args) {
|
|
108
109
|
this.libraryPath = libraryPath;
|
|
109
110
|
this.cliEntrypoint = cliEntrypoint;
|
|
110
111
|
this.environment = environment;
|
|
112
|
+
this.args = args;
|
|
111
113
|
this.lib = loadLibrary(libraryPath);
|
|
112
114
|
this.receiveStream = new import_node_stream.PassThrough();
|
|
113
115
|
this.sendStream = new import_node_stream.Writable({
|
|
@@ -126,6 +128,7 @@ class FfiRuntimeHost {
|
|
|
126
128
|
libraryPath;
|
|
127
129
|
cliEntrypoint;
|
|
128
130
|
environment;
|
|
131
|
+
args;
|
|
129
132
|
lib;
|
|
130
133
|
serverId = 0;
|
|
131
134
|
connectionId = 0;
|
|
@@ -142,21 +145,21 @@ class FfiRuntimeHost {
|
|
|
142
145
|
* the entrypoint directory (the napi-rs `<node-platform>-<arch>` layout, e.g.
|
|
143
146
|
* `linux-x64`). Throws if it cannot be found.
|
|
144
147
|
*/
|
|
145
|
-
static create(cliEntrypoint, prebuildsFolder, environment) {
|
|
148
|
+
static create(cliEntrypoint, prebuildsFolder, environment, args) {
|
|
146
149
|
const fullEntrypoint = (0, import_node_path.resolve)(cliEntrypoint);
|
|
147
150
|
const distDir = (0, import_node_path.dirname)(fullEntrypoint);
|
|
148
151
|
const libraryPath = (0, import_node_path.join)(distDir, "prebuilds", prebuildsFolder, "runtime.node");
|
|
149
152
|
if (!(0, import_node_fs.existsSync)(libraryPath)) {
|
|
150
153
|
throw new Error(`FFI runtime library not found. Looked for '${libraryPath}'.`);
|
|
151
154
|
}
|
|
152
|
-
return new FfiRuntimeHost(libraryPath, fullEntrypoint, environment);
|
|
155
|
+
return new FfiRuntimeHost(libraryPath, fullEntrypoint, environment, args);
|
|
153
156
|
}
|
|
154
157
|
/**
|
|
155
158
|
* Starts the in-process runtime: spawns the CLI worker via the native host,
|
|
156
159
|
* waits for readiness, and opens the FFI JSON-RPC connection.
|
|
157
160
|
*/
|
|
158
161
|
async start() {
|
|
159
|
-
const argvJson = buildArgvJson(this.cliEntrypoint);
|
|
162
|
+
const argvJson = buildArgvJson(this.cliEntrypoint, this.args);
|
|
160
163
|
const envJson = buildEnvJson(this.environment);
|
|
161
164
|
this.serverId = await new Promise((resolvePromise, rejectPromise) => {
|
|
162
165
|
this.lib.hostStart.async(
|
|
@@ -223,7 +223,7 @@ function createServerRpc(connection) {
|
|
|
223
223
|
/**
|
|
224
224
|
* Registers a new marketplace from a source (owner/repo, URL, or local path).
|
|
225
225
|
*
|
|
226
|
-
* @param params Marketplace source
|
|
226
|
+
* @param params Marketplace source and optional working directory for relative-path resolution.
|
|
227
227
|
*
|
|
228
228
|
* @returns Result of registering a new marketplace.
|
|
229
229
|
*/
|
|
@@ -1231,13 +1231,11 @@ function createSessionRpc(connection, sessionId) {
|
|
|
1231
1231
|
/** @experimental */
|
|
1232
1232
|
apps: {
|
|
1233
1233
|
/**
|
|
1234
|
-
*
|
|
1234
|
+
* Fetch an MCP resource (typically a `ui://` MCP App bundle, per SEP-1865) from a connected server. Requires the `mcp-apps` session capability.
|
|
1235
1235
|
*
|
|
1236
|
-
* @param params
|
|
1237
|
-
*
|
|
1238
|
-
* @returns Deprecated/obsolete MCP Apps alias for `McpResourcesReadResult`; use `session.mcp.resources.read` instead.
|
|
1236
|
+
* @param params MCP server and resource URI to fetch.
|
|
1239
1237
|
*
|
|
1240
|
-
* @
|
|
1238
|
+
* @returns Resource contents returned by the MCP server.
|
|
1241
1239
|
*/
|
|
1242
1240
|
readResource: async (params) => connection.sendRequest("session.mcp.apps.readResource", { sessionId, ...params }),
|
|
1243
1241
|
/**
|
|
@@ -1804,11 +1802,11 @@ function createSessionRpc(connection, sessionId) {
|
|
|
1804
1802
|
*/
|
|
1805
1803
|
recordContextChange: async (params) => connection.sendRequest("session.metadata.recordContextChange", { sessionId, ...params }),
|
|
1806
1804
|
/**
|
|
1807
|
-
* Updates the session's
|
|
1805
|
+
* Updates the session's working directory. For local sessions the target is validated first (an absolute path that exists on disk) and the permission primary directory is re-based; a rejected validation fails the call before any session state changes.
|
|
1808
1806
|
*
|
|
1809
|
-
* @param params Absolute path to set as the session's new working directory.
|
|
1807
|
+
* @param params Absolute path to set as the session's new working directory. For local sessions the path must be absolute and exist on disk: it is validated before any session state changes, and a failing validation rejects the call with nothing mutated, persisted, or emitted. Remote sessions record the path as-is.
|
|
1810
1808
|
*
|
|
1811
|
-
* @returns Update the session's working directory. Used by the host when the user explicitly changes cwd (e.g., the `/cd` slash command). The host is responsible for
|
|
1809
|
+
* @returns Update the session's working directory. Used by the host when the user explicitly changes cwd (e.g., the `/cd` slash command). The host is responsible for any related side-effects (file index, etc.); it does NOT change the process working directory (a session's cwd is per-session, not process-global). For local sessions the runtime validates the target first (an absolute path that exists on disk) and re-bases the permission primary directory; a rejected validation fails the call before anything is mutated, persisted, or emitted. Location-scoped permission rules are then re-keyed to the new directory (best-effort). Remote sessions only record the path.
|
|
1812
1810
|
*/
|
|
1813
1811
|
setWorkingDirectory: async (params) => connection.sendRequest("session.metadata.setWorkingDirectory", { sessionId, ...params }),
|
|
1814
1812
|
/**
|
package/dist/cjs/session.js
CHANGED
|
@@ -40,6 +40,7 @@ function isOpenCanvasInstance(value) {
|
|
|
40
40
|
const instance = value;
|
|
41
41
|
return typeof instance.instanceId === "string" && instance.instanceId.length > 0 && typeof instance.extensionId === "string" && instance.extensionId.length > 0 && typeof instance.canvasId === "string" && instance.canvasId.length > 0;
|
|
42
42
|
}
|
|
43
|
+
const TOOL_SEARCH_TOOL_NAME = "tool_search_tool";
|
|
43
44
|
class CopilotSession {
|
|
44
45
|
/**
|
|
45
46
|
* Creates a new CopilotSession instance.
|
|
@@ -352,11 +353,21 @@ class CopilotSession {
|
|
|
352
353
|
*/
|
|
353
354
|
async _executeToolAndRespond(requestId, toolName, toolCallId, args, handler, traceparent, tracestate) {
|
|
354
355
|
try {
|
|
356
|
+
let availableTools;
|
|
357
|
+
if (toolName === TOOL_SEARCH_TOOL_NAME) {
|
|
358
|
+
try {
|
|
359
|
+
const metadata = await this.rpc.tools.getCurrentMetadata();
|
|
360
|
+
availableTools = metadata.tools ?? void 0;
|
|
361
|
+
} catch {
|
|
362
|
+
availableTools = void 0;
|
|
363
|
+
}
|
|
364
|
+
}
|
|
355
365
|
const rawResult = await handler(args, {
|
|
356
366
|
sessionId: this.sessionId,
|
|
357
367
|
toolCallId,
|
|
358
368
|
toolName,
|
|
359
369
|
arguments: args,
|
|
370
|
+
availableTools,
|
|
360
371
|
traceparent,
|
|
361
372
|
tracestate
|
|
362
373
|
});
|
|
@@ -1009,7 +1020,7 @@ class CopilotSession {
|
|
|
1009
1020
|
*
|
|
1010
1021
|
* @example
|
|
1011
1022
|
* ```typescript
|
|
1012
|
-
* await session.setModel("gpt-4
|
|
1023
|
+
* await session.setModel("gpt-5.4");
|
|
1013
1024
|
* await session.setModel("claude-sonnet-4.6", { reasoningEffort: "high" });
|
|
1014
1025
|
* ```
|
|
1015
1026
|
*/
|
package/dist/cjs/types.js
CHANGED
|
@@ -39,7 +39,7 @@ const RuntimeConnection = {
|
|
|
39
39
|
* This is the default if no {@link CopilotClientOptions.connection} is set.
|
|
40
40
|
*/
|
|
41
41
|
forStdio(opts = {}) {
|
|
42
|
-
return { kind: "stdio", path: opts.path, args: opts.args };
|
|
42
|
+
return { kind: "stdio", path: opts.path, args: opts.args, env: opts.env };
|
|
43
43
|
},
|
|
44
44
|
/**
|
|
45
45
|
* Spawn a runtime child process that listens on a TCP socket and connect to it.
|
|
@@ -50,7 +50,8 @@ const RuntimeConnection = {
|
|
|
50
50
|
port: opts.port,
|
|
51
51
|
connectionToken: opts.connectionToken,
|
|
52
52
|
path: opts.path,
|
|
53
|
-
args: opts.args
|
|
53
|
+
args: opts.args,
|
|
54
|
+
env: opts.env
|
|
54
55
|
};
|
|
55
56
|
},
|
|
56
57
|
/**
|
package/dist/client.d.ts
CHANGED
|
@@ -435,17 +435,7 @@ export declare class CopilotClient {
|
|
|
435
435
|
* Connect to the CLI server (via socket or stdio)
|
|
436
436
|
*/
|
|
437
437
|
private connectToServer;
|
|
438
|
-
/**
|
|
439
|
-
* Start the in-process FFI runtime host: resolve the CLI entrypoint and native
|
|
440
|
-
* runtime library, then let the native host spawn the CLI worker.
|
|
441
|
-
*
|
|
442
|
-
* The worker inherits this host process's ambient environment; per-client options
|
|
443
|
-
* that lower to environment variables (`env`, `telemetry`, `gitHubToken`,
|
|
444
|
-
* `baseDirectory`) are intentionally not applied here, because the native runtime
|
|
445
|
-
* loads into the shared host process and a single env block cannot carry per-client
|
|
446
|
-
* values. Configure the in-process runtime via the host process environment instead.
|
|
447
|
-
* See https://github.com/github/copilot-sdk/issues/1934.
|
|
448
|
-
*/
|
|
438
|
+
/** Starts the in-process FFI runtime with SDK-managed typed options. */
|
|
449
439
|
private startInProcessFfi;
|
|
450
440
|
/**
|
|
451
441
|
* Connect to the in-process FFI runtime host over its receive/send streams,
|
|
@@ -460,9 +450,11 @@ export declare class CopilotClient {
|
|
|
460
450
|
/**
|
|
461
451
|
* Returns the napi prebuilds folder name for the current host — the
|
|
462
452
|
* `<node-platform>-<arch>` convention (e.g. `win32-x64`, `darwin-arm64`,
|
|
463
|
-
* `linux-x64`) under which the runtime ships
|
|
453
|
+
* `linux-x64`, `linuxmusl-x64`) under which the runtime ships
|
|
454
|
+
* `prebuilds/<folder>/runtime.node`.
|
|
464
455
|
*/
|
|
465
456
|
private static getNapiPrebuildsFolder;
|
|
457
|
+
private static isMusl;
|
|
466
458
|
/**
|
|
467
459
|
* Connect to child via stdio pipes
|
|
468
460
|
*/
|
package/dist/client.js
CHANGED
|
@@ -372,6 +372,21 @@ class CopilotClient {
|
|
|
372
372
|
"workingDirectory is not supported with RuntimeConnection.forInProcess(): the in-process transport hosts the runtime in this process, so honoring it would require mutating the shared process-global cwd. Change the host process's working directory before constructing the client instead."
|
|
373
373
|
);
|
|
374
374
|
}
|
|
375
|
+
if (conn.kind === "inprocess" && options.env !== void 0) {
|
|
376
|
+
throw new Error(
|
|
377
|
+
"env is not supported with RuntimeConnection.forInProcess(): the in-process transport loads the native runtime into the shared host process, whose single environment block cannot carry per-client values. Set the variables on the host process environment instead."
|
|
378
|
+
);
|
|
379
|
+
}
|
|
380
|
+
if (conn.kind === "inprocess" && options.telemetry !== void 0) {
|
|
381
|
+
throw new Error(
|
|
382
|
+
"telemetry is not supported with RuntimeConnection.forInProcess(): telemetry configuration is lowered to environment variables read by native runtime code running in the shared host process, so per-client telemetry cannot be honored in-process. Configure telemetry via the host process environment, or use a child-process transport."
|
|
383
|
+
);
|
|
384
|
+
}
|
|
385
|
+
if ((conn.kind === "stdio" || conn.kind === "tcp") && conn.env !== void 0 && options.env !== void 0) {
|
|
386
|
+
throw new Error(
|
|
387
|
+
"Set environment variables via either the client-level env option or the connection's env (RuntimeConnection.forStdio/forTcp), not both. Prefer the connection-level env for child-process transports."
|
|
388
|
+
);
|
|
389
|
+
}
|
|
375
390
|
if (conn.kind === "tcp" && conn.connectionToken !== void 0) {
|
|
376
391
|
if (typeof conn.connectionToken !== "string" || conn.connectionToken.length === 0) {
|
|
377
392
|
throw new Error("connectionToken must be a non-empty string");
|
|
@@ -400,7 +415,8 @@ class CopilotClient {
|
|
|
400
415
|
this.requestHandler = options.requestHandler ?? null;
|
|
401
416
|
this.onGitHubTelemetry = options.onGitHubTelemetry;
|
|
402
417
|
this.setupClientGlobalHandlers();
|
|
403
|
-
const
|
|
418
|
+
const connEnv = conn.kind === "stdio" || conn.kind === "tcp" ? conn.env : void 0;
|
|
419
|
+
const effectiveEnv = connEnv ?? options.env ?? process.env;
|
|
404
420
|
this.resolvedEnv = effectiveEnv;
|
|
405
421
|
this.resolvedCliPath = conn.kind === "stdio" || conn.kind === "tcp" ? conn.path ?? effectiveEnv.COPILOT_CLI_PATH ?? getBundledCliPath() : void 0;
|
|
406
422
|
const connArgs = conn.kind === "stdio" || conn.kind === "tcp" ? conn.args ?? [] : [];
|
|
@@ -1037,6 +1053,7 @@ class CopilotClient {
|
|
|
1037
1053
|
skipPermission: tool.skipPermission,
|
|
1038
1054
|
defer: tool.defer
|
|
1039
1055
|
})),
|
|
1056
|
+
toolSearch: config.toolSearch,
|
|
1040
1057
|
canvases: config.canvases?.map((canvas) => canvas.declaration),
|
|
1041
1058
|
requestCanvasRenderer: config.requestCanvasRenderer,
|
|
1042
1059
|
requestExtensions: config.requestExtensions,
|
|
@@ -1235,6 +1252,7 @@ class CopilotClient {
|
|
|
1235
1252
|
skipPermission: tool.skipPermission,
|
|
1236
1253
|
defer: tool.defer
|
|
1237
1254
|
})),
|
|
1255
|
+
toolSearch: config.toolSearch,
|
|
1238
1256
|
canvases: config.canvases?.map((canvas) => canvas.declaration),
|
|
1239
1257
|
requestCanvasRenderer: config.requestCanvasRenderer,
|
|
1240
1258
|
requestExtensions: config.requestExtensions,
|
|
@@ -1838,21 +1856,42 @@ stderr: ${stderrOutput}`
|
|
|
1838
1856
|
return this.connectViaTcp();
|
|
1839
1857
|
}
|
|
1840
1858
|
}
|
|
1841
|
-
/**
|
|
1842
|
-
* Start the in-process FFI runtime host: resolve the CLI entrypoint and native
|
|
1843
|
-
* runtime library, then let the native host spawn the CLI worker.
|
|
1844
|
-
*
|
|
1845
|
-
* The worker inherits this host process's ambient environment; per-client options
|
|
1846
|
-
* that lower to environment variables (`env`, `telemetry`, `gitHubToken`,
|
|
1847
|
-
* `baseDirectory`) are intentionally not applied here, because the native runtime
|
|
1848
|
-
* loads into the shared host process and a single env block cannot carry per-client
|
|
1849
|
-
* values. Configure the in-process runtime via the host process environment instead.
|
|
1850
|
-
* See https://github.com/github/copilot-sdk/issues/1934.
|
|
1851
|
-
*/
|
|
1859
|
+
/** Starts the in-process FFI runtime with SDK-managed typed options. */
|
|
1852
1860
|
async startInProcessFfi() {
|
|
1853
1861
|
const entrypoint = this.resolveCliPathForFfi();
|
|
1854
1862
|
const { FfiRuntimeHost } = await import("./ffiRuntimeHost.js");
|
|
1855
|
-
const
|
|
1863
|
+
const environment = {};
|
|
1864
|
+
if (this.options.gitHubToken) {
|
|
1865
|
+
environment.COPILOT_SDK_AUTH_TOKEN = this.options.gitHubToken;
|
|
1866
|
+
}
|
|
1867
|
+
if (this.options.baseDirectory) {
|
|
1868
|
+
environment.COPILOT_HOME = this.options.baseDirectory;
|
|
1869
|
+
}
|
|
1870
|
+
if (this.options.mode === "empty") {
|
|
1871
|
+
environment.COPILOT_DISABLE_KEYTAR = "1";
|
|
1872
|
+
}
|
|
1873
|
+
const args = [];
|
|
1874
|
+
if (this.options.logLevel) {
|
|
1875
|
+
args.push("--log-level", this.options.logLevel);
|
|
1876
|
+
}
|
|
1877
|
+
if (this.options.gitHubToken) {
|
|
1878
|
+
args.push("--auth-token-env", "COPILOT_SDK_AUTH_TOKEN");
|
|
1879
|
+
}
|
|
1880
|
+
if (!this.options.useLoggedInUser) {
|
|
1881
|
+
args.push("--no-auto-login");
|
|
1882
|
+
}
|
|
1883
|
+
if (this.options.sessionIdleTimeoutSeconds > 0) {
|
|
1884
|
+
args.push("--session-idle-timeout", this.options.sessionIdleTimeoutSeconds.toString());
|
|
1885
|
+
}
|
|
1886
|
+
if (this.options.enableRemoteSessions) {
|
|
1887
|
+
args.push("--remote");
|
|
1888
|
+
}
|
|
1889
|
+
const host = FfiRuntimeHost.create(
|
|
1890
|
+
entrypoint,
|
|
1891
|
+
CopilotClient.getNapiPrebuildsFolder(entrypoint),
|
|
1892
|
+
environment,
|
|
1893
|
+
args
|
|
1894
|
+
);
|
|
1856
1895
|
this.ffiHost = host;
|
|
1857
1896
|
await host.start();
|
|
1858
1897
|
}
|
|
@@ -1882,14 +1921,30 @@ stderr: ${stderrOutput}`
|
|
|
1882
1921
|
/**
|
|
1883
1922
|
* Returns the napi prebuilds folder name for the current host — the
|
|
1884
1923
|
* `<node-platform>-<arch>` convention (e.g. `win32-x64`, `darwin-arm64`,
|
|
1885
|
-
* `linux-x64`) under which the runtime ships
|
|
1924
|
+
* `linux-x64`, `linuxmusl-x64`) under which the runtime ships
|
|
1925
|
+
* `prebuilds/<folder>/runtime.node`.
|
|
1886
1926
|
*/
|
|
1887
|
-
static getNapiPrebuildsFolder() {
|
|
1927
|
+
static getNapiPrebuildsFolder(entrypoint) {
|
|
1888
1928
|
const arch = process.arch;
|
|
1889
1929
|
if (arch !== "x64" && arch !== "arm64") {
|
|
1890
1930
|
throw new Error(`Unsupported architecture '${arch}' for in-process FFI hosting.`);
|
|
1891
1931
|
}
|
|
1892
|
-
|
|
1932
|
+
let platform = process.platform;
|
|
1933
|
+
if (platform === "linux" && CopilotClient.isMusl(entrypoint)) {
|
|
1934
|
+
platform = "linuxmusl";
|
|
1935
|
+
}
|
|
1936
|
+
return `${platform}-${arch}`;
|
|
1937
|
+
}
|
|
1938
|
+
static isMusl(entrypoint) {
|
|
1939
|
+
if (entrypoint.includes(`copilot-linuxmusl-${process.arch}`)) {
|
|
1940
|
+
return true;
|
|
1941
|
+
}
|
|
1942
|
+
if (entrypoint.includes(`copilot-linux-${process.arch}`)) {
|
|
1943
|
+
return false;
|
|
1944
|
+
}
|
|
1945
|
+
const report = process.report?.getReport();
|
|
1946
|
+
const header = report && "header" in report ? report.header : void 0;
|
|
1947
|
+
return header !== void 0 && header.glibcVersionRuntime === void 0;
|
|
1893
1948
|
}
|
|
1894
1949
|
/**
|
|
1895
1950
|
* Connect to child via stdio pipes
|
package/dist/ffiRuntimeHost.d.ts
CHANGED
|
@@ -2,7 +2,8 @@ import { PassThrough, Writable } from "node:stream";
|
|
|
2
2
|
export declare class FfiRuntimeHost {
|
|
3
3
|
private readonly libraryPath;
|
|
4
4
|
private readonly cliEntrypoint;
|
|
5
|
-
private readonly environment
|
|
5
|
+
private readonly environment;
|
|
6
|
+
private readonly args;
|
|
6
7
|
private readonly lib;
|
|
7
8
|
private serverId;
|
|
8
9
|
private connectionId;
|
|
@@ -20,7 +21,7 @@ export declare class FfiRuntimeHost {
|
|
|
20
21
|
* the entrypoint directory (the napi-rs `<node-platform>-<arch>` layout, e.g.
|
|
21
22
|
* `linux-x64`). Throws if it cannot be found.
|
|
22
23
|
*/
|
|
23
|
-
static create(cliEntrypoint: string, prebuildsFolder: string, environment
|
|
24
|
+
static create(cliEntrypoint: string, prebuildsFolder: string, environment: Record<string, string | undefined> | undefined, args: readonly string[]): FfiRuntimeHost;
|
|
24
25
|
/**
|
|
25
26
|
* Starts the in-process runtime: spawns the CLI worker via the native host,
|
|
26
27
|
* waits for readiness, and opens the FFI JSON-RPC connection.
|
package/dist/ffiRuntimeHost.js
CHANGED
|
@@ -51,8 +51,9 @@ function loadLibrary(libraryPath) {
|
|
|
51
51
|
loadedLibraryPath = libraryPath;
|
|
52
52
|
return loadedLibrary;
|
|
53
53
|
}
|
|
54
|
-
function buildArgvJson(cliEntrypoint) {
|
|
54
|
+
function buildArgvJson(cliEntrypoint, args) {
|
|
55
55
|
const argv = cliEntrypoint.toLowerCase().endsWith(".js") ? ["node", cliEntrypoint, "--embedded-host", "--no-auto-update"] : [cliEntrypoint, "--embedded-host", "--no-auto-update"];
|
|
56
|
+
argv.push(...args);
|
|
56
57
|
return Buffer.from(JSON.stringify(argv), "utf8");
|
|
57
58
|
}
|
|
58
59
|
function buildEnvJson(environment) {
|
|
@@ -71,10 +72,11 @@ function buildEnvJson(environment) {
|
|
|
71
72
|
return Buffer.from(JSON.stringify(obj), "utf8");
|
|
72
73
|
}
|
|
73
74
|
class FfiRuntimeHost {
|
|
74
|
-
constructor(libraryPath, cliEntrypoint, environment) {
|
|
75
|
+
constructor(libraryPath, cliEntrypoint, environment, args) {
|
|
75
76
|
this.libraryPath = libraryPath;
|
|
76
77
|
this.cliEntrypoint = cliEntrypoint;
|
|
77
78
|
this.environment = environment;
|
|
79
|
+
this.args = args;
|
|
78
80
|
this.lib = loadLibrary(libraryPath);
|
|
79
81
|
this.receiveStream = new PassThrough();
|
|
80
82
|
this.sendStream = new Writable({
|
|
@@ -93,6 +95,7 @@ class FfiRuntimeHost {
|
|
|
93
95
|
libraryPath;
|
|
94
96
|
cliEntrypoint;
|
|
95
97
|
environment;
|
|
98
|
+
args;
|
|
96
99
|
lib;
|
|
97
100
|
serverId = 0;
|
|
98
101
|
connectionId = 0;
|
|
@@ -109,21 +112,21 @@ class FfiRuntimeHost {
|
|
|
109
112
|
* the entrypoint directory (the napi-rs `<node-platform>-<arch>` layout, e.g.
|
|
110
113
|
* `linux-x64`). Throws if it cannot be found.
|
|
111
114
|
*/
|
|
112
|
-
static create(cliEntrypoint, prebuildsFolder, environment) {
|
|
115
|
+
static create(cliEntrypoint, prebuildsFolder, environment, args) {
|
|
113
116
|
const fullEntrypoint = resolve(cliEntrypoint);
|
|
114
117
|
const distDir = dirname(fullEntrypoint);
|
|
115
118
|
const libraryPath = join(distDir, "prebuilds", prebuildsFolder, "runtime.node");
|
|
116
119
|
if (!existsSync(libraryPath)) {
|
|
117
120
|
throw new Error(`FFI runtime library not found. Looked for '${libraryPath}'.`);
|
|
118
121
|
}
|
|
119
|
-
return new FfiRuntimeHost(libraryPath, fullEntrypoint, environment);
|
|
122
|
+
return new FfiRuntimeHost(libraryPath, fullEntrypoint, environment, args);
|
|
120
123
|
}
|
|
121
124
|
/**
|
|
122
125
|
* Starts the in-process runtime: spawns the CLI worker via the native host,
|
|
123
126
|
* waits for readiness, and opens the FFI JSON-RPC connection.
|
|
124
127
|
*/
|
|
125
128
|
async start() {
|
|
126
|
-
const argvJson = buildArgvJson(this.cliEntrypoint);
|
|
129
|
+
const argvJson = buildArgvJson(this.cliEntrypoint, this.args);
|
|
127
130
|
const envJson = buildEnvJson(this.environment);
|
|
128
131
|
this.serverId = await new Promise((resolvePromise, rejectPromise) => {
|
|
129
132
|
this.lib.hostStart.async(
|
package/dist/generated/rpc.d.ts
CHANGED
|
@@ -3214,6 +3214,10 @@ export interface DiscoveredCanvas {
|
|
|
3214
3214
|
* Short, single-sentence description shown to the agent in canvas catalogs.
|
|
3215
3215
|
*/
|
|
3216
3216
|
description: string;
|
|
3217
|
+
/**
|
|
3218
|
+
* Host-local PNG path for the canvas icon, when supplied
|
|
3219
|
+
*/
|
|
3220
|
+
icon?: string;
|
|
3217
3221
|
inputSchema?: CanvasJsonSchema;
|
|
3218
3222
|
/**
|
|
3219
3223
|
* Actions the agent or host may invoke on an open instance
|
|
@@ -3269,6 +3273,10 @@ export interface OpenCanvasInstance {
|
|
|
3269
3273
|
* Provider-local canvas identifier
|
|
3270
3274
|
*/
|
|
3271
3275
|
canvasId: string;
|
|
3276
|
+
/**
|
|
3277
|
+
* Host-local PNG path for the canvas icon, when supplied
|
|
3278
|
+
*/
|
|
3279
|
+
icon?: string;
|
|
3272
3280
|
/**
|
|
3273
3281
|
* Rendered title
|
|
3274
3282
|
*/
|
|
@@ -5791,27 +5799,24 @@ export interface McpAppsListToolsResult {
|
|
|
5791
5799
|
}[];
|
|
5792
5800
|
}
|
|
5793
5801
|
/**
|
|
5794
|
-
*
|
|
5795
|
-
* Deprecated/obsolete MCP Apps alias for `McpResourcesReadRequest`; use `session.mcp.resources.read` instead.
|
|
5802
|
+
* MCP server and resource URI to fetch.
|
|
5796
5803
|
*
|
|
5797
5804
|
* This interface was referenced by `_RpcSchemaRoot`'s JSON-Schema
|
|
5798
5805
|
* via the `definition` "McpAppsReadResourceRequest".
|
|
5799
5806
|
*/
|
|
5800
5807
|
/** @experimental */
|
|
5801
|
-
/** @deprecated */
|
|
5802
5808
|
export interface McpAppsReadResourceRequest {
|
|
5803
5809
|
/**
|
|
5804
5810
|
* Name of the MCP server hosting the resource
|
|
5805
5811
|
*/
|
|
5806
5812
|
serverName: string;
|
|
5807
5813
|
/**
|
|
5808
|
-
* Resource URI
|
|
5814
|
+
* Resource URI (typically ui://...)
|
|
5809
5815
|
*/
|
|
5810
5816
|
uri: string;
|
|
5811
5817
|
}
|
|
5812
5818
|
/**
|
|
5813
|
-
*
|
|
5814
|
-
* Deprecated/obsolete MCP Apps alias for `McpResourcesReadResult`; use `session.mcp.resources.read` instead.
|
|
5819
|
+
* Resource contents returned by the MCP server.
|
|
5815
5820
|
*
|
|
5816
5821
|
* This interface was referenced by `_RpcSchemaRoot`'s JSON-Schema
|
|
5817
5822
|
* via the `definition` "McpAppsReadResourceResult".
|
|
@@ -5824,8 +5829,7 @@ export interface McpAppsReadResourceResult {
|
|
|
5824
5829
|
contents: McpAppsResourceContent[];
|
|
5825
5830
|
}
|
|
5826
5831
|
/**
|
|
5827
|
-
*
|
|
5828
|
-
* Deprecated/obsolete MCP Apps alias for `McpResourceContent`; use `session.mcp.resources.read` instead.
|
|
5832
|
+
* MCP Apps resource content with URI, optional MIME type, text or base64 blob, and resource metadata.
|
|
5829
5833
|
*
|
|
5830
5834
|
* This interface was referenced by `_RpcSchemaRoot`'s JSON-Schema
|
|
5831
5835
|
* via the `definition` "McpAppsResourceContent".
|
|
@@ -5833,7 +5837,7 @@ export interface McpAppsReadResourceResult {
|
|
|
5833
5837
|
/** @experimental */
|
|
5834
5838
|
export interface McpAppsResourceContent {
|
|
5835
5839
|
/**
|
|
5836
|
-
* The resource URI
|
|
5840
|
+
* The resource URI (typically ui://...)
|
|
5837
5841
|
*/
|
|
5838
5842
|
uri: string;
|
|
5839
5843
|
/**
|
|
@@ -5849,7 +5853,7 @@ export interface McpAppsResourceContent {
|
|
|
5849
5853
|
*/
|
|
5850
5854
|
blob?: string;
|
|
5851
5855
|
/**
|
|
5852
|
-
* Resource-level metadata
|
|
5856
|
+
* Resource-level metadata (CSP, permissions, etc.)
|
|
5853
5857
|
*/
|
|
5854
5858
|
_meta?: {
|
|
5855
5859
|
[k: string]: unknown | undefined;
|
|
@@ -7107,7 +7111,7 @@ export interface SessionWorkingDirectoryContext {
|
|
|
7107
7111
|
export interface MetadataRecordContextChangeResult {
|
|
7108
7112
|
}
|
|
7109
7113
|
/**
|
|
7110
|
-
* Absolute path to set as the session's new working directory.
|
|
7114
|
+
* Absolute path to set as the session's new working directory. For local sessions the path must be absolute and exist on disk: it is validated before any session state changes, and a failing validation rejects the call with nothing mutated, persisted, or emitted. Remote sessions record the path as-is.
|
|
7111
7115
|
*
|
|
7112
7116
|
* This interface was referenced by `_RpcSchemaRoot`'s JSON-Schema
|
|
7113
7117
|
* via the `definition` "MetadataSetWorkingDirectoryRequest".
|
|
@@ -7120,7 +7124,7 @@ export interface MetadataSetWorkingDirectoryRequest {
|
|
|
7120
7124
|
workingDirectory: string;
|
|
7121
7125
|
}
|
|
7122
7126
|
/**
|
|
7123
|
-
* Update the session's working directory. Used by the host when the user explicitly changes cwd (e.g., the `/cd` slash command). The host is responsible for
|
|
7127
|
+
* Update the session's working directory. Used by the host when the user explicitly changes cwd (e.g., the `/cd` slash command). The host is responsible for any related side-effects (file index, etc.); it does NOT change the process working directory (a session's cwd is per-session, not process-global). For local sessions the runtime validates the target first (an absolute path that exists on disk) and re-bases the permission primary directory; a rejected validation fails the call before anything is mutated, persisted, or emitted. Location-scoped permission rules are then re-keyed to the new directory (best-effort). Remote sessions only record the path.
|
|
7124
7128
|
*
|
|
7125
7129
|
* This interface was referenced by `_RpcSchemaRoot`'s JSON-Schema
|
|
7126
7130
|
* via the `definition` "MetadataSetWorkingDirectoryResult".
|
|
@@ -7305,6 +7309,7 @@ export interface ModelBilling {
|
|
|
7305
7309
|
* Whole-number percentage discount (0-100) applied to usage billed through this model. Populated for the synthetic `auto` model, where requests routed by auto-mode are billed at a reduced rate; absent for concrete models.
|
|
7306
7310
|
*/
|
|
7307
7311
|
discountPercent?: number;
|
|
7312
|
+
promo?: ModelBillingPromo;
|
|
7308
7313
|
}
|
|
7309
7314
|
/**
|
|
7310
7315
|
* Token-level pricing information for this model
|
|
@@ -7389,6 +7394,31 @@ export interface ModelBillingTokenPricesLongContext {
|
|
|
7389
7394
|
*/
|
|
7390
7395
|
maxPromptTokens?: number;
|
|
7391
7396
|
}
|
|
7397
|
+
/**
|
|
7398
|
+
* Active server-driven promotion for a model, including its discount and expiry.
|
|
7399
|
+
*
|
|
7400
|
+
* This interface was referenced by `_RpcSchemaRoot`'s JSON-Schema
|
|
7401
|
+
* via the `definition` "ModelBillingPromo".
|
|
7402
|
+
*/
|
|
7403
|
+
/** @experimental */
|
|
7404
|
+
export interface ModelBillingPromo {
|
|
7405
|
+
/**
|
|
7406
|
+
* Stable identifier for the promotion campaign.
|
|
7407
|
+
*/
|
|
7408
|
+
id?: string;
|
|
7409
|
+
/**
|
|
7410
|
+
* Percentage discount (0-100) applied while the promotion is active. May be fractional.
|
|
7411
|
+
*/
|
|
7412
|
+
discountPercent?: number;
|
|
7413
|
+
/**
|
|
7414
|
+
* UTC ISO 8601 timestamp marking when the promotion ends. Always present: the API only surfaces a promo whose expiry parses and is in the future. Consumers should treat a past value as expired.
|
|
7415
|
+
*/
|
|
7416
|
+
endsAt: string;
|
|
7417
|
+
/**
|
|
7418
|
+
* Human-readable promotion message. Does not include the expiry timestamp; consumers may format endsAt and append it.
|
|
7419
|
+
*/
|
|
7420
|
+
message?: string;
|
|
7421
|
+
}
|
|
7392
7422
|
/**
|
|
7393
7423
|
* Optional capability overrides (vision, tool_calls, reasoning, etc.).
|
|
7394
7424
|
*
|
|
@@ -9272,7 +9302,7 @@ export interface PluginsInstallRequest {
|
|
|
9272
9302
|
workingDirectory?: string;
|
|
9273
9303
|
}
|
|
9274
9304
|
/**
|
|
9275
|
-
* Marketplace source
|
|
9305
|
+
* Marketplace source and optional working directory for relative-path resolution.
|
|
9276
9306
|
*
|
|
9277
9307
|
* This interface was referenced by `_RpcSchemaRoot`'s JSON-Schema
|
|
9278
9308
|
* via the `definition` "PluginsMarketplacesAddRequest".
|
|
@@ -9283,6 +9313,10 @@ export interface PluginsMarketplacesAddRequest {
|
|
|
9283
9313
|
* Marketplace source. Accepts the same forms as the CLI: "owner/repo" or "owner/repo#ref" (GitHub), an http/https/ssh URL (optionally with #ref), a git scp-style URL (user@host:path), or a local path. The marketplace's own name (from its manifest) is used as the registration key.
|
|
9284
9314
|
*/
|
|
9285
9315
|
source: string;
|
|
9316
|
+
/**
|
|
9317
|
+
* Working directory used to resolve relative local paths in `source`. Defaults to the server's current working directory.
|
|
9318
|
+
*/
|
|
9319
|
+
workingDirectory?: string;
|
|
9286
9320
|
}
|
|
9287
9321
|
/**
|
|
9288
9322
|
* Name of the marketplace whose plugin catalog to fetch.
|
|
@@ -10185,7 +10219,7 @@ export interface QueueRemoveMostRecentResult {
|
|
|
10185
10219
|
/** @experimental */
|
|
10186
10220
|
export interface RegisterEventInterestParams {
|
|
10187
10221
|
/**
|
|
10188
|
-
* The event type the consumer wants the runtime to treat as 'observed' for behavior-switching gating. Some runtime code paths inspect whether any consumer is interested in a specific event type and choose a different implementation accordingly (e.g. `mcp.oauth_required`: when interest is registered the runtime delegates OAuth token acquisition to the consumer; when no interest is registered
|
|
10222
|
+
* The event type the consumer wants the runtime to treat as 'observed' for behavior-switching gating. Some runtime code paths inspect whether any consumer is interested in a specific event type and choose a different implementation accordingly (e.g. `mcp.oauth_required`: when interest is registered the runtime delegates interactive OAuth token acquisition to the consumer via `mcp.oauth_required` events; when no interest is registered the runtime still attempts non-interactive reconnect from cached or refreshable tokens, and only marks the server `needs-auth` if usable credentials are unavailable — it does not open a browser or start interactive OAuth without a consumer). SDK clients that long-poll events do NOT automatically appear as listeners to these gating checks — they must explicitly call `registerInterest` for each event type they want the runtime to count as having a consumer. Multiple registrations for the same event type from the same or different consumers are tracked independently and must each be released. See: `mcp.oauth_required`, `sampling.requested`, `auto_mode_switch.requested`, `session_limits_exhausted.requested`, `user_input.requested`, `elicitation.requested`, `command.queued`, `exit_plan_mode.requested`.
|
|
10189
10223
|
*/
|
|
10190
10224
|
eventType: string;
|
|
10191
10225
|
}
|
|
@@ -11826,6 +11860,10 @@ export interface SessionOpenOptions {
|
|
|
11826
11860
|
* Denylist of tool names.
|
|
11827
11861
|
*/
|
|
11828
11862
|
excludedTools?: string[];
|
|
11863
|
+
/**
|
|
11864
|
+
* Built-in subagent names to include in this session. When specified, only these built-ins are available, subject to runtime availability and exclusions. Custom agents with the same name remain available.
|
|
11865
|
+
*/
|
|
11866
|
+
includedBuiltinAgents?: string[];
|
|
11829
11867
|
/**
|
|
11830
11868
|
* Built-in subagent names to exclude from this session. Excluded built-ins are hidden from agent discovery and cannot be dispatched unless a custom agent with the same name is available.
|
|
11831
11869
|
*/
|
|
@@ -12896,6 +12934,10 @@ export interface SessionUpdateOptionsParams {
|
|
|
12896
12934
|
* Denylist of tool names for this session.
|
|
12897
12935
|
*/
|
|
12898
12936
|
excludedTools?: string[];
|
|
12937
|
+
/**
|
|
12938
|
+
* Built-in subagent names to include in this session. When specified, only these built-ins are available, subject to runtime availability and exclusions. Custom agents with the same name remain available. Set to null to remove the allowlist restriction.
|
|
12939
|
+
*/
|
|
12940
|
+
includedBuiltinAgents?: string[] | null;
|
|
12899
12941
|
/**
|
|
12900
12942
|
* Built-in subagent names to exclude from this session. Excluded built-ins are hidden from agent discovery and cannot be dispatched unless a custom agent with the same name is available.
|
|
12901
12943
|
*/
|
|
@@ -13384,7 +13426,7 @@ export interface SkillsLoadDiagnostics {
|
|
|
13384
13426
|
errors: string[];
|
|
13385
13427
|
}
|
|
13386
13428
|
/**
|
|
13387
|
-
* Slash-command invocation result that submits an agent prompt, with display prompt, optional mode, and settings-change flag.
|
|
13429
|
+
* Slash-command invocation result that submits an agent prompt, with display prompt, optional mode, optional user-facing notice, and settings-change flag.
|
|
13388
13430
|
*
|
|
13389
13431
|
* This interface was referenced by `_RpcSchemaRoot`'s JSON-Schema
|
|
13390
13432
|
* via the `definition` "SlashCommandAgentPromptResult".
|
|
@@ -13404,6 +13446,10 @@ export interface SlashCommandAgentPromptResult {
|
|
|
13404
13446
|
*/
|
|
13405
13447
|
displayPrompt: string;
|
|
13406
13448
|
mode?: SessionMode;
|
|
13449
|
+
/**
|
|
13450
|
+
* Optional user-facing notice to show before the prompt is submitted
|
|
13451
|
+
*/
|
|
13452
|
+
notice?: string;
|
|
13407
13453
|
/**
|
|
13408
13454
|
* True when the invocation mutated user runtime settings; consumers caching settings should refresh
|
|
13409
13455
|
*/
|
|
@@ -15435,7 +15481,7 @@ export declare function createServerRpc(connection: MessageConnection): {
|
|
|
15435
15481
|
/**
|
|
15436
15482
|
* Registers a new marketplace from a source (owner/repo, URL, or local path).
|
|
15437
15483
|
*
|
|
15438
|
-
* @param params Marketplace source
|
|
15484
|
+
* @param params Marketplace source and optional working directory for relative-path resolution.
|
|
15439
15485
|
*
|
|
15440
15486
|
* @returns Result of registering a new marketplace.
|
|
15441
15487
|
*/
|
|
@@ -16387,13 +16433,11 @@ export declare function createSessionRpc(connection: MessageConnection, sessionI
|
|
|
16387
16433
|
/** @experimental */
|
|
16388
16434
|
apps: {
|
|
16389
16435
|
/**
|
|
16390
|
-
*
|
|
16391
|
-
*
|
|
16392
|
-
* @param params Deprecated/obsolete MCP Apps alias for `McpResourcesReadRequest`; use `session.mcp.resources.read` instead.
|
|
16436
|
+
* Fetch an MCP resource (typically a `ui://` MCP App bundle, per SEP-1865) from a connected server. Requires the `mcp-apps` session capability.
|
|
16393
16437
|
*
|
|
16394
|
-
* @
|
|
16438
|
+
* @param params MCP server and resource URI to fetch.
|
|
16395
16439
|
*
|
|
16396
|
-
* @
|
|
16440
|
+
* @returns Resource contents returned by the MCP server.
|
|
16397
16441
|
*/
|
|
16398
16442
|
readResource: (params: McpAppsReadResourceRequest) => Promise<McpAppsReadResourceResult>;
|
|
16399
16443
|
/**
|
|
@@ -16960,11 +17004,11 @@ export declare function createSessionRpc(connection: MessageConnection, sessionI
|
|
|
16960
17004
|
*/
|
|
16961
17005
|
recordContextChange: (params: MetadataRecordContextChangeRequest) => Promise<MetadataRecordContextChangeResult>;
|
|
16962
17006
|
/**
|
|
16963
|
-
* Updates the session's
|
|
17007
|
+
* Updates the session's working directory. For local sessions the target is validated first (an absolute path that exists on disk) and the permission primary directory is re-based; a rejected validation fails the call before any session state changes.
|
|
16964
17008
|
*
|
|
16965
|
-
* @param params Absolute path to set as the session's new working directory.
|
|
17009
|
+
* @param params Absolute path to set as the session's new working directory. For local sessions the path must be absolute and exist on disk: it is validated before any session state changes, and a failing validation rejects the call with nothing mutated, persisted, or emitted. Remote sessions record the path as-is.
|
|
16966
17010
|
*
|
|
16967
|
-
* @returns Update the session's working directory. Used by the host when the user explicitly changes cwd (e.g., the `/cd` slash command). The host is responsible for
|
|
17011
|
+
* @returns Update the session's working directory. Used by the host when the user explicitly changes cwd (e.g., the `/cd` slash command). The host is responsible for any related side-effects (file index, etc.); it does NOT change the process working directory (a session's cwd is per-session, not process-global). For local sessions the runtime validates the target first (an absolute path that exists on disk) and re-bases the permission primary directory; a rejected validation fails the call before anything is mutated, persisted, or emitted. Location-scoped permission rules are then re-keyed to the new directory (best-effort). Remote sessions only record the path.
|
|
16968
17012
|
*/
|
|
16969
17013
|
setWorkingDirectory: (params: MetadataSetWorkingDirectoryRequest) => Promise<MetadataSetWorkingDirectoryResult>;
|
|
16970
17014
|
/**
|
package/dist/generated/rpc.js
CHANGED
|
@@ -195,7 +195,7 @@ function createServerRpc(connection) {
|
|
|
195
195
|
/**
|
|
196
196
|
* Registers a new marketplace from a source (owner/repo, URL, or local path).
|
|
197
197
|
*
|
|
198
|
-
* @param params Marketplace source
|
|
198
|
+
* @param params Marketplace source and optional working directory for relative-path resolution.
|
|
199
199
|
*
|
|
200
200
|
* @returns Result of registering a new marketplace.
|
|
201
201
|
*/
|
|
@@ -1203,13 +1203,11 @@ function createSessionRpc(connection, sessionId) {
|
|
|
1203
1203
|
/** @experimental */
|
|
1204
1204
|
apps: {
|
|
1205
1205
|
/**
|
|
1206
|
-
*
|
|
1206
|
+
* Fetch an MCP resource (typically a `ui://` MCP App bundle, per SEP-1865) from a connected server. Requires the `mcp-apps` session capability.
|
|
1207
1207
|
*
|
|
1208
|
-
* @param params
|
|
1209
|
-
*
|
|
1210
|
-
* @returns Deprecated/obsolete MCP Apps alias for `McpResourcesReadResult`; use `session.mcp.resources.read` instead.
|
|
1208
|
+
* @param params MCP server and resource URI to fetch.
|
|
1211
1209
|
*
|
|
1212
|
-
* @
|
|
1210
|
+
* @returns Resource contents returned by the MCP server.
|
|
1213
1211
|
*/
|
|
1214
1212
|
readResource: async (params) => connection.sendRequest("session.mcp.apps.readResource", { sessionId, ...params }),
|
|
1215
1213
|
/**
|
|
@@ -1776,11 +1774,11 @@ function createSessionRpc(connection, sessionId) {
|
|
|
1776
1774
|
*/
|
|
1777
1775
|
recordContextChange: async (params) => connection.sendRequest("session.metadata.recordContextChange", { sessionId, ...params }),
|
|
1778
1776
|
/**
|
|
1779
|
-
* Updates the session's
|
|
1777
|
+
* Updates the session's working directory. For local sessions the target is validated first (an absolute path that exists on disk) and the permission primary directory is re-based; a rejected validation fails the call before any session state changes.
|
|
1780
1778
|
*
|
|
1781
|
-
* @param params Absolute path to set as the session's new working directory.
|
|
1779
|
+
* @param params Absolute path to set as the session's new working directory. For local sessions the path must be absolute and exist on disk: it is validated before any session state changes, and a failing validation rejects the call with nothing mutated, persisted, or emitted. Remote sessions record the path as-is.
|
|
1782
1780
|
*
|
|
1783
|
-
* @returns Update the session's working directory. Used by the host when the user explicitly changes cwd (e.g., the `/cd` slash command). The host is responsible for
|
|
1781
|
+
* @returns Update the session's working directory. Used by the host when the user explicitly changes cwd (e.g., the `/cd` slash command). The host is responsible for any related side-effects (file index, etc.); it does NOT change the process working directory (a session's cwd is per-session, not process-global). For local sessions the runtime validates the target first (an absolute path that exists on disk) and re-bases the permission primary directory; a rejected validation fails the call before anything is mutated, persisted, or emitted. Location-scoped permission rules are then re-keyed to the new directory (best-effort). Remote sessions only record the path.
|
|
1784
1782
|
*/
|
|
1785
1783
|
setWorkingDirectory: async (params) => connection.sendRequest("session.metadata.setWorkingDirectory", { sessionId, ...params }),
|
|
1786
1784
|
/**
|
|
@@ -4168,6 +4168,14 @@ export interface ToolExecutionCompleteData {
|
|
|
4168
4168
|
* Whether this tool call was explicitly requested by the user rather than the assistant
|
|
4169
4169
|
*/
|
|
4170
4170
|
isUserRequested?: boolean;
|
|
4171
|
+
/**
|
|
4172
|
+
* FIDES IFC label projected from tool ingress metadata (MCP `CallToolResult._meta` or synthesized built-in ingress labels). Persisted as `{ ifc: ... }` so the label survives session resume, including model-visible failure results. Experimental.
|
|
4173
|
+
*
|
|
4174
|
+
* @experimental
|
|
4175
|
+
*/
|
|
4176
|
+
mcpMeta?: {
|
|
4177
|
+
[k: string]: unknown | undefined;
|
|
4178
|
+
};
|
|
4171
4179
|
/**
|
|
4172
4180
|
* Model identifier that generated this tool call
|
|
4173
4181
|
*/
|
|
@@ -4243,6 +4251,14 @@ export interface ToolExecutionCompleteResult {
|
|
|
4243
4251
|
* Full detailed tool result for UI/timeline display, preserving complete content such as diffs. Falls back to content when absent.
|
|
4244
4252
|
*/
|
|
4245
4253
|
detailedContent?: string;
|
|
4254
|
+
/**
|
|
4255
|
+
* FIDES IFC label projected from tool ingress metadata (MCP `CallToolResult._meta` or synthesized built-in ingress labels) — persisted as `{ ifc: ... }` (only the `ifc` key, not the whole `_meta`). Persisted so the FIDES IFC label survives session resume: the engine rehydrates accumulated taint by replaying these on load. Populated for ingress sources when FIDES IFC is on. Experimental.
|
|
4256
|
+
*
|
|
4257
|
+
* @experimental
|
|
4258
|
+
*/
|
|
4259
|
+
mcpMeta?: {
|
|
4260
|
+
[k: string]: unknown | undefined;
|
|
4261
|
+
};
|
|
4246
4262
|
/**
|
|
4247
4263
|
* Structured content (arbitrary JSON) returned verbatim by the MCP tool
|
|
4248
4264
|
*/
|
|
@@ -8268,7 +8284,7 @@ export interface ExtensionsLoadedExtension {
|
|
|
8268
8284
|
status: ExtensionsLoadedExtensionStatus;
|
|
8269
8285
|
}
|
|
8270
8286
|
/**
|
|
8271
|
-
* Session event "session.canvas.opened". Payload of `session.canvas.opened` with canvas instance and provider IDs plus optional title, status, URL, and input.
|
|
8287
|
+
* Session event "session.canvas.opened". Payload of `session.canvas.opened` with canvas instance and provider IDs plus optional icon, title, status, URL, and input.
|
|
8272
8288
|
*/
|
|
8273
8289
|
/** @experimental */
|
|
8274
8290
|
export interface CanvasOpenedEvent {
|
|
@@ -8299,7 +8315,7 @@ export interface CanvasOpenedEvent {
|
|
|
8299
8315
|
type: "session.canvas.opened";
|
|
8300
8316
|
}
|
|
8301
8317
|
/**
|
|
8302
|
-
* Payload of `session.canvas.opened` with canvas instance and provider IDs plus optional title, status, URL, and input.
|
|
8318
|
+
* Payload of `session.canvas.opened` with canvas instance and provider IDs plus optional icon, title, status, URL, and input.
|
|
8303
8319
|
*/
|
|
8304
8320
|
/** @experimental */
|
|
8305
8321
|
export interface CanvasOpenedData {
|
|
@@ -8315,6 +8331,10 @@ export interface CanvasOpenedData {
|
|
|
8315
8331
|
* Owning extension display name, when available
|
|
8316
8332
|
*/
|
|
8317
8333
|
extensionName?: string;
|
|
8334
|
+
/**
|
|
8335
|
+
* Host-local PNG path for the canvas icon, when supplied
|
|
8336
|
+
*/
|
|
8337
|
+
icon?: string;
|
|
8318
8338
|
/**
|
|
8319
8339
|
* Input supplied when the instance was opened
|
|
8320
8340
|
*/
|
|
@@ -8408,6 +8428,10 @@ export interface CanvasRegistryChangedCanvas {
|
|
|
8408
8428
|
* Owning extension display name, when available
|
|
8409
8429
|
*/
|
|
8410
8430
|
extensionName?: string;
|
|
8431
|
+
/**
|
|
8432
|
+
* Host-local PNG path for the canvas icon, when supplied
|
|
8433
|
+
*/
|
|
8434
|
+
icon?: string;
|
|
8411
8435
|
/**
|
|
8412
8436
|
* JSON Schema for canvas open input
|
|
8413
8437
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -10,4 +10,4 @@ export { CopilotSession, type AssistantMessageEvent } from "./session.js";
|
|
|
10
10
|
export { Canvas, CanvasError, createCanvas, type CanvasAction, type CanvasDeclaration, type CanvasHostContext, type CanvasHostContextCapabilities, type CanvasJsonSchema, type CanvasOptions, } from "./canvas.js";
|
|
11
11
|
export { defineTool, approveAll, convertMcpCallToolResult, createSessionFsAdapter, CopilotRequestHandler, CopilotWebSocketHandler, CopilotWebSocketCloseStatus, CopilotWebSocketForwarder, SYSTEM_MESSAGE_SECTIONS, } from "./types.js";
|
|
12
12
|
export type * from "./generated/session-events.js";
|
|
13
|
-
export type { CommandContext, CommandDefinition, CommandHandler, CanvasProviderIdentity, CloudSessionOptions, CloudSessionRepository, AutoModeSwitchHandler, AutoModeSwitchRequest, AutoModeSwitchResponse, CopilotClientMode, CopilotClientOptions, StdioRuntimeConnection, InProcessRuntimeConnection, TcpRuntimeConnection, UriRuntimeConnection, CustomAgentConfig, ElicitationFieldValue, ElicitationHandler, ElicitationParams, ElicitationContext, ElicitationResult, ElicitationSchema, ElicitationSchemaField, ExitPlanModeHandler, ExitPlanModeRequest, ExitPlanModeResult, ExtensionInfo, ForegroundSessionInfo, GetAuthStatusResponse, GetStatusResponse, GitHubTelemetryNotification, GitHubTelemetryEvent, GitHubTelemetryClientInfo, InfiniteSessionConfig, LargeToolOutputConfig, MemoryConfiguration, UiInputOptions, MCPStdioServerConfig, MCPHTTPServerConfig, MCPServerConfig, DefaultAgentConfig, BearerTokenProvider, MessageOptions, ModelBilling, ModelBillingTokenPrices, ModelBillingTokenPricesLongContext, CapiSessionOptions, ModelCapabilities, ModelCapabilitiesOverride, ModelInfo, ModelPolicy, NamedProviderConfig, PermissionHandler, PermissionRequest, PermissionRequestResult, ProviderConfig, ProviderModelConfig, ProviderTokenArgs, RemoteSessionMode, ResumeSessionConfig, SectionOverride, SectionOverrideAction, SectionTransformFn, SessionCapabilities, SessionConfig, SessionConfigBase, SessionEvent, SessionEventHandler, SessionEventPayload, SessionEventType, SessionLifecycleEvent, SessionLifecycleEventMetadata, SessionLifecycleEventType, SessionLifecycleHandler, SessionCreatedEvent, SessionDeletedEvent, SessionUpdatedEvent, SessionForegroundEvent, SessionBackgroundEvent, SessionContext, SessionListFilter, SessionMetadata, SessionUiApi, SessionFsConfig, SessionFsProvider, SessionFsFileInfo, SessionFsSqliteQueryResult, SessionFsSqliteQueryType, SessionFsSqliteProvider, CopilotRequestContext, SystemMessageAppendConfig, SystemMessageConfig, SystemMessageCustomizeConfig, SystemMessageReplaceConfig, SystemMessageSection, TelemetryConfig, TraceContext, TraceContextProvider, Tool, ToolHandler, ToolInvocation, ToolTelemetry, ToolResultObject, TypedSessionEventHandler, TypedSessionLifecycleHandler, ZodSchema, } from "./types.js";
|
|
13
|
+
export type { CommandContext, CommandDefinition, CommandHandler, CanvasProviderIdentity, CloudSessionOptions, CloudSessionRepository, AutoModeSwitchHandler, AutoModeSwitchRequest, AutoModeSwitchResponse, CopilotClientMode, CopilotClientOptions, StdioRuntimeConnection, InProcessRuntimeConnection, TcpRuntimeConnection, UriRuntimeConnection, ChildProcessRuntimeConnection, CustomAgentConfig, ElicitationFieldValue, ElicitationHandler, ElicitationParams, ElicitationContext, ElicitationResult, ElicitationSchema, ElicitationSchemaField, ExitPlanModeHandler, ExitPlanModeRequest, ExitPlanModeResult, ExtensionInfo, ForegroundSessionInfo, GetAuthStatusResponse, GetStatusResponse, GitHubTelemetryNotification, GitHubTelemetryEvent, GitHubTelemetryClientInfo, InfiniteSessionConfig, LargeToolOutputConfig, MemoryConfiguration, UiInputOptions, MCPStdioServerConfig, MCPHTTPServerConfig, MCPServerConfig, DefaultAgentConfig, BearerTokenProvider, MessageOptions, ModelBilling, ModelBillingTokenPrices, ModelBillingTokenPricesLongContext, CapiSessionOptions, ModelCapabilities, ModelCapabilitiesOverride, ModelInfo, ModelPolicy, NamedProviderConfig, PermissionHandler, PermissionRequest, PermissionRequestResult, ProviderConfig, ProviderModelConfig, ProviderTokenArgs, RemoteSessionMode, ResumeSessionConfig, SectionOverride, SectionOverrideAction, SectionTransformFn, SessionCapabilities, SessionConfig, SessionConfigBase, SessionEvent, SessionEventHandler, SessionEventPayload, SessionEventType, SessionLifecycleEvent, SessionLifecycleEventMetadata, SessionLifecycleEventType, SessionLifecycleHandler, SessionCreatedEvent, SessionDeletedEvent, SessionUpdatedEvent, SessionForegroundEvent, SessionBackgroundEvent, SessionContext, SessionListFilter, SessionMetadata, SessionUiApi, SessionFsConfig, SessionFsProvider, SessionFsFileInfo, SessionFsSqliteQueryResult, SessionFsSqliteQueryType, SessionFsSqliteProvider, CopilotRequestContext, SystemMessageAppendConfig, SystemMessageConfig, SystemMessageCustomizeConfig, SystemMessageReplaceConfig, SystemMessageSection, TelemetryConfig, TraceContext, TraceContextProvider, Tool, ToolHandler, ToolInvocation, CurrentToolMetadata, ToolTelemetry, ToolResultObject, ToolSearchConfig, TypedSessionEventHandler, TypedSessionLifecycleHandler, ZodSchema, } from "./types.js";
|
package/dist/session.d.ts
CHANGED
|
@@ -30,6 +30,11 @@ export type AssistantMessageEvent = Extract<SessionEvent, {
|
|
|
30
30
|
* await session.disconnect();
|
|
31
31
|
* ```
|
|
32
32
|
*/
|
|
33
|
+
/**
|
|
34
|
+
* Fixed name of the runtime's built-in tool-search tool. A client can replace
|
|
35
|
+
* its behavior by registering a {@link Tool} with this exact name and
|
|
36
|
+
* `overridesBuiltInTool: true`.
|
|
37
|
+
*/
|
|
33
38
|
export declare class CopilotSession {
|
|
34
39
|
readonly sessionId: string;
|
|
35
40
|
private connection;
|
|
@@ -262,7 +267,7 @@ export declare class CopilotSession {
|
|
|
262
267
|
*
|
|
263
268
|
* @example
|
|
264
269
|
* ```typescript
|
|
265
|
-
* await session.setModel("gpt-4
|
|
270
|
+
* await session.setModel("gpt-5.4");
|
|
266
271
|
* await session.setModel("claude-sonnet-4.6", { reasoningEffort: "high" });
|
|
267
272
|
* ```
|
|
268
273
|
*/
|
package/dist/session.js
CHANGED
|
@@ -17,6 +17,7 @@ function isOpenCanvasInstance(value) {
|
|
|
17
17
|
const instance = value;
|
|
18
18
|
return typeof instance.instanceId === "string" && instance.instanceId.length > 0 && typeof instance.extensionId === "string" && instance.extensionId.length > 0 && typeof instance.canvasId === "string" && instance.canvasId.length > 0;
|
|
19
19
|
}
|
|
20
|
+
const TOOL_SEARCH_TOOL_NAME = "tool_search_tool";
|
|
20
21
|
class CopilotSession {
|
|
21
22
|
/**
|
|
22
23
|
* Creates a new CopilotSession instance.
|
|
@@ -329,11 +330,21 @@ class CopilotSession {
|
|
|
329
330
|
*/
|
|
330
331
|
async _executeToolAndRespond(requestId, toolName, toolCallId, args, handler, traceparent, tracestate) {
|
|
331
332
|
try {
|
|
333
|
+
let availableTools;
|
|
334
|
+
if (toolName === TOOL_SEARCH_TOOL_NAME) {
|
|
335
|
+
try {
|
|
336
|
+
const metadata = await this.rpc.tools.getCurrentMetadata();
|
|
337
|
+
availableTools = metadata.tools ?? void 0;
|
|
338
|
+
} catch {
|
|
339
|
+
availableTools = void 0;
|
|
340
|
+
}
|
|
341
|
+
}
|
|
332
342
|
const rawResult = await handler(args, {
|
|
333
343
|
sessionId: this.sessionId,
|
|
334
344
|
toolCallId,
|
|
335
345
|
toolName,
|
|
336
346
|
arguments: args,
|
|
347
|
+
availableTools,
|
|
337
348
|
traceparent,
|
|
338
349
|
tracestate
|
|
339
350
|
});
|
|
@@ -986,7 +997,7 @@ class CopilotSession {
|
|
|
986
997
|
*
|
|
987
998
|
* @example
|
|
988
999
|
* ```typescript
|
|
989
|
-
* await session.setModel("gpt-4
|
|
1000
|
+
* await session.setModel("gpt-5.4");
|
|
990
1001
|
* await session.setModel("claude-sonnet-4.6", { reasoningEffort: "high" });
|
|
991
1002
|
* ```
|
|
992
1003
|
*/
|
package/dist/types.d.ts
CHANGED
|
@@ -6,9 +6,10 @@ import type { SessionFsProvider } from "./sessionFsProvider.js";
|
|
|
6
6
|
import type { CopilotRequestHandler } from "./copilotRequestHandler.js";
|
|
7
7
|
import type { ReasoningSummary, SessionLimitsConfig, SessionEvent as GeneratedSessionEvent } from "./generated/session-events.js";
|
|
8
8
|
import type { CopilotSession } from "./session.js";
|
|
9
|
-
import type { GitHubTelemetryNotification, ModelBillingTokenPrices, OpenCanvasInstance, RemoteSessionMode } from "./generated/rpc.js";
|
|
9
|
+
import type { GitHubTelemetryNotification, ModelBillingTokenPrices, OpenCanvasInstance, RemoteSessionMode, CurrentToolMetadata } from "./generated/rpc.js";
|
|
10
10
|
import type { ToolSet } from "./toolSet.js";
|
|
11
11
|
export type { RemoteSessionMode } from "./generated/rpc.js";
|
|
12
|
+
export type { CurrentToolMetadata } from "./generated/rpc.js";
|
|
12
13
|
export type { GitHubTelemetryNotification, GitHubTelemetryEvent, GitHubTelemetryClientInfo, } from "./generated/rpc.js";
|
|
13
14
|
export type { ModelBillingTokenPrices, ModelBillingTokenPricesLongContext, } from "./generated/rpc.js";
|
|
14
15
|
export type SessionEvent = GeneratedSessionEvent;
|
|
@@ -65,15 +66,28 @@ export interface TelemetryConfig {
|
|
|
65
66
|
*/
|
|
66
67
|
export type RuntimeConnection = StdioRuntimeConnection | InProcessRuntimeConnection | TcpRuntimeConnection | UriRuntimeConnection;
|
|
67
68
|
/**
|
|
68
|
-
*
|
|
69
|
-
*
|
|
69
|
+
* Shared shape for the transports that spawn a runtime **child process**
|
|
70
|
+
* ({@link StdioRuntimeConnection} and {@link TcpRuntimeConnection}).
|
|
70
71
|
*/
|
|
71
|
-
export interface
|
|
72
|
-
readonly kind: "stdio";
|
|
72
|
+
export interface ChildProcessRuntimeConnection {
|
|
73
73
|
/** Path to the runtime executable. When omitted, the bundled runtime is used. */
|
|
74
74
|
readonly path?: string;
|
|
75
75
|
/** Extra command-line arguments to pass to the runtime process. */
|
|
76
76
|
readonly args?: readonly string[];
|
|
77
|
+
/**
|
|
78
|
+
* Environment variables for the spawned runtime child process, replacing the
|
|
79
|
+
* inherited environment. Cannot be combined with
|
|
80
|
+
* {@link CopilotClientOptions.env}; setting both throws when the client is
|
|
81
|
+
* constructed. When omitted, the client-level env (or `process.env`) is used.
|
|
82
|
+
*/
|
|
83
|
+
readonly env?: Record<string, string>;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Spawns a runtime child process and communicates over its stdin/stdout.
|
|
87
|
+
* This is the default if no {@link CopilotClientOptions.connection} is set.
|
|
88
|
+
*/
|
|
89
|
+
export interface StdioRuntimeConnection extends ChildProcessRuntimeConnection {
|
|
90
|
+
readonly kind: "stdio";
|
|
77
91
|
}
|
|
78
92
|
/**
|
|
79
93
|
* Hosts the runtime in-process by loading the native runtime library and speaking
|
|
@@ -97,7 +111,7 @@ export interface InProcessRuntimeConnection {
|
|
|
97
111
|
/**
|
|
98
112
|
* Spawns a runtime child process that listens on a TCP socket and connects to it.
|
|
99
113
|
*/
|
|
100
|
-
export interface TcpRuntimeConnection {
|
|
114
|
+
export interface TcpRuntimeConnection extends ChildProcessRuntimeConnection {
|
|
101
115
|
readonly kind: "tcp";
|
|
102
116
|
/**
|
|
103
117
|
* TCP port to listen on. `0` (the default) auto-allocates a free port.
|
|
@@ -110,10 +124,6 @@ export interface TcpRuntimeConnection {
|
|
|
110
124
|
* loopback listener is safe by default.
|
|
111
125
|
*/
|
|
112
126
|
readonly connectionToken?: string;
|
|
113
|
-
/** Path to the runtime executable. When omitted, the bundled runtime is used. */
|
|
114
|
-
readonly path?: string;
|
|
115
|
-
/** Extra command-line arguments to pass to the runtime process. */
|
|
116
|
-
readonly args?: readonly string[];
|
|
117
127
|
}
|
|
118
128
|
/**
|
|
119
129
|
* Connects to an already-running runtime at the specified URL. The SDK does not
|
|
@@ -138,6 +148,7 @@ export declare const RuntimeConnection: {
|
|
|
138
148
|
readonly forStdio: (opts?: {
|
|
139
149
|
path?: string;
|
|
140
150
|
args?: readonly string[];
|
|
151
|
+
env?: Record<string, string>;
|
|
141
152
|
}) => StdioRuntimeConnection;
|
|
142
153
|
/**
|
|
143
154
|
* Spawn a runtime child process that listens on a TCP socket and connect to it.
|
|
@@ -147,6 +158,7 @@ export declare const RuntimeConnection: {
|
|
|
147
158
|
connectionToken?: string;
|
|
148
159
|
path?: string;
|
|
149
160
|
args?: readonly string[];
|
|
161
|
+
env?: Record<string, string>;
|
|
150
162
|
}) => TcpRuntimeConnection;
|
|
151
163
|
/**
|
|
152
164
|
* Connect to an already-running runtime at the given URL. The SDK does not
|
|
@@ -346,6 +358,10 @@ export type ToolResultObject = {
|
|
|
346
358
|
error?: string;
|
|
347
359
|
sessionLog?: string;
|
|
348
360
|
toolTelemetry?: ToolTelemetry;
|
|
361
|
+
/**
|
|
362
|
+
* Names of tools returned by a tool-search tool.
|
|
363
|
+
*/
|
|
364
|
+
toolReferences?: string[];
|
|
349
365
|
};
|
|
350
366
|
export type ToolResult = string | ToolResultObject;
|
|
351
367
|
/**
|
|
@@ -401,6 +417,14 @@ export interface ToolInvocation {
|
|
|
401
417
|
toolCallId: string;
|
|
402
418
|
toolName: string;
|
|
403
419
|
arguments: unknown;
|
|
420
|
+
/**
|
|
421
|
+
* Snapshot of the session's currently initialized tools. Populated by the
|
|
422
|
+
* SDK only when this invocation targets the built-in tool-search tool
|
|
423
|
+
* (`tool_search_tool`), so a tool-search override can rank/filter the live
|
|
424
|
+
* catalog — including MCP tools configured in settings — without issuing its
|
|
425
|
+
* own RPC. `undefined` for every other tool invocation.
|
|
426
|
+
*/
|
|
427
|
+
availableTools?: CurrentToolMetadata[];
|
|
404
428
|
/** W3C Trace Context traceparent from the CLI's execute_tool span. */
|
|
405
429
|
traceparent?: string;
|
|
406
430
|
/** W3C Trace Context tracestate from the CLI's execute_tool span. */
|
|
@@ -460,6 +484,33 @@ export declare function defineTool<T = unknown>(name: string, config: {
|
|
|
460
484
|
skipPermission?: boolean;
|
|
461
485
|
defer?: "auto" | "never";
|
|
462
486
|
}): Tool<T>;
|
|
487
|
+
/**
|
|
488
|
+
* SDK-supplied override for the runtime's built-in tool-search behavior.
|
|
489
|
+
*
|
|
490
|
+
* Tool search lets the model discover tools on demand instead of loading every
|
|
491
|
+
* tool definition up front. When the total tool count exceeds the deferral
|
|
492
|
+
* threshold, MCP and external tools are marked as deferred and surfaced through
|
|
493
|
+
* the built-in `tool_search_tool`.
|
|
494
|
+
*
|
|
495
|
+
* To override the tool-search tool's model-facing definition and/or its
|
|
496
|
+
* execution, register a {@link Tool} named `tool_search_tool` with
|
|
497
|
+
* `overridesBuiltInTool: true`. To customize the in-prompt tool-search
|
|
498
|
+
* guidance, use the `tool_instructions` section of {@link SystemMessageConfig}
|
|
499
|
+
* in `"customize"` mode.
|
|
500
|
+
*/
|
|
501
|
+
export interface ToolSearchConfig {
|
|
502
|
+
/**
|
|
503
|
+
* Toggle to enable/disable tool search. When disabled, all tools are pre-loaded
|
|
504
|
+
* and the model's active tool set is not deferred.
|
|
505
|
+
*/
|
|
506
|
+
enabled?: boolean;
|
|
507
|
+
/**
|
|
508
|
+
* Overrides the total tool count at which MCP and external tools are
|
|
509
|
+
* automatically deferred behind tool search. Defaults to the built-in
|
|
510
|
+
* threshold (30) when omitted.
|
|
511
|
+
*/
|
|
512
|
+
deferThreshold?: number;
|
|
513
|
+
}
|
|
463
514
|
/**
|
|
464
515
|
* Context passed to a command handler when a command is executed.
|
|
465
516
|
*/
|
|
@@ -1553,6 +1604,14 @@ export interface SessionConfigBase {
|
|
|
1553
1604
|
* Controls how the system prompt is constructed
|
|
1554
1605
|
*/
|
|
1555
1606
|
systemMessage?: SystemMessageConfig;
|
|
1607
|
+
/**
|
|
1608
|
+
* Override for the runtime's built-in tool-search behavior.
|
|
1609
|
+
*
|
|
1610
|
+
* To also override the tool-search tool's implementation, register a
|
|
1611
|
+
* {@link Tool} named `tool_search_tool` with `overridesBuiltInTool: true` in
|
|
1612
|
+
* {@link SessionConfigBase.tools}.
|
|
1613
|
+
*/
|
|
1614
|
+
toolSearch?: ToolSearchConfig;
|
|
1556
1615
|
/**
|
|
1557
1616
|
* List of tool names to allow. When specified, only these tools will be available.
|
|
1558
1617
|
*
|
package/dist/types.js
CHANGED
|
@@ -11,7 +11,7 @@ const RuntimeConnection = {
|
|
|
11
11
|
* This is the default if no {@link CopilotClientOptions.connection} is set.
|
|
12
12
|
*/
|
|
13
13
|
forStdio(opts = {}) {
|
|
14
|
-
return { kind: "stdio", path: opts.path, args: opts.args };
|
|
14
|
+
return { kind: "stdio", path: opts.path, args: opts.args, env: opts.env };
|
|
15
15
|
},
|
|
16
16
|
/**
|
|
17
17
|
* Spawn a runtime child process that listens on a TCP socket and connect to it.
|
|
@@ -22,7 +22,8 @@ const RuntimeConnection = {
|
|
|
22
22
|
port: opts.port,
|
|
23
23
|
connectionToken: opts.connectionToken,
|
|
24
24
|
path: opts.path,
|
|
25
|
-
args: opts.args
|
|
25
|
+
args: opts.args,
|
|
26
|
+
env: opts.env
|
|
26
27
|
};
|
|
27
28
|
},
|
|
28
29
|
/**
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"type": "git",
|
|
5
5
|
"url": "https://github.com/github/copilot-sdk.git"
|
|
6
6
|
},
|
|
7
|
-
"version": "1.0.7-preview.
|
|
7
|
+
"version": "1.0.7-preview.3",
|
|
8
8
|
"description": "TypeScript SDK for programmatic control of GitHub Copilot CLI via JSON-RPC",
|
|
9
9
|
"main": "./dist/cjs/index.js",
|
|
10
10
|
"types": "./dist/index.d.ts",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"author": "GitHub",
|
|
57
57
|
"license": "MIT",
|
|
58
58
|
"dependencies": {
|
|
59
|
-
"@github/copilot": "^1.0.
|
|
59
|
+
"@github/copilot": "^1.0.71-2",
|
|
60
60
|
"koffi": "^3.1.0",
|
|
61
61
|
"vscode-jsonrpc": "^8.2.1",
|
|
62
62
|
"zod": "^4.3.6"
|