@workerdeck/core 2.12.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>;
@@ -253,6 +281,87 @@ type SubscribeOptions = {
253
281
  imageRefs?: boolean;
254
282
  };
255
283
  //#endregion
284
+ //#region src/lib/instructions.d.ts
285
+ type InstructionsContext = {
286
+ sessionId: string;
287
+ cwd?: string;
288
+ profile?: string;
289
+ };
290
+ type SessionInstructions = string | ((context: InstructionsContext) => string);
291
+ declare function resolveInstructions(instructions: SessionInstructions | undefined, context: InstructionsContext): string | undefined;
292
+ declare function composeInstructions(...parts: Array<SessionInstructions | undefined>): SessionInstructions | undefined;
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
256
365
  //#region src/engines/claude/runner.d.ts
257
366
  type QueryFn = (params: {
258
367
  prompt: AsyncIterable<SDKUserMessage>;
@@ -270,11 +379,13 @@ type SessionRunnerConfig = CreateSessionRequest & {
270
379
  env?: Record<string, string | undefined>;
271
380
  pathToClaudeCodeExecutable?: string;
272
381
  extraOptions?: Partial<Options>;
382
+ instructions?: SessionInstructions;
273
383
  defaultApprovalTimeoutMs?: number | null;
274
384
  backfillHistory?: boolean;
275
385
  historyFn?: HistoryFn;
276
386
  sessionInfoFn?: SessionInfoFn;
277
387
  peers?: PeerDirectory;
388
+ shells?: ShellDirectory;
278
389
  };
279
390
  declare class SessionRunner implements Runner {
280
391
  #private;
@@ -292,7 +403,7 @@ declare class SessionRunner implements Runner {
292
403
  costState(): CostLedgerState;
293
404
  start(): Promise<void>;
294
405
  sendMessage(text: string, attachments?: readonly AttachmentInput[], options?: SendMessageOptions): void;
295
- queueLocalCommand(result: LocalCommandResult): void;
406
+ queueLocalCommand(input: LocalCommandResult | LocalShellSource): void;
296
407
  mcpServers(): Promise<McpServerStatusInfo[] | undefined>;
297
408
  reconnectMcpServer(name: string): Promise<void>;
298
409
  setMcpServerEnabled(name: string, enabled: boolean): Promise<void>;
@@ -324,7 +435,7 @@ type AiSdkRunnerConfig = Omit<CreateSessionRequest, 'cwd'> & {
324
435
  cwd?: string;
325
436
  languageModel: LanguageModel$1;
326
437
  tools?: ToolSet$1;
327
- instructions?: string;
438
+ instructions?: SessionInstructions;
328
439
  maxSteps?: number;
329
440
  executor?: ToolExecutor;
330
441
  executableTools?: string[];
@@ -345,6 +456,7 @@ type AiSdkRunnerConfig = Omit<CreateSessionRequest, 'cwd'> & {
345
456
  onClose?: () => void | Promise<void>;
346
457
  restore?: RunnerSnapshot;
347
458
  peers?: PeerDirectory;
459
+ shells?: ShellDirectory;
348
460
  };
349
461
  type PendingToolCall = {
350
462
  toolCallId: string;
@@ -396,7 +508,7 @@ declare class AiSdkRunner implements Runner {
396
508
  park(): RunnerSnapshot | undefined;
397
509
  snapshot(): RunnerSnapshot | undefined;
398
510
  sendMessage(text: string, attachments?: readonly AttachmentInput[], options?: SendMessageOptions): void;
399
- queueLocalCommand(result: LocalCommandResult): void;
511
+ queueLocalCommand(input: LocalCommandResult | LocalShellSource): void;
400
512
  resolveToolCall(toolCallId: string, output: ToolCallOutput, options?: {
401
513
  isError?: boolean;
402
514
  }): boolean;
@@ -596,6 +708,7 @@ type ToolContextOptions = {
596
708
  onDispatch?: (executionId: string, toolName: string) => void;
597
709
  onSettle?: (executionId: string, result: ToolExecutionResult) => void;
598
710
  peers?: PeerDirectory;
711
+ shells?: ShellDirectory;
599
712
  selfId?: () => string;
600
713
  };
601
714
  type ToolContext = {
@@ -631,7 +744,7 @@ type EngineSessionOptions = {
631
744
  mcp?: McpConnection;
632
745
  mcpTools?: ToolSet$1;
633
746
  tools?: Record<string, HostToolDefinition>;
634
- instructions?: string;
747
+ instructions?: SessionInstructions;
635
748
  executionLimits?: {
636
749
  timeoutMs?: number;
637
750
  memoryLimitBytes?: number;
@@ -663,6 +776,25 @@ declare class InputQueue implements AsyncIterable<SDKUserMessage> {
663
776
  [Symbol.asyncIterator](): AsyncIterator<SDKUserMessage>;
664
777
  }
665
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
666
798
  //#region src/lib/normalize.d.ts
667
799
  declare function toApiMessage(message: unknown): ApiMessage;
668
800
  declare function mcpStatusInfo(status: McpServerStatus): McpServerStatusInfo;
@@ -905,9 +1037,12 @@ type CodexRunnerConfig = CreateSessionRequest & {
905
1037
  connectFn: AppServerConnectFn;
906
1038
  env?: Record<string, string | undefined>;
907
1039
  codexHome?: string;
1040
+ codexPathOverride?: string;
1041
+ instructions?: SessionInstructions;
908
1042
  defaultApprovalTimeoutMs?: number | null;
909
1043
  backfillHistory?: boolean;
910
1044
  peers?: PeerDirectory;
1045
+ shells?: ShellDirectory;
911
1046
  };
912
1047
  declare class CodexRunner implements Runner {
913
1048
  #private;
@@ -924,7 +1059,7 @@ declare class CodexRunner implements Runner {
924
1059
  costState(): CostLedgerState;
925
1060
  start(): Promise<void>;
926
1061
  sendMessage(text: string, attachments?: readonly AttachmentInput[], options?: SendMessageOptions): void;
927
- queueLocalCommand(result: LocalCommandResult): void;
1062
+ queueLocalCommand(input: LocalCommandResult | LocalShellSource): void;
928
1063
  resolvePermission(requestId: string, decision: PermissionDecision): boolean;
929
1064
  interrupt(): Promise<void>;
930
1065
  clearContext(): Promise<void>;
@@ -964,5 +1099,5 @@ declare class JsonRpcStdioConnection {
964
1099
  //#region src/engines/provider/adapter.d.ts
965
1100
  declare const providerAdapter: EngineAdapter;
966
1101
  //#endregion
967
- 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 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, 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, isSlashCommand, listCodexSessions, localCommandContext, localCommandTranscript, mcpStatusInfo, modelOptionsFromSdk, normalizeMediaType, normalizeSdkMessage, peerDirectoryHandle, peerMentionsEnvelope, peerMessageEnvelope, peerSummary, peerToolSpecs, providerAdapter, recentLines, replaySlice, resolveBundledClaudeExecutable, resolveBundledCodexExecutable, 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 };
968
1103
  //# sourceMappingURL=index.d.mts.map