@workerdeck/core 2.10.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 +110 -7
- package/build/index.mjs +444 -57
- package/build/index.mjs.map +1 -1
- package/package.json +3 -3
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, ByModel, CostBreakdown, 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";
|
|
@@ -104,6 +105,9 @@ type RunnerSnapshot = {
|
|
|
104
105
|
parked: ParkedExecution[];
|
|
105
106
|
state: unknown;
|
|
106
107
|
};
|
|
108
|
+
type SendMessageOptions = {
|
|
109
|
+
origin?: MessageOrigin;
|
|
110
|
+
};
|
|
107
111
|
type PermissionDecision = {
|
|
108
112
|
behavior: 'allow';
|
|
109
113
|
updatedInput?: Record<string, unknown>;
|
|
@@ -124,7 +128,7 @@ interface Runner {
|
|
|
124
128
|
imageRefs?: boolean;
|
|
125
129
|
}): () => void;
|
|
126
130
|
eventAt?(seq: number): SessionEvent | undefined;
|
|
127
|
-
sendMessage(text: string, attachments?: readonly AttachmentInput[]): void;
|
|
131
|
+
sendMessage(text: string, attachments?: readonly AttachmentInput[], options?: SendMessageOptions): void;
|
|
128
132
|
queueLocalCommand?(result: LocalCommandResult): void;
|
|
129
133
|
refreshUsage?(): Promise<void>;
|
|
130
134
|
mcpServers?(): Promise<McpServerStatusInfo[] | undefined>;
|
|
@@ -152,6 +156,87 @@ type SubscribeOptions = {
|
|
|
152
156
|
imageRefs?: boolean;
|
|
153
157
|
};
|
|
154
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
|
|
155
240
|
//#region src/engines/claude/runner.d.ts
|
|
156
241
|
type QueryFn = (params: {
|
|
157
242
|
prompt: AsyncIterable<SDKUserMessage>;
|
|
@@ -173,6 +258,7 @@ type SessionRunnerConfig = CreateSessionRequest & {
|
|
|
173
258
|
backfillHistory?: boolean;
|
|
174
259
|
historyFn?: HistoryFn;
|
|
175
260
|
sessionInfoFn?: SessionInfoFn;
|
|
261
|
+
peers?: PeerDirectory;
|
|
176
262
|
};
|
|
177
263
|
declare class SessionRunner implements Runner {
|
|
178
264
|
#private;
|
|
@@ -189,7 +275,7 @@ declare class SessionRunner implements Runner {
|
|
|
189
275
|
carryCost(state: CostLedgerState): void;
|
|
190
276
|
costState(): CostLedgerState;
|
|
191
277
|
start(): Promise<void>;
|
|
192
|
-
sendMessage(text: string, attachments?: readonly AttachmentInput[]): void;
|
|
278
|
+
sendMessage(text: string, attachments?: readonly AttachmentInput[], options?: SendMessageOptions): void;
|
|
193
279
|
queueLocalCommand(result: LocalCommandResult): void;
|
|
194
280
|
mcpServers(): Promise<McpServerStatusInfo[] | undefined>;
|
|
195
281
|
reconnectMcpServer(name: string): Promise<void>;
|
|
@@ -242,6 +328,7 @@ type AiSdkRunnerConfig = Omit<CreateSessionRequest, 'cwd'> & {
|
|
|
242
328
|
reportMcpServers?: () => Promise<McpServerStatusInfo[] | undefined>;
|
|
243
329
|
onClose?: () => void | Promise<void>;
|
|
244
330
|
restore?: RunnerSnapshot;
|
|
331
|
+
peers?: PeerDirectory;
|
|
245
332
|
};
|
|
246
333
|
type PendingToolCall = {
|
|
247
334
|
toolCallId: string;
|
|
@@ -292,7 +379,7 @@ declare class AiSdkRunner implements Runner {
|
|
|
292
379
|
start(): Promise<void>;
|
|
293
380
|
park(): RunnerSnapshot | undefined;
|
|
294
381
|
snapshot(): RunnerSnapshot | undefined;
|
|
295
|
-
sendMessage(text: string, attachments?: readonly AttachmentInput[]): void;
|
|
382
|
+
sendMessage(text: string, attachments?: readonly AttachmentInput[], options?: SendMessageOptions): void;
|
|
296
383
|
queueLocalCommand(result: LocalCommandResult): void;
|
|
297
384
|
resolveToolCall(toolCallId: string, output: ToolCallOutput, options?: {
|
|
298
385
|
isError?: boolean;
|
|
@@ -492,6 +579,8 @@ type ToolContextOptions = {
|
|
|
492
579
|
};
|
|
493
580
|
onDispatch?: (executionId: string, toolName: string) => void;
|
|
494
581
|
onSettle?: (executionId: string, result: ToolExecutionResult) => void;
|
|
582
|
+
peers?: PeerDirectory;
|
|
583
|
+
selfId?: () => string;
|
|
495
584
|
};
|
|
496
585
|
type ToolContext = {
|
|
497
586
|
vfs: SandboxVfs;
|
|
@@ -702,6 +791,19 @@ type AppServerCollabAgentToolCallItem = {
|
|
|
702
791
|
reasoningEffort?: string | null;
|
|
703
792
|
agentsStates?: Record<string, unknown> | null;
|
|
704
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
|
+
};
|
|
705
807
|
type AppServerUserMessageItem = {
|
|
706
808
|
id: string;
|
|
707
809
|
type: 'userMessage';
|
|
@@ -711,7 +813,7 @@ type AppServerContextCompactionItem = {
|
|
|
711
813
|
id: string;
|
|
712
814
|
type: 'contextCompaction';
|
|
713
815
|
};
|
|
714
|
-
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;
|
|
715
817
|
type AppServerTurn = {
|
|
716
818
|
id: string;
|
|
717
819
|
status: string;
|
|
@@ -789,6 +891,7 @@ type CodexRunnerConfig = CreateSessionRequest & {
|
|
|
789
891
|
codexHome?: string;
|
|
790
892
|
defaultApprovalTimeoutMs?: number | null;
|
|
791
893
|
backfillHistory?: boolean;
|
|
894
|
+
peers?: PeerDirectory;
|
|
792
895
|
};
|
|
793
896
|
declare class CodexRunner implements Runner {
|
|
794
897
|
#private;
|
|
@@ -804,7 +907,7 @@ declare class CodexRunner implements Runner {
|
|
|
804
907
|
carryCost(state: CostLedgerState): void;
|
|
805
908
|
costState(): CostLedgerState;
|
|
806
909
|
start(): Promise<void>;
|
|
807
|
-
sendMessage(text: string, attachments?: readonly AttachmentInput[]): void;
|
|
910
|
+
sendMessage(text: string, attachments?: readonly AttachmentInput[], options?: SendMessageOptions): void;
|
|
808
911
|
queueLocalCommand(result: LocalCommandResult): void;
|
|
809
912
|
resolvePermission(requestId: string, decision: PermissionDecision): boolean;
|
|
810
913
|
interrupt(): Promise<void>;
|
|
@@ -845,5 +948,5 @@ declare class JsonRpcStdioConnection {
|
|
|
845
948
|
//#region src/engines/provider/adapter.d.ts
|
|
846
949
|
declare const providerAdapter: EngineAdapter;
|
|
847
950
|
//#endregion
|
|
848
|
-
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, 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 };
|
|
849
952
|
//# sourceMappingURL=index.d.mts.map
|