@workerdeck/core 2.13.0 → 2.14.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,5 @@
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, MessageOrigin, 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, ShellEndReason, ShellInfo, ShellOwner, ShellStatus, ToolCallRequestFrame, ToolExecutionBackend, ToolExecutionOutput } from "@workerdeck/protocol";
3
3
  import { z } from "zod";
4
4
  import { LanguageModel, LanguageModel as LanguageModel$1, ModelMessage, Tool, Tool as Tool$1, ToolSet, ToolSet as ToolSet$1 } from "ai";
5
5
  import { SandboxEngine, SandboxVfs } from "@workerdeck/sandbox";
@@ -22,9 +22,37 @@ type LocalCommandResult = {
22
22
  stderr: string;
23
23
  exitCode: number;
24
24
  };
25
+ type LocalShellSource = {
26
+ info(): ShellInfo;
27
+ text(): string;
28
+ subscribe(listener: () => void): () => void;
29
+ };
30
+ type ShellContextOptions = {
31
+ previous?: {
32
+ lines: number;
33
+ };
34
+ collapsed?: boolean;
35
+ };
36
+ type LocalCommandEvent = Extract<SessionEventBody, {
37
+ type: 'user_message';
38
+ }>;
39
+ type LocalCommandEmit = (text: string, uuid: string, shell: ShellInfo | undefined) => void;
25
40
  declare function localCommandTranscript(result: LocalCommandResult): string;
26
41
  declare function localCommandContext(pending: readonly string[]): string | undefined;
27
42
  declare function isSlashCommand(text: string): boolean;
43
+ declare function isLocalShellSource(input: LocalCommandResult | LocalShellSource): input is LocalShellSource;
44
+ declare function localCommandEvent(text: string, uuid: string, shell: ShellInfo | undefined): LocalCommandEvent;
45
+ declare function shellInlineText(shell: ShellInfo, text: string): string;
46
+ declare function shellContextText(shell: ShellInfo, text: string, options?: ShellContextOptions): string;
47
+ declare class LocalCommandQueue {
48
+ #private;
49
+ constructor(emit: LocalCommandEmit);
50
+ push(input: LocalCommandResult | LocalShellSource): void;
51
+ take(): string | undefined;
52
+ materialize(): string[];
53
+ restore(texts: readonly string[]): void;
54
+ clear(): void;
55
+ }
28
56
  //#endregion
29
57
  //#region src/lib/cost-ledger.d.ts
30
58
  type CostFigures = {
@@ -226,7 +254,7 @@ interface Runner {
226
254
  }): () => void;
227
255
  eventAt?(seq: number): SessionEvent | undefined;
228
256
  sendMessage(text: string, attachments?: readonly AttachmentInput[], options?: SendMessageOptions): void;
229
- queueLocalCommand?(result: LocalCommandResult): void;
257
+ queueLocalCommand?(input: LocalCommandResult | LocalShellSource): void;
230
258
  refreshUsage?(): Promise<void>;
231
259
  mcpServers?(): Promise<McpServerStatusInfo[] | undefined>;
232
260
  reconnectMcpServer?(name: string): Promise<void>;
@@ -263,6 +291,77 @@ type SessionInstructions = string | ((context: InstructionsContext) => string);
263
291
  declare function resolveInstructions(instructions: SessionInstructions | undefined, context: InstructionsContext): string | undefined;
264
292
  declare function composeInstructions(...parts: Array<SessionInstructions | undefined>): SessionInstructions | undefined;
265
293
  //#endregion
