@bastani/atomic 0.10.14 → 0.10.15-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 +17 -0
- 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 +3 -3
- package/dist/_shared/mode-rpc-sdk-IOPGDYR4.js +3 -3
- package/dist/_shared/mode-shared-2QJSCUM6.js +3 -3
- package/dist/_shared/p1a-prewarm-XIU57JHF.js +3 -3
- package/dist/_shared/runtime-O4KCSG4C.js +2 -2
- package/dist/_shared/{sdk-B5LEWGGI.js → sdk-OHKMDJ74.js} +27 -5
- package/dist/_shared/{sdk-B5LEWGGI.js.map → sdk-OHKMDJ74.js.map} +1 -1
- package/dist/_shared/session-data-AHTU7IS6.js +2 -2
- package/dist/_shared/startup-0-0-Q3MWKUK4.js +2 -2
- package/dist/_shared/startup-0-1-M6OWAYHH.js +2 -2
- package/dist/_shared/{startup-0-2-5QHPCEON.js → startup-0-2-2HUMCPKX.js} +14 -16
- package/dist/_shared/startup-0-2-2HUMCPKX.js.map +1 -0
- package/dist/_shared/startup-0-3-4ZYBYQNM.js +3 -3
- package/dist/_shared/startup-0-4-ZMJV547D.js +3 -3
- package/dist/_shared/startup-0-5-YDW47QX6.js +3 -3
- package/dist/_shared/startup-10-0-TDQNBDDL.js +3 -3
- package/dist/_shared/startup-14-0-MLX36RBG.js +1 -1
- package/dist/_shared/startup-15-0-YUKGAC63.js +1 -1
- package/dist/_shared/startup-15-1-4S7FLMNG.js +6 -30
- package/dist/_shared/startup-15-1-4S7FLMNG.js.map +1 -1
- package/dist/_shared/startup-8-0-34CBHPZH.js +3 -3
- package/dist/_shared/startup-8-1-LZFXSD3Z.js +3 -3
- package/dist/_shared/storage-command-7MGXLJGZ.js +2 -2
- package/dist/_shared/storage-status-K7PX2RXA.js +3 -3
- package/dist/_shared/task-unsaved-answer-VJ2KTB4V.js +2 -2
- package/dist/_shared/tree-outline-MUEPK5B7.js +2 -2
- package/dist/builtin/intercom/index.bundle.mjs +1 -1
- package/dist/builtin/intercom/package.json +1 -1
- package/dist/builtin/mcp/index.bundle.mjs +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 +1 -1
- package/dist/builtin/web-access/index.bundle.mjs +1 -1
- package/dist/builtin/web-access/package.json +1 -1
- package/dist/cli/auth-cli.code.js +1 -1
- package/dist/cli/auth-cli.impl.js +3 -3
- package/dist/cli/auth-cli.js +3 -3
- 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.impl.js +3 -3
- package/dist/cli/list-models.js +3 -3
- package/dist/cli/session-picker.code.js +1 -1
- package/dist/cli/session-picker.impl.js +3 -3
- package/dist/cli/session-picker.js +3 -3
- package/dist/cli/startup-ui.code.js +1 -1
- 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 +1 -1
- 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 +1 -1
- 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/compaction/compactor.d.ts +0 -8
- 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.impl.js +3 -3
- package/dist/core/export-html/tool-renderer.js +3 -3
- 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.impl.js +3 -3
- package/dist/core/extensions/loader-host-modules.js +3 -3
- 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 +2 -2
- package/dist/core/intercom-broker-control.impl.js +3 -3
- package/dist/core/intercom-broker-control.js +3 -3
- package/dist/core/package-manager-storage-adapters.impl.js +3 -3
- package/dist/core/package-manager-storage-adapters.js +3 -3
- package/dist/core/sdk.code.js +1 -1
- package/dist/core/sdk.impl.js +3 -3
- package/dist/core/sdk.js +3 -3
- package/dist/core/session-manager-core.js +3 -3
- package/dist/core/session-manager-list.impl.js +3 -3
- package/dist/core/session-manager-list.js +3 -3
- 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/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 +2 -2
- 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 +1 -1
- 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 +2 -2
- 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 +2 -2
- 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 +1 -1
- 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 +2 -2
- 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 +2 -2
- 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 +2 -2
- package/dist/core/tasks/task-reference-archive.js +3 -3
- 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.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 +1 -1
- 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.impl.js +3 -3
- package/dist/extensions/codemode/execute.js +3 -3
- package/dist/extensions/codemode/renderer.impl.js +3 -3
- package/dist/extensions/codemode/renderer.js +3 -3
- package/dist/extensions/mcp/cli.code.js +1 -1
- 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.d.ts +21 -1
- package/dist/index.js +2 -2
- package/dist/main-first-time-setup.code.js +1 -1
- package/dist/main-first-time-setup.impl.js +3 -3
- package/dist/main-first-time-setup.js +3 -3
- 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/print-mode.js +1 -1
- package/dist/package-manager-cli.code.js +2 -2
- package/dist/package-manager-cli.impl.js +3 -3
- package/dist/package-manager-cli.js +3 -3
- package/dist/startup-files.json +1 -1
- package/dist/startup-stages/6.js +1 -1
- package/dist/utils/startup-database-spare.code.js +1 -1
- package/dist/utils/startup-database-spare.impl.js +3 -3
- package/dist/utils/startup-database-spare.js +3 -3
- package/dist/utils/tools-manager.impl.js +3 -3
- package/dist/utils/tools-manager.js +3 -3
- package/docs/background-tasks/reference.md +182 -0
- package/docs/background-tasks.md +98 -405
- package/docs/build.md +67 -27
- package/docs/changelog.mdx +1 -1
- package/docs/codemode.md +108 -39
- package/docs/compaction/branch-summaries.md +54 -0
- package/docs/compaction/custom-compactors.md +161 -0
- package/docs/compaction/memory-compaction.md +77 -0
- package/docs/compaction/reference.md +86 -38
- package/docs/compaction.md +51 -252
- package/docs/computer-use.md +169 -321
- package/docs/containerization.md +71 -57
- package/docs/custom-provider/api-reference.md +119 -25
- package/docs/custom-provider/oauth.md +114 -132
- package/docs/custom-provider/override.md +37 -27
- package/docs/custom-provider/registration.md +107 -83
- package/docs/custom-provider/streaming.md +85 -71
- package/docs/custom-provider.md +85 -52
- package/docs/development.md +39 -29
- package/docs/docs.json +76 -63
- package/docs/environment-variables.md +94 -44
- package/docs/extensions/api-reference.md +86 -43
- package/docs/extensions/authoring.md +162 -154
- package/docs/extensions/events.md +80 -25
- package/docs/extensions/examples.md +90 -85
- package/docs/extensions/ui.md +206 -82
- package/docs/extensions.md +79 -108
- package/docs/getting-started/authentication.md +67 -36
- package/docs/getting-started/first-session.md +53 -43
- package/docs/getting-started/installation.md +116 -89
- package/docs/getting-started/project-instructions.md +48 -34
- package/docs/guides/configuration.md +82 -20
- package/docs/guides/non-interactive.md +66 -24
- package/docs/guides/resume-on-any-machine.md +135 -82
- package/docs/guides/team-setup.md +114 -105
- package/docs/guides.md +76 -32
- package/docs/herdr.md +15 -16
- package/docs/how-atomic-works.md +140 -0
- package/docs/index.md +58 -44
- package/docs/intercom/operations.md +141 -151
- package/docs/intercom/reference.md +85 -108
- package/docs/intercom.md +84 -145
- package/docs/json.md +120 -67
- package/docs/keybindings.md +85 -49
- package/docs/libraries/agent-core.md +137 -275
- package/docs/libraries/ai.md +100 -84
- package/docs/libraries/codemode.md +210 -300
- package/docs/libraries/schema.md +59 -53
- package/docs/libraries/storage-postgres.md +49 -35
- package/docs/libraries/telemetry.md +153 -354
- package/docs/libraries/tui.md +265 -393
- package/docs/libraries.md +42 -26
- package/docs/llama-cpp.md +171 -161
- package/docs/mcp-servers.md +90 -51
- package/docs/models/choose-a-model.md +188 -0
- package/docs/models/reference.md +74 -30
- package/docs/models.md +153 -88
- package/docs/orchestration/migrating-workflows.md +23 -16
- package/docs/orchestration/patterns.md +39 -44
- package/docs/orchestration.md +65 -26
- package/docs/packages/authoring.md +51 -29
- package/docs/packages/reference.md +42 -21
- package/docs/packages.md +69 -58
- package/docs/programmatic.md +118 -24
- package/docs/prompt-templates.md +84 -83
- package/docs/providers/reference.md +43 -48
- package/docs/providers.md +219 -451
- package/docs/quickstart.md +140 -120
- package/docs/reference/cli.md +135 -97
- package/docs/reference.md +20 -18
- package/docs/rpc/examples.md +76 -20
- package/docs/rpc/extension-ui.md +64 -38
- package/docs/rpc/protocol.md +361 -110
- package/docs/rpc.md +57 -17
- package/docs/sdk/reference.md +409 -534
- package/docs/sdk/storage.md +53 -13
- package/docs/sdk/structured-decisions.md +82 -56
- package/docs/sdk/web-server.md +57 -43
- package/docs/sdk.md +106 -84
- package/docs/security.md +42 -64
- package/docs/session-format.md +62 -38
- package/docs/sessions.md +99 -214
- package/docs/settings.md +165 -195
- package/docs/shell-aliases.md +9 -6
- package/docs/skills/authoring.md +69 -48
- package/docs/skills/reference.md +51 -20
- package/docs/skills.md +99 -148
- package/docs/slash-commands.md +129 -0
- package/docs/storage/custom-adapters.md +160 -85
- package/docs/storage/jsonl.md +81 -66
- package/docs/storage/postgres/pgbouncer.md +120 -126
- package/docs/storage/postgres/tuning.md +120 -143
- package/docs/storage/postgres.md +314 -330
- package/docs/storage/sqlite.md +71 -42
- package/docs/storage.md +298 -302
- package/docs/subagents/authoring.md +55 -38
- package/docs/subagents/reference.md +73 -33
- package/docs/subagents.md +119 -187
- package/docs/terminal-setup.md +50 -38
- package/docs/termux.md +67 -41
- package/docs/themes/reference.md +23 -19
- package/docs/themes.md +142 -127
- package/docs/tmux.md +47 -55
- package/docs/tools.md +147 -109
- package/docs/tui/reference.md +166 -214
- package/docs/tui.md +196 -341
- package/docs/usage.md +118 -138
- package/docs/verification.md +79 -51
- package/docs/web-access.md +121 -101
- package/docs/windows.md +26 -27
- package/docs/worktree-snapshots/reference.md +245 -0
- package/docs/worktree-snapshots.md +71 -259
- package/package.json +8 -8
- package/dist/_shared/startup-0-2-5QHPCEON.js.map +0 -1
- package/docs/guides/intercom.md +0 -32
- package/docs/guides/orchestration.md +0 -28
- package/docs/guides/subagents.md +0 -37
package/docs/rpc/examples.md
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
---
|
|
2
|
-
title: "RPC
|
|
3
|
-
sidebarTitle: "RPC examples"
|
|
2
|
+
title: "Connect with RPC clients"
|
|
3
|
+
sidebarTitle: "RPC client examples"
|
|
4
4
|
description: "Connect to Atomic RPC mode using the typed RpcClient in TypeScript or a standalone Node.js script."
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
## Typed TypeScript client (`RpcClient`)
|
|
8
8
|
|
|
9
|
-
Install `@bastani/atomic` and use `RpcClient` to spawn Atomic in a child process, send typed commands, stream events, answer extension UI requests
|
|
9
|
+
Install `@bastani/atomic` and use `RpcClient` to spawn Atomic in a child process, send typed commands, stream events, and answer extension UI requests.
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
<Warning>
|
|
12
|
+
By default, `RpcClient` launches `bun dist/cli.js`, which fails under Node.js or npm installs. Always pass `runtimeExecutable: process.execPath` with `cliPath: fileURLToPath(import.meta.resolve("@bastani/atomic/rpc-entry"))` for Node.js apps, or `runtimeExecutable: "atomic"` with `cliPath: ""` to drive an installed `atomic` binary on `PATH`.
|
|
13
|
+
</Warning>
|
|
14
|
+
|
|
15
|
+
**About `@bastani/atomic/rpc-entry`:** This dedicated RPC entry script sets `process.title = "atomic-rpc"`, suppresses Node runtime warnings so stderr stays clean, and injects `--mode rpc` before any `--` terminator so caller `--mode` flags cannot accidentally switch away from RPC mode.
|
|
12
16
|
|
|
13
17
|
### `RpcClientOptions`
|
|
14
18
|
|
|
@@ -24,13 +28,49 @@ By default `RpcClient` launches `bun dist/cli.js`. To launch the installed packa
|
|
|
24
28
|
| `runtimeArgs` | `[]` | Arguments passed to `runtimeExecutable` before `cliPath`. |
|
|
25
29
|
| `requestTimeoutMs` | `30000` | Timeout in milliseconds for short metadata and control commands. |
|
|
26
30
|
|
|
27
|
-
**Request timeout exemptions:** `requestTimeoutMs` (default `30_000` ms) applies only to short metadata and control requests such as `get_state`, `get_available_models`, `set_model`, `get_entries`, and `list_sessions`. Long-lived or interaction-gated commands (`prompt`, `steer`, `follow_up`, `resume_queued_messages`, `bash`, `user_bash`, `compact`, `login_provider`, `fork`, `clone`, `switch_session`, `new_session`, `import_session`, `navigate_tree`, `invoke_shortcut`, `start_pending_recovery
|
|
31
|
+
**Request timeout exemptions:** `requestTimeoutMs` (default `30_000` ms) applies only to short metadata and control requests such as `get_state`, `get_available_models`, `set_model`, `get_entries`, and `list_sessions`. Long-lived or interaction-gated commands (`prompt`, `steer`, `follow_up`, `resume_queued_messages`, `bash`, `user_bash`, `compact`, `login_provider`, `fork`, `clone`, `switch_session`, `new_session`, `import_session`, `navigate_tree`, `invoke_shortcut`, `start_pending_recovery`) and cooperative cancellation commands (`abort`, `abort_bash`, `abort_compaction`, `abort_branch_summary`, `abort_retry`, `cancel_login_provider`) are exempt and never time out on the client timer. If the child exits or the transport breaks, pending requests reject immediately.
|
|
32
|
+
|
|
33
|
+
**Startup and shutdown lifecycle:** In standalone mode, `client.start()` waits a fixed 100 ms after spawning the subprocess. `client.stop()` terminates the subprocess with `SIGTERM` and a **250 ms** grace period before escalating to `SIGKILL` (on Windows, `SIGTERM` terminates immediately). Wait for `agent_settled` and any pending writes before calling `stop()`.
|
|
34
|
+
|
|
35
|
+
### Prompting and waiting for turns to settle
|
|
36
|
+
|
|
37
|
+
<Warning>
|
|
38
|
+
**`promptAndWait()`, `waitForIdle()`, and `collectEvents()` stop on the first `agent_end`, not `agent_settled`:**
|
|
39
|
+
1. They resolve as soon as the first low-level `agent_end` event arrives — **before** automatic retries (`retryPending: true`), post-compaction continuations, or queued turns complete.
|
|
40
|
+
2. `promptAndWait()` does **not** inspect the `prompt` response's `disposition`. If an extension command or input hook returns `"handled"`, no turn starts and `promptAndWait()` hangs until its 60-second timeout fires.
|
|
28
41
|
|
|
29
|
-
|
|
42
|
+
For reliable turn completion in production clients, call `client.prompt()`, return early when `disposition === "handled"`, and wait for `event.type === "agent_settled"`.
|
|
43
|
+
</Warning>
|
|
30
44
|
|
|
31
45
|
```typescript
|
|
32
46
|
import { fileURLToPath } from "node:url";
|
|
33
|
-
import { RpcClient } from "@bastani/atomic";
|
|
47
|
+
import { RpcClient, type RpcEvent } from "@bastani/atomic";
|
|
48
|
+
|
|
49
|
+
async function runPromptUntilSettled(client: RpcClient, message: string): Promise<RpcEvent[]> {
|
|
50
|
+
const events: RpcEvent[] = [];
|
|
51
|
+
let resolveSettled!: () => void;
|
|
52
|
+
const settled = new Promise<void>((resolve) => {
|
|
53
|
+
resolveSettled = resolve;
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
const unsubscribe = client.onEvent((event) => {
|
|
57
|
+
events.push(event);
|
|
58
|
+
if (event.type === "message_update" && event.assistantMessageEvent.type === "text_delta") {
|
|
59
|
+
process.stdout.write(event.assistantMessageEvent.delta);
|
|
60
|
+
}
|
|
61
|
+
if (event.type === "agent_settled") resolveSettled();
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
try {
|
|
65
|
+
const disposition = await client.prompt(message);
|
|
66
|
+
if (disposition === "handled") return events;
|
|
67
|
+
await settled;
|
|
68
|
+
process.stdout.write("\n");
|
|
69
|
+
return events;
|
|
70
|
+
} finally {
|
|
71
|
+
unsubscribe();
|
|
72
|
+
}
|
|
73
|
+
}
|
|
34
74
|
|
|
35
75
|
const client = new RpcClient({
|
|
36
76
|
runtimeExecutable: process.execPath,
|
|
@@ -39,22 +79,28 @@ const client = new RpcClient({
|
|
|
39
79
|
requestTimeoutMs: 30_000,
|
|
40
80
|
});
|
|
41
81
|
|
|
42
|
-
const unsubscribe = client.onEvent((event) => {
|
|
43
|
-
if (event.type === "message_update" && event.assistantMessageEvent.type === "text_delta") {
|
|
44
|
-
process.stdout.write(event.assistantMessageEvent.delta);
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
|
|
48
82
|
try {
|
|
49
83
|
await client.start();
|
|
50
|
-
await client
|
|
51
|
-
process.stdout.write("\n");
|
|
84
|
+
await runPromptUntilSettled(client, "Explain this repository");
|
|
52
85
|
} finally {
|
|
53
|
-
unsubscribe();
|
|
54
86
|
await client.stop();
|
|
55
87
|
}
|
|
56
88
|
```
|
|
57
89
|
|
|
90
|
+
### Sending commands without a typed wrapper
|
|
91
|
+
|
|
92
|
+
`RpcClient` provides typed helpers for the most common commands plus several lower-level helpers:
|
|
93
|
+
|
|
94
|
+
- **`client.requestInternal<T>(command)`:** Sends any [`RpcCommand`](/rpc/protocol#commands) and unwraps its response `data`. Use this for protocol commands without a dedicated typed wrapper on `RpcClient` (`set_scoped_models`, `pause_queued_messages`, `resume_queued_messages`, `abort_compaction`, `abort_branch_summary`, `import_session`, `navigate_tree`, `set_label`, `reload`, `get_shortcuts`, `invoke_shortcut`, `stop_all_background`, and OAuth `login_provider` with `authType: "oauth"`).
|
|
95
|
+
- **`client.userBashWithUpdates(command, onUpdate, options?)`:** Streams correlated `stdout`/`stderr` deltas and supports `excludeFromContext` and `onRequestId` (by contrast, `client.bash(command)` does not expose `excludeFromContext`).
|
|
96
|
+
- **`client.getEntries({ windowOnly: true })`:** Sends `get_context_window` instead of `get_entries`.
|
|
97
|
+
- **`client.findQueuedMessages(query)`:** Checks which queued message IDs were committed to the session store after a sequence number.
|
|
98
|
+
- **`client.getStderr()`:** Returns bounded stderr text captured from the child process for diagnostics.
|
|
99
|
+
|
|
100
|
+
<Warning>
|
|
101
|
+
Do **not** call `client.loginProvider(provider)` in standalone RPC mode: it omits `authType` (defaulting to `"api_key"`), which requires Atomic's interactive input host and fails in standalone `atomic --mode rpc`. Save API keys with `await client.saveProviderCredential(provider, { type: "api_key", key })`, or start OAuth login with `await client.requestInternal({ type: "login_provider", provider, authType: "oauth", loginId })`.
|
|
102
|
+
</Warning>
|
|
103
|
+
|
|
58
104
|
### Handling extension UI and questionnaires
|
|
59
105
|
|
|
60
106
|
Subscribe with `onExtensionUIRequest()` and reply with `respondExtensionUI()`. Opt in to `ask_user_question` questionnaires by calling `setExtensionUiCapabilities({ questionnaire: true })` right after `start()`:
|
|
@@ -96,7 +142,7 @@ More TypeScript examples live in the repository under [`examples/rpc-client.ts`]
|
|
|
96
142
|
|
|
97
143
|
### Isolating subprocess storage
|
|
98
144
|
|
|
99
|
-
Pass `--storage-file <path>`, `--session-store <path>`, or `ATOMIC_STORAGE` in `RpcClientOptions` to give each RPC subprocess its own session store without editing user settings (see [Selecting storage per process](/storage#selecting-storage-per-process) and [
|
|
145
|
+
Pass `--storage-file <path>`, `--session-store <path>`, or `ATOMIC_STORAGE` in `RpcClientOptions` to give each RPC subprocess its own session store without editing user settings (see [Selecting storage per process](/storage#selecting-storage-per-process) and [Configure session storage](/sdk/storage)):
|
|
100
146
|
|
|
101
147
|
```typescript
|
|
102
148
|
import { fileURLToPath } from "node:url";
|
|
@@ -143,7 +189,7 @@ try {
|
|
|
143
189
|
|
|
144
190
|
## Standalone Node.js client
|
|
145
191
|
|
|
146
|
-
This ESM script spawns an installed `atomic --mode rpc` binary without importing `@bastani/atomic`, parses stdout with strict LF-only JSONL framing (avoiding Node's `readline`, which splits on `U+2028` and `U+2029`), aborts on `SIGINT`, and closes stdin cleanly
|
|
192
|
+
This ESM script spawns an installed `atomic --mode rpc` binary without importing `@bastani/atomic`, parses stdout with strict LF-only JSONL framing (avoiding Node's `readline`, which splits on `U+2028` and `U+2029`), checks `disposition` on the `prompt` response, aborts on `SIGINT`, and closes stdin cleanly once `agent_settled` arrives:
|
|
147
193
|
|
|
148
194
|
```javascript
|
|
149
195
|
import { spawn } from "node:child_process";
|
|
@@ -180,17 +226,27 @@ function attachJsonlReader(stream, onLine) {
|
|
|
180
226
|
attachJsonlReader(agent.stdout, (line) => {
|
|
181
227
|
const event = JSON.parse(line);
|
|
182
228
|
|
|
229
|
+
if (event.type === "response" && event.id === "p-1") {
|
|
230
|
+
if (!event.success) {
|
|
231
|
+
console.error(event.error);
|
|
232
|
+
agent.stdin.end();
|
|
233
|
+
} else if (event.data?.disposition === "handled") {
|
|
234
|
+
agent.stdin.end();
|
|
235
|
+
}
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
|
|
183
239
|
if (event.type === "message_update" && event.assistantMessageEvent.type === "text_delta") {
|
|
184
240
|
process.stdout.write(event.assistantMessageEvent.delta);
|
|
185
241
|
}
|
|
186
242
|
|
|
187
|
-
if (event.type === "
|
|
243
|
+
if (event.type === "agent_settled") {
|
|
188
244
|
process.stdout.write("\n");
|
|
189
245
|
agent.stdin.end();
|
|
190
246
|
}
|
|
191
247
|
});
|
|
192
248
|
|
|
193
|
-
agent.stdin.write(JSON.stringify({ type: "prompt", message: "Hello" }) + "\n");
|
|
249
|
+
agent.stdin.write(JSON.stringify({ id: "p-1", type: "prompt", message: "Hello" }) + "\n");
|
|
194
250
|
|
|
195
251
|
process.on("SIGINT", () => {
|
|
196
252
|
agent.stdin.write(JSON.stringify({ type: "abort" }) + "\n");
|
package/docs/rpc/extension-ui.md
CHANGED
|
@@ -1,39 +1,41 @@
|
|
|
1
1
|
---
|
|
2
|
-
title: "
|
|
3
|
-
sidebarTitle: "RPC UI
|
|
2
|
+
title: "Handle extension UI over RPC"
|
|
3
|
+
sidebarTitle: "RPC extension UI"
|
|
4
4
|
description: "Handle extension dialogs, notifications, status bars, widgets, questionnaires, and OAuth prompts over the RPC transport."
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Extensions request user interaction through `ctx.ui.select()`, `ctx.ui.confirm()`, and related methods. Provider OAuth logins started with `login_provider` (`authType: "oauth"`) use the same `extension_ui_request` and `extension_ui_response` sub-protocol. For process startup, framing, and typed client code, see [Drive Atomic over RPC](/rpc), [RPC protocol reference](/rpc/protocol), and [Connect with RPC clients](/rpc/examples).
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
## Extension UI protocol {#extension-ui-protocol}
|
|
10
10
|
|
|
11
11
|
Extension UI requests fall into three categories:
|
|
12
12
|
|
|
13
13
|
- **Dialog methods** (`select`, `confirm`, `input`, `editor`, and `questionnaire` when the client [opted in](/rpc/protocol#set_extension_ui_capabilities)): emit an `extension_ui_request` on stdout and wait until the client sends an `extension_ui_response` on stdin with the matching `id`.
|
|
14
14
|
- **Fire-and-forget UI methods** (`cancel`, `notify`, `setStatus`, `setWidget`, `setTitle`, `set_editor_text`): emit an `extension_ui_request` on stdout and expect no response. Handle `cancel` by closing its matching dialog; other methods update your display.
|
|
15
|
-
- **OAuth login methods** (`oauth_auth`, `oauth_device_code`, `oauth_progress`, `oauth_info`, `oauth_prompt`, `oauth_select`, `oauth_manual_code`, `oauth_manual_code_cancel`): drive interactive OAuth sign-in during `login_provider`. `oauth_prompt`, `oauth_select`, and `oauth_manual_code` expect an `extension_ui_response` with `value
|
|
15
|
+
- **OAuth login methods** (`oauth_auth`, `oauth_device_code`, `oauth_progress`, `oauth_info`, `oauth_prompt`, `oauth_select`, `oauth_manual_code`, `oauth_manual_code_cancel`): drive interactive OAuth sign-in during `login_provider`. `oauth_prompt`, `oauth_select`, and `oauth_manual_code` expect an `extension_ui_response` with `value`; the other OAuth methods are fire-and-forget.
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
<Note>
|
|
18
|
+
When a standard dialog (`select`, `confirm`, `input`, `editor`, or `questionnaire`) carries a `timeout` (in milliseconds) or an `AbortSignal`, Atomic resolves it automatically with its default value (`undefined` for `select`/`input`/`editor`, `false` for `confirm`, `{ answers: [], cancelled: true }` for `questionnaire`) if the timeout expires or the signal aborts, and sends a matching `cancel` notification. Clients do not need to run their own timers. Note that `editor` does not serialize `timeout` on the wire request even though Atomic still enforces `opts.timeout` locally and emits `cancel` if it expires.
|
|
19
|
+
</Note>
|
|
18
20
|
|
|
19
21
|
## Unsupported and degraded methods in plain RPC mode
|
|
20
22
|
|
|
21
23
|
In RPC mode, `ctx.mode` is `"rpc"` and `ctx.hasUI` is `true` because dialog and fire-and-forget methods work through this protocol. Guard terminal-only features such as `ctx.ui.custom()` with `ctx.mode === "tui"`.
|
|
22
24
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
25
|
+
| Method or property | Behavior in plain RPC mode |
|
|
26
|
+
| --- | --- |
|
|
27
|
+
| `setWidget(key, factory)` | Throws `Error("Component-factory widgets are unavailable in this RPC host.")`. Only string arrays (or `undefined` to clear) work over plain RPC. |
|
|
28
|
+
| `custom()` | Resolves to `undefined`. |
|
|
29
|
+
| `hostSessionPicker`, `hostInputForm` | Omitted (`undefined`). |
|
|
30
|
+
| `setWorkingMessage()`, `setWorkingVisible()`, `setWorkingIndicator()`, `setHiddenThinkingLabel()`, `setFooter()`, `setHeader()`, `setEditorComponent()`, `addAutocompleteProvider()`, `requestRender()` | No-ops. |
|
|
31
|
+
| `onTerminalInput()`, `onHostCustomUiStateChange()`, `onWidgetRelease()` | Return a no-op unsubscribe function. |
|
|
32
|
+
| `getEditorText()` | Returns `""`. |
|
|
33
|
+
| `getEditorComponent()` | Returns `undefined`. |
|
|
34
|
+
| `pasteToEditor(text)` | Delegates to `setEditorText(text)` without paste-collapse handling. |
|
|
35
|
+
| `getFooterDataProvider()` | Returns a stub (`getGitBranch() -> null`, `getExtensionStatuses() -> empty Map`, `getAvailableProviderCount() -> 1`, `onBranchChange() -> no-op unsubscribe`). |
|
|
36
|
+
| `getHostCustomUiState()`, `focusHostInlineCustomUi()` | Returns `{ blockingInlineCustomUiDepth: 0, blockingInlineCustomUiActive: false }`; `focusHostInlineCustomUi()` returns `false`. |
|
|
37
|
+
| `setToolsExpanded()`, `getToolsExpanded()`, `getChatRenderSettings()` | Stores tool-expansion state locally (matching `getChatRenderSettings().toolOutputExpanded`; not sent over the wire). `hideThinkingBlock` is `false`. |
|
|
38
|
+
| `getAllThemes()`, `getTheme()`, `setTheme()` | Returns `[]`, `undefined`, and `{ success: false, error: "Theme switching not supported in RPC mode" }`. |
|
|
37
39
|
|
|
38
40
|
## Extension UI requests (stdout)
|
|
39
41
|
|
|
@@ -235,18 +237,35 @@ Replace the text in the input editor. Fire-and-forget.
|
|
|
235
237
|
|
|
236
238
|
### OAuth login methods
|
|
237
239
|
|
|
238
|
-
During `login_provider`, Atomic emits OAuth UI requests containing `type: "extension_ui_request"`, `id`, `provider`, `loginId`, and `method`:
|
|
240
|
+
During [`login_provider`](/rpc/protocol#login_provider) with `"authType": "oauth"`, Atomic emits OAuth UI requests containing `type: "extension_ui_request"`, `id`, `provider`, `loginId`, and `method`:
|
|
239
241
|
|
|
240
|
-
|
|
242
|
+
<Warning>
|
|
243
|
+
**Do NOT send `cancelled: true` to cancel `oauth_prompt` or `oauth_manual_code`.** Atomic turns `cancelled: true` into `undefined`, and both `oauth_prompt` and `oauth_manual_code` coalesce `undefined` to an empty string (`""`) — submitting an empty answer instead of cancelling the sign-in flow! (Only `oauth_select` receives `undefined`.) To cancel an OAuth login, send [`cancel_login_provider`](/rpc/protocol#cancel_login_provider) with the matching `provider` and `loginId`. Unlike standard dialogs, cancelling an OAuth flow does **not** emit a `method: "cancel"` notification for `oauth_prompt` or `oauth_select` (close any open prompt when you send `cancel_login_provider` or when `login_provider` responds).
|
|
244
|
+
</Warning>
|
|
245
|
+
|
|
246
|
+
| Method | Payload fields | Response expected |
|
|
241
247
|
| --- | --- | --- |
|
|
242
|
-
| `oauth_auth` | `info
|
|
243
|
-
| `oauth_device_code` | `info
|
|
244
|
-
| `oauth_progress` | `message
|
|
245
|
-
| `oauth_info` | `message`, `links
|
|
246
|
-
| `oauth_prompt` | `prompt`
|
|
247
|
-
| `oauth_select` | `prompt`
|
|
248
|
-
| `oauth_manual_code` | None | `extension_ui_response` with `value`
|
|
249
|
-
| `oauth_manual_code_cancel` | None | None (close pending
|
|
248
|
+
| `oauth_auth` | `info`: `{ url: string, instructions?: string }` | None (fire-and-forget) |
|
|
249
|
+
| `oauth_device_code` | `info`: `{ userCode: string, verificationUri: string, openBrowserOnConfirm?: boolean, copyCodeOnConfirm?: boolean, intervalSeconds?: number, expiresInSeconds?: number }` | None (fire-and-forget) |
|
|
250
|
+
| `oauth_progress` | `message: string` | None (fire-and-forget) |
|
|
251
|
+
| `oauth_info` | `message: string`, `links: Array<{ url: string, label?: string }>` | None (fire-and-forget) |
|
|
252
|
+
| `oauth_prompt` | `prompt`: `{ message: string, placeholder?: string, allowEmpty?: boolean }` | `extension_ui_response` with `value: string` (to abort login, send `cancel_login_provider`) |
|
|
253
|
+
| `oauth_select` | `prompt`: `{ message: string, options: Array<{ id: string, label: string }> }` | `extension_ui_response` with `value` (selected option `id`) or `cancelled: true` (resolves `undefined`) |
|
|
254
|
+
| `oauth_manual_code` | None | `extension_ui_response` with `value: string` (to abort login, send `cancel_login_provider`) |
|
|
255
|
+
| `oauth_manual_code_cancel` | None | None (close pending `oauth_manual_code` prompt without responding) |
|
|
256
|
+
|
|
257
|
+
Concrete wire payloads for each OAuth UI request:
|
|
258
|
+
|
|
259
|
+
```json
|
|
260
|
+
{"type":"extension_ui_request","id":"oa-1","method":"oauth_auth","provider":"anthropic","loginId":"login-1","info":{"url":"https://console.anthropic.com/oauth/authorize?...","instructions":"Open the URL to authorize Atomic."}}
|
|
261
|
+
{"type":"extension_ui_request","id":"oa-2","method":"oauth_device_code","provider":"github-copilot","loginId":"login-2","info":{"userCode":"ABCD-1234","verificationUri":"https://github.com/login/device","openBrowserOnConfirm":true,"copyCodeOnConfirm":true,"intervalSeconds":5,"expiresInSeconds":900}}
|
|
262
|
+
{"type":"extension_ui_request","id":"oa-3","method":"oauth_progress","provider":"github-copilot","loginId":"login-2","message":"Waiting for authorization..."}
|
|
263
|
+
{"type":"extension_ui_request","id":"oa-4","method":"oauth_info","provider":"openai-codex","loginId":"login-3","message":"Review workspace access:","links":[{"url":"https://chatgpt.com/settings","label":"Account settings"}]}
|
|
264
|
+
{"type":"extension_ui_request","id":"oa-5","method":"oauth_prompt","provider":"anthropic","loginId":"login-1","prompt":{"message":"Paste the authorization code","placeholder":"code#state","allowEmpty":false}}
|
|
265
|
+
{"type":"extension_ui_request","id":"oa-6","method":"oauth_select","provider":"google-gemini-cli","loginId":"login-4","prompt":{"message":"Choose a project","options":[{"id":"proj-a","label":"Project A"},{"id":"proj-b","label":"Project B"}]}}
|
|
266
|
+
{"type":"extension_ui_request","id":"oa-7","method":"oauth_manual_code","provider":"openai-codex","loginId":"login-3"}
|
|
267
|
+
{"type":"extension_ui_request","id":"oa-8","method":"oauth_manual_code_cancel","provider":"openai-codex","loginId":"login-3"}
|
|
268
|
+
```
|
|
250
269
|
|
|
251
270
|
## Extension UI responses (stdin)
|
|
252
271
|
|
|
@@ -258,10 +277,9 @@ Send responses for dialog methods (`select`, `confirm`, `input`, `editor`, `ques
|
|
|
258
277
|
- For `select`, `input`, and `editor`, a non-cancelled response without `value` resolves to `undefined`. `select` does not validate `value` against the original `options` list, so clients should send one of the offered options.
|
|
259
278
|
- For `confirm`, a non-cancelled response without `confirmed` resolves to `false`.
|
|
260
279
|
- For `questionnaire`, see [questionnaire](#questionnaire) for answer validation.
|
|
280
|
+
- For `oauth_prompt` and `oauth_manual_code`, send `value` as a string; to cancel sign-in, send [`cancel_login_provider`](/rpc/protocol#cancel_login_provider) rather than `cancelled: true`.
|
|
261
281
|
|
|
262
|
-
### Value response (`select`, `input`, `editor`)
|
|
263
|
-
|
|
264
|
-
Also used for `oauth_prompt`, `oauth_select`, and `oauth_manual_code`:
|
|
282
|
+
### Value response (`select`, `input`, `editor`, `oauth_prompt`, `oauth_select`, `oauth_manual_code`)
|
|
265
283
|
|
|
266
284
|
```json
|
|
267
285
|
{"type": "extension_ui_response", "id": "uuid-1", "value": "Allow"}
|
|
@@ -273,9 +291,9 @@ Also used for `oauth_prompt`, `oauth_select`, and `oauth_manual_code`:
|
|
|
273
291
|
{"type": "extension_ui_response", "id": "uuid-2", "confirmed": true}
|
|
274
292
|
```
|
|
275
293
|
|
|
276
|
-
### Cancellation response (
|
|
294
|
+
### Cancellation response (standard dialogs and `oauth_select`)
|
|
277
295
|
|
|
278
|
-
Dismiss
|
|
296
|
+
Dismiss a standard dialog (`select`, `confirm`, `input`, `editor`, or `questionnaire`) or resolve `oauth_select` to `undefined`. Standard dialogs receive `undefined` (for `select`, `input`, `editor`), `false` (for `confirm`), or `{ answers: [], cancelled: true }` (for `questionnaire`). Do not use this to cancel `oauth_prompt` or `oauth_manual_code` — send `cancel_login_provider` instead.
|
|
279
297
|
|
|
280
298
|
```json
|
|
281
299
|
{"type": "extension_ui_response", "id": "uuid-3", "cancelled": true}
|
|
@@ -283,6 +301,14 @@ Dismiss any dialog method. The extension receives `undefined` (for `select`, `in
|
|
|
283
301
|
|
|
284
302
|
## See also
|
|
285
303
|
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
304
|
+
<Columns cols={2}>
|
|
305
|
+
<Card title="Drive Atomic over RPC" href="/rpc">
|
|
306
|
+
Startup flags, command concurrency lanes, JSONL framing, and shutdown signals.
|
|
307
|
+
</Card>
|
|
308
|
+
<Card title="RPC protocol reference" href="/rpc/protocol">
|
|
309
|
+
All commands, streamed events, and structured error codes.
|
|
310
|
+
</Card>
|
|
311
|
+
<Card title="Connect with RPC clients" href="/rpc/examples">
|
|
312
|
+
TypeScript `RpcClient` recipes and standalone Node.js examples.
|
|
313
|
+
</Card>
|
|
314
|
+
</Columns>
|