@bastani/atomic 0.9.44-alpha.3 → 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 +17 -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 +12 -0
- package/dist/builtin/workflows/package.json +1 -1
- package/dist/builtin/workflows/src/extension/index.bundle.mjs +92 -37
- package/dist/builtin/workflows/src/extension/local-worker-entry.mjs +92 -37
- package/dist/builtin/workflows/src/index.js +92 -37
- package/dist/builtin/workflows/src/local-worker-entry.mjs +92 -37
- 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
|
@@ -10117,16 +10117,20 @@ class JournalDurableBackend {
|
|
|
10117
10117
|
}
|
|
10118
10118
|
*append(runId, event, options) {
|
|
10119
10119
|
const lease = yield* this.ownership(runId);
|
|
10120
|
-
const base = this.sequences.get(runId);
|
|
10121
10120
|
const pinned = options?.expectSeq;
|
|
10122
|
-
|
|
10123
|
-
|
|
10121
|
+
for (let attempt = 0;attempt < CHANGE_APPEND_ATTEMPTS; attempt++) {
|
|
10122
|
+
const base = this.sequences.get(runId);
|
|
10123
|
+
const encoded = base !== undefined && (pinned === undefined || pinned === base) && event.type !== RUN_EVENT_TYPES.runStarted ? encodeHandleEvent(event, this.projection.getWorkflow(runId)?.pendingStageMessages) : undefined;
|
|
10124
|
+
if (encoded === undefined)
|
|
10125
|
+
break;
|
|
10124
10126
|
try {
|
|
10125
10127
|
return yield* this.write(runId, lease, encoded, { ...options, expectSeq: base });
|
|
10126
10128
|
} catch (error) {
|
|
10127
10129
|
if (!(error instanceof JournalCasConflictError) || pinned !== undefined)
|
|
10128
10130
|
throw error;
|
|
10129
10131
|
}
|
|
10132
|
+
for (const entry of yield* this.entries(runId, (this.sequences.get(runId) ?? 0) + 1))
|
|
10133
|
+
this.fold(entry);
|
|
10130
10134
|
}
|
|
10131
10135
|
yield* this.write(runId, lease, event, options);
|
|
10132
10136
|
}
|
|
@@ -10807,7 +10811,7 @@ function decodePendingStageDeliveries(previous, messages) {
|
|
|
10807
10811
|
function hasPendingStageDeliveryDelta(messages) {
|
|
10808
10812
|
return messages?.some(isDeltaEncoded) === true;
|
|
10809
10813
|
}
|
|
10810
|
-
var PROCESS_HOLDER_ID, processExitCleanups, JournalOwnershipError, JournalBackendClosedError, JournalOperationAbortedError, JournalExecutionRetiredError, JournalMessageScopeError, entryJson;
|
|
10814
|
+
var PROCESS_HOLDER_ID, CHANGE_APPEND_ATTEMPTS = 4, processExitCleanups, JournalOwnershipError, JournalBackendClosedError, JournalOperationAbortedError, JournalExecutionRetiredError, JournalMessageScopeError, entryJson;
|
|
10811
10815
|
var init_journal_backend = __esm(() => {
|
|
10812
10816
|
init_workflow_instance_ownership_error();
|
|
10813
10817
|
init_backend();
|
|
@@ -58080,6 +58084,27 @@ var init_sql_pool_queue = __esm(() => {
|
|
|
58080
58084
|
init_values();
|
|
58081
58085
|
});
|
|
58082
58086
|
|
|
58087
|
+
// dist/builtin/workflows/src/engine/session-closed-error.ts
|
|
58088
|
+
import { isStaleExtensionContextError as isStaleExtensionContextError2 } from "@bastani/atomic";
|
|
58089
|
+
function reportsClosedSession(error) {
|
|
58090
|
+
return "code" in error && error.code === "SessionClosed" || isStaleExtensionContextError2(error);
|
|
58091
|
+
}
|
|
58092
|
+
function isSessionClosedError(error) {
|
|
58093
|
+
let current = error;
|
|
58094
|
+
for (let depth = 0;depth < MAX_CAUSE_DEPTH && current !== undefined; depth++) {
|
|
58095
|
+
try {
|
|
58096
|
+
if (reportsClosedSession(current))
|
|
58097
|
+
return true;
|
|
58098
|
+
current = current.cause instanceof Error ? current.cause : undefined;
|
|
58099
|
+
} catch {
|
|
58100
|
+
return false;
|
|
58101
|
+
}
|
|
58102
|
+
}
|
|
58103
|
+
return false;
|
|
58104
|
+
}
|
|
58105
|
+
var MAX_CAUSE_DEPTH = 8;
|
|
58106
|
+
var init_session_closed_error = () => {};
|
|
58107
|
+
|
|
58083
58108
|
// dist/builtin/workflows/src/shared/external-run-routes.ts
|
|
58084
58109
|
function claimExternalRunRoute(store, runId, owner) {
|
|
58085
58110
|
let owners = registry.owners.get(store);
|
|
@@ -58574,7 +58599,10 @@ function registerPendingStageIntercomBridge(pi, activeStore, ownsRun = () => tru
|
|
|
58574
58599
|
};
|
|
58575
58600
|
const announcedRoutes = new Map;
|
|
58576
58601
|
const routeCompletions = new Map;
|
|
58577
|
-
const disposeReadiness = registerWorkflowPendingStageRouteReadiness(activeStore, (runId) =>
|
|
58602
|
+
const disposeReadiness = registerWorkflowPendingStageRouteReadiness(activeStore, (runId) => {
|
|
58603
|
+
announceIfPending();
|
|
58604
|
+
return routeCompletions.get(runId);
|
|
58605
|
+
});
|
|
58578
58606
|
const announceRoutes = () => {
|
|
58579
58607
|
if (disposed)
|
|
58580
58608
|
return;
|
|
@@ -58671,11 +58699,53 @@ function registerPendingStageIntercomBridge(pi, activeStore, ownsRun = () => tru
|
|
|
58671
58699
|
return;
|
|
58672
58700
|
}).catch((error) => reportWarning(`atomic-workflows: pending stage delivery sweep failed: ${error.message}`));
|
|
58673
58701
|
};
|
|
58674
|
-
|
|
58675
|
-
|
|
58702
|
+
let announcementPending = false;
|
|
58703
|
+
let announcementTimer;
|
|
58704
|
+
let announcedAt = Number.NEGATIVE_INFINITY;
|
|
58705
|
+
let announcementCost = 0;
|
|
58706
|
+
const announceNow = () => {
|
|
58707
|
+
if (announcementTimer !== undefined)
|
|
58708
|
+
clearTimeout(announcementTimer);
|
|
58709
|
+
announcementTimer = undefined;
|
|
58710
|
+
announcementPending = false;
|
|
58711
|
+
const started = performance.now();
|
|
58712
|
+
announceRoutes();
|
|
58713
|
+
announcedAt = performance.now();
|
|
58714
|
+
announcementCost = announcedAt - started;
|
|
58715
|
+
};
|
|
58716
|
+
function announceIfPending() {
|
|
58717
|
+
if (announcementPending)
|
|
58718
|
+
announceNow();
|
|
58719
|
+
}
|
|
58720
|
+
const announceBatch = () => {
|
|
58721
|
+
try {
|
|
58722
|
+
announceNow();
|
|
58723
|
+
} catch (error) {
|
|
58724
|
+
if (error instanceof Error && isSessionClosedError(error)) {
|
|
58725
|
+
dispose();
|
|
58726
|
+
return;
|
|
58727
|
+
}
|
|
58728
|
+
try {
|
|
58729
|
+
reportWarning(`atomic-workflows: pending stage route announcement failed: ${String(error)}`);
|
|
58730
|
+
} catch {
|
|
58731
|
+
dispose();
|
|
58732
|
+
}
|
|
58733
|
+
}
|
|
58734
|
+
};
|
|
58735
|
+
const scheduleAnnouncement = () => {
|
|
58736
|
+
if (disposed || announcementTimer !== undefined)
|
|
58737
|
+
return;
|
|
58738
|
+
const idle = announcementCost / ROUTE_ANNOUNCEMENT_EVENT_LOOP_SHARE - announcementCost;
|
|
58739
|
+
const wait = Math.max(ROUTE_ANNOUNCEMENT_BATCH_MS, announcedAt + idle - performance.now());
|
|
58740
|
+
announcementPending = true;
|
|
58741
|
+
announcementTimer = setTimeout(announceBatch, wait);
|
|
58742
|
+
announcementTimer.unref?.();
|
|
58743
|
+
};
|
|
58744
|
+
const unsubscribeStore = activeStore.subscribeInvalidation(scheduleAnnouncement);
|
|
58745
|
+
announceNow();
|
|
58676
58746
|
pi.on?.("session_start", () => {
|
|
58677
58747
|
announcedRoutes.clear();
|
|
58678
|
-
|
|
58748
|
+
announceNow();
|
|
58679
58749
|
});
|
|
58680
58750
|
const routePendingStageMessage = (payload) => {
|
|
58681
58751
|
if (disposed || !isPendingStageMessageEvent(payload) || payload.handled)
|
|
@@ -58757,6 +58827,10 @@ function registerPendingStageIntercomBridge(pi, activeStore, ownsRun = () => tru
|
|
|
58757
58827
|
});
|
|
58758
58828
|
const dispose = () => {
|
|
58759
58829
|
disposed = true;
|
|
58830
|
+
if (announcementTimer !== undefined)
|
|
58831
|
+
clearTimeout(announcementTimer);
|
|
58832
|
+
announcementTimer = undefined;
|
|
58833
|
+
announcementPending = false;
|
|
58760
58834
|
disposeReadiness();
|
|
58761
58835
|
disposeRouter();
|
|
58762
58836
|
routeCompletions.clear();
|
|
@@ -58770,10 +58844,11 @@ function registerPendingStageIntercomBridge(pi, activeStore, ownsRun = () => tru
|
|
|
58770
58844
|
pi.on?.("session_shutdown", dispose);
|
|
58771
58845
|
return Object.assign(dispose, {
|
|
58772
58846
|
async flush() {
|
|
58847
|
+
announceIfPending();
|
|
58773
58848
|
await Promise.allSettled(routeCompletions.values());
|
|
58774
58849
|
await sweepPromise;
|
|
58775
58850
|
},
|
|
58776
|
-
refresh:
|
|
58851
|
+
refresh: announceNow
|
|
58777
58852
|
});
|
|
58778
58853
|
}
|
|
58779
58854
|
function stageRouteTarget(runs, rootRunId, runId, stageId, resolveBoundarySegments = (id) => workflowBoundarySegments(runs, id)) {
|
|
@@ -59248,11 +59323,12 @@ async function settleUndeliverablePendingStageMessages(activeStore, notify, owns
|
|
|
59248
59323
|
}
|
|
59249
59324
|
return settled;
|
|
59250
59325
|
}
|
|
59251
|
-
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.";
|
|
59326
|
+
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;
|
|
59252
59327
|
var init_pending_stage_intercom = __esm(() => {
|
|
59253
59328
|
init_execution_context_boundary();
|
|
59254
59329
|
init_run_owner_backend();
|
|
59255
59330
|
init_store_backend();
|
|
59331
|
+
init_session_closed_error();
|
|
59256
59332
|
init_external_run_routes();
|
|
59257
59333
|
init_intercom_group();
|
|
59258
59334
|
init_pending_stage_route_capability();
|
|
@@ -61745,7 +61821,7 @@ function isInfrastructureError(value2) {
|
|
|
61745
61821
|
}
|
|
61746
61822
|
function isRetryableWorkflowError(error) {
|
|
61747
61823
|
let current = error;
|
|
61748
|
-
for (let depth = 0;depth <
|
|
61824
|
+
for (let depth = 0;depth < MAX_CAUSE_DEPTH2 && current !== undefined && current !== null; depth++) {
|
|
61749
61825
|
if (isInfrastructureError(current))
|
|
61750
61826
|
return true;
|
|
61751
61827
|
current = current instanceof Error ? current.cause : undefined;
|
|
@@ -61763,7 +61839,7 @@ function asWorkflowInfrastructureError(error) {
|
|
|
61763
61839
|
const code = workflowInfrastructureFault(error.message);
|
|
61764
61840
|
return code === undefined ? undefined : new WorkflowInfrastructureError(code, error.message, { cause: error });
|
|
61765
61841
|
}
|
|
61766
|
-
var WORKFLOW_INFRASTRUCTURE_ERROR_NAME = "WorkflowInfrastructureError",
|
|
61842
|
+
var WORKFLOW_INFRASTRUCTURE_ERROR_NAME = "WorkflowInfrastructureError", MAX_CAUSE_DEPTH2 = 8, FAULT_PATTERNS, WorkflowInfrastructureError;
|
|
61767
61843
|
var init_workflow_infrastructure_error = __esm(() => {
|
|
61768
61844
|
FAULT_PATTERNS = [
|
|
61769
61845
|
[/Local worker (?:process )?cleanup (?:was not confirmed|unconfirmed)/, "worker_cleanup_unconfirmed"],
|
|
@@ -64952,7 +65028,7 @@ function describeErrorWithCauses(error) {
|
|
|
64952
65028
|
const messages = [];
|
|
64953
65029
|
const visited = new Set;
|
|
64954
65030
|
let current = error;
|
|
64955
|
-
for (let depth = 0;current !== undefined && depth <
|
|
65031
|
+
for (let depth = 0;current !== undefined && depth < MAX_CAUSE_DEPTH3 && !visited.has(current); depth++) {
|
|
64956
65032
|
visited.add(current);
|
|
64957
65033
|
const message = current instanceof Error ? current.message : String(current);
|
|
64958
65034
|
if (!messages.includes(message))
|
|
@@ -64961,7 +65037,7 @@ function describeErrorWithCauses(error) {
|
|
|
64961
65037
|
}
|
|
64962
65038
|
return messages.join(": ");
|
|
64963
65039
|
}
|
|
64964
|
-
var
|
|
65040
|
+
var MAX_CAUSE_DEPTH3 = 5;
|
|
64965
65041
|
|
|
64966
65042
|
// dist/builtin/workflows/src/shared/returned-run-status.ts
|
|
64967
65043
|
function normalizeReturnedWorkflowStatus(status) {
|
|
@@ -66486,7 +66562,7 @@ function recordedOwners(boundary, reason) {
|
|
|
66486
66562
|
const pending = [{ value: reason, depth: 0 }];
|
|
66487
66563
|
while (pending.length > 0) {
|
|
66488
66564
|
const { value: value2, depth } = pending.pop();
|
|
66489
|
-
if (depth >
|
|
66565
|
+
if (depth > MAX_CAUSE_DEPTH4)
|
|
66490
66566
|
continue;
|
|
66491
66567
|
if (isPrimitive(value2)) {
|
|
66492
66568
|
if (depth === 0 || value2 !== undefined && value2 !== null) {
|
|
@@ -66808,7 +66884,7 @@ function containUiRejections(ui, scope) {
|
|
|
66808
66884
|
custom: (factory, options) => scope.watch(ui.custom(factory, options))
|
|
66809
66885
|
};
|
|
66810
66886
|
}
|
|
66811
|
-
var EVENT = "unhandledRejection", BOUNDARY_KEY, FLAG = "--unhandled-rejections",
|
|
66887
|
+
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;
|
|
66812
66888
|
var init_run_rejection_boundary = __esm(() => {
|
|
66813
66889
|
init_prompt_callsite();
|
|
66814
66890
|
init_workflow_source();
|
|
@@ -72699,27 +72775,6 @@ var init_runtime = __esm(() => {
|
|
|
72699
72775
|
init_intercom_group();
|
|
72700
72776
|
});
|
|
72701
72777
|
|
|
72702
|
-
// dist/builtin/workflows/src/engine/session-closed-error.ts
|
|
72703
|
-
import { isStaleExtensionContextError as isStaleExtensionContextError2 } from "@bastani/atomic";
|
|
72704
|
-
function reportsClosedSession(error) {
|
|
72705
|
-
return "code" in error && error.code === "SessionClosed" || isStaleExtensionContextError2(error);
|
|
72706
|
-
}
|
|
72707
|
-
function isSessionClosedError(error) {
|
|
72708
|
-
let current = error;
|
|
72709
|
-
for (let depth = 0;depth < MAX_CAUSE_DEPTH4 && current !== undefined; depth++) {
|
|
72710
|
-
try {
|
|
72711
|
-
if (reportsClosedSession(current))
|
|
72712
|
-
return true;
|
|
72713
|
-
current = current.cause instanceof Error ? current.cause : undefined;
|
|
72714
|
-
} catch {
|
|
72715
|
-
return false;
|
|
72716
|
-
}
|
|
72717
|
-
}
|
|
72718
|
-
return false;
|
|
72719
|
-
}
|
|
72720
|
-
var MAX_CAUSE_DEPTH4 = 8;
|
|
72721
|
-
var init_session_closed_error = () => {};
|
|
72722
|
-
|
|
72723
72778
|
// dist/builtin/workflows/src/engine/workflow-activity.ts
|
|
72724
72779
|
import { runCallback as runCallback4 } from "@bastani/atomic";
|
|
72725
72780
|
function nextEventLoopTurn() {
|
|
@@ -1908,16 +1908,20 @@ class JournalDurableBackend {
|
|
|
1908
1908
|
}
|
|
1909
1909
|
*append(runId, event, options) {
|
|
1910
1910
|
const lease = yield* this.ownership(runId);
|
|
1911
|
-
const base = this.sequences.get(runId);
|
|
1912
1911
|
const pinned = options?.expectSeq;
|
|
1913
|
-
|
|
1914
|
-
|
|
1912
|
+
for (let attempt = 0;attempt < CHANGE_APPEND_ATTEMPTS; attempt++) {
|
|
1913
|
+
const base = this.sequences.get(runId);
|
|
1914
|
+
const encoded = base !== undefined && (pinned === undefined || pinned === base) && event.type !== RUN_EVENT_TYPES.runStarted ? encodeHandleEvent(event, this.projection.getWorkflow(runId)?.pendingStageMessages) : undefined;
|
|
1915
|
+
if (encoded === undefined)
|
|
1916
|
+
break;
|
|
1915
1917
|
try {
|
|
1916
1918
|
return yield* this.write(runId, lease, encoded, { ...options, expectSeq: base });
|
|
1917
1919
|
} catch (error) {
|
|
1918
1920
|
if (!(error instanceof JournalCasConflictError) || pinned !== undefined)
|
|
1919
1921
|
throw error;
|
|
1920
1922
|
}
|
|
1923
|
+
for (const entry of yield* this.entries(runId, (this.sequences.get(runId) ?? 0) + 1))
|
|
1924
|
+
this.fold(entry);
|
|
1921
1925
|
}
|
|
1922
1926
|
yield* this.write(runId, lease, event, options);
|
|
1923
1927
|
}
|
|
@@ -2598,7 +2602,7 @@ function decodePendingStageDeliveries(previous, messages) {
|
|
|
2598
2602
|
function hasPendingStageDeliveryDelta(messages) {
|
|
2599
2603
|
return messages?.some(isDeltaEncoded) === true;
|
|
2600
2604
|
}
|
|
2601
|
-
var PROCESS_HOLDER_ID, processExitCleanups, JournalOwnershipError, JournalBackendClosedError, JournalOperationAbortedError, JournalExecutionRetiredError, JournalMessageScopeError, entryJson;
|
|
2605
|
+
var PROCESS_HOLDER_ID, CHANGE_APPEND_ATTEMPTS = 4, processExitCleanups, JournalOwnershipError, JournalBackendClosedError, JournalOperationAbortedError, JournalExecutionRetiredError, JournalMessageScopeError, entryJson;
|
|
2602
2606
|
var init_journal_backend = __esm(() => {
|
|
2603
2607
|
init_workflow_instance_ownership_error();
|
|
2604
2608
|
init_backend();
|
|
@@ -57397,6 +57401,27 @@ var init_executor = __esm(() => {
|
|
|
57397
57401
|
init_executor_run();
|
|
57398
57402
|
});
|
|
57399
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
|
+
|
|
57400
57425
|
// dist/builtin/workflows/src/shared/external-run-routes.ts
|
|
57401
57426
|
function claimExternalRunRoute(store, runId, owner) {
|
|
57402
57427
|
let owners = registry.owners.get(store);
|
|
@@ -57891,7 +57916,10 @@ function registerPendingStageIntercomBridge(pi, activeStore, ownsRun = () => tru
|
|
|
57891
57916
|
};
|
|
57892
57917
|
const announcedRoutes = new Map;
|
|
57893
57918
|
const routeCompletions = new Map;
|
|
57894
|
-
const disposeReadiness = registerWorkflowPendingStageRouteReadiness(activeStore, (runId) =>
|
|
57919
|
+
const disposeReadiness = registerWorkflowPendingStageRouteReadiness(activeStore, (runId) => {
|
|
57920
|
+
announceIfPending();
|
|
57921
|
+
return routeCompletions.get(runId);
|
|
57922
|
+
});
|
|
57895
57923
|
const announceRoutes = () => {
|
|
57896
57924
|
if (disposed)
|
|
57897
57925
|
return;
|
|
@@ -57988,11 +58016,53 @@ function registerPendingStageIntercomBridge(pi, activeStore, ownsRun = () => tru
|
|
|
57988
58016
|
return;
|
|
57989
58017
|
}).catch((error) => reportWarning(`atomic-workflows: pending stage delivery sweep failed: ${error.message}`));
|
|
57990
58018
|
};
|
|
57991
|
-
|
|
57992
|
-
|
|
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();
|
|
57993
58063
|
pi.on?.("session_start", () => {
|
|
57994
58064
|
announcedRoutes.clear();
|
|
57995
|
-
|
|
58065
|
+
announceNow();
|
|
57996
58066
|
});
|
|
57997
58067
|
const routePendingStageMessage = (payload) => {
|
|
57998
58068
|
if (disposed || !isPendingStageMessageEvent(payload) || payload.handled)
|
|
@@ -58074,6 +58144,10 @@ function registerPendingStageIntercomBridge(pi, activeStore, ownsRun = () => tru
|
|
|
58074
58144
|
});
|
|
58075
58145
|
const dispose = () => {
|
|
58076
58146
|
disposed = true;
|
|
58147
|
+
if (announcementTimer !== undefined)
|
|
58148
|
+
clearTimeout(announcementTimer);
|
|
58149
|
+
announcementTimer = undefined;
|
|
58150
|
+
announcementPending = false;
|
|
58077
58151
|
disposeReadiness();
|
|
58078
58152
|
disposeRouter();
|
|
58079
58153
|
routeCompletions.clear();
|
|
@@ -58087,10 +58161,11 @@ function registerPendingStageIntercomBridge(pi, activeStore, ownsRun = () => tru
|
|
|
58087
58161
|
pi.on?.("session_shutdown", dispose);
|
|
58088
58162
|
return Object.assign(dispose, {
|
|
58089
58163
|
async flush() {
|
|
58164
|
+
announceIfPending();
|
|
58090
58165
|
await Promise.allSettled(routeCompletions.values());
|
|
58091
58166
|
await sweepPromise;
|
|
58092
58167
|
},
|
|
58093
|
-
refresh:
|
|
58168
|
+
refresh: announceNow
|
|
58094
58169
|
});
|
|
58095
58170
|
}
|
|
58096
58171
|
function stageRouteTarget(runs, rootRunId, runId, stageId, resolveBoundarySegments = (id) => workflowBoundarySegments(runs, id)) {
|
|
@@ -58565,11 +58640,12 @@ async function settleUndeliverablePendingStageMessages(activeStore, notify, owns
|
|
|
58565
58640
|
}
|
|
58566
58641
|
return settled;
|
|
58567
58642
|
}
|
|
58568
|
-
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;
|
|
58569
58644
|
var init_pending_stage_intercom = __esm(() => {
|
|
58570
58645
|
init_execution_context_boundary();
|
|
58571
58646
|
init_run_owner_backend();
|
|
58572
58647
|
init_store_backend();
|
|
58648
|
+
init_session_closed_error();
|
|
58573
58649
|
init_external_run_routes();
|
|
58574
58650
|
init_intercom_group();
|
|
58575
58651
|
init_pending_stage_route_capability();
|
|
@@ -61126,7 +61202,7 @@ function isInfrastructureError(value2) {
|
|
|
61126
61202
|
}
|
|
61127
61203
|
function isRetryableWorkflowError(error) {
|
|
61128
61204
|
let current = error;
|
|
61129
|
-
for (let depth = 0;depth <
|
|
61205
|
+
for (let depth = 0;depth < MAX_CAUSE_DEPTH2 && current !== undefined && current !== null; depth++) {
|
|
61130
61206
|
if (isInfrastructureError(current))
|
|
61131
61207
|
return true;
|
|
61132
61208
|
current = current instanceof Error ? current.cause : undefined;
|
|
@@ -61144,7 +61220,7 @@ function asWorkflowInfrastructureError(error) {
|
|
|
61144
61220
|
const code = workflowInfrastructureFault(error.message);
|
|
61145
61221
|
return code === undefined ? undefined : new WorkflowInfrastructureError(code, error.message, { cause: error });
|
|
61146
61222
|
}
|
|
61147
|
-
var WORKFLOW_INFRASTRUCTURE_ERROR_NAME = "WorkflowInfrastructureError",
|
|
61223
|
+
var WORKFLOW_INFRASTRUCTURE_ERROR_NAME = "WorkflowInfrastructureError", MAX_CAUSE_DEPTH2 = 8, FAULT_PATTERNS, WorkflowInfrastructureError;
|
|
61148
61224
|
var init_workflow_infrastructure_error = __esm(() => {
|
|
61149
61225
|
FAULT_PATTERNS = [
|
|
61150
61226
|
[/Local worker (?:process )?cleanup (?:was not confirmed|unconfirmed)/, "worker_cleanup_unconfirmed"],
|
|
@@ -65165,7 +65241,7 @@ function describeErrorWithCauses(error) {
|
|
|
65165
65241
|
const messages = [];
|
|
65166
65242
|
const visited = new Set;
|
|
65167
65243
|
let current = error;
|
|
65168
|
-
for (let depth = 0;current !== undefined && depth <
|
|
65244
|
+
for (let depth = 0;current !== undefined && depth < MAX_CAUSE_DEPTH3 && !visited.has(current); depth++) {
|
|
65169
65245
|
visited.add(current);
|
|
65170
65246
|
const message = current instanceof Error ? current.message : String(current);
|
|
65171
65247
|
if (!messages.includes(message))
|
|
@@ -65174,7 +65250,7 @@ function describeErrorWithCauses(error) {
|
|
|
65174
65250
|
}
|
|
65175
65251
|
return messages.join(": ");
|
|
65176
65252
|
}
|
|
65177
|
-
var
|
|
65253
|
+
var MAX_CAUSE_DEPTH3 = 5;
|
|
65178
65254
|
|
|
65179
65255
|
// dist/builtin/workflows/src/shared/returned-run-status.ts
|
|
65180
65256
|
function normalizeReturnedWorkflowStatus(status) {
|
|
@@ -66699,7 +66775,7 @@ function recordedOwners(boundary, reason) {
|
|
|
66699
66775
|
const pending = [{ value: reason, depth: 0 }];
|
|
66700
66776
|
while (pending.length > 0) {
|
|
66701
66777
|
const { value: value2, depth } = pending.pop();
|
|
66702
|
-
if (depth >
|
|
66778
|
+
if (depth > MAX_CAUSE_DEPTH4)
|
|
66703
66779
|
continue;
|
|
66704
66780
|
if (isPrimitive(value2)) {
|
|
66705
66781
|
if (depth === 0 || value2 !== undefined && value2 !== null) {
|
|
@@ -67021,7 +67097,7 @@ function containUiRejections(ui, scope) {
|
|
|
67021
67097
|
custom: (factory, options) => scope.watch(ui.custom(factory, options))
|
|
67022
67098
|
};
|
|
67023
67099
|
}
|
|
67024
|
-
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;
|
|
67025
67101
|
var init_run_rejection_boundary = __esm(() => {
|
|
67026
67102
|
init_prompt_callsite();
|
|
67027
67103
|
init_workflow_source();
|
|
@@ -72912,27 +72988,6 @@ var init_runtime = __esm(() => {
|
|
|
72912
72988
|
init_intercom_group();
|
|
72913
72989
|
});
|
|
72914
72990
|
|
|
72915
|
-
// dist/builtin/workflows/src/engine/session-closed-error.ts
|
|
72916
|
-
import { isStaleExtensionContextError as isStaleExtensionContextError2 } from "@bastani/atomic";
|
|
72917
|
-
function reportsClosedSession(error) {
|
|
72918
|
-
return "code" in error && error.code === "SessionClosed" || isStaleExtensionContextError2(error);
|
|
72919
|
-
}
|
|
72920
|
-
function isSessionClosedError(error) {
|
|
72921
|
-
let current = error;
|
|
72922
|
-
for (let depth = 0;depth < MAX_CAUSE_DEPTH4 && current !== undefined; depth++) {
|
|
72923
|
-
try {
|
|
72924
|
-
if (reportsClosedSession(current))
|
|
72925
|
-
return true;
|
|
72926
|
-
current = current.cause instanceof Error ? current.cause : undefined;
|
|
72927
|
-
} catch {
|
|
72928
|
-
return false;
|
|
72929
|
-
}
|
|
72930
|
-
}
|
|
72931
|
-
return false;
|
|
72932
|
-
}
|
|
72933
|
-
var MAX_CAUSE_DEPTH4 = 8;
|
|
72934
|
-
var init_session_closed_error = () => {};
|
|
72935
|
-
|
|
72936
72991
|
// dist/builtin/workflows/src/engine/workflow-activity.ts
|
|
72937
72992
|
import { runCallback as runCallback4 } from "@bastani/atomic";
|
|
72938
72993
|
function nextEventLoopTurn() {
|
|
@@ -8,7 +8,11 @@ export declare class StorageUnavailableError extends StorageError {
|
|
|
8
8
|
readonly adapter: string;
|
|
9
9
|
readonly location: string;
|
|
10
10
|
readonly cause: StorageFailureCause;
|
|
11
|
-
|
|
11
|
+
/**
|
|
12
|
+
* `detail` names the driver failure in the message: a worker or coordinator that relays only `message` across
|
|
13
|
+
* a process boundary keeps the reason. Adapters pass it only for causes that cannot carry credentials.
|
|
14
|
+
*/
|
|
15
|
+
constructor(descriptor: StorageDescriptor, cause: StorageFailureCause, detail?: string);
|
|
12
16
|
}
|
|
13
17
|
export declare class StoreClosedError extends StorageError {
|
|
14
18
|
readonly adapter: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/core/storage/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAEpE,MAAM,MAAM,mBAAmB,GAAG,MAAM,GAAG,WAAW,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,CAAC;AAEtF,qBAAa,YAAa,SAAQ,KAAK;IACtC,SAAiB,YAAY,CAAC,EAAE,mBAAmB,CAAC;IACpD,YAAY,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,EAGlD;CACD;AAED,qBAAa,uBAAwB,SAAQ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,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,YAAY,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAKlD;CACD;AAED,qBAAa,2BAA4B,SAAQ,YAAY;IAC5D,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,YAAY,UAAU,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAIlD;CACD"}
|
|
@@ -7,8 +7,14 @@ export class StorageError extends Error {
|
|
|
7
7
|
export class StorageUnavailableError extends StorageError {
|
|
8
8
|
adapter;
|
|
9
9
|
location;
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
/**
|
|
11
|
+
* `detail` names the driver failure in the message: a worker or coordinator that relays only `message` across
|
|
12
|
+
* a process boundary keeps the reason. Adapters pass it only for causes that cannot carry credentials.
|
|
13
|
+
*/
|
|
14
|
+
constructor(descriptor, cause, detail) {
|
|
15
|
+
super(`Storage unavailable: ${descriptor.adapter} at ${descriptor.location}${detail ? `: ${detail}` : ""}`, {
|
|
16
|
+
cause,
|
|
17
|
+
});
|
|
12
18
|
this.adapter = descriptor.adapter;
|
|
13
19
|
this.location = descriptor.location;
|
|
14
20
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/core/storage/errors.ts"],"names":[],"mappings":"AAIA,MAAM,OAAO,YAAa,SAAQ,KAAK;IAEtC,YAAY,OAAe,EAAE,OAAsB;QAClD,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC;IAC7B,CAAC;CACD;AAED,MAAM,OAAO,uBAAwB,SAAQ,YAAY;IAC/C,OAAO,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QACrB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACtB,CAAC;CACD;AAED,MAAM,OAAO,uBAAwB,SAAQ,YAAY;IAC/C,MAAM,CAAS;IAExB,YAAY,MAAc,EAAE,KAA0B;QACrD,KAAK,CAAC,mCAAmC,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;QAC9D,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACtB,CAAC;CACD;AAED,MAAM,OAAO,0BAA2B,SAAQ,YAAY;IAClD,MAAM,CAAS;IACf,EAAE,CAAS;IACX,GAAG,CAAS;IACrB,YAAY,MAAc,EAAE,EAAU,EAAE,GAAW;QAClD,KAAK,CAAC,kCAAkC,MAAM,IAAI,EAAE,EAAE,CAAC,CAAC;QACxD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IAChB,CAAC;CACD;AAED,MAAM,OAAO,2BAA4B,SAAQ,YAAY;IACnD,UAAU,CAAS;IACnB,WAAW,CAAS;IAC7B,YAAY,UAAkB,EAAE,WAAmB;QAClD,KAAK,CAAC,2CAA2C,CAAC,CAAC;QACnD,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IAChC,CAAC;CACD","sourcesContent":["import type { SqliteValue, StorageDescriptor } from \"./database.js\";\n\nexport type StorageFailureCause = object | SqliteValue | boolean | symbol | undefined;\n\nexport class StorageError extends Error {\n\tdeclare readonly cleanupCause?: StorageFailureCause;\n\tconstructor(message: string, options?: ErrorOptions) {\n\t\tsuper(message, options);\n\t\tthis.name = new.target.name;\n\t}\n}\n\nexport class StorageUnavailableError extends StorageError {\n\treadonly adapter: string;\n\treadonly location: string;\n\tdeclare readonly cause: StorageFailureCause;\n\t/**\n\t * `detail` names the driver failure in the message: a worker or coordinator that relays only `message` across\n\t * a process boundary keeps the reason. Adapters pass it only for causes that cannot carry credentials.\n\t */\n\tconstructor(descriptor: StorageDescriptor, cause: StorageFailureCause, detail?: string) {\n\t\tsuper(`Storage unavailable: ${descriptor.adapter} at ${descriptor.location}${detail ? `: ${detail}` : \"\"}`, {\n\t\t\tcause,\n\t\t});\n\t\tthis.adapter = descriptor.adapter;\n\t\tthis.location = descriptor.location;\n\t}\n}\n\nexport class StoreClosedError extends StorageError {\n\treadonly adapter: string;\n\treadonly location: string;\n\tconstructor(descriptor: StorageDescriptor) {\n\t\tsuper(`Storage closed: ${descriptor.adapter} at ${descriptor.location}`);\n\t\tthis.adapter = descriptor.adapter;\n\t\tthis.location = descriptor.location;\n\t}\n}\n\nexport class StorageTransactionClosedError extends StorageError {\n\tconstructor() {\n\t\tsuper(\"Storage transaction is closed\");\n\t}\n}\n\nexport class StorageRollbackError extends StorageError {\n\tdeclare readonly cause: StorageFailureCause;\n\treadonly rollbackCause: StorageFailureCause;\n\tconstructor(cause: StorageFailureCause, rollbackCause: StorageFailureCause) {\n\t\tsuper(\"Storage rollback failed\", { cause });\n\t\tthis.rollbackCause = rollbackCause;\n\t}\n}\n\nexport class StorageInvalidTextError extends StorageError {\n\treadonly parameterIndex: number;\n\treadonly reason = \"nul-character\";\n\tconstructor(parameterIndex: number) {\n\t\tsuper(`Storage parameter ${parameterIndex} contains a NUL character`);\n\t\tthis.parameterIndex = parameterIndex;\n\t}\n}\n\nexport class StorageSchemaVersionError extends StorageError {\n\treadonly domain: string;\n\treadonly found: SqliteValue;\n\treadonly supported: number;\n\tconstructor(domain: string, found: SqliteValue, supported: number) {\n\t\tsuper(`Unsupported ${domain} storage schema version`);\n\t\tthis.domain = domain;\n\t\tthis.found = found;\n\t\tthis.supported = supported;\n\t}\n}\n\nexport class StoragePrefixError extends StorageError {\n\treadonly prefix: string;\n\treadonly reason: \"pattern\" | \"reserved\";\n\tconstructor(prefix: string, reason: \"pattern\" | \"reserved\") {\n\t\tsuper(`Invalid storage prefix: ${reason}`);\n\t\tthis.prefix = prefix;\n\t\tthis.reason = reason;\n\t}\n}\n\nexport class StorageConfigError extends StorageError {\n\treadonly source: \"sdk\" | \"cli\" | \"env\" | \"settings\";\n\treadonly field: string;\n\treadonly reason: string;\n\tconstructor(source: \"sdk\" | \"cli\" | \"env\" | \"settings\", field: string, reason: string) {\n\t\tsuper(`Invalid storage configuration: ${field} (${reason})`);\n\t\tthis.source = source;\n\t\tthis.field = field;\n\t\tthis.reason = reason;\n\t}\n}\n\nexport class StorageAdapterLoadError extends StorageError {\n\treadonly module: string;\n\tdeclare readonly cause: StorageFailureCause;\n\tconstructor(module: string, cause: StorageFailureCause) {\n\t\tsuper(`Could not load storage adapter: ${module}`, { cause });\n\t\tthis.module = module;\n\t}\n}\n\nexport class StorageOutcomeUnknownError extends StorageError {\n\treadonly domain: string;\n\treadonly id: string;\n\treadonly key: string;\n\tconstructor(domain: string, id: string, key: string) {\n\t\tsuper(`Storage write outcome unknown: ${domain} ${id}`);\n\t\tthis.domain = domain;\n\t\tthis.id = id;\n\t\tthis.key = key;\n\t}\n}\n\nexport class StoragePayloadTooLargeError extends StorageError {\n\treadonly limitBytes: number;\n\treadonly actualBytes: number;\n\tconstructor(limitBytes: number, actualBytes: number) {\n\t\tsuper(\"Storage payload exceeds the backend limit\");\n\t\tthis.limitBytes = limitBytes;\n\t\tthis.actualBytes = actualBytes;\n\t}\n}\n"]}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { DatabaseSync } from "node:sqlite";
|
|
2
2
|
import type { SqliteDatabase } from "./database.js";
|
|
3
|
-
export declare function openNodeSqliteDatabase(path: string, { busyTimeoutMs, readOnly }?: {
|
|
3
|
+
export declare function openNodeSqliteDatabase(path: string, { busyTimeoutMs, lockWaitMs, readOnly, }?: {
|
|
4
4
|
busyTimeoutMs?: number;
|
|
5
|
+
lockWaitMs?: number;
|
|
5
6
|
readOnly?: boolean;
|
|
6
7
|
}): Promise<SqliteDatabase>;
|
|
7
8
|
export declare function wrapNodeSqliteDatabase(connection: DatabaseSync): SqliteDatabase;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-sqlite.d.ts","sourceRoot":"","sources":["../../../src/core/storage/node-sqlite.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EAAE,cAAc,EAA6D,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"node-sqlite.d.ts","sourceRoot":"","sources":["../../../src/core/storage/node-sqlite.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EAAE,cAAc,EAA6D,MAAM,eAAe,CAAC;AA0R/G,wBAAsB,sBAAsB,CAC3C,IAAI,EAAE,MAAM,EACZ,EACC,aAAoB,EACpB,UAA6C,EAC7C,QAAgB,GAChB,GAAE;IAAE,aAAa,CAAC,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAO,GACzE,OAAO,CAAC,cAAc,CAAC,CA2BzB;AAED,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,YAAY,GAAG,cAAc,CAW/E"}
|