294
+ //#region src/lib/shells.d.ts
295
+ type ShellSummary = {
296
+ id: string;
297
+ ordinal: number;
298
+ command: string;
299
+ label: string;
300
+ cwd: string;
301
+ owner: ShellOwner;
302
+ status: ShellStatus;
303
+ startedAt: number;
304
+ endedAt?: number;
305
+ exitCode?: number;
306
+ endReason?: ShellEndReason;
307
+ bytes: number;
308
+ capped?: boolean;
309
+ };
310
+ type ShellReadResult = {
311
+ shell: ShellSummary;
312
+ text: string;
313
+ lines: number;
314
+ totalLines: number;
315
+ truncated: boolean;
316
+ };
317
+ type ShellReadOptions = {
318
+ tail?: number;
319
+ };
320
+ interface ShellDirectory {
321
+ list(from: string): Promise<ShellSummary[]>;
322
+ read(from: string, shellId: string, options?: ShellReadOptions): Promise<ShellReadResult | undefined>;
323
+ }
324
+ declare const SHELL_REFUSAL = "shell commands are not available on this session";
325
+ declare const SHELL_TOOL_SHAPES: {
326
+ readonly shell_list: {
327
+ readonly description: string;
328
+ readonly shape: {};
329
+ };
330
+ readonly shell_read: {
331
+ readonly description: string;
332
+ readonly shape: {
333
+ readonly shellId: z.ZodString;
334
+ readonly tail: z.ZodOptional<z.ZodNumber>;
335
+ };
336
+ };
337
+ };
338
+ type ShellToolName = keyof typeof SHELL_TOOL_SHAPES;
339
+ declare const SHELL_TOOL_NAMES: ShellToolName[];
340
+ type ShellToolSpec = {
341
+ name: ShellToolName;
342
+ description: string;
343
+ inputSchema: Record<string, unknown>;
344
+ };
345
+ type ShellToolOutput = {
346
+ text: string;
347
+ isError: boolean;
348
+ };
349
+ declare function shellToolSpecs(): ShellToolSpec[];
350
+ declare function isShellToolName(name: string): name is ShellToolName;
351
+ declare function clampShellTail(tail: number | undefined): number;
352
+ declare function shellSummary(info: ShellInfo): ShellSummary;
353
+ declare function shellTail(text: string, tail: number): {
354
+ text: string;
355
+ lines: number;
356
+ totalLines: number;
357
+ truncated: boolean;
358
+ };
359
+ declare function runShellTool(shells: ShellDirectory, from: string, name: string, args: unknown): Promise<ShellToolOutput>;
360
+ declare function shellReadText(result: ShellReadResult): string;
361
+ declare function installShellDirectory(directory: ShellDirectory | undefined): void;
362
+ declare function installedShellDirectory(): ShellDirectory | undefined;
363
+ declare function shellDirectoryHandle(): ShellDirectory;
364
+ //#endregion
266
365
  //#region src/engines/claude/runner.d.ts
