@workerdeck/core 2.12.0 → 2.13.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 +16 -3
- package/build/index.mjs +48 -6
- package/build/index.mjs.map +1 -1
- package/package.json +3 -3
package/build/index.d.mts
CHANGED
|
@@ -253,6 +253,16 @@ type SubscribeOptions = {
|
|
|
253
253
|
imageRefs?: boolean;
|
|
254
254
|
};
|
|
255
255
|
//#endregion
|
|
256
|
+
//#region src/lib/instructions.d.ts
|
|
257
|
+
type InstructionsContext = {
|
|
258
|
+
sessionId: string;
|
|
259
|
+
cwd?: string;
|
|
260
|
+
profile?: string;
|
|
261
|
+
};
|
|
262
|
+
type SessionInstructions = string | ((context: InstructionsContext) => string);
|
|
263
|
+
declare function resolveInstructions(instructions: SessionInstructions | undefined, context: InstructionsContext): string | undefined;
|
|
264
|
+
declare function composeInstructions(...parts: Array<SessionInstructions | undefined>): SessionInstructions | undefined;
|
|
265
|
+
//#endregion
|
|
256
266
|
//#region src/engines/claude/runner.d.ts
|
|
257
267
|
type QueryFn = (params: {
|
|
258
268
|
prompt: AsyncIterable<SDKUserMessage>;
|
|
@@ -270,6 +280,7 @@ type SessionRunnerConfig = CreateSessionRequest & {
|
|
|
270
280
|
env?: Record<string, string | undefined>;
|
|
271
281
|
pathToClaudeCodeExecutable?: string;
|
|
272
282
|
extraOptions?: Partial<Options>;
|
|
283
|
+
instructions?: SessionInstructions;
|
|
273
284
|
defaultApprovalTimeoutMs?: number | null;
|
|
274
285
|
backfillHistory?: boolean;
|
|
275
286
|
historyFn?: HistoryFn;
|
|
@@ -324,7 +335,7 @@ type AiSdkRunnerConfig = Omit<CreateSessionRequest, 'cwd'> & {
|
|
|
324
335
|
cwd?: string;
|
|
325
336
|
languageModel: LanguageModel$1;
|
|
326
337
|
tools?: ToolSet$1;
|
|
327
|
-
instructions?:
|
|
338
|
+
instructions?: SessionInstructions;
|
|
328
339
|
maxSteps?: number;
|
|
329
340
|
executor?: ToolExecutor;
|
|
330
341
|
executableTools?: string[];
|
|
@@ -631,7 +642,7 @@ type EngineSessionOptions = {
|
|
|
631
642
|
mcp?: McpConnection;
|
|
632
643
|
mcpTools?: ToolSet$1;
|
|
633
644
|
tools?: Record<string, HostToolDefinition>;
|
|
634
|
-
instructions?:
|
|
645
|
+
instructions?: SessionInstructions;
|
|
635
646
|
executionLimits?: {
|
|
636
647
|
timeoutMs?: number;
|
|
637
648
|
memoryLimitBytes?: number;
|
|
@@ -905,6 +916,8 @@ type CodexRunnerConfig = CreateSessionRequest & {
|
|
|
905
916
|
connectFn: AppServerConnectFn;
|
|
906
917
|
env?: Record<string, string | undefined>;
|
|
907
918
|
codexHome?: string;
|
|
919
|
+
codexPathOverride?: string;
|
|
920
|
+
instructions?: SessionInstructions;
|
|
908
921
|
defaultApprovalTimeoutMs?: number | null;
|
|
909
922
|
backfillHistory?: boolean;
|
|
910
923
|
peers?: PeerDirectory;
|
|
@@ -964,5 +977,5 @@ declare class JsonRpcStdioConnection {
|
|
|
964
977
|
//#region src/engines/provider/adapter.d.ts
|
|
965
978
|
declare const providerAdapter: EngineAdapter;
|
|
966
979
|
//#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 };
|
|
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 };
|
|
968
981
|
//# sourceMappingURL=index.d.mts.map
|
package/build/index.mjs
CHANGED
|
@@ -971,6 +971,19 @@ function withTitle(config, title) {
|
|
|
971
971
|
};
|
|
972
972
|
}
|
|
973
973
|
//#endregion
|
|
974
|
+
//#region src/lib/instructions.ts
|
|
975
|
+
function resolveInstructions(instructions, context) {
|
|
976
|
+
if (instructions === void 0) return;
|
|
977
|
+
const text = (typeof instructions === "function" ? instructions(context) : instructions).trim();
|
|
978
|
+
return text === "" ? void 0 : text;
|
|
979
|
+
}
|
|
980
|
+
function composeInstructions(...parts) {
|
|
981
|
+
const present = parts.filter((part) => part !== void 0 && part !== "");
|
|
982
|
+
if (present.length <= 1) return present[0];
|
|
983
|
+
if (present.every((part) => typeof part === "string")) return present.join("\n\n");
|
|
984
|
+
return (context) => present.map((part) => resolveInstructions(part, context)).filter((text) => text !== void 0).join("\n\n");
|
|
985
|
+
}
|
|
986
|
+
//#endregion
|
|
974
987
|
//#region src/lib/peers.ts
|
|
975
988
|
const PEER_MCP_SERVER = "workerdeck";
|
|
976
989
|
const PEER_MESSAGE_MAX_CHARS = 16e3;
|
|
@@ -1343,6 +1356,7 @@ var SessionRunner = class {
|
|
|
1343
1356
|
createdAt;
|
|
1344
1357
|
#config;
|
|
1345
1358
|
#cwd;
|
|
1359
|
+
#instructions;
|
|
1346
1360
|
#log = new EventLog();
|
|
1347
1361
|
#subscribers = new SubscriberSet();
|
|
1348
1362
|
#tasks = new TaskChecklist();
|
|
@@ -1379,6 +1393,12 @@ var SessionRunner = class {
|
|
|
1379
1393
|
this.#permissionMode = config.permissionMode;
|
|
1380
1394
|
this.id = id;
|
|
1381
1395
|
this.createdAt = Date.now();
|
|
1396
|
+
this.#instructions = resolveInstructions(config.instructions, {
|
|
1397
|
+
sessionId: id,
|
|
1398
|
+
cwd: config.cwd,
|
|
1399
|
+
profile: config.profile
|
|
1400
|
+
});
|
|
1401
|
+
if (this.#instructions !== void 0 && config.extraOptions?.systemPrompt !== void 0) throw new Error("instructions and extraOptions.systemPrompt both set - the host must pick one");
|
|
1382
1402
|
}
|
|
1383
1403
|
get status() {
|
|
1384
1404
|
return this.#status;
|
|
@@ -1661,7 +1681,12 @@ var SessionRunner = class {
|
|
|
1661
1681
|
env: c.env,
|
|
1662
1682
|
pathToClaudeCodeExecutable: c.pathToClaudeCodeExecutable,
|
|
1663
1683
|
...c.permissionMode === "bypassPermissions" || c.allowDangerouslySkipPermissions ? { allowDangerouslySkipPermissions: true } : {},
|
|
1664
|
-
...c.extraOptions
|
|
1684
|
+
...c.extraOptions,
|
|
1685
|
+
...this.#instructions === void 0 ? {} : { systemPrompt: {
|
|
1686
|
+
type: "preset",
|
|
1687
|
+
preset: "claude_code",
|
|
1688
|
+
append: this.#instructions
|
|
1689
|
+
} }
|
|
1665
1690
|
};
|
|
1666
1691
|
}
|
|
1667
1692
|
#mcpServersOption() {
|
|
@@ -2046,6 +2071,7 @@ var AiSdkRunner = class {
|
|
|
2046
2071
|
id;
|
|
2047
2072
|
createdAt;
|
|
2048
2073
|
#config;
|
|
2074
|
+
#instructions;
|
|
2049
2075
|
#model;
|
|
2050
2076
|
#log = new EventLog();
|
|
2051
2077
|
#subscribers = new SubscriberSet();
|
|
@@ -2075,6 +2101,11 @@ var AiSdkRunner = class {
|
|
|
2075
2101
|
this.#modelAlias = config.model;
|
|
2076
2102
|
this.id = config.restore?.id ?? id;
|
|
2077
2103
|
this.createdAt = config.restore?.createdAt ?? Date.now();
|
|
2104
|
+
this.#instructions = resolveInstructions(config.instructions, {
|
|
2105
|
+
sessionId: this.id,
|
|
2106
|
+
cwd: config.cwd,
|
|
2107
|
+
profile: config.profile
|
|
2108
|
+
});
|
|
2078
2109
|
if (config.restore) this.#restore(config.restore);
|
|
2079
2110
|
}
|
|
2080
2111
|
#restore(snapshot) {
|
|
@@ -2646,7 +2677,7 @@ var AiSdkRunner = class {
|
|
|
2646
2677
|
const agent = new ToolLoopAgent({
|
|
2647
2678
|
model: this.#model,
|
|
2648
2679
|
tools: this.#config.tools ?? {},
|
|
2649
|
-
instructions: this.#
|
|
2680
|
+
instructions: this.#instructions,
|
|
2650
2681
|
stopWhen: isStepCount(this.#config.maxSteps ?? 20)
|
|
2651
2682
|
});
|
|
2652
2683
|
const abort = new AbortController();
|
|
@@ -3718,7 +3749,7 @@ function createEngineSession(options) {
|
|
|
3718
3749
|
runner = new AiSdkRunner({
|
|
3719
3750
|
...options.config,
|
|
3720
3751
|
languageModel: options.resolveModel(options.profile, options.config),
|
|
3721
|
-
instructions: options.profile?.session?.instructions
|
|
3752
|
+
instructions: composeInstructions(options.profile?.session?.instructions, options.instructions, options.config.instructions),
|
|
3722
3753
|
tools: context.tools,
|
|
3723
3754
|
vfs,
|
|
3724
3755
|
executor,
|
|
@@ -3954,9 +3985,12 @@ const claudeAdapter = {
|
|
|
3954
3985
|
};
|
|
3955
3986
|
return { available: "unknown" };
|
|
3956
3987
|
},
|
|
3957
|
-
createRunner({ config, restore, id }) {
|
|
3988
|
+
createRunner({ config, profile, restore, id }) {
|
|
3958
3989
|
if (restore) throw new Error("the Claude engine cannot rebuild a parked session");
|
|
3959
|
-
return new SessionRunner(
|
|
3990
|
+
return new SessionRunner({
|
|
3991
|
+
...config,
|
|
3992
|
+
instructions: composeInstructions(profile?.session?.instructions, config.instructions)
|
|
3993
|
+
}, id);
|
|
3960
3994
|
},
|
|
3961
3995
|
async listSessions({ dir, limit, offset }) {
|
|
3962
3996
|
return (await listSessions({
|
|
@@ -4771,6 +4805,7 @@ var CodexRunner = class {
|
|
|
4771
4805
|
createdAt;
|
|
4772
4806
|
#config;
|
|
4773
4807
|
#cwd;
|
|
4808
|
+
#instructions;
|
|
4774
4809
|
#log = new EventLog();
|
|
4775
4810
|
#subscribers = new SubscriberSet();
|
|
4776
4811
|
#status = "starting";
|
|
@@ -4827,6 +4862,11 @@ var CodexRunner = class {
|
|
|
4827
4862
|
this.#threadMaterialized = config.resume !== void 0;
|
|
4828
4863
|
this.id = id;
|
|
4829
4864
|
this.createdAt = Date.now();
|
|
4865
|
+
this.#instructions = resolveInstructions(config.instructions, {
|
|
4866
|
+
sessionId: id,
|
|
4867
|
+
cwd: config.cwd,
|
|
4868
|
+
profile: config.profile
|
|
4869
|
+
});
|
|
4830
4870
|
}
|
|
4831
4871
|
#childEnv() {
|
|
4832
4872
|
return codexChildEnv(this.#config.env ?? process.env, this.#config.codexHome);
|
|
@@ -5252,6 +5292,7 @@ var CodexRunner = class {
|
|
|
5252
5292
|
approvalsReviewer: APPROVALS_REVIEWER_BY_MODE[this.#permissionMode]
|
|
5253
5293
|
};
|
|
5254
5294
|
if (this.#model) options.model = this.#model;
|
|
5295
|
+
if (this.#instructions !== void 0) options.developerInstructions = this.#instructions;
|
|
5255
5296
|
if (this.#config.peers) options.dynamicTools = peerToolSpecs().map((spec) => ({
|
|
5256
5297
|
type: "function",
|
|
5257
5298
|
...spec
|
|
@@ -6391,6 +6432,7 @@ const codexAdapter = {
|
|
|
6391
6432
|
return new CodexRunner({
|
|
6392
6433
|
...config,
|
|
6393
6434
|
codexHome: profile?.codexHome,
|
|
6435
|
+
instructions: composeInstructions(profile?.session?.instructions, config.instructions),
|
|
6394
6436
|
connectFn: (options) => connectAppServer({
|
|
6395
6437
|
executable,
|
|
6396
6438
|
...options
|
|
@@ -6443,6 +6485,6 @@ function getEngineAdapter(engine) {
|
|
|
6443
6485
|
return ADAPTERS[engine ?? "claude"];
|
|
6444
6486
|
}
|
|
6445
6487
|
//#endregion
|
|
6446
|
-
export { AiSdkRunner, BrowserBridgeExecutor, CLAUDE_CATALOG, CODEX_CATALOG, CodexRunner, CostLedger, DeferredExecutor, InputQueue, JsonRpcError, JsonRpcStdioConnection, PEER_MCP_SERVER, PEER_MESSAGE_MAX_CHARS, PEER_RECENT_DEFAULT, PEER_RECENT_MAX, PEER_TOOL_NAMES, PendingRequestRegistry, QuickJsExecutor, SUPPORTED_ATTACHMENT_TYPES, SessionRunner, 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 };
|
|
6488
|
+
export { AiSdkRunner, BrowserBridgeExecutor, CLAUDE_CATALOG, CODEX_CATALOG, CodexRunner, CostLedger, DeferredExecutor, InputQueue, JsonRpcError, JsonRpcStdioConnection, PEER_MCP_SERVER, PEER_MESSAGE_MAX_CHARS, PEER_RECENT_DEFAULT, PEER_RECENT_MAX, PEER_TOOL_NAMES, PendingRequestRegistry, QuickJsExecutor, SUPPORTED_ATTACHMENT_TYPES, SessionRunner, 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 };
|
|
6447
6489
|
|
|
6448
6490
|
//# sourceMappingURL=index.mjs.map
|