@github/copilot-sdk 1.0.15-unstable.35663726336.gcb2a8cc → 1.0.15
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 +55 -4
- package/dist/cjs/cliVersion.js +1 -1
- package/dist/cjs/client.js +25 -5
- package/dist/cjs/extension.js +9 -9
- package/dist/cjs/generated/rpc.js +408 -182
- package/dist/cjs/index.js +7 -7
- package/dist/cjs/installationConfirmation.js +98 -0
- package/dist/cjs/session.js +122 -135
- package/dist/cjs/{factory.js → workflow.js} +33 -33
- package/dist/cliVersion.d.ts +1 -1
- package/dist/cliVersion.js +1 -1
- package/dist/client.d.ts +1 -0
- package/dist/client.js +27 -5
- package/dist/extension.d.ts +6 -6
- package/dist/extension.js +9 -9
- package/dist/generated/rpc.d.ts +4189 -2011
- package/dist/generated/rpc.js +408 -182
- package/dist/generated/session-events.d.ts +289 -121
- package/dist/index.d.ts +3 -3
- package/dist/index.js +4 -4
- package/dist/installationConfirmation.d.ts +19 -0
- package/dist/installationConfirmation.js +77 -0
- package/dist/session.d.ts +10 -16
- package/dist/session.js +126 -139
- package/dist/types.d.ts +31 -66
- package/dist/workflow.d.ts +367 -0
- package/dist/{factory.js → workflow.js} +25 -25
- package/docs/extensions.md +1 -1
- package/docs/workflows.md +255 -0
- package/package.json +11 -10
- package/dist/factory.d.ts +0 -327
- package/docs/factories.md +0 -296
- package/docs/factory-patterns.md +0 -194
package/README.md
CHANGED
|
@@ -14,10 +14,9 @@ verified `github/copilot-cli` release assets when the SDK is published, so
|
|
|
14
14
|
starting the SDK performs no runtime download. Set `COPILOT_CLI_PATH` to use an
|
|
15
15
|
existing installation instead.
|
|
16
16
|
|
|
17
|
-
The checked-in
|
|
18
|
-
`
|
|
19
|
-
|
|
20
|
-
release's `SHA256SUMS.txt`.
|
|
17
|
+
The checked-in `copilotCliVersion` in `package.json` and compiled metadata in
|
|
18
|
+
`src/cliVersion.ts` use a development placeholder. The public SDK snapshot
|
|
19
|
+
replaces both with the CLI version published for that snapshot.
|
|
21
20
|
|
|
22
21
|
`npm run pack:release` builds the main package and all platform packages. Set
|
|
23
22
|
`COPILOT_CLI_DOWNLOAD_BASE_URL` to use a release mirror while packaging.
|
|
@@ -26,6 +25,12 @@ containing validated runtime npm package roots named for all eight platforms.
|
|
|
26
25
|
This keeps `COPILOT_CLI_USE_NPM_PACKAGE` false and embeds those runtime files in
|
|
27
26
|
the self-contained SDK platform packages.
|
|
28
27
|
|
|
28
|
+
In the runtime repository, packaging uses the prepared same-checkout runtime.
|
|
29
|
+
Set `COPILOT_SDK_RUNTIME_PLATFORMS` to the available target (for example,
|
|
30
|
+
`linux-x64`) for both `pack:release` and `verify:release-packages`. SDK CI checks
|
|
31
|
+
that target only; public release workflows leave this unset to package and
|
|
32
|
+
verify all eight platforms.
|
|
33
|
+
|
|
29
34
|
## Installation
|
|
30
35
|
|
|
31
36
|
```bash
|
|
@@ -119,6 +124,7 @@ new CopilotClient(options?: CopilotClientOptions)
|
|
|
119
124
|
- `workingDirectory?: string` - Working directory for the runtime process (default: current process cwd).
|
|
120
125
|
- `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`.
|
|
121
126
|
- `extensionLaunchProvider?: ExtensionLaunchProvider` - Experimental connection-level resolver for extension launch profiles. The client installs the reverse-RPC handler and registers the provider during startup before sessions can be created.
|
|
127
|
+
- `installationConfirmationHandler?: InstallationConfirmationHandler` - Experimental connection-global human review for `installations.confirm`. Receives the typed request and independent request/connection cancellation signals, and returns an explicit decision. Does not enable installation capabilities.
|
|
122
128
|
- `logLevel?: "none" | "error" | "warning" | "info" | "debug" | "all"` - Log level. When omitted, the runtime uses its own default (currently `"info"`).
|
|
123
129
|
- `env?: Record<string, string | undefined>` - Environment variables for the runtime process. When omitted, inherits `process.env`.
|
|
124
130
|
- `gitHubToken?: string` - GitHub token for authentication. When provided, takes priority over other auth methods.
|
|
@@ -130,6 +136,49 @@ new CopilotClient(options?: CopilotClientOptions)
|
|
|
130
136
|
- `sessionIdleTimeoutSeconds?: number` - Server-wide idle timeout for sessions in seconds. Ignored when connecting via `RuntimeConnection.forUri`.
|
|
131
137
|
- `enableRemoteSessions?: boolean` - Enable Mission Control remote session support. Ignored when connecting via `RuntimeConnection.forUri`.
|
|
132
138
|
|
|
139
|
+
#### Installation confirmation (experimental)
|
|
140
|
+
|
|
141
|
+
All six SDKs (Node.js, Python, Go, .NET, Java and Rust) provide this receiver with the
|
|
142
|
+
same semantics: each review gets one cancellation token, concurrent reviews are
|
|
143
|
+
independent, and a decision returned after cancellation is never sent. Without a
|
|
144
|
+
configured handler, an `installations.confirm` request is refused, which the
|
|
145
|
+
runtime treats as no consent.
|
|
146
|
+
|
|
147
|
+
The installation confirmation handler receives the generated
|
|
148
|
+
`InstallationConfirmationRequest` and a `CancellationToken`. Match `operationId`
|
|
149
|
+
and `policySessionId` against the exact original action on this connection
|
|
150
|
+
before presenting the complete review. Refuse unknown operations or incomplete
|
|
151
|
+
reviews; missing legacy session metadata is not permission to use the current
|
|
152
|
+
session. Return `"confirm"`, `"decline"` or `"cancel"` only after an explicit
|
|
153
|
+
human decision. The SDK echoes the original challenge and fingerprint.
|
|
154
|
+
|
|
155
|
+
Concurrent reviews remain independent. The token is cancelled when the runtime
|
|
156
|
+
retires the request, including runtime-enforced expiry, or when the original
|
|
157
|
+
connection closes. Observe it to close pending UI. Late handler results cannot
|
|
158
|
+
approve a retired request. This incoming signal does not cancel outbound
|
|
159
|
+
installation or OAuth RPCs, and dropping those promises is not cancellation.
|
|
160
|
+
|
|
161
|
+
Use `client.rpc.mcp.prepareInstall` before `applyInstall`: preparation returns an
|
|
162
|
+
inert runtime-issued `operationId` and original expiry. Register that ID with its
|
|
163
|
+
captured session on this exact client before applying. Removal uses
|
|
164
|
+
`planUninstall` then `applyUninstall`; the returned `operationId` identifies the
|
|
165
|
+
operation, while `planHandle` is the one-use removal input. Never interchange them.
|
|
166
|
+
Use `client.rpc.mcp.installations.list` and `recover` for owned inventory.
|
|
167
|
+
Inspect or cancel uncertain work through `status` and `cancel` on the original
|
|
168
|
+
connection and operation ID, without selecting a replacement session or replaying apply.
|
|
169
|
+
|
|
170
|
+
Owned OAuth similarly uses `session.rpc.mcp.oauth.prepareLogin` to obtain
|
|
171
|
+
`loginId` before browser, network or cached-reconnect work. Retain that ID with
|
|
172
|
+
the original session and `expectedInstallationId` for `login` and `cancelLogin`.
|
|
173
|
+
Prepare freezes reauthentication and display options. Cancelling an incoming
|
|
174
|
+
confirmation or abandoning a login promise is not a substitute for `cancelLogin`.
|
|
175
|
+
Manual MCP OAuth retains its direct `login` path.
|
|
176
|
+
|
|
177
|
+
A matching runtime contract and available owned-lifecycle support are required.
|
|
178
|
+
Capability negotiation does not promise availability; preserve typed refusals
|
|
179
|
+
instead of falling back to raw configuration writes. Generated presence and
|
|
180
|
+
transport tests do not establish a working installer, live OAuth or restart safety.
|
|
181
|
+
|
|
133
182
|
#### Methods
|
|
134
183
|
|
|
135
184
|
##### `start(): Promise<void>`
|
|
@@ -158,6 +207,7 @@ Create a new conversation session.
|
|
|
158
207
|
- `systemMessage?: SystemMessageConfig` - System message customization (see below)
|
|
159
208
|
- `infiniteSessions?: InfiniteSessionConfig` - Configure automatic context compaction (see below)
|
|
160
209
|
- `workingDirectory?: string` - Working directory for the session (default: runtime process cwd).
|
|
210
|
+
- `refreshCustomInstructions?: boolean` - Invalidates the process-wide custom-instruction discovery cache before creating this session, so instruction-file edits made in the same runtime are read again. Defaults to `false` (cache reuse). Other sessions in this runtime may observe updated instructions on later turns or discovery. This does not watch files or enable disabled instruction loading. Available on `SessionConfig`, not `ResumeSessionConfig`.
|
|
161
211
|
- `enableSessionStore?: boolean` - Enables the cross-session store for search and retrieval across sessions. When unset in `"copilot-cli"` mode, the runtime default applies (enabled). In `"empty"` mode, defaults to disabled.
|
|
162
212
|
- `gitHubTokenProvider?: GitHubTokenProvider` - Acquires rotating, session-scoped GitHub tokens. Token results require a positive `expiresIn` value in seconds remaining when the callback completes; production tokens typically last eight hours. Cannot be combined with `gitHubToken`.
|
|
163
213
|
- `provider?: ProviderConfig` - Custom API provider configuration (BYOK - Bring Your Own Key). See [Custom Providers](#custom-providers) section.
|
|
@@ -295,6 +345,7 @@ Source is independent of delivery mode. Leaving it unset preserves the existing
|
|
|
295
345
|
##### `sendAndWait(options: MessageOptions, timeout?: number): Promise<AssistantMessageEvent | undefined>`
|
|
296
346
|
|
|
297
347
|
Send a message and wait until the session becomes idle.
|
|
348
|
+
Sub-agent events are still delivered to listeners, but do not complete the wait or supply its reply.
|
|
298
349
|
|
|
299
350
|
**Options:**
|
|
300
351
|
|
package/dist/cjs/cliVersion.js
CHANGED
|
@@ -22,7 +22,7 @@ __export(cliVersion_exports, {
|
|
|
22
22
|
COPILOT_CLI_VERSION: () => COPILOT_CLI_VERSION
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(cliVersion_exports);
|
|
25
|
-
const COPILOT_CLI_VERSION = "1.0.
|
|
25
|
+
const COPILOT_CLI_VERSION = "1.0.89";
|
|
26
26
|
const COPILOT_CLI_USE_NPM_PACKAGE = false;
|
|
27
27
|
// Annotate the CommonJS export names for ESM import in node:
|
|
28
28
|
0 && (module.exports = {
|
package/dist/cjs/client.js
CHANGED
|
@@ -44,6 +44,7 @@ var import_runtimeArtifacts = require("./runtimeArtifacts.js");
|
|
|
44
44
|
var import_cliVersion = require("./cliVersion.js");
|
|
45
45
|
var import_sessionFsProvider = require("./sessionFsProvider.js");
|
|
46
46
|
var import_copilotRequestHandler = require("./copilotRequestHandler.js");
|
|
47
|
+
var import_installationConfirmation = require("./installationConfirmation.js");
|
|
47
48
|
var import_telemetry = require("./telemetry.js");
|
|
48
49
|
var import_schema = require("./schema.js");
|
|
49
50
|
var import_toolSet = require("./toolSet.js");
|
|
@@ -265,6 +266,7 @@ class CopilotClient {
|
|
|
265
266
|
sessionFsConfig = null;
|
|
266
267
|
requestHandler = null;
|
|
267
268
|
extensionLaunchProvider;
|
|
269
|
+
installationConfirmationHandler;
|
|
268
270
|
builtinPluginDirectories = [];
|
|
269
271
|
onGitHubTelemetry;
|
|
270
272
|
clientGlobalHandlers = {};
|
|
@@ -423,6 +425,7 @@ class CopilotClient {
|
|
|
423
425
|
this.sessionFsConfig = options.sessionFs ?? null;
|
|
424
426
|
this.requestHandler = options.requestHandler ?? null;
|
|
425
427
|
this.extensionLaunchProvider = options.extensionLaunchProvider;
|
|
428
|
+
this.installationConfirmationHandler = options.installationConfirmationHandler;
|
|
426
429
|
this.onGitHubTelemetry = options.onGitHubTelemetry;
|
|
427
430
|
this.setupClientGlobalHandlers();
|
|
428
431
|
const connEnv = conn.kind === "stdio" || conn.kind === "tcp" ? conn.env : void 0;
|
|
@@ -1237,6 +1240,7 @@ class CopilotClient {
|
|
|
1237
1240
|
includeSubAgentStreamingEvents: config.includeSubAgentStreamingEvents ?? true,
|
|
1238
1241
|
...this.onGitHubTelemetry != null ? { enableGitHubTelemetryForwarding: true } : {},
|
|
1239
1242
|
mcpServers: toWireMcpServers(config.mcpServers),
|
|
1243
|
+
...config.diagnostics !== void 0 ? { diagnostics: config.diagnostics } : {},
|
|
1240
1244
|
mcpOAuthTokenStorage: config.mcpOAuthTokenStorage,
|
|
1241
1245
|
authClientIdMetadataUrl: config.authClientIdMetadataUrl,
|
|
1242
1246
|
envValueMode: "direct",
|
|
@@ -1246,6 +1250,7 @@ class CopilotClient {
|
|
|
1246
1250
|
agent: config.agent,
|
|
1247
1251
|
configDir: config.configDirectory,
|
|
1248
1252
|
enableConfigDiscovery: config.enableConfigDiscovery,
|
|
1253
|
+
refreshCustomInstructions: config.refreshCustomInstructions,
|
|
1249
1254
|
skipEmbeddingRetrieval: config.skipEmbeddingRetrieval,
|
|
1250
1255
|
embeddingCacheStorage: config.embeddingCacheStorage,
|
|
1251
1256
|
organizationCustomInstructions: config.organizationCustomInstructions,
|
|
@@ -1338,10 +1343,11 @@ class CopilotClient {
|
|
|
1338
1343
|
return this.resumeSessionInternal(sessionId, config);
|
|
1339
1344
|
}
|
|
1340
1345
|
/** @internal */
|
|
1341
|
-
async resumeSessionForExtension(sessionId, config,
|
|
1342
|
-
return this.resumeSessionInternal(sessionId, config,
|
|
1346
|
+
async resumeSessionForExtension(sessionId, config, contributions = {}, extensionOptions) {
|
|
1347
|
+
return this.resumeSessionInternal(sessionId, config, contributions, extensionOptions);
|
|
1343
1348
|
}
|
|
1344
|
-
async resumeSessionInternal(sessionId, config,
|
|
1349
|
+
async resumeSessionInternal(sessionId, config, contributions = {}, extensionOptions) {
|
|
1350
|
+
const { workflows } = contributions;
|
|
1345
1351
|
if (config.gitHubToken !== void 0 && config.gitHubTokenProvider !== void 0) {
|
|
1346
1352
|
throw new Error("gitHubToken and gitHubTokenProvider are mutually exclusive");
|
|
1347
1353
|
}
|
|
@@ -1361,7 +1367,7 @@ class CopilotClient {
|
|
|
1361
1367
|
session.registerTools(config.tools);
|
|
1362
1368
|
session.registerCanvases(config.canvases);
|
|
1363
1369
|
session.registerCommands(config.commands);
|
|
1364
|
-
session.
|
|
1370
|
+
session.registerWorkflows(workflows);
|
|
1365
1371
|
const {
|
|
1366
1372
|
wireProvider: bearerWireProvider,
|
|
1367
1373
|
wireProviders: bearerWireProviders,
|
|
@@ -1442,7 +1448,7 @@ class CopilotClient {
|
|
|
1442
1448
|
})),
|
|
1443
1449
|
toolSearch: config.toolSearch,
|
|
1444
1450
|
canvases: config.canvases?.map((canvas) => canvas.declaration),
|
|
1445
|
-
|
|
1451
|
+
workflows: workflows?.map((workflow) => workflow.meta),
|
|
1446
1452
|
requestCanvasRenderer: config.requestCanvasRenderer,
|
|
1447
1453
|
requestExtensions: config.requestExtensions,
|
|
1448
1454
|
extensionSdkPath: config.extensionSdkPath,
|
|
@@ -1483,6 +1489,7 @@ class CopilotClient {
|
|
|
1483
1489
|
includeSubAgentStreamingEvents: config.includeSubAgentStreamingEvents ?? true,
|
|
1484
1490
|
...this.onGitHubTelemetry != null ? { enableGitHubTelemetryForwarding: true } : {},
|
|
1485
1491
|
mcpServers: toWireMcpServers(config.mcpServers),
|
|
1492
|
+
...config.diagnostics !== void 0 ? { diagnostics: config.diagnostics } : {},
|
|
1486
1493
|
mcpOAuthTokenStorage: config.mcpOAuthTokenStorage,
|
|
1487
1494
|
authClientIdMetadataUrl: config.authClientIdMetadataUrl,
|
|
1488
1495
|
envValueMode: "direct",
|
|
@@ -1903,6 +1910,9 @@ class CopilotClient {
|
|
|
1903
1910
|
if (this.options.mode === "empty") {
|
|
1904
1911
|
env.COPILOT_DISABLE_KEYTAR = "1";
|
|
1905
1912
|
}
|
|
1913
|
+
if (this.options.mode !== "empty") {
|
|
1914
|
+
env.COPILOT_RUNTIME_PROCESS_FILE_LOGGING = "1";
|
|
1915
|
+
}
|
|
1906
1916
|
if (this.options.telemetry) {
|
|
1907
1917
|
const t = this.options.telemetry;
|
|
1908
1918
|
env.COPILOT_OTEL_ENABLED = "true";
|
|
@@ -2277,6 +2287,16 @@ stderr: ${stderrOutput}` : ""}`
|
|
|
2277
2287
|
return session.clientSessionApis;
|
|
2278
2288
|
});
|
|
2279
2289
|
(0, import_rpc.registerClientGlobalApiHandlers)(this.connection, this.clientGlobalHandlers);
|
|
2290
|
+
if (this.installationConfirmationHandler) {
|
|
2291
|
+
const confirmation = (0, import_installationConfirmation.createInstallationConfirmationAdapter)(
|
|
2292
|
+
this.connection,
|
|
2293
|
+
this.installationConfirmationHandler
|
|
2294
|
+
);
|
|
2295
|
+
this.connection.onRequest(
|
|
2296
|
+
"installations.confirm",
|
|
2297
|
+
(params, token) => confirmation.confirm(params, token)
|
|
2298
|
+
);
|
|
2299
|
+
}
|
|
2280
2300
|
this.connection.onRequest(
|
|
2281
2301
|
"hooks.invoke",
|
|
2282
2302
|
async (params) => {
|
package/dist/cjs/extension.js
CHANGED
|
@@ -20,17 +20,17 @@ var extension_exports = {};
|
|
|
20
20
|
__export(extension_exports, {
|
|
21
21
|
Canvas: () => import_canvas.Canvas,
|
|
22
22
|
CanvasError: () => import_canvas.CanvasError,
|
|
23
|
-
|
|
23
|
+
WorkflowResumeError: () => import_workflow.WorkflowResumeError,
|
|
24
24
|
createCanvas: () => import_canvas.createCanvas,
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
defineWorkflow: () => import_workflow.defineWorkflow,
|
|
26
|
+
isWorkflowRunTerminal: () => import_workflow.isWorkflowRunTerminal,
|
|
27
27
|
joinSession: () => joinSession
|
|
28
28
|
});
|
|
29
29
|
module.exports = __toCommonJS(extension_exports);
|
|
30
30
|
var import_client = require("./client.js");
|
|
31
31
|
var import_types = require("./types.js");
|
|
32
32
|
var import_canvas = require("./canvas.js");
|
|
33
|
-
var
|
|
33
|
+
var import_workflow = require("./workflow.js");
|
|
34
34
|
async function joinSession(config = {}) {
|
|
35
35
|
const sessionId = process.env.SESSION_ID;
|
|
36
36
|
if (!sessionId) {
|
|
@@ -41,7 +41,7 @@ async function joinSession(config = {}) {
|
|
|
41
41
|
const client = new import_client.CopilotClient({ _internalConnection: { kind: "parent-process" } });
|
|
42
42
|
const {
|
|
43
43
|
extensionSdkPath: _stripped,
|
|
44
|
-
|
|
44
|
+
workflows,
|
|
45
45
|
requestedEnvironmentVariables,
|
|
46
46
|
...rest
|
|
47
47
|
} = config;
|
|
@@ -53,7 +53,7 @@ async function joinSession(config = {}) {
|
|
|
53
53
|
onPermissionRequest: config.onPermissionRequest ?? import_types.defaultJoinSessionPermissionHandler,
|
|
54
54
|
suppressResumeEvent: config.suppressResumeEvent ?? true
|
|
55
55
|
},
|
|
56
|
-
|
|
56
|
+
{ workflows },
|
|
57
57
|
requestedEnvironmentVariables?.length ? { requestedEnvironmentVariables } : void 0
|
|
58
58
|
);
|
|
59
59
|
}
|
|
@@ -61,9 +61,9 @@ async function joinSession(config = {}) {
|
|
|
61
61
|
0 && (module.exports = {
|
|
62
62
|
Canvas,
|
|
63
63
|
CanvasError,
|
|
64
|
-
|
|
64
|
+
WorkflowResumeError,
|
|
65
65
|
createCanvas,
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
defineWorkflow,
|
|
67
|
+
isWorkflowRunTerminal,
|
|
68
68
|
joinSession
|
|
69
69
|
});
|