@github/copilot-sdk-linuxmusl-x64 1.0.14-preview.1 → 1.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/copilot-sdk/cliVersion.d.ts +2 -0
- package/copilot-sdk/client.d.ts +5 -1
- package/copilot-sdk/docs/factories.md +36 -19
- package/copilot-sdk/extension.js +906 -185
- package/copilot-sdk/factory.d.ts +42 -16
- package/copilot-sdk/ffiRuntimeHost.d.ts +8 -2
- package/copilot-sdk/generated/rpc.d.ts +1683 -84
- package/copilot-sdk/generated/session-events.d.ts +987 -93
- package/copilot-sdk/index.d.ts +2 -2
- package/copilot-sdk/index.js +905 -184
- package/copilot-sdk/runtimeArtifacts.d.ts +13 -1
- package/copilot-sdk/session.d.ts +53 -1
- package/copilot-sdk/types.d.ts +78 -3
- package/package.json +1 -1
- package/prebuilds/linuxmusl-x64/runtime.node +0 -0
- package/schemas/api.schema.json +669 -107
- package/schemas/session-events.schema.json +560 -11
- package/sdk/index.js +256 -254
- package/tgrep/bin/linux-x64/tgrep +0 -0
- package/tgrep/bin/linuxmusl-x64/tgrep +0 -0
package/copilot-sdk/client.d.ts
CHANGED
|
@@ -7,10 +7,13 @@ export declare class CopilotClient {
|
|
|
7
7
|
private ffiHost;
|
|
8
8
|
private connection;
|
|
9
9
|
private messageWriter;
|
|
10
|
+
private connectionClosed;
|
|
10
11
|
private socket;
|
|
11
12
|
private runtimePort;
|
|
12
13
|
private actualHost;
|
|
13
14
|
private state;
|
|
15
|
+
/** Shared in-flight start; concurrent callers await it instead of spawning another CLI. */
|
|
16
|
+
private startPromise;
|
|
14
17
|
private sessions;
|
|
15
18
|
private stderrBuffer;
|
|
16
19
|
/** Resolved connection mode chosen in the constructor. */
|
|
@@ -92,7 +95,7 @@ export declare class CopilotClient {
|
|
|
92
95
|
private connectionExtraArgs;
|
|
93
96
|
/**
|
|
94
97
|
* Parse CLI URL into host and port
|
|
95
|
-
* Supports formats: "host:port", "http://host:port", "https://host:port", or just "port"
|
|
98
|
+
* Supports formats: "host:port", "[ipv6]:port", "http://host:port", "https://host:port", or just "port"
|
|
96
99
|
*/
|
|
97
100
|
private parseCliUrl;
|
|
98
101
|
private validateSessionFsConfig;
|
|
@@ -121,6 +124,7 @@ export declare class CopilotClient {
|
|
|
121
124
|
* ```
|
|
122
125
|
*/
|
|
123
126
|
start(): Promise<void>;
|
|
127
|
+
private doStart;
|
|
124
128
|
/**
|
|
125
129
|
* Stops the CLI server and closes all active sessions.
|
|
126
130
|
*
|
|
@@ -62,19 +62,20 @@ Validation covers the model's `run_factory` path only. An extension calling `ses
|
|
|
62
62
|
|
|
63
63
|
The `run()` context provides:
|
|
64
64
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
65
|
+
* `ctx.runId`: Stable ID reused across resumed attempts.
|
|
66
|
+
* `ctx.args`: Invocation arguments, forwarded verbatim. When the caller omits `args`, this is `{}` rather than `undefined`.
|
|
67
|
+
* `ctx.agent(prompt, options?)`: Runs one factory-owned subagent. Options are exactly `label`, `schema`, `model`, `agent`, `reasoningEffort`, and `contextTier`. See [Subagent calls](#subagent-calls).
|
|
68
|
+
* `ctx.parallel(thunks)`: Runs thunks concurrently and awaits all of them (a barrier). A thunk that throws becomes `null` in the result array, so one failed item does not lose the rest. Cancellation and hard runtime failures (`ResponseError`, `ConnectionError`) are the exception — those propagate and reject the whole call, because they mean the run itself is in trouble rather than one item having failed. Handle them at run level; do not assume every failure arrives as a `null`. Rejects above 4096 items.
|
|
69
|
+
* `ctx.pipeline(items, ...stages)`: Flows each item through every stage without a barrier between stages, so one item can be in a later stage while another is still in an earlier one. Each stage is called as `(previous, item, index)`, where `previous` is the prior stage's result and `item` is the original input. A stage that throws drops that item to `null` and skips its remaining stages, with the same exception for cancellation and hard runtime failures. Rejects above 4096 items.
|
|
70
|
+
* `ctx.phase(title)`: Starts a named progress phase. This sets a single run-global value, so calling it from inside concurrent `parallel`/`pipeline` stages races. Call it at run-level transitions and distinguish concurrent work by `label` instead.
|
|
71
|
+
* `ctx.log(message)`: Appends a progress line. When a factory bounds its own coverage (top-N, sampling), log what was dropped.
|
|
72
|
+
* `ctx.step(key, producer, options?)`: Journals the producer's JSON result under a stable key so a resume replays it without re-running the producer. A journaled (default) producer must return a JSON-serializable value; `undefined` or a non-JSON value is rejected. Pass `{ volatile: true }` to bypass the journal and run the producer every time.
|
|
73
73
|
|
|
74
74
|
The key is the *sole* identity: neither the producer body nor its inputs contribute to it. A resume replays the cached value for a matching key even if the producer has since changed, so version the key (`"scan-v2"`) whenever its inputs or meaning change. Journaled producers are best-effort at-least-once and may run again across crashes or concurrent same-key callers, so keep side effects idempotent.
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
75
|
+
* `ctx.pause(key)`: Pauses at a durable, one-shot checkpoint. The first attempt records the checkpoint, pauses, and throws `AbortError` after cooperative cancellation. When the run resumes, the factory starts again and the same checkpoint returns so execution can continue. Call it only from the main factory flow, not inside `ctx.parallel()` or `ctx.pipeline()`.
|
|
76
|
+
* `ctx.session`: The session returned by `joinSession`. It refuses calls that start, resume, or pause a factory run. Call `extensions_manage` with `operation: "guide"` to read more about the session APIs.
|
|
77
|
+
* `ctx.signal`: Cooperative cancellation signal for extension work and subprocesses.
|
|
78
|
+
* `ctx.factory(...)`: Always rejects because nested factories are not supported.
|
|
78
79
|
|
|
79
80
|
Factory-owned subagents are intentionally hidden from `read_agent` and `write_agent`. Use the factory observability APIs instead.
|
|
80
81
|
|
|
@@ -157,7 +158,7 @@ session.factory.run(
|
|
|
157
158
|
name: string,
|
|
158
159
|
options?: {
|
|
159
160
|
args?: JsonValue;
|
|
160
|
-
limits?:
|
|
161
|
+
limits?: FactoryLimitOverrides;
|
|
161
162
|
notifyOnComplete?: boolean;
|
|
162
163
|
logPhaseNames?: boolean;
|
|
163
164
|
},
|
|
@@ -180,7 +181,7 @@ The signature is:
|
|
|
180
181
|
session.factory.resume(
|
|
181
182
|
runId: string,
|
|
182
183
|
options?: {
|
|
183
|
-
limits?:
|
|
184
|
+
limits?: FactoryLimitOverrides;
|
|
184
185
|
notifyOnComplete?: boolean;
|
|
185
186
|
logPhaseNames?: boolean;
|
|
186
187
|
},
|
|
@@ -189,15 +190,31 @@ session.factory.resume(
|
|
|
189
190
|
|
|
190
191
|
Set `notifyOnComplete` to `true` for factories that are likely to be invoked by an agent, so the originating session is notified when the factory completes. Set it to `false` for factories intended to be invoked programmatically, where the caller awaits the result directly. Set `logPhaseNames` to emit factory phase names to the session transcript. Both options apply to new and resumed runs.
|
|
191
192
|
|
|
192
|
-
Both resolve with the run envelope (`FactoryRunResult`) for **every** outcome
|
|
193
|
+
Both resolve with the run envelope (`FactoryRunResult`) for **every** outcome—`completed`, `error`, `halted`, `paused`, and `cancelled` alike. Inspect `status` and read `result` only when the run completed; a limit breach carries a typed `failure`. A `paused` envelope means that the current attempt settled, not that the durable run is permanently finished. Resume the same run ID to start another attempt with its journal and accounting intact. SDK-initiated `run` and `resume` do not request permission, so they have no declined outcome. The model's `run_factory` tool requests permission before the durable row exists; declining it creates no run row. An SDK-initiated run is refused only when the session already has its maximum number of active top-level runs. Pre-execution resume failures throw `FactoryResumeError`, whose `code` is one of `not_found`, `non_resumable`, `already_active`, `factory_already_running`, `factory_limits_invalid`, `factory_session_disposed`, `factory_storage_unavailable`, or `factory_storage_corrupt`.
|
|
193
194
|
|
|
194
195
|
An agent that no longer has a prior run's ID in context can recover it with `factories_manage` and `operation: "runs"`, which lists the session's factory runs with their IDs and statuses. This matters for resume: a run that reached a limit keeps its journal, so resuming it replays completed work for free, while restarting it from scratch pays for that work twice.
|
|
195
196
|
|
|
197
|
+
Pause a running attempt from outside its factory body:
|
|
198
|
+
|
|
199
|
+
```ts
|
|
200
|
+
const paused = await session.factory.pause(runId);
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
Inside a factory body, use a durable checkpoint instead:
|
|
204
|
+
|
|
205
|
+
```ts
|
|
206
|
+
await ctx.step("prepare", prepareInput);
|
|
207
|
+
await ctx.pause("review-ready");
|
|
208
|
+
await ctx.agent("Review the prepared input");
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
The first attempt pauses at `"review-ready"` and ends through cooperative cancellation. On resume, the factory starts from the beginning, reuses the journaled step, returns from the checkpoint, and continues.
|
|
212
|
+
|
|
196
213
|
The agent-facing `run_factory` tool has exactly two input branches:
|
|
197
214
|
|
|
198
215
|
```ts
|
|
199
|
-
{ name: string; args?: JsonValue; limits?:
|
|
200
|
-
{ resumeFromRunId: string; limits?:
|
|
216
|
+
{ name: string; args?: JsonValue; limits?: FactoryLimitOverrides }
|
|
217
|
+
{ resumeFromRunId: string; limits?: FactoryLimitOverrides }
|
|
201
218
|
```
|
|
202
219
|
|
|
203
220
|
## Authoring a factory from inside a session
|
|
@@ -253,9 +270,9 @@ const progressPage = await session.factory.getRunProgress(runId, {
|
|
|
253
270
|
- `getRunDetail(runId)` returns phases, prompt-safe agent summaries, and the latest progress page.
|
|
254
271
|
- `getRunProgress(runId, options?)` pages progress forward, backward, by phase, or from the latest tail.
|
|
255
272
|
|
|
256
|
-
`getRun(runId)` reads the latest run envelope
|
|
273
|
+
`getRun(runId)` reads the latest run envelope. `pause(runId)` pauses a running attempt and returns its `paused` envelope. `cancel(runId)` cancels a run and returns its terminal envelope.
|
|
257
274
|
|
|
258
|
-
`waitForRun(runId, options?)` resolves with the
|
|
275
|
+
`waitForRun(runId, options?)` resolves with the current attempt's envelope once it settles into `completed`, `error`, `halted`, `paused`, or `cancelled`. It resolves immediately when the current attempt has already settled:
|
|
259
276
|
|
|
260
277
|
```ts
|
|
261
278
|
const settled = await session.factory.waitForRun(runId);
|
|
@@ -272,7 +289,7 @@ setTimeout(() => controller.abort(), 30_000);
|
|
|
272
289
|
const settled = await session.factory.waitForRun(runId, { signal: controller.signal });
|
|
273
290
|
```
|
|
274
291
|
|
|
275
|
-
Aborting rejects the wait and has no effect on the run, which keeps executing
|
|
292
|
+
Aborting rejects the wait and has no effect on the run, which keeps executing—use `pause(runId)` or `cancel(runId)` to stop it. The resolved object is a snapshot of that settled attempt. If its status is `paused`, a later resume updates the durable envelope under the same run ID. Call `getRun(runId)` to read the latest envelope. `isFactoryRunTerminal(status)` exposes the same current-attempt settlement test for callers driving their own loop.
|
|
276
293
|
|
|
277
294
|
Listen for the ephemeral `factory.run_updated` event. Its `{ runId, revision }` payload is an invalidation signal. Re-read the desired API when a newer monotonic revision arrives.
|
|
278
295
|
|