@workerdeck/core 2.9.0 → 2.11.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 CHANGED
@@ -1,5 +1,6 @@
1
1
  import { McpServerStatus, Options, Query, SDKMessage, SDKSessionInfo, SDKUserMessage, SessionMessage } from "@anthropic-ai/claude-agent-sdk";
2
- import { ApiMessage, CreateSessionRequest, EngineCapabilities, McpServerConfigWire, McpServerStatusInfo, MessageAttachment, ModelOption, PermissionMode, PermissionRequest, ProfileEngine, ProfileInfo, SdkSessionSummary, SessionEvent, SessionEventBody, SessionInfo, SessionStatus, ToolCallRequestFrame, ToolExecutionBackend, ToolExecutionOutput } from "@workerdeck/protocol";
2
+ import { ApiMessage, ByModel, CostBreakdown, CreateSessionRequest, EngineCapabilities, McpServerConfigWire, McpServerStatusInfo, MessageAttachment, MessageOrigin, ModelOption, PermissionMode, PermissionRequest, ProfileEngine, ProfileInfo, SdkSessionSummary, SessionEvent, SessionEventBody, SessionInfo, SessionStatus, ToolCallRequestFrame, ToolExecutionBackend, ToolExecutionOutput } from "@workerdeck/protocol";
3
+ import { z } from "zod";
3
4
  import { LanguageModel, LanguageModel as LanguageModel$1, ModelMessage, Tool, Tool as Tool$1, ToolSet, ToolSet as ToolSet$1 } from "ai";
4
5
  import { SandboxEngine, SandboxVfs } from "@workerdeck/sandbox";
5
6
  import { Readable, Writable } from "node:stream";
