@wrongstack/core 0.272.1 → 0.273.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/dist/{agent-bridge-DFQYEeXf.d.ts → agent-bridge-BZ2enORi.d.ts} +1 -1
- package/dist/{agent-subagent-runner-BZa_IEcd.d.ts → agent-subagent-runner-ehb4xGvd.d.ts} +11 -4
- package/dist/{brain-etbcbRwV.d.ts → brain-BxN2k2HP.d.ts} +101 -0
- package/dist/{config-rRS8yorV.d.ts → config-C8IYxlO8.d.ts} +8 -1
- package/dist/coordination/index.d.ts +13 -13
- package/dist/coordination/index.js +79 -25
- package/dist/coordination/index.js.map +1 -1
- package/dist/{default-config-B0cj-Hry.d.ts → default-config-BbX4ojZs.d.ts} +1 -0
- package/dist/defaults/index.d.ts +20 -19
- package/dist/defaults/index.js +2813 -206
- package/dist/defaults/index.js.map +1 -1
- package/dist/execution/index.d.ts +10 -10
- package/dist/execution/index.js +8 -2
- package/dist/execution/index.js.map +1 -1
- package/dist/extension/index.d.ts +4 -4
- package/dist/{global-mailbox-DJ4EoRr0.d.ts → global-mailbox-C9dsc9Y_.d.ts} +1 -1
- package/dist/{goal-preamble-hM8BH7TK.d.ts → goal-preamble-NhflDjYb.d.ts} +6 -6
- package/dist/{goal-store-CWlbT0TO.d.ts → goal-store-Cx363x7Z.d.ts} +1 -1
- package/dist/hq/index.d.ts +4 -4
- package/dist/hq/index.js +1 -0
- package/dist/hq/index.js.map +1 -1
- package/dist/{index-DWm_PE9L.d.ts → index-B7fHDt0B.d.ts} +12 -4
- package/dist/{index-2Lhk5v0o.d.ts → index-BbVprU-9.d.ts} +6 -0
- package/dist/index.d.ts +194 -33
- package/dist/index.js +3222 -681
- package/dist/index.js.map +1 -1
- package/dist/infrastructure/index.d.ts +4 -4
- package/dist/kernel/index.d.ts +94 -14
- package/dist/kernel/index.js.map +1 -1
- package/dist/{mcp-servers-BpWHTKlE.d.ts → mcp-servers-B6fSRNC1.d.ts} +1 -1
- package/dist/models/index.d.ts +3 -3
- package/dist/{models-registry-CXQFUn5t.d.ts → models-registry-4C6Wr91w.d.ts} +1 -1
- package/dist/{multi-agent-coordinator-jyimfo7D.d.ts → multi-agent-coordinator-q1skFeNP.d.ts} +1 -1
- package/dist/{null-fleet-bus-DOGQcvrY.d.ts → null-fleet-bus-C9rrgQwc.d.ts} +15 -5
- package/dist/observability/index.d.ts +1 -1
- package/dist/{parallel-eternal-engine-rItJBYp9.d.ts → parallel-eternal-engine-CtXly2Sf.d.ts} +7 -6
- package/dist/{path-resolver-DrpF5MGK.d.ts → path-resolver-Bim6G5Jz.d.ts} +2 -2
- package/dist/{pipeline-Ckkn3AOA.d.ts → pipeline-CNVKuQDQ.d.ts} +1 -1
- package/dist/{plan-templates-BvHw5Znw.d.ts → plan-templates-C4wXMmiM.d.ts} +3 -3
- package/dist/{provider-model-resolve-nZqnCeaR.d.ts → provider-model-resolve-DFd3IPpw.d.ts} +1 -1
- package/dist/{provider-runner-zVOn1p67.d.ts → provider-runner-BpM0mdBE.d.ts} +1 -1
- package/dist/sdd/index.d.ts +1111 -11
- package/dist/sdd/index.js +5516 -2949
- package/dist/sdd/index.js.map +1 -1
- package/dist/security/index.d.ts +1 -1
- package/dist/security/index.js +6 -0
- package/dist/security/index.js.map +1 -1
- package/dist/storage/index.d.ts +8 -8
- package/dist/storage/index.js +3 -2
- package/dist/storage/index.js.map +1 -1
- package/dist/tools/index.d.ts +1 -1
- package/dist/tools/index.js.map +1 -1
- package/dist/types/index.d.ts +14 -14
- package/dist/types/index.js +3 -0
- package/dist/types/index.js.map +1 -1
- package/dist/utils/index.d.ts +30 -4
- package/dist/utils/index.js +110 -1
- package/dist/utils/index.js.map +1 -1
- package/dist/{index-DqW4o62H.d.ts → worktree-manager-BDuXTaWL.d.ts} +48 -90
- package/dist/{wstack-paths-hOpNLmvf.d.ts → wstack-paths-BqkDAkoh.d.ts} +2 -0
- package/package.json +1 -1
package/dist/sdd/index.d.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { h as Specification, S as SpecAnalysis, g as SpecValidationResult, e as SpecStatus, f as SpecTemplate, b as SpecRequirement } from '../spec-TBi3Jr6T.js';
|
|
2
2
|
import { d as TaskGraph, e as TaskNode, i as TaskFilter, j as TaskSort, c as TaskProgress, T as TaskType, a as TaskPriority } from '../task-graph-u1q9Jkyk.js';
|
|
3
|
-
import { E as EventBus } from '../brain-
|
|
4
|
-
import { D as DoneCondition, g as Agent, h as AgentFactory, f as TaskResult } from '../agent-subagent-runner-
|
|
3
|
+
import { E as EventBus, B as BrainArbiter } from '../brain-BxN2k2HP.js';
|
|
4
|
+
import { D as DoneCondition, g as Agent, h as AgentFactory, f as TaskResult } from '../agent-subagent-runner-ehb4xGvd.js';
|
|
5
|
+
import { W as WorktreeManager } from '../worktree-manager-BDuXTaWL.js';
|
|
5
6
|
import '../context-Dw55zZ_Q.js';
|
|
6
|
-
import '../index-
|
|
7
|
+
import '../index-B7fHDt0B.js';
|
|
7
8
|
import '../logger-B63L5bTg.js';
|
|
8
|
-
import '../pipeline-
|
|
9
|
+
import '../pipeline-CNVKuQDQ.js';
|
|
9
10
|
import '../mailbox-types-Ct2hJq0P.js';
|
|
10
|
-
import '../config-
|
|
11
|
+
import '../config-C8IYxlO8.js';
|
|
11
12
|
import '../observability-D-HZN_mF.js';
|
|
12
13
|
import '../permission-CC7XFYWG.js';
|
|
13
14
|
import '../retry-policy-BV7nzeAd.js';
|
|
@@ -51,11 +52,28 @@ interface TaskTransition {
|
|
|
51
52
|
timestamp: number;
|
|
52
53
|
reason?: string | undefined;
|
|
53
54
|
}
|
|
55
|
+
/** A change notification emitted to `TaskTracker.subscribe` listeners. */
|
|
56
|
+
interface TaskTrackerChange {
|
|
57
|
+
type: 'node_added' | 'node_updated' | 'status_changed' | 'node_removed';
|
|
58
|
+
nodeId: string;
|
|
59
|
+
/** For `node_removed` this is the node as it was just before deletion. */
|
|
60
|
+
node: TaskNode;
|
|
61
|
+
transition?: TaskTransition | undefined;
|
|
62
|
+
}
|
|
63
|
+
type TaskTrackerListener = (change: TaskTrackerChange) => void;
|
|
54
64
|
declare class TaskTracker {
|
|
55
65
|
private readonly opts;
|
|
56
66
|
private graph;
|
|
57
67
|
private transitions;
|
|
68
|
+
private listeners;
|
|
58
69
|
constructor(opts: TaskTrackerOptions);
|
|
70
|
+
/**
|
|
71
|
+
* Subscribe to live task mutations (add / update / status change). Returns an
|
|
72
|
+
* unsubscribe fn. This is the hook the board projector uses to stream a live
|
|
73
|
+
* snapshot — the tracker was previously fire-and-forget with no observability.
|
|
74
|
+
*/
|
|
75
|
+
subscribe(listener: TaskTrackerListener): () => void;
|
|
76
|
+
private notifyChange;
|
|
59
77
|
/**
|
|
60
78
|
* Attach an existing graph (used by PhaseOrchestrator to associate a tracker
|
|
61
79
|
* with a phase's pre-built task graph without re-creating it).
|
|
@@ -65,8 +83,31 @@ declare class TaskTracker {
|
|
|
65
83
|
loadGraph(id: string): Promise<TaskGraph | null>;
|
|
66
84
|
addNode(node: Omit<TaskNode, 'id' | 'createdAt' | 'updatedAt'>): TaskNode;
|
|
67
85
|
addEdge(from: string, to: string, type?: TaskGraph['edges'][0]['type']): void;
|
|
86
|
+
/**
|
|
87
|
+
* Declare that `taskId` depends on `depId` (a `depends_on` edge `depId → taskId`),
|
|
88
|
+
* guarding against self-loops, duplicates, missing nodes, and cycles. Returns
|
|
89
|
+
* true if the dependency now holds (added or already present), false if it was
|
|
90
|
+
* rejected (would create a cycle / unknown node). This is the safe entry point
|
|
91
|
+
* for wiring agent-declared `dependsOn` references into the graph.
|
|
92
|
+
*/
|
|
93
|
+
addDependency(depId: string, taskId: string): boolean;
|
|
94
|
+
/** True when `taskId` transitively depends on `targetId` (follows depends_on blockers). */
|
|
95
|
+
private dependsOnTransitively;
|
|
96
|
+
/**
|
|
97
|
+
* Merge `patch` into a node's `metadata` (used for per-task model/provider/
|
|
98
|
+
* fallback assignment and the cancel marker). Persists + notifies as a node
|
|
99
|
+
* update. No-op if the node is missing.
|
|
100
|
+
*/
|
|
101
|
+
patchMetadata(id: string, patch: Record<string, unknown>): void;
|
|
102
|
+
/**
|
|
103
|
+
* Remove a node and every edge touching it. Intended for deleting a task that
|
|
104
|
+
* has not started yet — callers must gate on status (do not remove a running
|
|
105
|
+
* task). Dependents simply lose this blocker (re-evaluated by `canStart`).
|
|
106
|
+
* Returns true if a node was removed.
|
|
107
|
+
*/
|
|
108
|
+
removeNode(id: string): boolean;
|
|
68
109
|
updateNodeStatus(id: string, status: TaskNode['status'], reason?: string): void;
|
|
69
|
-
updateNode(id: string, patch: Partial<Pick<TaskNode, 'title' | 'description' | 'priority' | 'estimateHours' | 'tags'>>): void;
|
|
110
|
+
updateNode(id: string, patch: Partial<Pick<TaskNode, 'title' | 'description' | 'priority' | 'estimateHours' | 'tags' | 'assignee'>>): void;
|
|
70
111
|
getNode(id: string): TaskNode | undefined;
|
|
71
112
|
getAllNodes(filter?: TaskFilter, sort?: TaskSort): TaskNode[];
|
|
72
113
|
getChildren(parentId: string): TaskNode[];
|
|
@@ -88,7 +129,23 @@ declare class TaskTracker {
|
|
|
88
129
|
|
|
89
130
|
interface TaskGeneratorOptions {
|
|
90
131
|
taskTracker: TaskTracker;
|
|
132
|
+
/**
|
|
133
|
+
* Opt-in (default off): derive each task's completion-gate
|
|
134
|
+
* `metadata.verificationCommand` from an acceptance criterion that carries a
|
|
135
|
+
* runnable-command marker (`$ <cmd>`, or `run:`/`verify:`/`cmd:` prefix). Off
|
|
136
|
+
* by default so the common case stays fast — auto-running a check per task is
|
|
137
|
+
* exactly the slowness the robustness initiative set out to avoid; enable it
|
|
138
|
+
* explicitly (the CLI gates it behind WRONGSTACK_SDD_VERIFY_FROM_ACCEPTANCE).
|
|
139
|
+
*/
|
|
140
|
+
verificationFromAcceptance?: boolean | undefined;
|
|
91
141
|
}
|
|
142
|
+
/**
|
|
143
|
+
* Pull a runnable verification command out of a requirement's acceptance
|
|
144
|
+
* criteria. A criterion qualifies only when it carries an explicit marker —
|
|
145
|
+
* `$ <cmd>` (shell-prompt style) or a `run:` / `verify:` / `cmd:` prefix — so
|
|
146
|
+
* free-text criteria are never mistaken for commands. Returns the first match.
|
|
147
|
+
*/
|
|
148
|
+
declare function extractVerificationCommand(criteria: readonly string[]): string | undefined;
|
|
92
149
|
interface GeneratedTask {
|
|
93
150
|
specRequirementId?: string | undefined;
|
|
94
151
|
title: string;
|
|
@@ -699,6 +756,19 @@ declare class SddTaskDecomposer {
|
|
|
699
756
|
* Total waves produced so far.
|
|
700
757
|
*/
|
|
701
758
|
getWaveCount(): number;
|
|
759
|
+
/**
|
|
760
|
+
* All ready (dependency-satisfied) pending tasks, priority-sorted — UNSLICED.
|
|
761
|
+
* The continuous scheduler fills its own free slots from this list, so unlike
|
|
762
|
+
* `nextBatch()` it does not cap at `slots`.
|
|
763
|
+
*/
|
|
764
|
+
readyNodes(): TaskNode[];
|
|
765
|
+
/**
|
|
766
|
+
* True when every node has reached a terminal state (completed or failed).
|
|
767
|
+
* This — not `isDone()` (which requires ALL completed) — is the correct loop
|
|
768
|
+
* exit for the continuous scheduler: a terminally-failed task must not keep
|
|
769
|
+
* the run spinning to its backstop.
|
|
770
|
+
*/
|
|
771
|
+
isSettled(): boolean;
|
|
702
772
|
/**
|
|
703
773
|
* Return pending nodes whose blockers are all completed.
|
|
704
774
|
* Sorted by priority (critical first), then by creation time.
|
|
@@ -708,6 +778,31 @@ declare class SddTaskDecomposer {
|
|
|
708
778
|
private hasAnyBlockedTasks;
|
|
709
779
|
}
|
|
710
780
|
|
|
781
|
+
/** A sub-task produced by splitting a parent task (see `splitTask`). */
|
|
782
|
+
interface SddSubtaskSpec {
|
|
783
|
+
title: string;
|
|
784
|
+
description: string;
|
|
785
|
+
type?: TaskNode['type'] | undefined;
|
|
786
|
+
priority?: TaskNode['priority'] | undefined;
|
|
787
|
+
}
|
|
788
|
+
/**
|
|
789
|
+
* Verdict returned by the optional failure supervisor when a task is about to go
|
|
790
|
+
* terminal. `retry` re-queues with a fresh attempt budget; `reassign` swaps the
|
|
791
|
+
* worker model (+ optional provider) then re-queues; `split` breaks the task
|
|
792
|
+
* into sub-tasks; `fail` (or `undefined`) lets it terminal-fail.
|
|
793
|
+
*/
|
|
794
|
+
type SddSupervisorVerdict = {
|
|
795
|
+
action: 'retry';
|
|
796
|
+
} | {
|
|
797
|
+
action: 'reassign';
|
|
798
|
+
model?: string | undefined;
|
|
799
|
+
provider?: string | undefined;
|
|
800
|
+
} | {
|
|
801
|
+
action: 'split';
|
|
802
|
+
subtasks: SddSubtaskSpec[];
|
|
803
|
+
} | {
|
|
804
|
+
action: 'fail';
|
|
805
|
+
};
|
|
711
806
|
interface SddParallelRunOptions {
|
|
712
807
|
/** Pre-constructed TaskTracker (must already hold the graph's initial state). */
|
|
713
808
|
tracker: TaskTracker;
|
|
@@ -717,18 +812,119 @@ interface SddParallelRunOptions {
|
|
|
717
812
|
agent: Agent;
|
|
718
813
|
/** Project root (used for coordinator id). */
|
|
719
814
|
projectRoot: string;
|
|
720
|
-
/**
|
|
815
|
+
/**
|
|
816
|
+
* Override default parallel slots (1–16). Default: 2 — deliberately low so a
|
|
817
|
+
* run never juggles more git worktrees than a human can review. Independent
|
|
818
|
+
* tasks still run concurrently up to this cap; dependency chains run in order.
|
|
819
|
+
*/
|
|
721
820
|
parallelSlots?: number | undefined;
|
|
722
|
-
/**
|
|
821
|
+
/**
|
|
822
|
+
* Hard wall-clock cap per task in ms. OPT-IN — `undefined` by default so a
|
|
823
|
+
* long-but-productive task is never killed merely for running long (the old
|
|
824
|
+
* 5-min default hard-killed real coding tasks with `budget_timeout`). When
|
|
825
|
+
* set, the coordinator watchdog enforces it. Prefer `taskIdleTimeoutMs`.
|
|
826
|
+
*/
|
|
723
827
|
taskTimeoutMs?: number | undefined;
|
|
724
|
-
/**
|
|
828
|
+
/**
|
|
829
|
+
* Idle reaper per task in ms: reap a task only after this long with NO
|
|
830
|
+
* activity (iteration / tool call / streamed token / tool progress). Resets
|
|
831
|
+
* on every sign of forward motion, so an actively-working agent runs until
|
|
832
|
+
* its task naturally ends. Default: 600_000 (10 min of silence = genuinely
|
|
833
|
+
* stuck). This is the default guard — wall-clock (`taskTimeoutMs`) is opt-in.
|
|
834
|
+
*/
|
|
835
|
+
taskIdleTimeoutMs?: number | undefined;
|
|
836
|
+
/** Maximum in-run retry attempts for a failed task before it goes terminal. Default: 3. */
|
|
725
837
|
maxRetries?: number | undefined;
|
|
838
|
+
/**
|
|
839
|
+
* After the graph settles with terminal-failed tasks, requeue ALL failed
|
|
840
|
+
* (non-cancelled) tasks to `pending` and run them again — up to this many
|
|
841
|
+
* sweeps. Each sweep gives every failed task a fresh `maxRetries` budget. The
|
|
842
|
+
* loop stops early once a sweep produces no new completions (no progress).
|
|
843
|
+
* 0 = off. Default: 2.
|
|
844
|
+
*/
|
|
845
|
+
maxFailedRetrySweeps?: number | undefined;
|
|
726
846
|
/** Override the default agent factory. */
|
|
727
847
|
subagentFactory?: AgentFactory | undefined;
|
|
848
|
+
/**
|
|
849
|
+
* Run-level default model for worker subagents. A task's own
|
|
850
|
+
* `metadata.model` (set per-task in the WebUI) takes precedence; this is the
|
|
851
|
+
* fallback for every task that has no explicit assignment. Undefined → the
|
|
852
|
+
* factory's own default (the leader's model).
|
|
853
|
+
*/
|
|
854
|
+
defaultModel?: string | undefined;
|
|
855
|
+
/** Run-level default provider id (same precedence rules as defaultModel). */
|
|
856
|
+
defaultProvider?: string | undefined;
|
|
857
|
+
/**
|
|
858
|
+
* Run-level fallback model chain (entries: `model` / `provider/model`). A
|
|
859
|
+
* task's `metadata.fallbackModels` overrides this. The subagent factory wires
|
|
860
|
+
* these into a fallback extension so a 429/stream-hang rotates to the next.
|
|
861
|
+
*/
|
|
862
|
+
fallbackModels?: string[] | undefined;
|
|
863
|
+
/**
|
|
864
|
+
* Post-task verification gate. When set, a task whose worker reported success
|
|
865
|
+
* is NOT marked `completed` (and NOT merged) until this resolves `{ok:true}`.
|
|
866
|
+
* Runs in the task's worktree cwd (or the project root when no worktree). Core
|
|
867
|
+
* stays shell-agnostic — the caller injects a verifier that, e.g., runs the
|
|
868
|
+
* task's `metadata.verificationCommand` (tests / typecheck). A task with no
|
|
869
|
+
* command should return `{ok:true}`. An `{ok:false}` routes the task into the
|
|
870
|
+
* normal failure path (retry while attempts remain, else terminal-fail).
|
|
871
|
+
*/
|
|
872
|
+
verifyTask?: ((info: {
|
|
873
|
+
task: TaskNode;
|
|
874
|
+
result: TaskResult;
|
|
875
|
+
cwd: string;
|
|
876
|
+
}) => Promise<{
|
|
877
|
+
ok: boolean;
|
|
878
|
+
reason?: string;
|
|
879
|
+
}>) | undefined;
|
|
880
|
+
/**
|
|
881
|
+
* Optional merge-conflict resolver, forwarded to `WorktreeManager.merge`. Given
|
|
882
|
+
* the conflicted files + the base checkout cwd, return `true` once resolved (no
|
|
883
|
+
* markers left). When omitted or it returns `false`, the task is requeued (a
|
|
884
|
+
* re-run forks a fresh worktree off the advanced base) and, if retries are
|
|
885
|
+
* exhausted, terminally failed with its worktree kept for review.
|
|
886
|
+
*/
|
|
887
|
+
conflictResolver?: ((info: {
|
|
888
|
+
task: TaskNode;
|
|
889
|
+
conflictFiles: string[];
|
|
890
|
+
cwd: string;
|
|
891
|
+
}) => Promise<boolean>) | undefined;
|
|
892
|
+
/**
|
|
893
|
+
* Failure supervisor: consulted ONLY when a task has exhausted its retries and
|
|
894
|
+
* is about to go terminal-failed. Returning a verdict lets a decision agent
|
|
895
|
+
* keep the run moving — `retry` / `reassign` (swap model) / `split` — instead
|
|
896
|
+
* of dead-ending. Returning `{action:'fail'}` / `undefined` lets it fail. Each
|
|
897
|
+
* task can be rescued at most `maxSupervisorEscalations` times (loop guard).
|
|
898
|
+
*/
|
|
899
|
+
superviseFailure?: ((info: {
|
|
900
|
+
task: TaskNode;
|
|
901
|
+
error: string;
|
|
902
|
+
attempts: number;
|
|
903
|
+
}) => Promise<SddSupervisorVerdict | undefined>) | undefined;
|
|
904
|
+
/** Max times the supervisor may rescue a single task before it must fail. Default 2. */
|
|
905
|
+
maxSupervisorEscalations?: number | undefined;
|
|
728
906
|
/** Called after each wave completes. */
|
|
729
907
|
onWave?: ((wave: WaveResult) => void) | undefined;
|
|
730
908
|
/** Called with progress stats every ~2s during execution. */
|
|
731
909
|
onProgress?: ((progress: SddProgress) => void) | undefined;
|
|
910
|
+
/** Shared EventBus — when set, the run emits `sdd.*` live-board events. */
|
|
911
|
+
events?: EventBus | undefined;
|
|
912
|
+
/** Stable id correlating all events of this run (default: random). */
|
|
913
|
+
runId?: string | undefined;
|
|
914
|
+
/**
|
|
915
|
+
* Optional git-worktree manager. When set (and the project is a git repo),
|
|
916
|
+
* each task runs in its own isolated worktree and merges back into the base
|
|
917
|
+
* branch after success — so parallel agents never collide on the same files.
|
|
918
|
+
*/
|
|
919
|
+
worktrees?: WorktreeManager | undefined;
|
|
920
|
+
/** Run-level backstops (prevent an autonomous run from looping forever). */
|
|
921
|
+
maxTotalWaves?: number | undefined;
|
|
922
|
+
maxWallClockMs?: number | undefined;
|
|
923
|
+
/**
|
|
924
|
+
* Deadlock auto-recovery rounds: when the graph deadlocks on failed blockers,
|
|
925
|
+
* requeue those failed blockers `pending` and try again, up to N times. 0 = off.
|
|
926
|
+
*/
|
|
927
|
+
maxRecoveryRounds?: number | undefined;
|
|
732
928
|
}
|
|
733
929
|
interface SddProgress {
|
|
734
930
|
wave: number;
|
|
@@ -750,6 +946,12 @@ interface WaveResult {
|
|
|
750
946
|
durationMs: number;
|
|
751
947
|
stopRequested: boolean;
|
|
752
948
|
}
|
|
949
|
+
/** Result of a single task's execution in the continuous scheduler. */
|
|
950
|
+
interface TaskOutcome {
|
|
951
|
+
taskId: string;
|
|
952
|
+
success: boolean;
|
|
953
|
+
result?: TaskResult | undefined;
|
|
954
|
+
}
|
|
753
955
|
interface RunResult {
|
|
754
956
|
totalWaves: number;
|
|
755
957
|
totalCompleted: number;
|
|
@@ -762,21 +964,919 @@ interface RunResult {
|
|
|
762
964
|
declare class SddParallelRun {
|
|
763
965
|
private readonly opts;
|
|
764
966
|
private readonly slots;
|
|
967
|
+
/** Opt-in hard wall-clock cap (undefined → no cap; idle reaper guards instead). */
|
|
765
968
|
private readonly timeoutMs;
|
|
969
|
+
/** Idle reaper window (ms) — resets on activity; reaps only a genuine stall. */
|
|
970
|
+
private readonly idleTimeoutMs;
|
|
766
971
|
private readonly maxRetries;
|
|
972
|
+
/** Max supervisor rescues per task before it must terminal-fail (loop guard). */
|
|
973
|
+
private readonly maxSupervisorEscalations;
|
|
974
|
+
/** Per-task count of supervisor rescues used (resets nothing — bounds the loop). */
|
|
975
|
+
private supervisorEscalations;
|
|
976
|
+
/** Max end-of-run failed-task sweeps (see `maxFailedRetrySweeps`). */
|
|
977
|
+
private readonly maxFailedSweeps;
|
|
978
|
+
/** How many failed-task sweeps have run this `run()` so far. */
|
|
979
|
+
private failedSweeps;
|
|
980
|
+
/** Completed-count snapshot at the last sweep, to detect a no-progress sweep. */
|
|
981
|
+
private lastSweepCompleted;
|
|
767
982
|
private decomposer;
|
|
768
983
|
private coordinator;
|
|
769
984
|
private stopRequested;
|
|
770
985
|
private retryMap;
|
|
986
|
+
readonly runId: string;
|
|
987
|
+
private readonly events?;
|
|
988
|
+
private readonly maxTotalWaves;
|
|
989
|
+
private readonly maxWallClockMs?;
|
|
990
|
+
private readonly maxRecoveryRounds;
|
|
991
|
+
private recoveryRounds;
|
|
992
|
+
/** Per-run worker identities, so the board shows "who is on what". */
|
|
993
|
+
private usedNicknames;
|
|
994
|
+
/** Per-task git worktree cwd (Layer 2 worktree isolation; empty otherwise). */
|
|
995
|
+
private taskCwds;
|
|
996
|
+
/** Per-task git worktree branch, for board display. */
|
|
997
|
+
private taskBranches;
|
|
998
|
+
/** Live worktree handles keyed by task id (for commit/merge/release). */
|
|
999
|
+
private taskWorktrees;
|
|
1000
|
+
/** Live subagent id per running task — lets cancelTask() abort exactly one. */
|
|
1001
|
+
private taskSubagents;
|
|
1002
|
+
/** Tasks the user cancelled mid-flight — skip retry, mark terminal-cancelled. */
|
|
1003
|
+
private cancelledTasks;
|
|
1004
|
+
/**
|
|
1005
|
+
* Base branch the run's squash commits land on (captured once at start when
|
|
1006
|
+
* worktrees are enabled). Anchors a later `rollback()`.
|
|
1007
|
+
*/
|
|
1008
|
+
private baseBranch;
|
|
1009
|
+
/**
|
|
1010
|
+
* Squash-merge commits this run landed on the base branch, in landing order.
|
|
1011
|
+
* `rollback()` reverts these (newest → oldest). Persisted via the board
|
|
1012
|
+
* snapshot so a post-run rollback can read them off disk.
|
|
1013
|
+
*/
|
|
1014
|
+
private mergedCommits;
|
|
1015
|
+
/** Monotonic dispatch counter (unique subagent ids) + dispatch-round counter. */
|
|
1016
|
+
private dispatchSeq;
|
|
1017
|
+
private round;
|
|
771
1018
|
constructor(opts: SddParallelRunOptions);
|
|
1019
|
+
/** Type-safe emit on the optional EventBus (no-op when unwired). */
|
|
1020
|
+
private emit;
|
|
1021
|
+
private paused;
|
|
772
1022
|
/** Trigger stop — causes run() to abort after the current wave. */
|
|
773
1023
|
stop(): void;
|
|
774
|
-
/**
|
|
1024
|
+
/** Pause: no new wave starts until resume() (the current wave finishes). */
|
|
1025
|
+
pause(): void;
|
|
1026
|
+
resume(): void;
|
|
1027
|
+
isPaused(): boolean;
|
|
1028
|
+
isRunning(): boolean;
|
|
1029
|
+
/** Base branch the run's squash commits land on (undefined when worktrees off). */
|
|
1030
|
+
getBaseBranch(): string | undefined;
|
|
1031
|
+
/** Squash commits this run landed on the base branch, in landing order. */
|
|
1032
|
+
getMergedCommits(): ReadonlyArray<{
|
|
1033
|
+
taskId: string;
|
|
1034
|
+
sha: string;
|
|
1035
|
+
title: string;
|
|
1036
|
+
}>;
|
|
1037
|
+
/**
|
|
1038
|
+
* Remove every git worktree + branch this run (and any prior run) created.
|
|
1039
|
+
* Refuses while the run is still live — cleaning a checkout under an active
|
|
1040
|
+
* worker would corrupt it. Stop first. Returns the number of worktrees removed
|
|
1041
|
+
* (0 when worktrees are disabled). Idempotent.
|
|
1042
|
+
*/
|
|
1043
|
+
cleanupWorktrees(): Promise<number>;
|
|
1044
|
+
/**
|
|
1045
|
+
* Undo the run's merged commits by reverting each on the base branch (history
|
|
1046
|
+
* preserving). Refuses while the run is still live (stop first). Returns the
|
|
1047
|
+
* revert outcome; a dirty tree or revert conflict surfaces as `ok:false`.
|
|
1048
|
+
*/
|
|
1049
|
+
rollback(): Promise<{
|
|
1050
|
+
ok: boolean;
|
|
1051
|
+
reverted: number;
|
|
1052
|
+
reason?: string;
|
|
1053
|
+
}>;
|
|
1054
|
+
/** Requeue a task to `pending` so the scheduler re-runs it (clears retries + cancel marker). */
|
|
1055
|
+
retryTask(taskId: string): boolean;
|
|
1056
|
+
/** Reassign a task to a specific agent name (reflected on the board). */
|
|
1057
|
+
reassignTask(taskId: string, agentName: string): boolean;
|
|
1058
|
+
/**
|
|
1059
|
+
* Set/override a task's worker model (and optionally provider) — applied on its
|
|
1060
|
+
* NEXT dispatch (a running task must be cancelled + retried to take effect). The
|
|
1061
|
+
* assignment lives on node metadata so it survives crash → resume.
|
|
1062
|
+
*/
|
|
1063
|
+
setTaskModel(taskId: string, model: string | undefined, provider?: string | undefined): boolean;
|
|
1064
|
+
/** Set/override a task's fallback model chain (applied on its next dispatch). */
|
|
1065
|
+
setTaskFallbacks(taskId: string, fallbackModels: string[] | undefined): boolean;
|
|
1066
|
+
/**
|
|
1067
|
+
* Set/override a task's verification command (the completion gate runs it in
|
|
1068
|
+
* the task's cwd and only lets the task complete on exit 0). Empty/undefined
|
|
1069
|
+
* clears it. Applied on the task's next verification — i.e. its next dispatch.
|
|
1070
|
+
*/
|
|
1071
|
+
setTaskVerification(taskId: string, verificationCommand: string | undefined): boolean;
|
|
1072
|
+
/**
|
|
1073
|
+
* Cancel a task. If it is currently running, abort its subagent and mark the
|
|
1074
|
+
* node terminally failed+cancelled (so the scheduler frees the slot and does
|
|
1075
|
+
* NOT retry it). If it has not started, it is simply marked cancelled. Use
|
|
1076
|
+
* `retryTask` to bring a cancelled task back. Returns false for an unknown task.
|
|
1077
|
+
*/
|
|
1078
|
+
cancelTask(taskId: string): Promise<boolean>;
|
|
1079
|
+
/**
|
|
1080
|
+
* Delete a not-yet-started task from the graph (pending/blocked/failed only —
|
|
1081
|
+
* never a running task; cancel it first). Removes the node and every edge
|
|
1082
|
+
* touching it; dependents lose this blocker. Returns false if missing or running.
|
|
1083
|
+
*/
|
|
1084
|
+
deleteTask(taskId: string): boolean;
|
|
1085
|
+
/**
|
|
1086
|
+
* Split a task into sub-tasks and delegate them to separate workers. The new
|
|
1087
|
+
* leaves inherit the parent's blockers (so they don't start before the
|
|
1088
|
+
* parent's dependencies are met), every existing dependent is rewired to
|
|
1089
|
+
* depend on ALL leaves (so downstream work waits for the whole split), and the
|
|
1090
|
+
* parent becomes a `completed` container. Refuses a running task (cancel it
|
|
1091
|
+
* first) or empty subtask list. Returns the new leaf ids (empty on refusal).
|
|
1092
|
+
* The scheduler picks the new pending leaves up on its next dispatch pass.
|
|
1093
|
+
*/
|
|
1094
|
+
splitTask(taskId: string, subtasks: SddSubtaskSpec[]): string[];
|
|
1095
|
+
private waitWhilePaused;
|
|
1096
|
+
/**
|
|
1097
|
+
* Continuous dependency-driven execution. Unlike a wave-barrier loop (where a
|
|
1098
|
+
* whole batch must finish before the next starts), this fills free worker
|
|
1099
|
+
* slots the instant a task's dependencies are satisfied: a fast task's
|
|
1100
|
+
* dependent starts immediately rather than waiting for a slow sibling. Truly
|
|
1101
|
+
* independent tasks run in parallel; dependency chains run in order. Returns
|
|
1102
|
+
* the final summary when the graph settles, deadlocks, stops, or hits a backstop.
|
|
1103
|
+
*/
|
|
775
1104
|
run(): Promise<RunResult>;
|
|
1105
|
+
/**
|
|
1106
|
+
* Compute the blocking chains for a deadlock: every still-incomplete task and
|
|
1107
|
+
* the blockers (by node id) that are NOT completed. Failed blockers are
|
|
1108
|
+
* included since they're the usual deadlock cause once retries are exhausted.
|
|
1109
|
+
*/
|
|
1110
|
+
private computeDeadlockChains;
|
|
1111
|
+
/** Requeue failed tasks that block an incomplete dependent. Returns true if any. */
|
|
1112
|
+
private recoverFailedBlockers;
|
|
1113
|
+
/**
|
|
1114
|
+
* Requeue every terminal-failed task that the user did NOT cancel, giving each
|
|
1115
|
+
* a fresh `maxRetries` budget. Shared by the automatic end-of-run sweep and
|
|
1116
|
+
* the manual "retry all failed" control. Returns the number requeued.
|
|
1117
|
+
*/
|
|
1118
|
+
private requeueFailedTasks;
|
|
1119
|
+
/**
|
|
1120
|
+
* Manually requeue all failed tasks to `pending` (board "Retry all failed").
|
|
1121
|
+
* Unlike the automatic sweep this also clears any `cancelled` marker, so a
|
|
1122
|
+
* user can bring cancelled tasks back in the same action — mirroring
|
|
1123
|
+
* `retryTask`. Picked up by the running scheduler on its next dispatch pass.
|
|
1124
|
+
* Returns the number of tasks requeued.
|
|
1125
|
+
*/
|
|
1126
|
+
retryAllFailed(): number;
|
|
1127
|
+
/** Restore per-task retry counts persisted in node metadata (resume support). */
|
|
1128
|
+
private restoreRetryMap;
|
|
1129
|
+
/**
|
|
1130
|
+
* Reset orphaned `in_progress` tasks (no agent runs them after a crash) back
|
|
1131
|
+
* to `pending` so a fresh run re-executes them. Call before constructing a run
|
|
1132
|
+
* from a reloaded graph. Static so callers don't need a run instance.
|
|
1133
|
+
*/
|
|
1134
|
+
static resetOrphans(tracker: TaskTracker): number;
|
|
1135
|
+
/** Clean teardown after a stop: reset interrupted tasks + release worktrees. */
|
|
1136
|
+
private teardown;
|
|
776
1137
|
private buildCoordinator;
|
|
777
1138
|
private defaultFactory;
|
|
1139
|
+
/**
|
|
1140
|
+
* Execute a batch of tasks together. Retained as a thin wrapper over the
|
|
1141
|
+
* single-task primitive `executeOne` so the wave-oriented tests and any
|
|
1142
|
+
* batch callers keep working; the continuous scheduler in `run()` calls
|
|
1143
|
+
* `executeOne` directly. Throws if no coordinator is wired or a spawn fails
|
|
1144
|
+
* (surfaced from `executeOne`), preserving the original all-or-nothing contract.
|
|
1145
|
+
*/
|
|
778
1146
|
executeWave(batch: TaskBatch): Promise<WaveResult>;
|
|
1147
|
+
/**
|
|
1148
|
+
* Execute one task end-to-end: assign a worker identity, allocate its worktree,
|
|
1149
|
+
* spawn + assign the subagent, await its result, then update tracker status
|
|
1150
|
+
* (success / retry / terminal-fail / cancelled) and resolve the worktree. This
|
|
1151
|
+
* is the unit the continuous scheduler dispatches into a free slot. Throws on a
|
|
1152
|
+
* missing coordinator or failed spawn so callers can enforce all-or-nothing.
|
|
1153
|
+
*/
|
|
1154
|
+
executeOne(task: TaskNode): Promise<TaskOutcome>;
|
|
1155
|
+
/**
|
|
1156
|
+
* Apply a task failure: retry (→ pending, bump retry count) while attempts
|
|
1157
|
+
* remain, else consult the optional supervisor (which can rescue via
|
|
1158
|
+
* retry/reassign/split), else terminal-fail (→ failed). Shared by the
|
|
1159
|
+
* worker-failure, verification-gate, and merge-conflict paths so all three
|
|
1160
|
+
* negotiate the same retry budget and emit the same events.
|
|
1161
|
+
*/
|
|
1162
|
+
private applyTaskFailure;
|
|
1163
|
+
/**
|
|
1164
|
+
* Consult `superviseFailure` for a task that has exhausted its retries.
|
|
1165
|
+
* Applies the verdict (retry / reassign+retry / split) and returns true when
|
|
1166
|
+
* the task was rescued (caller must NOT terminal-fail it). Bounded per task by
|
|
1167
|
+
* `maxSupervisorEscalations` so an always-"retry" supervisor can't loop forever.
|
|
1168
|
+
*/
|
|
1169
|
+
private trySupervisorRescue;
|
|
1170
|
+
/**
|
|
1171
|
+
* Integrate a verified-successful task's worktree into the base branch.
|
|
1172
|
+
* Commits, squash-merges (optionally running `conflictResolver` first), and on
|
|
1173
|
+
* success releases the worktree. On an UNRESOLVED conflict it returns
|
|
1174
|
+
* `{ok:false}` with the conflicting files so the caller routes the task into
|
|
1175
|
+
* the failure path (a retry forks a fresh worktree off the now-advanced base,
|
|
1176
|
+
* which usually clears the conflict). No-op `{ok:true}` when worktrees are
|
|
1177
|
+
* disabled or none was allocated for this task. Never throws — a merge hiccup
|
|
1178
|
+
* degrades to a (retryable) failure rather than wedging the run.
|
|
1179
|
+
*/
|
|
1180
|
+
private integrateWorktree;
|
|
1181
|
+
/** Allocate a fresh git worktree per task in the batch (no-op without a manager). */
|
|
1182
|
+
private allocateWorktrees;
|
|
1183
|
+
/**
|
|
1184
|
+
* Resolve each task's worktree after its result is known. Serialized merges
|
|
1185
|
+
* (one at a time) keep the base branch consistent; the wave structure already
|
|
1186
|
+
* guarantees dependency order (a task's blockers merged in an earlier wave).
|
|
1187
|
+
*/
|
|
1188
|
+
private resolveWorktrees;
|
|
1189
|
+
private forgetWorktree;
|
|
1190
|
+
/** Persist a task's retry count into node metadata (survives crash → resume). */
|
|
1191
|
+
private persistRetries;
|
|
779
1192
|
private buildProgress;
|
|
780
1193
|
}
|
|
781
1194
|
|
|
782
|
-
|
|
1195
|
+
interface SddSupervisorOptions {
|
|
1196
|
+
/** Decision authority (policy/LLM/human). Reuse the session's TOKENS.BrainArbiter. */
|
|
1197
|
+
brain: BrainArbiter;
|
|
1198
|
+
/**
|
|
1199
|
+
* Models to rotate through on a `reassign` verdict (e.g. the run's fallback
|
|
1200
|
+
* chain). Omit to drop the reassign option entirely.
|
|
1201
|
+
*/
|
|
1202
|
+
reassignModels?: string[] | undefined;
|
|
1203
|
+
/**
|
|
1204
|
+
* Optional sub-task generator for a `split` verdict — typically an LLM call
|
|
1205
|
+
* that decomposes the failing task into smaller pieces. Omit to drop the split
|
|
1206
|
+
* option. Returning an empty array degrades the split into a retry.
|
|
1207
|
+
*/
|
|
1208
|
+
generateSubtasks?: ((info: {
|
|
1209
|
+
task: TaskNode;
|
|
1210
|
+
error: string;
|
|
1211
|
+
}) => Promise<SddSubtaskSpec[]>) | undefined;
|
|
1212
|
+
/**
|
|
1213
|
+
* Let the tiered brain's LLM layer actually pick the verdict.
|
|
1214
|
+
*
|
|
1215
|
+
* Default (false) requests `fallback: 'continue'`, which the policy layer
|
|
1216
|
+
* answers immediately (a bounded retry) — the LLM never runs, so `reassign`/
|
|
1217
|
+
* `split` can't be chosen. Set true to request `fallback: 'ask_human'`, which
|
|
1218
|
+
* makes the policy escalate so the autonomous (LLM) layer decides.
|
|
1219
|
+
*
|
|
1220
|
+
* ONLY enable this when the supplied `brain` will NOT block on a human prompt
|
|
1221
|
+
* for an unresolved decision (i.e. it has an autonomous layer and is NOT
|
|
1222
|
+
* wrapped in `HumanEscalatingBrainArbiter`). When the LLM can't decide (no
|
|
1223
|
+
* autonomous layer / over the risk ceiling / LLM down) the brain returns
|
|
1224
|
+
* `ask_human`, which the supervisor degrades to a **bounded retry** (never a
|
|
1225
|
+
* block, never a dead-end). A human-escalating brain would instead block
|
|
1226
|
+
* inside `decide()` and wedge the run — keep this false there.
|
|
1227
|
+
*/
|
|
1228
|
+
requestLlmVerdict?: boolean | undefined;
|
|
1229
|
+
}
|
|
1230
|
+
declare class SddSupervisor {
|
|
1231
|
+
private readonly opts;
|
|
1232
|
+
constructor(opts: SddSupervisorOptions);
|
|
1233
|
+
/**
|
|
1234
|
+
* Bind this as `SddParallelRunOptions.superviseFailure`. Returns a verdict the
|
|
1235
|
+
* run applies, or `undefined`/`{action:'fail'}` to let the task terminal-fail.
|
|
1236
|
+
*/
|
|
1237
|
+
readonly superviseFailure: (info: {
|
|
1238
|
+
task: TaskNode;
|
|
1239
|
+
error: string;
|
|
1240
|
+
attempts: number;
|
|
1241
|
+
}) => Promise<SddSupervisorVerdict | undefined>;
|
|
1242
|
+
}
|
|
1243
|
+
|
|
1244
|
+
interface CommandVerifierOptions {
|
|
1245
|
+
/** Metadata key holding the shell command to run. Default 'verificationCommand'. */
|
|
1246
|
+
metadataKey?: string;
|
|
1247
|
+
/** Kill + fail the verification after this many ms. Default 180_000 (3 min). */
|
|
1248
|
+
timeoutMs?: number;
|
|
1249
|
+
}
|
|
1250
|
+
/**
|
|
1251
|
+
* Build a `verifyTask` closure (shape matches {@link SddParallelRunOptions.verifyTask}).
|
|
1252
|
+
* Returns `{ ok: true }` immediately when the task carries no verification command,
|
|
1253
|
+
* otherwise spawns the command in `cwd` (shell, output discarded) and resolves
|
|
1254
|
+
* `{ ok: false, reason }` on non-zero exit, spawn error, or timeout.
|
|
1255
|
+
*/
|
|
1256
|
+
declare function makeCommandVerifier(options?: CommandVerifierOptions): (info: {
|
|
1257
|
+
task: TaskNode;
|
|
1258
|
+
result: TaskResult;
|
|
1259
|
+
cwd: string;
|
|
1260
|
+
}) => Promise<{
|
|
1261
|
+
ok: boolean;
|
|
1262
|
+
reason?: string;
|
|
1263
|
+
}>;
|
|
1264
|
+
|
|
1265
|
+
interface SubtaskGeneratorOptions {
|
|
1266
|
+
/** Runs one self-contained, isolated LLM turn and resolves its final text. */
|
|
1267
|
+
run: (prompt: string) => Promise<string>;
|
|
1268
|
+
/** Minimum well-formed sub-tasks required to accept a split. Default 2. */
|
|
1269
|
+
minSubtasks?: number;
|
|
1270
|
+
/** Maximum sub-tasks kept (excess is dropped). Default 4. */
|
|
1271
|
+
maxSubtasks?: number;
|
|
1272
|
+
}
|
|
1273
|
+
/**
|
|
1274
|
+
* Build a `SddSupervisorOptions.generateSubtasks` closure backed by an LLM turn.
|
|
1275
|
+
* Returns [] on any failure (parse error, too few valid items, runner throw), so
|
|
1276
|
+
* the supervisor safely degrades a `split` verdict into a retry.
|
|
1277
|
+
*/
|
|
1278
|
+
declare function makeLlmSubtaskGenerator(opts: SubtaskGeneratorOptions): (info: {
|
|
1279
|
+
task: TaskNode;
|
|
1280
|
+
error: string;
|
|
1281
|
+
}) => Promise<SddSubtaskSpec[]>;
|
|
1282
|
+
|
|
1283
|
+
type ConflictSide = 'incoming' | 'base';
|
|
1284
|
+
/**
|
|
1285
|
+
* Resolve every standard git conflict hunk in `text` by keeping `side`. Handles
|
|
1286
|
+
* both 2-way (`<<<<<<< / ======= / >>>>>>>`) and diff3 (`||||||| base`) markers.
|
|
1287
|
+
* Returns the rewritten text (markers removed).
|
|
1288
|
+
*/
|
|
1289
|
+
declare function resolveConflictText(text: string, side: ConflictSide): string;
|
|
1290
|
+
/** True when `text` still contains a git conflict marker line. */
|
|
1291
|
+
declare function hasConflictMarkers(text: string): boolean;
|
|
1292
|
+
/**
|
|
1293
|
+
* Build a `conflictResolver` that keeps `side` of every hunk in each conflicted
|
|
1294
|
+
* file. Returns false (abort → conservative fail) if any file can't be read,
|
|
1295
|
+
* written, or still has markers after the rewrite.
|
|
1296
|
+
*/
|
|
1297
|
+
declare function makePreferSideConflictResolver(side: ConflictSide): (info: {
|
|
1298
|
+
task: TaskNode;
|
|
1299
|
+
conflictFiles: string[];
|
|
1300
|
+
cwd: string;
|
|
1301
|
+
}) => Promise<boolean>;
|
|
1302
|
+
interface LlmConflictResolverOptions {
|
|
1303
|
+
/** Runs one self-contained, isolated LLM turn and resolves its final text. */
|
|
1304
|
+
run: (prompt: string) => Promise<string>;
|
|
1305
|
+
/**
|
|
1306
|
+
* Reject a resolution that shrinks the file below this fraction of its original
|
|
1307
|
+
* non-marker line count — a crude guard against the model dropping content.
|
|
1308
|
+
* Default 0.5.
|
|
1309
|
+
*/
|
|
1310
|
+
minRetainedFraction?: number;
|
|
1311
|
+
}
|
|
1312
|
+
/**
|
|
1313
|
+
* Build an LLM-backed `conflictResolver`: for each conflicted file it asks the
|
|
1314
|
+
* model (via one isolated `run` turn) to produce the fully resolved file and
|
|
1315
|
+
* writes it back. Heavily guarded — returns false (→ conservative abort/retry)
|
|
1316
|
+
* if the model leaves a marker, returns junk, or drops too much content. The
|
|
1317
|
+
* WorktreeManager STILL rejects any surviving marker, and (when a `verifyTask`
|
|
1318
|
+
* is configured) the run re-verifies the integrated base and reverts a
|
|
1319
|
+
* regression — so a bad LLM merge can never silently stick. OFF by default.
|
|
1320
|
+
*/
|
|
1321
|
+
declare function makeLlmConflictResolver(opts: LlmConflictResolverOptions): (info: {
|
|
1322
|
+
task: TaskNode;
|
|
1323
|
+
conflictFiles: string[];
|
|
1324
|
+
cwd: string;
|
|
1325
|
+
}) => Promise<boolean>;
|
|
1326
|
+
|
|
1327
|
+
/**
|
|
1328
|
+
* SDD live board model.
|
|
1329
|
+
*
|
|
1330
|
+
* A board snapshot is the canonical, surface-agnostic projection of a running
|
|
1331
|
+
* (or persisted) SDD TaskGraph: tasks laid into topological dependency columns,
|
|
1332
|
+
* each carrying its short id, status, blockers and the agent currently on it.
|
|
1333
|
+
* The projector (sdd-board-projector.ts) emits these over the EventBus and
|
|
1334
|
+
* persists them (sdd-board-store.ts); every surface (WebUI/TUI) renders the
|
|
1335
|
+
* same shape.
|
|
1336
|
+
*/
|
|
1337
|
+
|
|
1338
|
+
type SddBoardStatus = 'idle' | 'running' | 'paused' | 'completed' | 'failed' | 'deadlocked';
|
|
1339
|
+
/**
|
|
1340
|
+
* FORGE-style display status: `queued` = pending with all blockers done;
|
|
1341
|
+
* `cancelled` = a task the user stopped (stored as a terminal `failed` node
|
|
1342
|
+
* carrying `metadata.cancelled`, surfaced distinctly so it doesn't read as an
|
|
1343
|
+
* error). Display-only — not a core `TaskStatus`.
|
|
1344
|
+
*/
|
|
1345
|
+
type SddTaskDisplayStatus = TaskNode['status'] | 'queued' | 'cancelled';
|
|
1346
|
+
interface SddBoardTask {
|
|
1347
|
+
id: string;
|
|
1348
|
+
/** Stable short id (t01, t02, …) in creation order. */
|
|
1349
|
+
shortId: string;
|
|
1350
|
+
title: string;
|
|
1351
|
+
description: string;
|
|
1352
|
+
status: TaskNode['status'];
|
|
1353
|
+
displayStatus: SddTaskDisplayStatus;
|
|
1354
|
+
priority: TaskNode['priority'];
|
|
1355
|
+
type: TaskNode['type'];
|
|
1356
|
+
/** Short ids of the tasks that block this one (depends_on edges). */
|
|
1357
|
+
deps: string[];
|
|
1358
|
+
/** Worker on the task right now (scientist nickname), if any. */
|
|
1359
|
+
agentName?: string | undefined;
|
|
1360
|
+
/** Git worktree branch this task runs in, when isolated. */
|
|
1361
|
+
worktreeBranch?: string | undefined;
|
|
1362
|
+
startedAt?: number | undefined;
|
|
1363
|
+
completedAt?: number | undefined;
|
|
1364
|
+
retries: number;
|
|
1365
|
+
/** Per-task model assignment (overrides the run default), if set. */
|
|
1366
|
+
model?: string | undefined;
|
|
1367
|
+
/** Per-task provider assignment (overrides the run default), if set. */
|
|
1368
|
+
provider?: string | undefined;
|
|
1369
|
+
/** Per-task fallback model chain (overrides the run default), if set. */
|
|
1370
|
+
fallbackModels?: string[] | undefined;
|
|
1371
|
+
/** Per-task completion-gate verification command, if set. */
|
|
1372
|
+
verificationCommand?: string | undefined;
|
|
1373
|
+
}
|
|
1374
|
+
/** A topological column: tasks whose deepest dependency chain is `depth`. */
|
|
1375
|
+
interface SddBoardColumn {
|
|
1376
|
+
label: string;
|
|
1377
|
+
/** Short ids of the tasks in this column (join against `tasks`). */
|
|
1378
|
+
taskIds: string[];
|
|
1379
|
+
}
|
|
1380
|
+
interface SddDeadlockChain {
|
|
1381
|
+
/** Short id of the blocked task. */
|
|
1382
|
+
blocked: string;
|
|
1383
|
+
/** Short ids of the failed/incomplete blockers holding it. */
|
|
1384
|
+
blockedBy: string[];
|
|
1385
|
+
}
|
|
1386
|
+
/** One entry in the live activity feed (the board's "what just happened" ticker). */
|
|
1387
|
+
interface SddBoardFeedEntry {
|
|
1388
|
+
ts: number;
|
|
1389
|
+
kind: 'started' | 'completed' | 'failed' | 'retrying' | 'wave' | 'deadlock' | 'verification_failed' | 'conflict' | 'split' | 'supervisor';
|
|
1390
|
+
/** Short id of the task this entry concerns, when applicable. */
|
|
1391
|
+
taskShortId?: string | undefined;
|
|
1392
|
+
/** Worker involved, when applicable. */
|
|
1393
|
+
agentName?: string | undefined;
|
|
1394
|
+
/** Human-readable one-line summary. */
|
|
1395
|
+
text: string;
|
|
1396
|
+
}
|
|
1397
|
+
interface SddBoardSnapshot {
|
|
1398
|
+
runId: string;
|
|
1399
|
+
specId?: string | undefined;
|
|
1400
|
+
graphId: string;
|
|
1401
|
+
title: string;
|
|
1402
|
+
status: SddBoardStatus;
|
|
1403
|
+
startedAt: number;
|
|
1404
|
+
updatedAt: number;
|
|
1405
|
+
progress: TaskProgress;
|
|
1406
|
+
/** Current wave index (0-based) of the parallel run. */
|
|
1407
|
+
wave: number;
|
|
1408
|
+
tasks: SddBoardTask[];
|
|
1409
|
+
columns: SddBoardColumn[];
|
|
1410
|
+
diagnostics?: {
|
|
1411
|
+
deadlockChains?: SddDeadlockChain[];
|
|
1412
|
+
} | undefined;
|
|
1413
|
+
/** Live activity feed — most recent first (capped). */
|
|
1414
|
+
feed?: SddBoardFeedEntry[] | undefined;
|
|
1415
|
+
/** Run-level default worker model (task overrides take precedence). */
|
|
1416
|
+
defaultModel?: string | undefined;
|
|
1417
|
+
/** Run-level default worker provider. */
|
|
1418
|
+
defaultProvider?: string | undefined;
|
|
1419
|
+
/** Run-level default fallback model chain. */
|
|
1420
|
+
fallbackModels?: string[] | undefined;
|
|
1421
|
+
/** Base branch the run's squash commits land on (worktree runs only). */
|
|
1422
|
+
baseBranch?: string | undefined;
|
|
1423
|
+
/**
|
|
1424
|
+
* Squash commits the run landed on the base branch, in landing order. Lets a
|
|
1425
|
+
* post-run `/sdd rollback` revert them from disk after the live run is gone.
|
|
1426
|
+
*/
|
|
1427
|
+
mergedCommits?: Array<{
|
|
1428
|
+
taskId: string;
|
|
1429
|
+
sha: string;
|
|
1430
|
+
title: string;
|
|
1431
|
+
}> | undefined;
|
|
1432
|
+
}
|
|
1433
|
+
/**
|
|
1434
|
+
* Lay a TaskGraph's nodes into topological dependency columns with stable short
|
|
1435
|
+
* ids and per-task blocker refs. Shared by the projector (live) and any static
|
|
1436
|
+
* board browser. Pure; no run state — `agentName`/`worktreeBranch`/`retries`
|
|
1437
|
+
* are read from the node's `assignee`/`metadata` so a reload reflects the last
|
|
1438
|
+
* persisted run.
|
|
1439
|
+
*/
|
|
1440
|
+
/**
|
|
1441
|
+
* Stable short-id map (t01, t02, …) for a graph's nodes in creation order.
|
|
1442
|
+
* Shared by the board renderer and the projector (deadlock-chain labelling).
|
|
1443
|
+
*/
|
|
1444
|
+
declare function shortIdMap(graph: TaskGraph): Map<string, string>;
|
|
1445
|
+
declare function buildBoardTasks(graph: TaskGraph): {
|
|
1446
|
+
tasks: SddBoardTask[];
|
|
1447
|
+
columns: SddBoardColumn[];
|
|
1448
|
+
};
|
|
1449
|
+
/**
|
|
1450
|
+
* Build a full board snapshot from a graph + run state. The projector calls
|
|
1451
|
+
* this on every (throttled) change.
|
|
1452
|
+
*/
|
|
1453
|
+
declare function buildBoardSnapshot(graph: TaskGraph, run: {
|
|
1454
|
+
runId: string;
|
|
1455
|
+
specId?: string | undefined;
|
|
1456
|
+
status: SddBoardStatus;
|
|
1457
|
+
startedAt: number;
|
|
1458
|
+
wave: number;
|
|
1459
|
+
deadlockChains?: SddDeadlockChain[] | undefined;
|
|
1460
|
+
defaultModel?: string | undefined;
|
|
1461
|
+
defaultProvider?: string | undefined;
|
|
1462
|
+
fallbackModels?: string[] | undefined;
|
|
1463
|
+
baseBranch?: string | undefined;
|
|
1464
|
+
mergedCommits?: Array<{
|
|
1465
|
+
taskId: string;
|
|
1466
|
+
sha: string;
|
|
1467
|
+
title: string;
|
|
1468
|
+
}> | undefined;
|
|
1469
|
+
}, now: number): SddBoardSnapshot;
|
|
1470
|
+
|
|
1471
|
+
interface SddBoardStoreOptions {
|
|
1472
|
+
/** Directory for board snapshots + event logs (wpaths.projectSddBoards). */
|
|
1473
|
+
baseDir: string;
|
|
1474
|
+
}
|
|
1475
|
+
interface SddBoardIndexEntry {
|
|
1476
|
+
runId: string;
|
|
1477
|
+
specId?: string | undefined;
|
|
1478
|
+
title: string;
|
|
1479
|
+
status: string;
|
|
1480
|
+
total: number;
|
|
1481
|
+
completed: number;
|
|
1482
|
+
updatedAt: number;
|
|
1483
|
+
}
|
|
1484
|
+
/** One appended line in a board's JSONL event log. */
|
|
1485
|
+
interface SddBoardEvent {
|
|
1486
|
+
ts: number;
|
|
1487
|
+
type: string;
|
|
1488
|
+
payload?: unknown;
|
|
1489
|
+
}
|
|
1490
|
+
/**
|
|
1491
|
+
* File-backed SDD board storage. Each board (= one parallel run) has:
|
|
1492
|
+
* - `<runId>.json` — latest full snapshot (atomic; resume + standalone-webui mirror)
|
|
1493
|
+
* - `<runId>.events.jsonl`— append-only event log (audit / replay)
|
|
1494
|
+
* - `<runId>.control.jsonl` — append-only command queue (cross-process control, written by readers)
|
|
1495
|
+
* plus `_index.json` for fast listing. JSON for state, JSONL for streams.
|
|
1496
|
+
*/
|
|
1497
|
+
declare class SddBoardStore {
|
|
1498
|
+
private readonly baseDir;
|
|
1499
|
+
private readonly indexPath;
|
|
1500
|
+
constructor(opts: SddBoardStoreOptions);
|
|
1501
|
+
snapshotPath(runId: string): string;
|
|
1502
|
+
eventsPath(runId: string): string;
|
|
1503
|
+
controlPath(runId: string): string;
|
|
1504
|
+
saveSnapshot(snapshot: SddBoardSnapshot): Promise<void>;
|
|
1505
|
+
load(runId: string): Promise<SddBoardSnapshot | null>;
|
|
1506
|
+
list(): Promise<SddBoardIndexEntry[]>;
|
|
1507
|
+
loadLatestForSpec(specId: string): Promise<SddBoardSnapshot | null>;
|
|
1508
|
+
/** Append one line to the board's JSONL event log (best-effort, never throws). */
|
|
1509
|
+
appendEvent(runId: string, event: SddBoardEvent): Promise<void>;
|
|
1510
|
+
/** Append a control command (used by readers to steer a CLI-owned run). */
|
|
1511
|
+
appendControl(runId: string, command: {
|
|
1512
|
+
ts: number;
|
|
1513
|
+
type: string;
|
|
1514
|
+
payload?: unknown;
|
|
1515
|
+
}): Promise<void>;
|
|
1516
|
+
/** Read + truncate the control queue (the run drains it). Returns parsed commands. */
|
|
1517
|
+
drainControl(runId: string): Promise<Array<{
|
|
1518
|
+
ts: number;
|
|
1519
|
+
type: string;
|
|
1520
|
+
payload?: unknown;
|
|
1521
|
+
}>>;
|
|
1522
|
+
delete(runId: string): Promise<void>;
|
|
1523
|
+
private safe;
|
|
1524
|
+
private readIndex;
|
|
1525
|
+
private updateIndex;
|
|
1526
|
+
private removeFromIndex;
|
|
1527
|
+
}
|
|
1528
|
+
|
|
1529
|
+
interface SddBoardProjectorOptions {
|
|
1530
|
+
runId: string;
|
|
1531
|
+
graph: TaskGraph;
|
|
1532
|
+
tracker: TaskTracker;
|
|
1533
|
+
events: EventBus;
|
|
1534
|
+
/** Persist snapshots + JSONL events (optional — omit for in-memory only). */
|
|
1535
|
+
store?: SddBoardStore | undefined;
|
|
1536
|
+
specId?: string | undefined;
|
|
1537
|
+
/** Run-level default worker model/provider/fallbacks (shown in the board header). */
|
|
1538
|
+
defaultModel?: string | undefined;
|
|
1539
|
+
defaultProvider?: string | undefined;
|
|
1540
|
+
fallbackModels?: string[] | undefined;
|
|
1541
|
+
/** Base branch the run's squash commits land on (for the board + rollback). */
|
|
1542
|
+
baseBranch?: string | undefined;
|
|
1543
|
+
/** Snapshot coalescing window in ms (default 250). */
|
|
1544
|
+
throttleMs?: number | undefined;
|
|
1545
|
+
/** Clock injection for tests; defaults to Date.now. */
|
|
1546
|
+
now?: (() => number) | undefined;
|
|
1547
|
+
}
|
|
1548
|
+
declare class SddBoardProjector {
|
|
1549
|
+
private readonly o;
|
|
1550
|
+
private readonly now;
|
|
1551
|
+
private readonly throttleMs;
|
|
1552
|
+
private readonly shortId;
|
|
1553
|
+
private status;
|
|
1554
|
+
private wave;
|
|
1555
|
+
private startedAt;
|
|
1556
|
+
private deadlockChains;
|
|
1557
|
+
/** Live activity feed, most recent first (capped). */
|
|
1558
|
+
private feed;
|
|
1559
|
+
private static readonly FEED_CAP;
|
|
1560
|
+
private finished;
|
|
1561
|
+
private runDeadlocked;
|
|
1562
|
+
private runStopped;
|
|
1563
|
+
/** Squash commits the run landed on the base branch (for post-run rollback). */
|
|
1564
|
+
private mergedCommits;
|
|
1565
|
+
/** Base branch reported by the run at start (overrides the constructor option). */
|
|
1566
|
+
private runBaseBranch;
|
|
1567
|
+
private dirty;
|
|
1568
|
+
private timer;
|
|
1569
|
+
private readonly unsubs;
|
|
1570
|
+
/** Tail of in-flight persistence, so callers can await a settled state. */
|
|
1571
|
+
private lastSave;
|
|
1572
|
+
constructor(opts: SddBoardProjectorOptions);
|
|
1573
|
+
private pushFeed;
|
|
1574
|
+
/** ` (title…)` suffix for a feed line, or '' when the node/title is missing. */
|
|
1575
|
+
private titleOf;
|
|
1576
|
+
private assigneeOf;
|
|
1577
|
+
/** Latest snapshot, built on demand (e.g. for a late-joining client). */
|
|
1578
|
+
snapshot(): SddBoardSnapshot;
|
|
1579
|
+
/** Resolve once all in-flight snapshot persistence has settled. */
|
|
1580
|
+
drain(): Promise<void>;
|
|
1581
|
+
/** Stop projecting and release subscriptions. */
|
|
1582
|
+
dispose(): void;
|
|
1583
|
+
/** Subscribe to a run event scoped to this run id; also append to JSONL. */
|
|
1584
|
+
private onRun;
|
|
1585
|
+
private resolveStatus;
|
|
1586
|
+
private build;
|
|
1587
|
+
private markDirty;
|
|
1588
|
+
private flush;
|
|
1589
|
+
}
|
|
1590
|
+
|
|
1591
|
+
/**
|
|
1592
|
+
* Control surface over a live SDD run, exposed to every steering surface
|
|
1593
|
+
* (TUI, CLI-hosted webui in-process; standalone webui via a control file the
|
|
1594
|
+
* run drains). The run itself stays CLI-owned — this is the only sanctioned
|
|
1595
|
+
* way to pause / retry / reassign from outside the run loop.
|
|
1596
|
+
*/
|
|
1597
|
+
interface SddRunControl {
|
|
1598
|
+
runId: string;
|
|
1599
|
+
specId?: string | undefined;
|
|
1600
|
+
pause(): void;
|
|
1601
|
+
resume(): void;
|
|
1602
|
+
stop(): void;
|
|
1603
|
+
retryTask(taskId: string): boolean;
|
|
1604
|
+
/** Requeue every failed task to pending (board "Retry all failed"). Returns the count. */
|
|
1605
|
+
retryAllFailed(): number;
|
|
1606
|
+
reassignTask(taskId: string, agentName: string): boolean;
|
|
1607
|
+
/** Set/override a task's worker model (+ optional provider). Next dispatch. */
|
|
1608
|
+
setTaskModel(taskId: string, model: string | undefined, provider?: string | undefined): boolean;
|
|
1609
|
+
/** Set/override a task's fallback model chain. Next dispatch. */
|
|
1610
|
+
setTaskFallbacks(taskId: string, fallbackModels: string[] | undefined): boolean;
|
|
1611
|
+
/** Set/override a task's completion-gate verification command. Next dispatch. */
|
|
1612
|
+
setTaskVerification(taskId: string, verificationCommand: string | undefined): boolean;
|
|
1613
|
+
/** Cancel a task — abort it if running, else mark it cancelled. */
|
|
1614
|
+
cancelTask(taskId: string): Promise<boolean> | boolean;
|
|
1615
|
+
/** Delete a not-started task from the graph (refused while running). */
|
|
1616
|
+
deleteTask(taskId: string): boolean;
|
|
1617
|
+
/** Split a task into sub-tasks (refused while running). Returns the new leaf ids. */
|
|
1618
|
+
splitTask(taskId: string, subtasks: SddSubtaskSpec[]): string[];
|
|
1619
|
+
/**
|
|
1620
|
+
* Remove every git worktree + branch the run created (refused while running —
|
|
1621
|
+
* stop first). Returns the number removed.
|
|
1622
|
+
*/
|
|
1623
|
+
cleanupWorktrees(): Promise<number>;
|
|
1624
|
+
/**
|
|
1625
|
+
* Undo the run's merged commits by reverting each on the base branch (refused
|
|
1626
|
+
* while running). History-preserving; refuses on a dirty tree / revert conflict.
|
|
1627
|
+
*/
|
|
1628
|
+
rollback(): Promise<{
|
|
1629
|
+
ok: boolean;
|
|
1630
|
+
reverted: number;
|
|
1631
|
+
reason?: string;
|
|
1632
|
+
}>;
|
|
1633
|
+
/** Base branch the run's squash commits land on (worktree runs only). */
|
|
1634
|
+
getBaseBranch(): string | undefined;
|
|
1635
|
+
/** Squash commits the run landed on the base branch, in landing order. */
|
|
1636
|
+
getMergedCommits(): ReadonlyArray<{
|
|
1637
|
+
taskId: string;
|
|
1638
|
+
sha: string;
|
|
1639
|
+
title: string;
|
|
1640
|
+
}>;
|
|
1641
|
+
/** Latest board snapshot (built on demand). */
|
|
1642
|
+
snapshot(): SddBoardSnapshot;
|
|
1643
|
+
isRunning(): boolean;
|
|
1644
|
+
}
|
|
1645
|
+
/**
|
|
1646
|
+
* In-process registry of the active SDD run. One run is active at a time (a
|
|
1647
|
+
* single fleet drives it); a new run replaces the previous. Lives in the CLI
|
|
1648
|
+
* process where the fleet runs.
|
|
1649
|
+
*/
|
|
1650
|
+
declare class SddRunRegistry {
|
|
1651
|
+
private current;
|
|
1652
|
+
register(control: SddRunControl): void;
|
|
1653
|
+
clear(runId: string): void;
|
|
1654
|
+
getActive(): SddRunControl | null;
|
|
1655
|
+
}
|
|
1656
|
+
|
|
1657
|
+
interface SddInterviewDriverOptions {
|
|
1658
|
+
/** Disk-backed spec store (`wpaths.projectSpecs`). */
|
|
1659
|
+
specStore: SpecStore;
|
|
1660
|
+
/** Disk-backed task-graph store (`wpaths.projectTaskGraphs`). */
|
|
1661
|
+
graphStore: TaskGraphStore;
|
|
1662
|
+
/** Persist the interview session here so a reconnect can resume it. */
|
|
1663
|
+
sessionPath?: string | undefined;
|
|
1664
|
+
/** Project context string injected into the questioning prompt. */
|
|
1665
|
+
projectContext?: string | undefined;
|
|
1666
|
+
minQuestions?: number | undefined;
|
|
1667
|
+
maxQuestions?: number | undefined;
|
|
1668
|
+
}
|
|
1669
|
+
/** A serialisable view of the interview, streamed to observing surfaces. */
|
|
1670
|
+
interface SddInterviewSnapshot {
|
|
1671
|
+
sessionId: string;
|
|
1672
|
+
phase: AISpecPhase;
|
|
1673
|
+
title: string;
|
|
1674
|
+
questionCount: number;
|
|
1675
|
+
minQuestions: number;
|
|
1676
|
+
maxQuestions: number;
|
|
1677
|
+
answers: Array<{
|
|
1678
|
+
question: string;
|
|
1679
|
+
answer: string;
|
|
1680
|
+
}>;
|
|
1681
|
+
spec?: {
|
|
1682
|
+
id: string;
|
|
1683
|
+
title: string;
|
|
1684
|
+
overview: string;
|
|
1685
|
+
requirements: Array<{
|
|
1686
|
+
priority: string;
|
|
1687
|
+
description: string;
|
|
1688
|
+
}>;
|
|
1689
|
+
} | undefined;
|
|
1690
|
+
graphId?: string | undefined;
|
|
1691
|
+
taskCount: number;
|
|
1692
|
+
/**
|
|
1693
|
+
* Topologically-laid-out task graph (once decomposed) — lets the wizard
|
|
1694
|
+
* render the same animated DAG as the live board ("decomposition reveal").
|
|
1695
|
+
*/
|
|
1696
|
+
board?: {
|
|
1697
|
+
tasks: SddBoardTask[];
|
|
1698
|
+
columns: SddBoardColumn[];
|
|
1699
|
+
} | undefined;
|
|
1700
|
+
/** The current AI prompt for this phase (what to send the agent next). */
|
|
1701
|
+
prompt: string;
|
|
1702
|
+
}
|
|
1703
|
+
/** What `ingestAgentOutput` detected and acted on. */
|
|
1704
|
+
interface SddIngestResult {
|
|
1705
|
+
specDetected: boolean;
|
|
1706
|
+
implementationDetected: boolean;
|
|
1707
|
+
tasksDetected: boolean;
|
|
1708
|
+
graphId?: string | undefined;
|
|
1709
|
+
}
|
|
1710
|
+
declare class SddInterviewDriver {
|
|
1711
|
+
readonly builder: AISpecBuilder;
|
|
1712
|
+
private readonly o;
|
|
1713
|
+
private readonly minQuestions;
|
|
1714
|
+
private readonly maxQuestions;
|
|
1715
|
+
private tracker;
|
|
1716
|
+
private graph;
|
|
1717
|
+
constructor(opts: SddInterviewDriverOptions);
|
|
1718
|
+
/** Begin a fresh interview. Returns the first AI prompt (a question kickoff). */
|
|
1719
|
+
start(title: string, intent?: string): string;
|
|
1720
|
+
/**
|
|
1721
|
+
* Resume a previously-persisted interview from disk. Re-hydrates the task
|
|
1722
|
+
* graph too when one was already produced. Returns true if a session loaded.
|
|
1723
|
+
*/
|
|
1724
|
+
loadExisting(): Promise<boolean>;
|
|
1725
|
+
phase(): AISpecPhase;
|
|
1726
|
+
currentPrompt(): string;
|
|
1727
|
+
getTracker(): TaskTracker | null;
|
|
1728
|
+
getGraph(): TaskGraph | null;
|
|
1729
|
+
/** Record a Q/A pair (the agent asked `question`, the user replied `answer`). */
|
|
1730
|
+
submitAnswer(question: string, answer: string): void;
|
|
1731
|
+
/**
|
|
1732
|
+
* Feed the agent's text output back into the interview. Detects, in order:
|
|
1733
|
+
* 1. a Specification JSON → setSpec (phase → spec_review) + persist to SpecStore
|
|
1734
|
+
* 2. an implementation plan (implementation phase) → setImplementation
|
|
1735
|
+
* 3. a task JSON array → build + persist a TaskGraph
|
|
1736
|
+
* Each step is independent and best-effort; a malformed payload is ignored
|
|
1737
|
+
* rather than thrown, so a chatty agent turn never breaks the interview.
|
|
1738
|
+
*/
|
|
1739
|
+
ingestAgentOutput(text: string): Promise<SddIngestResult>;
|
|
1740
|
+
/**
|
|
1741
|
+
* Advance to the next phase (mirrors `/sdd approve`). When moving into the
|
|
1742
|
+
* executing phase, guarantees a task graph exists — deterministically
|
|
1743
|
+
* generating one from the approved spec if the agent never emitted a valid
|
|
1744
|
+
* task array. Returns the new phase and its AI prompt.
|
|
1745
|
+
*/
|
|
1746
|
+
approve(): Promise<{
|
|
1747
|
+
phase: AISpecPhase;
|
|
1748
|
+
prompt: string;
|
|
1749
|
+
}>;
|
|
1750
|
+
/**
|
|
1751
|
+
* Ensure a TaskGraph exists for the approved spec. If the agent already
|
|
1752
|
+
* produced one (via `ingestAgentOutput`), returns it; otherwise builds a
|
|
1753
|
+
* deterministic graph from the spec's requirements via TaskGenerator. This is
|
|
1754
|
+
* the robustness backstop: a run can always start, even if the model never
|
|
1755
|
+
* emitted a parseable task array.
|
|
1756
|
+
*/
|
|
1757
|
+
ensureTaskGraph(): Promise<TaskGraph | null>;
|
|
1758
|
+
snapshot(): SddInterviewSnapshot;
|
|
1759
|
+
private persistSpec;
|
|
1760
|
+
private persistGraph;
|
|
1761
|
+
/**
|
|
1762
|
+
* Port of the CLI `trySaveImplementationPlan` operating on this driver's
|
|
1763
|
+
* builder. Captures the prose plan that precedes the task JSON block.
|
|
1764
|
+
*/
|
|
1765
|
+
private trySaveImplementationPlan;
|
|
1766
|
+
/**
|
|
1767
|
+
* Port of the CLI `trySaveTasksFromAIOutput`: parse a task JSON array from the
|
|
1768
|
+
* agent output, build (or extend) the tracker + graph, persist to disk, and
|
|
1769
|
+
* link the graphId to the session. Returns the graphId on success.
|
|
1770
|
+
*/
|
|
1771
|
+
private tryBuildTasksFromOutput;
|
|
1772
|
+
}
|
|
1773
|
+
/**
|
|
1774
|
+
* True when the text reads like conversational filler rather than a structured
|
|
1775
|
+
* implementation plan. Ported verbatim from the CLI detection so behaviour is
|
|
1776
|
+
* identical across surfaces.
|
|
1777
|
+
*/
|
|
1778
|
+
declare function isExplanatoryText(text: string): boolean;
|
|
1779
|
+
|
|
1780
|
+
interface StartSddRunOptions {
|
|
1781
|
+
tracker: TaskTracker;
|
|
1782
|
+
graph: TaskGraph;
|
|
1783
|
+
/** Leader agent — seeds the default factory and the run's project context. */
|
|
1784
|
+
agent: Agent;
|
|
1785
|
+
projectRoot: string;
|
|
1786
|
+
events: EventBus;
|
|
1787
|
+
/** Per-task agent factory. Omit to run every task on the leader agent. */
|
|
1788
|
+
subagentFactory?: AgentFactory | undefined;
|
|
1789
|
+
/** Board snapshot/event persistence (also drained for cross-process control). */
|
|
1790
|
+
boardStore: SddBoardStore;
|
|
1791
|
+
/** Registry the run is registered with for in-process control. */
|
|
1792
|
+
registry?: SddRunRegistry | undefined;
|
|
1793
|
+
parallelSlots?: number | undefined;
|
|
1794
|
+
/** Opt-in hard wall-clock cap per task (ms). Omit → no cap (idle reaper guards). */
|
|
1795
|
+
taskTimeoutMs?: number | undefined;
|
|
1796
|
+
/** Idle reaper per task (ms); resets on activity. Default 600_000 (10 min). */
|
|
1797
|
+
taskIdleTimeoutMs?: number | undefined;
|
|
1798
|
+
/** End-of-run failed-task auto-retry sweeps (bounded). Default 2. */
|
|
1799
|
+
maxFailedRetrySweeps?: number | undefined;
|
|
1800
|
+
/** Post-task verification gate (forwarded to SddParallelRun). Omit → no gate. */
|
|
1801
|
+
verifyTask?: SddParallelRunOptions['verifyTask'];
|
|
1802
|
+
/** Merge-conflict resolver (forwarded to SddParallelRun). Omit → retry-on-fresh-base then fail. */
|
|
1803
|
+
conflictResolver?: SddParallelRunOptions['conflictResolver'];
|
|
1804
|
+
/** Failure supervisor (forwarded to SddParallelRun). Omit → no rescue, plain terminal-fail. */
|
|
1805
|
+
superviseFailure?: SddParallelRunOptions['superviseFailure'];
|
|
1806
|
+
/** Run-level default worker model / provider / fallback chain (task overrides win). */
|
|
1807
|
+
defaultModel?: string | undefined;
|
|
1808
|
+
defaultProvider?: string | undefined;
|
|
1809
|
+
fallbackModels?: string[] | undefined;
|
|
1810
|
+
/** Per-task git worktree isolation. Omit → tasks share the working tree. */
|
|
1811
|
+
worktrees?: WorktreeManager | undefined;
|
|
1812
|
+
/** Bounded deadlock recovery rounds (default 1). */
|
|
1813
|
+
maxRecoveryRounds?: number | undefined;
|
|
1814
|
+
/** Progress callback (e.g. CLI renderer line). */
|
|
1815
|
+
onProgress?: ((p: SddProgress) => void) | undefined;
|
|
1816
|
+
/** Control-file drain interval in ms (default 500). */
|
|
1817
|
+
controlDrainMs?: number | undefined;
|
|
1818
|
+
}
|
|
1819
|
+
interface SddRunHandle {
|
|
1820
|
+
run: SddParallelRun;
|
|
1821
|
+
runId: string;
|
|
1822
|
+
projector: SddBoardProjector;
|
|
1823
|
+
/** Resolves when the run finishes AND all teardown (drain/dispose/clear) is done. */
|
|
1824
|
+
completion: Promise<RunResult>;
|
|
1825
|
+
/** Request a clean stop (idempotent). */
|
|
1826
|
+
stop(): void;
|
|
1827
|
+
}
|
|
1828
|
+
/**
|
|
1829
|
+
* Wire up and start an SDD parallel run. Returns immediately with a handle whose
|
|
1830
|
+
* `completion` promise resolves once the run finishes and teardown is complete.
|
|
1831
|
+
* Orphaned in_progress tasks are reset up-front so a crashed prior run re-executes.
|
|
1832
|
+
*/
|
|
1833
|
+
declare function startSddRun(opts: StartSddRunOptions): SddRunHandle;
|
|
1834
|
+
|
|
1835
|
+
/** Force-remove every git worktree + branch a previous run left behind. */
|
|
1836
|
+
declare function cleanupSddWorktrees(projectRoot: string): Promise<{
|
|
1837
|
+
removed: number;
|
|
1838
|
+
}>;
|
|
1839
|
+
interface RollbackFromDiskOptions {
|
|
1840
|
+
projectRoot: string;
|
|
1841
|
+
/** Directory holding persisted board snapshots (`wpaths.projectSddBoards`). */
|
|
1842
|
+
boardsDir: string;
|
|
1843
|
+
/** Specific run to roll back. Omit → the most recently updated board. */
|
|
1844
|
+
runId?: string | undefined;
|
|
1845
|
+
}
|
|
1846
|
+
/**
|
|
1847
|
+
* Roll back a finished run's merged commits by reading its persisted board
|
|
1848
|
+
* snapshot (base branch + commit SHAs) and reverting each. History-preserving;
|
|
1849
|
+
* refuses on a dirty tree or revert conflict (surfaced in `reason`). Returns
|
|
1850
|
+
* `ok:false` with a reason when there is no board, no base branch, or nothing to
|
|
1851
|
+
* revert.
|
|
1852
|
+
*/
|
|
1853
|
+
declare function rollbackSddRunFromDisk(opts: RollbackFromDiskOptions): Promise<{
|
|
1854
|
+
ok: boolean;
|
|
1855
|
+
reverted: number;
|
|
1856
|
+
reason?: string;
|
|
1857
|
+
}>;
|
|
1858
|
+
interface DestroySddProjectOptions {
|
|
1859
|
+
projectRoot: string;
|
|
1860
|
+
/** Resolved wstack paths to delete. */
|
|
1861
|
+
paths: {
|
|
1862
|
+
projectSpecs: string;
|
|
1863
|
+
projectTaskGraphs: string;
|
|
1864
|
+
projectSddSession: string;
|
|
1865
|
+
projectSddBoards: string;
|
|
1866
|
+
};
|
|
1867
|
+
}
|
|
1868
|
+
interface DestroySddProjectResult {
|
|
1869
|
+
worktreesRemoved: number;
|
|
1870
|
+
/** Human labels of the artifacts that were deleted. */
|
|
1871
|
+
deleted: string[];
|
|
1872
|
+
}
|
|
1873
|
+
/**
|
|
1874
|
+
* Destroy an SDD project: clean every worktree + branch, then delete the on-disk
|
|
1875
|
+
* artifacts (specs, task-graphs, session, boards). Does NOT roll back git commits
|
|
1876
|
+
* — that is the separate, explicit `rollbackSddRunFromDisk`. Best-effort: a
|
|
1877
|
+
* missing path is simply skipped. The caller is responsible for stopping any
|
|
1878
|
+
* active run first.
|
|
1879
|
+
*/
|
|
1880
|
+
declare function destroySddProject(opts: DestroySddProjectOptions): Promise<DestroySddProjectResult>;
|
|
1881
|
+
|
|
1882
|
+
export { AISpecBuilder, type AISpecBuilderOptions, type AISpecPhase, type AISpecSession, AutoExecutor, type AutoExecutorOptions, type BottleneckTask, type CollectedAnswer, type CommandVerifierOptions, type ConflictSide, type CriticalPathAnalysis, DefaultTaskStore, type DestroySddProjectOptions, type DestroySddProjectResult, type ExecutionSummary, type GeneratedTask, type LlmConflictResolverOptions, type RollbackFromDiskOptions, type RunResult, SPEC_TEMPLATES, type SddBoardColumn, type SddBoardEvent, type SddBoardFeedEntry, type SddBoardIndexEntry, SddBoardProjector, type SddBoardProjectorOptions, type SddBoardSnapshot, type SddBoardStatus, SddBoardStore, type SddBoardStoreOptions, type SddBoardTask, type SddDeadlockChain, type SddIngestResult, SddInterviewDriver, type SddInterviewDriverOptions, type SddInterviewSnapshot, SddParallelRun, type SddParallelRunOptions, type SddProgress, type SddRunControl, type SddRunHandle, SddRunRegistry, type SddSubtaskSpec, SddSupervisor, type SddSupervisorOptions, type SddSupervisorVerdict, SddTaskDecomposer, type SddTaskDecomposerOptions, type SddTaskDisplayStatus, type SpecDiff, SpecDrivenDev, type SpecDrivenDevOptions, type SpecIndexEntry, SpecParser, SpecStore, type SpecStoreOptions, type SpecVersion, SpecVersioning, type StartSddRunOptions, type SubtaskGeneratorOptions, type TaskBatch, type TaskExecutionContext, type TaskExecutionResult, TaskFlow, type TaskFlowEventMap, type TaskFlowEventName, type TaskFlowExecutionContext, type TaskFlowOptions, type TaskFlowPhase, TaskGenerator, type TaskGeneratorOptions, type TaskGraphIndexEntry, TaskGraphStore, type TaskGraphStoreOptions, type TaskStore, TaskTracker, type TaskTrackerChange, type TaskTrackerListener, type TaskTrackerOptions, type TaskTransition, type WaveResult, analyzeCriticalPath, buildBoardSnapshot, buildBoardTasks, cleanupSddWorktrees, createAutoExecutor, destroySddProject, extractVerificationCommand, getTemplate, hasConflictMarkers, isExplanatoryText, listTemplates, makeCommandVerifier, makeLlmConflictResolver, makeLlmSubtaskGenerator, makePreferSideConflictResolver, renderProgress, renderSpecAnalysis, renderTaskGraph, renderTaskList, resolveConflictText, rollbackSddRunFromDisk, shortIdMap, startSddRun, templateToMarkdown };
|