@bastani/atomic 0.10.1 → 0.10.2-alpha.1
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/CHANGELOG.md +27 -0
- package/dist/builtin/intercom/CHANGELOG.md +6 -0
- package/dist/builtin/intercom/broker/watchdog.ts +4 -0
- package/dist/builtin/intercom/package.json +1 -1
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/CHANGELOG.md +16 -0
- package/dist/builtin/subagents/README.md +2 -0
- package/dist/builtin/subagents/package.json +1 -1
- package/dist/builtin/subagents/skills/subagent/SKILL.md +3 -3
- package/dist/builtin/subagents/src/extension/index.bundle.mjs +269 -144
- package/dist/builtin/web-access/CHANGELOG.md +7 -0
- package/dist/builtin/web-access/index.bundle.mjs +9 -5
- package/dist/builtin/web-access/package.json +1 -1
- package/dist/cli/list-models.d.ts.map +1 -1
- package/dist/cli/list-models.js +1 -14
- package/dist/cli/list-models.js.map +1 -1
- package/dist/core/agent-session-export.d.ts.map +1 -1
- package/dist/core/agent-session-export.js +13 -9
- package/dist/core/agent-session-export.js.map +1 -1
- package/dist/core/agent-session-message-queue.d.ts.map +1 -1
- package/dist/core/agent-session-message-queue.js +6 -3
- package/dist/core/agent-session-message-queue.js.map +1 -1
- package/dist/core/agent-session-methods.d.ts +3 -0
- package/dist/core/agent-session-methods.d.ts.map +1 -1
- package/dist/core/agent-session-methods.js.map +1 -1
- package/dist/core/agent-session-nested-tools.d.ts.map +1 -1
- package/dist/core/agent-session-nested-tools.js +2 -1
- package/dist/core/agent-session-nested-tools.js.map +1 -1
- package/dist/core/agent-session-prompt.d.ts.map +1 -1
- package/dist/core/agent-session-prompt.js +12 -0
- package/dist/core/agent-session-prompt.js.map +1 -1
- package/dist/core/agent-session-state.d.ts +6 -0
- package/dist/core/agent-session-state.d.ts.map +1 -1
- package/dist/core/agent-session-state.js +71 -4
- package/dist/core/agent-session-state.js.map +1 -1
- package/dist/core/agent-session-tool-hooks.d.ts.map +1 -1
- package/dist/core/agent-session-tool-hooks.js +9 -1
- package/dist/core/agent-session-tool-hooks.js.map +1 -1
- package/dist/core/agent-session-types.d.ts +2 -0
- package/dist/core/agent-session-types.d.ts.map +1 -1
- package/dist/core/agent-session-types.js.map +1 -1
- package/dist/core/agent-session.d.ts +3 -0
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +7 -0
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/cache-stats.d.ts +15 -0
- package/dist/core/cache-stats.d.ts.map +1 -1
- package/dist/core/cache-stats.js +40 -2
- package/dist/core/cache-stats.js.map +1 -1
- package/dist/core/diagnostic-writer.d.ts.map +1 -1
- package/dist/core/diagnostic-writer.js +2 -1
- package/dist/core/diagnostic-writer.js.map +1 -1
- package/dist/core/export-html/template.js +14 -4
- package/dist/core/extensions/context-types.d.ts +6 -0
- package/dist/core/extensions/context-types.d.ts.map +1 -1
- package/dist/core/extensions/context-types.js.map +1 -1
- package/dist/core/extensions/loader-api.d.ts.map +1 -1
- package/dist/core/extensions/loader-api.js +5 -2
- package/dist/core/extensions/loader-api.js.map +1 -1
- package/dist/core/queued-message-delivery.d.ts +100 -7
- package/dist/core/queued-message-delivery.d.ts.map +1 -1
- package/dist/core/queued-message-delivery.js +194 -4
- package/dist/core/queued-message-delivery.js.map +1 -1
- package/dist/core/resume-cache-checkpoint.d.ts +32 -0
- package/dist/core/resume-cache-checkpoint.d.ts.map +1 -0
- package/dist/core/resume-cache-checkpoint.js +67 -0
- package/dist/core/resume-cache-checkpoint.js.map +1 -0
- package/dist/core/sdk-types.d.ts +37 -0
- package/dist/core/sdk-types.d.ts.map +1 -1
- package/dist/core/sdk-types.js.map +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +57 -28
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-manager-core.d.ts.map +1 -1
- package/dist/core/session-manager-core.js +12 -3
- package/dist/core/session-manager-core.js.map +1 -1
- package/dist/core/session-manager-entries.d.ts +13 -0
- package/dist/core/session-manager-entries.d.ts.map +1 -1
- package/dist/core/session-manager-entries.js +38 -6
- package/dist/core/session-manager-entries.js.map +1 -1
- package/dist/core/settings-lock-directory.d.ts.map +1 -1
- package/dist/core/settings-lock-directory.js +2 -1
- package/dist/core/settings-lock-directory.js.map +1 -1
- package/dist/core/storage/node-sqlite-file-gate.d.ts +173 -0
- package/dist/core/storage/node-sqlite-file-gate.d.ts.map +1 -0
- package/dist/core/storage/node-sqlite-file-gate.js +1033 -0
- package/dist/core/storage/node-sqlite-file-gate.js.map +1 -0
- package/dist/core/storage/node-sqlite-thread.d.ts +33 -6
- package/dist/core/storage/node-sqlite-thread.d.ts.map +1 -1
- package/dist/core/storage/node-sqlite-thread.js +72 -2
- package/dist/core/storage/node-sqlite-thread.js.map +1 -1
- package/dist/core/storage/node-sqlite.d.ts.map +1 -1
- package/dist/core/storage/node-sqlite.js +216 -15
- package/dist/core/storage/node-sqlite.js.map +1 -1
- package/dist/core/storage/session/entry-structure.d.ts.map +1 -1
- package/dist/core/storage/session/entry-structure.js +39 -2
- package/dist/core/storage/session/entry-structure.js.map +1 -1
- package/dist/core/storage/session/session-resume.d.ts.map +1 -1
- package/dist/core/storage/session/session-resume.js +1 -0
- package/dist/core/storage/session/session-resume.js.map +1 -1
- package/dist/core/storage/session/session-search-index.d.ts.map +1 -1
- package/dist/core/storage/session/session-search-index.js +56 -9
- package/dist/core/storage/session/session-search-index.js.map +1 -1
- package/dist/core/storage/statement-sequence.d.ts +36 -0
- package/dist/core/storage/statement-sequence.d.ts.map +1 -0
- package/dist/core/storage/statement-sequence.js +22 -0
- package/dist/core/storage/statement-sequence.js.map +1 -0
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +13 -4
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tasks/heartbeat-notice.d.ts.map +1 -1
- package/dist/core/tasks/heartbeat-notice.js +2 -1
- package/dist/core/tasks/heartbeat-notice.js.map +1 -1
- package/dist/core/tool-loadout.d.ts +4 -2
- package/dist/core/tool-loadout.d.ts.map +1 -1
- package/dist/core/tool-loadout.js +27 -5
- package/dist/core/tool-loadout.js.map +1 -1
- package/dist/core/tools/history-regex-worker.d.ts.map +1 -1
- package/dist/core/tools/history-regex-worker.js +2 -1
- package/dist/core/tools/history-regex-worker.js.map +1 -1
- package/dist/core/tools/powershell.d.ts +22 -22
- package/dist/core/tools/sqlite-selector-connection.d.ts.map +1 -1
- package/dist/core/tools/sqlite-selector-connection.js +7 -0
- package/dist/core/tools/sqlite-selector-connection.js.map +1 -1
- package/dist/core/transformed-system-prompt.d.ts +92 -0
- package/dist/core/transformed-system-prompt.d.ts.map +1 -0
- package/dist/core/transformed-system-prompt.js +240 -0
- package/dist/core/transformed-system-prompt.js.map +1 -0
- package/dist/extensions/codemode/execute.js +1 -1
- package/dist/extensions/codemode/execute.js.map +1 -1
- package/dist/extensions/codemode/tool.d.ts.map +1 -1
- package/dist/extensions/codemode/tool.js +16 -3
- package/dist/extensions/codemode/tool.js.map +1 -1
- package/dist/extensions/llama/ui.d.ts.map +1 -1
- package/dist/extensions/llama/ui.js +13 -8
- package/dist/extensions/llama/ui.js.map +1 -1
- package/dist/extensions/mcp/config.d.ts +2 -0
- package/dist/extensions/mcp/config.d.ts.map +1 -1
- package/dist/extensions/mcp/config.js +5 -0
- package/dist/extensions/mcp/config.js.map +1 -1
- package/dist/extensions/mcp/index.d.ts +4 -0
- package/dist/extensions/mcp/index.d.ts.map +1 -1
- package/dist/extensions/mcp/index.js +289 -64
- package/dist/extensions/mcp/index.js.map +1 -1
- package/dist/extensions/mcp/runtime.d.ts +1 -1
- package/dist/extensions/mcp/runtime.d.ts.map +1 -1
- package/dist/extensions/mcp/runtime.js +2 -2
- package/dist/extensions/mcp/runtime.js.map +1 -1
- package/dist/extensions/mcp/tool-records.d.ts +58 -0
- package/dist/extensions/mcp/tool-records.d.ts.map +1 -0
- package/dist/extensions/mcp/tool-records.js +129 -0
- package/dist/extensions/mcp/tool-records.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/modes/interactive/components/agent-panel.d.ts +2 -4
- package/dist/modes/interactive/components/agent-panel.d.ts.map +1 -1
- package/dist/modes/interactive/components/agent-panel.js +65 -80
- package/dist/modes/interactive/components/agent-panel.js.map +1 -1
- package/dist/modes/interactive/components/compaction-boundary-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/compaction-boundary-message.js +3 -3
- package/dist/modes/interactive/components/compaction-boundary-message.js.map +1 -1
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +35 -28
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/components/notice-line.d.ts +16 -0
- package/dist/modes/interactive/components/notice-line.d.ts.map +1 -1
- package/dist/modes/interactive/components/notice-line.js +7 -0
- package/dist/modes/interactive/components/notice-line.js.map +1 -1
- package/dist/modes/interactive/components/prompt-slot.d.ts +1 -0
- package/dist/modes/interactive/components/prompt-slot.d.ts.map +1 -1
- package/dist/modes/interactive/components/prompt-slot.js +8 -4
- package/dist/modes/interactive/components/prompt-slot.js.map +1 -1
- package/dist/modes/interactive/components/task-board.d.ts +0 -1
- package/dist/modes/interactive/components/task-board.d.ts.map +1 -1
- package/dist/modes/interactive/components/task-board.js +6 -14
- package/dist/modes/interactive/components/task-board.js.map +1 -1
- package/dist/modes/interactive/components/task-row.d.ts.map +1 -1
- package/dist/modes/interactive/components/task-row.js +7 -6
- package/dist/modes/interactive/components/task-row.js.map +1 -1
- package/dist/modes/interactive/components/token-segment.d.ts +2 -1
- package/dist/modes/interactive/components/token-segment.d.ts.map +1 -1
- package/dist/modes/interactive/components/token-segment.js +2 -4
- package/dist/modes/interactive/components/token-segment.js.map +1 -1
- package/dist/modes/interactive/components/tree-selector-content.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector-content.js +2 -2
- package/dist/modes/interactive/components/tree-selector-content.js.map +1 -1
- package/dist/modes/interactive/components/working-run-meter.d.ts +0 -1
- package/dist/modes/interactive/components/working-run-meter.d.ts.map +1 -1
- package/dist/modes/interactive/components/working-run-meter.js +0 -9
- package/dist/modes/interactive/components/working-run-meter.js.map +1 -1
- package/dist/modes/interactive/extension-command-hold.d.ts +25 -0
- package/dist/modes/interactive/extension-command-hold.d.ts.map +1 -0
- package/dist/modes/interactive/extension-command-hold.js +45 -0
- package/dist/modes/interactive/extension-command-hold.js.map +1 -0
- package/dist/modes/interactive/interactive-agent-events.js +2 -1
- package/dist/modes/interactive/interactive-agent-events.js.map +1 -1
- package/dist/modes/interactive/interactive-extension-context.js +18 -10
- package/dist/modes/interactive/interactive-extension-context.js.map +1 -1
- package/dist/modes/interactive/interactive-extension-custom-ui.js +3 -0
- package/dist/modes/interactive/interactive-extension-custom-ui.js.map +1 -1
- package/dist/modes/interactive/interactive-input-handling.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-input-handling.js +54 -13
- package/dist/modes/interactive/interactive-input-handling.js.map +1 -1
- package/dist/modes/interactive/interactive-model-routing.d.ts +6 -0
- package/dist/modes/interactive/interactive-model-routing.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-model-routing.js +15 -9
- package/dist/modes/interactive/interactive-model-routing.js.map +1 -1
- package/dist/modes/interactive/interactive-prompt-turn.js +4 -0
- package/dist/modes/interactive/interactive-prompt-turn.js.map +1 -1
- package/dist/modes/interactive/interactive-queueing.d.ts +7 -0
- package/dist/modes/interactive/interactive-queueing.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-queueing.js +47 -1
- package/dist/modes/interactive/interactive-queueing.js.map +1 -1
- package/dist/modes/interactive/interactive-session-routing.js +6 -0
- package/dist/modes/interactive/interactive-session-routing.js.map +1 -1
- package/dist/modes/interactive/interactive-slash-commands.js +165 -65
- package/dist/modes/interactive/interactive-slash-commands.js.map +1 -1
- package/dist/modes/interactive/screen-hold.d.ts +3 -0
- package/dist/modes/interactive/screen-hold.d.ts.map +1 -1
- package/dist/modes/interactive/screen-hold.js +9 -1
- package/dist/modes/interactive/screen-hold.js.map +1 -1
- package/dist/modes/interactive-engine/engine-health.d.ts +11 -3
- package/dist/modes/interactive-engine/engine-health.d.ts.map +1 -1
- package/dist/modes/interactive-engine/engine-health.js +5 -4
- package/dist/modes/interactive-engine/engine-health.js.map +1 -1
- package/dist/modes/interactive-engine/engine-quit-intent.d.ts +7 -0
- package/dist/modes/interactive-engine/engine-quit-intent.d.ts.map +1 -1
- package/dist/modes/interactive-engine/engine-quit-intent.js +19 -0
- package/dist/modes/interactive-engine/engine-quit-intent.js.map +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.d.ts +18 -0
- package/dist/modes/interactive-engine/isolated-runtime.d.ts.map +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.js +56 -4
- package/dist/modes/interactive-engine/isolated-runtime.js.map +1 -1
- package/dist/modes/interactive-engine/protocol.d.ts +7 -0
- package/dist/modes/interactive-engine/protocol.d.ts.map +1 -1
- package/dist/modes/interactive-engine/protocol.js +1 -0
- package/dist/modes/interactive-engine/protocol.js.map +1 -1
- package/dist/modes/rpc/agent-panel-bridge.d.ts.map +1 -1
- package/dist/modes/rpc/agent-panel-bridge.js +0 -13
- package/dist/modes/rpc/agent-panel-bridge.js.map +1 -1
- package/dist/modes/rpc/rpc-client-process.d.ts +14 -1
- package/dist/modes/rpc/rpc-client-process.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client-process.js +74 -10
- package/dist/modes/rpc/rpc-client-process.js.map +1 -1
- package/dist/modes/rpc/rpc-client.d.ts +27 -1
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +81 -5
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/modes/rpc/rpc-event-buffer.d.ts +2 -0
- package/dist/modes/rpc/rpc-event-buffer.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-event-buffer.js +9 -0
- package/dist/modes/rpc/rpc-event-buffer.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +16 -3
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-session-binding.d.ts +7 -1
- package/dist/modes/rpc/rpc-session-binding.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-session-binding.js +10 -2
- package/dist/modes/rpc/rpc-session-binding.js.map +1 -1
- package/dist/utils/image-resize.d.ts.map +1 -1
- package/dist/utils/image-resize.js +2 -1
- package/dist/utils/image-resize.js.map +1 -1
- package/dist/utils/interactive-engine-bootstrap.d.ts +2 -0
- package/dist/utils/interactive-engine-bootstrap.d.ts.map +1 -1
- package/dist/utils/interactive-engine-bootstrap.js +1 -0
- package/dist/utils/interactive-engine-bootstrap.js.map +1 -1
- package/dist/utils/interactive-engine-env.d.ts +2 -0
- package/dist/utils/interactive-engine-env.d.ts.map +1 -1
- package/dist/utils/interactive-engine-env.js +1 -0
- package/dist/utils/interactive-engine-env.js.map +1 -1
- package/dist/utils/shell.d.ts.map +1 -1
- package/dist/utils/shell.js +2 -0
- package/dist/utils/shell.js.map +1 -1
- package/dist/utils/token-count.d.ts +8 -0
- package/dist/utils/token-count.d.ts.map +1 -0
- package/dist/utils/token-count.js +25 -0
- package/dist/utils/token-count.js.map +1 -0
- package/dist/utils/worker-threads.d.ts +18 -0
- package/dist/utils/worker-threads.d.ts.map +1 -0
- package/dist/utils/worker-threads.js +28 -0
- package/dist/utils/worker-threads.js.map +1 -0
- package/docs/background-tasks.md +13 -12
- package/docs/compaction.md +2 -2
- package/docs/development.md +1 -1
- package/docs/extensions/api-reference.md +5 -3
- package/docs/extensions/events.md +2 -0
- package/docs/mcp-servers.md +1 -1
- package/docs/settings.md +2 -0
- package/docs/storage.md +3 -1
- package/docs/subagents.md +6 -2
- package/docs/usage.md +1 -1
- package/npm-shrinkwrap.json +49 -49
- package/package.json +6 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk-types.js","sourceRoot":"","sources":["../../src/core/sdk-types.ts"],"names":[],"mappings":"","sourcesContent":["import type { AgentMessage, ThinkingLevel } from \"@bastani/atomic-agent-core\";\nimport type { Api, Model } from \"@bastani/atomic-ai/compat\";\nimport type { AgentSession } from \"./agent-session.js\";\nimport type { ReleaseWhenIdleOptions } from \"./agent-session-release.ts\";\nimport type { ExtensionBindings } from \"./agent-session-types.js\";\nimport type {\n\tLoadExtensionsResult,\n\tSessionStartEvent,\n\tSubagentChildPolicy,\n\tToolDefinition,\n} from \"./extensions/index.js\";\nimport type { ModelFallbackReason } from \"./model-resolver-types.ts\";\nimport type { ModelRuntime } from \"./model-runtime.js\";\nimport type { ResourceLoader } from \"./resource-loader.ts\";\nimport type { SessionManager } from \"./session-manager.ts\";\nimport type { SettingsManager } from \"./settings-manager.ts\";\nimport type { SqliteDatabase } from \"./storage/database.js\";\nimport type { AdapterOptions, SecretRef, StorageSelection } from \"./storage/provider.js\";\nimport type { SessionStore } from \"./storage/session/types.js\";\n\n/** A `createAgentSession({ storage })` selection: a database path, a caller-owned database, memory, or an adapter. */\nexport type SessionStorageOption =\n\t| { path: string; prefix?: string }\n\t| { database: SqliteDatabase; prefix?: string }\n\t| { memory: true }\n\t| { adapter: string; options?: AdapterOptions; secrets?: Readonly<Record<string, SecretRef>>; prefix?: string };\n\nexport type AtomicBuiltin = \"subagents\" | \"mcp\" | \"web-access\" | \"intercom\";\n\nexport interface CreateAgentSessionOptions {\n\t/** Shipped packages are enabled unless explicitly false. Independent of tool selection. */\n\tbuiltins?: Partial<Record<AtomicBuiltin, boolean>>;\n\t/** Working directory for project-local discovery. Default: process.cwd(), or the workspace worktree. */\n\tcwd?: string;\n\t/**\n\t * Repository binding from `workspace({ … })`, or an already resolved binding. The session runs in the bound worktree\n\t * (an explicit `cwd` must lie inside it), records the binding in the session, and a `\"read-only\"` workspace removes\n\t * and refuses the file-writing tools (`write`, `edit`, `todo`).\n\t */\n\tworkspace?: import(\"./workspace/spec.ts\").Workspace | import(\"./workspace/resolve.ts\").BoundWorkspace;\n\t/** Global config directory. Default: ~/.atomic/agent */\n\tagentDir?: string;\n\t/**\n\t * Storage for this session's sessions, in the form of the top-level `storage` setting, for example the selection\n\t * `teamProfileSelection()` returns. Outranks process-level selections and settings; `sessionStore` and\n\t * `sessionManager` outrank it. Intercom keeps the process's selection.\n\t */\n\tstorage?: SessionStorageOption;\n\n\t/** Cancel the first prompt's optional lookup of a missing Copilot model. Local selection is unchanged. */\n\tsignal?: AbortSignal;\n\t/** Canonical model/auth runtime. Defaults to agentDir/auth.json and models.json. */\n\tmodelRuntime?: ModelRuntime;\n\n\t/** Model to use. Default: from settings, else first available */\n\tmodel?: Model<Api>;\n\t/** Thinking level. Default: from settings, else 'medium' (clamped to model capabilities) */\n\tthinkingLevel?: ThinkingLevel;\n\t/**\n\t * Ordered fallback models as provider/model strings with optional :thinkingLevel suffix.\n\t * Used by main-chat turns. Default: settings.fallbackModels\n\t */\n\tfallbackModels?: string[];\n\t/** Hard eligibility gate applied before fallback inference. */\n\tisFallbackModelAllowed?: (model: Model<Api>, effort: string | undefined) => boolean;\n\t/** Models available for cycling (Ctrl+P in interactive mode) */\n\tscopedModels?: Array<{ model: Model<Api>; thinkingLevel?: ThinkingLevel }>;\n\n\t/**\n\t * Tool suppression mode.\n\t *\n\t * - \"all\": no active tools, even with an explicit allowlist\n\t * - \"builtin\": suppress coding-tool defaults only when tools is omitted;\n\t * extension/custom tools remain enabled\n\t */\n\tnoTools?: \"all\" | \"builtin\";\n\t/**\n\t * Optional allowlist of tool names or patterns where `*` matches any characters.\n\t *\n\t * When omitted, Atomic uses the resolved `defaultTools` setting for the initial\n\t * built-in selection when configured. Otherwise it enables the default\n\t * built-in tools (including codemode when its extension is loaded). Extension/custom tools remain enabled unless `noTools` changes\n\t * that default. MCP tools stay registered for codemode and tool search unless\n\t * an entry starts with `mcp__`; only matching tools are declared directly.\n\t * `excludedTools` applies afterwards. `noTools: \"all\"` overrides this selection.\n\t * Intercom follows the same selection and suppression rules as other extension tools.\n\t * A list of only `+name`/`-name` entries changes the resolved defaults instead\n\t * of allowlisting tools, and is reapplied on reload. Modifiers take exact names;\n\t * mixing them with plain names or patterns throws. Total suppression still wins.\n\t */\n\ttools?: string[];\n\t/**\n\t * Optional blocklist of tool names or patterns, including MCP tools.\n\t *\n\t * Matching built-in, extension, and SDK custom tools are omitted from the\n\t * final session tool registry and active tool set. Unknown names are ignored.\n\t */\n\texcludedTools?: string[];\n\t/** Custom tools to register (in addition to built-in tools). */\n\tcustomTools?: ToolDefinition[];\n\n\t/** Resource loader. When omitted, DefaultResourceLoader is used. */\n\tresourceLoader?: ResourceLoader;\n\n\t/** Session manager. Default: SessionManager.create(cwd) */\n\tsessionManager?: SessionManager;\n\t/** Session storage. Defaults to the resolved settings or the shared local SQLite database. */\n\tsessionStore?: SessionStore | StorageSelection;\n\t/**\n\t * Worktree snapshot settings for this session, overriding `snapshots.*` in settings.json. A turn that calls a\n\t * file-writing tool records a `worktree_snapshot` entry per checkout it touched. Invalid values throw\n\t * WorkspaceConfigError before the session is created.\n\t */\n\tsnapshots?: import(\"./worktree-snapshot/settings.ts\").WorktreeSnapshotSettingsInput;\n\n\t/** Settings manager. Default: SettingsManager.create(cwd, agentDir) */\n\tsettingsManager?: SettingsManager;\n\t/** Session start event metadata for extension runtime startup. */\n\tsessionStartEvent?: SessionStartEvent;\n\t/** Host bindings installed before extension startup. Rebinding does not replay startup. */\n\textensionBindings?: ExtensionBindings;\n\t/** Typed capability policy for an in-process subagent child. */\n\tsubagentPolicy?: SubagentChildPolicy;\n\t/**\n\t * The session's Intercom home group and the other groups it may reach. `group` replaces the group from\n\t * `ATOMIC_INTERCOM_GROUP`, Intercom `config.json` and the project. The session\n\t * lists, sends to and asks only sessions in `group`, `reachable`, or subgroups under `group`. It joins only `group` and `reachable` and can't leave `group`. Reach is one way. The broker enforces it. Change\n\t * `reachable` later with `session.intercom.setReachable(groups)`. Invalid values throw `IntercomPolicyError`.\n\t */\n\tintercom?: import(\"./intercom-policy.ts\").IntercomSessionOptions;\n\tparentIntercomPolicy?: import(\"./intercom-policy.ts\").IntercomPolicyView;\n\t/**\n\t * Internal: parent-issued shell task owner for an in-process subagent child. Supplied by the\n\t * parent's child-session options, so child background shells appear in the parent's `/tasks`.\n\t */\n\tparentCommandTaskOwner?: import(\"./tasks/child-command-owner.js\").ChildCommandTaskOwner;\n\t/**\n\t * Internal: the launching session's project history. Supplied by the parent's child-session options, so\n\t * `history://` in a subagent reads the project's sessions.\n\t */\n\tinheritedHistory?: import(\"./tools/history-protocol.ts\").ProjectHistory;\n\t/**\n\t * Capacity policy for this session and its managed commands. Omitted, the session draws its own permit from the\n\t * enclosing `withResourceAdmission` scope, if any. `null` means it holds none, even inside such a scope. Child\n\t * options from `getChildSessionOptions()` carry the parent's admission, or `null` when the parent holds none.\n\t */\n\tresourceAdmission?: ResourceAdmission | null;\n\tresourceAdmissionSignal?: AbortSignal;\n\tresourceAdmissionDelegated?: boolean;\n\t/**\n\t * Receives the usage of every model call this session makes, and of every call its own child sessions report.\n\t * A parent's child session options set it, so the parent emits `child_session_usage` for each call a subagent\n\t * child makes.\n\t */\n\tparentUsageSink?: (usage: import(\"@bastani/atomic-ai/compat\").Usage) => void;\n\t/**\n\t * Internal: called with `true` when this session starts waiting for its resource-admission permit and `false` when\n\t * the wait ends, so an in-process subagent's start budget can tell that wait from the rest of its setup.\n\t */\n\tonResourceAdmissionWait?: (waiting: boolean) => void;\n\t/**\n\t * Release the session once it has been idle (no run, compaction, shell command, queued message or background task)\n\t * for `afterMs` milliseconds, from 0 to 2147483647: it lets go of everything live and keeps only its stored history,\n\t * and subscribers get a `session_released` event first. Rehydrate it with `AgentSessionRuntime.rehydrate(sessionId)`.\n\t * Validated before anything is created; an invalid value throws `AgentReleaseConfigError`.\n\t */\n\treleaseWhenIdle?: ReleaseWhenIdleOptions;\n\t/** Transform the fully constructed base system prompt at session construction. */\n\tsystemPromptTransform?: (prompt: string) => string;\n\t/** Filter inherited session messages before they enter the new AgentSession. */\n\tinitialContextTransform?: (messages: AgentMessage[]) => AgentMessage[];\n}\n\nexport interface ResourceAdmissionRequest {\n\treadonly delegated?: boolean;\n}\n\nexport interface ResourceProcessIdentity {\n\treadonly kind: \"unix-process-group\";\n\treadonly id: number;\n}\n\nexport type ResourcePermit = (() => Promise<void>) & {\n\tbindProcess?: (identity: ResourceProcessIdentity) => Promise<void>;\n};\n\nexport interface ResourceAdmission {\n\tacquire(\n\t\tkind: \"session\" | \"process\",\n\t\tsignal?: AbortSignal,\n\t\trequest?: ResourceAdmissionRequest,\n\t): Promise<ResourcePermit>;\n}\n\n/** Result from createAgentSession */\nexport interface CreateAgentSessionResult {\n\t/** The created session */\n\tsession: AgentSession;\n\t/** Extensions result (for UI context setup in interactive mode) */\n\textensionsResult: LoadExtensionsResult;\n\t/** Warning when a restored or configured model cannot be selected. */\n\tmodelFallbackMessage?: string;\n\t/** Semantic reason for modelFallbackMessage; suitable for mode control flow. */\n\tmodelFallbackReason?: ModelFallbackReason;\n\t/** The resolved workspace binding, when the session was created with `workspace`. */\n\tworkspace?: import(\"./workspace/resolve.ts\").BoundWorkspace;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"sdk-types.js","sourceRoot":"","sources":["../../src/core/sdk-types.ts"],"names":[],"mappings":"","sourcesContent":["import type { AgentMessage, ThinkingLevel } from \"@bastani/atomic-agent-core\";\nimport type { Api, Model } from \"@bastani/atomic-ai/compat\";\nimport type { AgentSession } from \"./agent-session.js\";\nimport type { ReleaseWhenIdleOptions } from \"./agent-session-release.ts\";\nimport type { ExtensionBindings } from \"./agent-session-types.js\";\nimport type {\n\tLoadExtensionsResult,\n\tSessionStartEvent,\n\tSubagentChildPolicy,\n\tToolDefinition,\n} from \"./extensions/index.js\";\nimport type { ModelFallbackReason } from \"./model-resolver-types.ts\";\nimport type { ModelRuntime } from \"./model-runtime.js\";\nimport type { ResourceLoader } from \"./resource-loader.ts\";\nimport type { SessionManager } from \"./session-manager.ts\";\nimport type { SettingsManager } from \"./settings-manager.ts\";\nimport type { SqliteDatabase } from \"./storage/database.js\";\nimport type { AdapterOptions, SecretRef, StorageSelection } from \"./storage/provider.js\";\nimport type { SessionStore } from \"./storage/session/types.js\";\n\n/** A `createAgentSession({ storage })` selection: a database path, a caller-owned database, memory, or an adapter. */\nexport type SessionStorageOption =\n\t| { path: string; prefix?: string }\n\t| { database: SqliteDatabase; prefix?: string }\n\t| { memory: true }\n\t| { adapter: string; options?: AdapterOptions; secrets?: Readonly<Record<string, SecretRef>>; prefix?: string };\n\nexport type AtomicBuiltin = \"subagents\" | \"mcp\" | \"web-access\" | \"intercom\";\n\nexport interface CreateAgentSessionOptions {\n\t/** Shipped packages are enabled unless explicitly false. Independent of tool selection. */\n\tbuiltins?: Partial<Record<AtomicBuiltin, boolean>>;\n\t/** Working directory for project-local discovery. Default: process.cwd(), or the workspace worktree. */\n\tcwd?: string;\n\t/**\n\t * Repository binding from `workspace({ … })`, or an already resolved binding. The session runs in the bound worktree\n\t * (an explicit `cwd` must lie inside it), records the binding in the session, and a `\"read-only\"` workspace removes\n\t * and refuses the file-writing tools (`write`, `edit`, `todo`).\n\t */\n\tworkspace?: import(\"./workspace/spec.ts\").Workspace | import(\"./workspace/resolve.ts\").BoundWorkspace;\n\t/** Global config directory. Default: ~/.atomic/agent */\n\tagentDir?: string;\n\t/**\n\t * Storage for this session's sessions, in the form of the top-level `storage` setting, for example the selection\n\t * `teamProfileSelection()` returns. Outranks process-level selections and settings; `sessionStore` and\n\t * `sessionManager` outrank it. Intercom keeps the process's selection.\n\t */\n\tstorage?: SessionStorageOption;\n\n\t/** Cancel the first prompt's optional lookup of a missing Copilot model. Local selection is unchanged. */\n\tsignal?: AbortSignal;\n\t/** Canonical model/auth runtime. Defaults to agentDir/auth.json and models.json. */\n\tmodelRuntime?: ModelRuntime;\n\n\t/** Model to use. Default: from settings, else first available */\n\tmodel?: Model<Api>;\n\t/** Thinking level. Default: from settings, else 'medium' (clamped to model capabilities) */\n\tthinkingLevel?: ThinkingLevel;\n\t/**\n\t * Ordered fallback models as provider/model strings with optional :thinkingLevel suffix.\n\t * Used by main-chat turns. Default: settings.fallbackModels\n\t */\n\tfallbackModels?: string[];\n\t/** Hard eligibility gate applied before fallback inference. */\n\tisFallbackModelAllowed?: (model: Model<Api>, effort: string | undefined) => boolean;\n\t/** Models available for cycling (Ctrl+P in interactive mode) */\n\tscopedModels?: Array<{ model: Model<Api>; thinkingLevel?: ThinkingLevel }>;\n\n\t/**\n\t * Tool suppression mode.\n\t *\n\t * - \"all\": no active tools, even with an explicit allowlist\n\t * - \"builtin\": suppress coding-tool defaults only when tools is omitted;\n\t * extension/custom tools remain enabled\n\t */\n\tnoTools?: \"all\" | \"builtin\";\n\t/**\n\t * Optional allowlist of tool names or patterns where `*` matches any characters.\n\t *\n\t * When omitted, Atomic uses the resolved `defaultTools` setting for the initial\n\t * built-in selection when configured. Otherwise it enables the default\n\t * built-in tools (including codemode when its extension is loaded). Extension/custom tools remain enabled unless `noTools` changes\n\t * that default. MCP tools stay registered for codemode and tool search unless\n\t * an entry starts with `mcp__`; only matching tools are declared directly.\n\t * `excludedTools` applies afterwards. `noTools: \"all\"` overrides this selection.\n\t * Intercom follows the same selection and suppression rules as other extension tools.\n\t * A list of only `+name`/`-name` entries changes the resolved defaults instead\n\t * of allowlisting tools, and is reapplied on reload. Modifiers take exact names;\n\t * mixing them with plain names or patterns throws. Total suppression still wins.\n\t */\n\ttools?: string[];\n\t/**\n\t * Optional blocklist of tool names or patterns, including MCP tools.\n\t *\n\t * Matching built-in, extension, and SDK custom tools are omitted from the\n\t * final session tool registry and active tool set. Unknown names are ignored.\n\t */\n\texcludedTools?: string[];\n\t/** Custom tools to register (in addition to built-in tools). */\n\tcustomTools?: ToolDefinition[];\n\n\t/** Resource loader. When omitted, DefaultResourceLoader is used. */\n\tresourceLoader?: ResourceLoader;\n\n\t/** Session manager. Default: SessionManager.create(cwd) */\n\tsessionManager?: SessionManager;\n\t/** Session storage. Defaults to the resolved settings or the shared local SQLite database. */\n\tsessionStore?: SessionStore | StorageSelection;\n\t/**\n\t * Worktree snapshot settings for this session, overriding `snapshots.*` in settings.json. A turn that calls a\n\t * file-writing tool records a `worktree_snapshot` entry per checkout it touched. Invalid values throw\n\t * WorkspaceConfigError before the session is created.\n\t */\n\tsnapshots?: import(\"./worktree-snapshot/settings.ts\").WorktreeSnapshotSettingsInput;\n\n\t/** Settings manager. Default: SettingsManager.create(cwd, agentDir) */\n\tsettingsManager?: SettingsManager;\n\t/** Session start event metadata for extension runtime startup. */\n\tsessionStartEvent?: SessionStartEvent;\n\t/** Host bindings installed before extension startup. Rebinding does not replay startup. */\n\textensionBindings?: ExtensionBindings;\n\t/** Typed capability policy for an in-process subagent child. */\n\tsubagentPolicy?: SubagentChildPolicy;\n\t/**\n\t * The session's Intercom home group and the other groups it may reach. `group` replaces the group from\n\t * `ATOMIC_INTERCOM_GROUP`, Intercom `config.json` and the project. The session\n\t * lists, sends to and asks only sessions in `group`, `reachable`, or subgroups under `group`. It joins only `group` and `reachable` and can't leave `group`. Reach is one way. The broker enforces it. Change\n\t * `reachable` later with `session.intercom.setReachable(groups)`. Invalid values throw `IntercomPolicyError`.\n\t */\n\tintercom?: import(\"./intercom-policy.ts\").IntercomSessionOptions;\n\tparentIntercomPolicy?: import(\"./intercom-policy.ts\").IntercomPolicyView;\n\t/**\n\t * Internal: parent-issued shell task owner for an in-process subagent child. Supplied by the\n\t * parent's child-session options, so child background shells appear in the parent's `/tasks`.\n\t */\n\tparentCommandTaskOwner?: import(\"./tasks/child-command-owner.js\").ChildCommandTaskOwner;\n\t/**\n\t * Internal: the launching session's project history. Supplied by the parent's child-session options, so\n\t * `history://` in a subagent reads the project's sessions.\n\t */\n\tinheritedHistory?: import(\"./tools/history-protocol.ts\").ProjectHistory;\n\t/**\n\t * Capacity policy for this session and its managed commands. Omitted, the session draws its own permit from the\n\t * enclosing `withResourceAdmission` scope, if any. `null` means it holds none, even inside such a scope. Child\n\t * options from `getChildSessionOptions()` carry the parent's admission, or `null` when the parent holds none.\n\t */\n\tresourceAdmission?: ResourceAdmission | null;\n\tresourceAdmissionSignal?: AbortSignal;\n\tresourceAdmissionDelegated?: boolean;\n\t/**\n\t * Receives the usage of every model call this session makes, and of every call its own child sessions report.\n\t * A parent's child session options set it, so the parent emits `child_session_usage` for each call a subagent\n\t * child makes.\n\t */\n\tparentUsageSink?: (usage: import(\"@bastani/atomic-ai/compat\").Usage) => void;\n\t/**\n\t * Internal: in options from `getChildSessionOptions()`, the tools the parent's requests declare but hide (codemode\n\t * reaches them), so a fork of its conversation sends that conversation as the parent did.\n\t */\n\tparentHiddenTools?: readonly string[];\n\t/** Internal: in options from `getChildSessionOptions()`, the tools the parent's requests declare. */\n\tparentToolNames?: readonly string[];\n\t/**\n\t * Internal: called with `true` when this session starts waiting for its resource-admission permit and `false` when\n\t * the wait ends, so an in-process subagent's start budget can tell that wait from the rest of its setup.\n\t */\n\tonResourceAdmissionWait?: (waiting: boolean) => void;\n\t/**\n\t * Release the session once it has been idle (no run, compaction, shell command, queued message or background task)\n\t * for `afterMs` milliseconds, from 0 to 2147483647: it lets go of everything live and keeps only its stored history,\n\t * and subscribers get a `session_released` event first. Rehydrate it with `AgentSessionRuntime.rehydrate(sessionId)`.\n\t * Validated before anything is created; an invalid value throws `AgentReleaseConfigError`.\n\t */\n\treleaseWhenIdle?: ReleaseWhenIdleOptions;\n\t/** Transform the fully constructed base system prompt at session construction. */\n\tsystemPromptTransform?: (prompt: string) => string;\n\t/**\n\t * Internal: `systemPromptTransform` applied section by section. With it the session keeps sending the transformed\n\t * prompt it first sent, also after it is reopened, and tells the model later changes as section updates.\n\t */\n\tsystemPromptSections?: SystemPromptSectionsTransform;\n\t/** Filter inherited session messages before they enter the new AgentSession. */\n\tinitialContextTransform?: (messages: AgentMessage[]) => AgentMessage[];\n}\n\n/** `systemPromptTransform` applied to each section of the structured prompt; see `CreateAgentSessionOptions`. */\nexport interface SystemPromptSectionsTransform {\n\t/**\n\t * What the transform lets the prompt hold, such as which inherited instructions it keeps. A prompt the session sent\n\t * under another key, or that another session sent, is not sent again: the session sends its current prompt instead.\n\t */\n\treadonly key: string;\n\t/** Each section as the transformed prompt holds it, keyed and ordered as in that prompt; one it drops is absent. */\n\treadonly transform: (sections: Record<string, string>) => Record<string, string>;\n\t/**\n\t * The session continues another session's conversation (a forked subagent). Its first request sends that\n\t * conversation exactly as the other session last sent it, so it is read from that session's prompt cache, then a\n\t * note and the session's own sections after it. Its requests use `sessionId` as their prompt-cache key.\n\t */\n\treadonly fork?: {\n\t\treadonly sessionId: string;\n\t\t/** The tools the other session's requests declared but hid; see `parentHiddenTools`. */\n\t\treadonly hiddenTools?: readonly string[];\n\t\t/** The note that opens what the fork adds: the tools it may call, and those it reaches through codemode. */\n\t\treadonly note: (tools: {\n\t\t\treadonly tools: readonly string[];\n\t\t\treadonly throughCodemode: readonly string[];\n\t\t}) => string;\n\t};\n}\n\nexport interface ResourceAdmissionRequest {\n\treadonly delegated?: boolean;\n}\n\nexport interface ResourceProcessIdentity {\n\treadonly kind: \"unix-process-group\";\n\treadonly id: number;\n}\n\nexport type ResourcePermit = (() => Promise<void>) & {\n\tbindProcess?: (identity: ResourceProcessIdentity) => Promise<void>;\n};\n\nexport interface ResourceAdmission {\n\tacquire(\n\t\tkind: \"session\" | \"process\",\n\t\tsignal?: AbortSignal,\n\t\trequest?: ResourceAdmissionRequest,\n\t): Promise<ResourcePermit>;\n}\n\n/** Result from createAgentSession */\nexport interface CreateAgentSessionResult {\n\t/** The created session */\n\tsession: AgentSession;\n\t/** Extensions result (for UI context setup in interactive mode) */\n\textensionsResult: LoadExtensionsResult;\n\t/** Warning when a restored or configured model cannot be selected. */\n\tmodelFallbackMessage?: string;\n\t/** Semantic reason for modelFallbackMessage; suitable for mode control flow. */\n\tmodelFallbackReason?: ModelFallbackReason;\n\t/** The resolved workspace binding, when the session was created with `workspace`. */\n\tworkspace?: import(\"./workspace/resolve.ts\").BoundWorkspace;\n}\n"]}
|
package/dist/core/sdk.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../src/core/sdk.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../src/core/sdk.ts"],"names":[],"mappings":"AA2EA,OAAO,KAAK,EAAE,yBAAyB,EAAE,wBAAwB,EAAqB,MAAM,gBAAgB,CAAC;AAyC7G,YAAY,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,cAAc,kBAAkB,CAAC;AACjC,YAAY,EACX,aAAa,EACb,yBAAyB,EACzB,wBAAwB,EACxB,iBAAiB,EACjB,wBAAwB,EACxB,cAAc,EACd,uBAAuB,EACvB,oBAAoB,GACpB,MAAM,gBAAgB,CAAC;AA2ExB,wBAAsB,kBAAkB,CAAC,OAAO,GAAE,yBAA8B,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAEnH;AAED,4EAA4E;AAC5E,wBAAgB,2BAA2B,CAC1C,OAAO,EAAE,yBAAyB,EAClC,mBAAmB,UAAO,EAC1B,mBAAmB,UAAQ,GACzB,OAAO,CAAC,wBAAwB,CAAC,CAEnC"}
|
package/dist/core/sdk.js
CHANGED
|
@@ -42,6 +42,7 @@ import { scrubPreCompactionAssistantUsage } from "./provider-context-usage.js";
|
|
|
42
42
|
import { currentResourceAdmission } from "./resource-admission-scope.js";
|
|
43
43
|
import { canCloneDefaultResourceDiscovery, DefaultResourceLoader } from "./resource-loader.js";
|
|
44
44
|
import { prepareSessionResume, savedProjectTrustAsync, sessionResumeOptions } from "./resume/session-resume.js";
|
|
45
|
+
import { restoredCacheCheckpoint, restoredThinkingBudgets, withCacheCheckpoint } from "./resume-cache-checkpoint.js";
|
|
45
46
|
import { sessionAccountCheckpoint } from "./session-account-model.js";
|
|
46
47
|
import { sessionLifecycleCreation, sessionLifecycleScopes } from "./session-lifecycle-scope.js";
|
|
47
48
|
import { ownedSessionManagerStores, ownedSessionPermits, ownedSessionStores, sessionGenerationClosing, sessionLifetime, trackSessionWork, } from "./session-lifecycle-work.js";
|
|
@@ -60,6 +61,7 @@ import { selectStorage } from "./storage/selection.js";
|
|
|
60
61
|
import { assertTeamAdapterInstalled } from "./storage/team.js";
|
|
61
62
|
import { createChildCommandTaskOwner } from "./tasks/child-command-owner.js";
|
|
62
63
|
import { time } from "./timings.js";
|
|
64
|
+
import { isToolDeclarationHidden } from "./tool-loadout.js";
|
|
63
65
|
import { createToolNameMatcher } from "./tool-selection.js";
|
|
64
66
|
import { refreshConfig as refreshAskUserQuestionConfig } from "./tools/ask-user-question/config.js";
|
|
65
67
|
import { allToolNames, defaultToolSelectionFor } from "./tools/index.js";
|
|
@@ -480,7 +482,15 @@ async function constructAgentSession(options, deferStart, persistInitialState, a
|
|
|
480
482
|
let agent;
|
|
481
483
|
let lastConvertedLlmMessages;
|
|
482
484
|
let requestForkBoundaries;
|
|
483
|
-
let
|
|
485
|
+
let cacheCheckpoint = restoredCacheCheckpoint(existingMessages);
|
|
486
|
+
/** The provider message each input message of the latest conversion became, by input position. */
|
|
487
|
+
let convertedRows;
|
|
488
|
+
const convertRecordingRows = (messages) => cacheCheckpoint
|
|
489
|
+
? convertToLlmWithForkBoundaries(messages, (normalized) => {
|
|
490
|
+
convertedRows = normalized;
|
|
491
|
+
})
|
|
492
|
+
: convertToLlm(messages);
|
|
493
|
+
let convertForRequest = convertRecordingRows;
|
|
484
494
|
if (openingPair) {
|
|
485
495
|
convertForRequest = (messages) => {
|
|
486
496
|
const pair = activeForkPair;
|
|
@@ -494,7 +504,15 @@ async function constructAgentSession(options, deferStart, persistInitialState, a
|
|
|
494
504
|
}
|
|
495
505
|
// Create convertToLlm wrapper that filters images if blockImages is enabled (defense-in-depth)
|
|
496
506
|
const convertToLlmWithBlockImages = (messages) => {
|
|
497
|
-
|
|
507
|
+
let converted = convertForRequest(messages);
|
|
508
|
+
// A fork's opening request matches its replay pair by message identity, so it is left as it is.
|
|
509
|
+
if (cacheCheckpoint && !openingPair && convertedRows) {
|
|
510
|
+
const checkpoint = withCacheCheckpoint(messages, convertedRows, converted, cacheCheckpoint);
|
|
511
|
+
converted = checkpoint.converted;
|
|
512
|
+
if (!checkpoint.keep)
|
|
513
|
+
cacheCheckpoint = undefined;
|
|
514
|
+
}
|
|
515
|
+
convertedRows = undefined;
|
|
498
516
|
// Check setting dynamically so mid-session changes take effect
|
|
499
517
|
if (!settingsManager.getBlockImages()) {
|
|
500
518
|
lastConvertedLlmMessages = converted;
|
|
@@ -595,6 +613,8 @@ async function constructAgentSession(options, deferStart, persistInitialState, a
|
|
|
595
613
|
return sanitizedPayload;
|
|
596
614
|
};
|
|
597
615
|
const onPayload = (payload, model) => preparePayload(payload, model);
|
|
616
|
+
// A forked subagent keeps the prompt-cache key of the session whose conversation it continues.
|
|
617
|
+
const requestSessionId = () => options.systemPromptSections?.fork?.sessionId ?? sessionManager.getSessionId();
|
|
598
618
|
agent = new Agent({
|
|
599
619
|
initialState: {
|
|
600
620
|
systemPrompt: "",
|
|
@@ -613,7 +633,7 @@ async function constructAgentSession(options, deferStart, persistInitialState, a
|
|
|
613
633
|
// Consume even if authentication, a hook, or the transport fails.
|
|
614
634
|
openingPair = undefined;
|
|
615
635
|
activeForkPair = undefined;
|
|
616
|
-
convertForRequest =
|
|
636
|
+
convertForRequest = convertRecordingRows;
|
|
617
637
|
requestForkBoundaries = undefined;
|
|
618
638
|
header = undefined;
|
|
619
639
|
session._requestContextProjectionTransform = undefined;
|
|
@@ -711,7 +731,7 @@ async function constructAgentSession(options, deferStart, persistInitialState, a
|
|
|
711
731
|
return { authResult, requestModel, fastRouteStreamOptions, requestOptions };
|
|
712
732
|
};
|
|
713
733
|
const { authResult, requestModel, fastRouteStreamOptions, requestOptions } = await prepare();
|
|
714
|
-
if (streamOptions?.sessionId ===
|
|
734
|
+
if (streamOptions?.sessionId === requestSessionId()) {
|
|
715
735
|
const prefix = [...agent.state.messages];
|
|
716
736
|
const warmOptions = {
|
|
717
737
|
...fastRouteStreamOptions,
|
|
@@ -776,7 +796,7 @@ async function constructAgentSession(options, deferStart, persistInitialState, a
|
|
|
776
796
|
headers: response.headers,
|
|
777
797
|
});
|
|
778
798
|
},
|
|
779
|
-
sessionId:
|
|
799
|
+
sessionId: requestSessionId(),
|
|
780
800
|
transformContext: async (messages) => {
|
|
781
801
|
const runner = extensionRunnerRef.current;
|
|
782
802
|
const transformed = runner ? await runner.emitContext(messages) : messages;
|
|
@@ -785,7 +805,7 @@ async function constructAgentSession(options, deferStart, persistInitialState, a
|
|
|
785
805
|
steeringMode: settingsManager.getSteeringMode(),
|
|
786
806
|
followUpMode: settingsManager.getFollowUpMode(),
|
|
787
807
|
transport: settingsManager.getTransport(),
|
|
788
|
-
thinkingBudgets: settingsManager.getThinkingBudgets(),
|
|
808
|
+
thinkingBudgets: restoredThinkingBudgets(existingMessages, model, thinkingLevel, settingsManager.getThinkingBudgets()),
|
|
789
809
|
maxRetryDelayMs: settingsManager.getProviderRetrySettings().maxRetryDelayMs,
|
|
790
810
|
});
|
|
791
811
|
// This stream resolves auth through modelRuntime, so summaries must not pre-resolve it (upstream #11520).
|
|
@@ -825,28 +845,36 @@ async function constructAgentSession(options, deferStart, persistInitialState, a
|
|
|
825
845
|
worktreeSnapshots: options.snapshots === undefined
|
|
826
846
|
? undefined
|
|
827
847
|
: resolveWorktreeSnapshotSettings(options.snapshots, "sdk", "snapshots", settingsManager.getWorktreeSnapshotSettings()),
|
|
828
|
-
childSessionOptions: (child) =>
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
848
|
+
childSessionOptions: (child) => ({
|
|
849
|
+
...inheritChildSessionOptionsWithDefaults({
|
|
850
|
+
cwd,
|
|
851
|
+
agentDir,
|
|
852
|
+
modelRuntime,
|
|
853
|
+
settingsManager,
|
|
854
|
+
model: session.model,
|
|
855
|
+
thinkingLevel: session.thinkingLevel,
|
|
856
|
+
fallbackModels: options.fallbackModels ?? settingsManager.getFallbackModels(),
|
|
857
|
+
isFallbackModelAllowed: options.isFallbackModelAllowed,
|
|
858
|
+
builtins: childBuiltins,
|
|
859
|
+
tools: allowedToolNames,
|
|
860
|
+
noTools: options.noTools,
|
|
861
|
+
excludedTools: childExcludedTools,
|
|
862
|
+
customTools: options.customTools,
|
|
863
|
+
extensionBindings: session.extensionRunner.getChildHostBindings(),
|
|
864
|
+
parentCommandTaskOwner: childCommandTaskOwner,
|
|
865
|
+
inheritedHistory: childHistory,
|
|
866
|
+
resourceAdmission: options.resourceAdmission,
|
|
867
|
+
workspace,
|
|
868
|
+
parentUsageSink: reportChildUsage,
|
|
869
|
+
...(intercomPolicy === undefined ? {} : { parentIntercomPolicy: intercomPolicy }),
|
|
870
|
+
}, child, session.getAllTools().map((tool) => tool.name), builtinDefaultToolNames),
|
|
871
|
+
parentHiddenTools: session
|
|
872
|
+
.getActiveToolNames()
|
|
873
|
+
.filter((name) => isToolDeclarationHidden(session, name)),
|
|
874
|
+
parentToolNames: session
|
|
875
|
+
.getActiveToolNames()
|
|
876
|
+
.filter((name) => !isToolDeclarationHidden(session, name)),
|
|
877
|
+
}),
|
|
850
878
|
scopedModels: options.scopedModels,
|
|
851
879
|
// Undefined follows the settings' current `fallbackModels`, also once a project is trusted later.
|
|
852
880
|
fallbackModels: options.fallbackModels,
|
|
@@ -868,6 +896,7 @@ async function constructAgentSession(options, deferStart, persistInitialState, a
|
|
|
868
896
|
inheritedHistory: options.inheritedHistory,
|
|
869
897
|
resourceAdmission: options.resourceAdmission ?? undefined,
|
|
870
898
|
systemPromptTransform: options.systemPromptTransform,
|
|
899
|
+
systemPromptSections: options.systemPromptSections,
|
|
871
900
|
contextProjectionTransform: options.initialContextTransform,
|
|
872
901
|
workspace,
|
|
873
902
|
});
|