@bastani/atomic 0.9.44-alpha.4 → 0.9.44-alpha.5
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 +11 -0
- package/dist/builtin/intercom/CHANGELOG.md +6 -0
- package/dist/builtin/intercom/package.json +1 -1
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/package.json +1 -1
- package/dist/builtin/web-access/package.json +1 -1
- package/dist/builtin/workflows/CHANGELOG.md +6 -0
- package/dist/builtin/workflows/package.json +1 -1
- package/dist/builtin/workflows/src/extension/index.bundle.mjs +84 -33
- package/dist/builtin/workflows/src/extension/local-worker-entry.mjs +84 -33
- package/dist/builtin/workflows/src/index.js +84 -33
- package/dist/builtin/workflows/src/local-worker-entry.mjs +84 -33
- package/dist/core/storage/errors.d.ts +5 -1
- package/dist/core/storage/errors.d.ts.map +1 -1
- package/dist/core/storage/errors.js +8 -2
- package/dist/core/storage/errors.js.map +1 -1
- package/dist/core/storage/node-sqlite.d.ts +2 -1
- package/dist/core/storage/node-sqlite.d.ts.map +1 -1
- package/dist/core/storage/node-sqlite.js +83 -7
- package/dist/core/storage/node-sqlite.js.map +1 -1
- package/npm-shrinkwrap.json +32 -32
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## [0.9.44-alpha.5] - 2026-10-25
|
|
6
|
+
|
|
7
|
+
Large workflow fan-outs keep their Intercom routes and journal writes responsive under load.
|
|
8
|
+
|
|
9
|
+
- **A workflow host that keeps up:** route announcements are batched instead of rebuilt for every run on every store change, so heavy fan-outs no longer saturate the workflow host and time out Intercom sends ([#3939](https://github.com/bastani-inc/atomic/pull/3939))
|
|
10
|
+
- **Stages that start under journal contention:** a busy workflow journal no longer fails pooled stages with `Storage unavailable`; writers wait for the lock without blocking their event loop, and the SQLite reason stays in the error ([#3940](https://github.com/bastani-inc/atomic/pull/3940))
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
|
|
14
|
+
- A local SQLite store (`node-sqlite`, including the workflow journal) now waits for another process's write lock instead of failing after the 5 second busy timeout. When the lock is busy, it retries the start of the write transaction for up to 30 seconds without blocking the event loop. Single statements outside a transaction still use the configured busy timeout. Other failures, and a lock still held at that point, fail at once. `Storage unavailable` errors now include the SQLite reason, such as `database is locked (SQLite code 5)`, so the reason survives when local workers pass an error to another process
|
|
15
|
+
|
|
5
16
|
## [0.9.44-alpha.4] - 2026-10-25
|
|
6
17
|
|
|
7
18
|
Workflow journals stay small even when many stages write to the same run at once.
|
|
@@ -4,6 +4,12 @@ All notable changes to the `pi-intercom` extension will be documented in this fi
|
|
|
4
4
|
|
|
5
5
|
## [Unreleased]
|
|
6
6
|
|
|
7
|
+
## [0.9.44-alpha.5] - 2026-10-25
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
|
|
11
|
+
- A pooled workflow stage whose Intercom extension delivers queued messages at startup no longer fails with `Extension startup failed: …intercom…: Storage unavailable: node-sqlite at <journal>` while other processes are writing heavily to the workflow journal. The journal write now waits for the lock, and any remaining failure states its SQLite cause
|
|
12
|
+
|
|
7
13
|
## [0.9.44-alpha.3] - 2026-10-25
|
|
8
14
|
|
|
9
15
|
### Fixed
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bastani/intercom",
|
|
3
|
-
"version": "0.9.44-alpha.
|
|
3
|
+
"version": "0.9.44-alpha.5",
|
|
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": [
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bastani/subagents",
|
|
3
|
-
"version": "0.9.44-alpha.
|
|
3
|
+
"version": "0.9.44-alpha.5",
|
|
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.44-alpha.
|
|
3
|
+
"version": "0.9.44-alpha.5",
|
|
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,12 @@ 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.44-alpha.5] - 2026-10-25
|
|
10
|
+
|
|
11
|
+
### Fixed
|
|
12
|
+
|
|
13
|
+
- A large workflow fan-out no longer pins the workflow host's main thread rebuilding Intercom routes. Every store change re-announced the route of every run (480 children in a load test), so under a stream of messages and delivery receipts the host spent most of its time on announcements and Intercom sends began to time out. Store changes now publish routes in batches about 25 ms apart, spaced further when needed so announcing takes at most about a fifth of the host's time, and a stage that waits for its route still gets the latest one first.
|
|
14
|
+
|
|
9
15
|
## [0.9.44-alpha.4] - 2026-10-25
|
|
10
16
|
|
|
11
17
|
### Fixed
|
|
@@ -60863,6 +60863,27 @@ class GraphFrontierTracker {
|
|
|
60863
60863
|
}
|
|
60864
60864
|
}
|
|
60865
60865
|
|
|
60866
|
+
// dist/builtin/workflows/src/engine/session-closed-error.ts
|
|
60867
|
+
import { isStaleExtensionContextError as isStaleExtensionContextError6 } from "@bastani/atomic";
|
|
60868
|
+
function reportsClosedSession(error) {
|
|
60869
|
+
return "code" in error && error.code === "SessionClosed" || isStaleExtensionContextError6(error);
|
|
60870
|
+
}
|
|
60871
|
+
function isSessionClosedError(error) {
|
|
60872
|
+
let current = error;
|
|
60873
|
+
for (let depth = 0;depth < MAX_CAUSE_DEPTH && current !== undefined; depth++) {
|
|
60874
|
+
try {
|
|
60875
|
+
if (reportsClosedSession(current))
|
|
60876
|
+
return true;
|
|
60877
|
+
current = current.cause instanceof Error ? current.cause : undefined;
|
|
60878
|
+
} catch {
|
|
60879
|
+
return false;
|
|
60880
|
+
}
|
|
60881
|
+
}
|
|
60882
|
+
return false;
|
|
60883
|
+
}
|
|
60884
|
+
var MAX_CAUSE_DEPTH = 8;
|
|
60885
|
+
var init_session_closed_error = () => {};
|
|
60886
|
+
|
|
60866
60887
|
// dist/builtin/workflows/src/shared/external-run-routes.ts
|
|
60867
60888
|
function claimExternalRunRoute(store, runId, owner) {
|
|
60868
60889
|
let owners = registry.owners.get(store);
|
|
@@ -61139,7 +61160,10 @@ function registerPendingStageIntercomBridge(pi, activeStore, ownsRun = () => tru
|
|
|
61139
61160
|
};
|
|
61140
61161
|
const announcedRoutes = new Map;
|
|
61141
61162
|
const routeCompletions = new Map;
|
|
61142
|
-
const disposeReadiness = registerWorkflowPendingStageRouteReadiness(activeStore, (runId) =>
|
|
61163
|
+
const disposeReadiness = registerWorkflowPendingStageRouteReadiness(activeStore, (runId) => {
|
|
61164
|
+
announceIfPending();
|
|
61165
|
+
return routeCompletions.get(runId);
|
|
61166
|
+
});
|
|
61143
61167
|
const announceRoutes = () => {
|
|
61144
61168
|
if (disposed)
|
|
61145
61169
|
return;
|
|
@@ -61236,11 +61260,53 @@ function registerPendingStageIntercomBridge(pi, activeStore, ownsRun = () => tru
|
|
|
61236
61260
|
return;
|
|
61237
61261
|
}).catch((error) => reportWarning(`atomic-workflows: pending stage delivery sweep failed: ${error.message}`));
|
|
61238
61262
|
};
|
|
61239
|
-
|
|
61240
|
-
|
|
61263
|
+
let announcementPending = false;
|
|
61264
|
+
let announcementTimer;
|
|
61265
|
+
let announcedAt = Number.NEGATIVE_INFINITY;
|
|
61266
|
+
let announcementCost = 0;
|
|
61267
|
+
const announceNow = () => {
|
|
61268
|
+
if (announcementTimer !== undefined)
|
|
61269
|
+
clearTimeout(announcementTimer);
|
|
61270
|
+
announcementTimer = undefined;
|
|
61271
|
+
announcementPending = false;
|
|
61272
|
+
const started = performance.now();
|
|
61273
|
+
announceRoutes();
|
|
61274
|
+
announcedAt = performance.now();
|
|
61275
|
+
announcementCost = announcedAt - started;
|
|
61276
|
+
};
|
|
61277
|
+
function announceIfPending() {
|
|
61278
|
+
if (announcementPending)
|
|
61279
|
+
announceNow();
|
|
61280
|
+
}
|
|
61281
|
+
const announceBatch = () => {
|
|
61282
|
+
try {
|
|
61283
|
+
announceNow();
|
|
61284
|
+
} catch (error) {
|
|
61285
|
+
if (error instanceof Error && isSessionClosedError(error)) {
|
|
61286
|
+
dispose();
|
|
61287
|
+
return;
|
|
61288
|
+
}
|
|
61289
|
+
try {
|
|
61290
|
+
reportWarning(`atomic-workflows: pending stage route announcement failed: ${String(error)}`);
|
|
61291
|
+
} catch {
|
|
61292
|
+
dispose();
|
|
61293
|
+
}
|
|
61294
|
+
}
|
|
61295
|
+
};
|
|
61296
|
+
const scheduleAnnouncement = () => {
|
|
61297
|
+
if (disposed || announcementTimer !== undefined)
|
|
61298
|
+
return;
|
|
61299
|
+
const idle = announcementCost / ROUTE_ANNOUNCEMENT_EVENT_LOOP_SHARE - announcementCost;
|
|
61300
|
+
const wait = Math.max(ROUTE_ANNOUNCEMENT_BATCH_MS, announcedAt + idle - performance.now());
|
|
61301
|
+
announcementPending = true;
|
|
61302
|
+
announcementTimer = setTimeout(announceBatch, wait);
|
|
61303
|
+
announcementTimer.unref?.();
|
|
61304
|
+
};
|
|
61305
|
+
const unsubscribeStore = activeStore.subscribeInvalidation(scheduleAnnouncement);
|
|
61306
|
+
announceNow();
|
|
61241
61307
|
pi.on?.("session_start", () => {
|
|
61242
61308
|
announcedRoutes.clear();
|
|
61243
|
-
|
|
61309
|
+
announceNow();
|
|
61244
61310
|
});
|
|
61245
61311
|
const routePendingStageMessage = (payload) => {
|
|
61246
61312
|
if (disposed || !isPendingStageMessageEvent(payload) || payload.handled)
|
|
@@ -61322,6 +61388,10 @@ function registerPendingStageIntercomBridge(pi, activeStore, ownsRun = () => tru
|
|
|
61322
61388
|
});
|
|
61323
61389
|
const dispose = () => {
|
|
61324
61390
|
disposed = true;
|
|
61391
|
+
if (announcementTimer !== undefined)
|
|
61392
|
+
clearTimeout(announcementTimer);
|
|
61393
|
+
announcementTimer = undefined;
|
|
61394
|
+
announcementPending = false;
|
|
61325
61395
|
disposeReadiness();
|
|
61326
61396
|
disposeRouter();
|
|
61327
61397
|
routeCompletions.clear();
|
|
@@ -61335,10 +61405,11 @@ function registerPendingStageIntercomBridge(pi, activeStore, ownsRun = () => tru
|
|
|
61335
61405
|
pi.on?.("session_shutdown", dispose);
|
|
61336
61406
|
return Object.assign(dispose, {
|
|
61337
61407
|
async flush() {
|
|
61408
|
+
announceIfPending();
|
|
61338
61409
|
await Promise.allSettled(routeCompletions.values());
|
|
61339
61410
|
await sweepPromise;
|
|
61340
61411
|
},
|
|
61341
|
-
refresh:
|
|
61412
|
+
refresh: announceNow
|
|
61342
61413
|
});
|
|
61343
61414
|
}
|
|
61344
61415
|
function stageRouteTarget(runs, rootRunId, runId, stageId, resolveBoundarySegments = (id) => workflowBoundarySegments(runs, id)) {
|
|
@@ -61813,11 +61884,12 @@ async function settleUndeliverablePendingStageMessages(activeStore, notify, owns
|
|
|
61813
61884
|
}
|
|
61814
61885
|
return settled;
|
|
61815
61886
|
}
|
|
61816
|
-
var PENDING_STAGE_ROUTE_EVENT = "atomic:workflow-pending-stage-route", PENDING_STAGE_MESSAGE_EVENT = "atomic:workflow-pending-stage-message", PENDING_STAGE_UNDELIVERABLE_EVENT = "atomic:workflow-pending-stage-undeliverable", STICKY_LIVE_DELIVERED_EVENT = "atomic:workflow-sticky-live-delivered", PENDING_STAGE_ASK_REFUSAL = "Cannot ask a workflow stage whose session has not initialized. Use send; Atomic will queue the message until the stage session initializes.";
|
|
61887
|
+
var PENDING_STAGE_ROUTE_EVENT = "atomic:workflow-pending-stage-route", PENDING_STAGE_MESSAGE_EVENT = "atomic:workflow-pending-stage-message", PENDING_STAGE_UNDELIVERABLE_EVENT = "atomic:workflow-pending-stage-undeliverable", STICKY_LIVE_DELIVERED_EVENT = "atomic:workflow-sticky-live-delivered", PENDING_STAGE_ASK_REFUSAL = "Cannot ask a workflow stage whose session has not initialized. Use send; Atomic will queue the message until the stage session initializes.", ROUTE_ANNOUNCEMENT_BATCH_MS = 25, ROUTE_ANNOUNCEMENT_EVENT_LOOP_SHARE = 0.2;
|
|
61817
61888
|
var init_pending_stage_intercom = __esm(() => {
|
|
61818
61889
|
init_execution_context_boundary();
|
|
61819
61890
|
init_run_owner_backend();
|
|
61820
61891
|
init_store_backend();
|
|
61892
|
+
init_session_closed_error();
|
|
61821
61893
|
init_external_run_routes();
|
|
61822
61894
|
init_intercom_group();
|
|
61823
61895
|
init_pending_stage_route_capability();
|
|
@@ -64374,7 +64446,7 @@ function isInfrastructureError(value2) {
|
|
|
64374
64446
|
}
|
|
64375
64447
|
function isRetryableWorkflowError(error) {
|
|
64376
64448
|
let current = error;
|
|
64377
|
-
for (let depth = 0;depth <
|
|
64449
|
+
for (let depth = 0;depth < MAX_CAUSE_DEPTH2 && current !== undefined && current !== null; depth++) {
|
|
64378
64450
|
if (isInfrastructureError(current))
|
|
64379
64451
|
return true;
|
|
64380
64452
|
current = current instanceof Error ? current.cause : undefined;
|
|
@@ -64392,7 +64464,7 @@ function asWorkflowInfrastructureError(error) {
|
|
|
64392
64464
|
const code = workflowInfrastructureFault(error.message);
|
|
64393
64465
|
return code === undefined ? undefined : new WorkflowInfrastructureError(code, error.message, { cause: error });
|
|
64394
64466
|
}
|
|
64395
|
-
var WORKFLOW_INFRASTRUCTURE_ERROR_NAME = "WorkflowInfrastructureError",
|
|
64467
|
+
var WORKFLOW_INFRASTRUCTURE_ERROR_NAME = "WorkflowInfrastructureError", MAX_CAUSE_DEPTH2 = 8, FAULT_PATTERNS, WorkflowInfrastructureError;
|
|
64396
64468
|
var init_workflow_infrastructure_error = __esm(() => {
|
|
64397
64469
|
FAULT_PATTERNS = [
|
|
64398
64470
|
[/Local worker (?:process )?cleanup (?:was not confirmed|unconfirmed)/, "worker_cleanup_unconfirmed"],
|
|
@@ -68438,7 +68510,7 @@ function describeErrorWithCauses(error) {
|
|
|
68438
68510
|
const messages = [];
|
|
68439
68511
|
const visited = new Set;
|
|
68440
68512
|
let current = error;
|
|
68441
|
-
for (let depth = 0;current !== undefined && depth <
|
|
68513
|
+
for (let depth = 0;current !== undefined && depth < MAX_CAUSE_DEPTH3 && !visited.has(current); depth++) {
|
|
68442
68514
|
visited.add(current);
|
|
68443
68515
|
const message = current instanceof Error ? current.message : String(current);
|
|
68444
68516
|
if (!messages.includes(message))
|
|
@@ -68447,7 +68519,7 @@ function describeErrorWithCauses(error) {
|
|
|
68447
68519
|
}
|
|
68448
68520
|
return messages.join(": ");
|
|
68449
68521
|
}
|
|
68450
|
-
var
|
|
68522
|
+
var MAX_CAUSE_DEPTH3 = 5;
|
|
68451
68523
|
|
|
68452
68524
|
// dist/builtin/workflows/src/engine/run-durable-finalize.ts
|
|
68453
68525
|
async function finalizeDurableTerminalStatus(input) {
|
|
@@ -68967,7 +69039,7 @@ function recordedOwners(boundary, reason) {
|
|
|
68967
69039
|
const pending = [{ value: reason, depth: 0 }];
|
|
68968
69040
|
while (pending.length > 0) {
|
|
68969
69041
|
const { value: value2, depth } = pending.pop();
|
|
68970
|
-
if (depth >
|
|
69042
|
+
if (depth > MAX_CAUSE_DEPTH4)
|
|
68971
69043
|
continue;
|
|
68972
69044
|
if (isPrimitive(value2)) {
|
|
68973
69045
|
if (depth === 0 || value2 !== undefined && value2 !== null) {
|
|
@@ -69289,7 +69361,7 @@ function containUiRejections(ui, scope) {
|
|
|
69289
69361
|
custom: (factory, options) => scope.watch(ui.custom(factory, options))
|
|
69290
69362
|
};
|
|
69291
69363
|
}
|
|
69292
|
-
var EVENT = "unhandledRejection", BOUNDARY_KEY, FLAG = "--unhandled-rejections",
|
|
69364
|
+
var EVENT = "unhandledRejection", BOUNDARY_KEY, FLAG = "--unhandled-rejections", MAX_CAUSE_DEPTH4 = 8, MAX_PRIMITIVES_PER_RUN = 64, MAX_STOP_STRINGS = 64, ENDED_RUN_GRACE_MS = 30000, NATIVE_REPORTING_MODES, WATCHED_STAGE_METHODS;
|
|
69293
69365
|
var init_run_rejection_boundary = __esm(() => {
|
|
69294
69366
|
init_prompt_callsite();
|
|
69295
69367
|
init_workflow_source();
|
|
@@ -75135,27 +75207,6 @@ var init_runtime = __esm(() => {
|
|
|
75135
75207
|
init_intercom_group();
|
|
75136
75208
|
});
|
|
75137
75209
|
|
|
75138
|
-
// dist/builtin/workflows/src/engine/session-closed-error.ts
|
|
75139
|
-
import { isStaleExtensionContextError as isStaleExtensionContextError6 } from "@bastani/atomic";
|
|
75140
|
-
function reportsClosedSession(error) {
|
|
75141
|
-
return "code" in error && error.code === "SessionClosed" || isStaleExtensionContextError6(error);
|
|
75142
|
-
}
|
|
75143
|
-
function isSessionClosedError(error) {
|
|
75144
|
-
let current = error;
|
|
75145
|
-
for (let depth = 0;depth < MAX_CAUSE_DEPTH4 && current !== undefined; depth++) {
|
|
75146
|
-
try {
|
|
75147
|
-
if (reportsClosedSession(current))
|
|
75148
|
-
return true;
|
|
75149
|
-
current = current.cause instanceof Error ? current.cause : undefined;
|
|
75150
|
-
} catch {
|
|
75151
|
-
return false;
|
|
75152
|
-
}
|
|
75153
|
-
}
|
|
75154
|
-
return false;
|
|
75155
|
-
}
|
|
75156
|
-
var MAX_CAUSE_DEPTH4 = 8;
|
|
75157
|
-
var init_session_closed_error = () => {};
|
|
75158
|
-
|
|
75159
75210
|
// dist/builtin/workflows/src/engine/workflow-activity.ts
|
|
75160
75211
|
import { runCallback as runCallback4 } from "@bastani/atomic";
|
|
75161
75212
|
function nextEventLoopTurn() {
|
|
@@ -57401,6 +57401,27 @@ var init_executor = __esm(() => {
|
|
|
57401
57401
|
init_executor_run();
|
|
57402
57402
|
});
|
|
57403
57403
|
|
|
57404
|
+
// dist/builtin/workflows/src/engine/session-closed-error.ts
|
|
57405
|
+
import { isStaleExtensionContextError as isStaleExtensionContextError2 } from "@bastani/atomic";
|
|
57406
|
+
function reportsClosedSession(error) {
|
|
57407
|
+
return "code" in error && error.code === "SessionClosed" || isStaleExtensionContextError2(error);
|
|
57408
|
+
}
|
|
57409
|
+
function isSessionClosedError(error) {
|
|
57410
|
+
let current = error;
|
|
57411
|
+
for (let depth = 0;depth < MAX_CAUSE_DEPTH && current !== undefined; depth++) {
|
|
57412
|
+
try {
|
|
57413
|
+
if (reportsClosedSession(current))
|
|
57414
|
+
return true;
|
|
57415
|
+
current = current.cause instanceof Error ? current.cause : undefined;
|
|
57416
|
+
} catch {
|
|
57417
|
+
return false;
|
|
57418
|
+
}
|
|
57419
|
+
}
|
|
57420
|
+
return false;
|
|
57421
|
+
}
|
|
57422
|
+
var MAX_CAUSE_DEPTH = 8;
|
|
57423
|
+
var init_session_closed_error = () => {};
|
|
57424
|
+
|
|
57404
57425
|
// dist/builtin/workflows/src/shared/external-run-routes.ts
|
|
57405
57426
|
function claimExternalRunRoute(store, runId, owner) {
|
|
57406
57427
|
let owners = registry.owners.get(store);
|
|
@@ -57895,7 +57916,10 @@ function registerPendingStageIntercomBridge(pi, activeStore, ownsRun = () => tru
|
|
|
57895
57916
|
};
|
|
57896
57917
|
const announcedRoutes = new Map;
|
|
57897
57918
|
const routeCompletions = new Map;
|
|
57898
|
-
const disposeReadiness = registerWorkflowPendingStageRouteReadiness(activeStore, (runId) =>
|
|
57919
|
+
const disposeReadiness = registerWorkflowPendingStageRouteReadiness(activeStore, (runId) => {
|
|
57920
|
+
announceIfPending();
|
|
57921
|
+
return routeCompletions.get(runId);
|
|
57922
|
+
});
|
|
57899
57923
|
const announceRoutes = () => {
|
|
57900
57924
|
if (disposed)
|
|
57901
57925
|
return;
|
|
@@ -57992,11 +58016,53 @@ function registerPendingStageIntercomBridge(pi, activeStore, ownsRun = () => tru
|
|
|
57992
58016
|
return;
|
|
57993
58017
|
}).catch((error) => reportWarning(`atomic-workflows: pending stage delivery sweep failed: ${error.message}`));
|
|
57994
58018
|
};
|
|
57995
|
-
|
|
57996
|
-
|
|
58019
|
+
let announcementPending = false;
|
|
58020
|
+
let announcementTimer;
|
|
58021
|
+
let announcedAt = Number.NEGATIVE_INFINITY;
|
|
58022
|
+
let announcementCost = 0;
|
|
58023
|
+
const announceNow = () => {
|
|
58024
|
+
if (announcementTimer !== undefined)
|
|
58025
|
+
clearTimeout(announcementTimer);
|
|
58026
|
+
announcementTimer = undefined;
|
|
58027
|
+
announcementPending = false;
|
|
58028
|
+
const started = performance.now();
|
|
58029
|
+
announceRoutes();
|
|
58030
|
+
announcedAt = performance.now();
|
|
58031
|
+
announcementCost = announcedAt - started;
|
|
58032
|
+
};
|
|
58033
|
+
function announceIfPending() {
|
|
58034
|
+
if (announcementPending)
|
|
58035
|
+
announceNow();
|
|
58036
|
+
}
|
|
58037
|
+
const announceBatch = () => {
|
|
58038
|
+
try {
|
|
58039
|
+
announceNow();
|
|
58040
|
+
} catch (error) {
|
|
58041
|
+
if (error instanceof Error && isSessionClosedError(error)) {
|
|
58042
|
+
dispose();
|
|
58043
|
+
return;
|
|
58044
|
+
}
|
|
58045
|
+
try {
|
|
58046
|
+
reportWarning(`atomic-workflows: pending stage route announcement failed: ${String(error)}`);
|
|
58047
|
+
} catch {
|
|
58048
|
+
dispose();
|
|
58049
|
+
}
|
|
58050
|
+
}
|
|
58051
|
+
};
|
|
58052
|
+
const scheduleAnnouncement = () => {
|
|
58053
|
+
if (disposed || announcementTimer !== undefined)
|
|
58054
|
+
return;
|
|
58055
|
+
const idle = announcementCost / ROUTE_ANNOUNCEMENT_EVENT_LOOP_SHARE - announcementCost;
|
|
58056
|
+
const wait = Math.max(ROUTE_ANNOUNCEMENT_BATCH_MS, announcedAt + idle - performance.now());
|
|
58057
|
+
announcementPending = true;
|
|
58058
|
+
announcementTimer = setTimeout(announceBatch, wait);
|
|
58059
|
+
announcementTimer.unref?.();
|
|
58060
|
+
};
|
|
58061
|
+
const unsubscribeStore = activeStore.subscribeInvalidation(scheduleAnnouncement);
|
|
58062
|
+
announceNow();
|
|
57997
58063
|
pi.on?.("session_start", () => {
|
|
57998
58064
|
announcedRoutes.clear();
|
|
57999
|
-
|
|
58065
|
+
announceNow();
|
|
58000
58066
|
});
|
|
58001
58067
|
const routePendingStageMessage = (payload) => {
|
|
58002
58068
|
if (disposed || !isPendingStageMessageEvent(payload) || payload.handled)
|
|
@@ -58078,6 +58144,10 @@ function registerPendingStageIntercomBridge(pi, activeStore, ownsRun = () => tru
|
|
|
58078
58144
|
});
|
|
58079
58145
|
const dispose = () => {
|
|
58080
58146
|
disposed = true;
|
|
58147
|
+
if (announcementTimer !== undefined)
|
|
58148
|
+
clearTimeout(announcementTimer);
|
|
58149
|
+
announcementTimer = undefined;
|
|
58150
|
+
announcementPending = false;
|
|
58081
58151
|
disposeReadiness();
|
|
58082
58152
|
disposeRouter();
|
|
58083
58153
|
routeCompletions.clear();
|
|
@@ -58091,10 +58161,11 @@ function registerPendingStageIntercomBridge(pi, activeStore, ownsRun = () => tru
|
|
|
58091
58161
|
pi.on?.("session_shutdown", dispose);
|
|
58092
58162
|
return Object.assign(dispose, {
|
|
58093
58163
|
async flush() {
|
|
58164
|
+
announceIfPending();
|
|
58094
58165
|
await Promise.allSettled(routeCompletions.values());
|
|
58095
58166
|
await sweepPromise;
|
|
58096
58167
|
},
|
|
58097
|
-
refresh:
|
|
58168
|
+
refresh: announceNow
|
|
58098
58169
|
});
|
|
58099
58170
|
}
|
|
58100
58171
|
function stageRouteTarget(runs, rootRunId, runId, stageId, resolveBoundarySegments = (id) => workflowBoundarySegments(runs, id)) {
|
|
@@ -58569,11 +58640,12 @@ async function settleUndeliverablePendingStageMessages(activeStore, notify, owns
|
|
|
58569
58640
|
}
|
|
58570
58641
|
return settled;
|
|
58571
58642
|
}
|
|
58572
|
-
var PENDING_STAGE_ROUTE_EVENT = "atomic:workflow-pending-stage-route", PENDING_STAGE_MESSAGE_EVENT = "atomic:workflow-pending-stage-message", PENDING_STAGE_UNDELIVERABLE_EVENT = "atomic:workflow-pending-stage-undeliverable", STICKY_LIVE_DELIVERED_EVENT = "atomic:workflow-sticky-live-delivered", PENDING_STAGE_ASK_REFUSAL = "Cannot ask a workflow stage whose session has not initialized. Use send; Atomic will queue the message until the stage session initializes.";
|
|
58643
|
+
var PENDING_STAGE_ROUTE_EVENT = "atomic:workflow-pending-stage-route", PENDING_STAGE_MESSAGE_EVENT = "atomic:workflow-pending-stage-message", PENDING_STAGE_UNDELIVERABLE_EVENT = "atomic:workflow-pending-stage-undeliverable", STICKY_LIVE_DELIVERED_EVENT = "atomic:workflow-sticky-live-delivered", PENDING_STAGE_ASK_REFUSAL = "Cannot ask a workflow stage whose session has not initialized. Use send; Atomic will queue the message until the stage session initializes.", ROUTE_ANNOUNCEMENT_BATCH_MS = 25, ROUTE_ANNOUNCEMENT_EVENT_LOOP_SHARE = 0.2;
|
|
58573
58644
|
var init_pending_stage_intercom = __esm(() => {
|
|
58574
58645
|
init_execution_context_boundary();
|
|
58575
58646
|
init_run_owner_backend();
|
|
58576
58647
|
init_store_backend();
|
|
58648
|
+
init_session_closed_error();
|
|
58577
58649
|
init_external_run_routes();
|
|
58578
58650
|
init_intercom_group();
|
|
58579
58651
|
init_pending_stage_route_capability();
|
|
@@ -61130,7 +61202,7 @@ function isInfrastructureError(value2) {
|
|
|
61130
61202
|
}
|
|
61131
61203
|
function isRetryableWorkflowError(error) {
|
|
61132
61204
|
let current = error;
|
|
61133
|
-
for (let depth = 0;depth <
|
|
61205
|
+
for (let depth = 0;depth < MAX_CAUSE_DEPTH2 && current !== undefined && current !== null; depth++) {
|
|
61134
61206
|
if (isInfrastructureError(current))
|
|
61135
61207
|
return true;
|
|
61136
61208
|
current = current instanceof Error ? current.cause : undefined;
|
|
@@ -61148,7 +61220,7 @@ function asWorkflowInfrastructureError(error) {
|
|
|
61148
61220
|
const code = workflowInfrastructureFault(error.message);
|
|
61149
61221
|
return code === undefined ? undefined : new WorkflowInfrastructureError(code, error.message, { cause: error });
|
|
61150
61222
|
}
|
|
61151
|
-
var WORKFLOW_INFRASTRUCTURE_ERROR_NAME = "WorkflowInfrastructureError",
|
|
61223
|
+
var WORKFLOW_INFRASTRUCTURE_ERROR_NAME = "WorkflowInfrastructureError", MAX_CAUSE_DEPTH2 = 8, FAULT_PATTERNS, WorkflowInfrastructureError;
|
|
61152
61224
|
var init_workflow_infrastructure_error = __esm(() => {
|
|
61153
61225
|
FAULT_PATTERNS = [
|
|
61154
61226
|
[/Local worker (?:process )?cleanup (?:was not confirmed|unconfirmed)/, "worker_cleanup_unconfirmed"],
|
|
@@ -65169,7 +65241,7 @@ function describeErrorWithCauses(error) {
|
|
|
65169
65241
|
const messages = [];
|
|
65170
65242
|
const visited = new Set;
|
|
65171
65243
|
let current = error;
|
|
65172
|
-
for (let depth = 0;current !== undefined && depth <
|
|
65244
|
+
for (let depth = 0;current !== undefined && depth < MAX_CAUSE_DEPTH3 && !visited.has(current); depth++) {
|
|
65173
65245
|
visited.add(current);
|
|
65174
65246
|
const message = current instanceof Error ? current.message : String(current);
|
|
65175
65247
|
if (!messages.includes(message))
|
|
@@ -65178,7 +65250,7 @@ function describeErrorWithCauses(error) {
|
|
|
65178
65250
|
}
|
|
65179
65251
|
return messages.join(": ");
|
|
65180
65252
|
}
|
|
65181
|
-
var
|
|
65253
|
+
var MAX_CAUSE_DEPTH3 = 5;
|
|
65182
65254
|
|
|
65183
65255
|
// dist/builtin/workflows/src/shared/returned-run-status.ts
|
|
65184
65256
|
function normalizeReturnedWorkflowStatus(status) {
|
|
@@ -66703,7 +66775,7 @@ function recordedOwners(boundary, reason) {
|
|
|
66703
66775
|
const pending = [{ value: reason, depth: 0 }];
|
|
66704
66776
|
while (pending.length > 0) {
|
|
66705
66777
|
const { value: value2, depth } = pending.pop();
|
|
66706
|
-
if (depth >
|
|
66778
|
+
if (depth > MAX_CAUSE_DEPTH4)
|
|
66707
66779
|
continue;
|
|
66708
66780
|
if (isPrimitive(value2)) {
|
|
66709
66781
|
if (depth === 0 || value2 !== undefined && value2 !== null) {
|
|
@@ -67025,7 +67097,7 @@ function containUiRejections(ui, scope) {
|
|
|
67025
67097
|
custom: (factory, options) => scope.watch(ui.custom(factory, options))
|
|
67026
67098
|
};
|
|
67027
67099
|
}
|
|
67028
|
-
var EVENT = "unhandledRejection", BOUNDARY_KEY, FLAG = "--unhandled-rejections",
|
|
67100
|
+
var EVENT = "unhandledRejection", BOUNDARY_KEY, FLAG = "--unhandled-rejections", MAX_CAUSE_DEPTH4 = 8, MAX_PRIMITIVES_PER_RUN = 64, MAX_STOP_STRINGS = 64, ENDED_RUN_GRACE_MS = 30000, NATIVE_REPORTING_MODES, WATCHED_STAGE_METHODS;
|
|
67029
67101
|
var init_run_rejection_boundary = __esm(() => {
|
|
67030
67102
|
init_prompt_callsite();
|
|
67031
67103
|
init_workflow_source();
|
|
@@ -72916,27 +72988,6 @@ var init_runtime = __esm(() => {
|
|
|
72916
72988
|
init_intercom_group();
|
|
72917
72989
|
});
|
|
72918
72990
|
|
|
72919
|
-
// dist/builtin/workflows/src/engine/session-closed-error.ts
|
|
72920
|
-
import { isStaleExtensionContextError as isStaleExtensionContextError2 } from "@bastani/atomic";
|
|
72921
|
-
function reportsClosedSession(error) {
|
|
72922
|
-
return "code" in error && error.code === "SessionClosed" || isStaleExtensionContextError2(error);
|
|
72923
|
-
}
|
|
72924
|
-
function isSessionClosedError(error) {
|
|
72925
|
-
let current = error;
|
|
72926
|
-
for (let depth = 0;depth < MAX_CAUSE_DEPTH4 && current !== undefined; depth++) {
|
|
72927
|
-
try {
|
|
72928
|
-
if (reportsClosedSession(current))
|
|
72929
|
-
return true;
|
|
72930
|
-
current = current.cause instanceof Error ? current.cause : undefined;
|
|
72931
|
-
} catch {
|
|
72932
|
-
return false;
|
|
72933
|
-
}
|
|
72934
|
-
}
|
|
72935
|
-
return false;
|
|
72936
|
-
}
|
|
72937
|
-
var MAX_CAUSE_DEPTH4 = 8;
|
|
72938
|
-
var init_session_closed_error = () => {};
|
|
72939
|
-
|
|
72940
72991
|
// dist/builtin/workflows/src/engine/workflow-activity.ts
|
|
72941
72992
|
import { runCallback as runCallback4 } from "@bastani/atomic";
|
|
72942
72993
|
function nextEventLoopTurn() {
|