@bastani/atomic 0.9.38-alpha.5 → 0.9.38-alpha.6
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 +39 -0
- package/README.md +8 -6
- package/dist/builtin/intercom/CHANGELOG.md +9 -0
- package/dist/builtin/intercom/broker/broker.ts +6 -4
- package/dist/builtin/intercom/broker/delivered-message-cache.ts +50 -4
- package/dist/builtin/intercom/broker/send-handler.ts +6 -4
- package/dist/builtin/intercom/index.bundle.mjs +78 -33
- package/dist/builtin/intercom/package.json +1 -1
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/package.json +1 -1
- package/dist/builtin/subagents/src/extension/index.bundle.mjs +29 -33
- package/dist/builtin/web-access/CHANGELOG.md +7 -0
- package/dist/builtin/web-access/index.bundle.mjs +53 -15
- package/dist/builtin/web-access/package.json +1 -1
- package/dist/builtin/workflows/CHANGELOG.md +29 -0
- package/dist/builtin/workflows/builtin/{chunk-qrrkfg9v.js → chunk-2qgfyvzs.js} +1 -1
- package/dist/builtin/workflows/builtin/{chunk-na3wpwzh.js → chunk-g1a4hw0s.js} +390 -345
- package/dist/builtin/workflows/builtin/{chunk-xg7kkgf8.js → chunk-neszcj53.js} +1 -1
- package/dist/builtin/workflows/builtin/goal.js +2 -2
- package/dist/builtin/workflows/builtin/index.js +3 -3
- package/dist/builtin/workflows/builtin/ralph.js +2 -2
- package/dist/builtin/workflows/package.json +1 -1
- package/dist/builtin/workflows/src/authoring.d.ts +3 -8
- package/dist/builtin/workflows/src/durable/journal/conformance.d.ts +9 -1
- package/dist/builtin/workflows/src/durable/journal/internal.d.ts +20 -0
- package/dist/builtin/workflows/src/durable/journal/lease-expiry.d.ts +2 -0
- package/dist/builtin/workflows/src/durable/journal/memory-run-journal.d.ts +17 -1
- package/dist/builtin/workflows/src/durable/journal/resolution.d.ts +6 -1
- package/dist/builtin/workflows/src/durable/journal/sql-run-journal.d.ts +45 -0
- package/dist/builtin/workflows/src/durable/journal/sqlite-run-journal.d.ts +5 -47
- package/dist/builtin/workflows/src/durable/journal/types.d.ts +15 -30
- package/dist/builtin/workflows/src/durable/journal/values.d.ts +2 -0
- package/dist/builtin/workflows/src/extension/index.bundle.mjs +23360 -22814
- package/dist/builtin/workflows/src/index.js +7671 -7141
- package/dist/builtin/workflows/src/shared/authoring-contract-stage.d.ts +7 -7
- package/dist/builtin/workflows/src/shared/authoring-contract-ui.d.ts +0 -14
- package/dist/cli/args.d.ts +1 -0
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +6 -2
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/session-picker.d.ts +2 -2
- package/dist/cli/session-picker.d.ts.map +1 -1
- package/dist/cli/session-picker.js +3 -3
- package/dist/cli/session-picker.js.map +1 -1
- package/dist/core/agent-session-auto-compaction.d.ts +1 -1
- package/dist/core/agent-session-auto-compaction.d.ts.map +1 -1
- package/dist/core/agent-session-auto-compaction.js +2 -2
- package/dist/core/agent-session-auto-compaction.js.map +1 -1
- package/dist/core/agent-session-bash.d.ts +2 -3
- package/dist/core/agent-session-bash.d.ts.map +1 -1
- package/dist/core/agent-session-bash.js +18 -10
- package/dist/core/agent-session-bash.js.map +1 -1
- package/dist/core/agent-session-boundaries.d.ts +6 -6
- package/dist/core/agent-session-boundaries.d.ts.map +1 -1
- package/dist/core/agent-session-boundaries.js +22 -22
- package/dist/core/agent-session-boundaries.js.map +1 -1
- package/dist/core/agent-session-compaction.js +2 -2
- package/dist/core/agent-session-compaction.js.map +1 -1
- package/dist/core/agent-session-custom-message-commit.d.ts.map +1 -1
- package/dist/core/agent-session-custom-message-commit.js +10 -12
- package/dist/core/agent-session-custom-message-commit.js.map +1 -1
- package/dist/core/agent-session-events.d.ts.map +1 -1
- package/dist/core/agent-session-events.js +20 -13
- package/dist/core/agent-session-events.js.map +1 -1
- package/dist/core/agent-session-export.js +1 -1
- package/dist/core/agent-session-export.js.map +1 -1
- package/dist/core/agent-session-extension-bindings.d.ts +2 -2
- package/dist/core/agent-session-extension-bindings.d.ts.map +1 -1
- package/dist/core/agent-session-extension-bindings.js +75 -59
- package/dist/core/agent-session-extension-bindings.js.map +1 -1
- package/dist/core/agent-session-message-queue.d.ts +2 -2
- package/dist/core/agent-session-message-queue.d.ts.map +1 -1
- package/dist/core/agent-session-message-queue.js +17 -8
- package/dist/core/agent-session-message-queue.js.map +1 -1
- package/dist/core/agent-session-methods.d.ts +15 -15
- package/dist/core/agent-session-methods.d.ts.map +1 -1
- package/dist/core/agent-session-methods.js.map +1 -1
- package/dist/core/agent-session-models.d.ts +2 -2
- package/dist/core/agent-session-models.d.ts.map +1 -1
- package/dist/core/agent-session-models.js +59 -42
- package/dist/core/agent-session-models.js.map +1 -1
- package/dist/core/agent-session-persistent-custom-messages.d.ts +4 -4
- package/dist/core/agent-session-persistent-custom-messages.d.ts.map +1 -1
- package/dist/core/agent-session-persistent-custom-messages.js +16 -17
- package/dist/core/agent-session-persistent-custom-messages.js.map +1 -1
- package/dist/core/agent-session-prompt.d.ts.map +1 -1
- package/dist/core/agent-session-prompt.js +6 -8
- package/dist/core/agent-session-prompt.js.map +1 -1
- package/dist/core/agent-session-retry.d.ts.map +1 -1
- package/dist/core/agent-session-retry.js +17 -15
- package/dist/core/agent-session-retry.js.map +1 -1
- package/dist/core/agent-session-runtime.d.ts +3 -8
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +44 -96
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session-summary.js +1 -1
- package/dist/core/agent-session-summary.js.map +1 -1
- package/dist/core/agent-session-tree.d.ts +1 -1
- package/dist/core/agent-session-tree.d.ts.map +1 -1
- package/dist/core/agent-session-tree.js +7 -7
- package/dist/core/agent-session-tree.js.map +1 -1
- package/dist/core/cache-warmer.js +1 -1
- package/dist/core/cache-warmer.js.map +1 -1
- package/dist/core/export-html/index.js +1 -1
- package/dist/core/export-html/index.js.map +1 -1
- package/dist/core/export-html/template-js/entries-navigation.js +1 -1
- package/dist/core/export-html/template.js +1 -1
- package/dist/core/extensions/api-types.d.ts +12 -12
- package/dist/core/extensions/api-types.d.ts.map +1 -1
- package/dist/core/extensions/api-types.js.map +1 -1
- package/dist/core/extensions/context-types.d.ts +4 -2
- package/dist/core/extensions/context-types.d.ts.map +1 -1
- package/dist/core/extensions/context-types.js.map +1 -1
- package/dist/core/extensions/extension-work.d.ts +1 -0
- package/dist/core/extensions/extension-work.d.ts.map +1 -1
- package/dist/core/extensions/extension-work.js +5 -1
- package/dist/core/extensions/extension-work.js.map +1 -1
- package/dist/core/extensions/loader-api.d.ts.map +1 -1
- package/dist/core/extensions/loader-api.js +40 -42
- package/dist/core/extensions/loader-api.js.map +1 -1
- package/dist/core/extensions/loader-host-modules.d.ts +1 -1
- package/dist/core/extensions/loader-host-modules.d.ts.map +1 -1
- package/dist/core/extensions/loader-host-modules.js +6 -2
- package/dist/core/extensions/loader-host-modules.js.map +1 -1
- package/dist/core/extensions/loader-rollback.d.ts.map +1 -1
- package/dist/core/extensions/loader-rollback.js +1 -0
- package/dist/core/extensions/loader-rollback.js.map +1 -1
- package/dist/core/extensions/loader-virtual-modules.d.ts.map +1 -1
- package/dist/core/extensions/loader-virtual-modules.js +1 -0
- package/dist/core/extensions/loader-virtual-modules.js.map +1 -1
- package/dist/core/extensions/runner-context.d.ts +1 -0
- package/dist/core/extensions/runner-context.d.ts.map +1 -1
- package/dist/core/extensions/runner-context.js +3 -2
- package/dist/core/extensions/runner-context.js.map +1 -1
- package/dist/core/extensions/runner-handlers.d.ts +1 -1
- package/dist/core/extensions/runner-handlers.d.ts.map +1 -1
- package/dist/core/extensions/runner-handlers.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +3 -2
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +20 -12
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/runtime-types.d.ts +7 -7
- package/dist/core/extensions/runtime-types.d.ts.map +1 -1
- package/dist/core/extensions/runtime-types.js.map +1 -1
- package/dist/core/extensions/session-events.d.ts +5 -5
- package/dist/core/extensions/session-events.d.ts.map +1 -1
- package/dist/core/extensions/session-events.js.map +1 -1
- package/dist/core/fast-model-routing.d.ts.map +1 -1
- package/dist/core/fast-model-routing.js +1 -0
- package/dist/core/fast-model-routing.js.map +1 -1
- package/dist/core/intercom-runtime-group.js +1 -1
- package/dist/core/intercom-runtime-group.js.map +1 -1
- package/dist/core/provider-attribution.js +1 -1
- package/dist/core/provider-attribution.js.map +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +7 -6
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-manager-archive.d.ts +2 -16
- package/dist/core/session-manager-archive.d.ts.map +1 -1
- package/dist/core/session-manager-archive.js +8 -104
- package/dist/core/session-manager-archive.js.map +1 -1
- package/dist/core/session-manager-core.d.ts +48 -49
- package/dist/core/session-manager-core.d.ts.map +1 -1
- package/dist/core/session-manager-core.js +438 -306
- package/dist/core/session-manager-core.js.map +1 -1
- package/dist/core/session-manager-entries.d.ts.map +1 -1
- package/dist/core/session-manager-entries.js +5 -10
- package/dist/core/session-manager-entries.js.map +1 -1
- package/dist/core/session-manager-errors.d.ts +10 -0
- package/dist/core/session-manager-errors.d.ts.map +1 -0
- package/dist/core/session-manager-errors.js +27 -0
- package/dist/core/session-manager-errors.js.map +1 -0
- package/dist/core/session-manager-list.d.ts +1 -0
- package/dist/core/session-manager-list.d.ts.map +1 -1
- package/dist/core/session-manager-list.js +14 -7
- package/dist/core/session-manager-list.js.map +1 -1
- package/dist/core/session-manager-storage.d.ts +0 -11
- package/dist/core/session-manager-storage.d.ts.map +1 -1
- package/dist/core/session-manager-storage.js +4 -61
- package/dist/core/session-manager-storage.js.map +1 -1
- package/dist/core/session-manager-types.d.ts +2 -10
- package/dist/core/session-manager-types.d.ts.map +1 -1
- package/dist/core/session-manager-types.js.map +1 -1
- package/dist/core/session-manager-validation.d.ts.map +1 -1
- package/dist/core/session-manager-validation.js +3 -2
- package/dist/core/session-manager-validation.js.map +1 -1
- package/dist/core/session-manager.d.ts +1 -0
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +1 -0
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/session-mutation-queue.d.ts +3 -0
- package/dist/core/session-mutation-queue.d.ts.map +1 -0
- package/dist/core/session-mutation-queue.js +14 -0
- package/dist/core/session-mutation-queue.js.map +1 -0
- package/dist/core/settings-merge.d.ts.map +1 -1
- package/dist/core/settings-merge.js +3 -2
- package/dist/core/settings-merge.js.map +1 -1
- package/dist/core/settings-schema.d.ts +0 -5
- package/dist/core/settings-schema.d.ts.map +1 -1
- package/dist/core/settings-schema.js +1 -15
- package/dist/core/settings-schema.js.map +1 -1
- package/dist/core/storage/index.d.ts +1 -1
- package/dist/core/storage/index.d.ts.map +1 -1
- package/dist/core/storage/index.js +1 -1
- package/dist/core/storage/index.js.map +1 -1
- package/dist/core/storage/node-sqlite.d.ts +2 -0
- package/dist/core/storage/node-sqlite.d.ts.map +1 -1
- package/dist/core/storage/node-sqlite.js +47 -6
- package/dist/core/storage/node-sqlite.js.map +1 -1
- package/dist/core/storage/session/jsonl-session-store.d.ts +9 -2
- package/dist/core/storage/session/jsonl-session-store.d.ts.map +1 -1
- package/dist/core/storage/session/jsonl-session-store.js +71 -27
- package/dist/core/storage/session/jsonl-session-store.js.map +1 -1
- package/dist/core/storage/session/validation.js +1 -1
- package/dist/core/storage/session/validation.js.map +1 -1
- package/dist/core/storage/testing.d.ts +2 -0
- package/dist/core/storage/testing.d.ts.map +1 -1
- package/dist/core/storage/testing.js +45 -0
- package/dist/core/storage/testing.js.map +1 -1
- package/dist/core/tasks/completion.d.ts.map +1 -1
- package/dist/core/tasks/completion.js +2 -4
- package/dist/core/tasks/completion.js.map +1 -1
- package/dist/core/tools/bash-session-environment.d.ts.map +1 -1
- package/dist/core/tools/bash-session-environment.js +0 -2
- package/dist/core/tools/bash-session-environment.js.map +1 -1
- package/dist/core/tools/todos-model.js +3 -3
- package/dist/core/tools/todos-model.js.map +1 -1
- package/dist/core/tools/todos-mutations.js +2 -2
- package/dist/core/tools/todos-mutations.js.map +1 -1
- package/dist/core/tools/todos-render.js +1 -1
- package/dist/core/tools/todos-render.js.map +1 -1
- package/dist/core/tools/todos-storage.js +2 -2
- package/dist/core/tools/todos-storage.js.map +1 -1
- package/dist/extensions/codemode/execute.js +1 -1
- package/dist/extensions/codemode/execute.js.map +1 -1
- package/dist/extensions/codemode/tool.d.ts +1 -1
- package/dist/extensions/codemode/tool.d.ts.map +1 -1
- package/dist/extensions/codemode/tool.js.map +1 -1
- package/dist/extensions/herdr/index.d.ts.map +1 -1
- package/dist/extensions/herdr/index.js +1 -5
- package/dist/extensions/herdr/index.js.map +1 -1
- package/dist/extensions/mcp/index.js +1 -1
- package/dist/extensions/mcp/index.js.map +1 -1
- package/dist/extensions/mcp/tools.d.ts.map +1 -1
- package/dist/extensions/mcp/tools.js +6 -1
- package/dist/extensions/mcp/tools.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/main-session.d.ts +7 -1
- package/dist/main-session.d.ts.map +1 -1
- package/dist/main-session.js +86 -52
- package/dist/main-session.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +51 -30
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host.js +1 -0
- package/dist/modes/interactive/components/chat-session-host.js.map +1 -1
- package/dist/modes/interactive/components/extension-input.d.ts +1 -1
- package/dist/modes/interactive/components/extension-input.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-input.js +2 -2
- package/dist/modes/interactive/components/extension-input.js.map +1 -1
- package/dist/modes/interactive/components/host-session-picker.js +1 -1
- package/dist/modes/interactive/components/host-session-picker.js.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.js +4 -1
- package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
- package/dist/modes/interactive/components/session-selector-list.d.ts +9 -6
- package/dist/modes/interactive/components/session-selector-list.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector-list.js +15 -14
- package/dist/modes/interactive/components/session-selector-list.js.map +1 -1
- package/dist/modes/interactive/components/session-selector.d.ts +7 -4
- package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector.js +12 -14
- package/dist/modes/interactive/components/session-selector.js.map +1 -1
- package/dist/modes/interactive/components/tree-selector-component.d.ts +5 -1
- package/dist/modes/interactive/components/tree-selector-component.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector-component.js +20 -3
- package/dist/modes/interactive/components/tree-selector-component.js.map +1 -1
- package/dist/modes/interactive/interactive-bash-compact.js +1 -1
- package/dist/modes/interactive/interactive-bash-compact.js.map +1 -1
- package/dist/modes/interactive/interactive-deferred-startup.js +2 -2
- package/dist/modes/interactive/interactive-deferred-startup.js.map +1 -1
- package/dist/modes/interactive/interactive-editor-actions.js +2 -2
- package/dist/modes/interactive/interactive-editor-actions.js.map +1 -1
- package/dist/modes/interactive/interactive-extension-runtime.js +2 -0
- package/dist/modes/interactive/interactive-extension-runtime.js.map +1 -1
- package/dist/modes/interactive/interactive-input-handling.js +6 -4
- package/dist/modes/interactive/interactive-input-handling.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-helpers.js +1 -1
- package/dist/modes/interactive/interactive-mode-helpers.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-surface.d.ts +5 -5
- package/dist/modes/interactive/interactive-mode-surface.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-surface.js.map +1 -1
- package/dist/modes/interactive/interactive-model-routing.js +12 -7
- package/dist/modes/interactive/interactive-model-routing.js.map +1 -1
- package/dist/modes/interactive/interactive-selectors.js +2 -2
- package/dist/modes/interactive/interactive-selectors.js.map +1 -1
- package/dist/modes/interactive/interactive-session-routing.js +24 -12
- package/dist/modes/interactive/interactive-session-routing.js.map +1 -1
- package/dist/modes/interactive/interactive-slash-commands.js +2 -2
- package/dist/modes/interactive/interactive-slash-commands.js.map +1 -1
- package/dist/modes/interactive-engine/engine-args.d.ts.map +1 -1
- package/dist/modes/interactive-engine/engine-args.js +7 -4
- package/dist/modes/interactive-engine/engine-args.js.map +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.d.ts +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.d.ts.map +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.js +90 -71
- package/dist/modes/interactive-engine/isolated-runtime.js.map +1 -1
- package/dist/modes/rpc/rpc-bash-request-owners.js +1 -1
- package/dist/modes/rpc/rpc-bash-request-owners.js.map +1 -1
- package/dist/modes/rpc/rpc-client-api.d.ts +1 -1
- package/dist/modes/rpc/rpc-client-api.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client-api.js +2 -2
- package/dist/modes/rpc/rpc-client-api.js.map +1 -1
- package/dist/modes/rpc/rpc-client-process.d.ts +2 -2
- package/dist/modes/rpc/rpc-client-process.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client-process.js +18 -7
- package/dist/modes/rpc/rpc-client-process.js.map +1 -1
- package/dist/modes/rpc/rpc-client.d.ts +4 -1
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +6 -2
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/modes/rpc/rpc-command-handler.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-command-handler.js +11 -8
- package/dist/modes/rpc/rpc-command-handler.js.map +1 -1
- package/dist/modes/rpc/rpc-provider-auth.js +2 -2
- package/dist/modes/rpc/rpc-provider-auth.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +6 -2
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/docs/custom-provider/oauth.md +2 -2
- package/docs/custom-provider/override.md +3 -3
- package/docs/custom-provider/registration.md +7 -7
- package/docs/custom-provider/streaming.md +1 -1
- package/docs/custom-provider.md +5 -5
- package/docs/environment-variables.md +5 -1
- package/docs/extensions/api-reference.md +40 -19
- package/docs/extensions/authoring.md +1 -1
- package/docs/extensions/events.md +8 -8
- package/docs/extensions.md +2 -2
- package/docs/getting-started/installation.md +1 -2
- package/docs/providers.md +2 -2
- package/docs/quickstart.md +2 -1
- package/docs/reference/cli.md +3 -3
- package/docs/rpc/protocol.md +10 -4
- package/docs/sdk/reference.md +15 -13
- package/docs/sdk/web-server.md +5 -6
- package/docs/sdk.md +18 -1
- package/docs/session-format.md +7 -5
- package/docs/sessions.md +11 -2
- package/docs/settings.md +17 -2
- package/docs/storage.md +262 -1
- package/docs/usage.md +3 -2
- package/docs/workflows/api-reference.md +67 -11
- package/docs/workflows/operations.md +4 -2
- package/examples/extensions/bookmark.ts +2 -2
- package/examples/extensions/handoff.ts +2 -2
- package/examples/extensions/plan-mode/index.ts +15 -13
- package/examples/extensions/preset.ts +8 -8
- package/examples/extensions/session-name.ts +1 -1
- package/examples/extensions/snake.ts +3 -1
- package/examples/extensions/space-invaders.ts +3 -1
- package/examples/extensions/tic-tac-toe.ts +80 -80
- package/examples/sdk/11-sessions.ts +5 -5
- package/examples/sdk/13-session-runtime.ts +7 -7
- package/examples/sdk/README.md +1 -1
- package/npm-shrinkwrap.json +32 -32
- package/package.json +3 -3
- package/schemas/settings.schema.json +1 -22
- package/dist/builtin/workflows/builtin/chunk-h5fn47y5.js +0 -8
- package/dist/builtin/workflows/src/durable/journal/node-sqlite.d.ts +0 -20
package/docs/sdk.md
CHANGED
|
@@ -232,6 +232,23 @@ Web provider configuration caches are session-local. Configuration discovery and
|
|
|
232
232
|
|
|
233
233
|
`session.sessionSummary` returns the current branch's latest `SessionSummaryEntry`, or `undefined` when none is available. Read `summary` for the generated text and `summarizedThroughId` for the last message it describes. `SessionManager.list()` and `SessionManager.listAll()` expose those same fields on each `SessionInfo`. Stored summaries remain readable when `sessionSummary.enabled` is false; that setting controls generation only.
|
|
234
234
|
|
|
235
|
+
### Workflow journal selection
|
|
236
|
+
|
|
237
|
+
Standalone workflow `run()` accepts `RunOpts.journal` to choose a local SQLite file, a caller-owned connection, process-local memory, or a supplied `RunJournal`:
|
|
238
|
+
|
|
239
|
+
```typescript
|
|
240
|
+
import { run } from "@bastani/atomic/workflows";
|
|
241
|
+
|
|
242
|
+
await run(myWorkflow, inputs, { journal: { path: "./workflow-runs.sqlite" } });
|
|
243
|
+
await run(myWorkflow, inputs, { journal: { memory: true } });
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
Use `{ database }` for an existing `node:sqlite` `DatabaseSync`; Atomic does not close that connection. A supplied `RunJournal` is used as-is. Memory is an explicit opt-in for tests or ephemeral runs and cannot recover runs after the process exits.
|
|
247
|
+
|
|
248
|
+
Custom journals implement the full `RunJournal` interface, including `deleteOwnedRun(lease, expectSeq?)` for atomic lease-fenced deletion with an optional sequence check. A stale lease rejects with `StaleLeaseError` without deleting the successor's data. Open a facade-backed journal with `await SqlRunJournal.open(database, { prefix })`, or use `await openSqlRunJournal(pathOrDatabase?)` for the node adapter. Validate custom journals with `registerRunJournalConformance`; see [Choosing the durable backend](/workflows/api-reference#choosing-the-durable-backend).
|
|
249
|
+
|
|
250
|
+
Without a per-run option, a non-empty `ATOMIC_WORKFLOW_JOURNAL_PATH` overrides `workflows.journal.path` or `workflows.journal.memory` in settings. Relative settings paths resolve against the Atomic home directory. The default file is `~/.atomic/workflows/journal.sqlite`. Keep the original journal and working directory to resume saved runs. Storage failures reject the action rather than switching to memory. See [Workflow storage settings](/settings#workflow-storage).
|
|
251
|
+
|
|
235
252
|
### Workflow run control
|
|
236
253
|
|
|
237
254
|
`session.workflows` controls this session's runs without slash commands or the model-facing `workflow` tool. A fresh session can inspect a durable root by its full UUID within the same working directory and journal. Inspection stays read-only and does not add the run to `listRuns()`.
|
|
@@ -538,7 +555,7 @@ const createRuntime: CreateAgentSessionRuntimeFactory = async ({ cwd, sessionMan
|
|
|
538
555
|
const runtime = await createAgentSessionRuntime(createRuntime, {
|
|
539
556
|
cwd: process.cwd(),
|
|
540
557
|
agentDir: getAgentDir(),
|
|
541
|
-
sessionManager: SessionManager.create(process.cwd()),
|
|
558
|
+
sessionManager: await SessionManager.create(process.cwd()),
|
|
542
559
|
});
|
|
543
560
|
```
|
|
544
561
|
|
package/docs/session-format.md
CHANGED
|
@@ -5,7 +5,7 @@ Sessions are stored as JSONL (JSON Lines) files. Each line is a JSON object with
|
|
|
5
5
|
## File Location
|
|
6
6
|
|
|
7
7
|
```
|
|
8
|
-
~/.atomic/agent/sessions/--<path>--/<timestamp>_<
|
|
8
|
+
~/.atomic/agent/sessions/--<path>--/<timestamp>_<session-id-hash>.jsonl
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
Where `<path>` is the working directory with `/` replaced by `-`.
|
|
@@ -194,22 +194,22 @@ interface SessionEntryBase {
|
|
|
194
194
|
|
|
195
195
|
### SessionHeader
|
|
196
196
|
|
|
197
|
-
First line of the file. Metadata only, not
|
|
197
|
+
First line of the file. Metadata only, not a tree entry. Its `id` identifies the session; it has no `parentId`.
|
|
198
198
|
|
|
199
199
|
```json
|
|
200
|
-
{"type":"session","version":4,"id":"uuid","
|
|
200
|
+
{"type":"session","version":4,"id":"uuid","createdAt":"2024-12-03T14:00:00.000Z","cwd":"/path/to/project"}
|
|
201
201
|
```
|
|
202
202
|
|
|
203
203
|
For sessions with a parent (created via `/fork`, `/clone`, or `newSession({ parentSession })`):
|
|
204
204
|
|
|
205
205
|
```json
|
|
206
|
-
{"type":"session","version":4,"id":"uuid","
|
|
206
|
+
{"type":"session","version":4,"id":"uuid","createdAt":"2024-12-03T14:00:00.000Z","cwd":"/path/to/project","parentSessionId":"original-session-id"}
|
|
207
207
|
```
|
|
208
208
|
|
|
209
209
|
Workflow-owned sessions carry both `internal: true` and complete `workflow` linkage. Atomic writes this classification before the transcript becomes visible wherever possible, including workflow stage forks and fresh/forked subagents. A session is excluded from normal resume history only when `internal` is the exact boolean `true` and `workflow.runId`, `workflow.stageId`, and `workflow.stageName` are all non-empty strings:
|
|
210
210
|
|
|
211
211
|
```json
|
|
212
|
-
{"type":"session","version":4,"id":"uuid","
|
|
212
|
+
{"type":"session","version":4,"id":"uuid","createdAt":"2024-12-03T14:00:00.000Z","cwd":"/path/to/project","internal":true,"workflow":{"runId":"run-1","stageId":"stage-build","stageName":"build"}}
|
|
213
213
|
```
|
|
214
214
|
|
|
215
215
|
Malformed, incomplete, workflow-only, or truthy non-boolean legacy markers remain visible in normal history. Atomic does not infer workflow ownership from `parentSession`, so ordinary user-created forks are unaffected. Valid workflow classification is inherited when an internal workflow transcript is branched or forked.
|
|
@@ -425,6 +425,8 @@ for (const line of lines) {
|
|
|
425
425
|
|
|
426
426
|
Key methods for working with sessions programmatically.
|
|
427
427
|
|
|
428
|
+
Await `create`, `open`, `continueRecent`, `forkFrom`, and all session mutations. A resolved mutation has committed to its store; a failed write rejects with its typed storage error without publishing the failed entry. There is no `flush` method. `inMemory()` explicitly selects memory and performs no filesystem I/O. Other factories use persistent JSONL storage by default and never fall back to memory if it cannot be opened.
|
|
429
|
+
|
|
428
430
|
### Static Creation Methods
|
|
429
431
|
|
|
430
432
|
- `SessionManager.create(cwd, sessionDir?, options?)` - New session. Workflow-owned sessions require the pair `internal: true` and `workflow: { runId, stageId, stageName }`.
|
package/docs/sessions.md
CHANGED
|
@@ -17,14 +17,21 @@ atomic -c # Continue most recent session
|
|
|
17
17
|
atomic -r # Browse and select from past sessions
|
|
18
18
|
atomic --no-session # Ephemeral mode; do not save
|
|
19
19
|
atomic --name "my task" # Set session display name at startup
|
|
20
|
-
atomic --session <
|
|
21
|
-
atomic --
|
|
20
|
+
atomic --session <id|prefix> # Use an exact ID or unique 8-hex UUID prefix
|
|
21
|
+
atomic --import <file> # Import a format-4 JSONL export into session storage
|
|
22
|
+
atomic --fork <id|prefix> # Fork an exact ID or unique 8-hex UUID prefix
|
|
22
23
|
```
|
|
23
24
|
|
|
24
25
|
Use `/session` in interactive mode to see the current session file, session ID, message count, tokens, and cost. You can use it while a run is active; its totals update after each completed message, not each streaming text chunk. Detailed cost and cache-waste breakdowns are shown after the run finishes only when the available session history matches those totals; otherwise, only the total cost is shown.
|
|
25
26
|
|
|
26
27
|
For UUID-backed sessions, `--session` and `--fork` accept either the full UUID or exactly eight hexadecimal prefix characters. A prefix must be unique within the current project (or, if no local session matches, across the global session store); collisions list the matching UUIDs and require the full value. Exact custom session IDs keep their existing priority. `--session-id` remains an exact project-local ID used to open or create a session, not a prefix selector.
|
|
27
28
|
|
|
29
|
+
Session locations are for display, not selection. Use `--import <file>` or `/import <file>` to copy a format-4 JSONL export into the selected store. The session ID and entries are preserved. An ID already present in that store raises `SessionExistsError`; importing never replaces an existing session. Older session formats are not accepted.
|
|
30
|
+
|
|
31
|
+
Use `atomic --no-session --import <file>` to work with an imported conversation without saving it. `--import` cannot be combined with `--session`, `--fork`, `--session-id`, `--continue`, or `--resume`; choose one way to select the conversation. `--session-dir` remains available when importing into a persistent store.
|
|
32
|
+
|
|
33
|
+
Imported IDs are kept verbatim, including an empty ID. Resume an imported empty ID with `atomic --session ""` or choose its row in the session picker. Picker actions stay bound to the selected project's store even when another project uses the same ID.
|
|
34
|
+
|
|
28
35
|
### Custom session directories
|
|
29
36
|
|
|
30
37
|
Use `--session-dir <dir>`, `ATOMIC_CODING_AGENT_SESSION_DIR`, or the matching settings override to save the active chat outside `~/.atomic/agent/sessions/`.
|
|
@@ -137,6 +144,8 @@ Example shape:
|
|
|
137
144
|
|
|
138
145
|
Filter modes are: default, no-tools, user-only, labeled-only, and all. Configure the default with `treeFilterMode` in [Settings](/settings).
|
|
139
146
|
|
|
147
|
+
Label edits are saved before the tree is updated. While a save is pending, the label editor stays open. If saving fails, Atomic displays the error and keeps your text so you can retry with Enter or cancel with Escape.
|
|
148
|
+
|
|
140
149
|
### Selection Behavior
|
|
141
150
|
|
|
142
151
|
Selecting a user or custom message:
|
package/docs/settings.md
CHANGED
|
@@ -555,9 +555,24 @@ Arrays support glob patterns and exclusions. Use `!pattern` to exclude. Use `+pa
|
|
|
555
555
|
|
|
556
556
|
#### Workflow storage
|
|
557
557
|
|
|
558
|
-
Workflow runs use a local SQLite journal at `~/.atomic/workflows/journal.sqlite`. Set `
|
|
558
|
+
Workflow runs use a local SQLite journal at `~/.atomic/workflows/journal.sqlite`. Set `workflows.journal.path` in `settings.json` to choose another file:
|
|
559
559
|
|
|
560
|
-
|
|
560
|
+
```json
|
|
561
|
+
{
|
|
562
|
+
"workflows": {
|
|
563
|
+
"paths": ["./workflows"],
|
|
564
|
+
"journal": { "path": "workflows/project.sqlite" }
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
```
|
|
568
|
+
|
|
569
|
+
Relative settings paths resolve against the Atomic home directory, normally `~/.atomic`, not the project directory. A non-empty `ATOMIC_WORKFLOW_JOURNAL_PATH` overrides the settings path. SDK `RunOpts.journal` takes precedence over both. Empty environment and settings paths leave the next source in effect.
|
|
570
|
+
|
|
571
|
+
To keep workflow records only in memory, set `"journal": { "memory": true }`. Do not combine `memory: true` with a non-empty `path`. Memory must be selected explicitly and cannot recover runs after the process exits; an environment path still takes precedence over this setting.
|
|
572
|
+
|
|
573
|
+
Project `workflows.journal` replaces the global journal block as a whole. For example, a project can select `{ "memory": true }` over a global path, or a project path over global memory. Within either settings file, combining `memory: true` with a non-empty `path` is still an error.
|
|
574
|
+
|
|
575
|
+
Changing the journal selects a different run history. Preserve the original file to inspect or resume its runs. Storage needs no separate server. If the selected journal cannot be opened or written, the action fails with a typed storage error rather than selecting memory. Restore filesystem access and inspect the retained run before retrying. See [Durable workflows](/workflows/operations#durable-workflows-and-cross-session-resume).
|
|
561
576
|
|
|
562
577
|
#### packages
|
|
563
578
|
|
package/docs/storage.md
CHANGED
|
@@ -21,12 +21,271 @@ try {
|
|
|
21
21
|
|
|
22
22
|
The node adapter creates parent directories and enables WAL, full synchronization, and foreign keys. Its busy timeout defaults to 5000 ms; override it with `openNodeSqliteDatabase(path, { busyTimeoutMs: 1000 })`. Use `:memory:` for an ephemeral database.
|
|
23
23
|
|
|
24
|
+
Transactions from separate `openNodeSqliteDatabase` connections to the same file queue asynchronously within one process; symlink paths refer to the same queue. Separate in-memory databases remain independent. SQLite locking and the busy timeout still govern contention from other processes. Wrap a caller-owned connection consistently: its transaction queue is shared by wrappers of that connection, not by other connections to its file.
|
|
25
|
+
|
|
26
|
+
Use `wrapNodeSqliteDatabase(connection)` to adapt an existing `node:sqlite` `DatabaseSync`. Closing that facade drains its accepted work but leaves your connection open. Route concurrent work through the same facade rather than issuing raw connection commands while a facade transaction is active.
|
|
27
|
+
|
|
24
28
|
Use only the supplied transaction handle inside a transaction callback. Calling the database itself there waits behind the transaction and deadlocks. Keep callbacks short and await only handle operations. A rejected callback rolls back and preserves the rejection. A failed commit rolls back and rejects with `StorageUnavailableError`. Handles expire after their callbacks settle. Other database operations execute in call order. `close()` drains accepted work, releases the database files, and is idempotent; new calls after closing begins reject with `StoreClosedError`.
|
|
25
29
|
|
|
26
30
|
Errors are exported classes with typed fields. `StorageUnavailableError` provides `adapter`, `location`, and `cause`; stop using the affected store after this error. `StorageRollbackError` retains the original `cause` and `rollbackCause` when rollback also fails. Do not assume that transaction rolled back. Branch on error classes rather than message text.
|
|
27
31
|
|
|
28
32
|
String bindings containing U+0000 are rejected before SQL executes with `StorageInvalidTextError`. Its `parameterIndex` is zero-based and its `reason` is `"nul-character"`. This rule applies to database calls and transaction handles. Store JSON with `JSON.stringify`, which escapes NUL characters, or use `Uint8Array` for binary data containing zero bytes. This validation does not inspect SQL source or SQL-generated values.
|
|
29
33
|
|
|
34
|
+
## Bring your own driver
|
|
35
|
+
|
|
36
|
+
Atomic does not bundle remote database drivers. Install your chosen SQLite-compatible driver in your own project and wrap it as a `SqliteDatabase` from `@bastani/atomic/storage`. The interface consists of a diagnostic `descriptor`, async `exec`, `run`, `get`, `all`, `transaction(callback)`, and `close()` methods, with the return values and transaction-handle rules described above.
|
|
37
|
+
|
|
38
|
+
A wrapper must queue database operations in call order, keeping unrelated calls outside active transactions. Reject NUL text with `StorageInvalidTextError`, snapshot binary parameters before queueing, and normalize returned integers and blobs. Use `StorageUnavailableError` for driver failures, preserve callback failures, and report failed rollbacks with `StorageRollbackError`. Expire transaction handles after their callback settles. On close, reject new calls, drain accepted work, and release driver resources. Do not include credentials in diagnostics or fall back to memory after an opening failure.
|
|
39
|
+
|
|
40
|
+
### libSQL / Turso example
|
|
41
|
+
|
|
42
|
+
Install `@libsql/client` separately. Save the complete wrapper below as `storage-libsql-wrapper.ts` in your project. It accepts caller-provided credentials only. For a local file, create its parent directory first; no network or credentials are needed.
|
|
43
|
+
|
|
44
|
+
```ts
|
|
45
|
+
import type { SqliteDatabase } from "@bastani/atomic/storage";
|
|
46
|
+
import { openLibsqlDatabase } from "./storage-libsql-wrapper.js";
|
|
47
|
+
|
|
48
|
+
const database: SqliteDatabase = await openLibsqlDatabase({ url: "file:./data.sqlite" });
|
|
49
|
+
// For Turso instead: { url: "libsql://your-database.turso.io", authToken: token }
|
|
50
|
+
try {
|
|
51
|
+
await database.exec("CREATE TABLE IF NOT EXISTS notes (text TEXT)");
|
|
52
|
+
await database.transaction(async (tx) => {
|
|
53
|
+
await tx.run("INSERT INTO notes VALUES (?)", "hello");
|
|
54
|
+
});
|
|
55
|
+
const notes = await database.all("SELECT text FROM notes");
|
|
56
|
+
} finally {
|
|
57
|
+
await database.close();
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
The returned value can be passed to your own SDK application code that accepts `SqliteDatabase`. This does not select a custom driver for Atomic sessions or workflow runs.
|
|
62
|
+
|
|
63
|
+
<details>
|
|
64
|
+
<summary>Complete wrapper</summary>
|
|
65
|
+
|
|
66
|
+
{/* custom-driver-example */}
|
|
67
|
+
```ts
|
|
68
|
+
import type { Client, ResultSet, Row, Transaction } from "@libsql/client";
|
|
69
|
+
import {
|
|
70
|
+
type SqliteDatabase,
|
|
71
|
+
type SqliteExecutor,
|
|
72
|
+
type SqliteRow,
|
|
73
|
+
type SqliteValue,
|
|
74
|
+
type StorageDescriptor,
|
|
75
|
+
StorageAdapterLoadError,
|
|
76
|
+
StorageError,
|
|
77
|
+
type StorageFailureCause,
|
|
78
|
+
StorageInvalidTextError,
|
|
79
|
+
StorageRollbackError,
|
|
80
|
+
StorageTransactionClosedError,
|
|
81
|
+
StorageUnavailableError,
|
|
82
|
+
StoreClosedError,
|
|
83
|
+
} from "@bastani/atomic/storage";
|
|
84
|
+
|
|
85
|
+
export interface LibsqlDatabaseOptions {
|
|
86
|
+
url: string;
|
|
87
|
+
authToken?: string;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function credentialRedactor(options: LibsqlDatabaseOptions): (text: string) => string {
|
|
91
|
+
const secrets = [options.authToken ?? ""];
|
|
92
|
+
for (const match of options.url.matchAll(/[?&]([^=&#]*)=([^&#]*)/g)) {
|
|
93
|
+
const token = new URLSearchParams(match[0].slice(1)).get("authToken");
|
|
94
|
+
if (token !== null) secrets.push(match[2] ?? "", token);
|
|
95
|
+
}
|
|
96
|
+
const userinfo = options.url.match(/\/\/([^/?#]*)@/)?.[1];
|
|
97
|
+
if (userinfo !== undefined) secrets.push(...userinfo.split(":"));
|
|
98
|
+
try {
|
|
99
|
+
const url = new URL(options.url);
|
|
100
|
+
secrets.push(url.username, url.password, ...url.searchParams.getAll("authToken"));
|
|
101
|
+
} catch {}
|
|
102
|
+
for (const secret of [...secrets]) {
|
|
103
|
+
try {
|
|
104
|
+
secrets.push(encodeURIComponent(secret));
|
|
105
|
+
secrets.push(decodeURIComponent(secret));
|
|
106
|
+
} catch {}
|
|
107
|
+
}
|
|
108
|
+
return (text) =>
|
|
109
|
+
secrets
|
|
110
|
+
.filter(Boolean)
|
|
111
|
+
.sort((first, second) => second.length - first.length)
|
|
112
|
+
.reduce((value, secret) => value.replaceAll(secret, "[redacted]"), text);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function redactCause(cause: StorageFailureCause, redact: (text: string) => string): StorageFailureCause {
|
|
116
|
+
if (typeof cause === "string") return redact(cause);
|
|
117
|
+
if (!(cause instanceof Error)) return cause;
|
|
118
|
+
const nested = cause.cause as StorageFailureCause;
|
|
119
|
+
const safeCause = redactCause(nested, redact);
|
|
120
|
+
const message = redact(cause.message);
|
|
121
|
+
const stack = cause.stack === undefined ? undefined : redact(cause.stack);
|
|
122
|
+
if (message === cause.message && stack === cause.stack && safeCause === nested) return cause;
|
|
123
|
+
const safe = new StorageError(message, { cause: safeCause });
|
|
124
|
+
safe.stack = stack;
|
|
125
|
+
return safe;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function normalizeRow(row: Row, columns: readonly string[]): SqliteRow {
|
|
129
|
+
return Object.fromEntries(
|
|
130
|
+
columns.map((key, index) => {
|
|
131
|
+
const value = row[index];
|
|
132
|
+
return [
|
|
133
|
+
key,
|
|
134
|
+
typeof value === "bigint" &&
|
|
135
|
+
value >= -BigInt(Number.MAX_SAFE_INTEGER) &&
|
|
136
|
+
value <= BigInt(Number.MAX_SAFE_INTEGER)
|
|
137
|
+
? Number(value)
|
|
138
|
+
: value instanceof ArrayBuffer
|
|
139
|
+
? new Uint8Array(value.slice(0))
|
|
140
|
+
: value,
|
|
141
|
+
];
|
|
142
|
+
}),
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
class LibsqlDatabase implements SqliteDatabase {
|
|
147
|
+
readonly descriptor: StorageDescriptor;
|
|
148
|
+
private readonly client: Client;
|
|
149
|
+
private readonly redact: (text: string) => string;
|
|
150
|
+
private tail: Promise<void> = Promise.resolve();
|
|
151
|
+
private closing = false;
|
|
152
|
+
private closePromise?: Promise<void>;
|
|
153
|
+
private readonly executor: SqliteExecutor;
|
|
154
|
+
|
|
155
|
+
constructor(client: Client, descriptor: StorageDescriptor, redact: (text: string) => string) {
|
|
156
|
+
this.client = client;
|
|
157
|
+
this.descriptor = descriptor;
|
|
158
|
+
this.redact = redact;
|
|
159
|
+
this.executor = this.createExecutor(client, () => true);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
private async driver<T>(operation: () => T | Promise<T>): Promise<T> {
|
|
163
|
+
try {
|
|
164
|
+
return await operation();
|
|
165
|
+
} catch (cause) {
|
|
166
|
+
throw new StorageUnavailableError(this.descriptor, redactCause(cause as StorageFailureCause, this.redact));
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
private createExecutor(connection: Client | Transaction, active: () => boolean): SqliteExecutor {
|
|
171
|
+
const execute = async <T>(operation: () => Promise<T>, params: readonly SqliteValue[] = []): Promise<T> => {
|
|
172
|
+
if (!active()) throw new StorageTransactionClosedError();
|
|
173
|
+
const invalidIndex = params.findIndex((value) => typeof value === "string" && value.includes("\0"));
|
|
174
|
+
if (invalidIndex !== -1) throw new StorageInvalidTextError(invalidIndex);
|
|
175
|
+
return this.driver(operation);
|
|
176
|
+
};
|
|
177
|
+
const statement = (sql: string, params: readonly SqliteValue[]): Promise<ResultSet> =>
|
|
178
|
+
connection.execute({
|
|
179
|
+
sql,
|
|
180
|
+
args: params.map((value) => (value instanceof Uint8Array ? new Uint8Array(value) : value)),
|
|
181
|
+
});
|
|
182
|
+
return {
|
|
183
|
+
exec: (sql) => execute(() => connection.executeMultiple(sql)),
|
|
184
|
+
run: (sql, ...params) =>
|
|
185
|
+
execute(async () => ({ changes: (await statement(sql, params)).rowsAffected }), params),
|
|
186
|
+
get: <T extends SqliteRow>(sql: string, ...params: readonly SqliteValue[]) =>
|
|
187
|
+
execute(async () => {
|
|
188
|
+
const result = await statement(sql, params);
|
|
189
|
+
const row = result.rows[0];
|
|
190
|
+
return row === undefined ? undefined : (normalizeRow(row, result.columns) as T);
|
|
191
|
+
}, params),
|
|
192
|
+
all: <T extends SqliteRow>(sql: string, ...params: readonly SqliteValue[]) =>
|
|
193
|
+
execute(async () => {
|
|
194
|
+
const result = await statement(sql, params);
|
|
195
|
+
return result.rows.map((row) => normalizeRow(row, result.columns) as T);
|
|
196
|
+
}, params),
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
private enqueue<T>(operation: () => Promise<T>): Promise<T> {
|
|
201
|
+
if (this.closing) return Promise.reject(new StoreClosedError(this.descriptor));
|
|
202
|
+
const result = this.tail.then(operation);
|
|
203
|
+
this.tail = result.then(
|
|
204
|
+
() => {},
|
|
205
|
+
() => {},
|
|
206
|
+
);
|
|
207
|
+
return result;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
exec(sql: string): Promise<void> {
|
|
211
|
+
return this.enqueue(() => this.executor.exec(sql));
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
run(sql: string, ...params: readonly SqliteValue[]) {
|
|
215
|
+
const bound = params.map((value) => (value instanceof Uint8Array ? new Uint8Array(value) : value));
|
|
216
|
+
return this.enqueue(() => this.executor.run(sql, ...bound));
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
get<T extends SqliteRow>(sql: string, ...params: readonly SqliteValue[]): Promise<T | undefined> {
|
|
220
|
+
const bound = params.map((value) => (value instanceof Uint8Array ? new Uint8Array(value) : value));
|
|
221
|
+
return this.enqueue(() => this.executor.get<T>(sql, ...bound));
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
all<T extends SqliteRow>(sql: string, ...params: readonly SqliteValue[]): Promise<T[]> {
|
|
225
|
+
const bound = params.map((value) => (value instanceof Uint8Array ? new Uint8Array(value) : value));
|
|
226
|
+
return this.enqueue(() => this.executor.all<T>(sql, ...bound));
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
transaction<T>(callback: (transaction: SqliteExecutor) => Promise<T>): Promise<T> {
|
|
230
|
+
return this.enqueue(async () => {
|
|
231
|
+
const connection = await this.driver(() => this.client.transaction("write"));
|
|
232
|
+
let active = true;
|
|
233
|
+
try {
|
|
234
|
+
const result = await callback(this.createExecutor(connection, () => active));
|
|
235
|
+
active = false;
|
|
236
|
+
await this.driver(() => connection.commit());
|
|
237
|
+
return result;
|
|
238
|
+
} catch (cause) {
|
|
239
|
+
active = false;
|
|
240
|
+
try {
|
|
241
|
+
await this.driver(() => connection.rollback());
|
|
242
|
+
} catch (rollbackCause) {
|
|
243
|
+
throw new StorageRollbackError(cause as StorageFailureCause, rollbackCause as StorageFailureCause);
|
|
244
|
+
}
|
|
245
|
+
throw cause;
|
|
246
|
+
} finally {
|
|
247
|
+
await this.driver(() => connection.close());
|
|
248
|
+
}
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
close(): Promise<void> {
|
|
253
|
+
if (!this.closePromise) {
|
|
254
|
+
this.closing = true;
|
|
255
|
+
this.closePromise = this.tail.then(() => this.driver(() => this.client.close()));
|
|
256
|
+
}
|
|
257
|
+
return this.closePromise;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
export async function openLibsqlDatabase(options: LibsqlDatabaseOptions): Promise<SqliteDatabase> {
|
|
262
|
+
const config = { url: options.url, authToken: options.authToken };
|
|
263
|
+
const redact = credentialRedactor(config);
|
|
264
|
+
const descriptor = { adapter: "libsql", location: redact(config.url) };
|
|
265
|
+
let createClient: typeof import("@libsql/client").createClient;
|
|
266
|
+
try {
|
|
267
|
+
({ createClient } = await import("@libsql/client"));
|
|
268
|
+
} catch (cause) {
|
|
269
|
+
throw new StorageAdapterLoadError("@libsql/client", redactCause(cause as StorageFailureCause, redact));
|
|
270
|
+
}
|
|
271
|
+
let client: Client | undefined;
|
|
272
|
+
try {
|
|
273
|
+
client = createClient({ ...config, intMode: "bigint" });
|
|
274
|
+
const database = new LibsqlDatabase(client, descriptor, redact);
|
|
275
|
+
await database.exec("PRAGMA foreign_keys = ON");
|
|
276
|
+
return database;
|
|
277
|
+
} catch (cause) {
|
|
278
|
+
try {
|
|
279
|
+
client?.close();
|
|
280
|
+
} catch {}
|
|
281
|
+
throw new StorageUnavailableError(descriptor, redactCause(cause as StorageFailureCause, redact));
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
```
|
|
285
|
+
{/* /custom-driver-example */}
|
|
286
|
+
|
|
287
|
+
</details>
|
|
288
|
+
|
|
30
289
|
## Adapter conformance
|
|
31
290
|
|
|
32
291
|
Implement `SqliteDatabase` and run the exported suite from `@bastani/atomic/storage/testing`:
|
|
@@ -38,6 +297,8 @@ import { registerSqliteDatabaseConformance } from "@bastani/atomic/storage/testi
|
|
|
38
297
|
registerSqliteDatabaseConformance({ describe, it }, "my adapter", withSubject);
|
|
39
298
|
```
|
|
40
299
|
|
|
41
|
-
`withSubject` creates a fresh database for every case and calls the supplied callback with `{ database, reopen, withRollbackFailure }`. Clean up afterward, including on failure. `reopen()` closes and reopens the same persistent database and returns the new facade. `withRollbackFailure(error, callback)` injects a driver rollback failure only while running the callback, then restores normal behavior.
|
|
300
|
+
`withSubject` creates a fresh database for every case and calls the supplied callback with `{ database, reopen, withRollbackFailure }`. Clean up afterward, including on failure. `reopen()` closes and reopens the same persistent database and returns the new facade. `withRollbackFailure(error, callback)` injects a driver rollback failure only while running the callback, then restores normal behavior. Run the full suite against a persistent local database: it covers bindings, exact integers, binary snapshots, NUL rejection, transaction ordering and handle lifetime, commit/rollback failures, reopening, and close semantics.
|
|
301
|
+
|
|
302
|
+
For adapters supporting multiple connections to one database, also run `registerSqliteConnectionConformance({ describe, it }, "my adapter connections", withConnections)`. The fixture must open two facades on the same fresh database, pass both to the callback, and close both afterward. This checks concurrent transaction writes and event-loop responsiveness while one callback yields.
|
|
42
303
|
|
|
43
304
|
`validateStoragePrefix(prefix)` accepts an empty prefix or ASCII letters/underscores followed by ASCII letters, digits, or underscores. It rejects names beginning with `sqlite_`, regardless of case. Validate before opening files. `renderStorageIdentifiers(domain, names, prefix)` returns an immutable name map with `wf_` for `journal` or `session_` for `sessions`. `assertStorageSchemaVersion(domain, found, supported)` rejects a mismatched stored version without changing it.
|
package/docs/usage.md
CHANGED
|
@@ -122,10 +122,11 @@ Sessions are saved automatically to `~/.atomic/agent/sessions/`, organized by wo
|
|
|
122
122
|
atomic -c # Continue most recent session
|
|
123
123
|
atomic -r # Browse and select a session
|
|
124
124
|
atomic --no-session # Ephemeral mode; do not save
|
|
125
|
-
atomic --session <
|
|
125
|
+
atomic --session <id|prefix> # Use an exact ID or unique 8-hex UUID prefix
|
|
126
|
+
atomic --import <file> # Import a format-4 JSONL export into session storage
|
|
126
127
|
atomic --session-id <id> # Use/create an exact project-local session ID
|
|
127
128
|
atomic --name "Refactor" # Set the session display name
|
|
128
|
-
atomic --fork <
|
|
129
|
+
atomic --fork <id|prefix> # Fork an exact ID or unique 8-hex UUID prefix
|
|
129
130
|
```
|
|
130
131
|
|
|
131
132
|
When `--session-id` does not match an exact session in the current project, Atomic warns that no session was found and then creates the requested new session. Reusing an existing exact ID opens it without that warning.
|
|
@@ -1264,7 +1264,7 @@ Executes a compiled definition programmatically with validated inputs. Empty-inp
|
|
|
1264
1264
|
|
|
1265
1265
|
#### Stage sessions and adapters
|
|
1266
1266
|
|
|
1267
|
-
When `opts.adapters` supplies neither `agentSession` nor `prompt`, `run()` uses `createAgentSessionAdapter({ cwd: opts.cwd })`. Each stage then runs its own in-process Atomic `createAgentSession` session with
|
|
1267
|
+
When `opts.adapters` supplies neither `agentSession` nor `prompt`, `run()` uses `createAgentSessionAdapter({ cwd: opts.cwd })`. Each stage then runs its own in-process Atomic `createAgentSession` session with persistent session storage by default. Use the stage's `sessionDir` to choose its session directory, or supply an explicitly selected in-memory session manager through a custom adapter for ephemeral stages. A persistent storage failure fails stage creation; it never falls back to memory. Stage sessions resolve models, credentials, settings, and resources the same way `createAgentSession` does. A `prompt` adapter on its own answers stage prompts itself, so `run()` adds no default session adapter beside it.
|
|
1268
1268
|
|
|
1269
1269
|
```typescript
|
|
1270
1270
|
function createAgentSessionAdapter(
|
|
@@ -1286,7 +1286,7 @@ A custom adapter's `create(options, meta)` receives the stage's session options,
|
|
|
1286
1286
|
```ts
|
|
1287
1287
|
import { createAgentSessionAdapter, run } from "@bastani/atomic/workflows";
|
|
1288
1288
|
|
|
1289
|
-
// Default: in-process stage sessions with
|
|
1289
|
+
// Default: in-process stage sessions with persistent session storage.
|
|
1290
1290
|
await run(helloWorld, { name: "Atomic" }, { cwd: process.cwd() });
|
|
1291
1291
|
|
|
1292
1292
|
// Shared options for every stage.
|
|
@@ -1331,7 +1331,7 @@ interface RunOpts {
|
|
|
1331
1331
|
readonly signal?: AbortSignal;
|
|
1332
1332
|
readonly deferWorkflowStart?: boolean;
|
|
1333
1333
|
readonly config?: WorkflowRuntimeConfig;
|
|
1334
|
-
readonly
|
|
1334
|
+
readonly journal?: { path: string } | { database: DatabaseSync } | { memory: true } | RunJournal;
|
|
1335
1335
|
readonly models?: WorkflowModelCatalogPort;
|
|
1336
1336
|
readonly registry?: WorkflowRegistry;
|
|
1337
1337
|
readonly depth?: number;
|
|
@@ -1362,22 +1362,78 @@ The public authoring declaration intentionally excludes runtime-only executor fi
|
|
|
1362
1362
|
#### Choosing the durable backend
|
|
1363
1363
|
|
|
1364
1364
|
```typescript
|
|
1365
|
-
type
|
|
1366
|
-
|
|
1367
|
-
|
|
1365
|
+
import type { DatabaseSync } from "node:sqlite";
|
|
1366
|
+
import type { RunJournal } from "@bastani/atomic/workflows";
|
|
1367
|
+
|
|
1368
|
+
type JournalOption = { path: string } | { database: DatabaseSync } | { memory: true } | RunJournal;
|
|
1369
|
+
```
|
|
1370
|
+
|
|
1371
|
+
`run()` uses a local SQLite journal by default and releases the run's lease when execution settles. Select a journal with `RunOpts.journal`:
|
|
1372
|
+
|
|
1373
|
+
- `{ path }` opens that SQLite file.
|
|
1374
|
+
- `{ database }` uses a caller-owned `node:sqlite` connection. Atomic initializes the journal schema on it but does not close the connection.
|
|
1375
|
+
- `{ memory: true }` explicitly selects `MemoryRunJournal`. Records last only for the process and cannot recover runs after exit.
|
|
1376
|
+
- A `RunJournal` instance is used as supplied. `SqlRunJournal`, `openSqlRunJournal`, `MemoryRunJournal`, journal error classes, and `registerRunJournalConformance` are exported from `@bastani/atomic/workflows`.
|
|
1377
|
+
|
|
1378
|
+
Use `await openSqlRunJournal(path)` to open a file directly, or omit `path` for the default journal. It also accepts a caller-owned `DatabaseSync`. `await resolveRunJournal(options)` applies the selection rules below.
|
|
1379
|
+
|
|
1380
|
+
To attach your own SQLite-compatible driver, implement the [async SQLite storage API](/storage) and pass its facade to `SqlRunJournal.open`:
|
|
1381
|
+
|
|
1382
|
+
```ts
|
|
1383
|
+
import { openNodeSqliteDatabase } from "@bastani/atomic/storage";
|
|
1384
|
+
import { SqlRunJournal, run } from "@bastani/atomic/workflows";
|
|
1385
|
+
|
|
1386
|
+
const database = await openNodeSqliteDatabase("./shared.sqlite");
|
|
1387
|
+
const journal = await SqlRunJournal.open(database, { prefix: "project_" });
|
|
1388
|
+
try {
|
|
1389
|
+
await run(helloWorld, { name: "Atomic" }, { journal });
|
|
1390
|
+
} finally {
|
|
1391
|
+
await journal.close();
|
|
1392
|
+
await database.close();
|
|
1393
|
+
}
|
|
1368
1394
|
```
|
|
1369
1395
|
|
|
1370
|
-
`
|
|
1396
|
+
`SqlRunJournal.open` leaves ownership of the facade with you. Journal tables use `wf_` names, optionally preceded by your prefix; session tables use a separate namespace in the same database. A new prefix selects an empty journal, not a migration. Bare journal table names from earlier unreleased builds are not read. SQL event and lease timestamps, including expiry checks, use the database clock. Journal storage failures expose `StorageUnavailableError.adapter`, `.location`, and `.cause`; use `.location` rather than `.path`.
|
|
1397
|
+
|
|
1398
|
+
Custom journals implement this full async interface. The named types are exported from `@bastani/atomic/workflows`:
|
|
1399
|
+
|
|
1400
|
+
```ts
|
|
1401
|
+
interface RunJournal {
|
|
1402
|
+
createRun(header: RunHeader): Promise<"created" | "exists">;
|
|
1403
|
+
getRun(runId: string): Promise<RunSummary | undefined>;
|
|
1404
|
+
listRuns(filter?: { cwd?: string }): Promise<readonly RunSummary[]>;
|
|
1405
|
+
acquire(runId: string, holderId: string): Promise<LeaseOutcome>;
|
|
1406
|
+
takeover(runId: string, holderId: string, expectedHolder: string): Promise<LeaseOutcome>;
|
|
1407
|
+
takeoverExpired(runId: string, holderId: string, staleAfterMs: number): Promise<LeaseOutcome>;
|
|
1408
|
+
leaseState(runId: string): Promise<LeaseState | undefined>;
|
|
1409
|
+
renew(lease: Lease): Promise<void>;
|
|
1410
|
+
release(lease: Lease): Promise<void>;
|
|
1411
|
+
append(lease: Lease, event: RunEvent, options?: { key?: string; expectSeq?: number }): Promise<AppendOutcome>;
|
|
1412
|
+
read(runId: string, fromSeq?: number): AsyncIterable<JournalEntry>;
|
|
1413
|
+
readKey(runId: string, key: string): Promise<JournalEntry | undefined>;
|
|
1414
|
+
deleteOwnedRun(lease: Lease, expectSeq?: number): Promise<void>;
|
|
1415
|
+
deleteRun(runId: string): Promise<void>;
|
|
1416
|
+
close(): Promise<void>;
|
|
1417
|
+
}
|
|
1418
|
+
```
|
|
1419
|
+
|
|
1420
|
+
`getRun` returns the current summary or `undefined`. `leaseState` returns the current lease with its `renewedAt` timestamp and `ageMs`, or `undefined` when unheld. `ageMs` is the journal-clock time since renewal, computed in the same read and clamped to a non-negative safe integer. Use it for expiry decisions instead of subtracting `renewedAt` from the process clock. `takeoverExpired` measures a duration on the journal's clock and atomically refuses a foreign lease unless its renewal is strictly older than `staleAfterMs`, returning the `held` outcome while fresh. `read` loads bounded pages only as consumed, in sequence order starting at the inclusive `fromSeq`, which defaults to 1. Stopping iteration must stop further page reads.
|
|
1421
|
+
|
|
1422
|
+
`append` checks lease fencing first, then the idempotency key before `expectSeq`. A committed keyed retry returns `{ status: "exists", entry }` with the original entry even when the retry's sequence expectation is stale. A new key with a stale expectation rejects with `JournalCasConflictError` without writing.
|
|
1423
|
+
|
|
1424
|
+
`SqlRunJournal.append` serializes its payload once at invocation, before asynchronous lease and key checks, so later caller mutation cannot change the event. This invokes `toJSON` once even for a keyed duplicate, which still returns the original entry without writing. For `StatusChanged`, text validation and the run summary's status use the serialized payload, not the original object's status. Header and payload serialization failures retain their original cause in `StorageUnavailableError`; append reports such a failure only after the lease, key, and sequence checks above. A payload that cannot serialize has no status snapshot to validate, even if its original status contains invalid text.
|
|
1425
|
+
|
|
1426
|
+
`deleteOwnedRun` atomically deletes a run only while the lease's `runId`, `holderId`, and `epoch` still match; otherwise it rejects with `StaleLeaseError` and preserves the run and its events. An optional `expectSeq` must equal the latest sequence or the operation rejects with `JournalCasConflictError` without deleting anything. Deletion keeps the last epoch so an old lease cannot delete or write a recreated run. `deleteRun` is an unconditional administrative operation. Inputs and returned records must be detached. `close()` is idempotent, and every later operation rejects.
|
|
1371
1427
|
|
|
1372
|
-
|
|
1373
|
-
- **`{ mode: "memory" }`:** explicitly chooses state that lasts only for this call and cannot resume after process exit.
|
|
1428
|
+
Use `registerRunJournalConformance(runner, name, open, observeRead)` to check a fresh journal per case. Supply a read observer that reports actual page sizes and entries loaded or copied, with a `restore()` method, so the suite can verify lazy reads without consuming the whole history. Synchronous backend fast paths are internal and are not part of the custom-journal contract.
|
|
1374
1429
|
|
|
1375
|
-
|
|
1430
|
+
Precedence is `RunOpts.journal`, non-empty `ATOMIC_WORKFLOW_JOURNAL_PATH`, `workflows.journal.path` or `workflows.journal.memory`, then the default `~/.atomic/workflows/journal.sqlite`. Relative settings paths resolve against the Atomic home directory. Storage failures reject the call; Atomic never selects memory as a recovery step. Keep the same journal and working directory when resuming stored runs.
|
|
1376
1431
|
|
|
1377
1432
|
```ts
|
|
1378
1433
|
import { run } from "@bastani/atomic/workflows";
|
|
1379
1434
|
|
|
1380
|
-
await run(helloWorld, { name: "Atomic" }, {
|
|
1435
|
+
await run(helloWorld, { name: "Atomic" }, { journal: { path: "./workflow-runs.sqlite" } });
|
|
1436
|
+
await run(helloWorld, { name: "Atomic" }, { journal: { memory: true } });
|
|
1381
1437
|
```
|
|
1382
1438
|
|
|
1383
1439
|
### `resolveInputs(schema, provided)`
|
|
@@ -460,7 +460,7 @@ The readiness prompt can be answered in the attached stage UI or with `workflow(
|
|
|
460
460
|
|
|
461
461
|
Atomic workflows use a **local SQLite journal as their only persistent store**. It opens on the first workflow action and commits registrations, checkpoints, and control transitions before reporting them as durable. The default file is `~/.atomic/workflows/journal.sqlite`; set `ATOMIC_WORKFLOW_JOURNAL_PATH` before starting Atomic to select another file. Keep it on durable local storage. Storage failures stop the action rather than selecting another store.
|
|
462
462
|
|
|
463
|
-
|
|
463
|
+
Select process-local memory explicitly with `workflows.journal.memory: true` or SDK `RunOpts.journal: { memory: true }`. It supports checkpoint replay within the process but not recovery after exit. See [Choosing the durable backend](/workflows/api-reference#choosing-the-durable-backend).
|
|
464
464
|
|
|
465
465
|
### Storage failures and recovery
|
|
466
466
|
|
|
@@ -653,7 +653,9 @@ That history does not authorize any live release action.
|
|
|
653
653
|
|
|
654
654
|
### Configuring journal storage
|
|
655
655
|
|
|
656
|
-
Set `ATOMIC_WORKFLOW_JOURNAL_PATH` before starting Atomic to select a
|
|
656
|
+
Set `workflows.journal.path` in `settings.json` or set `ATOMIC_WORKFLOW_JOURNAL_PATH` before starting Atomic to select a local SQLite file. The non-empty environment value overrides settings; SDK `RunOpts.journal` overrides both. Relative settings paths resolve against the Atomic home directory, normally `~/.atomic`. With no override, Atomic uses `~/.atomic/workflows/journal.sqlite`.
|
|
657
|
+
|
|
658
|
+
For process-local storage, use `workflows.journal.memory: true` without a non-empty settings path, or pass `journal: { memory: true }` to SDK `run()`. Memory is never selected after a storage failure. Preserve a SQLite journal and its sidecar files; use the same journal and working directory to resume an existing run. See [Workflow storage settings](/settings#workflow-storage).
|
|
657
659
|
|
|
658
660
|
Pending-stage Intercom cleanup checks durable ownership only for runs with messages that need settlement. Repeated failures with the same message produce one warning per extension instance. Interactive hosts receive a display-only notification, never a console stack trace, even if notification delivery fails; headless hosts retain a console diagnostic. Pending messages are not discarded when cleanup fails.
|
|
659
661
|
|
|
@@ -20,7 +20,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
20
20
|
for (let i = entries.length - 1; i >= 0; i--) {
|
|
21
21
|
const entry = entries[i];
|
|
22
22
|
if (entry.type === "message" && entry.message.role === "assistant") {
|
|
23
|
-
pi.setLabel(entry.id, label);
|
|
23
|
+
await pi.setLabel(entry.id, label);
|
|
24
24
|
ctx.ui.notify(`Bookmarked as: ${label}`, "info");
|
|
25
25
|
return;
|
|
26
26
|
}
|
|
@@ -39,7 +39,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
39
39
|
const entry = entries[i];
|
|
40
40
|
const label = ctx.sessionManager.getLabel(entry.id);
|
|
41
41
|
if (label) {
|
|
42
|
-
pi.setLabel(entry.id, undefined);
|
|
42
|
+
await pi.setLabel(entry.id, undefined);
|
|
43
43
|
ctx.ui.notify(`Removed bookmark: ${label}`, "info");
|
|
44
44
|
return;
|
|
45
45
|
}
|
|
@@ -71,7 +71,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
71
71
|
// Convert to LLM format and serialize
|
|
72
72
|
const llmMessages = convertToLlm(messages);
|
|
73
73
|
const conversationText = serializeConversation(llmMessages);
|
|
74
|
-
const
|
|
74
|
+
const currentSessionId = ctx.sessionManager.getSessionId();
|
|
75
75
|
|
|
76
76
|
// Generate the handoff prompt with loader UI
|
|
77
77
|
const result = await ctx.ui.custom<string | null>((tui, theme, _kb, done) => {
|
|
@@ -144,7 +144,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
144
144
|
// context for post-switch UI work; the original ctx is stale after a
|
|
145
145
|
// successful session replacement.
|
|
146
146
|
const newSessionResult = await ctx.newSession({
|
|
147
|
-
parentSession:
|
|
147
|
+
parentSession: currentSessionId,
|
|
148
148
|
withSession: async (replacementCtx) => {
|
|
149
149
|
replacementCtx.ui.setEditorText(editedPrompt);
|
|
150
150
|
replacementCtx.ui.notify("Handoff ready. Submit when ready.", "info");
|