267
366
  type QueryFn = (params: {
268
367
  prompt: AsyncIterable<SDKUserMessage>;
@@ -286,6 +385,7 @@ type SessionRunnerConfig = CreateSessionRequest & {
286
385
  historyFn?: HistoryFn;
287
386
  sessionInfoFn?: SessionInfoFn;
288
387
  peers?: PeerDirectory;
388
+ shells?: ShellDirectory;
289
389
  };
290
390
  declare class SessionRunner implements Runner {
291
391
  #private;
@@ -303,7 +403,7 @@ declare class SessionRunner implements Runner {
303
403
  costState(): CostLedgerState;
304
404
  start(): Promise<void>;
305
405
  sendMessage(text: string, attachments?: readonly AttachmentInput[], options?: SendMessageOptions): void;
306
- queueLocalCommand(result: LocalCommandResult): void;
406
+ queueLocalCommand(input: LocalCommandResult | LocalShellSource): void;
307
407
  mcpServers(): Promise<McpServerStatusInfo[] | undefined>;
308
408
  reconnectMcpServer(name: string): Promise<void>;
309
409
  setMcpServerEnabled(name: string, enabled: boolean): Promise<void>;
@@ -356,6 +456,7 @@ type AiSdkRunnerConfig = Omit<CreateSessionRequest, 'cwd'> & {
356
456
  onClose?: () => void | Promise<void>;
357
457
  restore?: RunnerSnapshot;
358
458
  peers?: PeerDirectory;
459
+ shells?: ShellDirectory;
359
460
  };
360
461
  type PendingToolCall = {
361
462
  toolCallId: string;
@@ -407,7 +508,7 @@ declare class AiSdkRunner implements Runner {
407
508
  park(): RunnerSnapshot | undefined;
408
509
  snapshot(): RunnerSnapshot | undefined;
409
510
  sendMessage(text: string, attachments?: readonly AttachmentInput[], options?: SendMessageOptions): void;
410
- queueLocalCommand(result: LocalCommandResult): void;
511
+ queueLocalCommand(input: LocalCommandResult | LocalShellSource): void;
411
512
  resolveToolCall(toolCallId: string, output: ToolCallOutput, options?: {
412
513
  isError?: boolean;
413
514
  }): boolean;
@@ -607,6 +708,7 @@ type ToolContextOptions = {
607
708
  onDispatch?: (executionId: string, toolName: string) => void;
608
709
  onSettle?: (executionId: string, result: ToolExecutionResult) => void;
609
710
  peers?: PeerDirectory;
711
+ shells?: ShellDirectory;
610
712
  selfId?: () => string;
611
713
  };
612
714
  type ToolContext = {
@@ -674,6 +776,25 @@ declare class InputQueue implements AsyncIterable<SDKUserMessage> {
674
776
  [Symbol.asyncIterator](): AsyncIterator<SDKUserMessage>;
675
777
  }
676
778
  //#endregion
779
+ //#region src/lib/tty-text.d.ts
780
+ type HeadTailOptions = {
781
+ headLines: number;
782
+ headChars: number;
783
+ tailLines: number;
784
+ tailChars: number;
785
+ };
786
+ type HeadTail = {
787
+ head: string;
788
+ tail: string;
789
+ omittedLines: number;
790
+ totalLines: number;
791
+ totalBytes: number;
792
+ };
793
+ declare function ttyText(raw: string): string;
794
+ declare function splitLines(text: string): string[];
795
+ declare function countLines(text: string): number;
796
+ declare function headTail(text: string, opts: HeadTailOptions): HeadTail;
797
+ //#endregion
677
798
  //#region src/lib/normalize.d.ts
678
799
  declare function toApiMessage(message: unknown): ApiMessage;
679
800
  declare function mcpStatusInfo(status: McpServerStatus): McpServerStatusInfo;
@@ -921,6 +1042,7 @@ type CodexRunnerConfig = CreateSessionRequest & {
921
1042
  defaultApprovalTimeoutMs?: number | null;
922
1043
  backfillHistory?: boolean;
923
1044
  peers?: PeerDirectory;
1045
+ shells?: ShellDirectory;
924
1046
  };
925
1047
  declare class CodexRunner implements Runner {
926
1048
  #private;
@@ -937,7 +1059,7 @@ declare class CodexRunner implements Runner {
937
1059
  costState(): CostLedgerState;
938
1060
  start(): Promise<void>;
939
1061
  sendMessage(text: string, attachments?: readonly AttachmentInput[], options?: SendMessageOptions): void;
940
- queueLocalCommand(result: LocalCommandResult): void;
1062
+ queueLocalCommand(input: LocalCommandResult | LocalShellSource): void;
941
1063
  resolvePermission(requestId: string, decision: PermissionDecision): boolean;
942
1064
  interrupt(): Promise<void>;
943
1065
  clearContext(): Promise<void>;
@@ -977,5 +1099,5 @@ declare class JsonRpcStdioConnection {
977
1099
  //#region src/engines/provider/adapter.d.ts
978
1100
  declare const providerAdapter: EngineAdapter;
979
1101
  //#endregion
980
- 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, type InstructionsContext, 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 PeerMention, 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, type SessionInstructions, 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, composeInstructions, connectAppServer, connectMcpTools, createEngineSession, createToolContext, createWebFetch, getEngineAdapter, htmlToMarkdown, installPeerDirectory, installedPeerDirectory, isHostAllowed, isPrivateAddress, isSlashCommand, listCodexSessions, localCommandContext, localCommandTranscript, mcpStatusInfo, modelOptionsFromSdk, normalizeMediaType, normalizeSdkMessage, peerDirectoryHandle, peerMentionsEnvelope, peerMessageEnvelope, peerSummary, peerToolSpecs, providerAdapter, recentLines, replaySlice, resolveBundledClaudeExecutable, resolveBundledCodexExecutable, resolveInstructions, runPeerTool, toApiMessage, toExecutionResult, truncateResultBlocks, withHostTools, withMcpTools, withPeerContext };
1102
+ 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 HeadTail, type HeadTailOptions, type HistoryFn, type HostFetch, type HostToolDefinition, InputQueue, type InstructionsContext, JsonRpcError, JsonRpcStdioConnection, type LanguageModel, type LocalCommandEmit, type LocalCommandEvent, LocalCommandQueue, type LocalCommandResult, type LocalShellSource, 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 PeerMention, 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, SHELL_REFUSAL, SHELL_TOOL_NAMES, SHELL_TOOL_SHAPES, SUPPORTED_ATTACHMENT_TYPES, type SendMessageOptions, type SessionEventListener, type SessionInstructions, SessionRunner, type SessionRunnerConfig, type SettledBy, type ShellContextOptions, type ShellDirectory, type ShellReadOptions, type ShellReadResult, type ShellSummary, type ShellToolName, type ShellToolOutput, type ShellToolSpec, 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, clampShellTail, claudeAdapter, codexAdapter, composeInstructions, connectAppServer, connectMcpTools, countLines, createEngineSession, createToolContext, createWebFetch, getEngineAdapter, headTail, htmlToMarkdown, installPeerDirectory, installShellDirectory, installedPeerDirectory, installedShellDirectory, isHostAllowed, isLocalShellSource, isPrivateAddress, isShellToolName, isSlashCommand, listCodexSessions, localCommandContext, localCommandEvent, localCommandTranscript, mcpStatusInfo, modelOptionsFromSdk, normalizeMediaType, normalizeSdkMessage, peerDirectoryHandle, peerMentionsEnvelope, peerMessageEnvelope, peerSummary, peerToolSpecs, providerAdapter, recentLines, replaySlice, resolveBundledClaudeExecutable, resolveBundledCodexExecutable, resolveInstructions, runPeerTool, runShellTool, shellContextText, shellDirectoryHandle, shellInlineText, shellReadText, shellSummary, shellTail, shellToolSpecs, splitLines, toApiMessage, toExecutionResult, truncateResultBlocks, ttyText, withHostTools, withMcpTools, withPeerContext };
981
1103
  //# sourceMappingURL=index.d.mts.map