@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.
@@ -58084,6 +58084,27 @@ var init_sql_pool_queue = __esm(() => {
58084
58084
  init_values();
58085
58085
  });
58086
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
+
58087
58108
  // dist/builtin/workflows/src/shared/external-run-routes.ts
58088
58109
  function claimExternalRunRoute(store, runId, owner) {
58089
58110
  let owners = registry.owners.get(store);
@@ -58578,7 +58599,10 @@ function registerPendingStageIntercomBridge(pi, activeStore, ownsRun = () => tru
58578
58599
  };
58579
58600
  const announcedRoutes = new Map;
58580
58601
  const routeCompletions = new Map;
58581
- const disposeReadiness = registerWorkflowPendingStageRouteReadiness(activeStore, (runId) => routeCompletions.get(runId));
58602
+ const disposeReadiness = registerWorkflowPendingStageRouteReadiness(activeStore, (runId) => {
58603
+ announceIfPending();
58604
+ return routeCompletions.get(runId);
58605
+ });
58582
58606
  const announceRoutes = () => {
58583
58607
  if (disposed)
58584
58608
  return;
@@ -58675,11 +58699,53 @@ function registerPendingStageIntercomBridge(pi, activeStore, ownsRun = () => tru
58675
58699
  return;
58676
58700
  }).catch((error) => reportWarning(`atomic-workflows: pending stage delivery sweep failed: ${error.message}`));
58677
58701
  };
58678
- const unsubscribeStore = activeStore.subscribeInvalidation(announceRoutes);
58679
- announceRoutes();
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();
58680
58746
  pi.on?.("session_start", () => {
58681
58747
  announcedRoutes.clear();
58682
- announceRoutes();
58748
+ announceNow();
58683
58749
  });
58684
58750
  const routePendingStageMessage = (payload) => {
58685
58751
  if (disposed || !isPendingStageMessageEvent(payload) || payload.handled)
@@ -58761,6 +58827,10 @@ function registerPendingStageIntercomBridge(pi, activeStore, ownsRun = () => tru
58761
58827
  });
