@microsoft/copilot-sdk 2.0.0-preview.0 → 2.0.0-preview.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +525 -374
- package/dist/cjs/cliVersion.js +1 -1
- package/dist/cjs/client.js +814 -559
- package/dist/cjs/extension.js +11 -9
- package/dist/cjs/generated/rpc.js +7 -7
- package/dist/cjs/sdkProtocolVersion.js +1 -1
- package/dist/cjs/session.js +2 -2
- package/dist/cjs/toolSet.js +1 -1
- package/dist/cjs/types.js +41 -13
- package/dist/cliVersion.d.ts +1 -1
- package/dist/cliVersion.js +1 -1
- package/dist/client.d.ts +46 -45
- package/dist/client.js +825 -562
- package/dist/extension.d.ts +7 -5
- package/dist/extension.js +11 -9
- package/dist/generated/rpc.d.ts +833 -436
- package/dist/generated/rpc.js +7 -7
- package/dist/generated/session-events.d.ts +16 -0
- package/dist/host.d.ts +7 -3
- package/dist/index.d.ts +2 -1
- package/dist/sdkProtocolVersion.d.ts +1 -1
- package/dist/sdkProtocolVersion.js +1 -1
- package/dist/session.d.ts +6 -6
- package/dist/session.js +2 -2
- package/dist/toolSet.d.ts +6 -5
- package/dist/toolSet.js +1 -1
- package/dist/types.d.ts +1252 -1293
- package/dist/types.js +41 -13
- package/docs/examples.md +1 -1
- package/package.json +12 -12
package/dist/cjs/extension.js
CHANGED
|
@@ -42,14 +42,10 @@ async function joinSession(config = {}) {
|
|
|
42
42
|
mode: "coding-agent",
|
|
43
43
|
_internalConnection: { kind: "parent-process" }
|
|
44
44
|
});
|
|
45
|
-
const {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
workflows,
|
|
50
|
-
requestedEnvironmentVariables,
|
|
51
|
-
...rest
|
|
52
|
-
} = config;
|
|
45
|
+
const { workflows, requestedEnvironmentVariables, ...rest } = config;
|
|
46
|
+
const { sdkPath: _stripped, ...extensions } = config.extensions ?? {};
|
|
47
|
+
const { provider: _strippedSkillProvider, ...skills } = config.skills ?? {};
|
|
48
|
+
const { imageGeneration: _strippedImageGeneration, ...tools } = config.tools ?? {};
|
|
53
49
|
void _stripped;
|
|
54
50
|
void _strippedSkillProvider;
|
|
55
51
|
void _strippedImageGeneration;
|
|
@@ -57,7 +53,13 @@ async function joinSession(config = {}) {
|
|
|
57
53
|
sessionId,
|
|
58
54
|
{
|
|
59
55
|
...rest,
|
|
60
|
-
|
|
56
|
+
extensions,
|
|
57
|
+
skills,
|
|
58
|
+
tools,
|
|
59
|
+
permissions: {
|
|
60
|
+
...rest.permissions,
|
|
61
|
+
onRequest: config.permissions?.onRequest ?? import_types.defaultJoinSessionPermissionHandler
|
|
62
|
+
},
|
|
61
63
|
suppressResumeEvent: config.suppressResumeEvent ?? true
|
|
62
64
|
},
|
|
63
65
|
{ workflows },
|
|
@@ -1596,7 +1596,7 @@ function createInternalServerRpc(connection) {
|
|
|
1596
1596
|
*/
|
|
1597
1597
|
setHookDisabled: async (params) => connection.sendRequest("user.settings.setHookDisabled", params),
|
|
1598
1598
|
/**
|
|
1599
|
-
* Reads the user's settings document
|
|
1599
|
+
* Reads the user's settings document as `user.settings.loadWithWarning` does, without its warning, but from a caller-supplied configuration directory instead of the one the server resolved for itself. Use this when a consumer scopes a session to its own Copilot home — the SDK's per-session `configDir` override — so the settings read match the directory that session actually uses. An absent or empty `configDir` resolves the server's own home, making this identical to the `settings` that `user.settings.loadWithWarning` returns. Hook-validation relaxations are deliberately not caller-supplied: they continue to come from the server's environment, so a consumer cannot widen the host's hook policy through this method.
|
|
1600
1600
|
*
|
|
1601
1601
|
* @param params Selects the configuration directory whose user settings to read.
|
|
1602
1602
|
*
|
|
@@ -1604,7 +1604,7 @@ function createInternalServerRpc(connection) {
|
|
|
1604
1604
|
*/
|
|
1605
1605
|
loadForConfigDir: async (params) => connection.sendRequest("user.settings.loadForConfigDir", params),
|
|
1606
1606
|
/**
|
|
1607
|
-
* Reads a repository's checked-in settings document as stored, normalized, together with any diagnostic raised while reading it. This is the repository half of the layering `user.settings.get` reports: `user.settings.
|
|
1607
|
+
* Reads a repository's checked-in settings document as stored, normalized, together with any diagnostic raised while reading it. This is the repository half of the layering `user.settings.get` reports: `user.settings.loadWithWarning` reads the user's own document, and this reads the one a repository checks in to govern the keys `user.settings.listGovernanceKeys` lists as repo-governable. A document that fails to parse, or that sets a key a repository may not govern, is reported through `warning` while the settings that did load are still returned, so a consumer surfaces the diagnostic and continues rather than failing the session. When `repoRoot` is the user's home directory the Claude-compatible configuration is skipped, so a home-directory session does not inherit a personal config as repository policy.
|
|
1608
1608
|
*
|
|
1609
1609
|
* @param params Selects the repository whose checked-in settings to read.
|
|
1610
1610
|
*
|
|
@@ -1620,13 +1620,13 @@ function createInternalServerRpc(connection) {
|
|
|
1620
1620
|
*/
|
|
1621
1621
|
loadAndMergeRepo: async (params) => connection.sendRequest("user.settings.loadAndMergeRepo", params),
|
|
1622
1622
|
/**
|
|
1623
|
-
* Reports the on-disk path of the settings document `user.settings.
|
|
1623
|
+
* Reports the on-disk path of the settings document `user.settings.loadWithWarning` and `user.settings.set` read and write. Resolved the same way those methods resolve it, so a host that shows or opens the settings file names the file the runtime actually uses, including the extensionless legacy `settings` file when that is what is present.
|
|
1624
1624
|
*
|
|
1625
1625
|
* @returns The on-disk location of the user's settings document.
|
|
1626
1626
|
*/
|
|
1627
1627
|
getPath: async () => connection.sendRequest("user.settings.getPath", {}),
|
|
1628
1628
|
/**
|
|
1629
|
-
* Reads the user's stored settings together with the diagnostic raised while reading them. This is `user.settings.
|
|
1629
|
+
* Reads the user's stored settings together with the diagnostic raised while reading them. This is `user.settings.loadForConfigDir` without a `configDir` plus the reason part of the document was ignored: that one answers the document alone, so a caller cannot tell a clean read from a salvaged one. Read this when the caller is about to write the file back, where accepting a partial parse would discard every value the loader could not read. The settings that did load are still reported alongside the warning, so a consumer may surface it and continue instead of failing.
|
|
1630
1630
|
*
|
|
1631
1631
|
* @returns The user's stored settings, together with any diagnostic raised while reading them.
|
|
1632
1632
|
*/
|
|
@@ -1688,7 +1688,7 @@ function createInternalServerRpc(connection) {
|
|
|
1688
1688
|
*/
|
|
1689
1689
|
migrateStaffLogLevelOnce: async (params) => connection.sendRequest("user.settings.migrateStaffLogLevelOnce", params),
|
|
1690
1690
|
/**
|
|
1691
|
-
* Runs the one-time cleanup that removes obsolete CLI-owned settings and legacy rubber-duck keys from the user's settings document, and reports what it did. Idempotent and safe to call on every startup: with nothing obsolete left it reports `unchanged` and writes nothing. The cleanup preserves every key it does not recognize, so a setting written by a newer host is never dropped by an older one, and a document that fails to parse is reported `invalid` and left untouched rather than rewritten from a partial read. The cleaned document is not returned: it is written before this replies, so `user.settings.
|
|
1691
|
+
* Runs the one-time cleanup that removes obsolete CLI-owned settings and legacy rubber-duck keys from the user's settings document, and reports what it did. Idempotent and safe to call on every startup: with nothing obsolete left it reports `unchanged` and writes nothing. The cleanup preserves every key it does not recognize, so a setting written by a newer host is never dropped by an older one, and a document that fails to parse is reported `invalid` and left untouched rather than rewritten from a partial read. The cleaned document is not returned: it is written before this replies, so `user.settings.loadWithWarning` reads it authoritatively. A host that surfaces unrecognized keys through `user.settings.getUnknownKeysWarning` wants this first, because the keys this retires would otherwise be shown to the user as if they were misspelled settings.
|
|
1692
1692
|
*
|
|
1693
1693
|
* @param params Selects the configuration directory whose settings document to clean.
|
|
1694
1694
|
*
|
|
@@ -1696,7 +1696,7 @@ function createInternalServerRpc(connection) {
|
|
|
1696
1696
|
*/
|
|
1697
1697
|
migrateObsoleteOnDisk: async (params) => connection.sendRequest("user.settings.migrateObsoleteOnDisk", params),
|
|
1698
1698
|
/**
|
|
1699
|
-
* Resolves the on-disk locations of the settings files this runtime reads, so a consumer can show or open them. The user path is the same file `user.settings.get`, `user.settings.
|
|
1699
|
+
* Resolves the on-disk locations of the settings files this runtime reads, so a consumer can show or open them. The user path is the same file `user.settings.get`, `user.settings.loadWithWarning`, and `user.settings.set` operate on. Supply `repoRoot` to also resolve that repository's checked-in and local settings paths. A path is reported whether or not the file exists.
|
|
1700
1700
|
*
|
|
1701
1701
|
* @param params Selects which settings file paths to resolve.
|
|
1702
1702
|
*
|
|
@@ -4858,7 +4858,7 @@ function createSessionRpc(connection, sessionId) {
|
|
|
4858
4858
|
*
|
|
4859
4859
|
* @param params Model identifier to use when re-tokenizing the session's existing messages.
|
|
4860
4860
|
*
|
|
4861
|
-
* @returns Re-tokenize the session's existing messages against `modelId` and return the token totals. Useful for hosts that want an initial estimate of context usage on session resume, before the next agent turn fires `session.
|
|
4861
|
+
* @returns Re-tokenize the session's existing messages against `modelId` and return the token totals. Useful for hosts that want an initial estimate of context usage on session resume, before the next agent turn fires `session.usage_info` events. Returns zeros for an empty session.
|
|
4862
4862
|
*/
|
|
4863
4863
|
recomputeContextTokens: async (params) => connection.sendRequest("session.metadata.recomputeContextTokens", { ...params, sessionId })
|
|
4864
4864
|
},
|
|
@@ -22,7 +22,7 @@ __export(sdkProtocolVersion_exports, {
|
|
|
22
22
|
getSdkProtocolVersion: () => getSdkProtocolVersion
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(sdkProtocolVersion_exports);
|
|
25
|
-
const SDK_PROTOCOL_VERSION =
|
|
25
|
+
const SDK_PROTOCOL_VERSION = 4;
|
|
26
26
|
function getSdkProtocolVersion() {
|
|
27
27
|
return SDK_PROTOCOL_VERSION;
|
|
28
28
|
}
|
package/dist/cjs/session.js
CHANGED
|
@@ -524,7 +524,7 @@ class CopilotSession {
|
|
|
524
524
|
this._transcriptRecovery = recovery;
|
|
525
525
|
}
|
|
526
526
|
/**
|
|
527
|
-
* Outcome of the `
|
|
527
|
+
* Outcome of the `permissions.mode` requested when this session was created
|
|
528
528
|
* or resumed: whether it was applied, and the authoritative mode the
|
|
529
529
|
* session started in. Undefined when no mode was requested.
|
|
530
530
|
*/
|
|
@@ -1893,7 +1893,7 @@ class CopilotSession {
|
|
|
1893
1893
|
/**
|
|
1894
1894
|
* Sets the open-canvas snapshot for this session.
|
|
1895
1895
|
*
|
|
1896
|
-
* @param instances - The `
|
|
1896
|
+
* @param instances - The `canvases.open` array from the `session.resume` response.
|
|
1897
1897
|
* @internal This method is typically called internally when resuming a session.
|
|
1898
1898
|
*/
|
|
1899
1899
|
setOpenCanvases(instances) {
|
package/dist/cjs/toolSet.js
CHANGED
|
@@ -69,7 +69,7 @@ class ToolSet {
|
|
|
69
69
|
}
|
|
70
70
|
/**
|
|
71
71
|
* Returns a defensive copy of the accumulated filter strings, suitable for
|
|
72
|
-
* passing as {@link
|
|
72
|
+
* passing as {@link SessionOptionsBase.tools.availableTools}.
|
|
73
73
|
*/
|
|
74
74
|
toArray() {
|
|
75
75
|
return [...this.items];
|
package/dist/cjs/types.js
CHANGED
|
@@ -45,39 +45,67 @@ const RuntimeConnection = {
|
|
|
45
45
|
/**
|
|
46
46
|
* Spawn a runtime child process and communicate over its stdin/stdout.
|
|
47
47
|
*/
|
|
48
|
-
|
|
49
|
-
return {
|
|
48
|
+
forSpawnedStdio(opts = {}) {
|
|
49
|
+
return {
|
|
50
|
+
kind: "spawned-stdio",
|
|
51
|
+
path: opts.path,
|
|
52
|
+
args: opts.args,
|
|
53
|
+
env: opts.env,
|
|
54
|
+
workingDirectory: opts.workingDirectory,
|
|
55
|
+
baseDirectory: opts.baseDirectory,
|
|
56
|
+
sessionIdleTimeoutSeconds: opts.sessionIdleTimeoutSeconds
|
|
57
|
+
};
|
|
50
58
|
},
|
|
51
59
|
/**
|
|
52
60
|
* Spawn a runtime child process that listens on a TCP socket and connect to it.
|
|
53
61
|
*/
|
|
54
|
-
|
|
62
|
+
forSpawnedTcp(opts = {}) {
|
|
55
63
|
return {
|
|
56
|
-
kind: "tcp",
|
|
57
|
-
port: opts.port,
|
|
58
|
-
connectionToken: opts.connectionToken,
|
|
64
|
+
kind: "spawned-tcp",
|
|
59
65
|
path: opts.path,
|
|
60
66
|
args: opts.args,
|
|
61
|
-
env: opts.env
|
|
67
|
+
env: opts.env,
|
|
68
|
+
workingDirectory: opts.workingDirectory,
|
|
69
|
+
baseDirectory: opts.baseDirectory,
|
|
70
|
+
sessionIdleTimeoutSeconds: opts.sessionIdleTimeoutSeconds,
|
|
71
|
+
port: opts.port,
|
|
72
|
+
connectionToken: opts.connectionToken
|
|
62
73
|
};
|
|
63
74
|
},
|
|
64
75
|
/**
|
|
65
|
-
* Connect to an already-running runtime
|
|
66
|
-
* spawn a process in this mode.
|
|
76
|
+
* Connect to an already-running runtime over plaintext TCP without owning its lifetime.
|
|
67
77
|
*/
|
|
68
|
-
|
|
69
|
-
return { kind: "
|
|
78
|
+
forTcp(host, port, opts = {}) {
|
|
79
|
+
return { kind: "tcp", host, port, connectionToken: opts.connectionToken };
|
|
70
80
|
},
|
|
71
81
|
/**
|
|
72
82
|
* Host the runtime in-process over the native runtime library's C ABI (FFI).
|
|
73
83
|
*
|
|
74
84
|
* The default when no connection or environment override is supplied.
|
|
75
|
-
* Runtime configuration from `
|
|
85
|
+
* Runtime configuration from `github.token`, `observability.telemetry` and
|
|
76
86
|
* `baseDirectory` is scoped to this host, not the process environment.
|
|
77
87
|
* Client-level `env` and `workingDirectory` are unsupported.
|
|
78
88
|
*/
|
|
79
89
|
forInProcess(options = {}) {
|
|
80
|
-
return { kind: "inprocess"
|
|
90
|
+
return { ...options, kind: "inprocess" };
|
|
91
|
+
},
|
|
92
|
+
/**
|
|
93
|
+
* Resolves the SDK/deployment default at factory-call time, without starting a runtime.
|
|
94
|
+
* Honors COPILOT_SDK_DEFAULT_CONNECTION (stdio/inprocess, case-insensitive);
|
|
95
|
+
* unset or empty uses the installed SDK's default. Invalid values throw.
|
|
96
|
+
* Use a concrete factory when the hosting mode must be fixed.
|
|
97
|
+
*/
|
|
98
|
+
forDefault(options = {}) {
|
|
99
|
+
const value = process.env.COPILOT_SDK_DEFAULT_CONNECTION;
|
|
100
|
+
if (value?.toLowerCase() === "stdio") {
|
|
101
|
+
return RuntimeConnection.forSpawnedStdio(options);
|
|
102
|
+
}
|
|
103
|
+
if (!value || value.toLowerCase() === "inprocess") {
|
|
104
|
+
return RuntimeConnection.forInProcess(options);
|
|
105
|
+
}
|
|
106
|
+
throw new Error(
|
|
107
|
+
`Invalid COPILOT_SDK_DEFAULT_CONNECTION value '${value}'. Expected 'inprocess', 'stdio', or unset.`
|
|
108
|
+
);
|
|
81
109
|
}
|
|
82
110
|
};
|
|
83
111
|
function convertMcpCallToolResult(callResult) {
|
package/dist/cliVersion.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const COPILOT_CLI_VERSION = "1.0.
|
|
1
|
+
export declare const COPILOT_CLI_VERSION = "1.0.113-0.unstable.r43977958116.g150b9c6";
|
|
2
2
|
export declare const COPILOT_CLI_USE_NPM_PACKAGE = false;
|
package/dist/cliVersion.js
CHANGED
package/dist/client.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { createServerRpc } from "./generated/rpc.js";
|
|
|
2
2
|
import { CopilotDecisions } from "./decisions.js";
|
|
3
3
|
import { CopilotSession } from "./session.js";
|
|
4
4
|
import { AhpHost, type AhpHostOptions } from "./host.js";
|
|
5
|
-
import type { CopilotClientOptions, GetAuthStatusResponse, GetStatusResponse,
|
|
5
|
+
import type { CopilotClientOptions, GetAuthStatusResponse, GetStatusResponse, Model, ResumeSessionOptions, CreateSessionOptions, SessionLifecycleEventType, SessionLifecycleHandler, SessionListFilter, SessionMetadata, TypedSessionLifecycleHandler } from "./types.js";
|
|
6
6
|
export declare class CopilotClient {
|
|
7
7
|
private cliStartTimeout;
|
|
8
8
|
private cliProcess;
|
|
@@ -87,18 +87,6 @@ export declare class CopilotClient {
|
|
|
87
87
|
get decisions(): CopilotDecisions;
|
|
88
88
|
private logDebugTiming;
|
|
89
89
|
private logDebug;
|
|
90
|
-
/**
|
|
91
|
-
* Environment variable that overrides the transport when the caller does not set
|
|
92
|
-
* {@link CopilotClientOptions.connection}. Accepts `"inprocess"` or `"stdio"`
|
|
93
|
-
* (case-insensitive); unset selects the in-process transport. Any other value
|
|
94
|
-
* is an error.
|
|
95
|
-
*/
|
|
96
|
-
private static readonly DEFAULT_CONNECTION_ENV_VAR;
|
|
97
|
-
/**
|
|
98
|
-
* Resolves the default {@link RuntimeConnection} for the no-connection case,
|
|
99
|
-
* honoring {@link CopilotClient.DEFAULT_CONNECTION_ENV_VAR}.
|
|
100
|
-
*/
|
|
101
|
-
private static resolveDefaultConnection;
|
|
102
90
|
/**
|
|
103
91
|
* Creates a new CopilotClient instance.
|
|
104
92
|
*
|
|
@@ -112,30 +100,25 @@ export declare class CopilotClient {
|
|
|
112
100
|
* // Connect to an existing runtime
|
|
113
101
|
* const client = new CopilotClient({
|
|
114
102
|
* mode: "coding-agent",
|
|
115
|
-
*
|
|
103
|
+
* runtime: RuntimeConnection.forTcp("localhost", 3000),
|
|
116
104
|
* });
|
|
117
|
-
*
|
|
105
|
+
* *
|
|
118
106
|
* // Spawn the runtime over TCP on a chosen port
|
|
119
107
|
* const client = new CopilotClient({
|
|
120
108
|
* mode: "coding-agent",
|
|
121
|
-
*
|
|
109
|
+
* runtime: RuntimeConnection.forSpawnedTcp({ port: 9001 }),
|
|
122
110
|
* });
|
|
123
|
-
*
|
|
111
|
+
* *
|
|
124
112
|
* // Use a custom runtime binary
|
|
125
113
|
* const client = new CopilotClient({
|
|
126
114
|
* mode: "coding-agent",
|
|
127
|
-
*
|
|
128
|
-
* logLevel: "debug",
|
|
115
|
+
* runtime: RuntimeConnection.forSpawnedStdio({ path: "/usr/local/bin/copilot" }),
|
|
116
|
+
* observability: { logLevel: "debug" },
|
|
129
117
|
* });
|
|
130
118
|
* ```
|
|
131
119
|
*/
|
|
132
120
|
constructor(options: CopilotClientOptions);
|
|
133
121
|
private connectionExtraArgs;
|
|
134
|
-
/**
|
|
135
|
-
* Parse CLI URL into host and port
|
|
136
|
-
* Supports raw TCP addresses: "host:port", "[ipv6]:port", "http://host:port", or just "port"
|
|
137
|
-
*/
|
|
138
|
-
private parseCliUrl;
|
|
139
122
|
private validateSessionFsConfig;
|
|
140
123
|
private setupSessionFs;
|
|
141
124
|
private setupClientGlobalHandlers;
|
|
@@ -146,7 +129,7 @@ export declare class CopilotClient {
|
|
|
146
129
|
/**
|
|
147
130
|
* Starts the runtime host and establishes a connection.
|
|
148
131
|
*
|
|
149
|
-
* An explicit {@link RuntimeConnection.
|
|
132
|
+
* An explicit {@link RuntimeConnection.forTcp} only establishes the connection.
|
|
150
133
|
* Otherwise, starts an in-process host or the explicitly selected subprocess.
|
|
151
134
|
* If its subprocess survives a lost connection, it is terminated before restarting.
|
|
152
135
|
*
|
|
@@ -199,7 +182,11 @@ export declare class CopilotClient {
|
|
|
199
182
|
* @example
|
|
200
183
|
* ```typescript
|
|
201
184
|
* await using client = new CopilotClient({ mode: "coding-agent" });
|
|
202
|
-
* const session = await client.createSession({
|
|
185
|
+
* const session = await client.createSession({
|
|
186
|
+
* permissions: {
|
|
187
|
+
* onRequest: approveAll,
|
|
188
|
+
* },
|
|
189
|
+
* });
|
|
203
190
|
* await session.sendAndWait("Hello");
|
|
204
191
|
* // client.stop() is called automatically when the block exits.
|
|
205
192
|
* ```
|
|
@@ -239,6 +226,8 @@ export declare class CopilotClient {
|
|
|
239
226
|
private killCliProcess;
|
|
240
227
|
/** Mode-specific defaults spread under the caller's config (app values win). */
|
|
241
228
|
private configDefaultsForMode;
|
|
229
|
+
private applyModeDefaults;
|
|
230
|
+
private validateSessionCredentials;
|
|
242
231
|
/** Mode-specific default for enableExperimentalMode. */
|
|
243
232
|
private experimentalModeForMode;
|
|
244
233
|
/**
|
|
@@ -255,12 +244,12 @@ export declare class CopilotClient {
|
|
|
255
244
|
* Mode-specific options applied via session.options.update after create/resume.
|
|
256
245
|
*
|
|
257
246
|
* In empty mode, defaults the four overridable feature flags to safe values
|
|
258
|
-
* (caller values from `config` win). `
|
|
259
|
-
* in empty mode. `includedBuiltinSkills` defaults to `[]`, but callers can
|
|
247
|
+
* (caller values from `config` win). `plugins.installed=[]` is unconditional
|
|
248
|
+
* in empty mode. `skills.includedBuiltinSkills` defaults to `[]`, but callers can
|
|
260
249
|
* explicitly allow selected runtime-bundled skills.
|
|
261
250
|
*/
|
|
262
251
|
private updateSessionOptionsForMode;
|
|
263
|
-
createSession(config:
|
|
252
|
+
createSession(config: CreateSessionOptions): Promise<CopilotSession>;
|
|
264
253
|
private invalidateSessionInitializations;
|
|
265
254
|
private getSessionInitializationSignal;
|
|
266
255
|
private runInitializationCallback;
|
|
@@ -281,16 +270,24 @@ export declare class CopilotClient {
|
|
|
281
270
|
* @example
|
|
282
271
|
* ```typescript
|
|
283
272
|
* // Resume a previous session
|
|
284
|
-
* const session = await client.resumeSession("session-123", {
|
|
285
|
-
*
|
|
273
|
+
* const session = await client.resumeSession("session-123", {
|
|
274
|
+
* permissions: {
|
|
275
|
+
* onRequest: approveAll
|
|
276
|
+
* }
|
|
277
|
+
* });
|
|
278
|
+
* *
|
|
286
279
|
* // Resume with new tools
|
|
287
280
|
* const session = await client.resumeSession("session-123", {
|
|
288
|
-
*
|
|
289
|
-
*
|
|
281
|
+
* permissions: {
|
|
282
|
+
* onRequest: approveAll
|
|
283
|
+
* },
|
|
284
|
+
* tools: {
|
|
285
|
+
* definitions: [myNewTool]
|
|
286
|
+
* }
|
|
290
287
|
* });
|
|
291
288
|
* ```
|
|
292
289
|
*/
|
|
293
|
-
resumeSession(sessionId: string, config:
|
|
290
|
+
resumeSession(sessionId: string, config: ResumeSessionOptions): Promise<CopilotSession>;
|
|
294
291
|
private resumeSessionInternal;
|
|
295
292
|
private resumeSessionWithInitialization;
|
|
296
293
|
private requireAutoModeRecovery;
|
|
@@ -322,8 +319,7 @@ export declare class CopilotClient {
|
|
|
322
319
|
*
|
|
323
320
|
* @param message - Optional message to include in the ping
|
|
324
321
|
* @returns A promise that resolves with the ping response containing the message and timestamp
|
|
325
|
-
* @throws Error if the
|
|
326
|
-
* this was called fails
|
|
322
|
+
* @throws Error if startup fails, the connection is unavailable, or shutdown is in progress
|
|
327
323
|
*
|
|
328
324
|
* @example
|
|
329
325
|
* ```typescript
|
|
@@ -345,13 +341,11 @@ export declare class CopilotClient {
|
|
|
345
341
|
*/
|
|
346
342
|
getAuthStatus(): Promise<GetAuthStatusResponse>;
|
|
347
343
|
/**
|
|
348
|
-
*
|
|
349
|
-
*
|
|
350
|
-
* `connect` handshake or the provider registrations that follow it. A caller that
|
|
351
|
-
* queues before it calls this passes the startup it observed first, because
|
|
352
|
-
* `startPromise` is cleared once that startup settles.
|
|
344
|
+
* Lazily starts the client or joins its current startup. Await the observed
|
|
345
|
+
* attempt directly so its failure cannot turn into a retry within this request.
|
|
353
346
|
*/
|
|
354
347
|
private getStartedConnection;
|
|
348
|
+
private assertNotStopping;
|
|
355
349
|
/**
|
|
356
350
|
* List available models with their metadata.
|
|
357
351
|
*
|
|
@@ -361,10 +355,12 @@ export declare class CopilotClient {
|
|
|
361
355
|
* Results are cached after the first successful call to avoid rate limiting.
|
|
362
356
|
* The cache is cleared when the client disconnects.
|
|
363
357
|
*
|
|
364
|
-
*
|
|
365
|
-
*
|
|
358
|
+
* Starts the client if needed, unless a custom handler is set.
|
|
359
|
+
*
|
|
360
|
+
* @throws Error if startup fails, the connection is retired, or shutdown is in
|
|
361
|
+
* progress (when no custom handler is set)
|
|
366
362
|
*/
|
|
367
|
-
listModels(): Promise<
|
|
363
|
+
listModels(): Promise<Model[]>;
|
|
368
364
|
/**
|
|
369
365
|
* Send the `connect` handshake (carrying the optional token) and verify the
|
|
370
366
|
* server's protocol version. Falls back to `ping` against legacy servers
|
|
@@ -384,7 +380,11 @@ export declare class CopilotClient {
|
|
|
384
380
|
* ```typescript
|
|
385
381
|
* const lastId = await client.getLastSessionId();
|
|
386
382
|
* if (lastId) {
|
|
387
|
-
*
|
|
383
|
+
* const session = await client.resumeSession(lastId, {
|
|
384
|
+
* permissions: {
|
|
385
|
+
* onRequest: approveAll,
|
|
386
|
+
* },
|
|
387
|
+
* });
|
|
388
388
|
* }
|
|
389
389
|
* ```
|
|
390
390
|
*/
|
|
@@ -525,6 +525,7 @@ export declare class CopilotClient {
|
|
|
525
525
|
* ```
|
|
526
526
|
*/
|
|
527
527
|
onLifecycle(handler: SessionLifecycleHandler): () => void;
|
|
528
|
+
private static normalizeEnvironment;
|
|
528
529
|
/**
|
|
529
530
|
* Builds runtime configuration for child processes and the per-host FFI snapshot.
|
|
530
531
|
* Typed auth, home, keychain, and telemetry options override the effective env.
|