@workerdeck/core 0.15.0 → 0.16.0
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/build/index.d.mts +53 -20
- package/build/index.mjs +579 -252
- package/build/index.mjs.map +1 -1
- package/package.json +3 -3
package/build/index.d.mts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { McpServerStatus, Options, Query, SDKMessage, SDKUserMessage, SessionMessage } from "@anthropic-ai/claude-agent-sdk";
|
|
1
|
+
import { McpServerStatus, Options, Query, SDKMessage, SDKSessionInfo, SDKUserMessage, SessionMessage } from "@anthropic-ai/claude-agent-sdk";
|
|
2
2
|
import { ApiMessage, CreateSessionRequest, EngineCapabilities, McpServerConfigWire, McpServerStatusInfo, MessageAttachment, ModelOption, PermissionMode, PermissionRequest, ProfileEngine, ProfileInfo, SdkSessionSummary, SessionEvent, SessionEventBody, SessionInfo, SessionStatus, ToolCallRequestFrame, ToolExecutionBackend, ToolExecutionOutput } from "@workerdeck/protocol";
|
|
3
3
|
import { LanguageModel, LanguageModel as LanguageModel$1, ModelMessage, Tool, Tool as Tool$1, ToolSet, ToolSet as ToolSet$1 } from "ai";
|
|
4
4
|
import { SandboxEngine, SandboxVfs } from "@workerdeck/sandbox";
|
|
5
5
|
import { Readable, Writable } from "node:stream";
|
|
6
6
|
|
|
7
|
-
//#region src/attachments.d.ts
|
|
7
|
+
//#region src/lib/attachments.d.ts
|
|
8
8
|
/**
|
|
9
9
|
* An attachment plus its bytes — what the host hands a runner at send time.
|
|
10
10
|
*
|
|
@@ -44,7 +44,7 @@ declare function attachmentContentBlocks(attachments: readonly AttachmentInput[]
|
|
|
44
44
|
/** Strip the bytes: the log-safe half of an attachment. */
|
|
45
45
|
declare function attachmentRef(attachment: AttachmentInput): MessageAttachment;
|
|
46
46
|
//#endregion
|
|
47
|
-
//#region src/tool-executor.d.ts
|
|
47
|
+
//#region src/executors/tool-executor.d.ts
|
|
48
48
|
/**
|
|
49
49
|
* Result of one tool execution, whenever it arrives. `failed` is a normal
|
|
50
50
|
* outcome the agent loop adapts to — not an exception.
|
|
@@ -175,8 +175,19 @@ interface Runner {
|
|
|
175
175
|
/** Begin the session. Idempotent; returns the run promise (resolves when the run ends). */
|
|
176
176
|
start(): Promise<void>;
|
|
177
177
|
info(): SessionInfo;
|
|
178
|
-
/** Replay buffered events with seq > afterSeq, then deliver live events. Returns unsubscribe.
|
|
179
|
-
|
|
178
|
+
/** Replay buffered events with seq > afterSeq, then deliver live events. Returns unsubscribe.
|
|
179
|
+
*
|
|
180
|
+
* `coalesceReplay` drops state readings superseded later in the same replay —
|
|
181
|
+
* the fifty stale context/rate-limit polls a long session accumulates, which
|
|
182
|
+
* a client otherwise applies one by one and *renders*, counting its usage
|
|
183
|
+
* meters up through the session's history on every attach. Opt-in, and the
|
|
184
|
+
* default must stay off: it is only sound for a consumer whose handling of
|
|
185
|
+
* those events is last-write-wins, and `parking.ts` — which subscribes from
|
|
186
|
+
* seq 0 — branches on `status_changed` instead. Live events are never
|
|
187
|
+
* affected; this touches the buffered replay alone. */
|
|
188
|
+
subscribe(listener: SessionEventListener, afterSeq?: number, options?: {
|
|
189
|
+
coalesceReplay?: boolean;
|
|
190
|
+
}): () => void;
|
|
180
191
|
/** Queue a user message for the session (starts the next turn when idle).
|
|
181
192
|
* `attachments` carry their bytes to the engine and their reference to the
|
|
182
193
|
* event log (see {@link AttachmentInput}). */
|
|
@@ -221,7 +232,7 @@ interface Runner {
|
|
|
221
232
|
close(reason?: 'client' | 'server' | 'error'): void;
|
|
222
233
|
}
|
|
223
234
|
//#endregion
|
|
224
|
-
//#region src/runner.d.ts
|
|
235
|
+
//#region src/engines/claude/runner.d.ts
|
|
225
236
|
type QueryFn = (params: {
|
|
226
237
|
prompt: AsyncIterable<SDKUserMessage>;
|
|
227
238
|
options?: Options;
|
|
@@ -229,6 +240,9 @@ type QueryFn = (params: {
|
|
|
229
240
|
type HistoryFn = (sdkSessionId: string, options: {
|
|
230
241
|
dir?: string;
|
|
231
242
|
}) => Promise<SessionMessage[]>;
|
|
243
|
+
type SessionInfoFn = (sdkSessionId: string, options: {
|
|
244
|
+
dir?: string;
|
|
245
|
+
}) => Promise<SDKSessionInfo | undefined>;
|
|
232
246
|
type SessionRunnerConfig = CreateSessionRequest & {
|
|
233
247
|
/** Injectable query implementation (tests, instrumentation). Defaults to the SDK's query(). */queryFn?: QueryFn; /** Environment for the spawned Claude Code process. Defaults to process.env. */
|
|
234
248
|
env?: Record<string, string | undefined>;
|
|
@@ -239,6 +253,10 @@ type SessionRunnerConfig = CreateSessionRequest & {
|
|
|
239
253
|
* starts, so late-attaching clients get a full transcript. Default true. */
|
|
240
254
|
backfillHistory?: boolean; /** Injectable history reader (tests). Defaults to the SDK's getSessionMessages. */
|
|
241
255
|
historyFn?: HistoryFn;
|
|
256
|
+
/** Injectable session-metadata reader (tests). Defaults to the SDK's
|
|
257
|
+
* getSessionInfo — the only place the CLI's own session title is readable
|
|
258
|
+
* from, since no message on the stream carries it. */
|
|
259
|
+
sessionInfoFn?: SessionInfoFn;
|
|
242
260
|
};
|
|
243
261
|
/**
|
|
244
262
|
* One live Agent SDK session: owns the query() call, the streaming input queue, the
|
|
@@ -287,11 +305,22 @@ declare class SessionRunner implements Runner {
|
|
|
287
305
|
/**
|
|
288
306
|
* Replay buffered events with seq > afterSeq, then deliver live events.
|
|
289
307
|
* Returns an unsubscribe function.
|
|
308
|
+
*
|
|
309
|
+
* Replay honours the reset watermark: transcript content below the latest
|
|
310
|
+
* `conversation_reset` is skipped (the reducer would clear it again anyway,
|
|
311
|
+
* and a pre-reset client that never learned the reducer's case would render
|
|
312
|
+
* a conversation the engine has discarded), while state-bearing events —
|
|
313
|
+
* which are emitted once and never again — always replay. The reset event
|
|
314
|
+
* itself replays (the skip is strictly-below), which is what clears a
|
|
315
|
+
* reconnecting client still holding pre-reset rows; superseded resets are
|
|
316
|
+
* content below the newer one and are skipped with what they cleared.
|
|
290
317
|
*/
|
|
291
|
-
subscribe(listener: SessionEventListener, afterSeq?: number
|
|
318
|
+
subscribe(listener: SessionEventListener, afterSeq?: number, options?: {
|
|
319
|
+
coalesceReplay?: boolean;
|
|
320
|
+
}): () => void;
|
|
292
321
|
}
|
|
293
322
|
//#endregion
|
|
294
|
-
//#region src/
|
|
323
|
+
//#region src/engines/provider/runner.d.ts
|
|
295
324
|
/** `cwd` is optional for this engine: the loop has no host-filesystem coupling
|
|
296
325
|
* (tools get scoped VFS handles instead). Defaults to process.cwd() for display. */
|
|
297
326
|
type AiSdkRunnerConfig = Omit<CreateSessionRequest, 'cwd'> & {
|
|
@@ -456,7 +485,9 @@ declare class AiSdkRunner implements Runner {
|
|
|
456
485
|
setModel(model?: string): Promise<void>;
|
|
457
486
|
fail(message: string): void;
|
|
458
487
|
close(reason?: 'client' | 'server' | 'error'): void;
|
|
459
|
-
subscribe(listener: SessionEventListener, afterSeq?: number
|
|
488
|
+
subscribe(listener: SessionEventListener, afterSeq?: number, options?: {
|
|
489
|
+
coalesceReplay?: boolean;
|
|
490
|
+
}): () => void;
|
|
460
491
|
/**
|
|
461
492
|
* Deliver the result of an execution this runner dispatched. Used by the host
|
|
462
493
|
* when a backend settled out-of-band (a browser bridge answering later, a
|
|
@@ -477,7 +508,7 @@ declare class AiSdkRunner implements Runner {
|
|
|
477
508
|
setTitle(title: string | undefined): void;
|
|
478
509
|
}
|
|
479
510
|
//#endregion
|
|
480
|
-
//#region src/claude
|
|
511
|
+
//#region src/engines/claude/auth.d.ts
|
|
481
512
|
/**
|
|
482
513
|
* Credential presence for one Claude Code environment, as the CLI itself reports
|
|
483
514
|
* it. 'unknown' means the check could not run at all (no binary, a CLI too old
|
|
@@ -515,7 +546,7 @@ declare function checkClaudeAuth(env: Record<string, string | undefined>, option
|
|
|
515
546
|
timeoutMs?: number;
|
|
516
547
|
}): Promise<ClaudeAuthStatus>;
|
|
517
548
|
//#endregion
|
|
518
|
-
//#region src/quickjs-executor.d.ts
|
|
549
|
+
//#region src/executors/quickjs-executor.d.ts
|
|
519
550
|
/** Resolve a URL to text for the guest. Runs host-side with host authority —
|
|
520
551
|
* this is where a credential may be attached, never inside the sandbox. */
|
|
521
552
|
type HostFetch = (url: string, signal: AbortSignal) => Promise<string>;
|
|
@@ -548,7 +579,7 @@ declare class QuickJsExecutor implements ToolExecutor {
|
|
|
548
579
|
* (not the bare parent). Only http(s) — no file:, data:, or other schemes. */
|
|
549
580
|
declare function isHostAllowed(url: string, allowedHosts: string[]): boolean;
|
|
550
581
|
//#endregion
|
|
551
|
-
//#region src/pending-registry.d.ts
|
|
582
|
+
//#region src/lib/pending-registry.d.ts
|
|
552
583
|
/**
|
|
553
584
|
* One registry for every request that leaves the runner and must come back:
|
|
554
585
|
* permission approvals, browser-bridged tool calls, and deferred executions.
|
|
@@ -610,7 +641,7 @@ declare class PendingRequestRegistry {
|
|
|
610
641
|
cancelAll(reason: string, error: string, kind?: PendingKind): number;
|
|
611
642
|
}
|
|
612
643
|
//#endregion
|
|
613
|
-
//#region src/browser-bridge-executor.d.ts
|
|
644
|
+
//#region src/executors/browser-bridge-executor.d.ts
|
|
614
645
|
/** Answer a bridged call, as delivered by the client over the wire. */
|
|
615
646
|
type BridgeAnswer = {
|
|
616
647
|
output: ToolExecutionOutput;
|
|
@@ -664,7 +695,7 @@ declare class BrowserBridgeExecutor implements ToolExecutor {
|
|
|
664
695
|
/** Map a registry outcome onto the executor's result contract. */
|
|
665
696
|
declare function toExecutionResult(outcome: PendingOutcome<BridgeAnswer>): ToolExecutionResult;
|
|
666
697
|
//#endregion
|
|
667
|
-
//#region src/deferred-executor.d.ts
|
|
698
|
+
//#region src/executors/deferred-executor.d.ts
|
|
668
699
|
/** A dispatched execution, as handed to the backend that will run it. */
|
|
669
700
|
type DeferredDispatch = {
|
|
670
701
|
/** Correlation id. The result is delivered under it — `POST
|
|
@@ -714,7 +745,7 @@ declare class DeferredExecutor implements ToolExecutor {
|
|
|
714
745
|
dispatch(call: ToolExecutionCall): Promise<ToolExecutionDispatch>;
|
|
715
746
|
}
|
|
716
747
|
//#endregion
|
|
717
|
-
//#region src/web-fetch.d.ts
|
|
748
|
+
//#region src/engines/provider/web-fetch.d.ts
|
|
718
749
|
/**
|
|
719
750
|
* `web_fetch` backend, close to Claude Code's original WebFetch: fetch a URL,
|
|
720
751
|
* convert HTML to markdown, and (optionally) digest it with a model against the
|
|
@@ -760,7 +791,7 @@ declare function isPrivateAddress(address: string): boolean;
|
|
|
760
791
|
*/
|
|
761
792
|
declare function htmlToMarkdown(html: string): string;
|
|
762
793
|
//#endregion
|
|
763
|
-
//#region src/tools.d.ts
|
|
794
|
+
//#region src/engines/provider/tools.d.ts
|
|
764
795
|
/**
|
|
765
796
|
* How much authority a tool carries, which decides where it may run.
|
|
766
797
|
*
|
|
@@ -863,7 +894,7 @@ declare function withHostTools(context: ToolContext, hostTools: Record<string, H
|
|
|
863
894
|
|
|
864
895
|
kind?: string): ToolContext;
|
|
865
896
|
//#endregion
|
|
866
|
-
//#region src/
|
|
897
|
+
//#region src/engines/provider/session.d.ts
|
|
867
898
|
type EngineSessionOptions = {
|
|
868
899
|
/** Resolved session config (profile defaults already applied). */config: AiSdkRunnerConfig; /** The profile that selected this engine, when there was one. */
|
|
869
900
|
profile?: ProfileInfo;
|
|
@@ -1014,7 +1045,7 @@ declare function connectMcpTools(servers: Record<string, McpServerConfigWire>, o
|
|
|
1014
1045
|
required?: boolean;
|
|
1015
1046
|
}): Promise<McpConnection>;
|
|
1016
1047
|
//#endregion
|
|
1017
|
-
//#region src/input-queue.d.ts
|
|
1048
|
+
//#region src/lib/input-queue.d.ts
|
|
1018
1049
|
/**
|
|
1019
1050
|
* Push-based single-consumer AsyncIterable bridging imperative sendMessage() calls
|
|
1020
1051
|
* into the streaming `prompt` the Agent SDK consumes.
|
|
@@ -1026,7 +1057,7 @@ declare class InputQueue implements AsyncIterable<SDKUserMessage> {
|
|
|
1026
1057
|
[Symbol.asyncIterator](): AsyncIterator<SDKUserMessage>;
|
|
1027
1058
|
}
|
|
1028
1059
|
//#endregion
|
|
1029
|
-
//#region src/normalize.d.ts
|
|
1060
|
+
//#region src/lib/normalize.d.ts
|
|
1030
1061
|
declare function toApiMessage(message: unknown): ApiMessage;
|
|
1031
1062
|
/**
|
|
1032
1063
|
* The CLI's MCP status, as `McpServerStatusInfo`.
|
|
@@ -1497,7 +1528,9 @@ declare class CodexRunner implements Runner {
|
|
|
1497
1528
|
setModel(model?: string): Promise<void>;
|
|
1498
1529
|
fail(message: string): void;
|
|
1499
1530
|
close(reason?: 'client' | 'server' | 'error'): void;
|
|
1500
|
-
subscribe(listener: SessionEventListener, afterSeq?: number
|
|
1531
|
+
subscribe(listener: SessionEventListener, afterSeq?: number, options?: {
|
|
1532
|
+
coalesceReplay?: boolean;
|
|
1533
|
+
}): () => void;
|
|
1501
1534
|
/**
|
|
1502
1535
|
* The session's MCP servers, live from the binary.
|
|
1503
1536
|
*
|