@bastani/atomic 0.10.14-alpha.1 → 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 +29 -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 +9 -0
- 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/libraries/schema.md
CHANGED
|
@@ -4,15 +4,15 @@ sidebarTitle: "@bastani/atomic-schema"
|
|
|
4
4
|
description: "Build and validate JSON Schema drafts 2020-12 and 7 without eval, with zero runtime dependencies and optional coercion."
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
JSON Schema builders and validation without `eval`. Each schema compiles once into plain closures, so validation runs without code generation, works under a strict Content Security Policy, and
|
|
7
|
+
JSON Schema builders and validation without `eval`. Each schema compiles once into plain closures, so validation runs without code generation, works under a strict Content Security Policy, and requires zero runtime dependencies.
|
|
8
8
|
|
|
9
9
|
- Supports JSON Schema drafts 2020-12 and 7.
|
|
10
10
|
- Builders return plain JSON Schema objects typed with the values they accept, and compiled checks narrow values to that type.
|
|
11
|
-
- Errors include JSON Pointer paths
|
|
11
|
+
- Errors include JSON Pointer paths; missing and unknown fields report at the field path.
|
|
12
12
|
- Schemas are never mutated, so frozen schemas work.
|
|
13
|
-
- Format checks live in an optional subpath import.
|
|
13
|
+
- Format checks live in an optional subpath import (`@bastani/atomic-schema/formats`).
|
|
14
14
|
|
|
15
|
-
Atomic validates tool arguments with `@bastani/atomic-schema
|
|
15
|
+
Atomic validates tool arguments with `@bastani/atomic-schema` (see [Tool parameter schemas](/extensions#tool-parameter-schemas) and [Standalone libraries](/libraries)). Extensions can import it without installing it.
|
|
16
16
|
|
|
17
17
|
## Installation
|
|
18
18
|
|
|
@@ -26,16 +26,16 @@ npm install @bastani/atomic-schema
|
|
|
26
26
|
import { compile, int, obj, oneOf, opt, type Static, str } from "@bastani/atomic-schema";
|
|
27
27
|
|
|
28
28
|
const Read = obj({
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
path: str({ description: "Path to the file", minLength: 1 }),
|
|
30
|
+
offset: opt(int({ minimum: 1 })),
|
|
31
|
+
mode: oneOf(["text", "binary"]),
|
|
32
32
|
});
|
|
33
33
|
type Read = Static<typeof Read>; // { path: string; mode: "text" | "binary"; offset?: number }
|
|
34
34
|
|
|
35
35
|
const read = compile(Read);
|
|
36
36
|
const value: unknown = { path: "README.md", mode: "text" };
|
|
37
37
|
if (read.check(value)) {
|
|
38
|
-
|
|
38
|
+
console.log(value.path); // narrowed to Read
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
read.errors({ offset: 0, extra: true });
|
|
@@ -47,15 +47,15 @@ read.errors({ offset: 0, extra: true });
|
|
|
47
47
|
// ]
|
|
48
48
|
```
|
|
49
49
|
|
|
50
|
-
`Read` is plain JSON Schema (`{ type: "object", properties: {...}, required: ["path", "mode"], additionalProperties: false }`), ready for
|
|
50
|
+
`Read` is a plain JSON Schema object (`{ type: "object", properties: {...}, required: ["path", "mode"], additionalProperties: false }`), ready for tool definitions or `JSON.stringify`. `compile()` accepts any JSON Schema, built or handwritten.
|
|
51
51
|
|
|
52
|
-
`check(value)` is the fast boolean path
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
- `check(value)` is the fast boolean path (standalone function, allocation-free for most schemas).
|
|
53
|
+
- `errors(value)` returns `ValidationError[]` (`{ path, keyword, message }`), building the error explainer lazily on the first failure.
|
|
54
|
+
- `validate(value)` returns `ParseResult<T>` (`{ ok: true; value: T } | { ok: false; errors: ValidationError[] }`) without modifying the input.
|
|
55
55
|
|
|
56
56
|
### Builders
|
|
57
57
|
|
|
58
|
-
| Builder | Schema |
|
|
58
|
+
| Builder | Schema | Inferred type |
|
|
59
59
|
| --- | --- | --- |
|
|
60
60
|
| `str({ minLength, maxLength, pattern, format })` | `{ type: "string", ... }` | `string` |
|
|
61
61
|
| `num({ minimum, maximum, exclusiveMinimum, exclusiveMaximum, multipleOf })`, `int(...)` | `{ type: "number" }`, `{ type: "integer" }` | `number` |
|
|
@@ -73,26 +73,31 @@ read.errors({ offset: 0, extra: true });
|
|
|
73
73
|
| `unsafe<T>(schema)` | `schema` as given (`{}` by default) | `T`, unchecked |
|
|
74
74
|
| `recursive<T>(id, (self) => schema)` | `schema` with `$id: id`; `self` is `{ $ref: id }` | `T` |
|
|
75
75
|
|
|
76
|
-
Every builder
|
|
76
|
+
Every builder accepts `title`, `description`, `examples`, `deprecated`, and `default`.
|
|
77
|
+
|
|
78
|
+
<Note>
|
|
79
|
+
`default` is a schema annotation only—validation and coercion never insert default values into your data.
|
|
80
|
+
</Note>
|
|
77
81
|
|
|
78
|
-
|
|
82
|
+
Unions of objects discriminated by a `lit()` property check only the matching branch and report tag errors directly:
|
|
79
83
|
|
|
80
84
|
```typescript
|
|
81
|
-
const Block = union([
|
|
85
|
+
const Block = union([
|
|
86
|
+
obj({ kind: lit("text"), text: str() }),
|
|
87
|
+
obj({ kind: lit("image"), width: int({ minimum: 0 }) }),
|
|
88
|
+
]);
|
|
82
89
|
compile(Block).errors({ kind: "video" });
|
|
83
90
|
// [{ path: "/kind", keyword: "anyOf", message: 'expected one of ["text","image"]' }]
|
|
84
91
|
```
|
|
85
92
|
|
|
86
|
-
|
|
93
|
+
Recursive schemas require an explicit type argument and a unique `id` within the root schema:
|
|
87
94
|
|
|
88
95
|
```typescript
|
|
89
96
|
type Tree = { name: string; children: Tree[] };
|
|
90
97
|
const Tree = recursive<Tree>("Tree", (self) => obj({ name: str(), children: arr(self) }));
|
|
91
98
|
```
|
|
92
99
|
|
|
93
|
-
`Static` also infers types for TypeBox 1.x schemas
|
|
94
|
-
|
|
95
|
-
Other TypeBox kinds such as `Intersect`, `Cyclic`, and `Ref` resolve to `unknown`, as do plain JSON Schema objects without builder brands.
|
|
100
|
+
`Static` also infers types for TypeBox 1.x schemas without importing TypeBox (`String`, `Number`, `Integer`, `Boolean`, `Null`, `Literal`, `Array`, `Object` with `Type.Optional`/`Type.Readonly`, `Union`, `Record`, `Enum`, `Tuple`, `BigInt`, `Undefined`, `Unsafe`, `Unknown`, and `Any`). Other TypeBox kinds (`Intersect`, `Cyclic`, `Ref`) and unbranded plain JSON Schemas resolve to `unknown`.
|
|
96
101
|
|
|
97
102
|
### Options
|
|
98
103
|
|
|
@@ -100,74 +105,75 @@ Other TypeBox kinds such as `Intersect`, `Cyclic`, and `Ref` resolve to `unknown
|
|
|
100
105
|
import { formats } from "@bastani/atomic-schema/formats";
|
|
101
106
|
|
|
102
107
|
const validator = compile(schema, {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
+
draft: "7", // "2020-12" (default) or "7"
|
|
109
|
+
formats, // check `format`; omitted keeps `format` as an annotation
|
|
110
|
+
schemas: { "https://example.com/point.json": point }, // external $ref documents by URI
|
|
111
|
+
unresolvedRefs: "reject", // compile dangling $ref as false instead of throwing (default "throw")
|
|
112
|
+
coerce: true, // enable coerce() and parse() (see Coercion below)
|
|
108
113
|
});
|
|
109
114
|
```
|
|
110
115
|
|
|
111
|
-
`formats`
|
|
116
|
+
`formats` provides 21 checks: `date`, `date-time`, `duration`, `email`, `hostname`, `idn-email`, `idn-hostname`, `ipv4`, `ipv6`, `iri`, `iri-reference`, `json-pointer`, `json-pointer-uri-fragment`, `regex`, `relative-json-pointer`, `time`, `uri`, `uri-reference`, `uri-template`, `url`, and `uuid`. You can also pass a custom format map.
|
|
112
117
|
|
|
113
|
-
|
|
118
|
+
With `unresolvedRefs: "reject"`, a dangling `$ref` compiles as `false` so only values at that location fail with `unresolved reference <ref>` while the rest of the schema validates normally (useful for external MCP tool schemas).
|
|
114
119
|
|
|
115
120
|
### TypeBox schemas
|
|
116
121
|
|
|
117
|
-
TypeBox 1.x schemas are JSON Schema objects
|
|
122
|
+
TypeBox 1.x schemas are plain JSON Schema objects and compile directly. Inside Atomic extensions and SDK apps, import `Type` from `@bastani/atomic/typebox`; in standalone apps, import from `typebox`:
|
|
118
123
|
|
|
119
124
|
```typescript
|
|
120
|
-
import Type from "typebox"; //
|
|
125
|
+
import Type from "typebox"; // inside Atomic use: import { Type } from "@bastani/atomic/typebox"
|
|
121
126
|
|
|
122
127
|
const user = compile(Type.Object({ name: Type.String(), tags: Type.Array(Type.String()) }));
|
|
123
128
|
```
|
|
124
129
|
|
|
125
|
-
TypeBox's `BigInt` and `Undefined` types are supported (see Values). JavaScript-only types
|
|
130
|
+
TypeBox's `BigInt` and `Undefined` types are supported (see [Values](#values)). JavaScript-only types (`Function`, `Symbol`), refinements, and codecs are not JSON Schema and are not supported.
|
|
126
131
|
|
|
127
132
|
### Coercion
|
|
128
133
|
|
|
129
|
-
`
|
|
134
|
+
Pass `{ coerce: true }` to `compile()` to enable `coerce()` and `parse()` for loosely typed inputs such as model tool-call arguments. Without `coerce: true`, neither method is exposed and no coercion code is built; with it, coercion compiles lazily on the first call.
|
|
130
135
|
|
|
131
136
|
```typescript
|
|
132
137
|
const read = compile(Read, { coerce: true });
|
|
133
138
|
|
|
134
|
-
read.coerce({ path: "a.txt", offset: "10", mode: "text" });
|
|
139
|
+
read.coerce({ path: "a.txt", offset: "10", mode: "text" });
|
|
140
|
+
// { path: "a.txt", offset: 10, mode: "text" }
|
|
135
141
|
|
|
136
142
|
const result = read.parse({ path: "a.txt", offset: "ten", mode: "text" });
|
|
137
143
|
if (result.ok) result.value.offset; // number
|
|
138
144
|
else result.errors; // [{ path: "/offset", keyword: "type", message: "expected integer, got string" }]
|
|
139
145
|
```
|
|
140
146
|
|
|
141
|
-
`coerce(value)` returns the
|
|
147
|
+
`coerce(value)` returns the converted value without mutating `value` (copying only changed paths and returning `value` unchanged when nothing changes). `parse(value)` coerces and then validates, returning `{ ok: true, value }` or `{ ok: false, errors }`.
|
|
142
148
|
|
|
143
|
-
|
|
149
|
+
Coercion runs three passes in order:
|
|
144
150
|
|
|
145
|
-
1. **
|
|
146
|
-
2. **
|
|
147
|
-
* `string`: numbers and booleans become text, and `null` becomes `"null"`.
|
|
148
|
-
* `number`: numeric strings (`""` becomes `0`), `"true"` and `"false"`, booleans become `1` or `0`, and `null` becomes `0`.
|
|
149
|
-
* `integer`: same as `number`, then truncated (`"3.5"` and `3.5` become `3`).
|
|
150
|
-
* `boolean`: `"true"` and `"false"` in any case, `"1"` and `"0"`, `1` and `0`, and `null` becomes `false`.
|
|
151
|
-
* `null`: `"null"`, `"undefined"`, `""`, `"0"`, `0`, and `false`.
|
|
152
|
-
* `bigint`: integer strings (`"12"`, `"12n"`, with `"12.9"` truncated), numbers truncated, `"true"`, `"false"`, and booleans become `1n` or `0n`, and `null` becomes `0n`.
|
|
153
|
-
* `undefined`: `"undefined"`, `"null"`, `""`, `"0"`, `0`, `0n`, `false`, and `null`.
|
|
154
|
-
* `array`: a single value becomes a one-item array, then each item converts. A tuple (`prefixItems` or a draft-7 `items` array) converts its items without wrapping.
|
|
155
|
-
* `object`: each property converts according to `properties`, `patternProperties`, or `additionalProperties`.
|
|
156
|
-
3. **Scalar coercion by type.** Matches Ajv's `coerceTypes` for values left by pass 2, such as type arrays like `["integer", "null"]`. Numbers convert from numeric strings and booleans, booleans from `"true"`, `"false"`, `1`, and `0`, strings from numbers and booleans, `null` from `""`, `0`, and `false`, and `null` converts to `""`, `0`, or `false`. A value that already matches one type in a type array stays unchanged.
|
|
151
|
+
1. **Drop optional nulls:** Removes `null` from any optional object property (under `properties`, `patternProperties`, or `additionalProperties`) whose schema rejects `null`, treating the field as omitted.
|
|
152
|
+
2. **Schema-driven conversion:** Follows `$ref`, `const`/`enum` (converting to a matching member), `anyOf`/`oneOf` (keeping an already-valid value, or picking the first branch conversion that satisfies the full schema), and `allOf` (converting through each member in order). For typed schemas, converts according to the table below:
|
|
157
153
|
|
|
158
|
-
|
|
154
|
+
| Target type | Accepted conversions (Pass 2) |
|
|
155
|
+
| --- | --- |
|
|
156
|
+
| `string` | Numbers and booleans convert to text; `null` converts to `"null"`. |
|
|
157
|
+
| `number` | Numeric strings (`""` → `0`), `"true"`/`"false"`, booleans (`true` → `1`, `false` → `0`), and `null` (`0`). |
|
|
158
|
+
| `integer` | Same as `number`, then truncated toward zero (`"3.5"` and `3.5` → `3`). |
|
|
159
|
+
| `boolean` | `"true"`/`"false"` (case-insensitive), `"1"`/`"0"`, `1`/`0`, and `null` (`false`). |
|
|
160
|
+
| `null` | `"null"`, `"undefined"`, `""`, `"0"`, `0`, and `false`. |
|
|
161
|
+
| `bigint` | Integer strings (`"12"`, `"12n"`, `"12.9"` → `12n`), truncated numbers, `"true"`/`"false"`, booleans (`1n`/`0n`), and `null` (`0n`). |
|
|
162
|
+
| `undefined` | `"undefined"`, `"null"`, `""`, `"0"`, `0`, `0n`, `false`, and `null`. |
|
|
163
|
+
| `array` | Wraps a non-array value in a single-item array, then converts each item. Tuples (`prefixItems` or draft-7 `items` arrays) convert items in place without wrapping. |
|
|
164
|
+
| `object` | Converts each property using `properties`, `patternProperties`, or `additionalProperties`. |
|
|
159
165
|
|
|
160
|
-
|
|
166
|
+
3. **Type-array scalar fallback:** For values untouched by pass 2—most notably multi-type arrays such as `["integer", "null"]`—applies standard scalar conversions (numeric strings/booleans to numbers, `"true"`/`"false"`/`1`/`0` to booleans, numbers/booleans to strings, `""`/`0`/`false` to `null`, and `null` to `""`/`0`/`false`) while leaving any value that already matches one type in the array unchanged.
|
|
161
167
|
|
|
162
|
-
|
|
168
|
+
When passes 2 and 3 differ, pass 2 wins (for example, `null` for a required `string` becomes `"null"`, not `""`). Union branches evaluate in order and reuse recursive `$ref` conversions within a call; unconvertible values remain unchanged so validation reports them cleanly. Items beyond a draft-7 `items` tuple (`additionalItems`) are not coerced.
|
|
163
169
|
|
|
164
170
|
### Values
|
|
165
171
|
|
|
166
|
-
- An optional property whose value is `undefined` counts as absent
|
|
167
|
-
- `{ type: "bytes", minLength, maxLength }` matches a `Uint8Array` within those length bounds
|
|
168
|
-
- `{ type: "bigint" }` matches a `bigint
|
|
172
|
+
- An optional property whose value is `undefined` counts as absent. A required property set to `undefined` counts as present—valid only if its schema accepts `undefined`, and reported as missing otherwise.
|
|
173
|
+
- `{ type: "bytes", minLength, maxLength }` matches a `Uint8Array` within those length bounds.
|
|
174
|
+
- `{ type: "bigint" }` matches a `bigint`; numeric bounds (`minimum`, `maximum`, `exclusiveMinimum`, `exclusiveMaximum`, `multipleOf`) work with both `number` and `bigint` bounds.
|
|
169
175
|
- `{ type: "undefined" }` matches `undefined`.
|
|
170
|
-
- `equal(a, b)`
|
|
176
|
+
- `equal(a, b)` tests JSON value equality with the same rules as `const`, `enum`, and `uniqueItems`.
|
|
171
177
|
|
|
172
178
|
## Supported keywords
|
|
173
179
|
|
|
@@ -4,12 +4,12 @@ sidebarTitle: "@bastani/atomic-storage-postgres"
|
|
|
4
4
|
description: "PostgreSQL storage adapter for Atomic sessions and Intercom multi-node routing, usable from the CLI or TypeScript SDK."
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
`@bastani/atomic-storage-postgres` is Atomic's standalone [PostgreSQL](https://www.postgresql.org) storage adapter. It stores sessions and Intercom multi-node routing in one shared PostgreSQL database so multiple machines or SDK hosts can share state. Unlike the six core libraries in [Standalone libraries](/libraries), this package is not bundled inside `@bastani/atomic`; install it only when you use PostgreSQL.
|
|
7
|
+
`@bastani/atomic-storage-postgres` is Atomic's optional standalone [PostgreSQL](https://www.postgresql.org) storage adapter. It stores sessions and Intercom multi-node routing in one shared PostgreSQL database so multiple machines or SDK hosts can share state. Unlike the six core libraries in [Standalone libraries](/libraries), this package is not bundled inside `@bastani/atomic`; install it only when you use PostgreSQL.
|
|
8
8
|
|
|
9
9
|
- **PostgreSQL version requirement:** Atomic needs **PostgreSQL 16 or newer**.
|
|
10
|
-
- **Plain ESM with types:** Ships plain JavaScript ESM
|
|
10
|
+
- **Plain ESM with bundled types:** Ships plain JavaScript ESM with TypeScript declarations and requires Node.js 24.20+ with no TypeScript loader.
|
|
11
11
|
|
|
12
|
-
For operator setup, role creation SQL, migrations, and troubleshooting, see [PostgreSQL setup](/storage/postgres). For all
|
|
12
|
+
For operator setup, role creation SQL, migrations, and troubleshooting, see [PostgreSQL setup](/storage/postgres). For all four SDK storage backends and `createAgentSessionRuntime()`, see [SDK storage backends](/sdk/storage).
|
|
13
13
|
|
|
14
14
|
## Installation
|
|
15
15
|
|
|
@@ -62,63 +62,77 @@ Pass the returned `SqliteDatabase` to `createAgentSession({ sessionStore: { kind
|
|
|
62
62
|
| Option | Type | Default | Description |
|
|
63
63
|
| --- | --- | --- | --- |
|
|
64
64
|
| `url` | `string` *(required)* | — | A `postgres://` or `postgresql://` URL with a username and no embedded password. Any password in the URL or a `password=` query parameter is rejected with `credential-in-url`. |
|
|
65
|
-
| `password` | `string \| (() => Promise<string>)` | — | Password string or async callback invoked for each new connection, and once
|
|
65
|
+
| `password` | `string \| (() => Promise<string>)` | — | Password string or async callback invoked for each new connection, and once on open to distinguish its credential in the shared pool. Omit when using cloud `auth`; combining cloud `auth` with `password` throws `conflicting-token`. |
|
|
66
66
|
| `auth` | `"password" \| "azure-entra" \| "aws-iam" \| "gcp-iam"` | `"password"` | Credential strategy. Cloud modes request short-lived tokens per new connection via the provider's SDK. |
|
|
67
|
-
| `maxConnections` | `number` | `8` (`DEFAULT_MAX_CONNECTIONS`) |
|
|
68
|
-
| `readerMaxConnections` | `number` | `2` (`DEFAULT_READER_MAX_CONNECTIONS`) |
|
|
69
|
-
| `statementTimeoutMs` | `number` | `30000` (`DEFAULT_STATEMENT_TIMEOUT_MS`) |
|
|
70
|
-
| `connectTimeoutMs` | `number` | `10000` (`DEFAULT_CONNECT_TIMEOUT_MS`) |
|
|
71
|
-
| `idleTimeoutMs` | `number` | `300000` (`DEFAULT_IDLE_TIMEOUT_MS`) | How long a pool's last connection stays open
|
|
72
|
-
| `keepAliveIdleMs` | `number` | `60000` (`DEFAULT_KEEPALIVE_IDLE_MS`) |
|
|
73
|
-
| `maxPreparedStatements` | `number` | `256` (`DEFAULT_MAX_PREPARED_STATEMENTS`)
|
|
67
|
+
| `maxConnections` | `number` | `8` (`DEFAULT_MAX_CONNECTIONS`) | Maximum connections in the process's main pool (positive integer). Databases opened in the same process with identical connection, auth, schema, transport, and pool options share one main pool, one reader pool, and one listening connection, closed when the last handle closes. See [Tuning for many concurrent agents](/storage/postgres#tuning-for-many-concurrent-agents). |
|
|
68
|
+
| `readerMaxConnections` | `number` | `2` (`DEFAULT_READER_MAX_CONNECTIONS`) | Maximum connections in the shared reader pool for `openReader()` handles, capped at `maxConnections`. `0` disables the separate reader pool so reads share the main pool. |
|
|
69
|
+
| `statementTimeoutMs` | `number` | `30000` (`DEFAULT_STATEMENT_TIMEOUT_MS`) | Maximum time one statement may run before the server cancels it, in milliseconds (positive integer). |
|
|
70
|
+
| `connectTimeoutMs` | `number` | `10000` (`DEFAULT_CONNECT_TIMEOUT_MS`) | Maximum time to open a connection or wait for a free pooled connection, in milliseconds (positive integer). |
|
|
71
|
+
| `idleTimeoutMs` | `number` | `300000` (`DEFAULT_IDLE_TIMEOUT_MS`) | How long a pool's last connection stays open while idle, in milliseconds. Burst connections close after `SURGE_IDLE_TIMEOUT_MS` (`10000`) idle, or `idleTimeoutMs` if shorter. |
|
|
72
|
+
| `keepAliveIdleMs` | `number` | `60000` (`DEFAULT_KEEPALIVE_IDLE_MS`) | Idle milliseconds before TCP keepalive probes start on pooled connections. |
|
|
73
|
+
| `maxPreparedStatements` | `number` | `256` (`DEFAULT_MAX_PREPARED_STATEMENTS`) on direct connections and PgBouncer 1.21+ with `max_prepared_statements > 0`; `0` behind other transaction poolers (auto-detected on the first connection) | Maximum statements each pooled connection keeps prepared so PostgreSQL parses and plans them once per connection. Pass `0` to force unnamed statements, or pass a positive integer to override auto-detection or change the cap. |
|
|
74
74
|
| `listenUrl` | `string` | `url` | Direct session-mode endpoint for `LISTEN`/`NOTIFY` wake-ups when `url` goes through a transaction pooler. |
|
|
75
|
-
| `schema` | `string` | `"atomic"` (`DEFAULT_SCHEMA`) | Lowercase schema holding Atomic's tables.
|
|
75
|
+
| `schema` | `string` | `"atomic"` (`DEFAULT_SCHEMA`) | Lowercase schema holding Atomic's tables. Databases whose existing tables live in `public` without an `atomic` schema continue using `public` until `atomic storage migrate` moves them. Every transaction runs `SET LOCAL search_path`. |
|
|
76
76
|
| `sdkSearchPaths` | `readonly string[]` | — | Extra npm prefix directories to search when loading a cloud IAM SDK not found beside the adapter. CLI adapter loading passes `<agentDir>/npm`. |
|
|
77
77
|
| `proxy` | `string` | Environment proxy | An `http://` or `https://` proxy URL for `CONNECT` tunneling (credentials sent in `Proxy-Authorization` and redacted), or `"none"` to connect directly. Overrides environment proxy variables for TCP hosts. |
|
|
78
|
-
| `socket` | `PostgresSocketFactory` | — | Custom transport callback `(target: ProxyTarget) => Duplex \| Promise<Duplex>` carrying
|
|
78
|
+
| `socket` | `PostgresSocketFactory` | — | Custom transport callback `(target: ProxyTarget) => Duplex \| Promise<Duplex>` carrying PostgreSQL wire traffic (`target` has `{ host, port }`). Atomic negotiates TLS over it as over a normal socket. Cannot be combined with `proxy` (`conflicting-transport`). Unix socket directories always connect directly. |
|
|
79
79
|
|
|
80
80
|
## Exported API
|
|
81
81
|
|
|
82
|
-
-
|
|
83
|
-
- `DEFAULT_MAX_CONNECTIONS` (`8`), `DEFAULT_READER_MAX_CONNECTIONS` (`2`), `DEFAULT_STATEMENT_TIMEOUT_MS` (`30000`), `DEFAULT_CONNECT_TIMEOUT_MS` (`10000`), `DEFAULT_IDLE_TIMEOUT_MS` (`300000`), `SURGE_IDLE_TIMEOUT_MS` (`10000`), `DEFAULT_KEEPALIVE_IDLE_MS` (`60000`), `DEFAULT_MAX_PREPARED_STATEMENTS` (`256`), `DEFAULT_SCHEMA` (`"atomic"`).
|
|
84
|
-
-
|
|
85
|
-
- `
|
|
86
|
-
|
|
87
|
-
|
|
82
|
+
- **`openPostgresDatabase(options: PostgresDatabaseOptions): Promise<SqliteDatabase>`** — opens a pooled PostgreSQL-backed `SqliteDatabase`.
|
|
83
|
+
- **Default constants:** `DEFAULT_MAX_CONNECTIONS` (`8`), `DEFAULT_READER_MAX_CONNECTIONS` (`2`), `DEFAULT_STATEMENT_TIMEOUT_MS` (`30000`), `DEFAULT_CONNECT_TIMEOUT_MS` (`10000`), `DEFAULT_IDLE_TIMEOUT_MS` (`300000`), `SURGE_IDLE_TIMEOUT_MS` (`10000`), `DEFAULT_KEEPALIVE_IDLE_MS` (`60000`), `DEFAULT_MAX_PREPARED_STATEMENTS` (`256`), `DEFAULT_SCHEMA` (`"atomic"`).
|
|
84
|
+
- **Types:** `PostgresDatabaseOptions`, `PostgresSocketFactory`, `ProxyTarget`.
|
|
85
|
+
- **Default export:** `StorageAdapterModule` (`{ atomicStorageAdapter: 1, liveSecrets, openDatabase }`) used by Atomic CLI settings and `{ kind: "adapter" }` selections.
|
|
86
|
+
|
|
87
|
+
<Note>
|
|
88
|
+
**Low-level SQL translation helpers:** The package also exports `numberPlaceholders(sql)` (rewrites positional `?` parameters outside literals, quoted identifiers, and comments to `$1`, `$2`, ...) and `physicalIdentifiers(sql)` (replaces unquoted identifiers longer than 63 bytes with deterministic PostgreSQL physical names). Ordinary applications do not need to call these directly—they are provided for custom adapters or tooling translating Atomic SQLite queries to PostgreSQL.
|
|
89
|
+
</Note>
|
|
88
90
|
|
|
89
91
|
## Cloud IAM authentication
|
|
90
92
|
|
|
91
|
-
On Azure, AWS, and Google Cloud, set `auth` and omit `password` / `secrets.password`. Only the selected provider's SDK
|
|
93
|
+
On Azure, AWS, and Google Cloud, set `auth` and omit `password` / `secrets.password`. Only the selected provider's SDK loads on first connection. Tokens stay in memory, never appear in settings or errors, time out after 8 seconds, and clear and retry once on rejection (`28P01`, or Azure `28000`). Missing SDKs or token failures throw `StorageConfigError` (`reason: "auth-unavailable"`). Cloud tokens require TLS (`sslmode=verify-full` or `require`).
|
|
92
94
|
|
|
93
95
|
| `auth` | Optional peer SDK | CLI user-scope install | Credential source |
|
|
94
96
|
| --- | --- | --- | --- |
|
|
95
|
-
| `azure-entra` | `@azure/identity` | `atomic install npm:@azure/identity
|
|
96
|
-
| `aws-iam` | `@aws-sdk/rds-signer` | `atomic install npm:@aws-sdk/rds-signer
|
|
97
|
-
| `gcp-iam` | `google-auth-library` | `atomic install npm:google-auth-library
|
|
97
|
+
| `azure-entra` | `@azure/identity` | `atomic install npm:@azure/identity` | `DefaultAzureCredential` for `https://ossrdbms-aad.database.windows.net/.default` (reused until 5 minutes before expiry) |
|
|
98
|
+
| `aws-iam` | `@aws-sdk/rds-signer` | `atomic install npm:@aws-sdk/rds-signer` | RDS `Signer` using the AWS default credential chain (`AWS_*`, profiles, IRSA, instance profile) |
|
|
99
|
+
| `gcp-iam` | `google-auth-library` | `atomic install npm:google-auth-library` | `GoogleAuth` for `https://www.googleapis.com/auth/sqlservice.login` (ADC, GKE/GCE/Cloud Run metadata) |
|
|
98
100
|
|
|
99
|
-
For Azure Database for PostgreSQL Flexible Server (PostgreSQL 16+), Azure HorizonDB (PostgreSQL 17, read/write endpoint), Amazon RDS/Aurora, and Google Cloud SQL role-grant SQL, see [
|
|
101
|
+
For Azure Database for PostgreSQL Flexible Server (PostgreSQL 16+), Azure HorizonDB (PostgreSQL 17, read/write endpoint), Amazon RDS/Aurora, and Google Cloud SQL role-grant SQL, see [Cloud identities](/storage/postgres#cloud-identities).
|
|
100
102
|
|
|
101
103
|
## TLS, HTTP proxies, and connection poolers
|
|
102
104
|
|
|
103
105
|
- **TLS defaults:** When `url` omits `sslmode`, Atomic applies `sslmode=verify-full` for remote hosts (checking `PGHOST` if omitted from the URL). Add `sslrootcert=/path/to/ca.pem` for private CAs. Without `sslrootcert`, `require` verifies both certificate and hostname like `verify-full` (stricter than libpq). TLS parameter names are case-sensitive; unknown `sslmode` values are rejected.
|
|
104
106
|
- **HTTP `CONNECT` proxies:** Without `options.proxy`, remote TCP hosts check `HTTPS_PROXY` (`https_proxy`), then `ALL_PROXY` (when HTTP/HTTPS), then `HTTP_PROXY`, respecting `NO_PROXY`. Loopback hosts and Unix socket directories connect directly. Keep `sslmode=verify-full` (or `verify-ca` with a private CA) so TLS runs end to end through the tunnel.
|
|
105
|
-
- **Connection poolers and wake-ups:** Works with transaction-mode poolers (PgBouncer, Azure port `6432`, Supabase Supavisor, Neon `-pooler`) with no session-level state.
|
|
107
|
+
- **Connection poolers and wake-ups:** Works with transaction-mode poolers (PgBouncer, Azure port `6432`, Supabase Supavisor, Neon `-pooler`) with no session-level state. Atomic probes the first connection automatically: on PgBouncer 1.21+ with `max_prepared_statements > 0`, it keeps prepared statements enabled (up to `256`); behind transaction poolers that do not support prepared statements (on any port), it disables them automatically. Set `maxPreparedStatements` only to override auto-detection or change the per-connection cap. A process that listens for wake-ups (such as an Intercom broker) opens one extra `LISTEN` connection outside its pools; when `url` uses a transaction pooler, set `listenUrl` to a direct endpoint or Atomic falls back to polling. See the [PgBouncer guide](/storage/postgres/pgbouncer).
|
|
106
108
|
- **Retries and errors:** Connection drops, lock conflicts (`40001`, `40P01`, `55P03`), and canceled statements (`57014`) throw `StorageTransientError` (read-only and unwritten calls retry automatically). Invalid credentials (`28P01`), missing databases (`3D000`), and certificate errors fail immediately. Missing privileges (`42501`) fail immediately with `StorageConfigError` (`reason: "missing-privilege"`) naming the exact `GRANT` or migration command.
|
|
107
109
|
|
|
108
110
|
## CLI configuration
|
|
109
111
|
|
|
110
|
-
Join a machine with the CLI after installing in user scope and running `atomic storage migrate`:
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
112
|
+
Join a machine with the CLI after installing the adapter in user scope and running `atomic storage migrate`:
|
|
113
|
+
|
|
114
|
+
<Steps>
|
|
115
|
+
<Step title="Write the runtime password to a mode-0600 file">
|
|
116
|
+
```bash
|
|
117
|
+
(umask 077; printf 'Runtime password: '; read -rs password; printf '\n'; printf '%s' "$password" > ~/atomic-db-password)
|
|
118
|
+
```
|
|
119
|
+
</Step>
|
|
120
|
+
<Step title="Join the shared database and remove the temporary file">
|
|
121
|
+
```bash
|
|
122
|
+
atomic storage join 'postgresql://atomic_runtime@db.example.com:5432/atomic' --password-file ~/atomic-db-password
|
|
123
|
+
rm ~/atomic-db-password # atomic storage join keeps its own copy
|
|
124
|
+
```
|
|
125
|
+
</Step>
|
|
126
|
+
<Step title="Restart Intercom and verify connectivity">
|
|
127
|
+
```bash
|
|
128
|
+
atomic intercom restart
|
|
129
|
+
atomic storage status
|
|
130
|
+
```
|
|
131
|
+
</Step>
|
|
132
|
+
</Steps>
|
|
119
133
|
|
|
120
134
|
## Related docs
|
|
121
135
|
|
|
122
|
-
- [PostgreSQL operator guide](/storage/postgres): role creation SQL, migrations,
|
|
136
|
+
- [PostgreSQL operator guide](/storage/postgres): role creation SQL, migrations, cloud provider setup, and troubleshooting.
|
|
123
137
|
- [SDK storage backends](/sdk/storage): complete `createAgentSession()`, `createAgentSessionRuntime()`, and error-handling recipes.
|
|
124
138
|
- [Standalone libraries](/libraries): all published `@bastani/atomic-*` packages.
|