58762
58828
  const dispose = () => {
58763
58829
  disposed = true;
58830
+ if (announcementTimer !== undefined)
58831
+ clearTimeout(announcementTimer);
58832
+ announcementTimer = undefined;
58833
+ announcementPending = false;
58764
58834
  disposeReadiness();
58765
58835
  disposeRouter();
58766
58836
  routeCompletions.clear();
@@ -58774,10 +58844,11 @@ function registerPendingStageIntercomBridge(pi, activeStore, ownsRun = () => tru
58774
58844
  pi.on?.("session_shutdown", dispose);
58775
58845
  return Object.assign(dispose, {
58776
58846
  async flush() {
58847
+ announceIfPending();
58777
58848
  await Promise.allSettled(routeCompletions.values());
58778
58849
  await sweepPromise;
58779
58850
  },
58780
- refresh: announceRoutes
58851
+ refresh: announceNow
58781
58852
  });
58782
58853
  }
58783
58854
  function stageRouteTarget(runs, rootRunId, runId, stageId, resolveBoundarySegments = (id) => workflowBoundarySegments(runs, id)) {
@@ -59252,11 +59323,12 @@ async function settleUndeliverablePendingStageMessages(activeStore, notify, owns
59252
59323
  }
59253
59324
  return settled;
59254
59325
  }
59255
- 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;
59256
59327
  var init_pending_stage_intercom = __esm(() => {
59257
59328
  init_execution_context_boundary();
59258
59329
  init_run_owner_backend();
59259
59330
  init_store_backend();
59331
+ init_session_closed_error();
59260
59332
  init_external_run_routes();
59261
59333
  init_intercom_group();
59262
59334
  init_pending_stage_route_capability();
@@ -61749,7 +61821,7 @@ function isInfrastructureError(value2) {
61749
61821
  }
61750
61822
  function isRetryableWorkflowError(error) {
61751
61823
  let current = error;
61752
- for (let depth = 0;depth < MAX_CAUSE_DEPTH && current !== undefined && current !== null; depth++) {
61824
+ for (let depth = 0;depth < MAX_CAUSE_DEPTH2 && current !== undefined && current !== null; depth++) {
61753
61825
  if (isInfrastructureError(current))
61754
61826
  return true;
61755
61827
  current = current instanceof Error ? current.cause : undefined;
@@ -61767,7 +61839,7 @@ function asWorkflowInfrastructureError(error) {
61767
61839
  const code = workflowInfrastructureFault(error.message);
61768
61840
  return code === undefined ? undefined : new WorkflowInfrastructureError(code, error.message, { cause: error });
61769
61841
  }
61770
- var WORKFLOW_INFRASTRUCTURE_ERROR_NAME = "WorkflowInfrastructureError", MAX_CAUSE_DEPTH = 8, FAULT_PATTERNS, WorkflowInfrastructureError;
61842
+ var WORKFLOW_INFRASTRUCTURE_ERROR_NAME = "WorkflowInfrastructureError", MAX_CAUSE_DEPTH2 = 8, FAULT_PATTERNS, WorkflowInfrastructureError;
61771
61843
  var init_workflow_infrastructure_error = __esm(() => {
61772
61844
  FAULT_PATTERNS = [
61773
61845
  [/Local worker (?:process )?cleanup (?:was not confirmed|unconfirmed)/, "worker_cleanup_unconfirmed"],
@@ -64956,7 +65028,7 @@ function describeErrorWithCauses(error) {
64956
65028
  const messages = [];
64957
65029
  const visited = new Set;
64958
65030
  let current = error;
64959
- for (let depth = 0;current !== undefined && depth < MAX_CAUSE_DEPTH2 && !visited.has(current); depth++) {
65031
+ for (let depth = 0;current !== undefined && depth < MAX_CAUSE_DEPTH3 && !visited.has(current); depth++) {
64960
65032
  visited.add(current);
64961
65033
  const message = current instanceof Error ? current.message : String(current);
64962
65034
  if (!messages.includes(message))
@@ -64965,7 +65037,7 @@ function describeErrorWithCauses(error) {
64965
65037
  }
64966
65038
  return messages.join(": ");
64967
65039
  }
64968
- var MAX_CAUSE_DEPTH2 = 5;
65040
+ var MAX_CAUSE_DEPTH3 = 5;
64969
65041
 
64970
65042
  // dist/builtin/workflows/src/shared/returned-run-status.ts
64971
65043
  function normalizeReturnedWorkflowStatus(status) {
@@ -66490,7 +66562,7 @@ function recordedOwners(boundary, reason) {
66490
66562
  const pending = [{ value: reason, depth: 0 }];
66491
66563
  while (pending.length > 0) {
66492
66564
  const { value: value2, depth } = pending.pop();
66493
- if (depth > MAX_CAUSE_DEPTH3)
66565
+ if (depth > MAX_CAUSE_DEPTH4)
66494
66566
  continue;
66495
66567
  if (isPrimitive(value2)) {
66496
66568
  if (depth === 0 || value2 !== undefined && value2 !== null) {
@@ -66812,7 +66884,7 @@ function containUiRejections(ui, scope) {
66812
66884
  custom: (factory, options) => scope.watch(ui.custom(factory, options))
66813
66885
  };
66814
66886
  }
66815
- var EVENT = "unhandledRejection", BOUNDARY_KEY, FLAG = "--unhandled-rejections", MAX_CAUSE_DEPTH3 = 8, MAX_PRIMITIVES_PER_RUN = 64, MAX_STOP_STRINGS = 64, ENDED_RUN_GRACE_MS = 30000, NATIVE_REPORTING_MODES, WATCHED_STAGE_METHODS;
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;
66816
66888
  var init_run_rejection_boundary = __esm(() => {
66817
66889
  init_prompt_callsite();
66818
66890
  init_workflow_source();
@@ -72703,27 +72775,6 @@ var init_runtime = __esm(() => {
72703
72775
  init_intercom_group();
72704
72776
  });
72705
72777
 
72706
- // dist/builtin/workflows/src/engine/session-closed-error.ts
72707
- import { isStaleExtensionContextError as isStaleExtensionContextError2 } from "@bastani/atomic";
72708
- function reportsClosedSession(error) {
72709
- return "code" in error && error.code === "SessionClosed" || isStaleExtensionContextError2(error);
72710
- }
72711
- function isSessionClosedError(error) {
72712
- let current = error;
72713
- for (let depth = 0;depth < MAX_CAUSE_DEPTH4 && current !== undefined; depth++) {
72714
- try {
72715
- if (reportsClosedSession(current))
72716
- return true;
72717
- current = current.cause instanceof Error ? current.cause : undefined;
72718
- } catch {
72719
- return false;
72720
- }
72721
- }
72722
- return false;
72723
- }
72724
- var MAX_CAUSE_DEPTH4 = 8;
72725
- var init_session_closed_error = () => {};
72726
-
72727
72778
  // dist/builtin/workflows/src/engine/workflow-activity.ts
72728
72779
  import { runCallback as runCallback4 } from "@bastani/atomic";
72729
72780
  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) => routeCompletions.get(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
- const unsubscribeStore = activeStore.subscribeInvalidation(announceRoutes);
57996
- announceRoutes();
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
- announceRoutes();
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: announceRoutes
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 < MAX_CAUSE_DEPTH && current !== undefined && current !== null; 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", MAX_CAUSE_DEPTH = 8, FAULT_PATTERNS, 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 < MAX_CAUSE_DEPTH2 && !visited.has(current); 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 MAX_CAUSE_DEPTH2 = 5;
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 > MAX_CAUSE_DEPTH3)
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", MAX_CAUSE_DEPTH3 = 8, MAX_PRIMITIVES_PER_RUN = 64, MAX_STOP_STRINGS = 64, ENDED_RUN_GRACE_MS = 30000, NATIVE_REPORTING_MODES, WATCHED_STAGE_METHODS;
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() {
@@ -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
- constructor(descriptor: StorageDescriptor, cause: StorageFailureCause);
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,YAAY;IACxD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,SAAiB,KAAK,EAAE,mBAAmB,CAAC;IAC5C,YAAY,UAAU,EAAE,iBAAiB,EAAE,KAAK,EAAE,mBAAmB,EAIpE;CACD;AAED,qBAAa,gBAAiB,SAAQ,YAAY;IACjD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,YAAY,UAAU,EAAE,iBAAiB,EAIxC;CACD;AAED,qBAAa,6BAA8B,SAAQ,YAAY;IAC9D,cAEC;CACD;AAED,qBAAa,oBAAqB,SAAQ,YAAY;IACrD,SAAiB,KAAK,EAAE,mBAAmB,CAAC;IAC5C,QAAQ,CAAC,aAAa,EAAE,mBAAmB,CAAC;IAC5C,YAAY,KAAK,EAAE,mBAAmB,EAAE,aAAa,EAAE,mBAAmB,EAGzE;CACD;AAED,qBAAa,uBAAwB,SAAQ,YAAY;IACxD,QAAQ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,EAAE,MAAM,EAAE,KAAK,EAAE,mBAAmB,EAGrD;CACD;AAED,qBAAa,0BAA2B,SAAQ,YAAY;IAC3D,QAAQ,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
- constructor(descriptor, cause) {
11
- super(`Storage unavailable: ${descriptor.adapter} at ${descriptor.location}`, { cause });
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,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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\tconstructor(descriptor: StorageDescriptor, cause: StorageFailureCause) {\n\t\tsuper(`Storage unavailable: ${descriptor.adapter} at ${descriptor.location}`, { cause });\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
+ {"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,CAAS;IAChB,QAAQ,CAAS;IAE1B;;;OAGG;IACH,YAAY,UAA6B,EAAE,KAA0B,EAAE,MAAe;QACrF,KAAK,CAAC,wBAAwB,UAAU,CAAC,OAAO,OAAO,UAAU,CAAC,QAAQ,GAAG,MAAM,CAAC,CAAC,CAAC,KAAK,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE;YAC3G,KAAK;SACL,CAAC,CAAC;QACH,IAAI,CAAC,OAAO,GAAG,UAAU,CAAC,OAAO,CAAC;QAClC,IAAI,CAAC,QAAQ,GAAG,UAAU,CAAC,QAAQ,CAAC;IACrC,CAAC;CACD;AAED,MAAM,OAAO,gBAAiB,SAAQ,YAAY;IACxC,OAAO,CAAS;IAChB,QAAQ,CAAS;IAC1B,YAAY,UAA6B;QACxC,KAAK,CAAC,mBAAmB,UAAU,CAAC,OAAO,OAAO,UAAU,CAAC,QAAQ,EAAE,CAAC,CAAC;QACzE,IAAI,CAAC,OAAO,GAAG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AM,OAAO,kBAAmB,SAAQ,YAAY;IAC1C,MAAM,CAAqC;IAC3C,KAAK,CAAS;IACd,MAAM,CAAS;IACxB,YAAY,MAA0C,EAAE,KAAa,EAAE,MAAc;QACpF,KAAK,CAAC,kCAAkC,KAAK,KAAK,MAAM,GAAG,CAAC,CAAC;QAC7D,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;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;AAuM/G,wBAAsB,sBAAsB,CAC3C,IAAI,EAAE,MAAM,EACZ,EAAE,aAAoB,EAAE,QAAgB,EAAE,GAAE;IAAE,aAAa,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAO,GAC7F,OAAO,CAAC,cAAc,CAAC,CA2BzB;AAED,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,YAAY,GAAG,cAAc,CAW/E"}
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"}