@draht/coding-agent 2026.9.5-1 → 2026.10.4-2
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 +452 -0
- package/dist/bun/cli.d.ts +1 -1
- package/dist/bun/cli.d.ts.map +1 -1
- package/dist/bun/cli.js +6 -3
- package/dist/bun/cli.js.map +1 -1
- package/dist/bun/sandbox-env-setup.d.ts +2 -0
- package/dist/bun/sandbox-env-setup.d.ts.map +1 -0
- package/dist/bun/sandbox-env-setup.js +4 -0
- package/dist/bun/sandbox-env-setup.js.map +1 -0
- package/dist/bundle/chunks/anthropic-messages-GAKYXF65.js +6 -0
- package/dist/bundle/chunks/anthropic.js +75 -0
- package/dist/bundle/chunks/azure-openai-responses-ZIXMK6JO.js +2 -0
- package/dist/bundle/chunks/bedrock-converse-stream.js +79 -0
- package/dist/bundle/chunks/chunk-2E5VODES.js +2 -0
- package/dist/bundle/chunks/chunk-2FBJKY7F.js +2 -0
- package/dist/bundle/chunks/chunk-2N4I6WXC.js +2 -0
- package/dist/bundle/chunks/chunk-5VZWYVZB.js +82 -0
- package/dist/bundle/chunks/chunk-63BK6WK2.js +2 -0
- package/dist/bundle/chunks/chunk-6MSE6LZ3.js +6 -0
- package/dist/bundle/chunks/chunk-6ZJKIMU7.js +2 -0
- package/dist/bundle/chunks/chunk-736QBNUZ.js +12 -0
- package/dist/bundle/chunks/chunk-BXSHCX3G.js +11 -0
- package/dist/bundle/chunks/chunk-CEJJ5XF2.js +170 -0
- package/dist/bundle/chunks/chunk-COF5JT7R.js +4 -0
- package/dist/bundle/chunks/chunk-D6TMD5Q2.js +44 -0
- package/dist/bundle/chunks/chunk-DPE4ALPU.js +146 -0
- package/dist/bundle/chunks/chunk-EBVYI75P.js +2 -0
- package/dist/bundle/chunks/chunk-GVXA72ZA.js +2 -0
- package/dist/bundle/chunks/chunk-H6FT43VC.js +137 -0
- package/dist/bundle/chunks/chunk-HJ72RANT.js +2 -0
- package/dist/bundle/chunks/chunk-HTJ3L72O.js +2 -0
- package/dist/bundle/chunks/chunk-HZ2UHMBT.js +2 -0
- package/dist/bundle/chunks/chunk-I5OKY6RH.js +11 -0
- package/dist/bundle/chunks/chunk-IWTUBX6V.js +4 -0
- package/dist/bundle/chunks/chunk-KPO5375S.js +2 -0
- package/dist/bundle/chunks/chunk-KVH4HR57.js +31 -0
- package/dist/bundle/chunks/chunk-LDAOC5RB.js +18 -0
- package/dist/bundle/chunks/chunk-ON6XU6AG.js +2 -0
- package/dist/bundle/chunks/chunk-QMN7OD6G.js +2 -0
- package/dist/bundle/chunks/chunk-RZKPFWMH.js +42 -0
- package/dist/bundle/chunks/chunk-SDRCE6OP.js +2 -0
- package/dist/bundle/chunks/chunk-SVNWI7EV.js +8 -0
- package/dist/bundle/chunks/chunk-TIA2T6EO.js +3 -0
- package/dist/bundle/chunks/chunk-VOFPZOUQ.js +1472 -0
- package/dist/bundle/chunks/chunk-XBUEMKIY.js +2 -0
- package/dist/bundle/chunks/chunk-XOGEYN4Q.js +2 -0
- package/dist/bundle/chunks/chunk-ZZD35WKM.js +2 -0
- package/dist/bundle/chunks/cli-SR5QBZH4.js +51 -0
- package/dist/bundle/chunks/cloudflare-workers-ai-system-one-MJKOAE5S.js +2 -0
- package/dist/bundle/chunks/codemode-worker.js +315 -0
- package/dist/bundle/chunks/execute-VCYDHEYA.js +328 -0
- package/dist/bundle/chunks/github-copilot.js +2 -0
- package/dist/bundle/chunks/google-antigravity.js +75 -0
- package/dist/bundle/chunks/google-gemini-cli.js +75 -0
- package/dist/bundle/chunks/google-generative-ai-RPUPQ6PM.js +2 -0
- package/dist/bundle/chunks/google-vertex-EZES5QVQ.js +2 -0
- package/dist/bundle/chunks/https-proxy-agent-O2PVUIOI.js +13 -0
- package/dist/bundle/chunks/image-resize-worker.js +2 -0
- package/dist/bundle/chunks/jiti-loader-RKXLMQV2.js +2 -0
- package/dist/bundle/chunks/kimi-coding.js +2 -0
- package/dist/bundle/chunks/lib-XOG5PI3Y.js +9 -0
- package/dist/bundle/chunks/llama-cpp-classify-EJ5XMSQL.js +22 -0
- package/dist/bundle/chunks/meta.js +2 -0
- package/dist/bundle/chunks/mistral-conversations-AOYGU43Y.js +5 -0
- package/dist/bundle/chunks/multipart-parser-AZP5BX2W.js +3 -0
- package/dist/bundle/chunks/node-C2JGH2OB.js +2 -0
- package/dist/bundle/chunks/node-LQ52KV6B.js +16 -0
- package/dist/bundle/chunks/openai-chatgpt.js +75 -0
- package/dist/bundle/chunks/openai-codex-responses-M2Y77JEQ.js +10 -0
- package/dist/bundle/chunks/openai-codex.js +75 -0
- package/dist/bundle/chunks/openai-completions-A4OKYOYV.js +7 -0
- package/dist/bundle/chunks/openai-responses-6IXV53T3.js +3 -0
- package/dist/bundle/chunks/opencode-go.js +2 -0
- package/dist/bundle/chunks/openrouter-images-LYV4NKFM.js +2 -0
- package/dist/bundle/chunks/openrouter.js +75 -0
- package/dist/bundle/chunks/pi-messages-KKMEUT3Z.js +8 -0
- package/dist/bundle/chunks/radius.js +75 -0
- package/dist/bundle/chunks/runtime-6YJPGSP7.js +2 -0
- package/dist/bundle/chunks/settings-manager-D2EG7WDO.js +2 -0
- package/dist/bundle/chunks/src-TIBHS42X.js +4 -0
- package/dist/bundle/chunks/typesafe-system-one-YBEEY5XU.js +2 -0
- package/dist/bundle/chunks/virtual-modules-CBOAFAFT.js +2 -0
- package/dist/bundle/chunks/xai.js +75 -0
- package/dist/bundle/cli-runtime.js +3 -0
- package/dist/bundle/cli.js +5 -0
- package/dist/bundle/index.js +2 -0
- package/dist/bundle/rpc-entry.js +3 -0
- package/dist/cli/args.d.ts +4 -0
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +72 -21
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/auth-check.d.ts +19 -0
- package/dist/cli/auth-check.d.ts.map +1 -0
- package/dist/cli/auth-check.js +50 -0
- package/dist/cli/auth-check.js.map +1 -0
- package/dist/cli/auth-command.d.ts +24 -0
- package/dist/cli/auth-command.d.ts.map +1 -0
- package/dist/cli/auth-command.js +103 -0
- package/dist/cli/auth-command.js.map +1 -0
- package/dist/cli/config-selector.d.ts.map +1 -1
- package/dist/cli/config-selector.js +3 -2
- package/dist/cli/config-selector.js.map +1 -1
- package/dist/cli/credential-print.d.ts +5 -3
- package/dist/cli/credential-print.d.ts.map +1 -1
- package/dist/cli/credential-print.js +42 -30
- package/dist/cli/credential-print.js.map +1 -1
- package/dist/cli/file-processor.d.ts +1 -1
- package/dist/cli/file-processor.d.ts.map +1 -1
- package/dist/cli/file-processor.js +2 -1
- package/dist/cli/file-processor.js.map +1 -1
- package/dist/cli/list-models.d.ts +1 -1
- package/dist/cli/list-models.d.ts.map +1 -1
- package/dist/cli/list-models.js +2 -2
- package/dist/cli/list-models.js.map +1 -1
- package/dist/cli/session-picker.d.ts +1 -1
- package/dist/cli/session-picker.d.ts.map +1 -1
- package/dist/cli/session-picker.js.map +1 -1
- package/dist/cli/setup.d.ts +2 -0
- package/dist/cli/setup.d.ts.map +1 -0
- package/dist/cli/setup.js +12 -0
- package/dist/cli/setup.js.map +1 -0
- package/dist/cli/startup-ui.d.ts +2 -2
- package/dist/cli/startup-ui.d.ts.map +1 -1
- package/dist/cli/startup-ui.js +42 -33
- package/dist/cli/startup-ui.js.map +1 -1
- package/dist/cli.js +3 -12
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +20 -4
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +42 -6
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +12 -3
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session-services.d.ts +1 -0
- package/dist/core/agent-session-services.d.ts.map +1 -1
- package/dist/core/agent-session-services.js +14 -0
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session.d.ts +237 -39
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +1386 -565
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/auth-storage.d.ts +20 -8
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +199 -56
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/bug-report-upload.d.ts +11 -0
- package/dist/core/bug-report-upload.d.ts.map +1 -0
- package/dist/core/bug-report-upload.js +20 -0
- package/dist/core/bug-report-upload.js.map +1 -0
- package/dist/core/bug-report.d.ts +176 -0
- package/dist/core/bug-report.d.ts.map +1 -0
- package/dist/core/bug-report.js +292 -0
- package/dist/core/bug-report.js.map +1 -0
- package/dist/core/builtins/duet.js +2 -2
- package/dist/core/builtins/duet.js.map +1 -1
- package/dist/core/cache-stats.d.ts.map +1 -1
- package/dist/core/cache-stats.js +12 -1
- package/dist/core/cache-stats.js.map +1 -1
- package/dist/core/cache-warmer.d.ts +103 -0
- package/dist/core/cache-warmer.d.ts.map +1 -0
- package/dist/core/cache-warmer.js +356 -0
- package/dist/core/cache-warmer.js.map +1 -0
- package/dist/core/checkpoints/checkpoint-manager.d.ts +8 -4
- package/dist/core/checkpoints/checkpoint-manager.d.ts.map +1 -1
- package/dist/core/checkpoints/checkpoint-manager.js +46 -10
- package/dist/core/checkpoints/checkpoint-manager.js.map +1 -1
- package/dist/core/checkpoints/rewind.d.ts +4 -2
- package/dist/core/checkpoints/rewind.d.ts.map +1 -1
- package/dist/core/checkpoints/rewind.js +4 -3
- package/dist/core/checkpoints/rewind.js.map +1 -1
- package/dist/core/compaction/branch-summarization.js +2 -2
- package/dist/core/compaction/branch-summarization.js.map +1 -1
- package/dist/core/compaction/compaction.d.ts +9 -6
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +196 -118
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/compaction/utils.d.ts +2 -1
- package/dist/core/compaction/utils.d.ts.map +1 -1
- package/dist/core/compaction/utils.js +25 -18
- package/dist/core/compaction/utils.js.map +1 -1
- package/dist/core/crash-log.d.ts +27 -0
- package/dist/core/crash-log.d.ts.map +1 -0
- package/dist/core/crash-log.js +140 -0
- package/dist/core/crash-log.js.map +1 -0
- package/dist/core/defaults.d.ts +1 -0
- package/dist/core/defaults.d.ts.map +1 -1
- package/dist/core/defaults.js +9 -0
- package/dist/core/defaults.js.map +1 -1
- package/dist/core/experimental.js +1 -1
- package/dist/core/experimental.js.map +1 -1
- package/dist/core/export-html/template.css +10 -0
- package/dist/core/export-html/template.js +72 -18
- package/dist/core/extensions/index.d.ts +2 -2
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js +1 -1
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/jiti-loader.d.ts +2 -0
- package/dist/core/extensions/jiti-loader.d.ts.map +1 -0
- package/dist/core/extensions/jiti-loader.js +5 -0
- package/dist/core/extensions/jiti-loader.js.map +1 -0
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +228 -89
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +47 -8
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +376 -104
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/types.d.ts +521 -88
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js +3 -0
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/extensions/virtual-modules.d.ts +3 -0
- package/dist/core/extensions/virtual-modules.d.ts.map +1 -0
- package/dist/core/extensions/virtual-modules.js +37 -0
- package/dist/core/extensions/virtual-modules.js.map +1 -0
- package/dist/core/extensions/wrapper.d.ts +2 -2
- package/dist/core/extensions/wrapper.d.ts.map +1 -1
- package/dist/core/extensions/wrapper.js +3 -22
- package/dist/core/extensions/wrapper.js.map +1 -1
- package/dist/core/footer-data-provider.d.ts +1 -1
- package/dist/core/footer-data-provider.js +19 -18
- package/dist/core/footer-data-provider.js.map +1 -1
- package/dist/core/index.d.ts +2 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/keybindings.d.ts +83 -13
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +33 -7
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/mcp-servers.d.ts +119 -0
- package/dist/core/mcp-servers.d.ts.map +1 -0
- package/dist/core/mcp-servers.js +191 -0
- package/dist/core/mcp-servers.js.map +1 -0
- package/dist/core/messages.d.ts +1 -1
- package/dist/core/messages.d.ts.map +1 -1
- package/dist/core/messages.js +1 -0
- package/dist/core/messages.js.map +1 -1
- package/dist/core/model-config.d.ts +202 -20
- package/dist/core/model-config.d.ts.map +1 -1
- package/dist/core/model-config.js +53 -18
- package/dist/core/model-config.js.map +1 -1
- package/dist/core/model-registry.d.ts +19 -2
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +39 -2
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-resolver.d.ts +7 -5
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +29 -17
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/model-runtime.d.ts +79 -20
- package/dist/core/model-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js +460 -134
- package/dist/core/model-runtime.js.map +1 -1
- package/dist/core/models-store.d.ts +12 -7
- package/dist/core/models-store.d.ts.map +1 -1
- package/dist/core/models-store.js +87 -18
- package/dist/core/models-store.js.map +1 -1
- package/dist/core/multi-agent/fsm.js +8 -3
- package/dist/core/multi-agent/fsm.js.map +1 -1
- package/dist/core/multi-agent/mailbox.js +1 -3
- package/dist/core/multi-agent/mailbox.js.map +1 -1
- package/dist/core/multi-agent/permission-gate.d.ts +5 -2
- package/dist/core/multi-agent/permission-gate.d.ts.map +1 -1
- package/dist/core/multi-agent/permission-gate.js +597 -34
- package/dist/core/multi-agent/permission-gate.js.map +1 -1
- package/dist/core/multi-agent/task-board.js +2 -4
- package/dist/core/multi-agent/task-board.js.map +1 -1
- package/dist/core/multi-agent/worktree.js +1 -3
- package/dist/core/multi-agent/worktree.js.map +1 -1
- package/dist/core/nested-tool-calls.d.ts +102 -0
- package/dist/core/nested-tool-calls.d.ts.map +1 -0
- package/dist/core/nested-tool-calls.js +178 -0
- package/dist/core/nested-tool-calls.js.map +1 -0
- package/dist/core/package-manager.d.ts +10 -0
- package/dist/core/package-manager.d.ts.map +1 -1
- package/dist/core/package-manager.js +149 -33
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/pi-manifest.d.ts.map +1 -1
- package/dist/core/pi-manifest.js +13 -12
- package/dist/core/pi-manifest.js.map +1 -1
- package/dist/core/prompt-templates.d.ts +6 -1
- package/dist/core/prompt-templates.d.ts.map +1 -1
- package/dist/core/prompt-templates.js +63 -37
- package/dist/core/prompt-templates.js.map +1 -1
- package/dist/core/provider-attribution.js +5 -5
- package/dist/core/provider-attribution.js.map +1 -1
- package/dist/core/provider-composer.d.ts +44 -20
- package/dist/core/provider-composer.d.ts.map +1 -1
- package/dist/core/provider-composer.js +151 -51
- package/dist/core/provider-composer.js.map +1 -1
- package/dist/core/radius.d.ts +13 -0
- package/dist/core/radius.d.ts.map +1 -1
- package/dist/core/radius.js +19 -0
- package/dist/core/radius.js.map +1 -1
- package/dist/core/remote-catalog-provider.d.ts +10 -3
- package/dist/core/remote-catalog-provider.d.ts.map +1 -1
- package/dist/core/remote-catalog-provider.js +105 -81
- package/dist/core/remote-catalog-provider.js.map +1 -1
- package/dist/core/resource-loader.d.ts +7 -1
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +219 -42
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/runtime-credentials.d.ts +5 -5
- package/dist/core/runtime-credentials.d.ts.map +1 -1
- package/dist/core/runtime-credentials.js +13 -9
- package/dist/core/runtime-credentials.js.map +1 -1
- package/dist/core/sandbox/executor.js +1 -0
- package/dist/core/sandbox/executor.js.map +1 -1
- package/dist/core/sdk.d.ts +7 -5
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +100 -52
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-cwd.js +1 -0
- package/dist/core/session-cwd.js.map +1 -1
- package/dist/core/session-export.d.ts +8 -0
- package/dist/core/session-export.d.ts.map +1 -0
- package/dist/core/session-export.js +33 -0
- package/dist/core/session-export.js.map +1 -0
- package/dist/core/session-manager.d.ts +75 -15
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +314 -144
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/settings-diagnostics.d.ts +9 -0
- package/dist/core/settings-diagnostics.d.ts.map +1 -0
- package/dist/core/settings-diagnostics.js +21 -0
- package/dist/core/settings-diagnostics.js.map +1 -0
- package/dist/core/settings-manager.d.ts +84 -4
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +239 -25
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/skills.d.ts.map +1 -1
- package/dist/core/skills.js +51 -33
- package/dist/core/skills.js.map +1 -1
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +3 -1
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/soak/soak-log.js +6 -0
- package/dist/core/soak/soak-log.js.map +1 -1
- package/dist/core/socket-server/socket-server.js +11 -0
- package/dist/core/socket-server/socket-server.js.map +1 -1
- package/dist/core/socket-server/types.d.ts +2 -1
- package/dist/core/socket-server/types.d.ts.map +1 -1
- package/dist/core/socket-server/types.js.map +1 -1
- package/dist/core/source-info.d.ts +8 -0
- package/dist/core/source-info.d.ts.map +1 -1
- package/dist/core/source-info.js +16 -0
- package/dist/core/source-info.js.map +1 -1
- package/dist/core/system-prompt.d.ts +49 -6
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +126 -89
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tools/bash.d.ts +32 -2
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +82 -143
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/edit-diff.d.ts +0 -5
- package/dist/core/tools/edit-diff.d.ts.map +1 -1
- package/dist/core/tools/edit-diff.js +2 -5
- package/dist/core/tools/edit-diff.js.map +1 -1
- package/dist/core/tools/edit.d.ts +5 -12
- package/dist/core/tools/edit.d.ts.map +1 -1
- package/dist/core/tools/edit.js +19 -171
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/core/tools/find.d.ts +4 -0
- package/dist/core/tools/find.d.ts.map +1 -1
- package/dist/core/tools/find.js +11 -58
- package/dist/core/tools/find.js.map +1 -1
- package/dist/core/tools/grep.d.ts +4 -0
- package/dist/core/tools/grep.d.ts.map +1 -1
- package/dist/core/tools/grep.js +10 -62
- package/dist/core/tools/grep.js.map +1 -1
- package/dist/core/tools/index.d.ts +4 -1
- package/dist/core/tools/index.d.ts.map +1 -1
- package/dist/core/tools/index.js +18 -1
- package/dist/core/tools/index.js.map +1 -1
- package/dist/core/tools/ls.d.ts +4 -0
- package/dist/core/tools/ls.d.ts.map +1 -1
- package/dist/core/tools/ls.js +9 -50
- package/dist/core/tools/ls.js.map +1 -1
- package/dist/core/tools/output-accumulator.d.ts +11 -0
- package/dist/core/tools/output-accumulator.d.ts.map +1 -1
- package/dist/core/tools/output-accumulator.js +54 -12
- package/dist/core/tools/output-accumulator.js.map +1 -1
- package/dist/core/tools/powershell.d.ts +16 -0
- package/dist/core/tools/powershell.d.ts.map +1 -0
- package/dist/core/tools/powershell.js +39 -0
- package/dist/core/tools/powershell.js.map +1 -0
- package/dist/core/tools/read.d.ts +8 -1
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +16 -123
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/tools/render-utils.d.ts +6 -0
- package/dist/core/tools/render-utils.d.ts.map +1 -1
- package/dist/core/tools/render-utils.js +26 -0
- package/dist/core/tools/render-utils.js.map +1 -1
- package/dist/core/tools/renderers/bash.d.ts +12 -0
- package/dist/core/tools/renderers/bash.d.ts.map +1 -0
- package/dist/core/tools/renderers/bash.js +117 -0
- package/dist/core/tools/renderers/bash.js.map +1 -0
- package/dist/core/tools/renderers/edit.d.ts +23 -0
- package/dist/core/tools/renderers/edit.d.ts.map +1 -0
- package/dist/core/tools/renderers/edit.js +167 -0
- package/dist/core/tools/renderers/edit.js.map +1 -0
- package/dist/core/tools/renderers/find.d.ts +10 -0
- package/dist/core/tools/renderers/find.d.ts.map +1 -0
- package/dist/core/tools/renderers/find.js +64 -0
- package/dist/core/tools/renderers/find.js.map +1 -0
- package/dist/core/tools/renderers/grep.d.ts +10 -0
- package/dist/core/tools/renderers/grep.d.ts.map +1 -0
- package/dist/core/tools/renderers/grep.js +69 -0
- package/dist/core/tools/renderers/grep.js.map +1 -0
- package/dist/core/tools/renderers/index.d.ts +28 -0
- package/dist/core/tools/renderers/index.d.ts.map +1 -0
- package/dist/core/tools/renderers/index.js +47 -0
- package/dist/core/tools/renderers/index.js.map +1 -0
- package/dist/core/tools/renderers/ls.d.ts +10 -0
- package/dist/core/tools/renderers/ls.d.ts.map +1 -0
- package/dist/core/tools/renderers/ls.js +58 -0
- package/dist/core/tools/renderers/ls.js.map +1 -0
- package/dist/core/tools/renderers/read.d.ts +11 -0
- package/dist/core/tools/renderers/read.d.ts.map +1 -0
- package/dist/core/tools/renderers/read.js +130 -0
- package/dist/core/tools/renderers/read.js.map +1 -0
- package/dist/core/tools/renderers/write.d.ts +10 -0
- package/dist/core/tools/renderers/write.d.ts.map +1 -0
- package/dist/core/tools/renderers/write.js +153 -0
- package/dist/core/tools/renderers/write.js.map +1 -0
- package/dist/core/tools/tool-definition-wrapper.d.ts +5 -3
- package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -1
- package/dist/core/tools/tool-definition-wrapper.js +3 -1
- package/dist/core/tools/tool-definition-wrapper.js.map +1 -1
- package/dist/core/tools/truncate.d.ts +14 -0
- package/dist/core/tools/truncate.d.ts.map +1 -1
- package/dist/core/tools/truncate.js +29 -0
- package/dist/core/tools/truncate.js.map +1 -1
- package/dist/core/tools/write.d.ts +4 -0
- package/dist/core/tools/write.d.ts.map +1 -1
- package/dist/core/tools/write.js +12 -147
- package/dist/core/tools/write.js.map +1 -1
- package/dist/core/trust-manager.d.ts.map +1 -1
- package/dist/core/trust-manager.js +4 -1
- package/dist/core/trust-manager.js.map +1 -1
- package/dist/core/usage-totals.d.ts +3 -1
- package/dist/core/usage-totals.d.ts.map +1 -1
- package/dist/core/usage-totals.js +28 -1
- package/dist/core/usage-totals.js.map +1 -1
- package/dist/core/virtual-models.d.ts +117 -0
- package/dist/core/virtual-models.d.ts.map +1 -0
- package/dist/core/virtual-models.js +124 -0
- package/dist/core/virtual-models.js.map +1 -0
- package/dist/experimental/micro/api.d.ts +81 -0
- package/dist/experimental/micro/api.d.ts.map +1 -0
- package/dist/experimental/micro/api.js +2 -0
- package/dist/experimental/micro/api.js.map +1 -0
- package/dist/experimental/micro/main.d.ts +3 -0
- package/dist/experimental/micro/main.d.ts.map +1 -0
- package/dist/experimental/micro/main.js +21 -0
- package/dist/experimental/micro/main.js.map +1 -0
- package/dist/experimental/micro/models.d.ts +11 -0
- package/dist/experimental/micro/models.d.ts.map +1 -0
- package/dist/experimental/micro/models.js +95 -0
- package/dist/experimental/micro/models.js.map +1 -0
- package/dist/experimental/micro/runtime.d.ts +12 -0
- package/dist/experimental/micro/runtime.d.ts.map +1 -0
- package/dist/experimental/micro/runtime.js +465 -0
- package/dist/experimental/micro/runtime.js.map +1 -0
- package/dist/experimental/micro/sessions.d.ts +10 -0
- package/dist/experimental/micro/sessions.d.ts.map +1 -0
- package/dist/experimental/micro/sessions.js +41 -0
- package/dist/experimental/micro/sessions.js.map +1 -0
- package/dist/experimental/micro/tools.d.ts +10 -0
- package/dist/experimental/micro/tools.d.ts.map +1 -0
- package/dist/experimental/micro/tools.js +96 -0
- package/dist/experimental/micro/tools.js.map +1 -0
- package/dist/experimental/micro/tui.d.ts +3 -0
- package/dist/experimental/micro/tui.d.ts.map +1 -0
- package/dist/experimental/micro/tui.js +510 -0
- package/dist/experimental/micro/tui.js.map +1 -0
- package/dist/experimental/mini/main.d.ts +7 -0
- package/dist/experimental/mini/main.d.ts.map +1 -0
- package/dist/experimental/mini/main.js +21 -0
- package/dist/experimental/mini/main.js.map +1 -0
- package/dist/experimental/mini/server/entry.d.ts +3 -0
- package/dist/experimental/mini/server/entry.d.ts.map +1 -0
- package/dist/experimental/mini/server/entry.js +11 -0
- package/dist/experimental/mini/server/entry.js.map +1 -0
- package/dist/experimental/mini/server/run.d.ts +13 -0
- package/dist/experimental/mini/server/run.d.ts.map +1 -0
- package/dist/experimental/mini/server/run.js +150 -0
- package/dist/experimental/mini/server/run.js.map +1 -0
- package/dist/experimental/mini/shared/protocol.d.ts +127 -0
- package/dist/experimental/mini/shared/protocol.d.ts.map +1 -0
- package/dist/experimental/mini/shared/protocol.js +13 -0
- package/dist/experimental/mini/shared/protocol.js.map +1 -0
- package/dist/experimental/mini/shared/rpc.d.ts +49 -0
- package/dist/experimental/mini/shared/rpc.d.ts.map +1 -0
- package/dist/experimental/mini/shared/rpc.js +171 -0
- package/dist/experimental/mini/shared/rpc.js.map +1 -0
- package/dist/experimental/mini/shared/transport.d.ts +35 -0
- package/dist/experimental/mini/shared/transport.d.ts.map +1 -0
- package/dist/experimental/mini/shared/transport.js +94 -0
- package/dist/experimental/mini/shared/transport.js.map +1 -0
- package/dist/experimental/mini/tui/run.d.ts +9 -0
- package/dist/experimental/mini/tui/run.d.ts.map +1 -0
- package/dist/experimental/mini/tui/run.js +62 -0
- package/dist/experimental/mini/tui/run.js.map +1 -0
- package/dist/experimental/mini/tui/session.d.ts +26 -0
- package/dist/experimental/mini/tui/session.d.ts.map +1 -0
- package/dist/experimental/mini/tui/session.js +94 -0
- package/dist/experimental/mini/tui/session.js.map +1 -0
- package/dist/experimental/mini/tui/view.d.ts +10 -0
- package/dist/experimental/mini/tui/view.d.ts.map +1 -0
- package/dist/experimental/mini/tui/view.js +461 -0
- package/dist/experimental/mini/tui/view.js.map +1 -0
- package/dist/experimental/mini/worker/entry.d.ts +3 -0
- package/dist/experimental/mini/worker/entry.d.ts.map +1 -0
- package/dist/experimental/mini/worker/entry.js +10 -0
- package/dist/experimental/mini/worker/entry.js.map +1 -0
- package/dist/experimental/mini/worker/lane-service.d.ts +44 -0
- package/dist/experimental/mini/worker/lane-service.d.ts.map +1 -0
- package/dist/experimental/mini/worker/lane-service.js +97 -0
- package/dist/experimental/mini/worker/lane-service.js.map +1 -0
- package/dist/experimental/mini/worker/models-service.d.ts +19 -0
- package/dist/experimental/mini/worker/models-service.d.ts.map +1 -0
- package/dist/experimental/mini/worker/models-service.js +136 -0
- package/dist/experimental/mini/worker/models-service.js.map +1 -0
- package/dist/experimental/mini/worker/run.d.ts +14 -0
- package/dist/experimental/mini/worker/run.d.ts.map +1 -0
- package/dist/experimental/mini/worker/run.js +88 -0
- package/dist/experimental/mini/worker/run.js.map +1 -0
- package/dist/extensions/codemode/execute.d.ts +16 -0
- package/dist/extensions/codemode/execute.d.ts.map +1 -0
- package/dist/extensions/codemode/execute.js +429 -0
- package/dist/extensions/codemode/execute.js.map +1 -0
- package/dist/extensions/codemode/execute.lazy.d.ts +3 -0
- package/dist/extensions/codemode/execute.lazy.d.ts.map +1 -0
- package/dist/extensions/codemode/execute.lazy.js +3 -0
- package/dist/extensions/codemode/execute.lazy.js.map +1 -0
- package/dist/extensions/codemode/index.d.ts +21 -0
- package/dist/extensions/codemode/index.d.ts.map +1 -0
- package/dist/extensions/codemode/index.js +31 -0
- package/dist/extensions/codemode/index.js.map +1 -0
- package/dist/extensions/codemode/renderer.d.ts +12 -0
- package/dist/extensions/codemode/renderer.d.ts.map +1 -0
- package/dist/extensions/codemode/renderer.js +137 -0
- package/dist/extensions/codemode/renderer.js.map +1 -0
- package/dist/extensions/codemode/tool.d.ts +123 -0
- package/dist/extensions/codemode/tool.d.ts.map +1 -0
- package/dist/extensions/codemode/tool.js +315 -0
- package/dist/extensions/codemode/tool.js.map +1 -0
- package/dist/extensions/codemode/worker.d.ts +7 -0
- package/dist/extensions/codemode/worker.d.ts.map +1 -0
- package/dist/extensions/codemode/worker.js +7 -0
- package/dist/extensions/codemode/worker.js.map +1 -0
- package/dist/extensions/index.d.ts.map +1 -1
- package/dist/extensions/index.js +9 -1
- package/dist/extensions/index.js.map +1 -1
- package/dist/extensions/llama/client.d.ts +8 -0
- package/dist/extensions/llama/client.d.ts.map +1 -1
- package/dist/extensions/llama/client.js +13 -0
- package/dist/extensions/llama/client.js.map +1 -1
- package/dist/extensions/llama/huggingface.js +2 -0
- package/dist/extensions/llama/huggingface.js.map +1 -1
- package/dist/extensions/llama/index.d.ts.map +1 -1
- package/dist/extensions/llama/index.js +13 -2
- package/dist/extensions/llama/index.js.map +1 -1
- package/dist/extensions/llama/provider.d.ts +4 -2
- package/dist/extensions/llama/provider.d.ts.map +1 -1
- package/dist/extensions/llama/provider.js +119 -17
- package/dist/extensions/llama/provider.js.map +1 -1
- package/dist/extensions/llama/ui.js +28 -12
- package/dist/extensions/llama/ui.js.map +1 -1
- package/dist/extensions/mcp/cli.d.ts +21 -0
- package/dist/extensions/mcp/cli.d.ts.map +1 -0
- package/dist/extensions/mcp/cli.js +500 -0
- package/dist/extensions/mcp/cli.js.map +1 -0
- package/dist/extensions/mcp/cli.lazy.d.ts +3 -0
- package/dist/extensions/mcp/cli.lazy.d.ts.map +1 -0
- package/dist/extensions/mcp/cli.lazy.js +3 -0
- package/dist/extensions/mcp/cli.lazy.js.map +1 -0
- package/dist/extensions/mcp/config.d.ts +72 -0
- package/dist/extensions/mcp/config.d.ts.map +1 -0
- package/dist/extensions/mcp/config.js +158 -0
- package/dist/extensions/mcp/config.js.map +1 -0
- package/dist/extensions/mcp/index.d.ts +76 -0
- package/dist/extensions/mcp/index.d.ts.map +1 -0
- package/dist/extensions/mcp/index.js +1055 -0
- package/dist/extensions/mcp/index.js.map +1 -0
- package/dist/extensions/mcp/log.d.ts +16 -0
- package/dist/extensions/mcp/log.d.ts.map +1 -0
- package/dist/extensions/mcp/log.js +66 -0
- package/dist/extensions/mcp/log.js.map +1 -0
- package/dist/extensions/mcp/oauth.d.ts +96 -0
- package/dist/extensions/mcp/oauth.d.ts.map +1 -0
- package/dist/extensions/mcp/oauth.js +333 -0
- package/dist/extensions/mcp/oauth.js.map +1 -0
- package/dist/extensions/mcp/resources.d.ts +43 -0
- package/dist/extensions/mcp/resources.d.ts.map +1 -0
- package/dist/extensions/mcp/resources.js +262 -0
- package/dist/extensions/mcp/resources.js.map +1 -0
- package/dist/extensions/mcp/runtime.d.ts +98 -0
- package/dist/extensions/mcp/runtime.d.ts.map +1 -0
- package/dist/extensions/mcp/runtime.js +394 -0
- package/dist/extensions/mcp/runtime.js.map +1 -0
- package/dist/extensions/mcp/runtime.lazy.d.ts +3 -0
- package/dist/extensions/mcp/runtime.lazy.d.ts.map +1 -0
- package/dist/extensions/mcp/runtime.lazy.js +3 -0
- package/dist/extensions/mcp/runtime.lazy.js.map +1 -0
- package/dist/extensions/mcp/tools.d.ts +84 -0
- package/dist/extensions/mcp/tools.d.ts.map +1 -0
- package/dist/extensions/mcp/tools.js +251 -0
- package/dist/extensions/mcp/tools.js.map +1 -0
- package/dist/extensions/mcp/ui.d.ts +60 -0
- package/dist/extensions/mcp/ui.d.ts.map +1 -0
- package/dist/extensions/mcp/ui.js +174 -0
- package/dist/extensions/mcp/ui.js.map +1 -0
- package/dist/extensions/stub-provider/provider.d.ts +2 -2
- package/dist/extensions/stub-provider/provider.d.ts.map +1 -1
- package/dist/extensions/stub-provider/provider.js +2 -1
- package/dist/extensions/stub-provider/provider.js.map +1 -1
- package/dist/extensions/tool-search/index.d.ts +12 -0
- package/dist/extensions/tool-search/index.d.ts.map +1 -0
- package/dist/extensions/tool-search/index.js +15 -0
- package/dist/extensions/tool-search/index.js.map +1 -0
- package/dist/extensions/tool-search/tool.d.ts +73 -0
- package/dist/extensions/tool-search/tool.d.ts.map +1 -0
- package/dist/extensions/tool-search/tool.js +189 -0
- package/dist/extensions/tool-search/tool.js.map +1 -0
- package/dist/index.d.ts +20 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -6
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts +4 -0
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +123 -51
- package/dist/main.js.map +1 -1
- package/dist/migrations.d.ts +1 -1
- package/dist/migrations.js +7 -6
- package/dist/migrations.js.map +1 -1
- package/dist/modes/index.d.ts +1 -0
- package/dist/modes/index.d.ts.map +1 -1
- package/dist/modes/index.js.map +1 -1
- package/dist/modes/interactive/bug-report.d.ts +19 -0
- package/dist/modes/interactive/bug-report.d.ts.map +1 -0
- package/dist/modes/interactive/bug-report.js +211 -0
- package/dist/modes/interactive/bug-report.js.map +1 -0
- package/dist/modes/interactive/chat-viewport.d.ts +20 -0
- package/dist/modes/interactive/chat-viewport.d.ts.map +1 -0
- package/dist/modes/interactive/chat-viewport.js +28 -0
- package/dist/modes/interactive/chat-viewport.js.map +1 -0
- package/dist/modes/interactive/components/armin.js +10 -6
- package/dist/modes/interactive/components/armin.js.map +1 -1
- package/dist/modes/interactive/components/assistant-message.d.ts +6 -2
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/assistant-message.js +38 -15
- package/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/dist/modes/interactive/components/bash-execution.js +9 -4
- package/dist/modes/interactive/components/bash-execution.js.map +1 -1
- package/dist/modes/interactive/components/bordered-loader.js +3 -0
- package/dist/modes/interactive/components/bordered-loader.js.map +1 -1
- package/dist/modes/interactive/components/branch-summary-message.d.ts +1 -1
- package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/branch-summary-message.js +15 -6
- package/dist/modes/interactive/components/branch-summary-message.js.map +1 -1
- package/dist/modes/interactive/components/compaction-summary-message.d.ts +1 -1
- package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/compaction-summary-message.js +15 -6
- package/dist/modes/interactive/components/compaction-summary-message.js.map +1 -1
- package/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/config-selector.js +35 -8
- package/dist/modes/interactive/components/config-selector.js.map +1 -1
- package/dist/modes/interactive/components/countdown-timer.js +5 -0
- package/dist/modes/interactive/components/countdown-timer.js.map +1 -1
- package/dist/modes/interactive/components/custom-editor.d.ts +10 -1
- package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-editor.js +54 -2
- package/dist/modes/interactive/components/custom-editor.js.map +1 -1
- package/dist/modes/interactive/components/custom-entry.js +4 -1
- package/dist/modes/interactive/components/custom-entry.js.map +1 -1
- package/dist/modes/interactive/components/custom-message.js +7 -1
- package/dist/modes/interactive/components/custom-message.js.map +1 -1
- package/dist/modes/interactive/components/daxnuts.js +8 -6
- package/dist/modes/interactive/components/daxnuts.js.map +1 -1
- package/dist/modes/interactive/components/dynamic-border.js +1 -0
- package/dist/modes/interactive/components/dynamic-border.js.map +1 -1
- package/dist/modes/interactive/components/extension-editor.d.ts +4 -1
- package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-editor.js +14 -3
- package/dist/modes/interactive/components/extension-editor.js.map +1 -1
- package/dist/modes/interactive/components/extension-input.d.ts +2 -0
- package/dist/modes/interactive/components/extension-input.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-input.js +14 -2
- package/dist/modes/interactive/components/extension-input.js.map +1 -1
- package/dist/modes/interactive/components/extension-selector.d.ts +1 -0
- package/dist/modes/interactive/components/extension-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-selector.js +16 -1
- package/dist/modes/interactive/components/extension-selector.js.map +1 -1
- package/dist/modes/interactive/components/first-time-setup.d.ts +4 -4
- package/dist/modes/interactive/components/first-time-setup.d.ts.map +1 -1
- package/dist/modes/interactive/components/first-time-setup.js +12 -4
- package/dist/modes/interactive/components/first-time-setup.js.map +1 -1
- package/dist/modes/interactive/components/footer.d.ts +7 -0
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +51 -6
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/components/index.d.ts +1 -1
- package/dist/modes/interactive/components/index.d.ts.map +1 -1
- package/dist/modes/interactive/components/index.js.map +1 -1
- package/dist/modes/interactive/components/login-dialog.js +9 -3
- package/dist/modes/interactive/components/login-dialog.js.map +1 -1
- package/dist/modes/interactive/components/markdown-transform.d.ts +3 -0
- package/dist/modes/interactive/components/markdown-transform.d.ts.map +1 -0
- package/dist/modes/interactive/components/markdown-transform.js +19 -0
- package/dist/modes/interactive/components/markdown-transform.js.map +1 -0
- package/dist/modes/interactive/components/mermaid.d.ts +11 -0
- package/dist/modes/interactive/components/mermaid.d.ts.map +1 -0
- package/dist/modes/interactive/components/mermaid.js +75 -0
- package/dist/modes/interactive/components/mermaid.js.map +1 -0
- package/dist/modes/interactive/components/model-selector.d.ts +10 -4
- package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/model-selector.js +101 -40
- package/dist/modes/interactive/components/model-selector.js.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.js +11 -3
- package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.d.ts +4 -0
- package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.js +60 -32
- package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
- package/dist/modes/interactive/components/session-selector.d.ts +5 -5
- package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector.js +128 -78
- package/dist/modes/interactive/components/session-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts +23 -4
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +230 -67
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-submenu.d.ts +72 -0
- package/dist/modes/interactive/components/settings-submenu.d.ts.map +1 -0
- package/dist/modes/interactive/components/settings-submenu.js +165 -0
- package/dist/modes/interactive/components/settings-submenu.js.map +1 -0
- package/dist/modes/interactive/components/show-images-selector.js +1 -0
- package/dist/modes/interactive/components/show-images-selector.js.map +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.js +14 -5
- package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -1
- package/dist/modes/interactive/components/status-indicator.d.ts +3 -1
- package/dist/modes/interactive/components/status-indicator.d.ts.map +1 -1
- package/dist/modes/interactive/components/status-indicator.js +12 -3
- package/dist/modes/interactive/components/status-indicator.js.map +1 -1
- package/dist/modes/interactive/components/theme-selector.js +2 -0
- package/dist/modes/interactive/components/theme-selector.js.map +1 -1
- package/dist/modes/interactive/components/themed-text.d.ts +17 -0
- package/dist/modes/interactive/components/themed-text.d.ts.map +1 -0
- package/dist/modes/interactive/components/themed-text.js +29 -0
- package/dist/modes/interactive/components/themed-text.js.map +1 -0
- package/dist/modes/interactive/components/thinking-selector.d.ts +15 -3
- package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/thinking-selector.js +76 -18
- package/dist/modes/interactive/components/thinking-selector.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts +21 -4
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +78 -52
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector.js +44 -18
- package/dist/modes/interactive/components/tree-selector.js.map +1 -1
- package/dist/modes/interactive/components/trust-selector.js +8 -2
- package/dist/modes/interactive/components/trust-selector.js.map +1 -1
- package/dist/modes/interactive/components/user-message-selector.js +6 -3
- package/dist/modes/interactive/components/user-message-selector.js.map +1 -1
- package/dist/modes/interactive/components/user-message.d.ts +3 -1
- package/dist/modes/interactive/components/user-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/user-message.js +12 -2
- package/dist/modes/interactive/components/user-message.js.map +1 -1
- package/dist/modes/interactive/components/visual-truncate.d.ts +27 -3
- package/dist/modes/interactive/components/visual-truncate.d.ts.map +1 -1
- package/dist/modes/interactive/components/visual-truncate.js +39 -6
- package/dist/modes/interactive/components/visual-truncate.js.map +1 -1
- package/dist/modes/interactive/external-editor.d.ts.map +1 -1
- package/dist/modes/interactive/external-editor.js +2 -1
- package/dist/modes/interactive/external-editor.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +69 -5
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +1314 -593
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/model-catalog-refresh.d.ts +7 -0
- package/dist/modes/interactive/model-catalog-refresh.d.ts.map +1 -0
- package/dist/modes/interactive/model-catalog-refresh.js +34 -0
- package/dist/modes/interactive/model-catalog-refresh.js.map +1 -0
- package/dist/modes/interactive/session-share.d.ts +23 -0
- package/dist/modes/interactive/session-share.d.ts.map +1 -0
- package/dist/modes/interactive/session-share.js +130 -0
- package/dist/modes/interactive/session-share.js.map +1 -0
- package/dist/modes/interactive/theme/dark.json +54 -63
- package/dist/modes/interactive/theme/light.json +52 -60
- package/dist/modes/interactive/theme/system-theme.d.ts +54 -0
- package/dist/modes/interactive/theme/system-theme.d.ts.map +1 -0
- package/dist/modes/interactive/theme/system-theme.js +535 -0
- package/dist/modes/interactive/theme/system-theme.js.map +1 -0
- package/dist/modes/interactive/theme/theme-controller.d.ts +59 -7
- package/dist/modes/interactive/theme/theme-controller.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme-controller.js +164 -51
- package/dist/modes/interactive/theme/theme-controller.js.map +1 -1
- package/dist/modes/interactive/theme/theme-json.d.ts +85 -0
- package/dist/modes/interactive/theme/theme-json.d.ts.map +1 -0
- package/dist/modes/interactive/theme/theme-json.js +132 -0
- package/dist/modes/interactive/theme/theme-json.js.map +1 -0
- package/dist/modes/interactive/theme/theme-schema.json +24 -3
- package/dist/modes/interactive/theme/theme.d.ts +80 -42
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme.js +274 -417
- package/dist/modes/interactive/theme/theme.js.map +1 -1
- package/dist/modes/interactive/tui-renderer.d.ts +22 -0
- package/dist/modes/interactive/tui-renderer.d.ts.map +1 -0
- package/dist/modes/interactive/tui-renderer.js +67 -0
- package/dist/modes/interactive/tui-renderer.js.map +1 -0
- package/dist/modes/json-event.d.ts +34 -0
- package/dist/modes/json-event.d.ts.map +1 -0
- package/dist/modes/json-event.js +29 -0
- package/dist/modes/json-event.js.map +1 -0
- package/dist/modes/print-mode.d.ts +1 -1
- package/dist/modes/print-mode.d.ts.map +1 -1
- package/dist/modes/print-mode.js +12 -2
- package/dist/modes/print-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-client.d.ts +17 -9
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +27 -15
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +14 -12
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +22 -1
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/dist/package-manager-cli.d.ts +1 -0
- package/dist/package-manager-cli.d.ts.map +1 -1
- package/dist/package-manager-cli.js +217 -63
- package/dist/package-manager-cli.js.map +1 -1
- package/dist/prompts/commands/plan-phase.md +1 -0
- package/dist/prompts/commands/review.md +2 -0
- package/dist/prompts/commands/verify-work.md +1 -0
- package/dist/prompts/commands/why.md +4 -0
- package/dist/rpc-entry.js +1 -0
- package/dist/rpc-entry.js.map +1 -1
- package/dist/skills/blast-radius/SKILL.md +1 -0
- package/dist/skills/explainers/SKILL.md +65 -0
- package/dist/skills/unslop/SKILL.md +19 -1
- package/dist/utils/abort.d.ts +5 -0
- package/dist/utils/abort.d.ts.map +1 -0
- package/dist/utils/abort.js +48 -0
- package/dist/utils/abort.js.map +1 -0
- package/dist/utils/changelog.js +1 -1
- package/dist/utils/changelog.js.map +1 -1
- package/dist/utils/child-process.d.ts +1 -1
- package/dist/utils/child-process.js +1 -1
- package/dist/utils/child-process.js.map +1 -1
- package/dist/utils/clipboard-command.d.ts +7 -0
- package/dist/utils/clipboard-command.d.ts.map +1 -0
- package/dist/utils/clipboard-command.js +45 -0
- package/dist/utils/clipboard-command.js.map +1 -0
- package/dist/utils/clipboard-image.d.ts.map +1 -1
- package/dist/utils/clipboard-image.js +60 -91
- package/dist/utils/clipboard-image.js.map +1 -1
- package/dist/utils/clipboard.d.ts +2 -0
- package/dist/utils/clipboard.d.ts.map +1 -1
- package/dist/utils/clipboard.js +116 -121
- package/dist/utils/clipboard.js.map +1 -1
- package/dist/utils/draht-user-agent.d.ts +2 -0
- package/dist/utils/draht-user-agent.d.ts.map +1 -0
- package/dist/utils/draht-user-agent.js +5 -0
- package/dist/utils/draht-user-agent.js.map +1 -0
- package/dist/utils/exif-orientation.d.ts +2 -1
- package/dist/utils/exif-orientation.d.ts.map +1 -1
- package/dist/utils/exif-orientation.js.map +1 -1
- package/dist/utils/frontmatter.d.ts.map +1 -1
- package/dist/utils/frontmatter.js +2 -1
- package/dist/utils/frontmatter.js.map +1 -1
- package/dist/utils/management-http.d.ts +25 -0
- package/dist/utils/management-http.d.ts.map +1 -0
- package/dist/utils/management-http.js +54 -0
- package/dist/utils/management-http.js.map +1 -0
- package/dist/utils/mime.js +1 -1
- package/dist/utils/mime.js.map +1 -1
- package/dist/utils/paths.d.ts +4 -3
- package/dist/utils/paths.d.ts.map +1 -1
- package/dist/utils/paths.js +15 -4
- package/dist/utils/paths.js.map +1 -1
- package/dist/utils/photon.d.ts +2 -1
- package/dist/utils/photon.d.ts.map +1 -1
- package/dist/utils/photon.js.map +1 -1
- package/dist/utils/shell.d.ts +4 -3
- package/dist/utils/shell.d.ts.map +1 -1
- package/dist/utils/shell.js +20 -35
- package/dist/utils/shell.js.map +1 -1
- package/dist/utils/syntax-highlight.d.ts +1 -0
- package/dist/utils/syntax-highlight.d.ts.map +1 -1
- package/dist/utils/syntax-highlight.js +62 -1
- package/dist/utils/syntax-highlight.js.map +1 -1
- package/dist/utils/text.d.ts +8 -0
- package/dist/utils/text.d.ts.map +1 -0
- package/dist/utils/text.js +9 -0
- package/dist/utils/text.js.map +1 -0
- package/dist/utils/tool-result-images.d.ts +21 -0
- package/dist/utils/tool-result-images.d.ts.map +1 -0
- package/dist/utils/tool-result-images.js +48 -0
- package/dist/utils/tool-result-images.js.map +1 -0
- package/dist/utils/tools-manager.d.ts +11 -1
- package/dist/utils/tools-manager.d.ts.map +1 -1
- package/dist/utils/tools-manager.js +53 -36
- package/dist/utils/tools-manager.js.map +1 -1
- package/dist/utils/version-check.d.ts +4 -1
- package/dist/utils/version-check.d.ts.map +1 -1
- package/dist/utils/version-check.js +30 -9
- package/dist/utils/version-check.js.map +1 -1
- package/dist/utils/wsl.d.ts +3 -0
- package/dist/utils/wsl.d.ts.map +1 -0
- package/dist/utils/wsl.js +15 -0
- package/dist/utils/wsl.js.map +1 -0
- package/dist/utils/zip.d.ts +7 -0
- package/dist/utils/zip.d.ts.map +1 -0
- package/dist/utils/zip.js +60 -0
- package/dist/utils/zip.js.map +1 -0
- package/docs/cli-integration.md +106 -0
- package/docs/cli.md +374 -0
- package/docs/compaction.md +91 -29
- package/docs/configuration.md +47 -0
- package/docs/containerization.md +100 -66
- package/docs/custom-provider.md +109 -707
- package/docs/docs.json +155 -99
- package/docs/environment-variables.md +30 -17
- package/docs/extensions.md +169 -2811
- package/docs/how-pi-works.md +53 -0
- package/docs/images/interactive-mode.png +0 -0
- package/docs/index.md +25 -69
- package/docs/json.md +197 -56
- package/docs/keybindings.md +89 -93
- package/docs/llama-cpp.md +18 -3
- package/docs/mcp.md +231 -0
- package/docs/message-types.md +261 -0
- package/docs/models.md +94 -478
- package/docs/packages.md +67 -163
- package/docs/prompt-templates.md +31 -68
- package/docs/providers.md +118 -215
- package/docs/quickstart.md +55 -108
- package/docs/rpc-commands.md +860 -0
- package/docs/rpc-extension-ui.md +200 -0
- package/docs/rpc.md +139 -1518
- package/docs/sdk.md +79 -1127
- package/docs/security.md +76 -32
- package/docs/session-format.md +73 -219
- package/docs/sessions.md +36 -116
- package/docs/settings.md +124 -257
- package/docs/shell-aliases.md +85 -5
- package/docs/skills.md +52 -189
- package/docs/slash-commands.md +61 -0
- package/docs/terminal-setup.md +132 -61
- package/docs/termux.md +74 -84
- package/docs/themes.md +91 -252
- package/docs/tmux.md +31 -39
- package/docs/tui.md +74 -891
- package/docs/usage.md +54 -255
- package/docs/virtual-models.md +114 -0
- package/docs/windows.md +57 -7
- package/examples/extensions/antigravity-image-gen.ts +9 -9
- package/examples/extensions/bash-spawn-hook.ts +1 -1
- package/examples/extensions/border-status-editor.ts +1 -1
- package/examples/extensions/built-in-tool-renderer.ts +16 -40
- package/examples/extensions/custom-compaction.ts +1 -16
- package/examples/extensions/custom-provider-anthropic/index.ts +20 -13
- package/examples/extensions/custom-provider-gitlab-duo/index.ts +4 -3
- package/examples/extensions/custom-provider-gitlab-duo/test.ts +5 -5
- package/examples/extensions/debug-provider.ts +90 -0
- package/examples/extensions/doom-overlay/wad-finder.ts +7 -3
- package/examples/extensions/dynamic-resources/dynamic.json +3 -1
- package/examples/extensions/git-checkpoint.ts +2 -2
- package/examples/extensions/handoff.ts +2 -11
- package/examples/extensions/jev-router.ts +113 -0
- package/examples/extensions/minimal-mode.ts +24 -96
- package/examples/extensions/notify.ts +3 -1
- package/examples/extensions/prompt-customizer.ts +19 -67
- package/examples/extensions/qna.ts +3 -7
- package/examples/extensions/subagent/agents.ts +40 -9
- package/examples/extensions/subagent/index.ts +27 -4
- package/examples/extensions/summarize.ts +7 -18
- package/examples/extensions/titlebar-spinner.ts +1 -1
- package/examples/rpc-client.ts +35 -0
- package/examples/rpc-extension-ui.ts +38 -9
- package/examples/sdk/02-custom-model.ts +1 -2
- package/examples/sdk/06-extensions.ts +1 -1
- package/examples/sdk/09-api-keys-and-oauth.ts +1 -1
- package/examples/sdk/12-full-control.ts +1 -1
- package/examples/sdk/14-codemode-mcp.ts +61 -0
- package/package.json +25 -30
- package/prompts/commands/plan-phase.md +1 -0
- package/prompts/commands/review.md +2 -0
- package/prompts/commands/verify-work.md +1 -0
- package/prompts/commands/why.md +4 -0
- package/skills/blast-radius/SKILL.md +1 -0
- package/skills/explainers/SKILL.md +65 -0
- package/skills/unslop/SKILL.md +19 -1
- package/dist/utils/clipboard-native.d.ts +0 -11
- package/dist/utils/clipboard-native.d.ts.map +0 -1
- package/dist/utils/clipboard-native.js +0 -20
- package/dist/utils/clipboard-native.js.map +0 -1
- package/dist/utils/pi-user-agent.d.ts +0 -2
- package/dist/utils/pi-user-agent.d.ts.map +0 -1
- package/dist/utils/pi-user-agent.js +0 -5
- package/dist/utils/pi-user-agent.js.map +0 -1
- package/docs/development.md +0 -71
- package/docs/tree.md +0 -231
- package/examples/extensions/kimi-deferred-tools.ts +0 -61
package/docs/sdk.md
CHANGED
|
@@ -1,1195 +1,147 @@
|
|
|
1
|
-
> draht can help you use the SDK. Ask it to build an integration for your use case.
|
|
2
|
-
|
|
3
1
|
# SDK
|
|
4
2
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
**Example use cases:**
|
|
8
|
-
- Build a custom UI (web, desktop, mobile)
|
|
9
|
-
- Integrate agent capabilities into existing applications
|
|
10
|
-
- Create automated pipelines with agent reasoning
|
|
11
|
-
- Build custom tools that spawn sub-agents
|
|
12
|
-
- Test agent behavior programmatically
|
|
13
|
-
|
|
14
|
-
See [examples/sdk/](../examples/sdk/) for working examples from minimal to full control.
|
|
15
|
-
|
|
16
|
-
## Quick Start
|
|
17
|
-
|
|
18
|
-
```typescript
|
|
19
|
-
import { AuthStorage, createAgentSession, ModelRegistry, SessionManager } from "@draht/coding-agent";
|
|
20
|
-
|
|
21
|
-
// Set up credential storage and model registry
|
|
22
|
-
const authStorage = AuthStorage.create();
|
|
23
|
-
const modelRegistry = ModelRegistry.create(authStorage);
|
|
24
|
-
|
|
25
|
-
const { session } = await createAgentSession({
|
|
26
|
-
sessionManager: SessionManager.inMemory(),
|
|
27
|
-
authStorage,
|
|
28
|
-
modelRegistry,
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
session.subscribe((event) => {
|
|
32
|
-
if (event.type === "message_update" && event.assistantMessageEvent.type === "text_delta") {
|
|
33
|
-
process.stdout.write(event.assistantMessageEvent.delta);
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
await session.prompt("What files are in the current directory?");
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
## Installation
|
|
41
|
-
|
|
42
|
-
```bash
|
|
43
|
-
npm install @draht/coding-agent
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
The SDK is included in the main package. No separate installation needed.
|
|
3
|
+
`@draht/coding-agent` embeds draht in a Node.js or Bun process. It provides direct TypeScript access to the agent, sessions, tools, models, and resources used by the command-line application.
|
|
47
4
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
### createAgentSession()
|
|
51
|
-
|
|
52
|
-
The main factory function for a single `AgentSession`.
|
|
53
|
-
|
|
54
|
-
`createAgentSession()` uses a `ResourceLoader` to supply extensions, skills, prompt templates, themes, and context files. If you do not provide one, it uses `DefaultResourceLoader` with standard discovery.
|
|
5
|
+
Use the SDK for in-process TypeScript integration. For a language-independent or isolated subprocess, see [CLI Integration](cli-integration.md).
|
|
55
6
|
|
|
56
7
|
```typescript
|
|
57
|
-
import { createAgentSession
|
|
8
|
+
import { createAgentSession } from "@draht/coding-agent";
|
|
58
9
|
|
|
59
|
-
// Minimal: defaults with DefaultResourceLoader
|
|
60
10
|
const { session } = await createAgentSession();
|
|
61
11
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
});
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
### AgentSession
|
|
71
|
-
|
|
72
|
-
The session manages agent lifecycle, message history, model state, compaction, and event streaming.
|
|
73
|
-
|
|
74
|
-
```typescript
|
|
75
|
-
interface AgentSession {
|
|
76
|
-
// Send a prompt and wait for completion
|
|
77
|
-
prompt(text: string, options?: PromptOptions): Promise<void>;
|
|
78
|
-
|
|
79
|
-
// Queue messages during streaming
|
|
80
|
-
steer(text: string): Promise<void>;
|
|
81
|
-
followUp(text: string): Promise<void>;
|
|
82
|
-
|
|
83
|
-
// Subscribe to events (returns unsubscribe function)
|
|
84
|
-
subscribe(listener: (event: AgentSessionEvent) => void): () => void;
|
|
85
|
-
|
|
86
|
-
// Session info
|
|
87
|
-
sessionFile: string | undefined;
|
|
88
|
-
sessionId: string;
|
|
89
|
-
|
|
90
|
-
// Model control
|
|
91
|
-
setModel(model: Model, options?: { persistDefault?: boolean }): Promise<void>;
|
|
92
|
-
setThinkingLevel(level: ThinkingLevel, options?: { persistDefault?: boolean }): void;
|
|
93
|
-
cycleModel(): Promise<ModelCycleResult | undefined>;
|
|
94
|
-
cycleThinkingLevel(): ThinkingLevel | undefined;
|
|
95
|
-
|
|
96
|
-
// State access
|
|
97
|
-
agent: Agent;
|
|
98
|
-
model: Model | undefined;
|
|
99
|
-
thinkingLevel: ThinkingLevel;
|
|
100
|
-
messages: AgentMessage[];
|
|
101
|
-
isStreaming: boolean;
|
|
102
|
-
|
|
103
|
-
// In-place tree navigation within the current session file
|
|
104
|
-
navigateTree(targetId: string, options?: { summarize?: boolean; customInstructions?: string; replaceInstructions?: boolean; label?: string }): Promise<{ editorText?: string; cancelled: boolean }>;
|
|
105
|
-
|
|
106
|
-
// Compaction
|
|
107
|
-
compact(customInstructions?: string): Promise<CompactionResult>;
|
|
108
|
-
abortCompaction(): void;
|
|
109
|
-
|
|
110
|
-
// Abort current operation
|
|
111
|
-
abort(): Promise<void>;
|
|
112
|
-
|
|
113
|
-
// Cleanup
|
|
114
|
-
dispose(): void;
|
|
115
|
-
}
|
|
116
|
-
```
|
|
117
|
-
|
|
118
|
-
Session replacement APIs such as new-session, resume, fork, and import live on `AgentSessionRuntime`, not on `AgentSession`.
|
|
119
|
-
|
|
120
|
-
### createAgentSessionRuntime() and AgentSessionRuntime
|
|
121
|
-
|
|
122
|
-
Use the runtime API when you need to replace the active session and rebuild cwd-bound runtime state.
|
|
123
|
-
This is the same layer used by the built-in interactive, print, and RPC modes.
|
|
124
|
-
|
|
125
|
-
`createAgentSessionRuntime()` takes a runtime factory plus the initial cwd/session target. The factory closes over process-global fixed inputs, recreates cwd-bound services for the effective cwd, resolves session options against those services, and returns a full runtime result.
|
|
126
|
-
|
|
127
|
-
```typescript
|
|
128
|
-
import {
|
|
129
|
-
type CreateAgentSessionRuntimeFactory,
|
|
130
|
-
createAgentSessionFromServices,
|
|
131
|
-
createAgentSessionRuntime,
|
|
132
|
-
createAgentSessionServices,
|
|
133
|
-
getAgentDir,
|
|
134
|
-
SessionManager,
|
|
135
|
-
} from "@draht/coding-agent";
|
|
136
|
-
|
|
137
|
-
const createRuntime: CreateAgentSessionRuntimeFactory = async ({ cwd, sessionManager, sessionStartEvent }) => {
|
|
138
|
-
const services = await createAgentSessionServices({ cwd });
|
|
139
|
-
return {
|
|
140
|
-
...(await createAgentSessionFromServices({
|
|
141
|
-
services,
|
|
142
|
-
sessionManager,
|
|
143
|
-
sessionStartEvent,
|
|
144
|
-
})),
|
|
145
|
-
services,
|
|
146
|
-
diagnostics: services.diagnostics,
|
|
147
|
-
};
|
|
148
|
-
};
|
|
149
|
-
|
|
150
|
-
const runtime = await createAgentSessionRuntime(createRuntime, {
|
|
151
|
-
cwd: process.cwd(),
|
|
152
|
-
agentDir: getAgentDir(),
|
|
153
|
-
sessionManager: SessionManager.create(process.cwd()),
|
|
154
|
-
});
|
|
155
|
-
```
|
|
156
|
-
|
|
157
|
-
`AgentSessionRuntime` owns replacement of the active runtime across:
|
|
158
|
-
|
|
159
|
-
- `newSession()`
|
|
160
|
-
- `switchSession()`
|
|
161
|
-
- `fork()`
|
|
162
|
-
- clone flows via `fork(entryId, { position: "at" })`
|
|
163
|
-
- `importFromJsonl()`
|
|
164
|
-
|
|
165
|
-
Important behavior:
|
|
166
|
-
|
|
167
|
-
- `runtime.session` changes after those operations
|
|
168
|
-
- event subscriptions are attached to a specific `AgentSession`, so re-subscribe after replacement
|
|
169
|
-
- if you use extensions, call `runtime.session.bindExtensions(...)` again for the new session
|
|
170
|
-
- creation returns diagnostics on `runtime.diagnostics`
|
|
171
|
-
- if runtime creation or replacement fails, the method throws and the caller decides how to handle it
|
|
172
|
-
|
|
173
|
-
```typescript
|
|
174
|
-
let session = runtime.session;
|
|
175
|
-
let unsubscribe = session.subscribe(() => {});
|
|
176
|
-
|
|
177
|
-
await runtime.newSession();
|
|
178
|
-
|
|
179
|
-
unsubscribe();
|
|
180
|
-
session = runtime.session;
|
|
181
|
-
unsubscribe = session.subscribe(() => {});
|
|
182
|
-
```
|
|
183
|
-
|
|
184
|
-
### Prompting and Message Queueing
|
|
185
|
-
|
|
186
|
-
`PromptOptions` controls prompt expansion, queueing behavior while streaming, and prompt preflight notifications:
|
|
187
|
-
|
|
188
|
-
```typescript
|
|
189
|
-
interface PromptOptions {
|
|
190
|
-
expandPromptTemplates?: boolean;
|
|
191
|
-
images?: ImageContent[];
|
|
192
|
-
streamingBehavior?: "steer" | "followUp";
|
|
193
|
-
source?: InputSource;
|
|
194
|
-
preflightResult?: (success: boolean) => void;
|
|
195
|
-
}
|
|
196
|
-
```
|
|
197
|
-
|
|
198
|
-
`preflightResult` is called once per `prompt()` invocation:
|
|
199
|
-
|
|
200
|
-
- `true` when the prompt was accepted, queued, or handled immediately
|
|
201
|
-
- `false` when prompt preflight rejected before acceptance
|
|
202
|
-
|
|
203
|
-
It fires before `prompt()` resolves. `prompt()` still resolves only after the full accepted run finishes, including retries. Failures after acceptance are reported through the normal event and message stream, not through `preflightResult(false)`.
|
|
204
|
-
|
|
205
|
-
The `prompt()` method handles prompt templates, extension commands, and message sending:
|
|
206
|
-
|
|
207
|
-
```typescript
|
|
208
|
-
// Basic prompt (when not streaming)
|
|
209
|
-
await session.prompt("What files are here?");
|
|
210
|
-
|
|
211
|
-
// With images
|
|
212
|
-
await session.prompt("What's in this image?", {
|
|
213
|
-
images: [{ type: "image", source: { type: "base64", mediaType: "image/png", data: "..." } }]
|
|
214
|
-
});
|
|
215
|
-
|
|
216
|
-
// During streaming: must specify how to queue the message
|
|
217
|
-
await session.prompt("Stop and do this instead", { streamingBehavior: "steer" });
|
|
218
|
-
await session.prompt("After you're done, also check X", { streamingBehavior: "followUp" });
|
|
219
|
-
```
|
|
220
|
-
|
|
221
|
-
**Behavior:**
|
|
222
|
-
- **Extension commands** (e.g., `/mycommand`): Execute immediately, even during streaming. They manage their own LLM interaction via `pi.sendMessage()`.
|
|
223
|
-
- **File-based prompt templates** (from `.md` files): Expanded to their content before sending or queueing.
|
|
224
|
-
- **During streaming without `streamingBehavior`**: Throws an error. Use `steer()` or `followUp()` directly, or specify the option.
|
|
225
|
-
- **`preflightResult(true)`**: Means the prompt was accepted, queued, or handled immediately.
|
|
226
|
-
- **`preflightResult(false)`**: Means preflight rejected before acceptance.
|
|
227
|
-
|
|
228
|
-
For explicit queueing during streaming:
|
|
229
|
-
|
|
230
|
-
```typescript
|
|
231
|
-
// Queue a steering message for delivery after the current assistant turn finishes its tool calls
|
|
232
|
-
await session.steer("New instruction");
|
|
233
|
-
|
|
234
|
-
// Wait for agent to finish (delivered only when agent stops)
|
|
235
|
-
await session.followUp("After you're done, also do this");
|
|
236
|
-
```
|
|
237
|
-
|
|
238
|
-
Both `steer()` and `followUp()` expand file-based prompt templates but error on extension commands (extension commands cannot be queued).
|
|
239
|
-
|
|
240
|
-
### Agent and AgentState
|
|
241
|
-
|
|
242
|
-
The `Agent` class (from `@draht/agent-core`) handles the core LLM interaction. Access it via `session.agent`.
|
|
243
|
-
|
|
244
|
-
```typescript
|
|
245
|
-
// Access current state
|
|
246
|
-
const state = session.agent.state;
|
|
247
|
-
|
|
248
|
-
// state.messages: AgentMessage[] - conversation history
|
|
249
|
-
// state.model: Model - current model
|
|
250
|
-
// state.thinkingLevel: ThinkingLevel - current thinking level
|
|
251
|
-
// state.systemPrompt: string - system prompt
|
|
252
|
-
// state.tools: AgentTool[] - available tools
|
|
253
|
-
// state.streamingMessage?: AgentMessage - current partial assistant message
|
|
254
|
-
// state.errorMessage?: string - latest assistant error
|
|
255
|
-
|
|
256
|
-
// Replace messages (useful for branching or restoration)
|
|
257
|
-
session.agent.state.messages = messages; // copies the top-level array
|
|
258
|
-
|
|
259
|
-
// Replace tools
|
|
260
|
-
session.agent.state.tools = tools; // copies the top-level array
|
|
261
|
-
|
|
262
|
-
// Wait for agent to finish processing
|
|
263
|
-
await session.agent.waitForIdle();
|
|
264
|
-
```
|
|
265
|
-
|
|
266
|
-
### Events
|
|
267
|
-
|
|
268
|
-
Subscribe to events to receive streaming output and lifecycle notifications.
|
|
269
|
-
|
|
270
|
-
```typescript
|
|
271
|
-
session.subscribe((event) => {
|
|
272
|
-
switch (event.type) {
|
|
273
|
-
// Streaming text from assistant
|
|
274
|
-
case "message_update":
|
|
275
|
-
if (event.assistantMessageEvent.type === "text_delta") {
|
|
276
|
-
process.stdout.write(event.assistantMessageEvent.delta);
|
|
277
|
-
}
|
|
278
|
-
if (event.assistantMessageEvent.type === "thinking_delta") {
|
|
279
|
-
// Thinking output (if thinking enabled)
|
|
280
|
-
}
|
|
281
|
-
break;
|
|
282
|
-
|
|
283
|
-
// Tool execution
|
|
284
|
-
case "tool_execution_start":
|
|
285
|
-
console.log(`Tool: ${event.toolName}`);
|
|
286
|
-
break;
|
|
287
|
-
case "tool_execution_update":
|
|
288
|
-
// Streaming tool output
|
|
289
|
-
break;
|
|
290
|
-
case "tool_execution_end":
|
|
291
|
-
console.log(`Result: ${event.isError ? "error" : "success"}`);
|
|
292
|
-
break;
|
|
293
|
-
|
|
294
|
-
// Message lifecycle
|
|
295
|
-
case "message_start":
|
|
296
|
-
// New message starting
|
|
297
|
-
break;
|
|
298
|
-
case "message_end":
|
|
299
|
-
// Message complete
|
|
300
|
-
break;
|
|
301
|
-
|
|
302
|
-
// Agent lifecycle
|
|
303
|
-
case "agent_start":
|
|
304
|
-
// Agent started processing prompt
|
|
305
|
-
break;
|
|
306
|
-
case "agent_end":
|
|
307
|
-
// Agent finished (event.messages contains new messages)
|
|
308
|
-
break;
|
|
309
|
-
|
|
310
|
-
// Turn lifecycle (one LLM response + tool calls)
|
|
311
|
-
case "turn_start":
|
|
312
|
-
break;
|
|
313
|
-
case "turn_end":
|
|
314
|
-
// event.message: assistant response
|
|
315
|
-
// event.toolResults: tool results from this turn
|
|
316
|
-
break;
|
|
317
|
-
|
|
318
|
-
// Session events (queue, compaction, retry)
|
|
319
|
-
case "queue_update":
|
|
320
|
-
console.log(event.steering, event.followUp);
|
|
321
|
-
break;
|
|
322
|
-
case "compaction_start":
|
|
323
|
-
case "compaction_end":
|
|
324
|
-
case "auto_retry_start":
|
|
325
|
-
case "auto_retry_end":
|
|
326
|
-
case "summarization_retry_scheduled":
|
|
327
|
-
case "summarization_retry_attempt_start":
|
|
328
|
-
case "summarization_retry_finished":
|
|
329
|
-
break;
|
|
330
|
-
}
|
|
331
|
-
});
|
|
332
|
-
```
|
|
333
|
-
|
|
334
|
-
## Options Reference
|
|
335
|
-
|
|
336
|
-
### Directories
|
|
337
|
-
|
|
338
|
-
```typescript
|
|
339
|
-
const { session } = await createAgentSession({
|
|
340
|
-
// Working directory for DefaultResourceLoader discovery
|
|
341
|
-
cwd: process.cwd(), // default
|
|
342
|
-
|
|
343
|
-
// Global config directory
|
|
344
|
-
agentDir: "~/.draht/agent", // default (expands ~)
|
|
345
|
-
});
|
|
346
|
-
```
|
|
347
|
-
|
|
348
|
-
`cwd` is used by `DefaultResourceLoader` for:
|
|
349
|
-
- Project extensions (`.draht/extensions/`)
|
|
350
|
-
- Project skills:
|
|
351
|
-
- `.draht/skills/`
|
|
352
|
-
- `.agents/skills/` in `cwd` and ancestor directories (up to git repo root, or filesystem root when not in a repo)
|
|
353
|
-
- Project prompts (`.draht/prompts/`)
|
|
354
|
-
- Context files (`AGENTS.md` walking up from cwd)
|
|
355
|
-
- Session directory naming
|
|
356
|
-
|
|
357
|
-
`agentDir` is used by `DefaultResourceLoader` for:
|
|
358
|
-
- Global extensions (`extensions/`)
|
|
359
|
-
- Global skills:
|
|
360
|
-
- `skills/` under `agentDir` (for example `~/.draht/agent/skills/`)
|
|
361
|
-
- `~/.agents/skills/`
|
|
362
|
-
- Global prompts (`prompts/`)
|
|
363
|
-
- Global context file (`AGENTS.md`)
|
|
364
|
-
- Settings (`settings.json`)
|
|
365
|
-
- Custom models (`models.json`)
|
|
366
|
-
- Credentials (`auth.json`)
|
|
367
|
-
- Sessions (`sessions/`)
|
|
368
|
-
|
|
369
|
-
When you pass a custom `ResourceLoader`, `cwd` and `agentDir` no longer control resource discovery. They still influence session naming and tool path resolution.
|
|
370
|
-
|
|
371
|
-
### Model
|
|
372
|
-
|
|
373
|
-
```typescript
|
|
374
|
-
import { getModel } from "@draht/ai";
|
|
375
|
-
import { AuthStorage, ModelRegistry } from "@draht/coding-agent";
|
|
376
|
-
|
|
377
|
-
const authStorage = AuthStorage.create();
|
|
378
|
-
const modelRegistry = ModelRegistry.create(authStorage);
|
|
379
|
-
|
|
380
|
-
// Find specific built-in model (doesn't check if API key exists)
|
|
381
|
-
const opus = getModel("anthropic", "claude-opus-4-5");
|
|
382
|
-
if (!opus) throw new Error("Model not found");
|
|
383
|
-
|
|
384
|
-
// Find any model by provider/id, including custom models from models.json
|
|
385
|
-
// (doesn't check if API key exists)
|
|
386
|
-
const customModel = modelRegistry.find("my-provider", "my-model");
|
|
387
|
-
|
|
388
|
-
// Get only models that have valid API keys configured
|
|
389
|
-
const available = await modelRegistry.getAvailable();
|
|
390
|
-
|
|
391
|
-
const { session } = await createAgentSession({
|
|
392
|
-
model: opus,
|
|
393
|
-
thinkingLevel: "medium", // off, minimal, low, medium, high, xhigh, max
|
|
394
|
-
|
|
395
|
-
// Models for cycling (Ctrl+P in interactive mode)
|
|
396
|
-
scopedModels: [
|
|
397
|
-
{ model: opus, thinkingLevel: "high" },
|
|
398
|
-
{ model: haiku, thinkingLevel: "off" },
|
|
399
|
-
],
|
|
400
|
-
|
|
401
|
-
authStorage,
|
|
402
|
-
modelRegistry,
|
|
403
|
-
});
|
|
404
|
-
```
|
|
405
|
-
|
|
406
|
-
If no model is provided:
|
|
407
|
-
1. Tries to restore from session (if continuing)
|
|
408
|
-
2. Uses default from settings
|
|
409
|
-
3. Falls back to first available model
|
|
410
|
-
|
|
411
|
-
To match CLI model parsing, use the exported resolver helpers:
|
|
412
|
-
|
|
413
|
-
```typescript
|
|
414
|
-
import {
|
|
415
|
-
resolveCliModel,
|
|
416
|
-
resolveModelScopeWithDiagnostics,
|
|
417
|
-
} from "@draht/coding-agent";
|
|
418
|
-
|
|
419
|
-
const cliModel = resolveCliModel({
|
|
420
|
-
cliModel: "anthropic/claude-opus-4-5:high",
|
|
421
|
-
modelRegistry,
|
|
422
|
-
});
|
|
423
|
-
if (cliModel.error) throw new Error(cliModel.error);
|
|
424
|
-
if (cliModel.warning) console.warn(cliModel.warning);
|
|
425
|
-
|
|
426
|
-
const { scopedModels, diagnostics } = await resolveModelScopeWithDiagnostics(
|
|
427
|
-
["anthropic/*:high", "gpt-5"],
|
|
428
|
-
modelRegistry,
|
|
429
|
-
);
|
|
430
|
-
for (const diagnostic of diagnostics) {
|
|
431
|
-
console.warn(diagnostic.message);
|
|
12
|
+
try {
|
|
13
|
+
await session.prompt("What files are in the current directory?");
|
|
14
|
+
console.log(session.getLastAssistantText());
|
|
15
|
+
} finally {
|
|
16
|
+
session.dispose();
|
|
432
17
|
}
|
|
433
18
|
```
|
|
434
19
|
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
> See [examples/sdk/02-custom-model.ts](../examples/sdk/02-custom-model.ts)
|
|
438
|
-
|
|
439
|
-
### API Keys and OAuth
|
|
440
|
-
|
|
441
|
-
API key resolution priority (handled by AuthStorage):
|
|
442
|
-
1. Runtime overrides (via `setRuntimeApiKey`, not persisted)
|
|
443
|
-
2. Stored credentials in `auth.json` (API keys or OAuth tokens)
|
|
444
|
-
3. Environment variables (`ANTHROPIC_API_KEY`, `OPENAI_API_KEY`, etc.)
|
|
445
|
-
4. Fallback resolver (for custom provider keys from `models.json`)
|
|
446
|
-
|
|
447
|
-
```typescript
|
|
448
|
-
import { AuthStorage, ModelRegistry } from "@draht/coding-agent";
|
|
449
|
-
|
|
450
|
-
// Default: uses ~/.draht/agent/auth.json and ~/.draht/agent/models.json
|
|
451
|
-
const authStorage = AuthStorage.create();
|
|
452
|
-
const modelRegistry = ModelRegistry.create(authStorage);
|
|
453
|
-
|
|
454
|
-
const { session } = await createAgentSession({
|
|
455
|
-
sessionManager: SessionManager.inMemory(),
|
|
456
|
-
authStorage,
|
|
457
|
-
modelRegistry,
|
|
458
|
-
});
|
|
459
|
-
|
|
460
|
-
// Runtime API key override (not persisted to disk)
|
|
461
|
-
authStorage.setRuntimeApiKey("anthropic", "sk-my-temp-key");
|
|
462
|
-
|
|
463
|
-
// Custom auth storage location
|
|
464
|
-
const customAuth = AuthStorage.create("/my/app/auth.json");
|
|
465
|
-
const customRegistry = ModelRegistry.create(customAuth, "/my/app/models.json");
|
|
20
|
+
This uses the working directory, discovered resources, stored settings, and configured credentials. `prompt()` resolves when the run finishes.
|
|
466
21
|
|
|
467
|
-
|
|
468
|
-
sessionManager: SessionManager.inMemory(),
|
|
469
|
-
authStorage: customAuth,
|
|
470
|
-
modelRegistry: customRegistry,
|
|
471
|
-
});
|
|
22
|
+
The [complete minimal example](../examples/sdk/01-minimal.ts) also streams text events. All [SDK examples](../examples/sdk/) are typechecked with the repository.
|
|
472
23
|
|
|
473
|
-
|
|
474
|
-
const simpleRegistry = ModelRegistry.inMemory(authStorage);
|
|
475
|
-
```
|
|
24
|
+
<a id="session-management"></a>
|
|
476
25
|
|
|
477
|
-
|
|
26
|
+
## Session lifecycle
|
|
478
27
|
|
|
479
|
-
|
|
28
|
+
`createAgentSession()` creates an `AgentSession`. The session owns one conversation, its model and tools, queued messages, compaction state, and extension runtime.
|
|
480
29
|
|
|
481
|
-
|
|
30
|
+
Read current state through `session.messages`, `session.model`, `session.thinkingLevel`, `session.systemPrompt`, and `session.getActiveToolNames()`.
|
|
482
31
|
|
|
483
|
-
|
|
484
|
-
import { createAgentSession, DefaultResourceLoader } from "@draht/coding-agent";
|
|
485
|
-
|
|
486
|
-
const loader = new DefaultResourceLoader({
|
|
487
|
-
systemPromptOverride: () => "You are a helpful assistant.",
|
|
488
|
-
});
|
|
489
|
-
await loader.reload();
|
|
490
|
-
|
|
491
|
-
const { session } = await createAgentSession({ resourceLoader: loader });
|
|
492
|
-
```
|
|
32
|
+
`session.systemPrompt` is read-only and returns the current effective system prompt, including changes that have not yet been sent to the model. Tool changes are declared to the model before the next request.
|
|
493
33
|
|
|
494
|
-
|
|
34
|
+
<a id="sessionmanager-api"></a>
|
|
495
35
|
|
|
496
|
-
###
|
|
36
|
+
### Session storage
|
|
497
37
|
|
|
498
|
-
|
|
38
|
+
Sessions are persistent by default. `SessionManager` owns the persisted or in-memory entry tree and tracks its active leaf. Branching changes that leaf without deleting abandoned branches. When draht reconstructs model context, the manager selects the active branch and applies compaction.
|
|
499
39
|
|
|
500
|
-
|
|
501
|
-
- Default built-ins: `read`, `bash`, `edit`, `write`
|
|
502
|
-
- `noTools: "all"` disables all tools
|
|
503
|
-
- `noTools: "builtin"` disables default built-ins while keeping extension and custom tools enabled
|
|
504
|
-
- `excludeTools` disables specific built-in, extension, or custom tool names after any `tools` allowlist is applied
|
|
40
|
+
`SessionManager` is authoritative for finalized model context. Restore external history by constructing the session with a manager containing those entries. Assigning `session.agent.state.messages` does not replace persisted context.
|
|
505
41
|
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
```typescript
|
|
509
|
-
import { createAgentSession } from "@draht/coding-agent";
|
|
510
|
-
|
|
511
|
-
// Read-only mode
|
|
512
|
-
const { session } = await createAgentSession({
|
|
513
|
-
tools: ["read", "grep", "find", "ls"],
|
|
514
|
-
});
|
|
515
|
-
|
|
516
|
-
// Pick specific tools
|
|
517
|
-
const { session } = await createAgentSession({
|
|
518
|
-
tools: ["read", "bash", "grep"],
|
|
519
|
-
});
|
|
520
|
-
|
|
521
|
-
// Disable one tool while keeping the rest available
|
|
522
|
-
const { session } = await createAgentSession({
|
|
523
|
-
excludeTools: ["ask_question"],
|
|
524
|
-
});
|
|
525
|
-
```
|
|
526
|
-
|
|
527
|
-
#### Tools with Custom cwd
|
|
528
|
-
|
|
529
|
-
When you pass a custom `cwd`, `createAgentSession()` builds selected built-in tools for that cwd.
|
|
42
|
+
Use an in-memory manager when the host does not want session files:
|
|
530
43
|
|
|
531
44
|
```typescript
|
|
532
45
|
import { createAgentSession, SessionManager } from "@draht/coding-agent";
|
|
533
46
|
|
|
534
|
-
const cwd = "/path/to/project";
|
|
535
|
-
|
|
536
|
-
// Use default tools for custom cwd
|
|
537
|
-
const { session } = await createAgentSession({
|
|
538
|
-
cwd,
|
|
539
|
-
sessionManager: SessionManager.inMemory(cwd),
|
|
540
|
-
});
|
|
541
|
-
|
|
542
|
-
// Or pick specific tools for custom cwd
|
|
543
|
-
const { session } = await createAgentSession({
|
|
544
|
-
cwd,
|
|
545
|
-
tools: ["read", "bash", "grep"],
|
|
546
|
-
sessionManager: SessionManager.inMemory(cwd),
|
|
547
|
-
});
|
|
548
|
-
```
|
|
549
|
-
|
|
550
|
-
> See [examples/sdk/05-tools.ts](../examples/sdk/05-tools.ts)
|
|
551
|
-
|
|
552
|
-
### Custom Tools
|
|
553
|
-
|
|
554
|
-
```typescript
|
|
555
|
-
import { Type } from "typebox";
|
|
556
|
-
import { createAgentSession, defineTool } from "@draht/coding-agent";
|
|
557
|
-
|
|
558
|
-
// Inline custom tool
|
|
559
|
-
const myTool = defineTool({
|
|
560
|
-
name: "my_tool",
|
|
561
|
-
label: "My Tool",
|
|
562
|
-
description: "Does something useful",
|
|
563
|
-
parameters: Type.Object({
|
|
564
|
-
input: Type.String({ description: "Input value" }),
|
|
565
|
-
}),
|
|
566
|
-
execute: async (_toolCallId, params) => ({
|
|
567
|
-
content: [{ type: "text", text: `Result: ${params.input}` }],
|
|
568
|
-
details: {},
|
|
569
|
-
}),
|
|
570
|
-
});
|
|
571
|
-
|
|
572
|
-
// Pass custom tools directly
|
|
573
|
-
const { session } = await createAgentSession({
|
|
574
|
-
customTools: [myTool],
|
|
575
|
-
});
|
|
576
|
-
```
|
|
577
|
-
|
|
578
|
-
Use `defineTool()` for standalone definitions and arrays like `customTools: [myTool]`. Inline `pi.registerTool({ ... })` already infers parameter types correctly.
|
|
579
|
-
|
|
580
|
-
Custom tools passed via `customTools` are combined with extension-registered tools. Extensions loaded by the ResourceLoader can also register tools via `pi.registerTool()`.
|
|
581
|
-
|
|
582
|
-
If you pass `tools`, include each custom or extension tool name you want enabled, for example `tools: ["read", "bash", "my_tool"]`.
|
|
583
|
-
|
|
584
|
-
> See [examples/sdk/05-tools.ts](../examples/sdk/05-tools.ts)
|
|
585
|
-
|
|
586
|
-
### Extensions
|
|
587
|
-
|
|
588
|
-
Extensions are loaded by the `ResourceLoader`. `DefaultResourceLoader` discovers extensions from `~/.draht/agent/extensions/`, `.draht/extensions/`, and settings.json extension sources.
|
|
589
|
-
|
|
590
|
-
```typescript
|
|
591
|
-
import { createAgentSession, DefaultResourceLoader } from "@draht/coding-agent";
|
|
592
|
-
|
|
593
|
-
const loader = new DefaultResourceLoader({
|
|
594
|
-
additionalExtensionPaths: ["/path/to/my-extension.ts"],
|
|
595
|
-
extensionFactories: [
|
|
596
|
-
(pi) => {
|
|
597
|
-
pi.on("agent_start", () => {
|
|
598
|
-
console.log("[Inline Extension] Agent starting");
|
|
599
|
-
});
|
|
600
|
-
},
|
|
601
|
-
],
|
|
602
|
-
});
|
|
603
|
-
await loader.reload();
|
|
604
|
-
|
|
605
|
-
const { session } = await createAgentSession({ resourceLoader: loader });
|
|
606
|
-
```
|
|
607
|
-
|
|
608
|
-
Extensions can register tools, subscribe to events, add commands, and more. See [extensions.md](extensions.md) for the full API.
|
|
609
|
-
|
|
610
|
-
**Named inline extensions:** By default, inline factories display as `<inline:1>`, `<inline:2>`, etc. in the startup Extensions list. To show a descriptive name instead, wrap the factory:
|
|
611
|
-
|
|
612
|
-
```typescript
|
|
613
|
-
import type { InlineExtension } from "@draht/coding-agent";
|
|
614
|
-
|
|
615
|
-
const myProvider: InlineExtension = {
|
|
616
|
-
name: "my-provider",
|
|
617
|
-
factory: (pi) => {
|
|
618
|
-
pi.on("agent_start", () => {
|
|
619
|
-
console.log("[my-provider] Agent starting");
|
|
620
|
-
});
|
|
621
|
-
},
|
|
622
|
-
};
|
|
623
|
-
|
|
624
|
-
const loader = new DefaultResourceLoader({
|
|
625
|
-
extensionFactories: [myProvider],
|
|
626
|
-
});
|
|
627
|
-
```
|
|
628
|
-
|
|
629
|
-
This displays as `<inline:my-provider>` instead of `<inline:1>`. Bare factory functions are still accepted for backward compatibility.
|
|
630
|
-
|
|
631
|
-
**Event Bus:** Extensions can communicate via `pi.events`. Pass a shared `eventBus` to `DefaultResourceLoader` if you need to emit or listen from outside:
|
|
632
|
-
|
|
633
|
-
```typescript
|
|
634
|
-
import { createEventBus, DefaultResourceLoader } from "@draht/coding-agent";
|
|
635
|
-
|
|
636
|
-
const eventBus = createEventBus();
|
|
637
|
-
const loader = new DefaultResourceLoader({
|
|
638
|
-
eventBus,
|
|
639
|
-
});
|
|
640
|
-
await loader.reload();
|
|
641
|
-
|
|
642
|
-
eventBus.on("my-extension:status", (data) => console.log(data));
|
|
643
|
-
```
|
|
644
|
-
|
|
645
|
-
> See [examples/sdk/06-extensions.ts](../examples/sdk/06-extensions.ts) and [docs/extensions.md](extensions.md)
|
|
646
|
-
|
|
647
|
-
### Skills
|
|
648
|
-
|
|
649
|
-
```typescript
|
|
650
|
-
import {
|
|
651
|
-
createAgentSession,
|
|
652
|
-
DefaultResourceLoader,
|
|
653
|
-
type Skill,
|
|
654
|
-
} from "@draht/coding-agent";
|
|
655
|
-
|
|
656
|
-
const customSkill: Skill = {
|
|
657
|
-
name: "my-skill",
|
|
658
|
-
description: "Custom instructions",
|
|
659
|
-
filePath: "/path/to/SKILL.md",
|
|
660
|
-
baseDir: "/path/to",
|
|
661
|
-
source: "custom",
|
|
662
|
-
};
|
|
663
|
-
|
|
664
|
-
const loader = new DefaultResourceLoader({
|
|
665
|
-
skillsOverride: (current) => ({
|
|
666
|
-
skills: [...current.skills, customSkill],
|
|
667
|
-
diagnostics: current.diagnostics,
|
|
668
|
-
}),
|
|
669
|
-
});
|
|
670
|
-
await loader.reload();
|
|
671
|
-
|
|
672
|
-
const { session } = await createAgentSession({ resourceLoader: loader });
|
|
673
|
-
```
|
|
674
|
-
|
|
675
|
-
> See [examples/sdk/04-skills.ts](../examples/sdk/04-skills.ts)
|
|
676
|
-
|
|
677
|
-
### Context Files
|
|
678
|
-
|
|
679
|
-
```typescript
|
|
680
|
-
import { createAgentSession, DefaultResourceLoader } from "@draht/coding-agent";
|
|
681
|
-
|
|
682
|
-
const loader = new DefaultResourceLoader({
|
|
683
|
-
agentsFilesOverride: (current) => ({
|
|
684
|
-
agentsFiles: [
|
|
685
|
-
...current.agentsFiles,
|
|
686
|
-
{ path: "/virtual/AGENTS.md", content: "# Guidelines\n\n- Be concise" },
|
|
687
|
-
],
|
|
688
|
-
}),
|
|
689
|
-
});
|
|
690
|
-
await loader.reload();
|
|
691
|
-
|
|
692
|
-
const { session } = await createAgentSession({ resourceLoader: loader });
|
|
693
|
-
```
|
|
694
|
-
|
|
695
|
-
> See [examples/sdk/07-context-files.ts](../examples/sdk/07-context-files.ts)
|
|
696
|
-
|
|
697
|
-
### Slash Commands
|
|
698
|
-
|
|
699
|
-
```typescript
|
|
700
|
-
import {
|
|
701
|
-
createAgentSession,
|
|
702
|
-
DefaultResourceLoader,
|
|
703
|
-
type PromptTemplate,
|
|
704
|
-
} from "@draht/coding-agent";
|
|
705
|
-
|
|
706
|
-
const customCommand: PromptTemplate = {
|
|
707
|
-
name: "deploy",
|
|
708
|
-
description: "Deploy the application",
|
|
709
|
-
source: "(custom)",
|
|
710
|
-
content: "# Deploy\n\n1. Build\n2. Test\n3. Deploy",
|
|
711
|
-
};
|
|
712
|
-
|
|
713
|
-
const loader = new DefaultResourceLoader({
|
|
714
|
-
promptsOverride: (current) => ({
|
|
715
|
-
prompts: [...current.prompts, customCommand],
|
|
716
|
-
diagnostics: current.diagnostics,
|
|
717
|
-
}),
|
|
718
|
-
});
|
|
719
|
-
await loader.reload();
|
|
720
|
-
|
|
721
|
-
const { session } = await createAgentSession({ resourceLoader: loader });
|
|
722
|
-
```
|
|
723
|
-
|
|
724
|
-
> See [examples/sdk/08-prompt-templates.ts](../examples/sdk/08-prompt-templates.ts)
|
|
725
|
-
|
|
726
|
-
### Session Management
|
|
727
|
-
|
|
728
|
-
Sessions use a tree structure with `id`/`parentId` linking, enabling in-place branching.
|
|
729
|
-
|
|
730
|
-
```typescript
|
|
731
|
-
import {
|
|
732
|
-
type CreateAgentSessionRuntimeFactory,
|
|
733
|
-
createAgentSession,
|
|
734
|
-
createAgentSessionFromServices,
|
|
735
|
-
createAgentSessionRuntime,
|
|
736
|
-
createAgentSessionServices,
|
|
737
|
-
getAgentDir,
|
|
738
|
-
SessionManager,
|
|
739
|
-
} from "@draht/coding-agent";
|
|
740
|
-
|
|
741
|
-
// In-memory (no persistence)
|
|
742
|
-
const { session } = await createAgentSession({
|
|
743
|
-
sessionManager: SessionManager.inMemory(),
|
|
744
|
-
});
|
|
745
|
-
|
|
746
|
-
// New persistent session
|
|
747
|
-
const { session: persisted } = await createAgentSession({
|
|
748
|
-
sessionManager: SessionManager.create(process.cwd()),
|
|
749
|
-
});
|
|
750
|
-
|
|
751
|
-
// Continue most recent
|
|
752
|
-
const { session: continued, modelFallbackMessage } = await createAgentSession({
|
|
753
|
-
sessionManager: SessionManager.continueRecent(process.cwd()),
|
|
754
|
-
});
|
|
755
|
-
if (modelFallbackMessage) {
|
|
756
|
-
console.log("Note:", modelFallbackMessage);
|
|
757
|
-
}
|
|
758
|
-
|
|
759
|
-
// Open specific file
|
|
760
|
-
const { session: opened } = await createAgentSession({
|
|
761
|
-
sessionManager: SessionManager.open("/path/to/session.jsonl"),
|
|
762
|
-
});
|
|
763
|
-
|
|
764
|
-
// List sessions
|
|
765
|
-
const currentProjectSessions = await SessionManager.list(process.cwd());
|
|
766
|
-
const allSessions = await SessionManager.listAll(process.cwd());
|
|
767
|
-
|
|
768
|
-
// Session replacement API for /new, /resume, /fork, /clone, and import flows.
|
|
769
|
-
const createRuntime: CreateAgentSessionRuntimeFactory = async ({ cwd, sessionManager, sessionStartEvent }) => {
|
|
770
|
-
const services = await createAgentSessionServices({ cwd });
|
|
771
|
-
return {
|
|
772
|
-
...(await createAgentSessionFromServices({
|
|
773
|
-
services,
|
|
774
|
-
sessionManager,
|
|
775
|
-
sessionStartEvent,
|
|
776
|
-
})),
|
|
777
|
-
services,
|
|
778
|
-
diagnostics: services.diagnostics,
|
|
779
|
-
};
|
|
780
|
-
};
|
|
781
|
-
|
|
782
|
-
const runtime = await createAgentSessionRuntime(createRuntime, {
|
|
783
|
-
cwd: process.cwd(),
|
|
784
|
-
agentDir: getAgentDir(),
|
|
785
|
-
sessionManager: SessionManager.create(process.cwd()),
|
|
786
|
-
});
|
|
787
|
-
|
|
788
|
-
// Replace the active session with a fresh one
|
|
789
|
-
await runtime.newSession();
|
|
790
|
-
|
|
791
|
-
// Replace the active session with another saved session
|
|
792
|
-
await runtime.switchSession("/path/to/session.jsonl");
|
|
793
|
-
|
|
794
|
-
// Replace the active session with a fork from a specific user entry
|
|
795
|
-
await runtime.fork("entry-id");
|
|
796
|
-
|
|
797
|
-
// Clone the active path through a specific entry
|
|
798
|
-
await runtime.fork("entry-id", { position: "at" });
|
|
799
|
-
```
|
|
800
|
-
|
|
801
|
-
**SessionManager tree API:**
|
|
802
|
-
|
|
803
|
-
```typescript
|
|
804
|
-
const sm = SessionManager.open("/path/to/session.jsonl");
|
|
805
|
-
|
|
806
|
-
// Session listing
|
|
807
|
-
const currentProjectSessions = await SessionManager.list(process.cwd());
|
|
808
|
-
const allSessions = await SessionManager.listAll(process.cwd());
|
|
809
|
-
|
|
810
|
-
// Tree traversal
|
|
811
|
-
const entries = sm.getEntries(); // All entries (excludes header)
|
|
812
|
-
const tree = sm.getTree(); // Full tree structure
|
|
813
|
-
const path = sm.getPath(); // Path from root to current leaf
|
|
814
|
-
const leaf = sm.getLeafEntry(); // Current leaf entry
|
|
815
|
-
const entry = sm.getEntry(id); // Get entry by ID
|
|
816
|
-
const children = sm.getChildren(id); // Direct children of entry
|
|
817
|
-
|
|
818
|
-
// Labels
|
|
819
|
-
const label = sm.getLabel(id); // Get label for entry
|
|
820
|
-
sm.appendLabelChange(id, "checkpoint"); // Set label
|
|
821
|
-
|
|
822
|
-
// Branching
|
|
823
|
-
sm.branch(entryId); // Move leaf to earlier entry
|
|
824
|
-
sm.branchWithSummary(id, "Summary..."); // Branch with context summary
|
|
825
|
-
sm.createBranchedSession(leafId); // Extract path to new file
|
|
826
|
-
```
|
|
827
|
-
|
|
828
|
-
> See [examples/sdk/11-sessions.ts](../examples/sdk/11-sessions.ts) and [Session Format](session-format.md)
|
|
829
|
-
|
|
830
|
-
### Settings Management
|
|
831
|
-
|
|
832
|
-
```typescript
|
|
833
|
-
import { createAgentSession, SettingsManager, SessionManager } from "@draht/coding-agent";
|
|
834
|
-
|
|
835
|
-
// Default: loads from files (global + project merged)
|
|
836
47
|
const { session } = await createAgentSession({
|
|
837
|
-
settingsManager: SettingsManager.create(),
|
|
838
|
-
});
|
|
839
|
-
|
|
840
|
-
// With overrides
|
|
841
|
-
const settingsManager = SettingsManager.create();
|
|
842
|
-
settingsManager.applyOverrides({
|
|
843
|
-
compaction: { enabled: false },
|
|
844
|
-
retry: { enabled: true, maxRetries: 5 },
|
|
845
|
-
});
|
|
846
|
-
const { session } = await createAgentSession({ settingsManager });
|
|
847
|
-
|
|
848
|
-
// In-memory (no file I/O, for testing)
|
|
849
|
-
const { session } = await createAgentSession({
|
|
850
|
-
settingsManager: SettingsManager.inMemory({ compaction: { enabled: false } }),
|
|
851
48
|
sessionManager: SessionManager.inMemory(),
|
|
852
49
|
});
|
|
853
|
-
|
|
854
|
-
// Custom directories
|
|
855
|
-
const { session } = await createAgentSession({
|
|
856
|
-
settingsManager: SettingsManager.create("/custom/cwd", "/custom/agent"),
|
|
857
|
-
});
|
|
858
50
|
```
|
|
859
51
|
|
|
860
|
-
|
|
861
|
-
- `SettingsManager.create(cwd?, agentDir?)` - Load from files
|
|
862
|
-
- `SettingsManager.inMemory(settings?)` - No file I/O
|
|
863
|
-
|
|
864
|
-
**Project-specific settings:**
|
|
52
|
+
See the checked [sessions example](../examples/sdk/11-sessions.ts) for creating, opening, continuing, listing, and forking sessions. [Session File Format](session-format.md) defines the persisted JSONL contract, and [Message Types](message-types.md) defines transcript values. For exact methods and signatures, use the exported TypeScript declarations or [`session-manager.ts`](../src/core/session-manager.ts).
|
|
865
53
|
|
|
866
|
-
|
|
867
|
-
1. Global: `~/.draht/agent/settings.json`
|
|
868
|
-
2. Project: `<cwd>/.draht/settings.json`
|
|
54
|
+
`cwd` selects the workspace used for project resource discovery, context files, session grouping, and built-in tool paths. Pass it explicitly when the target differs from `process.cwd()`.
|
|
869
55
|
|
|
870
|
-
|
|
56
|
+
`session.dispose()` aborts active work, invalidates extension contexts, disconnects from the agent, and removes event listeners. Call it when the session is no longer needed.
|
|
871
57
|
|
|
872
|
-
|
|
58
|
+
`AgentSessionRuntime` adds `newSession()`, `switchSession()`, `fork()`, and `importFromJsonl()`. Each operation replaces the active `AgentSession` and recreates services for the target working directory.
|
|
873
59
|
|
|
874
|
-
|
|
875
|
-
- Setters enqueue persistence writes asynchronously.
|
|
876
|
-
- Call `await settingsManager.flush()` when you need a durability boundary (for example, before process exit or before asserting file contents in tests).
|
|
877
|
-
- `SettingsManager` does not print settings I/O errors. Use `settingsManager.drainErrors()` and report them in your app layer.
|
|
60
|
+
After a runtime replacement, subscriptions belong to the old `AgentSession` and must be rebound. See the [session runtime example](../examples/sdk/13-session-runtime.ts).
|
|
878
61
|
|
|
879
|
-
|
|
62
|
+
## Prompting
|
|
880
63
|
|
|
881
|
-
|
|
64
|
+
`prompt()` handles extension commands and expands file-based prompt templates before ordinary user messages enter the agent. For an accepted agent run, it resolves after the run finishes, including automatic retries.
|
|
882
65
|
|
|
883
|
-
|
|
66
|
+
A prompt sent while the session is already streaming must specify whether it should steer the current run or follow it. Calling `prompt()` without that choice rejects rather than guessing.
|
|
884
67
|
|
|
885
|
-
|
|
886
|
-
import {
|
|
887
|
-
DefaultResourceLoader,
|
|
888
|
-
getAgentDir,
|
|
889
|
-
} from "@draht/coding-agent";
|
|
890
|
-
|
|
891
|
-
const loader = new DefaultResourceLoader({
|
|
892
|
-
cwd,
|
|
893
|
-
agentDir: getAgentDir(),
|
|
894
|
-
});
|
|
895
|
-
await loader.reload();
|
|
68
|
+
A steering message enters after the current assistant turn and its tool calls. A follow-up enters after the current run finishes its pending work. `steer()` and `followUp()` expose those behaviors directly and return `"queued"` if the input was queued (including after an extension transformed it), or `"handled"` if an extension consumed it.
|
|
896
69
|
|
|
897
|
-
|
|
898
|
-
const skills = loader.getSkills();
|
|
899
|
-
const prompts = loader.getPrompts();
|
|
900
|
-
const themes = loader.getThemes();
|
|
901
|
-
const contextFiles = loader.getAgentsFiles().agentsFiles;
|
|
902
|
-
```
|
|
903
|
-
|
|
904
|
-
## Return Value
|
|
905
|
-
|
|
906
|
-
`createAgentSession()` returns:
|
|
907
|
-
|
|
908
|
-
```typescript
|
|
909
|
-
interface CreateAgentSessionResult {
|
|
910
|
-
// The session
|
|
911
|
-
session: AgentSession;
|
|
912
|
-
|
|
913
|
-
// Extensions result (for runner setup)
|
|
914
|
-
extensionsResult: LoadExtensionsResult;
|
|
915
|
-
|
|
916
|
-
// Warning if session model couldn't be restored
|
|
917
|
-
modelFallbackMessage?: string;
|
|
918
|
-
}
|
|
70
|
+
`abort()` stops the active operation and waits for the session to become idle. `waitForIdle()` waits without aborting it.
|
|
919
71
|
|
|
920
|
-
|
|
921
|
-
extensions: Extension[];
|
|
922
|
-
errors: Array<{ path: string; error: string }>;
|
|
923
|
-
runtime: ExtensionRuntime;
|
|
924
|
-
}
|
|
925
|
-
```
|
|
72
|
+
## Subscribing to events
|
|
926
73
|
|
|
927
|
-
|
|
74
|
+
Subscribe before prompting when the host needs streamed output:
|
|
928
75
|
|
|
929
76
|
```typescript
|
|
930
|
-
|
|
931
|
-
import { Type } from "typebox";
|
|
932
|
-
import {
|
|
933
|
-
AuthStorage,
|
|
934
|
-
createAgentSession,
|
|
935
|
-
DefaultResourceLoader,
|
|
936
|
-
defineTool,
|
|
937
|
-
ModelRegistry,
|
|
938
|
-
SessionManager,
|
|
939
|
-
SettingsManager,
|
|
940
|
-
} from "@draht/coding-agent";
|
|
941
|
-
|
|
942
|
-
// Set up auth storage (custom location)
|
|
943
|
-
const authStorage = AuthStorage.create("/custom/agent/auth.json");
|
|
944
|
-
|
|
945
|
-
// Runtime API key override (not persisted)
|
|
946
|
-
if (process.env.MY_KEY) {
|
|
947
|
-
authStorage.setRuntimeApiKey("anthropic", process.env.MY_KEY);
|
|
948
|
-
}
|
|
949
|
-
|
|
950
|
-
// Model registry (no custom models.json)
|
|
951
|
-
const modelRegistry = ModelRegistry.create(authStorage);
|
|
952
|
-
|
|
953
|
-
// Inline tool
|
|
954
|
-
const statusTool = defineTool({
|
|
955
|
-
name: "status",
|
|
956
|
-
label: "Status",
|
|
957
|
-
description: "Get system status",
|
|
958
|
-
parameters: Type.Object({}),
|
|
959
|
-
execute: async () => ({
|
|
960
|
-
content: [{ type: "text", text: `Uptime: ${process.uptime()}s` }],
|
|
961
|
-
details: {},
|
|
962
|
-
}),
|
|
963
|
-
});
|
|
964
|
-
|
|
965
|
-
const model = getModel("anthropic", "claude-opus-4-5");
|
|
966
|
-
if (!model) throw new Error("Model not found");
|
|
967
|
-
|
|
968
|
-
// In-memory settings with overrides
|
|
969
|
-
const settingsManager = SettingsManager.inMemory({
|
|
970
|
-
compaction: { enabled: false },
|
|
971
|
-
retry: { enabled: true, maxRetries: 2 },
|
|
972
|
-
});
|
|
973
|
-
|
|
974
|
-
const loader = new DefaultResourceLoader({
|
|
975
|
-
cwd: process.cwd(),
|
|
976
|
-
agentDir: "/custom/agent",
|
|
977
|
-
settingsManager,
|
|
978
|
-
systemPromptOverride: () => "You are a minimal assistant. Be concise.",
|
|
979
|
-
});
|
|
980
|
-
await loader.reload();
|
|
981
|
-
|
|
982
|
-
const { session } = await createAgentSession({
|
|
983
|
-
cwd: process.cwd(),
|
|
984
|
-
agentDir: "/custom/agent",
|
|
985
|
-
|
|
986
|
-
model,
|
|
987
|
-
thinkingLevel: "off",
|
|
988
|
-
authStorage,
|
|
989
|
-
modelRegistry,
|
|
990
|
-
|
|
991
|
-
tools: ["read", "bash", "status"],
|
|
992
|
-
customTools: [statusTool],
|
|
993
|
-
resourceLoader: loader,
|
|
994
|
-
|
|
995
|
-
sessionManager: SessionManager.inMemory(),
|
|
996
|
-
settingsManager,
|
|
997
|
-
});
|
|
998
|
-
|
|
999
|
-
session.subscribe((event) => {
|
|
77
|
+
const unsubscribe = session.subscribe((event) => {
|
|
1000
78
|
if (event.type === "message_update" && event.assistantMessageEvent.type === "text_delta") {
|
|
1001
79
|
process.stdout.write(event.assistantMessageEvent.delta);
|
|
1002
80
|
}
|
|
1003
81
|
});
|
|
1004
82
|
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
The SDK exports run mode utilities for building custom interfaces on top of `createAgentSession()`:
|
|
1011
|
-
|
|
1012
|
-
### InteractiveMode
|
|
1013
|
-
|
|
1014
|
-
Full TUI interactive mode with editor, chat history, and all built-in commands:
|
|
1015
|
-
|
|
1016
|
-
```typescript
|
|
1017
|
-
import {
|
|
1018
|
-
type CreateAgentSessionRuntimeFactory,
|
|
1019
|
-
createAgentSessionFromServices,
|
|
1020
|
-
createAgentSessionRuntime,
|
|
1021
|
-
createAgentSessionServices,
|
|
1022
|
-
getAgentDir,
|
|
1023
|
-
InteractiveMode,
|
|
1024
|
-
SessionManager,
|
|
1025
|
-
} from "@draht/coding-agent";
|
|
1026
|
-
|
|
1027
|
-
const createRuntime: CreateAgentSessionRuntimeFactory = async ({ cwd, sessionManager, sessionStartEvent }) => {
|
|
1028
|
-
const services = await createAgentSessionServices({ cwd });
|
|
1029
|
-
return {
|
|
1030
|
-
...(await createAgentSessionFromServices({ services, sessionManager, sessionStartEvent })),
|
|
1031
|
-
services,
|
|
1032
|
-
diagnostics: services.diagnostics,
|
|
1033
|
-
};
|
|
1034
|
-
};
|
|
1035
|
-
const runtime = await createAgentSessionRuntime(createRuntime, {
|
|
1036
|
-
cwd: process.cwd(),
|
|
1037
|
-
agentDir: getAgentDir(),
|
|
1038
|
-
sessionManager: SessionManager.create(process.cwd()),
|
|
1039
|
-
});
|
|
1040
|
-
|
|
1041
|
-
const mode = new InteractiveMode(runtime, {
|
|
1042
|
-
migratedProviders: [],
|
|
1043
|
-
modelFallbackMessage: undefined,
|
|
1044
|
-
initialMessage: "Hello",
|
|
1045
|
-
initialImages: [],
|
|
1046
|
-
initialMessages: [],
|
|
1047
|
-
});
|
|
1048
|
-
|
|
1049
|
-
await mode.run();
|
|
83
|
+
try {
|
|
84
|
+
await session.prompt("Explain this repository");
|
|
85
|
+
} finally {
|
|
86
|
+
unsubscribe();
|
|
87
|
+
}
|
|
1050
88
|
```
|
|
1051
89
|
|
|
1052
|
-
|
|
90
|
+
Session events report message updates, tool execution, queues, compaction, retries, and run lifecycle changes.
|
|
1053
91
|
|
|
1054
|
-
|
|
92
|
+
`message_end` contains the authoritative completed message. `agent_end` marks the end of one low-level agent run, but automatic recovery or queued work can still follow.
|
|
1055
93
|
|
|
1056
|
-
|
|
1057
|
-
import {
|
|
1058
|
-
type CreateAgentSessionRuntimeFactory,
|
|
1059
|
-
createAgentSessionFromServices,
|
|
1060
|
-
createAgentSessionRuntime,
|
|
1061
|
-
createAgentSessionServices,
|
|
1062
|
-
getAgentDir,
|
|
1063
|
-
runPrintMode,
|
|
1064
|
-
SessionManager,
|
|
1065
|
-
} from "@draht/coding-agent";
|
|
94
|
+
Use `agent_settled` when the host needs to know that draht will not continue automatically.
|
|
1066
95
|
|
|
1067
|
-
|
|
1068
|
-
const services = await createAgentSessionServices({ cwd });
|
|
1069
|
-
return {
|
|
1070
|
-
...(await createAgentSessionFromServices({ services, sessionManager, sessionStartEvent })),
|
|
1071
|
-
services,
|
|
1072
|
-
diagnostics: services.diagnostics,
|
|
1073
|
-
};
|
|
1074
|
-
};
|
|
1075
|
-
const runtime = await createAgentSessionRuntime(createRuntime, {
|
|
1076
|
-
cwd: process.cwd(),
|
|
1077
|
-
agentDir: getAgentDir(),
|
|
1078
|
-
sessionManager: SessionManager.create(process.cwd()),
|
|
1079
|
-
});
|
|
96
|
+
## Configuring a session
|
|
1080
97
|
|
|
1081
|
-
|
|
1082
|
-
mode: "text",
|
|
1083
|
-
initialMessage: "Hello",
|
|
1084
|
-
initialImages: [],
|
|
1085
|
-
messages: ["Follow up"],
|
|
1086
|
-
});
|
|
1087
|
-
```
|
|
98
|
+
Without overrides, the factory creates a `ModelRuntime`, file-backed `SettingsManager`, persistent `SessionManager`, `DefaultResourceLoader`, and the configured default tools.
|
|
1088
99
|
|
|
1089
|
-
|
|
100
|
+
Each boundary can be supplied explicitly:
|
|
1090
101
|
|
|
1091
|
-
|
|
102
|
+
- `modelRuntime`, `model`, `thinkingLevel`, and `scopedModels` control model access and selection.
|
|
103
|
+
- `settingsManager` supplies merged settings or an in-memory configuration.
|
|
104
|
+
- `sessionManager` supplies persistent or in-memory conversation history.
|
|
105
|
+
- `resourceLoader` supplies extensions, skills, prompt templates, themes, and context files.
|
|
106
|
+
- `tools`, `noTools`, `excludeTools`, and `customTools` control the active tool set.
|
|
1092
107
|
|
|
1093
|
-
|
|
1094
|
-
import {
|
|
1095
|
-
type CreateAgentSessionRuntimeFactory,
|
|
1096
|
-
createAgentSessionFromServices,
|
|
1097
|
-
createAgentSessionRuntime,
|
|
1098
|
-
createAgentSessionServices,
|
|
1099
|
-
getAgentDir,
|
|
1100
|
-
runRpcMode,
|
|
1101
|
-
SessionManager,
|
|
1102
|
-
} from "@draht/coding-agent";
|
|
108
|
+
Use `DefaultResourceLoader` when you want standard discovery with selected overrides. Supply a custom `ResourceLoader` when the host owns resource storage and discovery completely.
|
|
1103
109
|
|
|
1104
|
-
|
|
1105
|
-
const services = await createAgentSessionServices({ cwd });
|
|
1106
|
-
return {
|
|
1107
|
-
...(await createAgentSessionFromServices({ services, sessionManager, sessionStartEvent })),
|
|
1108
|
-
services,
|
|
1109
|
-
diagnostics: services.diagnostics,
|
|
1110
|
-
};
|
|
1111
|
-
};
|
|
1112
|
-
const runtime = await createAgentSessionRuntime(createRuntime, {
|
|
1113
|
-
cwd: process.cwd(),
|
|
1114
|
-
agentDir: getAgentDir(),
|
|
1115
|
-
sessionManager: SessionManager.create(process.cwd()),
|
|
1116
|
-
});
|
|
110
|
+
<a id="inlineextension"></a>
|
|
1117
111
|
|
|
1118
|
-
|
|
1119
|
-
```
|
|
112
|
+
Inline extension factories can be supplied through `DefaultResourceLoader`. Give one an `InlineExtension` name only when it needs a stable name in diagnostics and startup output. A named inline extension with `replaceable: true` is left out when another extension registers a tool, command, or flag with a name it registers during loading, instead of both loading with a conflict. The CLI's built-in codemode, tool search, and MCP extensions are replaceable. A named entry with `builtin: true` is not an inline extension: it supplies the code of the `builtin:<name>` extension, which loads like a configured extension file. It loads by default, is listed in `draht config`, and is disabled by `-builtin:<name>` in the `extensions` setting or by `noExtensions`; `additionalExtensionPaths: ["builtin:<name>"]` loads it explicitly. It loads after project trust is resolved, so it cannot handle `project_trust`. The CLI's built-in extensions use it.
|
|
1120
113
|
|
|
1121
|
-
|
|
114
|
+
<a id="codemode-mcp"></a>
|
|
1122
115
|
|
|
1123
|
-
|
|
116
|
+
The CLI loads `codemode`, `tool_search`, and MCP as built-in extensions. SDK sessions do not; add `createCodemodeExtension()`, `createToolSearchExtension()`, and `createMcpExtension()` to the `extensionFactories` of `DefaultResourceLoader`. `codemode` and `tool_search` are registered inactive: enable them through the `defaultTools` setting (`["+codemode", "+tool_search"]` keeps the other default tools), or let the MCP extension activate them: `codemode` for servers with `codemode` exposure, `tool_search` for servers with `deferred` exposure. The MCP extension connects its servers on `session_start`, so call `session.bindExtensions()`. See [Codemode and MCP](../examples/sdk/14-codemode-mcp.ts).
|
|
1124
117
|
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
```bash
|
|
1128
|
-
draht --mode rpc --no-session
|
|
1129
|
-
```
|
|
118
|
+
See the focused examples for [models](../examples/sdk/02-custom-model.ts), [tools](../examples/sdk/05-tools.ts), [extensions](../examples/sdk/06-extensions.ts), and [full control](../examples/sdk/12-full-control.ts).
|
|
1130
119
|
|
|
1131
|
-
|
|
120
|
+
## Examples
|
|
1132
121
|
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
-
|
|
1136
|
-
-
|
|
1137
|
-
-
|
|
122
|
+
| Example | Purpose |
|
|
123
|
+
|---|---|
|
|
124
|
+
| [Minimal](../examples/sdk/01-minimal.ts) | Create, prompt, observe, and dispose a session |
|
|
125
|
+
| [Custom model](../examples/sdk/02-custom-model.ts) | Select a model and thinking level |
|
|
126
|
+
| [System prompt](../examples/sdk/03-custom-prompt.ts) | Replace or append to the system prompt |
|
|
127
|
+
| [Skills](../examples/sdk/04-skills.ts) | Discover, filter, and add skills |
|
|
128
|
+
| [Tools](../examples/sdk/05-tools.ts) | Select built-in tools and their working directory |
|
|
129
|
+
| [Extensions](../examples/sdk/06-extensions.ts) | Load file-based and inline extensions |
|
|
130
|
+
| [Context files](../examples/sdk/07-context-files.ts) | Add or replace project instructions |
|
|
131
|
+
| [Prompt templates](../examples/sdk/08-prompt-templates.ts) | Add file-style prompt templates |
|
|
132
|
+
| [Credentials](../examples/sdk/09-api-keys-and-oauth.ts) | Configure credential and model storage |
|
|
133
|
+
| [Settings](../examples/sdk/10-settings.ts) | Supply file-backed or in-memory settings |
|
|
134
|
+
| [Sessions](../examples/sdk/11-sessions.ts) | Control session persistence and restoration |
|
|
135
|
+
| [Full control](../examples/sdk/12-full-control.ts) | Replace default discovery and state services |
|
|
136
|
+
| [Session runtime](../examples/sdk/13-session-runtime.ts) | Replace the active session safely |
|
|
137
|
+
| [Codemode and MCP](../examples/sdk/14-codemode-mcp.ts) | Add the `codemode`, `tool_search`, and MCP extensions |
|
|
1138
138
|
|
|
1139
|
-
|
|
1140
|
-
- You're integrating from another language
|
|
1141
|
-
- You want process isolation
|
|
1142
|
-
- You're building a language-agnostic client
|
|
139
|
+
<a id="exports"></a>
|
|
1143
140
|
|
|
1144
|
-
##
|
|
1145
|
-
|
|
1146
|
-
The main entry point exports:
|
|
1147
|
-
|
|
1148
|
-
```typescript
|
|
1149
|
-
// Factory
|
|
1150
|
-
createAgentSession
|
|
1151
|
-
createAgentSessionRuntime
|
|
1152
|
-
AgentSessionRuntime
|
|
1153
|
-
|
|
1154
|
-
// Auth and Models
|
|
1155
|
-
AuthStorage
|
|
1156
|
-
ModelRegistry
|
|
1157
|
-
resolveCliModel
|
|
1158
|
-
resolveModelScopeWithDiagnostics
|
|
1159
|
-
|
|
1160
|
-
// Resource loading
|
|
1161
|
-
DefaultResourceLoader
|
|
1162
|
-
type ResourceLoader
|
|
1163
|
-
createEventBus
|
|
1164
|
-
|
|
1165
|
-
// Helpers
|
|
1166
|
-
defineTool
|
|
1167
|
-
getAgentDir
|
|
1168
|
-
getPackageDir
|
|
1169
|
-
getReadmePath
|
|
1170
|
-
getDocsPath
|
|
1171
|
-
getExamplesPath
|
|
1172
|
-
|
|
1173
|
-
// Session management
|
|
1174
|
-
SessionManager
|
|
1175
|
-
SettingsManager
|
|
1176
|
-
|
|
1177
|
-
// Tool factories
|
|
1178
|
-
createCodingTools
|
|
1179
|
-
createReadOnlyTools
|
|
1180
|
-
createReadTool, createBashTool, createEditTool, createWriteTool
|
|
1181
|
-
createGrepTool, createFindTool, createLsTool
|
|
1182
|
-
|
|
1183
|
-
// Types
|
|
1184
|
-
type CreateAgentSessionOptions
|
|
1185
|
-
type CreateAgentSessionResult
|
|
1186
|
-
type ExtensionFactory
|
|
1187
|
-
type InlineExtension
|
|
1188
|
-
type ExtensionAPI
|
|
1189
|
-
type ToolDefinition
|
|
1190
|
-
type Skill
|
|
1191
|
-
type PromptTemplate
|
|
1192
|
-
type Tool
|
|
1193
|
-
```
|
|
141
|
+
## Resources
|
|
1194
142
|
|
|
1195
|
-
|
|
143
|
+
- [Choose a Model](models.md) covers model selection and compatible endpoints; [Provider Authentication](providers.md) covers credentials and cloud-provider setup.
|
|
144
|
+
- [Configuration](configuration.md) explains normal discovery and settings; [Settings](settings.md) lists every setting.
|
|
145
|
+
- [Sessions and Context](sessions.md) explains session behavior; [Session Format](session-format.md) defines persisted entries; [Message Types](message-types.md) defines shared transcript values.
|
|
146
|
+
- [Extensions](extensions.md), [Skills](skills.md), and [Prompt Templates](prompt-templates.md) document resources supplied through a `ResourceLoader`.
|
|
147
|
+
- [CLI Integration](cli-integration.md) covers print, JSON, and RPC alternatives to an in-process SDK integration.
|