@bastani/atomic 0.10.9-alpha.1 → 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 +69 -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
package/docs/keybindings.md
CHANGED
|
@@ -1,34 +1,57 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: "Keybindings"
|
|
3
|
-
|
|
3
|
+
sidebarTitle: "Keybindings"
|
|
4
|
+
description: "Default keyboard shortcuts and custom ~/.atomic/agent/keybindings.json configuration rules."
|
|
4
5
|
---
|
|
5
6
|
|
|
6
|
-
|
|
7
|
+
Customize keyboard shortcuts in `~/.atomic/agent/keybindings.json`. Run `/reload` after editing the file to apply changes without restarting. Add `"$schema": "https://raw.githubusercontent.com/bastani-inc/atomic/main/packages/coding-agent/schemas/keybindings.schema.json"` for editor completion and validation (Atomic ignores `$schema` at load time).
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
## Key format
|
|
9
10
|
|
|
10
|
-
|
|
11
|
+
Write keys as `modifier+key` using any combination of `ctrl`, `shift`, `alt`, and `super`:
|
|
11
12
|
|
|
12
|
-
|
|
13
|
+
- **Letters:** `a` to `z`
|
|
14
|
+
- **Digits:** `0` to `9`
|
|
15
|
+
- **Special:** `escape`, `esc`, `enter`, `return`, `tab`, `space`, `backspace`, `delete`, `insert`, `clear`, `home`, `end`, `pageUp`, `pageDown`, `up`, `down`, `left`, `right`
|
|
16
|
+
- **Function:** `f1` to `f12`
|
|
17
|
+
- **Symbols:** `` ` ``, `-`, `=`, `[`, `]`, `\`, `;`, `'`, `,`, `.`, `/`, `!`, `@`, `#`, `$`, `%`, `^`, `&`, `*`, `(`, `)`, `_`, `+`, `|`, `~`, `{`, `}`, `:`, `<`, `>`, `?`
|
|
13
18
|
|
|
14
|
-
|
|
19
|
+
Examples: `ctrl+shift+x`, `alt+ctrl+x`, `ctrl+shift+alt+x`, `ctrl+super+x`, `ctrl+1`, `ctrl++`. Support for `super` depends on your terminal.
|
|
15
20
|
|
|
16
|
-
|
|
21
|
+
**Key syntax rules:**
|
|
22
|
+
|
|
23
|
+
- Key names and modifiers are **case-insensitive** (`pageUp` and `pageup`, `CTRL+P` and `ctrl+p` are equivalent).
|
|
24
|
+
- Modifier order does not matter (`ctrl+shift+p` and `shift+ctrl+p` are equivalent), but duplicate modifiers (such as `ctrl+ctrl+x`) are invalid and never match.
|
|
25
|
+
- **`escape` and `esc` never match with any modifier.** Bind plain `escape` or `esc` only.
|
|
26
|
+
- Binding `+` with modifiers works (`ctrl++`, `alt++`).
|
|
27
|
+
|
|
28
|
+
## Custom configuration
|
|
29
|
+
|
|
30
|
+
Create `~/.atomic/agent/keybindings.json`:
|
|
31
|
+
|
|
32
|
+
```json
|
|
33
|
+
{
|
|
34
|
+
"$schema": "https://raw.githubusercontent.com/bastani-inc/atomic/main/packages/coding-agent/schemas/keybindings.schema.json",
|
|
35
|
+
"tui.editor.historyPrevious": "ctrl+p",
|
|
36
|
+
"tui.editor.historyNext": "ctrl+n",
|
|
37
|
+
"tui.editor.deleteWordBackward": ["ctrl+w", "alt+backspace"],
|
|
38
|
+
"app.model.cycleForward": []
|
|
39
|
+
}
|
|
40
|
+
```
|
|
17
41
|
|
|
18
|
-
|
|
19
|
-
- **Digits.** `0` to `9`
|
|
20
|
-
- **Special.** `escape`, `esc`, `enter`, `return`, `tab`, `space`, `backspace`, `delete`, `insert`, `clear`, `home`, `end`, `pageUp`, `pageDown`, `up`, `down`, `left`, `right`
|
|
21
|
-
- **Function.** `f1` to `f12`
|
|
22
|
-
- **Symbols.** `` ` ``, `-`, `=`, `[`, `]`, `\`, `;`, `'`, `,`, `.`, `/`, `!`, `@`, `#`, `$`, `%`, `^`, `&`, `*`, `(`, `)`, `_`, `+`, `|`, `~`, `{`, `}`, `:`, `<`, `>`, `?`
|
|
42
|
+
**Configuration rules:**
|
|
23
43
|
|
|
24
|
-
|
|
44
|
+
- **Replacement semantics:** Setting an action in `keybindings.json` **completely replaces** its default keys rather than appending to them. Pass an array to keep defaults alongside a new key, or pass `[]` to unbind the action.
|
|
45
|
+
- **Invalid config fallback:** Malformed JSON or a non-object top-level value is silently ignored and all defaults apply with no warning. Unknown action IDs, entries whose value is not a string or string array, and unrecognized key strings are also silently ignored.
|
|
46
|
+
- **Legacy migration:** If your file contains older pre-namespaced action names (such as `cursorUp`, `expandTools`, `app.tasks.inspect`, or `app.tasks.cancel`), Atomic migrates them automatically on startup and **rewrites `~/.atomic/agent/keybindings.json` in place** (sorting known keys and dropping any legacy key whose current namespaced equivalent is already present).
|
|
47
|
+
- **Windows and WSL defaults:** WSL defaults apply on Linux whenever `WSL_DISTRO_NAME` or `WSL_INTEROP` is set. On native Windows, `app.suspend` defaults to `alt+z` and opens an interactive PowerShell subshell (leaving `ctrl+z` for editor undo; type `exit` to return while background tasks keep running). On WSL, standard Linux `ctrl+z`/`fg` suspension applies and `tui.editor.undo` defaults to `alt+z`. See [Windows](/windows).
|
|
25
48
|
|
|
26
49
|
## All actions
|
|
27
50
|
|
|
28
51
|
### TUI editor cursor movement
|
|
29
52
|
|
|
30
53
|
| Keybinding id | Default | Description |
|
|
31
|
-
|
|
54
|
+
| --- | --- | --- |
|
|
32
55
|
| `tui.editor.cursorUp` | `up` | Move cursor up |
|
|
33
56
|
| `tui.editor.cursorDown` | `down` | Move cursor down |
|
|
34
57
|
| `tui.editor.cursorLeft` | `left`, `ctrl+b` | Move cursor left |
|
|
@@ -49,7 +72,7 @@ Dedicated history actions switch prompt history entries regardless of cursor lin
|
|
|
49
72
|
### TUI editor deletion
|
|
50
73
|
|
|
51
74
|
| Keybinding id | Default | Description |
|
|
52
|
-
|
|
75
|
+
| --- | --- | --- |
|
|
53
76
|
| `tui.editor.deleteCharBackward` | `backspace` | Delete character backward |
|
|
54
77
|
| `tui.editor.deleteCharForward` | `delete`, `ctrl+d` | Delete character forward |
|
|
55
78
|
| `tui.editor.deleteWordBackward` | `ctrl+w`, `alt+backspace` | Delete word backward |
|
|
@@ -60,7 +83,7 @@ Dedicated history actions switch prompt history entries regardless of cursor lin
|
|
|
60
83
|
### TUI input
|
|
61
84
|
|
|
62
85
|
| Keybinding id | Default | Description |
|
|
63
|
-
|
|
86
|
+
| --- | --- | --- |
|
|
64
87
|
| `tui.input.newLine` | `shift+enter`, `ctrl+j` | Insert new line |
|
|
65
88
|
| `tui.input.submit` | `enter` | Submit input |
|
|
66
89
|
| `tui.input.tab` | `tab` | Tab / autocomplete |
|
|
@@ -68,7 +91,7 @@ Dedicated history actions switch prompt history entries regardless of cursor lin
|
|
|
68
91
|
### TUI kill ring
|
|
69
92
|
|
|
70
93
|
| Keybinding id | Default | Description |
|
|
71
|
-
|
|
94
|
+
| --- | --- | --- |
|
|
72
95
|
| `tui.editor.yank` | `ctrl+y` | Paste most recently deleted text |
|
|
73
96
|
| `tui.editor.yankPop` | `alt+y` | Cycle through deleted text after yank |
|
|
74
97
|
| `tui.editor.undo` | `ctrl+-` (`ctrl+z` on native Windows, `alt+z` on WSL) | Undo last edit |
|
|
@@ -76,7 +99,7 @@ Dedicated history actions switch prompt history entries regardless of cursor lin
|
|
|
76
99
|
### TUI clipboard and selection
|
|
77
100
|
|
|
78
101
|
| Keybinding id | Default | Description |
|
|
79
|
-
|
|
102
|
+
| --- | --- | --- |
|
|
80
103
|
| `tui.input.copy` | `ctrl+c` | Copy selection |
|
|
81
104
|
| `tui.select.up` | `up` | Move selection up |
|
|
82
105
|
| `tui.select.down` | `down` | Move selection down |
|
|
@@ -87,9 +110,11 @@ Dedicated history actions switch prompt history entries regardless of cursor lin
|
|
|
87
110
|
|
|
88
111
|
Local copy requires a working clipboard utility (`wl-clipboard` on Wayland, `xclip` or `xsel` on X11, or Termux:API on Termux). Atomic forwards copies through OSC 52 over SSH, Mosh, and Rex and as a headless Linux fallback; set `ATOMIC_CLIPBOARD_OSC52=1` (legacy `PI_CLIPBOARD_OSC52=1`) to force OSC 52 after local copy. See [Terminal setup](/terminal-setup) for terminal clipboard and mouse configuration.
|
|
89
112
|
|
|
90
|
-
|
|
113
|
+
<div id="tui-fullscreen-viewport" />
|
|
91
114
|
|
|
92
|
-
|
|
115
|
+
### Transcript scrolling and mouse
|
|
116
|
+
|
|
117
|
+
Interactive sessions run in fullscreen with a scrollable transcript above the docked input box. `app.tools.expand` (`Ctrl+O` by default) expands or collapses all tool and summary blocks in the displayed transcript.
|
|
93
118
|
|
|
94
119
|
**Clicking blocks:**
|
|
95
120
|
|
|
@@ -109,10 +134,10 @@ Interactive sessions run in fullscreen with a scrollable transcript above the do
|
|
|
109
134
|
- When scrolled up, a centered `↓ jump to bottom · ctrl+end` pill appears above the editor (counting new messages as they arrive) and the current turn's opening prompt stays pinned at the top. Viewed subagent transcripts and `/tasks` shell views scroll independently without moving `main`.
|
|
110
135
|
- Drag to select characters, double-click for a word or path, and triple-click for a line. Selection copies automatically unless `fullscreenCopyOnSelect` is `false`. On Windows, pressing the secondary mouse button pastes clipboard text into the focused component. See [Terminal setup](/terminal-setup) for mouse and trackpad behavior.
|
|
111
136
|
|
|
112
|
-
While the main editor has focus, `home` and `end` stay with the editor, `ctrl+home` and `ctrl+end` jump to the transcript top and bottom, `pageUp` and `pageDown` scroll the transcript, and `ctrl+pageUp` and `ctrl+pageDown` scroll the editor. Focused overlays and scrollable lists (autocomplete, `/settings`, `/model`) capture scrolling actions first.
|
|
137
|
+
**Editor vs. transcript scrolling:** While the main editor has focus, `home` and `end` stay with the editor, `ctrl+home` and `ctrl+end` jump to the transcript top and bottom, `pageUp` and `pageDown` scroll the transcript, and `ctrl+pageUp` and `ctrl+pageDown` scroll the editor. Focused overlays and scrollable lists (autocomplete, `/settings`, `/model`) capture scrolling actions first.
|
|
113
138
|
|
|
114
139
|
| Key | Editor action | Fullscreen action |
|
|
115
|
-
|
|
140
|
+
| --- | --- | --- |
|
|
116
141
|
| `home`, `end` | Editor | Editor |
|
|
117
142
|
| `ctrl+home`, `ctrl+end` | *(none)* | Transcript |
|
|
118
143
|
| `pageUp`, `pageDown` | Editor | Transcript |
|
|
@@ -120,10 +145,10 @@ While the main editor has focus, `home` and `end` stay with the editor, `ctrl+ho
|
|
|
120
145
|
|
|
121
146
|
Rebind these like any other action: for example `"tui.altScreen.pageUp": "ctrl+pageUp"` keeps `pageUp` in the editor and moves transcript paging to `ctrl+pageUp`, and `[]` unbinds a shortcut. Focused custom components may consume viewport keys first; see the [input handling contract](/extensions/ui#custom-components).
|
|
122
147
|
|
|
123
|
-
Transcript scroll keys also work while the bottom-pinned `ask_user_question` dialog or Notes is open. Inside `ask_user_question`, use `↑`/`↓` to move between options, `Enter` to pick (`Enter` or `Space` to toggle multi-select boxes), type on **Type something.** for a custom answer, `n` to add a note, `Tab` or `←`/`→` to switch questions, and `Esc` to cancel.
|
|
148
|
+
**`ask_user_question` controls:** Transcript scroll keys also work while the bottom-pinned `ask_user_question` dialog or Notes is open. Inside `ask_user_question`, use `↑`/`↓` to move between options, `Enter` to pick (`Enter` or `Space` to toggle multi-select boxes), type on **Type something.** for a custom answer, `n` to add a note, `Tab` or `←`/`→` to switch questions, and `Esc` to cancel.
|
|
124
149
|
|
|
125
150
|
| Keybinding id | Default | Description |
|
|
126
|
-
|
|
151
|
+
| --- | --- | --- |
|
|
127
152
|
| `tui.altScreen.pageUp` | `pageUp` | Scroll the transcript up by one page |
|
|
128
153
|
| `tui.altScreen.pageDown` | `pageDown` | Scroll the transcript down by one page |
|
|
129
154
|
| `tui.altScreen.halfPageUp` | *(none)* | Scroll the transcript up by half a page |
|
|
@@ -140,12 +165,12 @@ Atomic does not ship a find-in-transcript shortcut. The four `tui.altScreen.sear
|
|
|
140
165
|
### Application
|
|
141
166
|
|
|
142
167
|
| Keybinding id | Default | Description |
|
|
143
|
-
|
|
168
|
+
| --- | --- | --- |
|
|
144
169
|
| `app.interrupt` | `escape` | Abort active or queued work and restore queued messages to the editor (pauses a viewed subagent without switching to `main`) |
|
|
145
|
-
| `app.clear` | `ctrl+c` | Clear editor text, interrupt work, recover an unresponsive
|
|
170
|
+
| `app.clear` | `ctrl+c` | Clear editor text, interrupt work, recover an unresponsive session, or press twice within 0.8 s on an empty idle prompt to exit (while viewing a subagent, pauses it instead of exiting) |
|
|
146
171
|
| `app.exit` | `ctrl+d` | Exit when the editor is empty |
|
|
147
172
|
| `app.suspend` | `ctrl+z` (`alt+z` on native Windows) | Suspend to background on POSIX and WSL; open a PowerShell subshell on native Windows |
|
|
148
|
-
| `app.editor.external` | `ctrl+g` | Open in external editor (`externalEditor`, `$VISUAL`, or `$EDITOR`) |
|
|
173
|
+
| `app.editor.external` | `ctrl+g` | Open in external editor (`externalEditor`, `$VISUAL`, or `$EDITOR`, falling back to `notepad` on Windows or `nano` on macOS and Linux) |
|
|
149
174
|
| `app.history.search` | `ctrl+r` | Search the viewed agent's past prompts and place the chosen one in the editor without sending |
|
|
150
175
|
| `app.clipboard.pasteImage` | `ctrl+v` (`alt+v`, `ctrl+v` on Windows and WSL) | Paste files on macOS, images, or text from clipboard |
|
|
151
176
|
|
|
@@ -157,12 +182,12 @@ Atomic does not ship a find-in-transcript shortcut. The four `tui.altScreen.sear
|
|
|
157
182
|
**`Ctrl+C`, `Esc`, and `Ctrl+X` routing:**
|
|
158
183
|
|
|
159
184
|
- `Ctrl+X` does not copy text; paired with `Ctrl+K` it stops all background work ([Navigation](#navigation)), on OAuth sign-in screens it copies the sign-in URL (`app.auth.copyUrl`), and in `/scoped-models` it clears selections. Use `/copy` to copy the viewed agent's last assistant message.
|
|
160
|
-
- Physical `Esc` always requests cooperative cancellation without
|
|
185
|
+
- Physical `Esc` always requests cooperative cancellation without restarting the session. Physical `Ctrl+C` closes stuck custom dialogs (dialogs that handle `Ctrl+C` receive the first press and close on the second) and restarts an unresponsive background session process, even if you remap `app.clear`. See [Message queue](/usage#message-queue) for full interrupt and recovery rules.
|
|
161
186
|
|
|
162
187
|
### Sessions
|
|
163
188
|
|
|
164
189
|
| Keybinding id | Default | Description |
|
|
165
|
-
|
|
190
|
+
| --- | --- | --- |
|
|
166
191
|
| `app.session.new` | *(none)* | Start a new session (`/new`) |
|
|
167
192
|
| `app.session.tree` | *(none)* | Open session tree navigator (`/tree`) |
|
|
168
193
|
| `app.session.fork` | *(none)* | Fork current session (`/fork`) |
|
|
@@ -179,7 +204,7 @@ While viewing a subagent, `app.session.new`, `app.session.tree`, and `app.sessio
|
|
|
179
204
|
### Models and thinking
|
|
180
205
|
|
|
181
206
|
| Keybinding id | Default | Description |
|
|
182
|
-
|
|
207
|
+
| --- | --- | --- |
|
|
183
208
|
| `app.model.select` | `ctrl+l` | Open model selector |
|
|
184
209
|
| `app.model.cycleForward` | `ctrl+p` | Cycle to next model |
|
|
185
210
|
| `app.model.cycleBackward` | `shift+ctrl+p` (`alt+p` on Windows and WSL) | Cycle to previous model |
|
|
@@ -191,7 +216,7 @@ Interactive model and thinking choices save automatically as startup defaults; t
|
|
|
191
216
|
### Display and message queue
|
|
192
217
|
|
|
193
218
|
| Keybinding id | Default | Description |
|
|
194
|
-
|
|
219
|
+
| --- | --- | --- |
|
|
195
220
|
| `app.tools.expand` | `ctrl+o` | Collapse or expand tool detail in the viewed transcript (main chat or subagent) |
|
|
196
221
|
| `app.auth.copyUrl` | `ctrl+x` | Copy the URL on an OAuth sign-in screen |
|
|
197
222
|
| `app.message.followUp` | `alt+enter` (`ctrl+q` on Windows and WSL) | Queue follow-up message |
|
|
@@ -204,7 +229,7 @@ Message queue shortcuts work identically on `main` and while viewing a subagent.
|
|
|
204
229
|
Atomic shares one chat screen across `main` and its subagents, with the [agent panel](/background-tasks#the-agent-panel) below the prompt and `/tasks` for full task inspection. Press `↓` on an empty prompt to focus the agent panel, `←` on an empty prompt while viewing a subagent to return to `main`, `Ctrl+X` then `Ctrl+K` (twice within 3 seconds) to stop all background work, and `?` on an empty prompt or list to show active keys. See [Background tasks](/background-tasks) for full navigation and stop workflows.
|
|
205
230
|
|
|
206
231
|
| Keybinding id | Default | Description |
|
|
207
|
-
|
|
232
|
+
| --- | --- | --- |
|
|
208
233
|
| `app.nav.back` | `left` | Go back one level in `/tasks`, shell output, or the focused panel, and from a viewed subagent's empty prompt to `main`. `Esc` and `Ctrl+C` never act as this key |
|
|
209
234
|
| `app.list.open` | `enter`, `right` | Switch to the selected subagent (or `main`), or open the selected shell output |
|
|
210
235
|
| `app.list.stop` | `x` | Stop the selected item (press again to confirm); dismiss a finished one |
|
|
@@ -214,18 +239,18 @@ Atomic shares one chat screen across `main` and its subagents, with the [agent p
|
|
|
214
239
|
| `app.agents.focus` | `down` | Focus the agent panel from an empty prompt |
|
|
215
240
|
| `app.agents.chord` | `ctrl+x` | Start a background-work chord in the main chat |
|
|
216
241
|
| `app.agents.stopAll` | `ctrl+k` | After the chord key: stop all background subagents and shells (press twice to confirm) |
|
|
217
|
-
| `app.tasks.open` |
|
|
218
|
-
| `app.tasks.input` |
|
|
242
|
+
| `app.tasks.open` | *(none)* | Command-only `/tasks` route |
|
|
243
|
+
| `app.tasks.input` | *(none)* | Focus stdin only when the selected task has writable input |
|
|
219
244
|
| `app.tasks.openWaited` | `alt+w` | Open the output of the shell a waiting subagent waits on, while viewing that subagent or from its `/tasks` row |
|
|
220
245
|
|
|
221
246
|
On macOS, `Alt+W` requires your terminal to send Option as Meta (enable **Use Option as Meta key** in Terminal.app, set Option to **Esc+** in iTerm2, set `macos-option-as-alt` in Ghostty, or set `macos_option_as_alt both` in kitty). Otherwise remap `app.tasks.openWaited`. Avoid binding `alt+w` to another editor action because `app.tasks.openWaited` takes priority while viewing a waiting subagent or its `/tasks` row.
|
|
222
247
|
|
|
223
|
-
|
|
248
|
+
Open question prompts and the main input box keep keyboard priority; `Esc` leaves stdin or task detail before leaving task focus, and unbound actions show no key hint.
|
|
224
249
|
|
|
225
250
|
### Tree navigation
|
|
226
251
|
|
|
227
252
|
| Keybinding id | Default | Description |
|
|
228
|
-
|
|
253
|
+
| --- | --- | --- |
|
|
229
254
|
| `app.tree.foldOrUp` | `ctrl+left`, `alt+left` | Fold current branch segment, or jump to the previous segment start |
|
|
230
255
|
| `app.tree.unfoldOrDown` | `ctrl+right`, `alt+right` | Unfold current branch segment, or jump to the next segment start or branch end |
|
|
231
256
|
| `app.tree.editLabel` | `shift+l` | Edit the label on the selected tree node |
|
|
@@ -243,26 +268,14 @@ Older configs using `app.tasks.inspect` and `app.tasks.cancel` migrate automatic
|
|
|
243
268
|
Used inside `/scoped-models`. `Enter` toggles the selected model, typing filters by model or provider name, and `Esc` or `Ctrl+C` clears the search before closing. Changes save automatically.
|
|
244
269
|
|
|
245
270
|
| Keybinding id | Default | Description |
|
|
246
|
-
|
|
271
|
+
| --- | --- | --- |
|
|
247
272
|
| `app.models.enableAll` | `ctrl+a` | Enable all models (or all matching the current search) |
|
|
248
273
|
| `app.models.clearAll` | `ctrl+x` | Clear all models (or all matching the current search) |
|
|
249
274
|
| `app.models.toggleProvider` | `ctrl+p` | Toggle all models for the current provider |
|
|
250
275
|
| `app.models.reorderUp` | `alt+up` (`alt+q` on Windows and WSL) | Move the selected model up in the cycle order |
|
|
251
276
|
| `app.models.reorderDown` | `alt+down` | Move the selected model down in the cycle order |
|
|
252
277
|
|
|
253
|
-
##
|
|
254
|
-
|
|
255
|
-
Create `~/.atomic/agent/keybindings.json`:
|
|
256
|
-
|
|
257
|
-
```json
|
|
258
|
-
{
|
|
259
|
-
"tui.editor.historyPrevious": "ctrl+p",
|
|
260
|
-
"tui.editor.historyNext": "ctrl+n",
|
|
261
|
-
"tui.editor.deleteWordBackward": ["ctrl+w", "alt+backspace"]
|
|
262
|
-
}
|
|
263
|
-
```
|
|
264
|
-
|
|
265
|
-
User entries override defaults. On native Windows, `app.suspend` defaults to `alt+z` and opens an interactive PowerShell subshell (leaving `ctrl+z` for editor undo; type `exit` to return while background tasks keep running). In WSL, standard Linux `ctrl+z`/`fg` suspension applies and editor undo defaults to `alt+z`. See [Windows](/windows).
|
|
278
|
+
## Preset examples
|
|
266
279
|
|
|
267
280
|
### Emacs example
|
|
268
281
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: "@bastani/atomic-agent-core"
|
|
3
|
-
sidebarTitle: "
|
|
4
|
-
description: "Stateful agent loop with tool execution, event streaming, steering and follow-up messages."
|
|
3
|
+
sidebarTitle: "@bastani/atomic-agent-core"
|
|
4
|
+
description: "Stateful agent loop with tool execution, event streaming, steering, and follow-up messages."
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
Stateful agent with tool execution and event streaming, built on [`@bastani/atomic-ai`](/libraries/ai). Atomic's sessions run on this agent loop, and you can use it directly to build your own agent. Atomic's [SDK](/sdk) wraps it with sessions, tools, extensions, and compaction, so prefer the SDK when you want Atomic's built-in behavior.
|
|
7
|
+
Stateful agent with tool execution and event streaming, built on [`@bastani/atomic-ai`](/libraries/ai) (requires Node.js 22.19+). Atomic's sessions run on this agent loop, and you can use it directly to build your own agent. Atomic's [TypeScript SDK](/sdk) wraps it with sessions, tools, extensions, and compaction, so prefer the SDK when you want Atomic's built-in behavior.
|
|
8
8
|
|
|
9
9
|
## Installation
|
|
10
10
|
|
|
@@ -71,7 +71,7 @@ The agent emits events as turns run so your interface can update incrementally.
|
|
|
71
71
|
|
|
72
72
|
When you call `prompt("Hello")`:
|
|
73
73
|
|
|
74
|
-
```
|
|
74
|
+
```text
|
|
75
75
|
prompt("Hello")
|
|
76
76
|
├─ agent_start
|
|
77
77
|
├─ turn_start
|
|
@@ -122,6 +122,8 @@ Set the mode globally through `toolExecution` in `AgentOptions`, or per tool thr
|
|
|
122
122
|
|
|
123
123
|
`beforeToolCall` runs after `tool_execution_start` and argument validation. It can block execution and attach `terminate: true` to the blocked result. `afterToolCall` runs after tool execution finishes and before `tool_execution_end` and the final tool result message events are emitted.
|
|
124
124
|
|
|
125
|
+
**`afterToolCall` merge rules:** Overrides merge field-by-field (`content`, `details`, `structuredContent`, `isError`, `usage`, `terminate`) with no deep merge. Importantly, returning `content` **without** `structuredContent` drops the original `structuredContent` so the two cannot go out of sync; pass `structuredContent` alongside `content` if you want to keep it.
|
|
126
|
+
|
|
125
127
|
Tools, blocked `beforeToolCall` results, and `afterToolCall` overrides can return `terminate: true` to skip the automatic follow-up LLM call. The loop stops early only when every finalized tool result in that batch sets `terminate: true`. Mixed batches continue normally.
|
|
126
128
|
|
|
127
129
|
With the `Agent` class, assistant `message_end` processing finishes before tool preflight begins. That guarantees `beforeToolCall` sees agent state that already includes the assistant message requesting the tool call.
|
|
@@ -204,7 +206,7 @@ await agent.continue(); // Uses the queued message only because the tail is assi
|
|
|
204
206
|
| `tool_execution_update` | Tool streams progress |
|
|
205
207
|
| `tool_execution_end` | Tool completes |
|
|
206
208
|
|
|
207
|
-
`Agent.subscribe()` listeners are awaited in registration order. `agent_end` means no more loop events will be emitted,
|
|
209
|
+
`Agent.subscribe()` listeners receive `(event, signal)` and are awaited in registration order. If a listener throws or rejects, the error propagates to the caller awaiting `prompt()` or `continue()`. `agent_end` means no more loop events will be emitted, and `await agent.waitForIdle()` and `await agent.prompt(...)` settle only after awaited `agent_end` listeners finish.
|
|
208
210
|
|
|
209
211
|
## Agent options
|
|
210
212
|
|
|
@@ -220,7 +222,7 @@ const agent = new Agent({
|
|
|
220
222
|
messages: AgentMessage[],
|
|
221
223
|
},
|
|
222
224
|
|
|
223
|
-
// Convert AgentMessage[] to LLM Message[] (required for custom message types)
|
|
225
|
+
// Convert AgentMessage[] to LLM Message[] (required for custom message types; must not throw or reject)
|
|
224
226
|
convertToLlm: (messages) => messages.filter(...),
|
|
225
227
|
|
|
226
228
|
// Transform context before convertToLlm (for pruning, compaction)
|
|
@@ -247,9 +249,19 @@ const agent = new Agent({
|
|
|
247
249
|
// Dynamic API key resolution (for expiring OAuth tokens)
|
|
248
250
|
getApiKey: async (provider) => refreshToken(),
|
|
249
251
|
|
|
252
|
+
// Optional provider transport, retry cap, and request/response inspection hooks
|
|
253
|
+
transport: "sse",
|
|
254
|
+
maxRetryDelayMs: 60_000,
|
|
255
|
+
onPayload: (payload, model) => payload,
|
|
256
|
+
onResponse: (response) => {},
|
|
257
|
+
onProviderStreamEvent: (event) => {},
|
|
258
|
+
|
|
250
259
|
// Tool execution mode: "parallel" (default) or "sequential"
|
|
251
260
|
toolExecution: "parallel",
|
|
252
261
|
|
|
262
|
+
// Custom error text when the model calls an unregistered tool name
|
|
263
|
+
unknownToolMessage: (toolName) => `Tool "${toolName}" is not available.`,
|
|
264
|
+
|
|
253
265
|
// Preflight each tool call after args are validated. Can block execution.
|
|
254
266
|
beforeToolCall: async ({ toolCall, args, context }) => {
|
|
255
267
|
if (toolCall.name === "bash") {
|
|
@@ -272,6 +284,10 @@ const agent = new Agent({
|
|
|
272
284
|
return { context: { ...context, messages: await loadCanonicalMessages(signal) } };
|
|
273
285
|
},
|
|
274
286
|
|
|
287
|
+
// Optional turn-boundary hooks that update model, tools, or system messages between turns.
|
|
288
|
+
prepareNextTurn: async (signal) => undefined,
|
|
289
|
+
prepareNextTurnWithContext: async (context, signal) => undefined,
|
|
290
|
+
|
|
275
291
|
// Finalize a completed turn before turn_end is emitted.
|
|
276
292
|
// `continue` ensures one next request; existing tool/queue scheduling can satisfy it.
|
|
277
293
|
// `end` ends this run after turn_end without polling queues.
|
|
@@ -289,6 +305,12 @@ const agent = new Agent({
|
|
|
289
305
|
});
|
|
290
306
|
```
|
|
291
307
|
|
|
308
|
+
### `StreamFn`, `setDefaultStreamFn()`, and `convertToLlm` contracts
|
|
309
|
+
|
|
310
|
+
- **`StreamFn` must never throw or reject** for request, model, or runtime failures. Always return an `AssistantMessageEventStream` and encode failures via stream `error` events and a final `AssistantMessage` with `stopReason: "error"` or `"aborted"` and `errorMessage`.
|
|
311
|
+
- **`convertToLlm` must never throw or reject**; filter or normalize custom messages deterministically.
|
|
312
|
+
- **`setDefaultStreamFn(streamFn | undefined)`:** Sets a process-wide fallback `StreamFn` used when `Agent` or `agentLoop()` callers do not supply an explicit `streamFn`.
|
|
313
|
+
|
|
292
314
|
## Agent state
|
|
293
315
|
|
|
294
316
|
```typescript
|
|
@@ -479,6 +501,8 @@ const readFileTool: AgentTool<typeof readFileParameters> = {
|
|
|
479
501
|
label: "Read File", // For UI display
|
|
480
502
|
description: "Read a file's contents",
|
|
481
503
|
parameters: readFileParameters,
|
|
504
|
+
// Optional JSON Schema describing structuredContent returned to programmatic/codemode callers
|
|
505
|
+
outputSchema: obj({ path: str(), content: str() }),
|
|
482
506
|
// Override execution mode for this tool (optional).
|
|
483
507
|
// "sequential" forces the entire batch to run one at a time.
|
|
484
508
|
// "parallel" allows concurrent execution with other tool calls.
|
|
@@ -494,6 +518,7 @@ const readFileTool: AgentTool<typeof readFileParameters> = {
|
|
|
494
518
|
// when every finalized tool result in the batch does the same.
|
|
495
519
|
return {
|
|
496
520
|
content: [{ type: "text", text: content }],
|
|
521
|
+
structuredContent: { path: params.path, content },
|
|
497
522
|
details: { path: params.path, size: content.length },
|
|
498
523
|
};
|
|
499
524
|
},
|
|
@@ -520,9 +545,25 @@ The agent catches thrown errors and reports them to the LLM as tool errors with
|
|
|
520
545
|
|
|
521
546
|
Return `terminate: true` from `execute()`, a blocked `beforeToolCall`, or `afterToolCall` to skip the follow-up LLM call after the current tool batch. This takes effect only when every finalized tool result in the batch sets `terminate: true`. The hint is runtime-only, so emitted `toolResult` transcript messages remain standard LLM tool results.
|
|
522
547
|
|
|
523
|
-
### MCP and
|
|
548
|
+
### MCP, Codemode, and `runToolCall()`
|
|
549
|
+
|
|
550
|
+
[`@bastani/atomic-codemode`](/libraries/codemode) runs model-written JavaScript that calls tools. Wrap it as an `AgentTool` named `codemode` whose scripts invoke the agent's tools through `runToolCall(toolCall, options)` so argument validation, `beforeToolCall`, and `afterToolCall` apply to nested calls too.
|
|
551
|
+
|
|
552
|
+
```typescript
|
|
553
|
+
import { type AgentToolCall, type AgentToolCallOutcome, type RunToolCallOptions, runToolCall } from "@bastani/atomic-agent-core";
|
|
554
|
+
|
|
555
|
+
const outcome: AgentToolCallOutcome = await runToolCall(toolCall, {
|
|
556
|
+
tools,
|
|
557
|
+
assistantMessage,
|
|
558
|
+
context,
|
|
559
|
+
beforeToolCall: agent.beforeToolCall,
|
|
560
|
+
afterToolCall: agent.afterToolCall,
|
|
561
|
+
signal,
|
|
562
|
+
});
|
|
563
|
+
// outcome: { result: AgentToolResult<unknown>, isError: boolean, durationMs?: number }
|
|
564
|
+
```
|
|
524
565
|
|
|
525
|
-
|
|
566
|
+
`runToolCall()` returns `{ result, isError, durationMs? }` (returning tool failures as `isError: true` rather than throwing). See [Using with agent-core](/libraries/codemode#using-with-agent-core). Tools that wrap an MCP server's tools work the same way. Atomic's own MCP support lives in the [MCP servers](/mcp-servers) extension.
|
|
526
567
|
|
|
527
568
|
## Proxy usage
|
|
528
569
|
|
package/docs/libraries/ai.md
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: "@bastani/atomic-ai"
|
|
3
|
-
sidebarTitle: "
|
|
4
|
-
description: "Unified LLM API
|
|
3
|
+
sidebarTitle: "@bastani/atomic-ai"
|
|
4
|
+
description: "Unified LLM API for providers, models, auth, streaming, tool calling, images, classification, and thinking."
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
`@bastani/atomic-ai` is the LLM library Atomic
|
|
7
|
+
`@bastani/atomic-ai` is the LLM library Atomic runs on (requires Node.js 22.19+). It ships in every Atomic release at Atomic's version, and you can install it independently:
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
10
|
npm install @bastani/atomic-ai
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
Inside an Atomic extension, import it without installing it because the host provides it. See [
|
|
13
|
+
Inside an Atomic extension, import it without installing it because the host provides it. See [Standalone libraries](/libraries) for how the packages fit together and for legacy package names that still resolve inside Atomic.
|
|
14
14
|
|
|
15
15
|
`@bastani/atomic-ai` provides one LLM API across providers with provider collections, automatic auth resolution, token and cost tracking, and JSON-serializable contexts for mid-session model handoffs.
|
|
16
16
|
|
|
@@ -18,14 +18,14 @@ Inside an Atomic extension, import it without installing it because the host pro
|
|
|
18
18
|
|
|
19
19
|
## Supported providers
|
|
20
20
|
|
|
21
|
-
- **OpenAI** (API key or Sign in with ChatGPT; separate `openai-images` and `openai-decisions` providers share OpenAI API keys)
|
|
21
|
+
- **OpenAI** (`openai`: API key or Sign in with ChatGPT OAuth; `openai-api` via `openaiApiProvider()`: dedicated API-key-only provider so API billing stays separate from ChatGPT OAuth; separate `openai-images` and `openai-decisions` providers share OpenAI API keys)
|
|
22
22
|
- **Ant Ling**
|
|
23
23
|
- **Azure** (Azure OpenAI Responses and Microsoft Foundry Chat Completions)
|
|
24
24
|
- **OpenAI Codex** (ChatGPT subscription via OAuth)
|
|
25
25
|
- **TypeSafe** (System One classifier API)
|
|
26
26
|
- **DeepSeek**
|
|
27
27
|
- **NVIDIA NIM**
|
|
28
|
-
- **Anthropic** (API key, bearer token, workload identity federation, or Claude Pro/Max OAuth)
|
|
28
|
+
- **Anthropic** (`anthropic`: API key, bearer token, workload identity federation, or Claude Pro/Max OAuth; `anthropic-api` via `anthropicApiProvider()`: dedicated API-key-only provider so API billing stays separate from Claude Pro/Max OAuth)
|
|
29
29
|
- **Google**
|
|
30
30
|
- **Vertex AI** (Gemini via Google Cloud Vertex AI)
|
|
31
31
|
- **Mistral**
|
|
@@ -60,7 +60,12 @@ Inside an Atomic extension, import it without installing it because the host pro
|
|
|
60
60
|
npm install @bastani/atomic-ai
|
|
61
61
|
```
|
|
62
62
|
|
|
63
|
-
|
|
63
|
+
Requires Node.js 22.19 or newer.
|
|
64
|
+
|
|
65
|
+
Key root and subpath exports:
|
|
66
|
+
|
|
67
|
+
- Root `@bastani/atomic-ai`: `createModels`, `createProvider`, `Type`/`Static`/`TSchema` (re-exported from TypeBox), thinking helpers (`DEFAULT_THINKING_BUDGETS`, `fittedThinkingBudget`, `thinkingBudgetForLevel`, `getSupportedThinkingLevels`, `clampThinkingLevel`), `OAuthRefreshRejectedError`, `GitHubCopilot*Error`, `cleanupSessionResources`, and `PI_AI_VERSION`.
|
|
68
|
+
- Subpaths: `@bastani/atomic-ai/providers/<provider>`, `@bastani/atomic-ai/providers/all`, `@bastani/atomic-ai/api/<api-id>`, `@bastani/atomic-ai/session-resources`, `@bastani/atomic-ai/bun-oauth`, `@bastani/atomic-ai/oauth`, and `@bastani/atomic-ai/compat`.
|
|
64
69
|
|
|
65
70
|
## Quick start
|
|
66
71
|
|
|
@@ -1774,6 +1779,8 @@ Rules:
|
|
|
1774
1779
|
|
|
1775
1780
|
Avoid `@bastani/atomic-ai/compat` in new bundled apps because it preserves the legacy global API and pulls in the full built-in catalog.
|
|
1776
1781
|
|
|
1782
|
+
### Bundler troubleshooting
|
|
1783
|
+
|
|
1777
1784
|
For single-file Node ESM bundles, some SDK dependencies may still use dynamic CommonJS `require()` internally. If you see errors such as `Dynamic require of "child_process" is not supported`, add a Node `require` shim to the bundle. With esbuild:
|
|
1778
1785
|
|
|
1779
1786
|
```bash
|
|
@@ -1913,15 +1920,17 @@ Official docs: [Application Default Credentials](https://cloud.google.com/docs/a
|
|
|
1913
1920
|
|
|
1914
1921
|
### CLI login
|
|
1915
1922
|
|
|
1916
|
-
|
|
1923
|
+
`@bastani/atomic-ai` ships the `atomic-ai` binary (with `pi-ai` kept as a legacy alias) to log into built-in **OAuth** providers:
|
|
1917
1924
|
|
|
1918
1925
|
```bash
|
|
1919
|
-
npx @bastani/atomic-ai login # interactive provider selection
|
|
1920
|
-
npx @bastani/atomic-ai login anthropic #
|
|
1921
|
-
npx @bastani/atomic-ai list # list
|
|
1926
|
+
npx @bastani/atomic-ai login # interactive OAuth provider selection
|
|
1927
|
+
npx @bastani/atomic-ai login anthropic # log into a specific OAuth provider
|
|
1928
|
+
npx @bastani/atomic-ai list # list OAuth-enabled providers
|
|
1929
|
+
# Or when installed locally/globally:
|
|
1930
|
+
atomic-ai login anthropic
|
|
1922
1931
|
```
|
|
1923
1932
|
|
|
1924
|
-
|
|
1933
|
+
The CLI lists only providers that support OAuth (`provider.auth.oauth`), and writes credentials to `auth.json` in the current working directory with owner-only permissions (`0600`).
|
|
1925
1934
|
|
|
1926
1935
|
### Programmatic OAuth
|
|
1927
1936
|
|
|
@@ -1,11 +1,27 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: "@bastani/atomic-codemode"
|
|
3
|
-
sidebarTitle: "
|
|
4
|
-
description: "
|
|
3
|
+
sidebarTitle: "@bastani/atomic-codemode"
|
|
4
|
+
description: "Run model-written JavaScript in a QuickJS WebAssembly sandbox whose only capability is calling injected tools."
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
Runs model-written JavaScript in a QuickJS VM (compiled to WebAssembly) where the only capability is calling injected tools. Nested tool calls never enter the LLM context; only the script's output and return value do.
|
|
8
8
|
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install @bastani/atomic-codemode
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Requires Node.js 22.19+ (or Bun / Cloudflare Workers via the portable subpaths). Available package entry points:
|
|
16
|
+
|
|
17
|
+
- `@bastani/atomic-codemode`: `CodemodeSandbox`, `loadQuickJSWasm`, `parseCodemodeSource`, `renderDeclarations`, and worker runtime for Node and Bun.
|
|
18
|
+
- `@bastani/atomic-codemode/portable`: `RemoteCodemodeSandbox` and `InlineCodemodeSandbox` with zero Node.js imports.
|
|
19
|
+
- `@bastani/atomic-codemode/cloudflare`: `CodemodeSandboxDurableObject` and `createInlineCodemodeSandbox` for Cloudflare Workers.
|
|
20
|
+
- `@bastani/atomic-codemode/declarations`: lightweight `renderDeclarations()` without worker or WebAssembly dependencies.
|
|
21
|
+
- `@bastani/atomic-codemode/source`: lightweight `parseCodemodeSource()`, `CodemodeSourceError`, and `CODEMODE_SOURCE_GRAMMAR`.
|
|
22
|
+
- `@bastani/atomic-codemode/node-options`: Node worker option helpers.
|
|
23
|
+
- `@bastani/atomic-codemode/worker`: worker entrypoint for bundled hosts.
|
|
24
|
+
|
|
9
25
|
Scripts use `tools`, `ALL_TOOLS`, `text`, `image`, `exit`, `store`, and `load`, and may start with a `// @options:` line. Atomic uses it for its built-in [`codemode` tool](/codemode). It has no dependency on the other Atomic packages and can be used on its own to expose any functions (remote APIs, MCP servers, application services) to model-written scripts.
|
|
10
26
|
|
|
11
27
|
The package runs in two kinds of environments. Each has its own sandbox class, but they share one API, one script environment, and one result format:
|
|
@@ -50,16 +66,17 @@ await sandbox.close();
|
|
|
50
66
|
|
|
51
67
|
`code` is the body of an async function, so `return` and top-level `await` work. Inside the script, every sandbox provides:
|
|
52
68
|
|
|
53
|
-
- `tools.<name>(args)` returns a promise. Arguments and results go through a JSON round trip
|
|
69
|
+
- `tools.<name>(args)` returns a promise. Arguments and results go through a JSON round trip. When a tool rejects with an `Error`, the script catches an `Error` with the same message plus any extra JSON-serializable own properties from that error (such as `code`, excluding `name`, `message`, and `stack`). Tool names are also exposed as identifiers with invalid characters replaced by `_` via `toCodemodeIdentifier`, so `my-tool` is available as both `tools.my_tool` and `tools["my-tool"]`.
|
|
54
70
|
- `ALL_TOOLS` lists `{ name, description }` for every tool, using the identifier form for `name`.
|
|
55
71
|
- `text(value)` appends a text item to `result.output`, JSON-stringifying non-string values. `console.log`, `info`, `warn`, `error`, and `debug` append text items with `console: true`.
|
|
56
72
|
- `image(urlOrItem)` appends an image item. It accepts a base64 `data:` URL, `{ image_url }`, or an image block (`{ type: "image", data, mimeType }`, as MCP tools and `@bastani/atomic-ai` produce). Remote URLs are rejected.
|
|
57
73
|
- `exit()` ends the script immediately with a successful result, keeping its output and store writes.
|
|
58
|
-
- `globals` passed to the sandbox are callable as top-level functions, such as a host helper `image(ref)`. They behave like tools but are not recorded in `result.calls`.
|
|
74
|
+
- `globals` passed to the sandbox are callable as top-level functions, such as a host helper `image(ref)`. They behave like tools but are not recorded in `result.calls`. Global names must be valid JavaScript identifiers (or dotted `namespace.member` forms, placing the function on a frozen namespace object) and cannot collide with reserved names: `tools`, `ALL_TOOLS`, `console`, `text`, `image`, `exit`, `globalThis`, `store`, or `load`. With `spread: true`, `execute` receives all call arguments as an array instead of only the first argument, and `signature` replaces the declaration generated from the schemas.
|
|
59
75
|
- `store(key, value)` and `load(key)` read and write JSON values synchronously. See [Store](#store).
|
|
76
|
+
- **Frozen built-in prototypes:** Before running scripts, the VM freezes built-in prototypes (`Object.prototype`, `Array.prototype`, and others, while still allowing instance overrides of `constructor`, `name`, `message`, `toString`, `toLocaleString`, `valueOf`, and `toJSON`). Scripts that attempt to monkey-patch built-in prototypes throw a `TypeError`.
|
|
60
77
|
- Nothing else is available. There are no timers, `fetch`, `process`, `require`, modules, or `WebAssembly`. `eval` and `Function` work, but they only evaluate code inside the same VM.
|
|
61
78
|
|
|
62
|
-
Setting `timeoutMs: Infinity` disables the deadline so the script runs until it settles or `signal` aborts it. A script that awaits a promise nothing can settle (with no tool call pending and no timers or I/O in the VM) fails immediately instead of hanging.
|
|
79
|
+
When `timeoutMs` is omitted, `CodemodeSandbox` uses `DEFAULT_TIMEOUT_MS` (`300_000` ms, or 5 minutes). Setting `timeoutMs: Infinity` disables the deadline so the script runs until it settles or `signal` aborts it. A script that awaits a promise nothing can settle (with no tool call pending and no timers or I/O in the VM) fails immediately instead of hanging.
|
|
63
80
|
|
|
64
81
|
`memoryLimitBytes` caps the VM heap. Allocations beyond that limit fail inside the script with `InternalError: out of memory`.
|
|
65
82
|
|
|
@@ -107,7 +124,12 @@ const source = await tools.read({ path: "package.json" });
|
|
|
107
124
|
text(JSON.parse(source).name);
|
|
108
125
|
```
|
|
109
126
|
|
|
110
|
-
Supported fields
|
|
127
|
+
Supported JSON fields on the `// @options:` header line are snake_case:
|
|
128
|
+
|
|
129
|
+
- `max_output_tokens`: non-negative safe integer (`>= 0`; `0` is valid), returned as `options.maxOutputTokens`.
|
|
130
|
+
- `timeout_ms`: positive safe integer from `1` to `2,147,483,647`, returned as `options.timeoutMs`.
|
|
131
|
+
|
|
132
|
+
`parseCodemodeSource()` returns `{ code, options: { maxOutputTokens?, timeoutMs? } }`. The sandbox does not enforce these limits itself; the caller decides how to apply them. The options line is replaced by a blank line so line numbers in stack traces still match the input.
|
|
111
133
|
|
|
112
134
|
Empty input, invalid JSON, unknown fields, an options line without code, or an options line after line 1 throw `CodemodeSourceError`. `CODEMODE_SOURCE_GRAMMAR` is a Lark grammar for providers that support grammar-constrained tool input. Both exports are also available from the lightweight `@bastani/atomic-codemode/source` entry.
|
|
113
135
|
|
package/docs/libraries/schema.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: "@bastani/atomic-schema"
|
|
3
|
-
sidebarTitle: "
|
|
4
|
-
description: "JSON Schema
|
|
3
|
+
sidebarTitle: "@bastani/atomic-schema"
|
|
4
|
+
description: "Build and validate JSON Schema drafts 2020-12 and 7 without eval, with zero runtime dependencies and optional coercion."
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
JSON Schema builders and validation without `eval`. Each schema compiles once into plain closures, so validation runs without code generation, works under a strict Content Security Policy, and needs no runtime dependencies.
|
|
@@ -48,7 +48,7 @@ read.errors({ offset: 0, extra: true });
|
|
|
48
48
|
|
|
49
49
|
`check(value)` is the fast boolean path. It is a standalone function you can pass around, and it avoids allocations for most schemas.
|
|
50
50
|
|
|
51
|
-
`errors(value)` explains failures and returns `[]` for valid values. The error explainer is built on the first failure and reused, so schemas whose inputs always pass never pay for it. `validate(value)` runs both without modifying the input and returns `{ ok: true
|
|
51
|
+
`errors(value)` explains failures and returns `ValidationError[]` (`{ path: string; keyword: string; message: string }`), or `[]` for valid values. The error explainer is built on the first failure and reused, so schemas whose inputs always pass never pay for it. `validate(value)` runs both without modifying the input and returns `ParseResult<T>` (`{ ok: true; value: T } | { ok: false; errors: ValidationError[] }`).
|
|
52
52
|
|
|
53
53
|
### Builders
|
|
54
54
|
|
|
@@ -59,7 +59,7 @@ read.errors({ offset: 0, extra: true });
|
|
|
59
59
|
| `bool()`, `nul()`, `unknown()` | `{ type: "boolean" }`, `{ type: "null" }`, `{}` | `boolean`, `null`, `unknown` |
|
|
60
60
|
| `lit(value)` | `{ const: value }` | the literal |
|
|
61
61
|
| `oneOf(["a", "b"])` | `{ enum: [...] }` | `"a" \| "b"` |
|
|
62
|
-
| `obj({ a: str(), b: opt(num()) }, { open })` | closed object; `open: true`
|
|
62
|
+
| `obj({ a: str(), b: opt(num()) }, { open })` | closed object (`additionalProperties: false`); `open: true` omits `additionalProperties` | `{ a: string; b?: number }` |
|
|
63
63
|
| `arr(items, { minItems, maxItems, uniqueItems })` | `{ type: "array", items }` | `T[]` |
|
|
64
64
|
| `tuple([str(), num()])` | `prefixItems`, no additional items | `[string, number]` |
|
|
65
65
|
| `map(value)` | `{ type: "object", additionalProperties: value }` | `Record<string, T>` |
|
|
@@ -105,16 +105,16 @@ const validator = compile(schema, {
|
|
|
105
105
|
});
|
|
106
106
|
```
|
|
107
107
|
|
|
108
|
-
`formats` includes
|
|
108
|
+
`formats` includes all 21 supported format keys: `date`, `date-time`, `duration`, `email`, `hostname`, `idn-email`, `idn-hostname`, `ipv4`, `ipv6`, `iri`, `iri-reference`, `json-pointer`, `json-pointer-uri-fragment`, `regex`, `relative-json-pointer`, `time`, `uri`, `uri-reference`, `uri-template`, `url`, and `uuid`. Pass your own record to check a subset of formats or add custom checks.
|
|
109
109
|
|
|
110
110
|
By default, an unresolved `$ref` (a missing definition or a document not in `schemas`) throws during `compile()`. With `unresolvedRefs: "reject"`, that reference compiles as `false` instead. Only values at that position fail, with the error `unresolved reference <ref>`, while the rest of the schema continues to validate. Use this option for external schemas such as MCP tool schemas whose references may dangle.
|
|
111
111
|
|
|
112
112
|
### TypeBox schemas
|
|
113
113
|
|
|
114
|
-
TypeBox 1.x schemas are JSON Schema objects, so they compile directly:
|
|
114
|
+
TypeBox 1.x schemas are JSON Schema objects, so they compile directly. Inside Atomic extensions and SDK apps, import `Type` from `@bastani/atomic/typebox`; in standalone apps using `@bastani/atomic-schema` alone, import from `typebox` directly:
|
|
115
115
|
|
|
116
116
|
```typescript
|
|
117
|
-
import Type from "typebox";
|
|
117
|
+
import Type from "typebox"; // standalone app; inside Atomic use: import { Type } from "@bastani/atomic/typebox"
|
|
118
118
|
|
|
119
119
|
const user = compile(Type.Object({ name: Type.String(), tags: Type.Array(Type.String()) }));
|
|
120
120
|
```
|