@bastani/atomic 0.9.35-alpha.4 → 0.9.35
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 +51 -0
- package/dist/builtin/intercom/package.json +1 -1
- package/dist/builtin/mcp/CHANGELOG.md +6 -0
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/package.json +1 -1
- package/dist/builtin/web-access/package.json +1 -1
- package/dist/builtin/workflows/CHANGELOG.md +32 -0
- package/dist/builtin/workflows/package.json +1 -1
- package/dist/builtin/workflows/src/extension/index.bundle.mjs +114 -45
- package/dist/builtin/workflows/src/index.js +98 -34
- package/dist/builtin/workflows/src/shared/authoring-contract-ui.d.ts +2 -0
- package/dist/core/settings-schema.d.ts +1 -0
- package/dist/core/settings-schema.d.ts.map +1 -1
- package/dist/core/settings-schema.js +5 -0
- package/dist/core/settings-schema.js.map +1 -1
- package/docs/settings.md +3 -0
- package/docs/workflows/api-reference.md +4 -1
- package/docs/workflows/operations.md +2 -0
- package/npm-shrinkwrap.json +32 -32
- package/package.json +3 -3
- package/schemas/settings.schema.json +6 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,57 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## [0.9.35] - 2026-10-13
|
|
6
|
+
|
|
7
|
+
### Breaking Changes
|
|
8
|
+
|
|
9
|
+
- Removed the experimental `@bastani/atomic/client` entrypoint and the `@earendil-works/pi-client` and `@earendil-works/pi-protocol` dependencies, which upstream Pi no longer publishes. SDK code that imported `@bastani/atomic/client` should use `createAgentSession()` from `@bastani/atomic` in-process or RPC mode (`--mode rpc` / `@bastani/atomic/rpc-entry`), or pin the previous release. The CLI, RPC mode, extensions and workflows are unaffected.
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- `session.workflows.resume(runId)` now adopts a paused run that was launched through the model-facing `workflow` tool once its owning session has been disposed, in the same process or after the owning process exits. Disposing a session quits its in-flight runs at their last checkpoint and durably records that it released its checkpointed paused runs; the adopting session becomes the owner and the run continues under the same UUID. Runs whose owner is still open, runs whose owner crashed without disposing, and finished runs are still refused ([#3566](https://github.com/bastani-inc/atomic/issues/3566)).
|
|
14
|
+
- Switching sessions with `/new`, `/fork`, or `/resume` now releases the previous session's paused workflow runs, the same way disposing a session does. The model in the new session can inspect them with the `workflow` tool's `status` and `stages` actions and resume them, and `session.workflows.resume(runId)` can adopt them; adoption, including the `/workflow resume <id>` slash command, transfers ownership to the resuming session. The new session lists the released runs with their `/workflow resume <id>` commands, and, in the process that released it, a run another session already adopted now reports that it is owned by another session. `/reload` still keeps runs executing and releases nothing ([#3569](https://github.com/bastani-inc/atomic/issues/3569)).
|
|
15
|
+
- SDK and RPC clients can read stored session summaries with their summarized-through message IDs, and list or inspect workflow history with saved summaries and run identities. SDK sessions expose `sessionSummary`; RPC adds `get_session_summary`, `list_sessions`, `list_workflow_runs`, and `get_workflow_run_summary`.
|
|
16
|
+
- Added `ATOMIC_CLIPBOARD_OSC52=1`, with legacy alias `PI_CLIPBOARD_OSC52=1`, to send copied text through OSC 52 after the local clipboard write. Use it when a multiplexer or remote IDE session leaves no SSH markers for Atomic to detect.
|
|
17
|
+
- Added elapsed time while a codemode script runs and total time when it finishes. Bash commands continued in the background keep their "Observed for" timing label.
|
|
18
|
+
- Codemode declarations now include input constraints such as integer bounds and defaults that TypeScript types alone cannot express.
|
|
19
|
+
- Added per-key OpenRouter model lists with the key's context limits, output limits and prices. Configured regional endpoints are respected, and the personalized list is saved for offline use.
|
|
20
|
+
- Added `workflows.durability.poolSize` to configure maximum connections per workflow database pool for managed and remote PostgreSQL (default 10, minimum 2).
|
|
21
|
+
|
|
22
|
+
### Changed
|
|
23
|
+
|
|
24
|
+
- Changed `serializeConversation()` (branch summaries, resume-picker session summaries, and the policy-refusal summary fallback) to omit thinking blocks; replayed thinking is often not in the live context, so including it could make a summarization request larger than the context it summarizes and fail. Verbatim line compaction still serializes thinking lines.
|
|
25
|
+
- Changed `openai-codex/gpt-6.1-sol` to a 500,000-token context window (up from 272,000) with no long-context price tier on Standard, Fast, or Ultrafast. OpenAI raised GPT-6.1 Sol's default context to 500k in Codex & Work for ChatGPT subscriptions and does not charge long-context fees when usage draws from the subscription. `openai/gpt-6.1-sol` and the other Codex models are unchanged.
|
|
26
|
+
- MCP tools now describe their content blocks and nested structured-content fields directly in codemode declarations, including schemas with local references.
|
|
27
|
+
- `showHardwareCursor` now uses only the terminal cursor at the focused input position instead of also drawing a reverse-video cursor cell. Custom TUI components can use `renderFakeCursor()` with `CURSOR_MARKER` to follow this setting.
|
|
28
|
+
|
|
29
|
+
### Fixed
|
|
30
|
+
|
|
31
|
+
- Fixed the code mode tool description claiming every failed tool call throws; a tool that declares an output schema resolves with its value on failure too (for example `bash` with a non-zero exit), so scripts should check its fields.
|
|
32
|
+
- Fixed `read` reporting success when it refuses a selected range as too large. The refusal is now an error result, so models see a failed read with guidance to read a smaller range, and code mode's `tools.read(...)` throws instead of resolving with the refusal text as if it were the file's contents ([#3574](https://github.com/bastani-inc/atomic/issues/3574)).
|
|
33
|
+
- Fixed `/resume` and `atomic -r` hiding session summaries after newer messages. The latest summary now stays visible until a branch summary retires it, and opening or resuming an interactive session refreshes missing or stale summaries in the background.
|
|
34
|
+
- Fixed tree navigation moving the active branch while a user prompt is waiting for `before_agent_start` handlers to finish.
|
|
35
|
+
- Fixed print mode returning success for responses truncated by the model output limit. Partial text remains on stdout, with a warning on stderr and exit code 1.
|
|
36
|
+
- Fixed home-directory (`~`) expansion in resource include and exclude patterns, including Windows environments where `HOME` differs from `USERPROFILE`.
|
|
37
|
+
- Fixed MCP tool calls rejecting array, null, or primitive structured content.
|
|
38
|
+
- Fixed cancelled MCP requests being retried after a shared authorization refresh.
|
|
39
|
+
- Fixed slow MCP resource listings delaying tools on connection. Resources and templates are now listed only on demand.
|
|
40
|
+
- Fixed code mode taking excessive time to join large numbers of text output items.
|
|
41
|
+
- Fixed transient Windows permission errors when acquiring the authentication lock, while keeping persistent permission failures bounded.
|
|
42
|
+
- Fixed runs started by `pi.sendMessage(..., { triggerTurn: true })`, including protected workflow task completions, skipping `before_agent_start` and losing handler-added system prompt sections after tool calls. The event now distinguishes user and custom messages with `messageType`; handlers reading `prompt` or `images` must first narrow to `"user"`.
|
|
43
|
+
- Fixed interrupt messages dropping an earlier custom message while its `before_agent_start` handler was still running.
|
|
44
|
+
- Fixed misplaced `// @options:` lines silently being ignored. They now fail the codemode call before the script runs; options must be on the first line.
|
|
45
|
+
- Fixed Kitty image detection inside Herdr terminals and delayed terminal-reply bytes leaking into keyboard input.
|
|
46
|
+
- Fixed shifted-symbol keybindings such as `+` using the physical key name instead of the produced symbol.
|
|
47
|
+
- Fixed OpenRouter account model refresh being blocked by an unavailable or invalid optional pi.dev catalog.
|
|
48
|
+
- Fixed running codemode and bash rows continuing to update elapsed-time displays after removal.
|
|
49
|
+
|
|
50
|
+
## [0.9.35-alpha.5] - 2026-10-12
|
|
51
|
+
|
|
52
|
+
### Added
|
|
53
|
+
|
|
54
|
+
- Added `workflows.durability.poolSize` to configure maximum connections per workflow database pool for managed and remote PostgreSQL (default 10, minimum 2).
|
|
55
|
+
|
|
5
56
|
## [0.9.35-alpha.4] - 2026-10-13
|
|
6
57
|
|
|
7
58
|
### Breaking Changes
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bastani/intercom",
|
|
3
|
-
"version": "0.9.35
|
|
3
|
+
"version": "0.9.35",
|
|
4
4
|
"private": true,
|
|
5
5
|
"description": "Atomic extension providing a private coordination channel between parent and child agent sessions. Fork of: https://github.com/nicobailon/pi-intercom",
|
|
6
6
|
"contributors": [
|
|
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.9.35] - 2026-10-13
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
|
|
14
|
+
- Fixed OAuth exchanging an authorization code whose `iss` parameter could not be checked because no authorization server metadata was discovered. It now throws `OAuthIssuerMismatchError`, whose `expected` is `undefined` in that case (RFC 9207). Reported by [@AizenvoltPrime](https://github.com/AizenvoltPrime).
|
|
15
|
+
|
|
10
16
|
## [0.9.35-alpha.1] - 2026-10-12
|
|
11
17
|
|
|
12
18
|
### Fixed
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bastani/subagents",
|
|
3
|
-
"version": "0.9.35
|
|
3
|
+
"version": "0.9.35",
|
|
4
4
|
"private": true,
|
|
5
5
|
"description": "Atomic extension for delegating tasks to subagents with parallel execution. Fork of: https://github.com/nicobailon/pi-subagents",
|
|
6
6
|
"contributors": [
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bastani/web-access",
|
|
3
|
-
"version": "0.9.35
|
|
3
|
+
"version": "0.9.35",
|
|
4
4
|
"private": true,
|
|
5
5
|
"description": "Atomic extension for web search, URL fetching, GitHub repo cloning, PDF/video extraction. Fork of: https://github.com/nicobailon/pi-web-access",
|
|
6
6
|
"contributors": [
|
|
@@ -6,6 +6,38 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [0.9.35] - 2026-10-13
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- `session.workflows.resume(runId)` now adopts a paused run that was launched through the model-facing `workflow` tool once its owning session has been disposed, in the same process or after the owning process exits. Disposing a session quits its in-flight runs at their last checkpoint and durably records that it released its checkpointed paused runs; the adopting session becomes the owner and the run continues under the same UUID. Runs whose owner is still open, runs whose owner crashed without disposing, and finished runs are still refused ([#3566](https://github.com/bastani-inc/atomic/issues/3566)).
|
|
14
|
+
- Switching sessions with `/new`, `/fork`, or `/resume` now releases the previous session's paused workflow runs, the same way disposing a session does. The model in the new session can inspect them with the `workflow` tool's `status` and `stages` actions and resume them, and `session.workflows.resume(runId)` can adopt them; adoption, including the `/workflow resume <id>` slash command, transfers ownership to the resuming session. The new session lists the released runs with their `/workflow resume <id>` commands, and, in the process that released it, a run another session already adopted now reports that it is owned by another session. `/reload` still keeps runs executing and releases nothing ([#3569](https://github.com/bastani-inc/atomic/issues/3569)).
|
|
15
|
+
- Resuming a workflow from another project with `/workflow resume <id>` now offers to fork its saved progress into the current directory under a new run ID, leaving the source run unchanged. SDK, tool, and headless resume requests return an actionable error instead of running in a different project.
|
|
16
|
+
- Workflow resume history now shows descriptive run identities and saved generated progress summaries, and supplies saved summaries to the main chat when resuming.
|
|
17
|
+
- SDK workflow lists and details expose run labels, identities, saved summaries and summarized-through timestamps. `listRuns({ includeDurable: true })` includes stored resumable and completed history; RPC clients can access the same history.
|
|
18
|
+
- Added `durability.poolSize` to SDK workflow runs (default 10, minimum 2), applying the connection maximum to DBOS SQL pools, ownership-fence pools, and their replacement connections for managed or remote PostgreSQL. Later requests for a different size reject once the process is configured.
|
|
19
|
+
|
|
20
|
+
### Fixed
|
|
21
|
+
|
|
22
|
+
- Fixed an SDK session started after another session in the same process was disposed falling back to non-durable workflows with `Managed Postgres health observer is stopped.`. Releasing the last session now discards the stopped workflow database configuration, so the next session starts a fresh managed Postgres and launches durably ([#3565](https://github.com/bastani-inc/atomic/issues/3565)).
|
|
23
|
+
- Fixed durable workflows failing with `atomicWorkflowHandle is not a registered DBOS workflow function` when a new SDK session uses a different working directory after the last session is disposed. Final session disposal now releases workflow registrations so the next session recreates them in its own SDK ([#3577](https://github.com/bastani-inc/atomic/issues/3577)).
|
|
24
|
+
- Workflow SDK and RPC history now excludes stored runs from other projects. Resuming through either API respects disabled session summaries, and killing a blocked run requests a new final summary.
|
|
25
|
+
- Concurrent workflow metadata writes and legacy recovery now queue instead of exhausting a small ownership-fence connection pool.
|
|
26
|
+
- Fixed completed durable workflows leaving their root DBOS record `PENDING` when run metadata was written before DBOS recorded the root's result. Admission, including same-ID retries and admission recovery, now waits for the root's own result to be saved, without holding its lock or database connection, before writing metadata, so the root completes as `SUCCESS` and DBOS cleanup can remove it.
|
|
27
|
+
- Retrying or recovering an unfinished durable registration now fails within the admission deadline without starting workflow code or saving resume metadata if its original root cannot finish. Restoring the database does not guarantee that an abandoned registration can be resumed.
|
|
28
|
+
|
|
29
|
+
## [0.9.35-alpha.5] - 2026-10-12
|
|
30
|
+
|
|
31
|
+
### Added
|
|
32
|
+
|
|
33
|
+
- Added `durability.poolSize` to SDK workflow runs (default 10, minimum 2), applying the connection maximum to DBOS SQL pools, ownership-fence pools, and their replacement connections for managed or remote PostgreSQL. Later requests for a different size reject once the process is configured.
|
|
34
|
+
|
|
35
|
+
### Fixed
|
|
36
|
+
|
|
37
|
+
- Concurrent workflow metadata writes and legacy recovery now queue instead of exhausting a small ownership-fence connection pool.
|
|
38
|
+
- Fixed completed durable workflows leaving their root DBOS record `PENDING` when run metadata was written before DBOS recorded the root's result. Admission, including same-ID retries and admission recovery, now waits for the root's own result to be saved, without holding its lock or database connection, before writing metadata, so the root completes as `SUCCESS` and DBOS cleanup can remove it.
|
|
39
|
+
- Retrying or recovering an unfinished durable registration now fails within the admission deadline without starting workflow code or saving resume metadata if its original root cannot finish. Restoring the database does not guarantee that an abandoned registration can be resumed.
|
|
40
|
+
|
|
9
41
|
## [0.9.35-alpha.3] - 2026-10-12
|
|
10
42
|
|
|
11
43
|
### Added
|
|
@@ -4552,8 +4552,7 @@ async function reconcileDbosAdmission(sdk, metadata, repairMissing, checkReady)
|
|
|
4552
4552
|
}
|
|
4553
4553
|
if (!repairMissing || metadata.completedCheckpoints > 0 || metadata.pendingPrompts > 0)
|
|
4554
4554
|
return false;
|
|
4555
|
-
|
|
4556
|
-
await sdk.startWorkflow(id, metadata.name, metadata.inputs);
|
|
4555
|
+
await sdk.startWorkflow(id, metadata.name, metadata.inputs);
|
|
4557
4556
|
signal.throwIfAborted();
|
|
4558
4557
|
const accepted = await sdk.retrieveWorkflow(id);
|
|
4559
4558
|
signal.throwIfAborted();
|
|
@@ -4580,6 +4579,27 @@ var init_dbos_admission_recovery = __esm(() => {
|
|
|
4580
4579
|
init_dbos_metadata();
|
|
4581
4580
|
});
|
|
4582
4581
|
|
|
4582
|
+
// dist/builtin/workflows/src/durable/dbos-pool-size.ts
|
|
4583
|
+
function validateDbosPoolSize(poolSize, name = "durability.poolSize") {
|
|
4584
|
+
if (typeof poolSize !== "number" || !Number.isInteger(poolSize) || poolSize < 2) {
|
|
4585
|
+
throw new TypeError(`${name} must be an integer of at least 2 (one ownership connection and one transaction connection)`);
|
|
4586
|
+
}
|
|
4587
|
+
}
|
|
4588
|
+
function resolvedDbosPoolSize() {
|
|
4589
|
+
return getDbosProcessOwner().poolSize ?? 10;
|
|
4590
|
+
}
|
|
4591
|
+
function requestDbosPoolSize(poolSize) {
|
|
4592
|
+
validateDbosPoolSize(poolSize);
|
|
4593
|
+
const owner = getDbosProcessOwner();
|
|
4594
|
+
if ((owner.configured !== undefined || owner.wrappers !== undefined) && resolvedDbosPoolSize() !== poolSize) {
|
|
4595
|
+
throw new Error(`Workflow durability is already configured for this process with poolSize ${resolvedDbosPoolSize()}; DBOS cannot switch to poolSize ${poolSize} until the process restarts.`);
|
|
4596
|
+
}
|
|
4597
|
+
owner.poolSize = poolSize;
|
|
4598
|
+
}
|
|
4599
|
+
var init_dbos_pool_size = __esm(() => {
|
|
4600
|
+
init_dbos_process_owner();
|
|
4601
|
+
});
|
|
4602
|
+
|
|
4583
4603
|
// dist/builtin/workflows/src/durable/dbos-prompt-reservations.ts
|
|
4584
4604
|
function emptyDbosPromptReservationState(baseline = 0, epoch = crypto.randomUUID()) {
|
|
4585
4605
|
const normalized = Math.max(0, Math.trunc(baseline));
|
|
@@ -5246,6 +5266,7 @@ class DbosOwnerFence {
|
|
|
5246
5266
|
pool;
|
|
5247
5267
|
executorId;
|
|
5248
5268
|
endPool;
|
|
5269
|
+
compactionPool;
|
|
5249
5270
|
lifetime;
|
|
5250
5271
|
endedClients = new WeakSet;
|
|
5251
5272
|
protectedClients = new Set;
|
|
@@ -5258,10 +5279,11 @@ class DbosOwnerFence {
|
|
|
5258
5279
|
get invalidated() {
|
|
5259
5280
|
return this.lost;
|
|
5260
5281
|
}
|
|
5261
|
-
constructor(pool, executorId, endPool) {
|
|
5282
|
+
constructor(pool, executorId, endPool, compactionPool = pool) {
|
|
5262
5283
|
this.pool = pool;
|
|
5263
5284
|
this.executorId = executorId;
|
|
5264
5285
|
this.endPool = endPool;
|
|
5286
|
+
this.compactionPool = compactionPool;
|
|
5265
5287
|
}
|
|
5266
5288
|
fail() {
|
|
5267
5289
|
this.lost = true;
|
|
@@ -5321,14 +5343,16 @@ class DbosOwnerFence {
|
|
|
5321
5343
|
async recover(executorId, callback) {
|
|
5322
5344
|
if (!isDatabaseExecutor(executorId))
|
|
5323
5345
|
return;
|
|
5324
|
-
const
|
|
5346
|
+
const context = writeContext.getStore();
|
|
5347
|
+
const client = context?.fence === this ? context.client : await this.pool().connect();
|
|
5325
5348
|
const fail = () => {
|
|
5326
5349
|
this.fail();
|
|
5327
5350
|
};
|
|
5328
5351
|
client.on("error", fail);
|
|
5329
5352
|
client.on("end", fail);
|
|
5330
5353
|
try {
|
|
5331
|
-
|
|
5354
|
+
if (context?.fence !== this)
|
|
5355
|
+
await client.query("BEGIN");
|
|
5332
5356
|
const result = await client.query("SELECT pg_try_advisory_xact_lock($1, $2) AS held", [
|
|
5333
5357
|
...lockKey(executorId)
|
|
5334
5358
|
]);
|
|
@@ -5337,11 +5361,13 @@ class DbosOwnerFence {
|
|
|
5337
5361
|
return await callback();
|
|
5338
5362
|
} finally {
|
|
5339
5363
|
try {
|
|
5340
|
-
|
|
5364
|
+
if (context?.fence !== this)
|
|
5365
|
+
await client.query("ROLLBACK");
|
|
5341
5366
|
} finally {
|
|
5342
5367
|
client.removeListener("error", fail);
|
|
5343
5368
|
client.removeListener("end", fail);
|
|
5344
|
-
|
|
5369
|
+
if (context?.fence !== this)
|
|
5370
|
+
client.release();
|
|
5345
5371
|
}
|
|
5346
5372
|
}
|
|
5347
5373
|
}
|
|
@@ -5385,7 +5411,7 @@ class DbosOwnerFence {
|
|
|
5385
5411
|
}
|
|
5386
5412
|
if (this.lost)
|
|
5387
5413
|
throw this.fail();
|
|
5388
|
-
return await writeContext.run({ fence: this, workflows: new Map([...active ?? [], [workflowId, claim]]) }, callback);
|
|
5414
|
+
return await writeContext.run({ fence: this, workflows: new Map([...active ?? [], [workflowId, claim]]), client }, callback);
|
|
5389
5415
|
} finally {
|
|
5390
5416
|
try {
|
|
5391
5417
|
await client.query("ROLLBACK");
|
|
@@ -5405,7 +5431,7 @@ class DbosOwnerFence {
|
|
|
5405
5431
|
const metadataId = `${authority.root}:checkpoint:__atomic_metadata`;
|
|
5406
5432
|
if (retainedId !== metadataId && !retainedId.startsWith(`${metadataId}:`))
|
|
5407
5433
|
throw new Error("Metadata compaction requires a metadata checkpoint");
|
|
5408
|
-
const client = await this.
|
|
5434
|
+
const client = await this.compactionPool().connect();
|
|
5409
5435
|
try {
|
|
5410
5436
|
await installDbosRowGuard(client);
|
|
5411
5437
|
await client.query("BEGIN");
|
|
@@ -5601,7 +5627,7 @@ function getAtomicExecutorId() {
|
|
|
5601
5627
|
owner.executorId ??= `atomic-db-${crypto.randomUUID()}`;
|
|
5602
5628
|
return owner.executorId;
|
|
5603
5629
|
}
|
|
5604
|
-
function createRealDbosHandle(dbos, mainWorkflow, checkpointWorkflow, fence, previousExecutorIds = []) {
|
|
5630
|
+
function createRealDbosHandle(dbos, mainWorkflow, checkpointWorkflow, fence, previousExecutorIds = [], options = {}) {
|
|
5605
5631
|
const checkpointId = (workflowId, stepName) => `${workflowId}:checkpoint:${stepName}`;
|
|
5606
5632
|
async function stepRecord(status, prefix) {
|
|
5607
5633
|
if (status.status !== "SUCCESS")
|
|
@@ -5630,24 +5656,43 @@ function createRealDbosHandle(dbos, mainWorkflow, checkpointWorkflow, fence, pre
|
|
|
5630
5656
|
}
|
|
5631
5657
|
return records;
|
|
5632
5658
|
}
|
|
5659
|
+
async function retrieveMatchingRootMarker(workflowId, name, inputs) {
|
|
5660
|
+
const existing = await raw.retrieveWorkflow(workflowId);
|
|
5661
|
+
if (existing === undefined)
|
|
5662
|
+
return;
|
|
5663
|
+
if (existing.name !== name || !isDeepStrictEqual2(existing.inputs, inputs))
|
|
5664
|
+
throw new Error("Workflow root identity changed during admission");
|
|
5665
|
+
return dbos.retrieveWorkflow(workflowId);
|
|
5666
|
+
}
|
|
5667
|
+
async function startRoot(workflowId, name, inputs) {
|
|
5668
|
+
if (fence !== undefined) {
|
|
5669
|
+
const existing = await retrieveMatchingRootMarker(workflowId, name, inputs);
|
|
5670
|
+
if (existing !== undefined)
|
|
5671
|
+
return existing;
|
|
5672
|
+
}
|
|
5673
|
+
try {
|
|
5674
|
+
return await dbos.startWorkflow(mainWorkflow, { workflowID: workflowId })(name, { ...inputs });
|
|
5675
|
+
} catch (err) {
|
|
5676
|
+
if (!isDbosDuplicateWorkflowError(err))
|
|
5677
|
+
throw err;
|
|
5678
|
+
const raced = await retrieveMatchingRootMarker(workflowId, name, inputs);
|
|
5679
|
+
if (raced === undefined)
|
|
5680
|
+
throw err;
|
|
5681
|
+
return raced;
|
|
5682
|
+
}
|
|
5683
|
+
}
|
|
5684
|
+
async function settleMarker(marker) {
|
|
5685
|
+
if (!options.settleRootMarker || marker === undefined)
|
|
5686
|
+
return;
|
|
5687
|
+
await boundedAdmission(async () => {
|
|
5688
|
+
await marker.getResult();
|
|
5689
|
+
}, dbosAdmissionContext.getStore(), undefined, "Workflow database root marker settlement timed out.");
|
|
5690
|
+
}
|
|
5633
5691
|
const raw = {
|
|
5634
5692
|
launch: () => dbos.launch(),
|
|
5635
5693
|
shutdown: () => dbos.shutdown(),
|
|
5636
5694
|
async startWorkflow(workflowId, name, inputs) {
|
|
5637
|
-
|
|
5638
|
-
const existing = await raw.retrieveWorkflow(workflowId);
|
|
5639
|
-
if (existing !== undefined) {
|
|
5640
|
-
if (existing.name !== name || !isDeepStrictEqual2(existing.inputs, inputs))
|
|
5641
|
-
throw new Error("Workflow root identity changed during admission");
|
|
5642
|
-
return;
|
|
5643
|
-
}
|
|
5644
|
-
}
|
|
5645
|
-
try {
|
|
5646
|
-
await dbos.startWorkflow(mainWorkflow, { workflowID: workflowId })(name, { ...inputs });
|
|
5647
|
-
} catch (err) {
|
|
5648
|
-
if (!isDbosDuplicateWorkflowError(err))
|
|
5649
|
-
throw err;
|
|
5650
|
-
}
|
|
5695
|
+
await settleMarker(await startRoot(workflowId, name, inputs));
|
|
5651
5696
|
},
|
|
5652
5697
|
async retrieveWorkflow(workflowId) {
|
|
5653
5698
|
const statuses = await dbos.listWorkflows({ workflowIDs: [workflowId], loadInput: true, limit: 1 });
|
|
@@ -5785,10 +5830,7 @@ function createRealDbosHandle(dbos, mainWorkflow, checkpointWorkflow, fence, pre
|
|
|
5785
5830
|
if (next === undefined)
|
|
5786
5831
|
throw new Error("Workflow ownership fence cannot create a recovery generation");
|
|
5787
5832
|
fence.close().catch(() => {});
|
|
5788
|
-
return createRealDbosHandle(dbos, mainWorkflow, checkpointWorkflow, next, [
|
|
5789
|
-
...previousExecutorIds,
|
|
5790
|
-
fence.executorId
|
|
5791
|
-
]);
|
|
5833
|
+
return createRealDbosHandle(dbos, mainWorkflow, checkpointWorkflow, next, [...previousExecutorIds, fence.executorId], options);
|
|
5792
5834
|
},
|
|
5793
5835
|
adoptPreviousGeneration: async (workflowId) => {
|
|
5794
5836
|
if (previousExecutorIds.length === 0)
|
|
@@ -5860,7 +5902,13 @@ function createRealDbosHandle(dbos, mainWorkflow, checkpointWorkflow, fence, pre
|
|
|
5860
5902
|
}
|
|
5861
5903
|
return await claim();
|
|
5862
5904
|
}, true),
|
|
5863
|
-
startWorkflow: (id, name, inputs) =>
|
|
5905
|
+
startWorkflow: async (id, name, inputs) => {
|
|
5906
|
+
let marker;
|
|
5907
|
+
await mutate(id, async () => {
|
|
5908
|
+
marker = await startRoot(id, name, inputs);
|
|
5909
|
+
});
|
|
5910
|
+
await settleMarker(marker);
|
|
5911
|
+
},
|
|
5864
5912
|
cancelWorkflow: (id) => mutate(id, () => raw.cancelWorkflow(id)),
|
|
5865
5913
|
resumeWorkflow: (id) => mutate(id, () => raw.resumeWorkflow(id)),
|
|
5866
5914
|
recordStepOutput: (id, step, output) => mutate(id, () => raw.recordStepOutput(id, step, output), { name: step, output }),
|
|
@@ -5891,6 +5939,7 @@ function statusToInfo(status, fallbackId) {
|
|
|
5891
5939
|
return info;
|
|
5892
5940
|
}
|
|
5893
5941
|
var init_dbos_sdk_handle = __esm(() => {
|
|
5942
|
+
init_dbos_admission();
|
|
5894
5943
|
init_dbos_metadata();
|
|
5895
5944
|
init_dbos_owner_fence();
|
|
5896
5945
|
init_dbos_process_owner();
|
|
@@ -36226,9 +36275,10 @@ function resolvedPostgresHealth(url) {
|
|
|
36226
36275
|
|
|
36227
36276
|
// dist/builtin/workflows/src/durable/dbos-recoverable-pool.ts
|
|
36228
36277
|
function createRecoverablePostgresPool(initialUrl, options = {}) {
|
|
36229
|
-
const
|
|
36278
|
+
const poolSize = options.poolSize ?? 10;
|
|
36279
|
+
const pool = new Pool({ ...import_datasource.getPGClientConfig(initialUrl), max: poolSize });
|
|
36230
36280
|
const endFacade = pool.end.bind(pool);
|
|
36231
|
-
const createPool = options.createPool ?? ((url) => new Pool(import_datasource.getPGClientConfig(url)));
|
|
36281
|
+
const createPool = options.createPool ?? ((url) => new Pool({ ...import_datasource.getPGClientConfig(url), max: poolSize }));
|
|
36232
36282
|
const draining = new Set;
|
|
36233
36283
|
const checkouts = new Map;
|
|
36234
36284
|
let current;
|
|
@@ -36387,6 +36437,7 @@ function configureAdmissionDatabase(sdk, config, launchLock = withDbosLaunchLock
|
|
|
36387
36437
|
const createPool = (fenced = true) => {
|
|
36388
36438
|
let unsubscribe;
|
|
36389
36439
|
const managed = createRecoverablePostgresPool(systemDatabaseUrl, {
|
|
36440
|
+
poolSize: resolvedDbosPoolSize(),
|
|
36390
36441
|
beforeConnect: health === undefined ? undefined : () => health.check(),
|
|
36391
36442
|
afterConnect: health === undefined ? undefined : (client) => health.validate(client),
|
|
36392
36443
|
onConnectionError: () => health?.invalidate(),
|
|
@@ -36399,7 +36450,7 @@ function configureAdmissionDatabase(sdk, config, launchLock = withDbosLaunchLock
|
|
|
36399
36450
|
let pool = createPool();
|
|
36400
36451
|
const createFence = (executorId) => {
|
|
36401
36452
|
const fencePool = createPool(false);
|
|
36402
|
-
const created = new DbosOwnerFence(() => fencePool, executorId, () => fencePool.end());
|
|
36453
|
+
const created = new DbosOwnerFence(() => fencePool, executorId, () => fencePool.end(), () => pool);
|
|
36403
36454
|
const owner = getDbosProcessOwner();
|
|
36404
36455
|
owner.executorFences ??= new Set;
|
|
36405
36456
|
owner.executorFences.add(created);
|
|
@@ -36446,6 +36497,7 @@ var init_dbos_admission_config = __esm(() => {
|
|
|
36446
36497
|
init_dbos_admission_pool();
|
|
36447
36498
|
init_dbos_launch_lock();
|
|
36448
36499
|
init_dbos_owner_fence();
|
|
36500
|
+
init_dbos_pool_size();
|
|
36449
36501
|
init_dbos_process_owner();
|
|
36450
36502
|
init_dbos_recoverable_pool();
|
|
36451
36503
|
import_datasource2 = __toESM(require_datasource(), 1);
|
|
@@ -36458,6 +36510,8 @@ function effectiveSystemDatabaseUrl(configUrl, envUrl = explicitDbosSystemDataba
|
|
|
36458
36510
|
return url === undefined || url.length === 0 ? undefined : url;
|
|
36459
36511
|
}
|
|
36460
36512
|
async function configureDbosDurableBackend(config) {
|
|
36513
|
+
if (config?.poolSize !== undefined)
|
|
36514
|
+
requestDbosPoolSize(config.poolSize);
|
|
36461
36515
|
const sdk = await importDbosSdk();
|
|
36462
36516
|
const owner = getDbosProcessOwner();
|
|
36463
36517
|
const existing = owner.wrappers;
|
|
@@ -36488,7 +36542,7 @@ async function configureDbosDurableBackend(config) {
|
|
|
36488
36542
|
owner.wrappers = { mainWorkflow, checkpointWorkflow };
|
|
36489
36543
|
}
|
|
36490
36544
|
let backendFence = owner.executorFence;
|
|
36491
|
-
let backend = new DbosDurableBackend(createRealDbosHandle(sdk, mainWorkflow, checkpointWorkflow, backendFence), {
|
|
36545
|
+
let backend = new DbosDurableBackend(createRealDbosHandle(sdk, mainWorkflow, checkpointWorkflow, backendFence, [], { settleRootMarker: true }), {
|
|
36492
36546
|
checkReady
|
|
36493
36547
|
});
|
|
36494
36548
|
return {
|
|
@@ -36499,7 +36553,9 @@ async function configureDbosDurableBackend(config) {
|
|
|
36499
36553
|
await launch();
|
|
36500
36554
|
if (backendFence !== owner.executorFence && backendFence?.closed) {
|
|
36501
36555
|
backendFence = owner.executorFence;
|
|
36502
|
-
backend = new DbosDurableBackend(createRealDbosHandle(sdk, mainWorkflow, checkpointWorkflow, backendFence
|
|
36556
|
+
backend = new DbosDurableBackend(createRealDbosHandle(sdk, mainWorkflow, checkpointWorkflow, backendFence, [], {
|
|
36557
|
+
settleRootMarker: true
|
|
36558
|
+
}), { checkReady });
|
|
36503
36559
|
}
|
|
36504
36560
|
},
|
|
36505
36561
|
shutdown: async (options) => {
|
|
@@ -37264,6 +37320,10 @@ class DbosDurableBackend {
|
|
|
37264
37320
|
return { kind: deletion === "current" ? "deleted" : "malformed" };
|
|
37265
37321
|
}
|
|
37266
37322
|
const metadata = classifyLatestMetadata(records, info.workflowId);
|
|
37323
|
+
if (metadata.kind === "unavailable" && records.length === 0) {
|
|
37324
|
+
await this.suppressWorkflow(info.workflowId);
|
|
37325
|
+
return { kind: "absent" };
|
|
37326
|
+
}
|
|
37267
37327
|
if (metadata.kind !== "current" || expected !== undefined && (metadata.metadata.name !== expected.name || !isDeepStrictEqual3(metadata.metadata.inputs, expected.inputs))) {
|
|
37268
37328
|
await this.suppressWorkflow(info.workflowId);
|
|
37269
37329
|
return { kind: "malformed" };
|
|
@@ -37396,6 +37456,7 @@ var init_dbos_backend = __esm(() => {
|
|
|
37396
37456
|
init_dbos_admission_recovery();
|
|
37397
37457
|
init_dbos_envelope();
|
|
37398
37458
|
init_dbos_metadata();
|
|
37459
|
+
init_dbos_pool_size();
|
|
37399
37460
|
init_dbos_prompt_reservations();
|
|
37400
37461
|
init_dbos_status_transition();
|
|
37401
37462
|
init_dbos_tombstone();
|
|
@@ -118106,6 +118167,7 @@ function createAgentSessionAdapter(baseOptions = {}) {
|
|
|
118106
118167
|
init_backend();
|
|
118107
118168
|
init_backend_process_owner();
|
|
118108
118169
|
init_dbos_lifecycle();
|
|
118170
|
+
init_dbos_pool_size();
|
|
118109
118171
|
init_dbos_system_database_url();
|
|
118110
118172
|
init_factory();
|
|
118111
118173
|
|
|
@@ -118125,6 +118187,8 @@ async function run2(def, inputs, callerOpts = {}) {
|
|
|
118125
118187
|
return await run(def, inputs, { ...opts, durableBackend: new InMemoryDurableBackend });
|
|
118126
118188
|
}
|
|
118127
118189
|
const durableRequested = durability?.mode === "durable";
|
|
118190
|
+
if (durability?.poolSize !== undefined)
|
|
118191
|
+
requestDbosPoolSize(durability.poolSize);
|
|
118128
118192
|
const presetBackend = opts.durableBackend ?? getDurableBackendProcessOwner().injectedBackend;
|
|
118129
118193
|
if (presetBackend !== undefined) {
|
|
118130
118194
|
if (durableRequested && !presetBackend.persistent) {
|
|
@@ -119436,13 +119500,14 @@ function createStatusWriter(store, config, opts = {}) {
|
|
|
119436
119500
|
}
|
|
119437
119501
|
|
|
119438
119502
|
// dist/builtin/workflows/src/extension/workflow-database-settings.ts
|
|
119503
|
+
init_dbos_pool_size();
|
|
119439
119504
|
init_dbos_system_database_url();
|
|
119440
119505
|
import { readFileSync as readFileSync7 } from "node:fs";
|
|
119441
119506
|
import { readFile as readFile6 } from "node:fs/promises";
|
|
119442
119507
|
import { homedir as homedir3 } from "node:os";
|
|
119443
119508
|
import { join as join33, resolve as resolve16 } from "node:path";
|
|
119444
119509
|
import { getAgentDir as getAgentDir3, getAgentDirs as getAgentDirs3, getProjectConfigDirs, SettingsManager } from "@bastani/atomic";
|
|
119445
|
-
var DATABASE_SETTING_KEYS = new Set(["systemDatabaseUrl", "systemDatabaseUrlFile"]);
|
|
119510
|
+
var DATABASE_SETTING_KEYS = new Set(["systemDatabaseUrl", "systemDatabaseUrlFile", "poolSize"]);
|
|
119446
119511
|
function databaseSettings(settings) {
|
|
119447
119512
|
const workflows = settings.workflows;
|
|
119448
119513
|
if (workflows === undefined || workflows === null || Array.isArray(workflows))
|
|
@@ -119478,9 +119543,13 @@ async function resolveWorkflowDatabaseSettings(global2, project, directories) {
|
|
|
119478
119543
|
throw new TypeError("workflows.durability must be an object");
|
|
119479
119544
|
}
|
|
119480
119545
|
if (Object.keys(database).some((key) => !DATABASE_SETTING_KEYS.has(key))) {
|
|
119481
|
-
throw new TypeError("workflows.durability supports only systemDatabaseUrl or
|
|
119546
|
+
throw new TypeError("workflows.durability supports only systemDatabaseUrl, systemDatabaseUrlFile, or poolSize");
|
|
119482
119547
|
}
|
|
119483
|
-
const { systemDatabaseUrl: url, systemDatabaseUrlFile: file } = database;
|
|
119548
|
+
const { systemDatabaseUrl: url, systemDatabaseUrlFile: file, poolSize } = database;
|
|
119549
|
+
if (poolSize !== undefined)
|
|
119550
|
+
validateDbosPoolSize(poolSize, "workflows.durability.poolSize");
|
|
119551
|
+
if (process.env.DBOS_SYSTEM_DATABASE_URL?.trim())
|
|
119552
|
+
return { poolSize };
|
|
119484
119553
|
if (url !== undefined && file !== undefined) {
|
|
119485
119554
|
throw new TypeError("Set only one of workflows.durability.systemDatabaseUrl and systemDatabaseUrlFile");
|
|
119486
119555
|
}
|
|
@@ -119497,7 +119566,7 @@ async function resolveWorkflowDatabaseSettings(global2, project, directories) {
|
|
|
119497
119566
|
}
|
|
119498
119567
|
}
|
|
119499
119568
|
if (value2 === undefined)
|
|
119500
|
-
return;
|
|
119569
|
+
return { poolSize };
|
|
119501
119570
|
if (typeof value2 !== "string" || value2.trim() === "") {
|
|
119502
119571
|
throw new TypeError("Workflow database selection must contain a non-empty Postgres URL");
|
|
119503
119572
|
}
|
|
@@ -119508,21 +119577,21 @@ async function resolveWorkflowDatabaseSettings(global2, project, directories) {
|
|
|
119508
119577
|
} catch {
|
|
119509
119578
|
throw new TypeError("Workflow database selection must contain a valid Postgres URL");
|
|
119510
119579
|
}
|
|
119511
|
-
return value2.trim();
|
|
119580
|
+
return { url: value2.trim(), poolSize };
|
|
119512
119581
|
}
|
|
119513
119582
|
async function prepareWorkflowDatabaseSettings(cwd, projectTrusted) {
|
|
119514
|
-
if (process.env.DBOS_SYSTEM_DATABASE_URL?.trim())
|
|
119515
|
-
return;
|
|
119516
119583
|
const manager = SettingsManager.create(cwd, getAgentDir3(), { projectTrusted });
|
|
119517
|
-
if (manager.drainErrors().length > 0)
|
|
119584
|
+
if (manager.drainErrors().length > 0 && !process.env.DBOS_SYSTEM_DATABASE_URL?.trim())
|
|
119518
119585
|
throw new Error("Cannot read workflow database settings; repair settings.json");
|
|
119519
119586
|
const projectDirectories = getProjectConfigDirs(cwd);
|
|
119520
|
-
const
|
|
119587
|
+
const database = await resolveWorkflowDatabaseSettings(manager.getGlobalSettings(), manager.getProjectSettings(), {
|
|
119521
119588
|
global: settingsDirectoryDeclaringDatabase(getAgentDirs3()),
|
|
119522
119589
|
project: projectTrusted ? settingsDirectoryDeclaringDatabase(projectDirectories) : projectDirectories[0]
|
|
119523
119590
|
});
|
|
119524
|
-
if (url !== undefined)
|
|
119525
|
-
requestDbosSystemDatabaseUrl(url);
|
|
119591
|
+
if (database?.url !== undefined)
|
|
119592
|
+
requestDbosSystemDatabaseUrl(database.url);
|
|
119593
|
+
if (database?.poolSize !== undefined)
|
|
119594
|
+
requestDbosPoolSize(database.poolSize);
|
|
119526
119595
|
}
|
|
119527
119596
|
|
|
119528
119597
|
// dist/builtin/workflows/src/extension/workflow-heartbeat-notice.ts
|