@@ -24,6 +25,28 @@ type LocalCommandResult = {
24
25
  declare function localCommandTranscript(result: LocalCommandResult): string;
25
26
  declare function localCommandContext(pending: readonly string[]): string | undefined;
26
27
  //#endregion
28
+ //#region src/lib/cost-ledger.d.ts
29
+ type CostFigures = {
30
+ byModel?: ByModel;
31
+ reportedCostUsd?: number;
32
+ };
33
+ type CostLedgerState = CostFigures & {
34
+ lifetime?: CostFigures;
35
+ };
36
+ declare class CostLedger {
37
+ #private;
38
+ carry(state: CostLedgerState | undefined): void;
39
+ carryUnlessRestored(state: CostLedgerState | undefined): void;
40
+ observeCumulative(byModel: ByModel | undefined, reportedCostUsd: number | undefined): void;
41
+ observeDelta(byModel: ByModel): void;
42
+ rollover(): void;
43
+ get byModel(): ByModel | undefined;
44
+ get breakdown(): CostBreakdown;
45
+ get costUsd(): number | undefined;
46
+ get reportedCostUsd(): number | undefined;
47
+ snapshot(): CostLedgerState;
48
+ }
49
+ //#endregion
27
50
  //#region src/executors/tool-executor.d.ts
28
51
  type ToolExecutionResult = {
29
52
  status: 'ok';
@@ -82,6 +105,9 @@ type RunnerSnapshot = {
82
105
  parked: ParkedExecution[];
83
106
  state: unknown;
84
107
  };
108
+ type SendMessageOptions = {
109
+ origin?: MessageOrigin;
110
+ };
85
111
  type PermissionDecision = {
86
112
  behavior: 'allow';
87
113
  updatedInput?: Record<string, unknown>;
@@ -102,7 +128,7 @@ interface Runner {
102
128
  imageRefs?: boolean;
103
129
  }): () => void;
104
130
  eventAt?(seq: number): SessionEvent | undefined;
105
- sendMessage(text: string, attachments?: readonly AttachmentInput[]): void;
131
+ sendMessage(text: string, attachments?: readonly AttachmentInput[], options?: SendMessageOptions): void;
106
132
  queueLocalCommand?(result: LocalCommandResult): void;
107
133
  refreshUsage?(): Promise<void>;
108
134
  mcpServers?(): Promise<McpServerStatusInfo[] | undefined>;
@@ -117,6 +143,8 @@ interface Runner {
117
143
  settleExecution?(executionId: string, result: ToolExecutionResult): boolean;
118
144
  park?(): RunnerSnapshot | undefined;
119
145
  snapshot?(): RunnerSnapshot | undefined;
146
+ carryCost?(state: CostLedgerState): void;
147
+ costState?(): CostLedgerState;
120
148
  fail(message: string): void;
121
149
  close(reason?: 'client' | 'server' | 'error'): void;
122
150
  }
@@ -128,6 +156,87 @@ type SubscribeOptions = {
128
156
  imageRefs?: boolean;
129
157
  };
130
158
  //#endregion
159
+ //#region src/lib/peers.d.ts
160
+ type PeerSessionSummary = {
161
+ id: string;
162
+ engine?: ProfileEngine;
163
+ status: SessionStatus;
164
+ title?: string;
165
+ project?: string;
166
+ cwd: string;
167
+ profile?: string;
168
+ lastActivityAt?: number;
169
+ pendingPermissionCount: number;
170
+ };
171
+ type PeerPeek = PeerSessionSummary & {
172
+ live: boolean;
173
+ checklist?: SessionInfo['checklist'];
174
+ pendingApprovals: string[];
175
+ recent: string[];
176
+ };
177
+ type PeerSendResult = {
178
+ delivered: true;
179
+ sessionId: string;
180
+ name?: string;
181
+ queued: boolean;
182
+ } | {
183
+ delivered: false;
184
+ reason: string;
185
+ };
186
+ type PeerSendOptions = {
187
+ hops?: string[];
188
+ };
189
+ interface PeerDirectory {
190
+ list(from: string): Promise<PeerSessionSummary[]>;
191
+ peek(from: string, sessionId: string, options?: {
192
+ recent?: number;
193
+ }): Promise<PeerPeek | undefined>;
194
+ send(from: string, sessionId: string, text: string, options?: PeerSendOptions): Promise<PeerSendResult>;
195
+ }
196
+ declare const PEER_MCP_SERVER = "workerdeck";
197
+ declare const PEER_MESSAGE_MAX_CHARS = 16000;
198
+ declare const PEER_RECENT_DEFAULT = 8;
199
+ declare const PEER_RECENT_MAX = 40;
200
+ declare const PEER_TOOL_SHAPES: {
201
+ readonly peers_list: {
202
+ readonly description: string;
203
+ readonly shape: {};
204
+ };
205
+ readonly peers_peek: {
206
+ readonly description: string;
207
+ readonly shape: {
208
+ readonly sessionId: z.ZodString;
209
+ readonly recent: z.ZodOptional<z.ZodNumber>;
210
+ };
211
+ };
212
+ readonly peers_send: {
213
+ readonly description: string;
214
+ readonly shape: {
215
+ readonly sessionId: z.ZodString;
216
+ readonly text: z.ZodString;
217
+ };
218
+ };
219
+ };
220
+ type PeerToolName = keyof typeof PEER_TOOL_SHAPES;
221
+ declare const PEER_TOOL_NAMES: PeerToolName[];
222
+ type PeerToolSpec = {
223
+ name: PeerToolName;
224
+ description: string;
225
+ inputSchema: Record<string, unknown>;
226
+ };
227
+ type PeerToolOutput = {
228
+ text: string;
229
+ isError: boolean;
230
+ };
231
+ declare function peerToolSpecs(): PeerToolSpec[];
232
+ declare function runPeerTool(peers: PeerDirectory, from: string, name: string, args: unknown): Promise<PeerToolOutput>;
233
+ declare function peerMessageEnvelope(text: string, origin: MessageOrigin): string;
234
+ declare function peerSummary(info: SessionInfo): PeerSessionSummary;
235
+ declare function recentLines(events: readonly SessionEvent[], limit: number): string[];
236
+ declare function installPeerDirectory(directory: PeerDirectory | undefined): void;
237
+ declare function installedPeerDirectory(): PeerDirectory | undefined;
238
+ declare function peerDirectoryHandle(): PeerDirectory;
239
+ //#endregion
131
240
  //#region src/engines/claude/runner.d.ts
132
241
  type QueryFn = (params: {
133
242
  prompt: AsyncIterable<SDKUserMessage>;
@@ -149,6 +258,7 @@ type SessionRunnerConfig = CreateSessionRequest & {
149
258
  backfillHistory?: boolean;
150
259
  historyFn?: HistoryFn;
151
260
  sessionInfoFn?: SessionInfoFn;
261
+ peers?: PeerDirectory;
152
262
  };
153
263
  declare class SessionRunner implements Runner {
154
264
  #private;
@@ -162,8 +272,10 @@ declare class SessionRunner implements Runner {
162
272
  get pendingApprovals(): PermissionRequest[];
163
273
  info(): SessionInfo;
164
274
  setTitle(title: string | undefined): void;
275
+ carryCost(state: CostLedgerState): void;
276
+ costState(): CostLedgerState;
165
277
  start(): Promise<void>;
166
- sendMessage(text: string, attachments?: readonly AttachmentInput[]): void;
278
+ sendMessage(text: string, attachments?: readonly AttachmentInput[], options?: SendMessageOptions): void;
167
279
  queueLocalCommand(result: LocalCommandResult): void;
168
280
  mcpServers(): Promise<McpServerStatusInfo[] | undefined>;
169
281
  reconnectMcpServer(name: string): Promise<void>;
@@ -216,12 +328,13 @@ type AiSdkRunnerConfig = Omit<CreateSessionRequest, 'cwd'> & {
216
328
  reportMcpServers?: () => Promise<McpServerStatusInfo[] | undefined>;
217
329
  onClose?: () => void | Promise<void>;
218
330
  restore?: RunnerSnapshot;
331
+ peers?: PeerDirectory;
219
332
  };
220
333
  type PendingToolCall = {
221
334
  toolCallId: string;
222
335
  toolName: string;
223
336
  input: unknown;
224
- deferred?: boolean;
337
+ parkable?: boolean;
225
338
  expiresAt?: number;
226
339
  };
227
340
  type AiSdkSessionState = {
@@ -229,12 +342,6 @@ type AiSdkSessionState = {
229
342
  pendingToolCalls: PendingToolCall[];
230
343
  dispatched: string[];
231
344
  numTurns: number;
232
- totalUsage: {
233
- input: number;
234
- output: number;
235
- cacheWrite: number;
236
- cacheRead: number;
237
- };
238
345
  turnAccum?: {
239
346
  startedAt: number;
240
347
  input: number;
@@ -267,10 +374,12 @@ declare class AiSdkRunner implements Runner {
267
374
  get pendingApprovals(): PermissionRequest[];
268
375
  get vfs(): SandboxVfs | undefined;
269
376
  info(): SessionInfo;
377
+ carryCost(state: CostLedgerState): void;
378
+ costState(): CostLedgerState;
270
379
  start(): Promise<void>;
271
380
  park(): RunnerSnapshot | undefined;
272
381
  snapshot(): RunnerSnapshot | undefined;
273
- sendMessage(text: string, attachments?: readonly AttachmentInput[]): void;
382
+ sendMessage(text: string, attachments?: readonly AttachmentInput[], options?: SendMessageOptions): void;
274
383
  queueLocalCommand(result: LocalCommandResult): void;
275
384
  resolveToolCall(toolCallId: string, output: ToolCallOutput, options?: {
276
385
  isError?: boolean;
@@ -470,6 +579,8 @@ type ToolContextOptions = {
470
579
  };
471
580
  onDispatch?: (executionId: string, toolName: string) => void;
472
581
  onSettle?: (executionId: string, result: ToolExecutionResult) => void;
582
+ peers?: PeerDirectory;
583
+ selfId?: () => string;
473
584
  };
474
585
  type ToolContext = {
475
586
  vfs: SandboxVfs;
@@ -680,6 +791,19 @@ type AppServerCollabAgentToolCallItem = {
680
791
  reasoningEffort?: string | null;
681
792
  agentsStates?: Record<string, unknown> | null;
682
793
  };
794
+ type AppServerDynamicToolCallItem = {
795
+ id: string;
796
+ type: 'dynamicToolCall';
797
+ tool: string;
798
+ namespace?: string | null;
799
+ arguments: unknown;
800
+ status: string;
801
+ success?: boolean | null;
802
+ contentItems?: Array<{
803
+ type: string;
804
+ text?: string;
805
+ }> | null;
806
+ };
683
807
  type AppServerUserMessageItem = {
684
808
  id: string;
685
809
  type: 'userMessage';
@@ -689,7 +813,7 @@ type AppServerContextCompactionItem = {
689
813
  id: string;
690
814
  type: 'contextCompaction';
691
815
  };
692
- type AppServerItem = AppServerAgentMessageItem | AppServerReasoningItem | AppServerCommandExecutionItem | AppServerFileChangeItem | AppServerMcpToolCallItem | AppServerWebSearchItem | AppServerImageGenerationItem | AppServerImageViewItem | AppServerUserMessageItem | AppServerSubAgentActivityItem | AppServerCollabAgentToolCallItem | AppServerContextCompactionItem;
816
+ type AppServerItem = AppServerAgentMessageItem | AppServerReasoningItem | AppServerCommandExecutionItem | AppServerFileChangeItem | AppServerMcpToolCallItem | AppServerDynamicToolCallItem | AppServerWebSearchItem | AppServerImageGenerationItem | AppServerImageViewItem | AppServerUserMessageItem | AppServerSubAgentActivityItem | AppServerCollabAgentToolCallItem | AppServerContextCompactionItem;
693
817
  type AppServerTurn = {
694
818
  id: string;
695
819
  status: string;
@@ -726,6 +850,10 @@ type AppServerUserInput = {
726
850
  } | {
727
851
  type: 'localImage';
728
852
  path: string;
853
+ } | {
854
+ type: 'skill';
855
+ name: string;
856
+ path: string;
729
857
  };
730
858
  type AppServerConnection = {
731
859
  request(method: string, params?: unknown): Promise<unknown>;
@@ -763,6 +891,7 @@ type CodexRunnerConfig = CreateSessionRequest & {
763
891
  codexHome?: string;
764
892
  defaultApprovalTimeoutMs?: number | null;
765
893
  backfillHistory?: boolean;
894
+ peers?: PeerDirectory;
766
895
  };
767
896
  declare class CodexRunner implements Runner {
768
897
  #private;
@@ -775,8 +904,10 @@ declare class CodexRunner implements Runner {
775
904
  get pendingApprovals(): PermissionRequest[];
776
905
  info(): SessionInfo;
777
906
  setTitle(title: string | undefined): void;
907
+ carryCost(state: CostLedgerState): void;
908
+ costState(): CostLedgerState;
778
909
  start(): Promise<void>;
779
- sendMessage(text: string, attachments?: readonly AttachmentInput[]): void;
910
+ sendMessage(text: string, attachments?: readonly AttachmentInput[], options?: SendMessageOptions): void;
780
911
  queueLocalCommand(result: LocalCommandResult): void;
781
912
  resolvePermission(requestId: string, decision: PermissionDecision): boolean;
782
913
  interrupt(): Promise<void>;
@@ -817,5 +948,5 @@ declare class JsonRpcStdioConnection {
817
948
  //#region src/engines/provider/adapter.d.ts
818
949
  declare const providerAdapter: EngineAdapter;
819
950
  //#endregion
820
- export { AiSdkRunner, type AiSdkRunnerConfig, type AiSdkSessionState, type AppServerConnectFn, type AppServerConnectOptions, type AppServerConnection, type AppServerHistoryTurn, type AppServerItem, type AppServerThreadListResponse, type AppServerThreadSummary, type AppServerTokenUsage, type AppServerTurn, type AppServerUserInput, type AttachmentInput, type AttachmentKind, type BridgeAnswer, BrowserBridgeExecutor, type BrowserBridgeExecutorOptions, CLAUDE_CATALOG, CODEX_CATALOG, type ClaudeAuthProbe, type ClaudeAuthStatus, CodexRunner, type CodexRunnerConfig, type DeferredDispatch, DeferredExecutor, type DeferredExecutorOptions, type EngineAdapter, type EngineAvailability, type EngineRunnerRequest, type EngineSessionOptions, type HistoryFn, type HostFetch, type HostToolDefinition, InputQueue, JsonRpcError, JsonRpcStdioConnection, type LanguageModel, type LocalCommandResult, type McpConnection, type ModelCatalog, type ParkedExecution, type PendingEntry, type PendingKind, type PendingOutcome, PendingRequestRegistry, type PendingToolCall, type PermissionDecision, type QueryFn, QuickJsExecutor, type QuickJsExecutorOptions, type RegisterOptions, type Runner, type RunnerSnapshot, SUPPORTED_ATTACHMENT_TYPES, type SessionEventListener, SessionRunner, type SessionRunnerConfig, type SettledBy, type Tool, type ToolCallOutput, type ToolContext, type ToolContextOptions, type ToolDefinition, type ToolExecutionCall, type ToolExecutionDispatch, type ToolExecutionResult, type ToolExecutor, type ToolSet, type ToolTrust, type WebFetchDigest, type WebFetchFn, type WebFetchOptions, type WebFetchResult, attachmentContentBlocks, attachmentKind, attachmentRef, checkClaudeAuth, claudeAdapter, codexAdapter, connectAppServer, connectMcpTools, createEngineSession, createToolContext, createWebFetch, getEngineAdapter, htmlToMarkdown, isHostAllowed, isPrivateAddress, listCodexSessions, localCommandContext, localCommandTranscript, mcpStatusInfo, modelOptionsFromSdk, normalizeMediaType, normalizeSdkMessage, providerAdapter, replaySlice, resolveBundledClaudeExecutable, resolveBundledCodexExecutable, toApiMessage, toExecutionResult, truncateResultBlocks, withHostTools, withMcpTools };
951
+ export { AiSdkRunner, type AiSdkRunnerConfig, type AiSdkSessionState, type AppServerConnectFn, type AppServerConnectOptions, type AppServerConnection, type AppServerHistoryTurn, type AppServerItem, type AppServerThreadListResponse, type AppServerThreadSummary, type AppServerTokenUsage, type AppServerTurn, type AppServerUserInput, type AttachmentInput, type AttachmentKind, type BridgeAnswer, BrowserBridgeExecutor, type BrowserBridgeExecutorOptions, CLAUDE_CATALOG, CODEX_CATALOG, type ClaudeAuthProbe, type ClaudeAuthStatus, CodexRunner, type CodexRunnerConfig, type CostFigures, CostLedger, type CostLedgerState, type DeferredDispatch, DeferredExecutor, type DeferredExecutorOptions, type EngineAdapter, type EngineAvailability, type EngineRunnerRequest, type EngineSessionOptions, type HistoryFn, type HostFetch, type HostToolDefinition, InputQueue, JsonRpcError, JsonRpcStdioConnection, type LanguageModel, type LocalCommandResult, type McpConnection, type ModelCatalog, PEER_MCP_SERVER, PEER_MESSAGE_MAX_CHARS, PEER_RECENT_DEFAULT, PEER_RECENT_MAX, PEER_TOOL_NAMES, type ParkedExecution, type PeerDirectory, type PeerPeek, type PeerSendOptions, type PeerSendResult, type PeerSessionSummary, type PeerToolName, type PeerToolSpec, type PendingEntry, type PendingKind, type PendingOutcome, PendingRequestRegistry, type PendingToolCall, type PermissionDecision, type QueryFn, QuickJsExecutor, type QuickJsExecutorOptions, type RegisterOptions, type Runner, type RunnerSnapshot, SUPPORTED_ATTACHMENT_TYPES, type SendMessageOptions, type SessionEventListener, SessionRunner, type SessionRunnerConfig, type SettledBy, type Tool, type ToolCallOutput, type ToolContext, type ToolContextOptions, type ToolDefinition, type ToolExecutionCall, type ToolExecutionDispatch, type ToolExecutionResult, type ToolExecutor, type ToolSet, type ToolTrust, type WebFetchDigest, type WebFetchFn, type WebFetchOptions, type WebFetchResult, attachmentContentBlocks, attachmentKind, attachmentRef, checkClaudeAuth, claudeAdapter, codexAdapter, connectAppServer, connectMcpTools, createEngineSession, createToolContext, createWebFetch, getEngineAdapter, htmlToMarkdown, installPeerDirectory, installedPeerDirectory, isHostAllowed, isPrivateAddress, listCodexSessions, localCommandContext, localCommandTranscript, mcpStatusInfo, modelOptionsFromSdk, normalizeMediaType, normalizeSdkMessage, peerDirectoryHandle, peerMessageEnvelope, peerSummary, peerToolSpecs, providerAdapter, recentLines, replaySlice, resolveBundledClaudeExecutable, resolveBundledCodexExecutable, runPeerTool, toApiMessage, toExecutionResult, truncateResultBlocks, withHostTools, withMcpTools };
821
952
  //# sourceMappingURL=index.d.mts.map