pi-subagents 0.73.1 → 0.75.0
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 +100 -0
- package/README.md +1 -1
- package/docs/agents.md +30 -16
- package/docs/configuration.md +76 -9
- package/docs/extension-api.md +6 -5
- package/docs/missions.md +28 -14
- package/docs/models.md +8 -4
- package/docs/observability.md +10 -5
- package/docs/tool-reference.md +90 -88
- package/docs/workflows.md +166 -172
- package/package.json +2 -2
- package/prompts/review-loop.md +1 -1
- package/skills/council-mode/SKILL.md +1 -1
- package/skills/pi-subagents/SKILL.md +12 -5
- package/skills/pi-subagents/references/constraints-and-recipes.md +3 -3
- package/skills/pi-subagents/references/execution-controls.md +68 -67
- package/skills/pi-subagents/references/management-authoring-rpc.md +2 -2
- package/skills/pi-subagents/references/multi-lane-orchestration.md +1 -1
- package/skills/pi-subagents/references/prompting-and-roles.md +45 -48
- package/src/agents/agent-management.js +2 -2
- package/src/agents/agent-management.js.map +1 -1
- package/src/agents/agents.d.ts +2 -0
- package/src/agents/agents.d.ts.map +1 -1
- package/src/agents/agents.js +73 -3
- package/src/agents/agents.js.map +1 -1
- package/src/api/preflight.d.ts +6 -2
- package/src/api/preflight.d.ts.map +1 -1
- package/src/api/preflight.js +46 -2
- package/src/api/preflight.js.map +1 -1
- package/src/extension/config.d.ts.map +1 -1
- package/src/extension/config.js +15 -4
- package/src/extension/config.js.map +1 -1
- package/src/extension/control-notices.d.ts +2 -0
- package/src/extension/control-notices.d.ts.map +1 -1
- package/src/extension/control-notices.js +2 -0
- package/src/extension/control-notices.js.map +1 -1
- package/src/extension/doctor.d.ts.map +1 -1
- package/src/extension/doctor.js +1 -0
- package/src/extension/doctor.js.map +1 -1
- package/src/extension/fanout-child.d.ts.map +1 -1
- package/src/extension/fanout-child.js +13 -3
- package/src/extension/fanout-child.js.map +1 -1
- package/src/extension/herdr-pi-bridge.d.ts.map +1 -1
- package/src/extension/herdr-pi-bridge.js +2 -0
- package/src/extension/herdr-pi-bridge.js.map +1 -1
- package/src/extension/index.d.ts +1 -1
- package/src/extension/index.d.ts.map +1 -1
- package/src/extension/index.js +87 -179
- package/src/extension/index.js.map +1 -1
- package/src/extension/public-execution.d.ts +10 -1
- package/src/extension/public-execution.d.ts.map +1 -1
- package/src/extension/public-execution.js +73 -35
- package/src/extension/public-execution.js.map +1 -1
- package/src/extension/reply-workflow-script.d.ts +12 -0
- package/src/extension/reply-workflow-script.d.ts.map +1 -0
- package/src/extension/reply-workflow-script.js +61 -0
- package/src/extension/reply-workflow-script.js.map +1 -0
- package/src/extension/rpc.d.ts +2 -0
- package/src/extension/rpc.d.ts.map +1 -1
- package/src/extension/rpc.js +33 -10
- package/src/extension/rpc.js.map +1 -1
- package/src/extension/schemas.d.ts +4 -117
- package/src/extension/schemas.d.ts.map +1 -1
- package/src/extension/schemas.js +42 -127
- package/src/extension/schemas.js.map +1 -1
- package/src/extension/tool-activation.d.ts +2 -4
- package/src/extension/tool-activation.d.ts.map +1 -1
- package/src/extension/tool-activation.js +54 -104
- package/src/extension/tool-activation.js.map +1 -1
- package/src/extension/tool-description.d.ts +8 -5
- package/src/extension/tool-description.d.ts.map +1 -1
- package/src/extension/tool-description.js +51 -27
- package/src/extension/tool-description.js.map +1 -1
- package/src/extension/upgrade-notice.d.ts +7 -0
- package/src/extension/upgrade-notice.d.ts.map +1 -0
- package/src/extension/upgrade-notice.js +37 -0
- package/src/extension/upgrade-notice.js.map +1 -0
- package/src/integrations/herdr-status.d.ts +3 -0
- package/src/integrations/herdr-status.d.ts.map +1 -1
- package/src/integrations/herdr-status.js +17 -3
- package/src/integrations/herdr-status.js.map +1 -1
- package/src/intercom/native-supervisor-channel.d.ts.map +1 -1
- package/src/intercom/native-supervisor-channel.js +4 -1
- package/src/intercom/native-supervisor-channel.js.map +1 -1
- package/src/missions/goal-driver.d.ts +1 -0
- package/src/missions/goal-driver.d.ts.map +1 -1
- package/src/missions/goal-driver.js +49 -34
- package/src/missions/goal-driver.js.map +1 -1
- package/src/missions/store.d.ts.map +1 -1
- package/src/missions/store.js +11 -1
- package/src/missions/store.js.map +1 -1
- package/src/profiles/profiles.d.ts +1 -1
- package/src/profiles/profiles.d.ts.map +1 -1
- package/src/profiles/profiles.js +4 -0
- package/src/profiles/profiles.js.map +1 -1
- package/src/runs/background/async-execution.d.ts +16 -0
- package/src/runs/background/async-execution.d.ts.map +1 -1
- package/src/runs/background/async-execution.js +95 -8
- package/src/runs/background/async-execution.js.map +1 -1
- package/src/runs/background/async-job-tracker.d.ts +1 -0
- package/src/runs/background/async-job-tracker.d.ts.map +1 -1
- package/src/runs/background/async-job-tracker.js +67 -24
- package/src/runs/background/async-job-tracker.js.map +1 -1
- package/src/runs/background/async-retention.d.ts +1 -1
- package/src/runs/background/async-retention.d.ts.map +1 -1
- package/src/runs/background/async-retention.js +47 -15
- package/src/runs/background/async-retention.js.map +1 -1
- package/src/runs/background/await-async-run.d.ts +23 -0
- package/src/runs/background/await-async-run.d.ts.map +1 -0
- package/src/runs/background/await-async-run.js +82 -0
- package/src/runs/background/await-async-run.js.map +1 -0
- package/src/runs/background/chain-root-attachment.d.ts +1 -0
- package/src/runs/background/chain-root-attachment.d.ts.map +1 -1
- package/src/runs/background/chain-root-attachment.js +3 -3
- package/src/runs/background/chain-root-attachment.js.map +1 -1
- package/src/runs/background/control-channel.d.ts +10 -0
- package/src/runs/background/control-channel.d.ts.map +1 -1
- package/src/runs/background/control-channel.js +51 -0
- package/src/runs/background/control-channel.js.map +1 -1
- package/src/runs/background/notify.d.ts +3 -0
- package/src/runs/background/notify.d.ts.map +1 -1
- package/src/runs/background/notify.js +3 -0
- package/src/runs/background/notify.js.map +1 -1
- package/src/runs/background/run-child-session.d.ts.map +1 -1
- package/src/runs/background/run-child-session.js +24 -7
- package/src/runs/background/run-child-session.js.map +1 -1
- package/src/runs/background/run-status.d.ts.map +1 -1
- package/src/runs/background/run-status.js +6 -0
- package/src/runs/background/run-status.js.map +1 -1
- package/src/runs/background/runner-aliases.d.ts +1 -0
- package/src/runs/background/runner-aliases.d.ts.map +1 -1
- package/src/runs/background/runner-aliases.js +6 -2
- package/src/runs/background/runner-aliases.js.map +1 -1
- package/src/runs/background/runner-child-launch.d.ts +1 -0
- package/src/runs/background/runner-child-launch.d.ts.map +1 -1
- package/src/runs/background/runner-child-launch.js +2 -0
- package/src/runs/background/runner-child-launch.js.map +1 -1
- package/src/runs/background/scheduled-runs.d.ts +2 -1
- package/src/runs/background/scheduled-runs.d.ts.map +1 -1
- package/src/runs/background/scheduled-runs.js +33 -16
- package/src/runs/background/scheduled-runs.js.map +1 -1
- package/src/runs/background/stale-run-reconciler.d.ts +1 -1
- package/src/runs/background/stale-run-reconciler.d.ts.map +1 -1
- package/src/runs/background/stale-run-reconciler.js +15 -2
- package/src/runs/background/stale-run-reconciler.js.map +1 -1
- package/src/runs/background/subagent-runner.d.ts +3 -0
- package/src/runs/background/subagent-runner.d.ts.map +1 -1
- package/src/runs/background/subagent-runner.js +49 -3
- package/src/runs/background/subagent-runner.js.map +1 -1
- package/src/runs/foreground/async-stop-action.d.ts.map +1 -1
- package/src/runs/foreground/async-stop-action.js +15 -1
- package/src/runs/foreground/async-stop-action.js.map +1 -1
- package/src/runs/foreground/command-action.d.ts +13 -0
- package/src/runs/foreground/command-action.d.ts.map +1 -0
- package/src/runs/foreground/command-action.js +38 -0
- package/src/runs/foreground/command-action.js.map +1 -0
- package/src/runs/foreground/execution.d.ts.map +1 -1
- package/src/runs/foreground/execution.js +27 -6
- package/src/runs/foreground/execution.js.map +1 -1
- package/src/runs/foreground/subagent-executor.d.ts +7 -5
- package/src/runs/foreground/subagent-executor.d.ts.map +1 -1
- package/src/runs/foreground/subagent-executor.js +356 -192
- package/src/runs/foreground/subagent-executor.js.map +1 -1
- package/src/runs/shared/child-commands.d.ts +28 -0
- package/src/runs/shared/child-commands.d.ts.map +1 -0
- package/src/runs/shared/child-commands.js +250 -0
- package/src/runs/shared/child-commands.js.map +1 -0
- package/src/runs/shared/child-launch.d.ts +5 -1
- package/src/runs/shared/child-launch.d.ts.map +1 -1
- package/src/runs/shared/child-launch.js +15 -1
- package/src/runs/shared/child-launch.js.map +1 -1
- package/src/runs/shared/child-session.d.ts +13 -0
- package/src/runs/shared/child-session.d.ts.map +1 -1
- package/src/runs/shared/child-session.js +182 -19
- package/src/runs/shared/child-session.js.map +1 -1
- package/src/runs/shared/child-tool-plan.d.ts +4 -0
- package/src/runs/shared/child-tool-plan.d.ts.map +1 -1
- package/src/runs/shared/child-tool-plan.js +12 -5
- package/src/runs/shared/child-tool-plan.js.map +1 -1
- package/src/runs/shared/claude-code-adapter.d.ts +56 -0
- package/src/runs/shared/claude-code-adapter.d.ts.map +1 -1
- package/src/runs/shared/claude-code-adapter.js +138 -2
- package/src/runs/shared/claude-code-adapter.js.map +1 -1
- package/src/runs/shared/dynamic-fanout.js +2 -2
- package/src/runs/shared/dynamic-fanout.js.map +1 -1
- package/src/runs/shared/external-cli-preflight.d.ts +10 -0
- package/src/runs/shared/external-cli-preflight.d.ts.map +1 -1
- package/src/runs/shared/external-cli-preflight.js +50 -6
- package/src/runs/shared/external-cli-preflight.js.map +1 -1
- package/src/runs/shared/external-cli-runner.d.ts.map +1 -1
- package/src/runs/shared/external-cli-runner.js +4 -2
- package/src/runs/shared/external-cli-runner.js.map +1 -1
- package/src/runs/shared/mcp-config-sources.d.ts +1 -0
- package/src/runs/shared/mcp-config-sources.d.ts.map +1 -1
- package/src/runs/shared/mcp-config-sources.js +1 -1
- package/src/runs/shared/mcp-config-sources.js.map +1 -1
- package/src/runs/shared/mcp-direct-tool-allowlist.d.ts +28 -0
- package/src/runs/shared/mcp-direct-tool-allowlist.d.ts.map +1 -1
- package/src/runs/shared/mcp-direct-tool-allowlist.js +79 -2
- package/src/runs/shared/mcp-direct-tool-allowlist.js.map +1 -1
- package/src/runs/shared/model-resolution.d.ts +16 -2
- package/src/runs/shared/model-resolution.d.ts.map +1 -1
- package/src/runs/shared/model-resolution.js +39 -11
- package/src/runs/shared/model-resolution.js.map +1 -1
- package/src/runs/shared/model-scope.d.ts +2 -1
- package/src/runs/shared/model-scope.d.ts.map +1 -1
- package/src/runs/shared/model-scope.js +26 -10
- package/src/runs/shared/model-scope.js.map +1 -1
- package/src/runs/shared/parallel-utils.d.ts +4 -0
- package/src/runs/shared/parallel-utils.d.ts.map +1 -1
- package/src/runs/shared/parallel-utils.js.map +1 -1
- package/src/runs/shared/pi-spawn.d.ts +1 -10
- package/src/runs/shared/pi-spawn.d.ts.map +1 -1
- package/src/runs/shared/pi-spawn.js +7 -86
- package/src/runs/shared/pi-spawn.js.map +1 -1
- package/src/runs/shared/run-history.d.ts +47 -0
- package/src/runs/shared/run-history.d.ts.map +1 -1
- package/src/runs/shared/run-history.js +70 -0
- package/src/runs/shared/run-history.js.map +1 -1
- package/src/runs/shared/subagent-control.d.ts.map +1 -1
- package/src/runs/shared/subagent-control.js +30 -17
- package/src/runs/shared/subagent-control.js.map +1 -1
- package/src/runs/shared/subagent-prompt-runtime.d.ts +1 -0
- package/src/runs/shared/subagent-prompt-runtime.d.ts.map +1 -1
- package/src/runs/shared/subagent-prompt-runtime.js +14 -5
- package/src/runs/shared/subagent-prompt-runtime.js.map +1 -1
- package/src/runs/shared/worktree.d.ts +1 -1
- package/src/runs/shared/worktree.d.ts.map +1 -1
- package/src/runs/shared/worktree.js +1 -1
- package/src/runs/shared/worktree.js.map +1 -1
- package/src/shared/disabled-features.d.ts +92 -0
- package/src/shared/disabled-features.d.ts.map +1 -0
- package/src/shared/disabled-features.js +113 -0
- package/src/shared/disabled-features.js.map +1 -0
- package/src/shared/extension-context.d.ts +9 -0
- package/src/shared/extension-context.d.ts.map +1 -1
- package/src/shared/extension-context.js +7 -0
- package/src/shared/extension-context.js.map +1 -1
- package/src/shared/required-child-extensions.d.ts +16 -1
- package/src/shared/required-child-extensions.d.ts.map +1 -1
- package/src/shared/required-child-extensions.js +37 -5
- package/src/shared/required-child-extensions.js.map +1 -1
- package/src/shared/settings.d.ts +1 -1
- package/src/shared/types.d.ts +26 -1
- package/src/shared/types.d.ts.map +1 -1
- package/src/shared/types.js +1 -1
- package/src/shared/types.js.map +1 -1
- package/src/slash/prompt-template-bridge.js +2 -2
- package/src/slash/prompt-template-bridge.js.map +1 -1
- package/src/slash/slash-commands.d.ts +2 -0
- package/src/slash/slash-commands.d.ts.map +1 -1
- package/src/slash/slash-commands.js +2 -2
- package/src/slash/slash-commands.js.map +1 -1
- package/src/slash/subagent-cost.d.ts.map +1 -1
- package/src/slash/subagent-cost.js +8 -4
- package/src/slash/subagent-cost.js.map +1 -1
- package/src/tui/render.d.ts +1 -1
- package/src/tui/render.d.ts.map +1 -1
- package/src/tui/render.js +59 -21
- package/src/tui/render.js.map +1 -1
- package/src/watchdog/diff-tool.d.ts +3 -1
- package/src/watchdog/diff-tool.d.ts.map +1 -1
- package/src/watchdog/diff-tool.js +20 -11
- package/src/watchdog/diff-tool.js.map +1 -1
- package/src/watchdog/register-child.js +2 -2
- package/src/watchdog/register-child.js.map +1 -1
- package/src/watchdog/register-main.js +2 -2
- package/src/watchdog/register-main.js.map +1 -1
- package/src/watchdog/review.d.ts +1 -1
- package/src/watchdog/review.d.ts.map +1 -1
- package/src/watchdog/review.js +1 -1
- package/src/watchdog/review.js.map +1 -1
- package/src/watchdog/turn-delta.js +1 -1
- package/src/watchdog/turn-delta.js.map +1 -1
- package/src/workflows/chat-progress.js +2 -2
- package/src/workflows/chat-progress.js.map +1 -1
- package/src/workflows/scripted-workflow.d.ts +8 -0
- package/src/workflows/scripted-workflow.d.ts.map +1 -1
- package/src/workflows/scripted-workflow.js +10 -2
- package/src/workflows/scripted-workflow.js.map +1 -1
- package/src/workflows/structured-workflow-scripts.d.ts +10 -0
- package/src/workflows/structured-workflow-scripts.d.ts.map +1 -0
- package/src/workflows/structured-workflow-scripts.js +166 -0
- package/src/workflows/structured-workflow-scripts.js.map +1 -0
- package/src/workflows/workflow-receipt.d.ts.map +1 -1
- package/src/workflows/workflow-receipt.js +10 -4
- package/src/workflows/workflow-receipt.js.map +1 -1
- package/src/workflows/workflow-resources.d.ts +13 -0
- package/src/workflows/workflow-resources.d.ts.map +1 -1
- package/src/workflows/workflow-resources.js +46 -16
- package/src/workflows/workflow-resources.js.map +1 -1
- package/src/workflows/workflow-reuse.d.ts +51 -0
- package/src/workflows/workflow-reuse.d.ts.map +1 -0
- package/src/workflows/workflow-reuse.js +103 -0
- package/src/workflows/workflow-reuse.js.map +1 -0
- package/src/workflows/workflow-revival.d.ts +32 -0
- package/src/workflows/workflow-revival.d.ts.map +1 -0
- package/src/workflows/workflow-revival.js +111 -0
- package/src/workflows/workflow-revival.js.map +1 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { AsyncStatus } from "../shared/types.ts";
|
|
2
|
+
import type { WorkflowScriptChildResult } from "./scripted-workflow.ts";
|
|
3
|
+
/** The same link, kept in the revived run's directory so reviving it again keeps the key. */
|
|
4
|
+
export declare const REVIVAL_ORIGIN_FILE = "workflow-revival-origin.json";
|
|
5
|
+
export interface WorkflowKeyRevival {
|
|
6
|
+
/** Revived runs after the given run, oldest first. */
|
|
7
|
+
revivedRunIds: string[];
|
|
8
|
+
latestRunId: string;
|
|
9
|
+
/** State of the latest revived run; undefined when its status is unreadable. */
|
|
10
|
+
state?: AsyncStatus["state"];
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Links a detached revival to the workflow key of its source run when the source failed and is
|
|
14
|
+
* an async workflow child or an earlier revival of one. Throws when the source status cannot be
|
|
15
|
+
* read or the key's revival chain is full; the caller reports that on the revive receipt.
|
|
16
|
+
*/
|
|
17
|
+
export declare function recordWorkflowRevival(asyncDirRoot: string, sourceRunId: string, revivedRunId: string): void;
|
|
18
|
+
/**
|
|
19
|
+
* Follows revival links from one run of a workflow key by exact reads. Returns undefined when
|
|
20
|
+
* the run was never revived; malformed or mismatched links end the chain.
|
|
21
|
+
*/
|
|
22
|
+
export declare function projectWorkflowKeyRevival(asyncDirRoot: string, workflowRunId: string, workflowKey: string, runId: string): WorkflowKeyRevival | undefined;
|
|
23
|
+
/** `Revived → <run> [→ <run>]: <state>`, shown next to the key's original failure. */
|
|
24
|
+
export declare function formatWorkflowKeyRevival(revival: WorkflowKeyRevival): string;
|
|
25
|
+
/**
|
|
26
|
+
* Adds each failed child's revivals to its lineage, so the receipt's latest run for that key is
|
|
27
|
+
* the newest revival. The child's own result and evidence stay as they were.
|
|
28
|
+
*/
|
|
29
|
+
export declare function withWorkflowRevivals<T extends WorkflowScriptChildResult>(asyncDirRoot: string, workflowRunId: string, children: T[]): Array<T & {
|
|
30
|
+
revival?: WorkflowKeyRevival;
|
|
31
|
+
}>;
|
|
32
|
+
//# sourceMappingURL=workflow-revival.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflow-revival.d.ts","sourceRoot":"","sources":["../../../src/workflows/workflow-revival.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEtD,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AAQxE,6FAA6F;AAC7F,eAAO,MAAM,mBAAmB,iCAAiC,CAAC;AAelE,MAAM,WAAW,kBAAkB;IAClC,sDAAsD;IACtD,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,gFAAgF;IAChF,KAAK,CAAC,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;CAC7B;AAoBD;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,YAAY,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,IAAI,CAoB3G;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,kBAAkB,GAAG,SAAS,CAkBzJ;AAED,sFAAsF;AACtF,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,kBAAkB,GAAG,MAAM,CAE5E;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,SAAS,yBAAyB,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,EAAE,GAAG,KAAK,CAAC,CAAC,GAAG;IAAE,OAAO,CAAC,EAAE,kBAAkB,CAAA;CAAE,CAAC,CAOjL"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import * as fs from "node:fs";
|
|
2
|
+
import * as path from "node:path";
|
|
3
|
+
import { writePrivateAtomicJson } from "../shared/atomic-json.js";
|
|
4
|
+
import { readStatus } from "../shared/utils.js";
|
|
5
|
+
/**
|
|
6
|
+
* A top-level resume of a failed async workflow child starts a detached run. These records
|
|
7
|
+
* link that run back to its workflow key without writing the workflow's own status or receipt.
|
|
8
|
+
* The source run is terminal, so the live workflow host never writes its directory.
|
|
9
|
+
*/
|
|
10
|
+
const REVIVAL_LINK_FILE = "workflow-revival.json";
|
|
11
|
+
/** The same link, kept in the revived run's directory so reviving it again keeps the key. */
|
|
12
|
+
export const REVIVAL_ORIGIN_FILE = "workflow-revival-origin.json";
|
|
13
|
+
/** Recording refuses a deeper link, so readers bounded by this always reach the chain's end. */
|
|
14
|
+
const MAX_REVIVAL_DEPTH = 16;
|
|
15
|
+
const KEY_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;
|
|
16
|
+
function isRunId(value) {
|
|
17
|
+
return typeof value === "string" && value.length > 0 && value.length <= 255 && path.basename(value) === value && value !== "." && value !== "..";
|
|
18
|
+
}
|
|
19
|
+
function readLink(file) {
|
|
20
|
+
let value;
|
|
21
|
+
try {
|
|
22
|
+
value = JSON.parse(fs.readFileSync(file, "utf-8"));
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
28
|
+
return undefined;
|
|
29
|
+
const link = value;
|
|
30
|
+
if (link.version !== 1 || !isRunId(link.workflowRunId) || typeof link.workflowKey !== "string" || !KEY_PATTERN.test(link.workflowKey) || !isRunId(link.sourceRunId) || !isRunId(link.revivedRunId))
|
|
31
|
+
return undefined;
|
|
32
|
+
if (!Number.isInteger(link.depth) || link.depth < 1 || link.depth > MAX_REVIVAL_DEPTH)
|
|
33
|
+
return undefined;
|
|
34
|
+
return { version: 1, workflowRunId: link.workflowRunId, workflowKey: link.workflowKey, sourceRunId: link.sourceRunId, revivedRunId: link.revivedRunId, depth: link.depth };
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Links a detached revival to the workflow key of its source run when the source failed and is
|
|
38
|
+
* an async workflow child or an earlier revival of one. Throws when the source status cannot be
|
|
39
|
+
* read or the key's revival chain is full; the caller reports that on the revive receipt.
|
|
40
|
+
*/
|
|
41
|
+
export function recordWorkflowRevival(asyncDirRoot, sourceRunId, revivedRunId) {
|
|
42
|
+
const sourceDir = path.join(asyncDirRoot, sourceRunId);
|
|
43
|
+
const status = readStatus(sourceDir);
|
|
44
|
+
if (status?.runId !== sourceRunId || status.state !== "failed")
|
|
45
|
+
return;
|
|
46
|
+
const origin = isRunId(status.parentWorkflowRunId) && typeof status.workflowKey === "string" && KEY_PATTERN.test(status.workflowKey)
|
|
47
|
+
? { workflowRunId: status.parentWorkflowRunId, workflowKey: status.workflowKey, depth: 0 }
|
|
48
|
+
: readLink(path.join(sourceDir, REVIVAL_ORIGIN_FILE));
|
|
49
|
+
if (!origin || ("revivedRunId" in origin && origin.revivedRunId !== sourceRunId))
|
|
50
|
+
return;
|
|
51
|
+
if (origin.depth >= MAX_REVIVAL_DEPTH)
|
|
52
|
+
throw new Error(`workflow key '${origin.workflowKey}' of ${origin.workflowRunId} already has ${MAX_REVIVAL_DEPTH} chained revivals.`);
|
|
53
|
+
const link = { version: 1, workflowRunId: origin.workflowRunId, workflowKey: origin.workflowKey, sourceRunId, revivedRunId, depth: origin.depth + 1 };
|
|
54
|
+
const originFile = path.join(asyncDirRoot, revivedRunId, REVIVAL_ORIGIN_FILE);
|
|
55
|
+
writePrivateAtomicJson(originFile, link);
|
|
56
|
+
try {
|
|
57
|
+
writePrivateAtomicJson(path.join(sourceDir, REVIVAL_LINK_FILE), link);
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
// Keep the origin exactly when the published link names this revival: an unlinked origin
|
|
61
|
+
// would only pin the run against retention, and a linked one protects the key's chain.
|
|
62
|
+
if (readLink(path.join(sourceDir, REVIVAL_LINK_FILE))?.revivedRunId !== revivedRunId)
|
|
63
|
+
fs.rmSync(originFile, { force: true });
|
|
64
|
+
throw error;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Follows revival links from one run of a workflow key by exact reads. Returns undefined when
|
|
69
|
+
* the run was never revived; malformed or mismatched links end the chain.
|
|
70
|
+
*/
|
|
71
|
+
export function projectWorkflowKeyRevival(asyncDirRoot, workflowRunId, workflowKey, runId) {
|
|
72
|
+
if (!isRunId(runId))
|
|
73
|
+
return undefined;
|
|
74
|
+
const revivedRunIds = [];
|
|
75
|
+
let current = runId;
|
|
76
|
+
while (revivedRunIds.length < MAX_REVIVAL_DEPTH) {
|
|
77
|
+
const link = readLink(path.join(asyncDirRoot, current, REVIVAL_LINK_FILE));
|
|
78
|
+
if (!link || link.sourceRunId !== current || link.workflowRunId !== workflowRunId || link.workflowKey !== workflowKey)
|
|
79
|
+
break;
|
|
80
|
+
revivedRunIds.push(link.revivedRunId);
|
|
81
|
+
current = link.revivedRunId;
|
|
82
|
+
}
|
|
83
|
+
if (revivedRunIds.length === 0)
|
|
84
|
+
return undefined;
|
|
85
|
+
let status = null;
|
|
86
|
+
try {
|
|
87
|
+
status = readStatus(path.join(asyncDirRoot, current));
|
|
88
|
+
}
|
|
89
|
+
catch {
|
|
90
|
+
// Readers show "status unavailable" instead of failing the workflow's status or notice.
|
|
91
|
+
}
|
|
92
|
+
return { revivedRunIds, latestRunId: current, ...(status?.runId === current ? { state: status.state } : {}) };
|
|
93
|
+
}
|
|
94
|
+
/** `Revived → <run> [→ <run>]: <state>`, shown next to the key's original failure. */
|
|
95
|
+
export function formatWorkflowKeyRevival(revival) {
|
|
96
|
+
return `Revived → ${revival.revivedRunIds.join(" → ")}: ${revival.state === "complete" ? "completed" : revival.state ?? "status unavailable"}`;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Adds each failed child's revivals to its lineage, so the receipt's latest run for that key is
|
|
100
|
+
* the newest revival. The child's own result and evidence stay as they were.
|
|
101
|
+
*/
|
|
102
|
+
export function withWorkflowRevivals(asyncDirRoot, workflowRunId, children) {
|
|
103
|
+
return children.map((child) => {
|
|
104
|
+
if (child.ok || child.state === "running" || !child.runId)
|
|
105
|
+
return child;
|
|
106
|
+
const lineage = child.continuation?.runIds ?? [child.runId];
|
|
107
|
+
const revival = projectWorkflowKeyRevival(asyncDirRoot, workflowRunId, child.key, lineage.at(-1) ?? child.runId);
|
|
108
|
+
return revival ? { ...child, continuation: { runIds: [...lineage, ...revival.revivedRunIds] }, revival } : child;
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=workflow-revival.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflow-revival.js","sourceRoot":"","sources":["../../../src/workflows/workflow-revival.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAElE,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAGhD;;;;GAIG;AACH,MAAM,iBAAiB,GAAG,uBAAuB,CAAC;AAClD,6FAA6F;AAC7F,MAAM,CAAC,MAAM,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