@bastani/atomic 0.10.9 → 0.10.10-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +57 -0
- package/README.md +211 -155
- package/dist/_shared/dist-KOELCESV.js +2 -2
- package/dist/_shared/fork-row-index-UAUAQRD5.js +2 -2
- package/dist/_shared/lib-4PES5P4V.js +2 -2
- package/dist/_shared/mode-interactive-sdk-7KXUFI2F.js +27 -12
- package/dist/_shared/mode-interactive-sdk-7KXUFI2F.js.map +1 -1
- package/dist/_shared/mode-rpc-sdk-IOPGDYR4.js +47 -7
- package/dist/_shared/mode-rpc-sdk-IOPGDYR4.js.map +1 -1
- package/dist/_shared/mode-shared-2QJSCUM6.js +48 -19
- package/dist/_shared/mode-shared-2QJSCUM6.js.map +1 -1
- package/dist/_shared/{p1a-prewarm-UQY3X2UK.js → p1a-prewarm-XIU57JHF.js} +5 -5
- package/dist/_shared/{p1a-prewarm-UQY3X2UK.js.map → p1a-prewarm-XIU57JHF.js.map} +1 -1
- package/dist/_shared/p2-shell-main-B2WIALFD.js +30 -25
- package/dist/_shared/p2-shell-main-B2WIALFD.js.map +1 -1
- package/dist/_shared/runtime-O4KCSG4C.js +5 -5
- package/dist/_shared/{sdk-OSBEPR3Q.js → sdk-RRLVN7ER.js} +15 -9
- package/dist/_shared/sdk-RRLVN7ER.js.map +1 -0
- package/dist/_shared/session-data-AHTU7IS6.js +2 -2
- package/dist/_shared/session-manager-list-2BLEEZVG.js +1 -1
- package/dist/_shared/settings-startup-8-DNZ2RIHM.js +4 -1
- package/dist/_shared/settings-startup-8-DNZ2RIHM.js.map +1 -1
- package/dist/_shared/{startup-0-0-TYUFUOJZ.js → startup-0-0-4VG2G44V.js} +427 -33
- package/dist/_shared/startup-0-0-4VG2G44V.js.map +1 -0
- package/dist/_shared/{startup-0-1-W2G2UY7R.js → startup-0-1-XTIL65D4.js} +18 -11
- package/dist/_shared/startup-0-1-XTIL65D4.js.map +1 -0
- package/dist/_shared/{startup-0-2-UXBUEOXW.js → startup-0-2-27OWFHV6.js} +145 -58
- package/dist/_shared/startup-0-2-27OWFHV6.js.map +1 -0
- package/dist/_shared/startup-0-3-T4DVFYWX.js +15 -25
- package/dist/_shared/startup-0-3-T4DVFYWX.js.map +1 -1
- package/dist/_shared/{startup-0-4-HN5EB4K7.js → startup-0-4-ZMJV547D.js} +81 -12
- package/dist/_shared/startup-0-4-ZMJV547D.js.map +1 -0
- package/dist/_shared/startup-0-5-FD2P735I.js +90 -50
- package/dist/_shared/startup-0-5-FD2P735I.js.map +1 -1
- package/dist/_shared/startup-10-0-TDQNBDDL.js +5 -5
- package/dist/_shared/startup-12-0-55AAXBJZ.js +13 -7
- package/dist/_shared/startup-12-0-55AAXBJZ.js.map +1 -1
- package/dist/_shared/startup-14-0-MLX36RBG.js +4 -4
- package/dist/_shared/startup-15-0-YUKGAC63.js +4 -4
- package/dist/_shared/startup-15-1-4S7FLMNG.js +88 -28
- package/dist/_shared/startup-15-1-4S7FLMNG.js.map +1 -1
- package/dist/_shared/startup-8-0-34CBHPZH.js +5 -5
- package/dist/_shared/startup-8-1-4KANEHRA.js +61 -17
- package/dist/_shared/startup-8-1-4KANEHRA.js.map +1 -1
- package/dist/_shared/storage-command-7MGXLJGZ.js +4 -4
- package/dist/_shared/task-unsaved-answer-VJ2KTB4V.js +2 -2
- package/dist/_shared/tree-outline-MUEPK5B7.js +2 -2
- package/dist/builtin/intercom/CHANGELOG.md +6 -0
- package/dist/builtin/intercom/README.md +85 -114
- package/dist/builtin/intercom/broker/broker.bundle.mjs +3 -3
- package/dist/builtin/intercom/broker/presence-handler.ts +1 -1
- package/dist/builtin/intercom/group.ts +7 -3
- package/dist/builtin/intercom/index.bundle.mjs +1 -1
- package/dist/builtin/intercom/package.json +1 -1
- package/dist/builtin/mcp/README.md +37 -27
- package/dist/builtin/mcp/index.bundle.mjs +1 -1
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/CHANGELOG.md +8 -0
- package/dist/builtin/subagents/README.md +71 -138
- package/dist/builtin/subagents/package.json +1 -1
- package/dist/builtin/subagents/src/extension/index.bundle.mjs +213 -74
- package/dist/builtin/web-access/CHANGELOG.md +9 -0
- package/dist/builtin/web-access/README.md +60 -87
- package/dist/builtin/web-access/index.bundle.mjs +387 -351
- package/dist/builtin/web-access/package.json +1 -1
- package/dist/cli/args.js +2 -2
- package/dist/cli/auth-cli.code.js +4 -4
- package/dist/cli/auth-cli.impl.js +3 -3
- package/dist/cli/auth-cli.js +3 -3
- package/dist/cli/blueprint-command.code.js +2 -2
- package/dist/cli/blueprint-command.impl.js +3 -3
- package/dist/cli/blueprint-command.js +3 -3
- package/dist/cli/intercom-command.code.js +3 -3
- package/dist/cli/intercom-command.impl.js +3 -3
- package/dist/cli/intercom-command.js +3 -3
- package/dist/cli/list-models.code.js +3 -3
- package/dist/cli/list-models.impl.js +3 -3
- package/dist/cli/list-models.js +3 -3
- package/dist/cli/session-picker.code.js +2 -2
- package/dist/cli/session-picker.impl.js +3 -3
- package/dist/cli/session-picker.js +3 -3
- package/dist/cli/startup-ui.code.js +2 -2
- package/dist/cli/startup-ui.impl.js +3 -3
- package/dist/cli/startup-ui.js +3 -3
- package/dist/cli/storage-command.impl.js +3 -3
- package/dist/cli/storage-command.js +3 -3
- package/dist/cli/storage-search-session.code.js +2 -2
- package/dist/cli/storage-search-session.impl.js +3 -3
- package/dist/cli/storage-search-session.js +3 -3
- package/dist/cli/team-command.code.js +2 -2
- package/dist/cli/team-command.impl.js +3 -3
- package/dist/cli/team-command.js +3 -3
- package/dist/cli.js +2 -2
- package/dist/core/agent-session-methods.d.ts +4 -1
- package/dist/core/agent-session-methods.js.map +1 -1
- package/dist/core/agent-session.d.ts +3 -0
- package/dist/core/compaction/compactor.d.ts +20 -14
- package/dist/core/compaction/errors.d.ts +120 -0
- package/dist/core/compaction/index.d.ts +1 -0
- package/dist/core/compaction/model-resolver.d.ts +2 -2
- package/dist/core/debug.impl.js +3 -3
- package/dist/core/debug.js +3 -3
- package/dist/core/export-html/card-projection.impl.js +3 -3
- package/dist/core/export-html/card-projection.js +3 -3
- package/dist/core/export-html/index.code.js +2 -2
- package/dist/core/export-html/index.impl.js +3 -3
- package/dist/core/export-html/index.js +3 -3
- package/dist/core/export-html/json-spans.impl.js +3 -3
- package/dist/core/export-html/json-spans.js +3 -3
- package/dist/core/export-html/oversized-render-inputs.impl.js +3 -3
- package/dist/core/export-html/oversized-render-inputs.js +3 -3
- package/dist/core/export-html/tool-renderer.code.js +1 -1
- package/dist/core/export-html/tool-renderer.impl.js +3 -3
- package/dist/core/export-html/tool-renderer.js +3 -3
- package/dist/core/extensions/api-types.d.ts +1 -1
- package/dist/core/extensions/api-types.js.map +1 -1
- package/dist/core/extensions/index.d.ts +1 -1
- package/dist/core/extensions/jiti-loader.impl.js +3 -3
- package/dist/core/extensions/jiti-loader.js +3 -3
- package/dist/core/extensions/jiti-static-loader.impl.js +3 -3
- package/dist/core/extensions/jiti-static-loader.js +3 -3
- package/dist/core/extensions/loader-host-modules.code.js +1 -1
- package/dist/core/extensions/loader-host-modules.impl.js +3 -3
- package/dist/core/extensions/loader-host-modules.js +3 -3
- package/dist/core/extensions/loader-virtual-modules.js +1 -1
- package/dist/core/extensions/provider-types.d.ts +18 -6
- package/dist/core/extensions/provider-types.js.map +1 -1
- package/dist/core/extensions/runner-context.js +1 -1
- package/dist/core/intercom-broker-control-host.code.js +1 -1
- package/dist/core/intercom-broker-control-host.impl.js +3 -3
- package/dist/core/intercom-broker-control-host.js +3 -3
- package/dist/core/intercom-broker-control.code.js +3 -3
- package/dist/core/intercom-broker-control.impl.js +3 -3
- package/dist/core/intercom-broker-control.js +3 -3
- package/dist/core/model-config.d.ts +40 -0
- package/dist/core/model-registry.js +1 -1
- package/dist/core/model-resolver-scope.d.ts +4 -4
- package/dist/core/model-runtime.d.ts +1 -1
- package/dist/core/package-manager-storage-adapters.impl.js +3 -3
- package/dist/core/package-manager-storage-adapters.js +3 -3
- package/dist/core/provider-composer-internal.d.ts +11 -2
- package/dist/core/sdk.code.js +3 -3
- package/dist/core/sdk.impl.js +3 -3
- package/dist/core/sdk.js +3 -3
- package/dist/core/session-manager-core.js +5 -5
- package/dist/core/session-manager-list.impl.js +3 -3
- package/dist/core/session-manager-list.js +3 -3
- package/dist/core/session-manager.code.js +1 -1
- package/dist/core/session-manager.impl.js +3 -3
- package/dist/core/session-manager.js +3 -3
- package/dist/core/session-storage.impl.js +3 -3
- package/dist/core/session-storage.js +3 -3
- package/dist/core/settings-manager-basic-accessors.d.ts +6 -2
- package/dist/core/storage/index.js +2 -2
- package/dist/core/storage/node-sqlite-thread.js +2 -2
- package/dist/core/storage/node-sqlite.js +2 -2
- package/dist/core/storage/offline-snapshot-file.impl.js +3 -3
- package/dist/core/storage/offline-snapshot-file.js +3 -3
- package/dist/core/storage/provider.js +2 -2
- package/dist/core/storage/selection.js +2 -2
- package/dist/core/storage/session/branch-fork-source.code.js +2 -2
- package/dist/core/storage/session/branch-fork-source.impl.js +3 -3
- package/dist/core/storage/session/branch-fork-source.js +3 -3
- package/dist/core/storage/session/card-view.impl.js +3 -3
- package/dist/core/storage/session/card-view.js +3 -3
- package/dist/core/storage/session/child-reader.code.js +3 -3
- package/dist/core/storage/session/child-reader.impl.js +3 -3
- package/dist/core/storage/session/child-reader.js +3 -3
- package/dist/core/storage/session/chunked-resume-projection.impl.js +3 -3
- package/dist/core/storage/session/chunked-resume-projection.js +3 -3
- package/dist/core/storage/session/expanded-child-details.code.js +2 -2
- package/dist/core/storage/session/expanded-child-details.impl.js +3 -3
- package/dist/core/storage/session/expanded-child-details.js +3 -3
- package/dist/core/storage/session/fork-row-bytes.impl.js +3 -3
- package/dist/core/storage/session/fork-row-bytes.js +3 -3
- package/dist/core/storage/session/fork-row-index.impl.js +3 -3
- package/dist/core/storage/session/fork-row-index.js +3 -3
- package/dist/core/storage/session/fork-staging.code.js +2 -2
- package/dist/core/storage/session/fork-staging.impl.js +3 -3
- package/dist/core/storage/session/fork-staging.js +3 -3
- package/dist/core/storage/session/fork-window.code.js +3 -3
- package/dist/core/storage/session/fork-window.impl.js +3 -3
- package/dist/core/storage/session/fork-window.js +3 -3
- package/dist/core/storage/session/history-pages.impl.js +3 -3
- package/dist/core/storage/session/history-pages.js +3 -3
- package/dist/core/storage/session/jsonl-entry-projection.impl.js +3 -3
- package/dist/core/storage/session/jsonl-entry-projection.js +3 -3
- package/dist/core/storage/session/jsonl-session-store.impl.js +3 -3
- package/dist/core/storage/session/jsonl-session-store.js +3 -3
- package/dist/core/storage/session/memory-session-store.impl.js +3 -3
- package/dist/core/storage/session/memory-session-store.js +3 -3
- package/dist/core/storage/session/pinned-branch-resume.code.js +3 -3
- package/dist/core/storage/session/pinned-branch-resume.impl.js +3 -3
- package/dist/core/storage/session/pinned-branch-resume.js +3 -3
- package/dist/core/storage/session/released-history-files.code.js +3 -3
- package/dist/core/storage/session/released-history-files.impl.js +3 -3
- package/dist/core/storage/session/released-history-files.js +3 -3
- package/dist/core/storage/session/resident-fork-rows.impl.js +3 -3
- package/dist/core/storage/session/resident-fork-rows.js +3 -3
- package/dist/core/storage/session/session-resume.impl.js +3 -3
- package/dist/core/storage/session/session-resume.js +3 -3
- package/dist/core/storage/session/snapshot-cut.impl.js +3 -3
- package/dist/core/storage/session/snapshot-cut.js +3 -3
- package/dist/core/storage/session/snapshot-history.code.js +3 -3
- package/dist/core/storage/session/snapshot-history.impl.js +3 -3
- package/dist/core/storage/session/snapshot-history.js +3 -3
- package/dist/core/storage/session/sql-session-store.code.js +1 -1
- package/dist/core/storage/session/sql-session-store.impl.js +3 -3
- package/dist/core/storage/session/sql-session-store.js +3 -3
- package/dist/core/storage/session/tree-outline.impl.js +3 -3
- package/dist/core/storage/session/tree-outline.js +3 -3
- package/dist/core/storage/session/tree-presentation.impl.js +3 -3
- package/dist/core/storage/session/tree-presentation.js +3 -3
- package/dist/core/storage/storage-status.impl.js +3 -3
- package/dist/core/storage/storage-status.js +3 -3
- package/dist/core/storage/team.impl.js +3 -3
- package/dist/core/storage/team.js +3 -3
- package/dist/core/structured-output/index.code.js +1 -1
- package/dist/core/structured-output/index.impl.js +3 -3
- package/dist/core/structured-output/index.js +3 -3
- package/dist/core/tasks/task-completion-entry.impl.js +3 -3
- package/dist/core/tasks/task-completion-entry.js +3 -3
- package/dist/core/tasks/task-file-history.code.js +3 -3
- package/dist/core/tasks/task-file-history.impl.js +3 -3
- package/dist/core/tasks/task-file-history.js +3 -3
- package/dist/core/tasks/task-reference-archive.code.js +4 -4
- package/dist/core/tasks/task-reference-archive.js +3 -3
- package/dist/core/tasks/task-reference-identity.code.js +1 -1
- package/dist/core/tasks/task-reference-identity.js +3 -3
- package/dist/core/tasks/task-reference-stream.impl.js +3 -3
- package/dist/core/tasks/task-reference-stream.js +3 -3
- package/dist/core/tasks/task-unsaved-answer.impl.js +3 -3
- package/dist/core/tasks/task-unsaved-answer.js +3 -3
- package/dist/core/tasks/task-view-source.impl.js +3 -3
- package/dist/core/tasks/task-view-source.js +3 -3
- package/dist/core/tools/read-url.code.js +2 -2
- package/dist/core/tools/read-url.impl.js +3 -3
- package/dist/core/tools/read-url.js +3 -3
- package/dist/core/worktree-snapshot/blob-store.js +2 -2
- package/dist/core/worktree-snapshot/errors.code.js +3 -3
- package/dist/core/worktree-snapshot/errors.impl.js +3 -3
- package/dist/core/worktree-snapshot/errors.js +3 -3
- package/dist/core/worktree-snapshot/session-index-reset.impl.js +3 -3
- package/dist/core/worktree-snapshot/session-index-reset.js +3 -3
- package/dist/extensions/codemode/execute.code.js +1 -1
- package/dist/extensions/codemode/execute.impl.js +3 -3
- package/dist/extensions/codemode/execute.js +3 -3
- package/dist/extensions/codemode/renderer.code.js +2 -2
- package/dist/extensions/codemode/renderer.impl.js +3 -3
- package/dist/extensions/codemode/renderer.js +3 -3
- package/dist/extensions/mcp/cli.code.js +2 -2
- package/dist/extensions/mcp/cli.impl.js +3 -3
- package/dist/extensions/mcp/cli.js +3 -3
- package/dist/extensions/mcp/cli.lazy.code.js +2 -2
- package/dist/extensions/mcp/cli.lazy.impl.js +3 -3
- package/dist/extensions/mcp/cli.lazy.js +3 -3
- package/dist/extensions/mcp/runtime.code.js +1 -1
- package/dist/extensions/mcp/runtime.impl.js +3 -3
- package/dist/extensions/mcp/runtime.js +3 -3
- package/dist/index-extensions.d.ts +1 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.js +7 -7
- package/dist/main-first-time-setup.code.js +2 -2
- package/dist/main-first-time-setup.impl.js +3 -3
- package/dist/main-first-time-setup.js +3 -3
- package/dist/modes/interactive/components/settings-selector-types.d.ts +1 -0
- package/dist/modes/interactive/components/settings-selector-types.js.map +1 -1
- package/dist/modes/interactive/components/stored-tree-view.code.js +2 -2
- package/dist/modes/interactive/components/stored-tree-view.impl.js +3 -3
- package/dist/modes/interactive/components/stored-tree-view.js +3 -3
- package/dist/modes/interactive/components/user-message-selector-archive.impl.js +3 -3
- package/dist/modes/interactive/components/user-message-selector-archive.js +3 -3
- package/dist/modes/interactive/theme/color-utils.d.ts +5 -5
- package/dist/modes/interactive/theme/theme-loading.d.ts +1 -0
- package/dist/modes/interactive-engine/engine-prewarm.js +1 -1
- package/dist/modes/interactive-engine/remote-model-catalog.d.ts +1 -0
- package/dist/modes/print-mode.js +1 -1
- package/dist/modes/rpc/rpc-client-api.d.ts +6 -0
- package/dist/modes/rpc/rpc-types.d.ts +29 -2
- package/dist/package-manager-cli.code.js +5 -5
- package/dist/package-manager-cli.impl.js +3 -3
- package/dist/package-manager-cli.js +3 -3
- package/dist/rpc-entry.js +1 -1
- package/dist/startup-files.json +1 -1
- package/dist/startup-stages/5.js +1 -1
- package/dist/startup-stages/7.js +1 -1
- package/dist/startup-stages/8.js +1 -2
- package/dist/startup-stages/9.js +2 -1
- package/dist/utils/native-module.d.ts +44 -0
- package/dist/utils/startup-database-spare.code.js +3 -3
- package/dist/utils/startup-database-spare.impl.js +3 -3
- package/dist/utils/startup-database-spare.js +3 -3
- package/dist/utils/tools-manager.code.js +1 -1
- package/dist/utils/tools-manager.impl.js +3 -3
- package/dist/utils/tools-manager.js +3 -3
- package/docs/background-tasks.md +235 -243
- package/docs/build.md +12 -11
- package/docs/codemode.md +60 -51
- package/docs/compaction/reference.md +61 -24
- package/docs/compaction.md +117 -65
- package/docs/computer-use.md +179 -146
- package/docs/containerization.md +79 -33
- package/docs/custom-provider/api-reference.md +148 -11
- package/docs/custom-provider/oauth.md +44 -27
- package/docs/custom-provider/override.md +14 -7
- package/docs/custom-provider/registration.md +75 -65
- package/docs/custom-provider/streaming.md +42 -19
- package/docs/custom-provider.md +25 -61
- package/docs/development.md +47 -43
- package/docs/docs.json +33 -33
- package/docs/environment-variables.md +83 -57
- package/docs/extensions/api-reference.md +323 -734
- package/docs/extensions/authoring.md +186 -269
- package/docs/extensions/events.md +308 -375
- package/docs/extensions/examples.md +122 -74
- package/docs/extensions/ui.md +217 -197
- package/docs/extensions.md +152 -259
- package/docs/getting-started/authentication.md +27 -14
- package/docs/getting-started/first-session.md +25 -26
- package/docs/getting-started/installation.md +62 -84
- package/docs/getting-started/project-instructions.md +39 -14
- package/docs/guides/configuration.md +42 -20
- package/docs/guides/intercom.md +17 -13
- package/docs/guides/non-interactive.md +29 -16
- package/docs/guides/orchestration.md +16 -10
- package/docs/guides/resume-on-any-machine.md +54 -49
- package/docs/guides/subagents.md +22 -14
- package/docs/guides/team-setup.md +37 -26
- package/docs/guides.md +22 -21
- package/docs/herdr.md +21 -16
- package/docs/index.md +16 -17
- package/docs/intercom/operations.md +68 -66
- package/docs/intercom/reference.md +196 -191
- package/docs/intercom.md +103 -92
- package/docs/json.md +71 -71
- package/docs/keybindings.md +63 -50
- package/docs/libraries/agent-core.md +49 -8
- package/docs/libraries/ai.md +21 -12
- package/docs/libraries/codemode.md +28 -6
- package/docs/libraries/schema.md +7 -7
- package/docs/libraries/telemetry.md +7 -7
- package/docs/libraries/tui.md +74 -94
- package/docs/libraries.md +5 -5
- package/docs/llama-cpp.md +38 -33
- package/docs/mcp-servers.md +96 -90
- package/docs/models/reference.md +46 -33
- package/docs/models-configuration.md +12 -6
- package/docs/models.md +93 -88
- package/docs/orchestration/migrating-workflows.md +21 -19
- package/docs/orchestration/patterns.md +35 -20
- package/docs/orchestration.md +22 -21
- package/docs/packages/authoring.md +28 -19
- package/docs/packages/reference.md +75 -16
- package/docs/packages.md +31 -33
- package/docs/programmatic.md +22 -21
- package/docs/prompt-templates.md +63 -41
- package/docs/providers/reference.md +35 -19
- package/docs/providers.md +61 -71
- package/docs/quickstart.md +32 -46
- package/docs/reference/cli.md +249 -252
- package/docs/reference.md +23 -20
- package/docs/rpc/examples.md +74 -17
- package/docs/rpc/extension-ui.md +79 -62
- package/docs/rpc/protocol.md +816 -358
- package/docs/rpc.md +75 -151
- package/docs/sdk/reference.md +175 -45
- package/docs/sdk/structured-decisions.md +92 -62
- package/docs/sdk/web-server.md +79 -46
- package/docs/sdk.md +237 -195
- package/docs/security.md +106 -43
- package/docs/session-format.md +96 -59
- package/docs/sessions.md +149 -113
- package/docs/settings.md +289 -204
- package/docs/shell-aliases.md +15 -6
- package/docs/skills/authoring.md +17 -9
- package/docs/skills/reference.md +23 -21
- package/docs/skills.md +104 -97
- package/docs/storage.md +140 -242
- package/docs/subagents/authoring.md +147 -16
- package/docs/subagents/reference.md +100 -30
- package/docs/subagents.md +220 -252
- package/docs/terminal-setup.md +97 -69
- package/docs/termux.md +51 -85
- package/docs/themes/reference.md +51 -37
- package/docs/themes.md +49 -54
- package/docs/tmux.md +38 -21
- package/docs/tools.md +198 -147
- package/docs/tui/reference.md +64 -32
- package/docs/tui.md +38 -66
- package/docs/usage.md +76 -78
- package/docs/verification.md +25 -25
- package/docs/web-access.md +72 -55
- package/docs/windows.md +53 -58
- package/docs/worktree-snapshots.md +62 -65
- package/package.json +8 -8
- package/schemas/models.schema.json +51 -0
- package/dist/_shared/sdk-OSBEPR3Q.js.map +0 -1
- package/dist/_shared/startup-0-0-TYUFUOJZ.js.map +0 -1
- package/dist/_shared/startup-0-1-W2G2UY7R.js.map +0 -1
- package/dist/_shared/startup-0-2-UXBUEOXW.js.map +0 -1
- package/dist/_shared/startup-0-4-HN5EB4K7.js.map +0 -1
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
---
|
|
2
|
-
title:
|
|
3
|
-
|
|
2
|
+
title: "Write an extension"
|
|
3
|
+
sidebarTitle: "Write an extension"
|
|
4
|
+
description: "Structure an extension, persist state across reloads and restarts, register custom tools, and customize terminal rendering."
|
|
4
5
|
---
|
|
5
6
|
|
|
6
|
-
# Writing extensions
|
|
7
|
-
|
|
8
|
-
## Writing an extension
|
|
9
|
-
|
|
10
7
|
An extension exports a default factory function that receives `ExtensionAPI`. The parameter can have any name; older extensions and examples call it `pi`. The factory can be synchronous or asynchronous:
|
|
11
8
|
|
|
12
9
|
```typescript
|
|
@@ -15,11 +12,10 @@ import type { ExtensionAPI } from "@bastani/atomic";
|
|
|
15
12
|
export default function (atomic: ExtensionAPI) {
|
|
16
13
|
// Subscribe to events
|
|
17
14
|
atomic.on("event_name", async (event, ctx) => {
|
|
18
|
-
// ctx.ui for user interaction
|
|
19
15
|
const ok = await ctx.ui.confirm("Title", "Are you sure?");
|
|
20
16
|
ctx.ui.notify("Done!", "info");
|
|
21
|
-
ctx.ui.setStatus("my-ext", "Processing...");
|
|
22
|
-
ctx.ui.setWidget("my-ext", ["Line 1", "Line 2"]);
|
|
17
|
+
ctx.ui.setStatus("my-ext", "Processing..."); // Footer status
|
|
18
|
+
ctx.ui.setWidget("my-ext", ["Line 1", "Line 2"]); // Widget above editor (default)
|
|
23
19
|
});
|
|
24
20
|
|
|
25
21
|
// Register tools, commands, shortcuts, flags
|
|
@@ -30,17 +26,17 @@ export default function (atomic: ExtensionAPI) {
|
|
|
30
26
|
}
|
|
31
27
|
```
|
|
32
28
|
|
|
33
|
-
Editable extensions support TypeScript without
|
|
29
|
+
Editable extensions support TypeScript without a separate build step. Running `/reload` picks up edits to your extension and local modules it imports; unchanged modules may retain module-scoped state.
|
|
34
30
|
|
|
35
|
-
Imports from Atomic's
|
|
31
|
+
Imports from Atomic's bundled core packages keep the running host's classes and shared state across `/reload`, including on Windows. The `@earendil-works/pi-coding-agent` compatibility import shares those exports with `@bastani/atomic`, so `instanceof` checks work across both names after reload. Restart Atomic after updating Atomic itself.
|
|
36
32
|
|
|
37
|
-
In Bun single-file builds,
|
|
33
|
+
In Bun single-file builds, bundled built-in packages keep their module-scoped state across `/reload`. Restart Atomic to reload shipped code.
|
|
38
34
|
|
|
39
|
-
If
|
|
35
|
+
If your factory returns a `Promise`, Atomic awaits it before continuing startup. Async initialization completes before `session_start`, before `resources_discover`, and before provider registrations queued with `atomic.registerProvider()` are flushed.
|
|
40
36
|
|
|
41
|
-
|
|
37
|
+
## Async factory functions
|
|
42
38
|
|
|
43
|
-
Use an async factory for one-time startup work such as fetching remote configuration or
|
|
39
|
+
Use an async factory for one-time startup work such as fetching remote configuration or discovering available models:
|
|
44
40
|
|
|
45
41
|
```typescript
|
|
46
42
|
import type { ExtensionAPI } from "@bastani/atomic";
|
|
@@ -73,26 +69,26 @@ export default async function (atomic: ExtensionAPI) {
|
|
|
73
69
|
}
|
|
74
70
|
```
|
|
75
71
|
|
|
76
|
-
|
|
72
|
+
Models registered here become available during normal startup and in `atomic --list-models`.
|
|
77
73
|
|
|
78
|
-
|
|
74
|
+
## Long-lived resources and shutdown
|
|
79
75
|
|
|
80
|
-
Extension factories
|
|
76
|
+
Extension factories can run during commands that never start a full session, such as metadata commands or early configuration checks. Do not start child processes, sockets, file watchers, or timers directly inside the factory function.
|
|
81
77
|
|
|
82
|
-
|
|
78
|
+
Start background resources inside `session_start` or inside the command, tool, or event handler that needs them. Register an idempotent `session_shutdown` handler to close every resource you open.
|
|
83
79
|
|
|
84
|
-
|
|
80
|
+
## Extension layouts
|
|
85
81
|
|
|
86
|
-
**Single file.**
|
|
82
|
+
**Single file.** Best for small extensions:
|
|
87
83
|
|
|
88
|
-
```
|
|
84
|
+
```text
|
|
89
85
|
~/.atomic/agent/extensions/
|
|
90
86
|
└── my-extension.ts
|
|
91
87
|
```
|
|
92
88
|
|
|
93
|
-
**Directory with `index.ts`.**
|
|
89
|
+
**Directory with `index.ts`.** Best for multi-file extensions:
|
|
94
90
|
|
|
95
|
-
```
|
|
91
|
+
```text
|
|
96
92
|
~/.atomic/agent/extensions/
|
|
97
93
|
└── my-extension/
|
|
98
94
|
├── index.ts # Entry point (exports default function)
|
|
@@ -100,9 +96,9 @@ Defer background resource startup until `session_start` or the command/tool/even
|
|
|
100
96
|
└── utils.ts # Helper module
|
|
101
97
|
```
|
|
102
98
|
|
|
103
|
-
**Package with dependencies.**
|
|
99
|
+
**Package with dependencies.** Best for extensions that need npm packages:
|
|
104
100
|
|
|
105
|
-
```
|
|
101
|
+
```text
|
|
106
102
|
~/.atomic/agent/extensions/
|
|
107
103
|
└── my-extension/
|
|
108
104
|
├── package.json # Declares dependencies and entry points
|
|
@@ -113,7 +109,6 @@ Defer background resource startup until `session_start` or the command/tool/even
|
|
|
113
109
|
```
|
|
114
110
|
|
|
115
111
|
```json
|
|
116
|
-
// package.json
|
|
117
112
|
{
|
|
118
113
|
"name": "my-extension",
|
|
119
114
|
"dependencies": {
|
|
@@ -126,25 +121,25 @@ Defer background resource startup until `session_start` or the command/tool/even
|
|
|
126
121
|
}
|
|
127
122
|
```
|
|
128
123
|
|
|
129
|
-
|
|
124
|
+
Use `"atomic"` as the manifest key (legacy `"pi"` is also accepted). Run `npm install` (or your package manager's install command) in the extension directory so imports from `node_modules/` resolve automatically.
|
|
130
125
|
|
|
131
126
|
## State management
|
|
132
127
|
|
|
133
128
|
Choose the store that matches the lifetime you need:
|
|
134
129
|
|
|
135
|
-
- **Tool result `details`.**
|
|
136
|
-
- **`atomic.appendEntry()`.**
|
|
137
|
-
- **`sessionScopedExtensionState()`.**
|
|
130
|
+
- **Tool result `details`.** Rebuilds state across `/branch`, `/tree`, and `/resume` from the conversation transcript.
|
|
131
|
+
- **`atomic.appendEntry()`.** Stores durable custom entries that survive process restarts without entering model context.
|
|
132
|
+
- **`sessionScopedExtensionState()`.** Keeps live in-memory objects alive across `/reload` within the current process (lost on process restart).
|
|
138
133
|
|
|
139
|
-
In Bun single-file builds, an editable file extension whose imported
|
|
134
|
+
In Bun single-file builds, an editable file extension whose imported files have not changed can reuse its evaluated factory and keep module-scoped variables across `/reload`. Editing any file in that import graph re-evaluates its modules and resets those variables.
|
|
140
135
|
|
|
141
|
-
Extensions
|
|
136
|
+
Extensions whose state must follow conversation branches should store a snapshot in tool result `details`:
|
|
142
137
|
|
|
143
138
|
```typescript
|
|
144
139
|
export default function (atomic: ExtensionAPI) {
|
|
145
140
|
let items: string[] = [];
|
|
146
141
|
|
|
147
|
-
// Reconstruct state from
|
|
142
|
+
// Reconstruct state from the active branch
|
|
148
143
|
atomic.on("session_start", async (_event, ctx) => {
|
|
149
144
|
items = [];
|
|
150
145
|
for (const entry of ctx.sessionManager.getBranch()) {
|
|
@@ -159,11 +154,11 @@ export default function (atomic: ExtensionAPI) {
|
|
|
159
154
|
atomic.registerTool({
|
|
160
155
|
name: "my_tool",
|
|
161
156
|
// ...
|
|
162
|
-
async execute(
|
|
157
|
+
async execute(_toolCallId, _params) {
|
|
163
158
|
items.push("new item");
|
|
164
159
|
return {
|
|
165
160
|
content: [{ type: "text", text: "Added" }],
|
|
166
|
-
details: { items: [...items] },
|
|
161
|
+
details: { items: [...items] },
|
|
167
162
|
};
|
|
168
163
|
},
|
|
169
164
|
});
|
|
@@ -172,7 +167,7 @@ export default function (atomic: ExtensionAPI) {
|
|
|
172
167
|
|
|
173
168
|
### Session-scoped in-memory state
|
|
174
169
|
|
|
175
|
-
Import `sessionScopedExtensionState` from `@bastani/atomic` when an extension must keep a live object across `/reload`, such as a registry, abort controller, connection pool, or
|
|
170
|
+
Import `sessionScopedExtensionState` from `@bastani/atomic` when an extension must keep a live object across `/reload`, such as a registry, abort controller, connection pool, or handle that cannot be rebuilt from the transcript:
|
|
176
171
|
|
|
177
172
|
```typescript
|
|
178
173
|
import { sessionScopedExtensionState, type ExtensionAPI } from "@bastani/atomic";
|
|
@@ -182,7 +177,7 @@ interface CounterState {
|
|
|
182
177
|
}
|
|
183
178
|
|
|
184
179
|
export default function (atomic: ExtensionAPI) {
|
|
185
|
-
const state = sessionScopedExtensionState(atomic.events, "my-extension:counter:v1", () => ({
|
|
180
|
+
const state = sessionScopedExtensionState<CounterState>(atomic.events, "my-extension:counter:v1", () => ({
|
|
186
181
|
count: 0,
|
|
187
182
|
}));
|
|
188
183
|
|
|
@@ -196,37 +191,33 @@ export default function (atomic: ExtensionAPI) {
|
|
|
196
191
|
}
|
|
197
192
|
```
|
|
198
193
|
|
|
199
|
-
**Required scope.** Pass the extension's `atomic.events`
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
**
|
|
204
|
-
|
|
205
|
-
**Reload behavior.** `/reload` builds a new `atomic.events` facade that still forwards to the same bus. Calling `sessionScopedExtensionState` again with the same namespaced key returns the existing object without invoking `create`.
|
|
206
|
-
|
|
207
|
-
The reload transaction does not clone this object or roll back mutations made in factory code. Keep factory setup idempotent, and mutate durable state only after the new generation starts when failed reloads must not affect it. Entries live as long as that bus and are not written to the session store; use `atomic.appendEntry()` when data must survive process restart.
|
|
208
|
-
|
|
209
|
-
**Shutdown.** `session_shutdown` still runs for resources you opened. Close sockets, watchers, or timers there; the next `session_start` or first use can recreate them inside the same session-scoped object.
|
|
194
|
+
- **Required scope.** Pass the extension's `atomic.events` object (or the session `EventBus` directly). Every `/reload` of the same session reconnects to the same stored object, while separate sessions stay independent. Do not pass a random object; an unregistered scope will not reconnect after reload.
|
|
195
|
+
- **Session-wide key namespace.** Keys are shared across all extensions in the session. Two extensions passing the same key receive the first extension's object, and the second factory does not run. Prefix every key with a unique extension identifier.
|
|
196
|
+
- **Key versioning.** Append a version suffix and bump it when the stored shape changes (for example `"my-extension:counter:v1"` to `"my-extension:counter:v2"`). The new key ignores older incompatible state.
|
|
197
|
+
- **Reload behavior.** `/reload` creates a new `atomic.events` wrapper backed by the same session bus. Calling `sessionScopedExtensionState()` with the same key returns the existing object without running `create` again. Failed reloads do not undo mutations made to this object during factory setup. Keep factory setup idempotent and avoid mutating shared state until `session_start`. Use `atomic.appendEntry()` when data must survive a full restart.
|
|
198
|
+
- **Shutdown.** `session_shutdown` still runs for resources you opened. Close sockets, watchers, or timers there; the next `session_start` or first use can recreate them inside the same session-scoped object.
|
|
210
199
|
|
|
211
200
|
## Custom tools
|
|
212
201
|
|
|
213
|
-
Register tools the
|
|
202
|
+
Register tools the model can call with `atomic.registerTool()`. Use the `defineTool(tool)` helper from `@bastani/atomic` when storing tool definitions in variables or arrays so TypeScript preserves parameter type inference.
|
|
214
203
|
|
|
215
|
-
|
|
204
|
+
Tool name collisions follow two rules:
|
|
216
205
|
|
|
217
|
-
|
|
206
|
+
- Within a single extension, registering the same tool name twice keeps the last registration and emits a warning.
|
|
207
|
+
- Across multiple extensions, the **first** loaded extension wins. The mandatory bundled `intercom` tool cannot be shadowed.
|
|
218
208
|
|
|
219
|
-
|
|
209
|
+
Prompt metadata options:
|
|
220
210
|
|
|
221
|
-
|
|
211
|
+
- **`promptSnippet`:** Adds a short one-line entry in the `Available tools` section of the default system prompt. If omitted, the tool is left out of that list.
|
|
212
|
+
- **`promptGuidelines`:** Adds tool-specific bullets to the default system prompt `Guidelines` section while the tool is active. Because guidelines are appended flat without grouping, always name the tool explicitly (write `"Use my_tool when..."`, not `"Use this tool when..."`).
|
|
222
213
|
|
|
223
|
-
|
|
214
|
+
Some models include a leading `@` prefix in file path arguments. Built-in tools strip a leading `@` before resolving paths; normalize it in your custom path-taking tools as well.
|
|
224
215
|
|
|
225
|
-
|
|
216
|
+
### Serializing file mutations
|
|
226
217
|
|
|
227
|
-
|
|
218
|
+
If your tool edits files, wrap the full read-modify-write operation in `withFileMutationQueue()` so it shares the same per-file lock as built-in `edit` and `write`. Because tool calls run concurrently by default, unqueued tools can read stale contents and overwrite each other's changes.
|
|
228
219
|
|
|
229
|
-
|
|
220
|
+
Resolve the target path to an absolute path relative to `ctx.cwd` before calling `withFileMutationQueue()`. For existing files, Atomic canonicalizes the path with `realpath()` so symlinks share the same queue; for new files, it uses the resolved absolute path. If your callback throws, the queue releases automatically so waiting mutations can proceed.
|
|
230
221
|
|
|
231
222
|
```typescript
|
|
232
223
|
import { withFileMutationQueue } from "@bastani/atomic";
|
|
@@ -252,25 +243,27 @@ async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
|
|
|
252
243
|
|
|
253
244
|
### Tool definition
|
|
254
245
|
|
|
255
|
-
`parameters` is required, including for no-argument tools (
|
|
246
|
+
`parameters` is required, including for no-argument tools (`Type.Object({})`). Registration rejects missing, null, array, and primitive values before they can break provider requests.
|
|
247
|
+
|
|
248
|
+
If a root schema is an `anyOf` or `oneOf` union, give every branch an explicit `type: "object"` (xAI rejects non-object root branches with `tool parameter root must be an object type`). Prefer a plain `Type.Object` root with optional properties when a union is unnecessary.
|
|
256
249
|
|
|
257
|
-
|
|
250
|
+
Use `StringEnum` from `@bastani/atomic` (also exported from `@bastani/atomic-ai`) for string enums instead of `Type.Union` with `Type.Literal`, which Google's API rejects.
|
|
258
251
|
|
|
259
252
|
```typescript
|
|
260
253
|
import { Type } from "typebox";
|
|
261
|
-
import { StringEnum } from "@bastani/atomic";
|
|
262
|
-
import { Text } from "@bastani/atomic-tui";
|
|
254
|
+
import { defineTool, StringEnum } from "@bastani/atomic";
|
|
263
255
|
|
|
264
|
-
|
|
256
|
+
const myTool = defineTool({
|
|
265
257
|
name: "my_tool",
|
|
266
258
|
label: "My Tool",
|
|
267
|
-
description: "What this tool does (shown to
|
|
259
|
+
description: "What this tool does (shown to the model)",
|
|
268
260
|
promptSnippet: "List or add items in the project todo list",
|
|
269
261
|
promptGuidelines: [
|
|
270
|
-
"Use my_tool for todo planning instead of direct file edits when the user asks for a task list."
|
|
262
|
+
"Use my_tool for todo planning instead of direct file edits when the user asks for a task list.",
|
|
271
263
|
],
|
|
264
|
+
maxResultSizeChars: 40_000, // Per-tool cap for persisted model-visible output (Infinity opts out)
|
|
272
265
|
parameters: Type.Object({
|
|
273
|
-
action: StringEnum(["list", "add"] as const),
|
|
266
|
+
action: StringEnum(["list", "add"] as const),
|
|
274
267
|
text: Type.Optional(Type.String()),
|
|
275
268
|
}),
|
|
276
269
|
prepareArguments(args) {
|
|
@@ -282,50 +275,43 @@ atomic.registerTool({
|
|
|
282
275
|
return args;
|
|
283
276
|
},
|
|
284
277
|
|
|
285
|
-
async execute(
|
|
286
|
-
// Check for cancellation
|
|
278
|
+
async execute(_toolCallId, params, signal, onUpdate) {
|
|
287
279
|
if (signal?.aborted) {
|
|
288
280
|
return { content: [{ type: "text", text: "Cancelled" }] };
|
|
289
281
|
}
|
|
290
282
|
|
|
291
|
-
// Stream progress updates
|
|
292
283
|
onUpdate?.({
|
|
293
284
|
content: [{ type: "text", text: "Working..." }],
|
|
294
285
|
details: { progress: 50 },
|
|
295
286
|
});
|
|
296
287
|
|
|
297
|
-
// Run commands via atomic.exec (captured from extension closure)
|
|
298
288
|
const result = await atomic.exec("some-command", [], { signal });
|
|
299
289
|
|
|
300
|
-
// Return result
|
|
301
290
|
return {
|
|
302
|
-
content: [{ type: "text", text: "Done" }],
|
|
303
|
-
details: { data: result },
|
|
304
|
-
// Optional:
|
|
305
|
-
// in the batch also returns terminate: true.
|
|
291
|
+
content: [{ type: "text", text: "Done" }], // Sent to model
|
|
292
|
+
details: { data: result }, // For rendering and state
|
|
293
|
+
// Optional: end the turn without a follow-up model call when every
|
|
294
|
+
// finalized tool result in the batch also returns terminate: true.
|
|
306
295
|
terminate: true,
|
|
307
296
|
};
|
|
308
297
|
},
|
|
309
298
|
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
renderResult(result, options, theme, context) { ... },
|
|
299
|
+
renderCall(args, theme, context) { /* optional */ },
|
|
300
|
+
renderResult(result, options, theme, context) { /* optional */ },
|
|
313
301
|
});
|
|
314
|
-
```
|
|
315
|
-
|
|
316
|
-
**Signaling errors.** Throw from `execute` to report an execution failure. When a failure also carries useful data, return an error result with `isError: true`, `content`, and optional `structuredContent`.
|
|
317
302
|
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
For a schema-backed decision, use `createStructuredOutputTool({ schema, name })`. Atomic does not register `structured_output` in normal sessions by default. The calling model supplies `instructions`, nonempty named `state`, and optional `model` and `fallbackModels`. The tool resolves those exact IDs through the session model registry, infers a value matching `schema`, and returns that value as terminating JSON rather than treating the calling model's arguments as the result.
|
|
303
|
+
atomic.registerTool(myTool);
|
|
304
|
+
```
|
|
321
305
|
|
|
322
|
-
|
|
306
|
+
Additional `ToolDefinition` fields:
|
|
323
307
|
|
|
324
|
-
|
|
308
|
+
- **`maxResultSizeChars?: number`:** Sets a per-tool character cap for model-visible result persistence. Pass `Infinity` to opt out for self-bounded tools.
|
|
309
|
+
- **`prepareArguments(args)`:** Optional normalizer that runs before schema validation and `execute()`. Keep the public schema clean instead of advertising deprecated fields.
|
|
310
|
+
- **`terminate: true`:** Return on a tool result to skip the automatic follow-up model call when every finalized result in the batch also sets `terminate: true`.
|
|
311
|
+
- **Signaling errors:** Throw an `Error` from `execute()` to report a failure. When a failure also carries structured data, return `{ isError: true, content, structuredContent }`.
|
|
325
312
|
|
|
326
313
|
```typescript
|
|
327
|
-
|
|
328
|
-
async execute(toolCallId, params) {
|
|
314
|
+
async execute(_toolCallId, params) {
|
|
329
315
|
if (!isValid(params.input)) {
|
|
330
316
|
throw new Error(`Invalid input: ${params.input}`);
|
|
331
317
|
}
|
|
@@ -333,11 +319,23 @@ async execute(toolCallId, params) {
|
|
|
333
319
|
}
|
|
334
320
|
```
|
|
335
321
|
|
|
336
|
-
|
|
322
|
+
#### Structured output tool helper
|
|
323
|
+
|
|
324
|
+
For a schema-backed decision, use `createStructuredOutputTool({ schema, name?, capture?, output?, timeoutMs? })`. Atomic does not register `structured_output` in normal sessions by default. Include any custom `name` (such as `"final_decision"`) in explicit tool allowlists.
|
|
325
|
+
|
|
326
|
+
- **`capture`:** Pass `createStructuredOutputCapture()` to inspect `{ called, value }` in memory after the call finishes.
|
|
327
|
+
- **`output`:** Pass `{ outputPath }` to write the validated JSON result to disk with `0o600` file permissions.
|
|
328
|
+
- **`timeoutMs`:** Overrides the default wall-clock deadline (`httpIdleTimeoutMs`) covering every repair attempt, transport retry, and model fallback.
|
|
329
|
+
|
|
330
|
+
When the model calls the tool, it supplies `instructions`, nonempty named `state`, and optional `model` and `fallbackModels`:
|
|
331
|
+
|
|
332
|
+
- Omitting `model` uses the session's configured **`decisionModel`** (via `ctx.getDecisionModel()`, which defaults to the current chat model when unset or `""`), then any explicit `fallbackModels`, and finally the current chat model as the terminal fallback.
|
|
333
|
+
- A registered classifier runs only for a finite Choice schema and is skipped for incompatible schemas.
|
|
334
|
+
- Provider errors (including refusals) advance to the next model. Plain-text responses without a valid structured value are repaired up to three times before advancing. Cancellation stops the call immediately.
|
|
337
335
|
|
|
338
336
|
#### Constrained sampling
|
|
339
337
|
|
|
340
|
-
`ToolDefinition.constrainedSampling` is preserved for extension tools, SDK `customTools`, wrappers, and
|
|
338
|
+
`ToolDefinition.constrainedSampling` is preserved for extension tools, SDK `customTools`, wrappers, and default interactive mode. It accepts `false` or a `ConstrainedSamplingConfig`:
|
|
341
339
|
|
|
342
340
|
```typescript
|
|
343
341
|
atomic.registerTool({
|
|
@@ -352,53 +350,27 @@ atomic.registerTool({
|
|
|
352
350
|
});
|
|
353
351
|
```
|
|
354
352
|
|
|
355
|
-
|
|
353
|
+
Supported values:
|
|
356
354
|
|
|
357
|
-
- `{ type: "json_schema", strict: "prefer" }
|
|
358
|
-
- `{ type: "json_schema", strict: "require" }
|
|
359
|
-
- `{ type: "grammar", variants: { openai_lark?: string, openai_regex?: string } }
|
|
360
|
-
- `false
|
|
355
|
+
- `{ type: "json_schema", strict: "prefer" }`: requests strict provider enforcement and falls back to ordinary tool calling when unavailable.
|
|
356
|
+
- `{ type: "json_schema", strict: "require" }`: fails the request instead of weakening the constraint.
|
|
357
|
+
- `{ type: "grammar", variants: { openai_lark?: string, openai_regex?: string } }`: requests an OpenAI custom grammar tool (Lark wins when both non-empty variants are set).
|
|
358
|
+
- `false`: explicitly opts out while preserving `false` during public tool inspection.
|
|
361
359
|
|
|
362
|
-
If Anthropic rejects a request because strict tools exceed its grammar-size, tool-count, or union-parameter limits, Atomic retries once with `prefer` tools using
|
|
360
|
+
If Anthropic rejects a request because strict tools exceed its grammar-size, tool-count, or union-parameter limits, Atomic retries once with `prefer` tools using ordinary schemas while keeping `require` tools strict (never retried after streaming starts).
|
|
363
361
|
|
|
364
|
-
Built-in `read`, `edit`, `write`, `bash`, and
|
|
362
|
+
Built-in `read`, `edit`, `write`, `bash`, and `powershell` default to `{ type: "json_schema", strict: "prefer" }`. Grammar tools require an object schema with one required string property and apply only when model metadata advertises `supportsOpenAIGrammarTools` (alias `supportsGrammarTools`). See [Custom models](/models/reference#constrained-tool-sampling) and [RPC](/rpc/protocol#get_available_models).
|
|
365
363
|
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
**Argument preparation:** `prepareArguments(args)` is optional. If defined, it runs before schema validation and before `execute()`. Use it only when a custom tool must normalize arguments before validation. Return the object you want validated against `parameters`, keep the public schema strict, and avoid advertising deprecated fields.
|
|
369
|
-
|
|
370
|
-
```typescript
|
|
371
|
-
atomic.registerTool({
|
|
372
|
-
name: "deploy_plan",
|
|
373
|
-
label: "Deploy Plan",
|
|
374
|
-
description: "Create a deployment plan for one target environment",
|
|
375
|
-
parameters: Type.Object({
|
|
376
|
-
environment: Type.String(),
|
|
377
|
-
dryRun: Type.Optional(Type.Boolean()),
|
|
378
|
-
}),
|
|
379
|
-
prepareArguments(args) {
|
|
380
|
-
if (!args || typeof args !== "object") return args;
|
|
381
|
-
const input = args as { env?: unknown; environment?: unknown; dryRun?: unknown };
|
|
382
|
-
if (typeof input.environment === "string") return args;
|
|
383
|
-
if (typeof input.env !== "string") return args;
|
|
384
|
-
return { environment: input.env, dryRun: input.dryRun };
|
|
385
|
-
},
|
|
386
|
-
async execute(toolCallId, params) {
|
|
387
|
-
return {
|
|
388
|
-
content: [{ type: "text", text: `Planning deploy to ${params.environment}` }],
|
|
389
|
-
details: {},
|
|
390
|
-
};
|
|
391
|
-
},
|
|
392
|
-
});
|
|
393
|
-
```
|
|
364
|
+
#### Concurrency, sequential execution, and detachable waits
|
|
394
365
|
|
|
395
|
-
|
|
366
|
+
When one assistant message contains multiple tool calls, Atomic runs them concurrently by default unless configured otherwise:
|
|
396
367
|
|
|
397
|
-
-
|
|
398
|
-
-
|
|
399
|
-
-
|
|
368
|
+
- **`concurrency: "shared"` (default):** May overlap other shared calls, starting only after any earlier `"exclusive"` call finishes.
|
|
369
|
+
- **`concurrency: "exclusive"`:** Waits for every earlier call in the message to finish, and blocks later calls until it completes.
|
|
370
|
+
- **`concurrency: (args) => "shared" | "exclusive"`:** Decides per call. If the function throws, the call runs exclusively.
|
|
371
|
+
- **`executionMode: "sequential" | "parallel"`:** Setting `executionMode: "sequential"` forces every call in the message to execute strictly one at a time in order (see `examples/extensions/tic-tac-toe.ts`).
|
|
400
372
|
|
|
401
|
-
Built-in `edit`, `write`, `todo`, and `ask_user_question` are exclusive, and `bash` is exclusive when
|
|
373
|
+
Built-in `edit`, `write`, `todo`, and `ask_user_question` are exclusive, and `bash` is exclusive when `pty: true`. Other `bash` calls are shared, so declare `"exclusive"` on custom tools that modify state later calls depend on:
|
|
402
374
|
|
|
403
375
|
```typescript
|
|
404
376
|
atomic.registerTool({
|
|
@@ -407,29 +379,31 @@ atomic.registerTool({
|
|
|
407
379
|
description: "Apply one database migration",
|
|
408
380
|
parameters: Type.Object({ name: Type.String(), dryRun: Type.Optional(Type.Boolean()) }),
|
|
409
381
|
concurrency: (args) => (args.dryRun === true ? "shared" : "exclusive"),
|
|
410
|
-
async execute(
|
|
382
|
+
async execute(_toolCallId, params) {
|
|
411
383
|
return { content: [{ type: "text", text: `Applied ${params.name}` }], details: {} };
|
|
412
384
|
},
|
|
413
385
|
});
|
|
414
386
|
```
|
|
415
387
|
|
|
416
|
-
**
|
|
388
|
+
**Detachable long waits:** A tool that only waits on external work (such as a CI job or deployment) can set `detachable: true` or `(args) => boolean`, plus optional `detachmentRequiresReady?: boolean`. When running inside a background subagent that suspends while waiting, a call still running after the delay continues independently, releases the subagent, and wakes it when the result arrives.
|
|
417
389
|
|
|
418
|
-
|
|
390
|
+
Once a call detaches, `onUpdate` progress updates are dropped and `ctx` only answers `cwd`. Because a restarted session can re-run a detached call with the same ID and arguments, mark a tool `detachable` only when re-running it is safe. Built-in `bash` detaches only `{ action: "wait" }` calls without `budgetMs`.
|
|
419
391
|
|
|
420
392
|
### Structured results and nested tools
|
|
421
393
|
|
|
422
|
-
Declare `outputSchema` when a tool returns machine-readable data, and return a matching `structuredContent` alongside model-facing `content`. Script callers receive
|
|
394
|
+
Declare `outputSchema` when a tool returns machine-readable data, and return a matching `structuredContent` alongside model-facing `content`. Script callers receive `structuredContent`; tools without an `outputSchema` return text to scripts. A `tool_result` handler that redacts text must also replace `structuredContent`; replacing only `content` drops `structuredContent` so redacted data cannot leak.
|
|
423
395
|
|
|
424
|
-
Inside `execute`,
|
|
396
|
+
Inside `execute()`, `ctx` is an `ExtensionToolContext`:
|
|
425
397
|
|
|
426
|
-
|
|
398
|
+
- `ctx.tools` lists callable tools allowed by the session.
|
|
399
|
+
- `ctx.executeTool(name, args, { signal, onUpdate })` invokes another tool through the normal argument preparation, validation, permission hooks, and result hooks, returning an `AgentToolCallOutcome`. Nested calls cannot bypass session allowlists, exclusions, or `model-only` exposure.
|
|
400
|
+
- If your orchestrator calls a tool with `concurrency: "exclusive"`, mark the orchestrator `concurrency: "exclusive"` as well. A shared tool cannot upgrade a nested call to exclusive access and receives an error before the target runs.
|
|
427
401
|
|
|
428
|
-
Nested execution events and the nested tool's `ctx` include `parentToolCallId`. Nested calls do not create separate
|
|
402
|
+
Nested execution events and the nested tool's `ctx` include `parentToolCallId`. Nested calls do not create separate transcript messages; the parent reports their outcomes and may attach bounded `nestedCalls` metadata. Report only the parent's own usage because nested usage aggregates automatically.
|
|
429
403
|
|
|
430
404
|
### Tool exposure
|
|
431
405
|
|
|
432
|
-
`ToolDefinition.exposure` controls whether a tool is declared to the model or callable
|
|
406
|
+
`ToolDefinition.exposure` controls whether a tool is declared to the model or callable from another tool. Omitting it defaults to `"direct"`:
|
|
433
407
|
|
|
434
408
|
| Exposure | Model declaration | Callable from another tool |
|
|
435
409
|
| --- | --- | --- |
|
|
@@ -439,76 +413,62 @@ Nested execution events and the nested tool's `ctx` include `parentToolCallId`.
|
|
|
439
413
|
| `deferred` | Only if explicitly activated | When registered and permitted by the session |
|
|
440
414
|
| `hidden` | Never | Never |
|
|
441
415
|
|
|
442
|
-
Use `model-only` for interactive or orchestration tools that should not
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
An active orchestrator may implement `prepareLoadout(loadout)`. The loadout lists `declared`, `callable`, and `registered` tools and provides `getExposure(name)`, `getNamespace(name)`, and `getPromptGuidelines(name)`. Return `descriptions` to replace model-facing descriptions or `hiddenDeclarations` to hide declarations while retaining permitted nested access. This changes presentation, not authorization.
|
|
451
|
-
|
|
452
|
-
### Fireworks deferred tool loading
|
|
453
|
-
|
|
454
|
-
Extensions making requests directly through `@bastani/atomic-ai` can use native deferred tool loading with Fireworks `anthropic-messages` models. Keep the discovery tool in `context.tools`. After the discovery tool result, append a chronological system message with `toolsAdded` (and `toolsRemoved` if needed) containing the newly loaded tool definitions. The provider serializes deferred definitions with `defer_loading` and inserts `tool_reference` content at the load point.
|
|
416
|
+
- Use `model-only` for interactive or orchestration tools that scripts should not invoke freely. You can expose a restricted subset to scripts with `scriptAccess: { description, outputSchema?, refuse(params) }`. `refuse` runs after validation and before permission hooks, returning an error reason string or `undefined` to allow execution. Direct model calls are unaffected.
|
|
417
|
+
- `codemode` tools appear in the codemode tool catalog; `deferred` tools stay discoverable without occupying the inline catalog. Session allowlists and exclusions always take precedence.
|
|
418
|
+
- `direct` and `model-only` tools activate by default. Set `defaultActive: false` to keep a tool inactive until activated with `atomic.setActiveTools()`.
|
|
419
|
+
- `namespace: { name, description, instructions? }` groups related tools and optional namespace-level guidance.
|
|
420
|
+
- Optional `annotations` carry advisory hints (`readOnlyHint`, `destructiveHint`, `idempotentHint`, `openWorldHint`) that do not enforce permissions.
|
|
421
|
+
- Set `writesFiles: true` on tools that modify files so turns calling them record a [worktree snapshot](/worktree-snapshots) like `bash`, `edit`, and `write`.
|
|
422
|
+
- An active orchestrator tool can implement `prepareLoadout(loadout)` to adjust how tools are described or hidden from the model (returning `descriptions` or `hiddenDeclarations`). This changes model presentation only, not authorization.
|
|
455
423
|
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
This is an AI SDK capability. Atomic's `atomic.setActiveTools()` updates the active tool list and records chronological system-message tool deltas for the next request; it does not attach tool names to a tool result. See the [AI SDK deferred tool-loading guide](https://github.com/bastani-inc/atomic/blob/main/packages/ai/README.md#fireworks-deferred-tools) for details.
|
|
424
|
+
**Fireworks deferred tool loading:** Extensions calling `@bastani/atomic-ai` directly can use native deferred tool loading on Fireworks `anthropic-messages` models. See [Libraries: AI](/libraries/ai) and the [AI SDK deferred tool-loading guide](https://github.com/bastani-inc/atomic/blob/main/packages/ai/README.md#fireworks-deferred-tools).
|
|
459
425
|
|
|
460
426
|
### Overriding built-in tools
|
|
461
427
|
|
|
462
|
-
Extensions can override built-in tools (`read`, `bash`, `powershell`, `kill`, `edit`, `write`, `find`, `search`, `ask_user_question`, `todo`) by registering a tool with the same name. Interactive mode displays a warning when
|
|
428
|
+
Extensions can override built-in tools (`read`, `bash`, `powershell`, `kill`, `edit`, `write`, `find`, `search`, `ls`, `ask_user_question`, `todo`) by registering a tool with the same name. Interactive mode displays a warning when a built-in tool is overridden:
|
|
463
429
|
|
|
464
430
|
```bash
|
|
465
431
|
# Extension's read tool replaces built-in read
|
|
466
432
|
atomic -e ./tool-override.ts
|
|
467
433
|
```
|
|
468
434
|
|
|
469
|
-
|
|
435
|
+
Use `--no-builtin-tools` (short flag `-nbt`) to start with no built-in tools while keeping extension tools enabled:
|
|
470
436
|
|
|
471
437
|
```bash
|
|
472
|
-
# No built-in tools, only extension tools
|
|
473
438
|
atomic --no-builtin-tools -e ./my-extension.ts
|
|
474
439
|
```
|
|
475
440
|
|
|
476
|
-
See [examples/extensions/tool-override.ts](https://github.com/bastani-inc/atomic/blob/main/packages/coding-agent/examples/extensions/tool-override.ts) for a complete example
|
|
477
|
-
|
|
478
|
-
**Rendering.** Built-in renderer inheritance is resolved per slot. Execution override and rendering override are independent. If your override omits `renderCall`, the built-in `renderCall` is used. If your override omits `renderResult`, the built-in `renderResult` is used. If your override omits both, the built-in renderer is used automatically for syntax highlighting, diffs, and status framing. This lets you wrap built-in tools for logging or access control without reimplementing the UI.
|
|
479
|
-
|
|
480
|
-
**Prompt metadata.** `promptSnippet` and `promptGuidelines` are not inherited from the built-in tool. If your override should keep those prompt instructions, define them on the override explicitly (or reuse the exported `*ToolSystemPromptContribution` constants from `@bastani/atomic`).
|
|
481
|
-
|
|
482
|
-
**Matching result shapes.** Your implementation must match the built-in tool's `details` shape because the UI and session logic depend on these fields for rendering and state tracking. Import the detail types and tool factories from `@bastani/atomic`:
|
|
441
|
+
See [examples/extensions/tool-override.ts](https://github.com/bastani-inc/atomic/blob/main/packages/coding-agent/examples/extensions/tool-override.ts) for a complete override example.
|
|
483
442
|
|
|
484
|
-
-
|
|
485
|
-
- `
|
|
486
|
-
-
|
|
487
|
-
- `
|
|
488
|
-
- `
|
|
489
|
-
- `
|
|
490
|
-
- `
|
|
491
|
-
- `
|
|
443
|
+
- **Renderer inheritance:** Execution and rendering overrides are independent per slot. If your override omits `renderCall` or `renderResult`, Atomic keeps the built-in renderer for that slot (syntax highlighting, diffs, and framing).
|
|
444
|
+
- **Prompt metadata:** `promptSnippet` and `promptGuidelines` are not inherited from the built-in tool. Set them explicitly or reuse the exported `*ToolSystemPromptContribution` constants from `@bastani/atomic`.
|
|
445
|
+
- **Matching `details` shapes:** Match the built-in tool's `details` type so built-in renderers and session logic work. Import detail types and factories from `@bastani/atomic`:
|
|
446
|
+
- `read`: `ReadToolDetails` (`createReadToolDefinition`)
|
|
447
|
+
- `bash`: `BashToolDetails` (`createBashToolDefinition`)
|
|
448
|
+
- `powershell`: `PowerShellToolDetails` (`createPowerShellToolDefinition`)
|
|
449
|
+
- `edit`: `EditToolDetails` (`createEditToolDefinition`)
|
|
450
|
+
- `find`: `FindToolDetails` (`createFindToolDefinition`)
|
|
451
|
+
- `search`: `SearchToolDetails` (`createSearchToolDefinition`)
|
|
452
|
+
- `ls`: `LsToolDetails` (`createLsToolDefinition`)
|
|
453
|
+
- `write`, `kill`, `ask_user_question`, `todo`: `createWriteToolDefinition`, `createKillToolDefinition`, `createAskUserQuestionToolDefinition`, `createTodoToolDefinition`
|
|
492
454
|
|
|
493
455
|
### Remote execution
|
|
494
456
|
|
|
495
|
-
Built-in tools
|
|
457
|
+
Built-in tools accept pluggable operations objects for SSH, containers, and sandboxes:
|
|
496
458
|
|
|
497
459
|
```typescript
|
|
498
|
-
import { createReadTool,
|
|
460
|
+
import { createReadTool, type ReadOperations } from "@bastani/atomic";
|
|
499
461
|
|
|
500
|
-
// Create tool with custom operations
|
|
501
462
|
const remoteRead = createReadTool(cwd, {
|
|
502
463
|
operations: {
|
|
503
464
|
readFile: (path) => sshExec(remote, `cat ${path}`),
|
|
504
465
|
access: (path) => sshExec(remote, `test -r ${path}`).then(() => {}),
|
|
505
|
-
}
|
|
466
|
+
},
|
|
506
467
|
});
|
|
507
468
|
|
|
508
|
-
// Register, checking flag at execution time
|
|
509
469
|
atomic.registerTool({
|
|
510
470
|
...remoteRead,
|
|
511
|
-
async execute(id, params, signal, onUpdate
|
|
471
|
+
async execute(id, params, signal, onUpdate) {
|
|
512
472
|
const ssh = getSshConfig();
|
|
513
473
|
if (ssh) {
|
|
514
474
|
const tool = createReadTool(cwd, { operations: createRemoteOps(ssh) });
|
|
@@ -519,17 +479,11 @@ atomic.registerTool({
|
|
|
519
479
|
});
|
|
520
480
|
```
|
|
521
481
|
|
|
522
|
-
`ReadOperations`
|
|
523
|
-
|
|
524
|
-
`
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
`GrepOperations` only uses the directory check because search always scans the local filesystem with native search or `rg`. The optional `readFile` callback is deprecated and ignored, including for context lines. Existing integrations can leave it in place, but to search a remote system, override `execute()` instead.
|
|
529
|
-
|
|
530
|
-
For `user_bash`, extensions can reuse Atomic's local shell backend via `createLocalBashOperations()` instead of reimplementing local process spawning, shell resolution, and process-tree termination.
|
|
531
|
-
|
|
532
|
-
The bash tool also supports a spawn hook to adjust the command, cwd, or env before execution:
|
|
482
|
+
- `ReadOperations` can provide `stat` and `listDir` for remote directory reads, and optional `createReadStream` (returning an async iterable of `Uint8Array` chunks, such as a Node `Readable` without encoding) so line ranges of large files stream without reading the whole file into memory. `:conflicts` views and notebooks still read the full file. Archive, SQLite, internal-resource, and notebook helpers stay local.
|
|
483
|
+
- **Operations interfaces:** `ReadOperations`, `WriteOperations`, `EditOperations`, `BashOperations`, `PowerShellOperations`, `LsOperations`, `GrepOperations`, `FindOperations`.
|
|
484
|
+
- `GrepOperations` checks only directories because search scans the local filesystem with native search or `rg`; its optional `readFile` callback is deprecated and ignored. Override `execute()` to search a remote host.
|
|
485
|
+
- For `user_bash` handlers, call `createLocalBashOperations()` to reuse Atomic's local shell spawning and process-tree cleanup.
|
|
486
|
+
- `createBashTool()` supports `spawnHook` to modify `command`, `cwd`, or `env` before launch:
|
|
533
487
|
|
|
534
488
|
```typescript
|
|
535
489
|
import { createBashTool } from "@bastani/atomic";
|
|
@@ -543,43 +497,32 @@ const bashTool = createBashTool(cwd, {
|
|
|
543
497
|
});
|
|
544
498
|
```
|
|
545
499
|
|
|
546
|
-
See [examples/extensions/ssh.ts](https://github.com/bastani-inc/atomic/blob/main/packages/coding-agent/examples/extensions/ssh.ts) for a
|
|
500
|
+
See [examples/extensions/ssh.ts](https://github.com/bastani-inc/atomic/blob/main/packages/coding-agent/examples/extensions/ssh.ts) for a full SSH example.
|
|
547
501
|
|
|
548
502
|
### Output truncation
|
|
549
503
|
|
|
550
|
-
**Tools
|
|
551
|
-
- Context overflow errors (prompt too long)
|
|
552
|
-
- Compaction failures
|
|
553
|
-
- Degraded model performance
|
|
554
|
-
|
|
555
|
-
The built-in limit is **50KB** (~10k tokens) and **2000 lines**, whichever is hit first. Use the exported truncation utilities:
|
|
504
|
+
**Tools must truncate large output** to avoid context overflow errors, compaction failures, and degraded responses. The built-in limit is **50 KB** (~10k tokens) and **2,000 lines**, whichever comes first:
|
|
556
505
|
|
|
557
506
|
```typescript
|
|
558
507
|
import {
|
|
559
|
-
truncateHead, // Keep first N lines/bytes (
|
|
560
|
-
truncateTail, // Keep last N lines/bytes (
|
|
508
|
+
truncateHead, // Keep first N lines/bytes (file reads, search results)
|
|
509
|
+
truncateTail, // Keep last N lines/bytes (logs, command output)
|
|
561
510
|
truncateLine, // Truncate a single line to maxBytes with ellipsis
|
|
562
|
-
formatSize, // Human-readable size (
|
|
511
|
+
formatSize, // Human-readable size ("50KB", "1.5MB")
|
|
563
512
|
DEFAULT_MAX_BYTES, // 50KB
|
|
564
513
|
DEFAULT_MAX_LINES, // 2000
|
|
565
514
|
} from "@bastani/atomic";
|
|
566
515
|
|
|
567
|
-
async execute(
|
|
516
|
+
async execute() {
|
|
568
517
|
const output = await runCommand();
|
|
569
|
-
|
|
570
|
-
// Apply truncation
|
|
571
518
|
const truncation = truncateHead(output, {
|
|
572
519
|
maxLines: DEFAULT_MAX_LINES,
|
|
573
520
|
maxBytes: DEFAULT_MAX_BYTES,
|
|
574
521
|
});
|
|
575
522
|
|
|
576
523
|
let result = truncation.content;
|
|
577
|
-
|
|
578
524
|
if (truncation.truncated) {
|
|
579
|
-
// Write full output to temp file
|
|
580
525
|
const tempFile = writeTempFile(output);
|
|
581
|
-
|
|
582
|
-
// Inform the LLM where to find complete output
|
|
583
526
|
result += `\n\n[Output truncated: ${truncation.outputLines} of ${truncation.totalLines} lines`;
|
|
584
527
|
result += ` (${formatSize(truncation.outputBytes)} of ${formatSize(truncation.totalBytes)}).`;
|
|
585
528
|
result += ` Full output saved to: ${tempFile}]`;
|
|
@@ -589,28 +532,23 @@ async execute(toolCallId, params, signal, onUpdate, ctx) {
|
|
|
589
532
|
}
|
|
590
533
|
```
|
|
591
534
|
|
|
592
|
-
|
|
593
|
-
- Use `truncateHead` for content where the beginning matters (search results, file reads)
|
|
594
|
-
- Use `truncateTail` for content where the end matters (logs, command output)
|
|
595
|
-
- Always inform the LLM when output is truncated and where to find the full version
|
|
596
|
-
- Document the truncation limits in your tool's description
|
|
597
|
-
|
|
598
|
-
See [examples/extensions/truncated-tool.ts](https://github.com/bastani-inc/atomic/blob/main/packages/coding-agent/examples/extensions/truncated-tool.ts) for a complete example wrapping `rg` (ripgrep) with proper truncation.
|
|
535
|
+
Use `truncateHead` when the beginning matters, `truncateTail` when the end matters, inform the model where full output was saved, and document truncation limits in the tool description. See [examples/extensions/truncated-tool.ts](https://github.com/bastani-inc/atomic/blob/main/packages/coding-agent/examples/extensions/truncated-tool.ts).
|
|
599
536
|
|
|
600
537
|
### Multiple tools
|
|
601
538
|
|
|
602
|
-
One extension can register multiple tools
|
|
539
|
+
One extension can register multiple tools sharing one resource and release it on `session_shutdown`:
|
|
603
540
|
|
|
604
541
|
```typescript
|
|
605
542
|
export default function (atomic: ExtensionAPI) {
|
|
606
|
-
let connection = null;
|
|
543
|
+
let connection: DbConnection | null = null;
|
|
607
544
|
|
|
608
|
-
atomic.registerTool({ name: "db_connect", ... });
|
|
609
|
-
atomic.registerTool({ name: "db_query", ... });
|
|
610
|
-
atomic.registerTool({ name: "db_close", ... });
|
|
545
|
+
atomic.registerTool({ name: "db_connect", /* ... */ });
|
|
546
|
+
atomic.registerTool({ name: "db_query", /* ... */ });
|
|
547
|
+
atomic.registerTool({ name: "db_close", /* ... */ });
|
|
611
548
|
|
|
612
549
|
atomic.on("session_shutdown", async () => {
|
|
613
550
|
connection?.close();
|
|
551
|
+
connection = null;
|
|
614
552
|
});
|
|
615
553
|
}
|
|
616
554
|
```
|
|
@@ -619,13 +557,11 @@ export default function (atomic: ExtensionAPI) {
|
|
|
619
557
|
|
|
620
558
|
Tools can provide `renderCall` and `renderResult` for custom display in the interactive transcript and HTML exports. See [TUI components](/tui) for the full component API.
|
|
621
559
|
|
|
622
|
-
To
|
|
560
|
+
To select renderers dynamically for any tool (including MCP tools in resumed sessions before their server connects), register a resolver with `atomic.registerToolRenderer((toolName, next) => renderers)`. Resolvers run in extension load order; `next()` returns the remaining resolvers' choice and then the tool's own renderers, so `next() ?? mine` acts as a fallback. See [`atomic.registerToolRenderer()`](/extensions/api-reference#atomic-registertoolrenderer-resolver).
|
|
623
561
|
|
|
624
|
-
Extension `Image` components render JPEG, GIF, and WebP images on Kitty-protocol terminals automatically
|
|
562
|
+
Extension `Image` components render JPEG, GIF, and WebP images on Kitty-protocol terminals automatically.
|
|
625
563
|
|
|
626
|
-
By default, tool output
|
|
627
|
-
|
|
628
|
-
Set `renderShell: "self"` when the tool should draw its own shell instead of using the default `Box`. This is useful for tools that need complete control over framing or background behavior, for example large previews that must stay visually stable after the tool settles.
|
|
564
|
+
By default, tool output wraps in a `Box` handling padding and background. Each defined `renderCall` or `renderResult` must return a `Component`; an omitted slot falls back to Atomic's default renderer. Set `renderShell: "self"` when the tool draws its own outer framing and background:
|
|
629
565
|
|
|
630
566
|
```typescript
|
|
631
567
|
atomic.registerTool({
|
|
@@ -637,28 +573,27 @@ atomic.registerTool({
|
|
|
637
573
|
async execute() {
|
|
638
574
|
return { content: [{ type: "text", text: "ok" }], details: undefined };
|
|
639
575
|
},
|
|
640
|
-
renderCall(
|
|
576
|
+
renderCall(_args, theme) {
|
|
641
577
|
return new Text(theme.fg("accent", "my custom shell"), 0, 0);
|
|
642
578
|
},
|
|
643
579
|
});
|
|
644
580
|
```
|
|
645
581
|
|
|
646
|
-
`renderCall` and `renderResult`
|
|
647
|
-
|
|
648
|
-
- `args`. The current tool call arguments.
|
|
649
|
-
- `state`. Shared row-local state across `renderCall` and `renderResult`.
|
|
650
|
-
- `lastComponent`. The previously returned component for that slot, if any.
|
|
651
|
-
- `invalidate()`. Request a rerender of this tool row.
|
|
652
|
-
- `toolCallId`, `cwd`, `executionStarted`, `argsComplete`, `isPartial`, `expanded`, `showImages`, `isError`.
|
|
653
|
-
- `durationMs`. Recorded execution time of the final result; `undefined` while running, when the tool did not run, or for older saved results.
|
|
654
|
-
- `outputPad`. Configured horizontal padding; renderers with `renderShell: "self"` apply it themselves.
|
|
655
|
-
- `keyText()`, `keyHint()`. Format the user's configured keybindings; see [Keybinding hints](#keybinding-hints).
|
|
582
|
+
`renderCall` and `renderResult` receive a `ToolRenderContext` object with:
|
|
656
583
|
|
|
657
|
-
|
|
584
|
+
- `args`: current tool call arguments
|
|
585
|
+
- `state`: shared row-local state across `renderCall` and `renderResult`
|
|
586
|
+
- `lastComponent`: previously returned component for that slot, if any
|
|
587
|
+
- `invalidate()`: request a rerender of this tool row
|
|
588
|
+
- `toolCallId`, `cwd`, `executionStarted`, `argsComplete`, `isPartial`, `expanded`, `showImages`, `isError`
|
|
589
|
+
- `durationMs`: recorded execution time of the final result (`undefined` while running, when skipped, or on older saved results)
|
|
590
|
+
- `outputPad`: configured horizontal padding (apply it yourself when `renderShell: "self"`)
|
|
591
|
+
- `keyText()`, `keyHint()`: format the user's configured keybindings (see [Keybinding hints](#keybinding-hints))
|
|
592
|
+
- Optional helpers `getTaskRecord?()`, `getElapsedMs?()`, and `getToolDefinition?()` when exposed by the host
|
|
658
593
|
|
|
659
594
|
#### renderCall
|
|
660
595
|
|
|
661
|
-
Renders the tool call
|
|
596
|
+
Renders the tool call header:
|
|
662
597
|
|
|
663
598
|
```typescript
|
|
664
599
|
import { Text } from "@bastani/atomic-tui";
|
|
@@ -677,10 +612,10 @@ renderCall(args, theme, context) {
|
|
|
677
612
|
|
|
678
613
|
#### renderResult
|
|
679
614
|
|
|
680
|
-
Renders the tool
|
|
615
|
+
Renders the tool output:
|
|
681
616
|
|
|
682
617
|
```typescript
|
|
683
|
-
renderResult(result, { expanded, isPartial }, theme
|
|
618
|
+
renderResult(result, { expanded, isPartial }, theme) {
|
|
684
619
|
if (isPartial) {
|
|
685
620
|
return new Text(theme.fg("warning", "Processing..."), 0, 0);
|
|
686
621
|
}
|
|
@@ -699,11 +634,11 @@ renderResult(result, { expanded, isPartial }, theme, context) {
|
|
|
699
634
|
}
|
|
700
635
|
```
|
|
701
636
|
|
|
702
|
-
|
|
637
|
+
Return an empty `Container` when a slot intentionally displays nothing.
|
|
703
638
|
|
|
704
639
|
#### Keybinding hints
|
|
705
640
|
|
|
706
|
-
Use `keyHint()` and `keyText()`
|
|
641
|
+
Use `context.keyHint()` and `context.keyText()` (or `options.keyHint()` and `options.keyText()` in message and entry renderers) so hints match the user's `keybindings.json`. Test `keyText()` for an empty string before adding punctuation when a keybinding may be unbound:
|
|
707
642
|
|
|
708
643
|
```typescript
|
|
709
644
|
renderResult(result, { expanded }, theme, context) {
|
|
@@ -715,47 +650,29 @@ renderResult(result, { expanded }, theme, context) {
|
|
|
715
650
|
}
|
|
716
651
|
```
|
|
717
652
|
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
- `keyHint(keybinding, description)`. Formats a configured keybinding id such as `"app.tools.expand"` or `"tui.select.confirm"`, followed by the description.
|
|
721
|
-
- `keyText(keybinding)`. Returns the raw configured key text for a keybinding id, or `""` if the id has no keys.
|
|
722
|
-
|
|
723
|
-
In renderers, use these context methods instead of importing `keyHint()`, `keyHintIfBound()`, or `keyText()` from `@bastani/atomic`. An extension can resolve its own copy of the package (for example from its own `node_modules`), and that copy does not see Atomic's configured keybindings, so `app.*` ids format as `""`. `rawKeyHint(key, description)` formats a literal key string and is safe to import.
|
|
724
|
-
|
|
725
|
-
In fullscreen mode, clicking a hint from `keyHint()` or `rawKeyHint()` presses the key it names. A hint for `app.tools.expand` drawn inside a block that a click expands (such as your tool's result or message) is the exception: clicking it toggles that block alone, as clicking anywhere else on the block does. The hint carries zero-width marks that the renderer strips before writing to the terminal; use `keyText()` for key names in plain text such as notifications or log lines.
|
|
726
|
-
|
|
727
|
-
To make a plain-text hint clickable, pass it through `clickableHintText()` from `@bastani/atomic-tui`, for example `clickableHintText("↑↓ select · enter choose · esc cancel")`. Named or modified keys can be separated from their label by a tab or Unicode space; for bare keys with that spacing, use `clickableKeysHint([{ text: "a", key: "a" }], "\u00a0accept")`.
|
|
728
|
-
|
|
729
|
-
In `clickableHintText("esc / a destination")`, the slash and its label run `/`. Pass `["a"]` as the second argument if `a` is another key instead (`clickableHintText("1/2 / esc pick", ["1", "2"])` marks all three keys, while a plain ratio like `1 / 2` stays text).
|
|
730
|
-
|
|
731
|
-
Use namespaced keybinding ids:
|
|
653
|
+
Do not import `keyHint()`, `keyHintIfBound()`, or `keyText()` from `@bastani/atomic` inside renderers; use the injected context methods so they read Atomic's active keybinding config. `rawKeyHint(key, description)` formats a literal key string and is safe to import.
|
|
732
654
|
|
|
733
|
-
|
|
734
|
-
- Shared TUI ids use the `tui.*` namespace, for example `tui.select.confirm`, `tui.select.cancel`, `tui.input.tab`.
|
|
655
|
+
In fullscreen mode, clicking a hint from `keyHint()` or `rawKeyHint()` sends the named key (except `app.tools.expand` inside an expandable block, which toggles that block alone). Hints embed zero-width markers that the renderer strips before writing to the terminal; use `keyText()` for plain text such as notifications or logs.
|
|
735
656
|
|
|
736
|
-
|
|
657
|
+
To make a plain-text hint clickable, pass it through `clickableHintText()` from `@bastani/atomic-tui` (for example `clickableHintText("↑↓ select · enter choose · esc cancel")`), or use `clickableKeysHint([{ text: "a", key: "a" }], "\u00a0accept")` for bare keys. When a label contains `/`, pass extra bare keys in the second argument (for example `clickableHintText("1/2 / esc pick", ["1", "2"])`).
|
|
737
658
|
|
|
738
|
-
Custom editors and `ctx.ui.custom()` components receive `keybindings: KeybindingsManager` as an
|
|
659
|
+
Use namespaced keybinding IDs (`app.*` for coding-agent actions and `tui.*` for shared TUI actions; see [Keybindings](/keybindings)). Custom editors and `ctx.ui.custom()` components receive `keybindings: KeybindingsManager` as an argument; use it directly instead of calling `getKeybindings()` or `setKeybindings()`.
|
|
739
660
|
|
|
740
661
|
#### Best practices
|
|
741
662
|
|
|
742
|
-
- Use `Text` with padding `(0, 0)` because the default `Box`
|
|
743
|
-
-
|
|
744
|
-
-
|
|
745
|
-
-
|
|
746
|
-
-
|
|
747
|
-
- Read `context.args` in `renderResult` instead of copying args into `context.state`.
|
|
748
|
-
- Use `context.state` only for data that must be shared across call and result slots.
|
|
749
|
-
- Reuse `context.lastComponent` when the same component instance can be updated in place.
|
|
750
|
-
- Use `renderShell: "self"` only when the default boxed shell gets in the way. In self-shell mode the tool is responsible for its own framing, padding, and background.
|
|
663
|
+
- Use `Text` with padding `(0, 0)` because the default `Box` adds padding.
|
|
664
|
+
- Handle `isPartial` for streaming progress and `expanded` for details on demand (`Ctrl+O` toggles all blocks; clicking toggles one block).
|
|
665
|
+
- Read `context.args` in `renderResult` instead of copying arguments into `context.state`.
|
|
666
|
+
- Reuse `context.lastComponent` when updating the same component across renders.
|
|
667
|
+
- Use `renderShell: "self"` only when you need custom outer framing, padding, and background.
|
|
751
668
|
|
|
752
669
|
#### Fallback
|
|
753
670
|
|
|
754
|
-
If a slot renderer is
|
|
671
|
+
If a slot renderer is omitted or throws:
|
|
755
672
|
|
|
756
673
|
- `renderCall`: shows the tool name
|
|
757
674
|
- `renderResult`: shows raw text from `content`
|
|
758
675
|
|
|
759
676
|
## Next steps
|
|
760
677
|
|
|
761
|
-
Continue with [
|
|
678
|
+
Continue with [Extension events](/extensions/events) to hook into the session lifecycle, or look up context properties and registration methods in the [Extension API reference](/extensions/api-reference).
|