@agimon-ai/doompi-workflow 0.0.1-alpha.95 → 0.0.1-alpha.97

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.
@@ -1 +1 @@
1
- {"version":3,"file":"pi.d.mts","names":[],"sources":["../../src/tui/workflowRuntime.ts","../../generated/pi.ts"],"mappings":";;;;;;;;;KA+ZY,iBACV,iBACA,yBACA;EAAW;EAAa,KAAK,OAAO;MACjC;UAEY;;WAEN,aAAa,SAAS;;EAE/B,SAAS;EACT;EACA;;EAEA;;EAEA,gBAAgB;EAChB,uBAAuB;;EAEvB;EACA,cAAc,GAAG,iBAAiB,MAAM;;EAExC,gBAAgB;EAChB;EACA;;;;qBClZW,+DAAS,mBAAA,QAAT"}
1
+ {"version":3,"file":"pi.d.mts","names":[],"sources":["../../src/tui/workflowRuntime.ts","../../generated/pi.ts"],"mappings":";;;;;;;;;KAsbY,iBACV,iBACA,yBACA;EAAW;EAAa,KAAK,OAAO;MACjC;UAEY;;WAEN,aAAa,SAAS;;EAE/B,SAAS;EACT;EACA;;EAEA;;EAEA,gBAAgB;EAChB,uBAAuB;;EAEvB;EACA,cAAc,GAAG,iBAAiB,MAAM;;EAExC,gBAAgB;EAChB;EACA;;;;qBCzaW,+DAAS,mBAAA,QAAT"}
@@ -3317,6 +3317,27 @@ const ERROR_COLOUR = "error";
3317
3317
  * user in a session that will not close.
3318
3318
  */
3319
3319
  const SHUTDOWN_FINALIZE_TIMEOUT_MS = 1e4;
3320
+ /**
3321
+ * Pi awaits extension disposal before it exits the process, so any unbounded
3322
+ * wait in dispose keeps an `--auto-stop` session alive after it asked to stop.
3323
+ */
3324
+ const SHUTDOWN_STEP_TIMEOUT_MS = 5e3;
3325
+ /**
3326
+ * Rejects as soon as the signal aborts, so a registry read that never answers
3327
+ * cannot hold the readiness task, and every disposal waiting on it, open.
3328
+ */
3329
+ function untilAborted(work, signal) {
3330
+ if (signal.aborted) return Promise.reject(signal.reason);
3331
+ return new Promise((resolveWork, rejectWork) => {
3332
+ const onAbort = () => rejectWork(signal.reason);
3333
+ signal.addEventListener("abort", onAbort, { once: true });
3334
+ work.then(resolveWork, rejectWork).finally(() => signal.removeEventListener("abort", onAbort));
3335
+ });
3336
+ }
3337
+ /** Resolves when the work does or the timeout passes; a rejection still propagates. */
3338
+ async function withinTimeout(work, timeoutMs) {
3339
+ await Promise.race([work, new Promise((settle) => setTimeout(settle, timeoutMs).unref?.())]);
3340
+ }
3320
3341
  const FOLLOW_INTERVAL_MS = 2e3;
3321
3342
  const TAIL_LINES = 24;
3322
3343
  /** Below these a resized run has no room left to draw, so it keeps its own size and the panel clips. */
@@ -4935,10 +4956,10 @@ function createWorkflowPiRuntime(pi, options) {
4935
4956
  const retired = () => ownReadinessAbort.signal.aborted || !ownsSession();
4936
4957
  signal.throwIfAborted();
4937
4958
  if (retired()) return { value: void 0 };
4938
- await startRunControl(ctx);
4959
+ await untilAborted(startRunControl(ctx), signal);
4939
4960
  signal.throwIfAborted();
4940
4961
  if (retired()) return { value: void 0 };
4941
- await refreshStatus(ctx, false);
4962
+ await untilAborted(refreshStatus(ctx, false), signal);
4942
4963
  signal.throwIfAborted();
4943
4964
  if (retired()) return { value: void 0 };
4944
4965
  lifecycleNarrationReady = true;
@@ -4972,13 +4993,13 @@ function createWorkflowPiRuntime(pi, options) {
4972
4993
  const ownedReadiness = standaloneReadiness;
4973
4994
  standaloneReadiness = void 0;
4974
4995
  if (ownedReadiness) await runCleanup("dispose standalone workflow readiness", () => ownedReadiness.dispose());
4975
- else if (pendingReadiness) await Promise.allSettled([pendingReadiness.then((handle) => handle.wait())]);
4996
+ else if (pendingReadiness) await withinTimeout(Promise.allSettled([pendingReadiness.then((handle) => handle.wait())]), SHUTDOWN_STEP_TIMEOUT_MS);
4976
4997
  if (pendingInlineRuns.size > 0) {
4977
4998
  for (const service of [runService, recoverService]) await runCleanup("interrupt an inline workflow", () => service.interrupt("SIGTERM", {
4978
4999
  phase: "workflow",
4979
5000
  source: "pi-session-shutdown"
4980
5001
  }));
4981
- await Promise.race([Promise.allSettled(pendingInlineRuns), new Promise((settle) => setTimeout(settle, SHUTDOWN_FINALIZE_TIMEOUT_MS).unref?.())]);
5002
+ await withinTimeout(Promise.allSettled(pendingInlineRuns), SHUTDOWN_FINALIZE_TIMEOUT_MS);
4982
5003
  }
4983
5004
  if (monitorTimer) clearInterval(monitorTimer);
4984
5005
  monitorTimer = void 0;
@@ -5013,13 +5034,13 @@ function createWorkflowPiRuntime(pi, options) {
5013
5034
  const pendingCount = pendingInlineRuns.size;
5014
5035
  const activeTelemetry = telemetry;
5015
5036
  telemetry = void 0;
5016
- if (activeTelemetry) {
5037
+ if (activeTelemetry) await runCleanup("stop workflow telemetry", () => withinTimeout((async () => {
5017
5038
  await runCleanup("record the workflow session finish", () => activeTelemetry.recordEvent("doom_workflow.session_finished", {
5018
5039
  "workflow.pending_count": pendingCount,
5019
5040
  outcome: pendingCount === 0 ? "completed" : "interrupted"
5020
5041
  }));
5021
- await runCleanup("stop workflow telemetry", () => activeTelemetry.shutdown());
5022
- }
5042
+ await activeTelemetry.shutdown();
5043
+ })(), SHUTDOWN_STEP_TIMEOUT_MS));
5023
5044
  pendingInlineRuns.clear();
5024
5045
  pendingTerminalRuns.clear();
5025
5046
  deliveredTerminalRuns.clear();