@tagma/sdk 0.7.3 → 0.7.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (230) hide show
  1. package/README.md +85 -57
  2. package/dist/approval.d.ts +2 -12
  3. package/dist/approval.d.ts.map +1 -1
  4. package/dist/approval.js +1 -90
  5. package/dist/approval.js.map +1 -1
  6. package/dist/bootstrap.d.ts +1 -1
  7. package/dist/bootstrap.d.ts.map +1 -1
  8. package/dist/completions/file-exists.js +1 -1
  9. package/dist/completions/file-exists.js.map +1 -1
  10. package/dist/completions/output-check.d.ts.map +1 -1
  11. package/dist/completions/output-check.js +17 -4
  12. package/dist/completions/output-check.js.map +1 -1
  13. package/dist/config.d.ts +4 -4
  14. package/dist/config.d.ts.map +1 -1
  15. package/dist/config.js +2 -2
  16. package/dist/config.js.map +1 -1
  17. package/dist/dataflow.d.ts +3 -0
  18. package/dist/dataflow.d.ts.map +1 -0
  19. package/dist/dataflow.js +2 -0
  20. package/dist/dataflow.js.map +1 -0
  21. package/dist/drivers/opencode.d.ts.map +1 -1
  22. package/dist/drivers/opencode.js +23 -71
  23. package/dist/drivers/opencode.js.map +1 -1
  24. package/dist/engine.d.ts +5 -56
  25. package/dist/engine.d.ts.map +1 -1
  26. package/dist/engine.js +7 -297
  27. package/dist/engine.js.map +1 -1
  28. package/dist/index.d.ts +4 -6
  29. package/dist/index.d.ts.map +1 -1
  30. package/dist/index.js +2 -4
  31. package/dist/index.js.map +1 -1
  32. package/dist/logger.d.ts +2 -60
  33. package/dist/logger.d.ts.map +1 -1
  34. package/dist/logger.js +1 -153
  35. package/dist/logger.js.map +1 -1
  36. package/dist/middlewares/static-context.d.ts.map +1 -1
  37. package/dist/middlewares/static-context.js +1 -2
  38. package/dist/middlewares/static-context.js.map +1 -1
  39. package/dist/pipeline-runner.d.ts.map +1 -1
  40. package/dist/pipeline-runner.js +2 -2
  41. package/dist/pipeline-runner.js.map +1 -1
  42. package/dist/plugins.d.ts +2 -2
  43. package/dist/plugins.d.ts.map +1 -1
  44. package/dist/plugins.js +1 -1
  45. package/dist/plugins.js.map +1 -1
  46. package/dist/runner.d.ts +1 -35
  47. package/dist/runner.d.ts.map +1 -1
  48. package/dist/runner.js +1 -610
  49. package/dist/runner.js.map +1 -1
  50. package/dist/runtime/adapters/stdin-approval.d.ts +2 -0
  51. package/dist/runtime/adapters/stdin-approval.d.ts.map +1 -0
  52. package/dist/runtime/adapters/stdin-approval.js +2 -0
  53. package/dist/runtime/adapters/stdin-approval.js.map +1 -0
  54. package/dist/runtime/adapters/websocket-approval.d.ts +2 -0
  55. package/dist/runtime/adapters/websocket-approval.d.ts.map +1 -0
  56. package/dist/runtime/adapters/websocket-approval.js +2 -0
  57. package/dist/runtime/adapters/websocket-approval.js.map +1 -0
  58. package/dist/runtime/bun-process-runner.d.ts +2 -0
  59. package/dist/runtime/bun-process-runner.d.ts.map +1 -0
  60. package/dist/runtime/bun-process-runner.js +2 -0
  61. package/dist/runtime/bun-process-runner.js.map +1 -0
  62. package/dist/runtime.d.ts +2 -8
  63. package/dist/runtime.d.ts.map +1 -1
  64. package/dist/runtime.js +1 -7
  65. package/dist/runtime.js.map +1 -1
  66. package/dist/schema.d.ts.map +1 -1
  67. package/dist/schema.js +3 -4
  68. package/dist/schema.js.map +1 -1
  69. package/dist/tagma.d.ts +3 -4
  70. package/dist/tagma.d.ts.map +1 -1
  71. package/dist/tagma.js +2 -3
  72. package/dist/tagma.js.map +1 -1
  73. package/dist/triggers/file.d.ts.map +1 -1
  74. package/dist/triggers/file.js +74 -108
  75. package/dist/triggers/file.js.map +1 -1
  76. package/dist/triggers/manual.d.ts.map +1 -1
  77. package/dist/triggers/manual.js +1 -2
  78. package/dist/triggers/manual.js.map +1 -1
  79. package/dist/types.d.ts +1 -2
  80. package/dist/types.d.ts.map +1 -1
  81. package/dist/types.js +1 -12
  82. package/dist/types.js.map +1 -1
  83. package/dist/utils-api.d.ts +1 -1
  84. package/dist/utils-api.d.ts.map +1 -1
  85. package/dist/utils-api.js +1 -1
  86. package/dist/utils-api.js.map +1 -1
  87. package/dist/validate-raw.d.ts.map +1 -1
  88. package/dist/validate-raw.js +5 -12
  89. package/dist/validate-raw.js.map +1 -1
  90. package/package.json +20 -22
  91. package/dist/adapters/stdin-approval.d.ts +0 -6
  92. package/dist/adapters/stdin-approval.d.ts.map +0 -1
  93. package/dist/adapters/stdin-approval.js +0 -90
  94. package/dist/adapters/stdin-approval.js.map +0 -1
  95. package/dist/adapters/websocket-approval.d.ts +0 -28
  96. package/dist/adapters/websocket-approval.d.ts.map +0 -1
  97. package/dist/adapters/websocket-approval.js +0 -147
  98. package/dist/adapters/websocket-approval.js.map +0 -1
  99. package/dist/core/dataflow.d.ts +0 -23
  100. package/dist/core/dataflow.d.ts.map +0 -1
  101. package/dist/core/dataflow.js +0 -99
  102. package/dist/core/dataflow.js.map +0 -1
  103. package/dist/core/log-prune.d.ts +0 -16
  104. package/dist/core/log-prune.d.ts.map +0 -1
  105. package/dist/core/log-prune.js +0 -34
  106. package/dist/core/log-prune.js.map +0 -1
  107. package/dist/core/preflight.d.ts +0 -13
  108. package/dist/core/preflight.d.ts.map +0 -1
  109. package/dist/core/preflight.js +0 -61
  110. package/dist/core/preflight.js.map +0 -1
  111. package/dist/core/run-context.d.ts +0 -55
  112. package/dist/core/run-context.d.ts.map +0 -1
  113. package/dist/core/run-context.js +0 -158
  114. package/dist/core/run-context.js.map +0 -1
  115. package/dist/core/run-state.d.ts +0 -25
  116. package/dist/core/run-state.d.ts.map +0 -1
  117. package/dist/core/run-state.js +0 -93
  118. package/dist/core/run-state.js.map +0 -1
  119. package/dist/core/scheduler.d.ts +0 -13
  120. package/dist/core/scheduler.d.ts.map +0 -1
  121. package/dist/core/scheduler.js +0 -35
  122. package/dist/core/scheduler.js.map +0 -1
  123. package/dist/core/task-executor.d.ts +0 -13
  124. package/dist/core/task-executor.d.ts.map +0 -1
  125. package/dist/core/task-executor.js +0 -601
  126. package/dist/core/task-executor.js.map +0 -1
  127. package/dist/core/trigger-errors.d.ts +0 -9
  128. package/dist/core/trigger-errors.d.ts.map +0 -1
  129. package/dist/core/trigger-errors.js +0 -15
  130. package/dist/core/trigger-errors.js.map +0 -1
  131. package/dist/dag.d.ts +0 -45
  132. package/dist/dag.d.ts.map +0 -1
  133. package/dist/dag.js +0 -177
  134. package/dist/dag.js.map +0 -1
  135. package/dist/hooks.d.ts +0 -73
  136. package/dist/hooks.d.ts.map +0 -1
  137. package/dist/hooks.js +0 -106
  138. package/dist/hooks.js.map +0 -1
  139. package/dist/pipeline-definition.d.ts +0 -3
  140. package/dist/pipeline-definition.d.ts.map +0 -1
  141. package/dist/pipeline-definition.js +0 -4
  142. package/dist/pipeline-definition.js.map +0 -1
  143. package/dist/ports.d.ts +0 -196
  144. package/dist/ports.d.ts.map +0 -1
  145. package/dist/ports.js +0 -688
  146. package/dist/ports.js.map +0 -1
  147. package/dist/prompt-doc.d.ts +0 -70
  148. package/dist/prompt-doc.d.ts.map +0 -1
  149. package/dist/prompt-doc.js +0 -154
  150. package/dist/prompt-doc.js.map +0 -1
  151. package/dist/registry.d.ts +0 -67
  152. package/dist/registry.d.ts.map +0 -1
  153. package/dist/registry.js +0 -293
  154. package/dist/registry.js.map +0 -1
  155. package/dist/task-ref.d.ts +0 -55
  156. package/dist/task-ref.d.ts.map +0 -1
  157. package/dist/task-ref.js +0 -103
  158. package/dist/task-ref.js.map +0 -1
  159. package/dist/utils.d.ts +0 -13
  160. package/dist/utils.d.ts.map +0 -1
  161. package/dist/utils.js +0 -177
  162. package/dist/utils.js.map +0 -1
  163. package/src/adapters/stdin-approval.ts +0 -106
  164. package/src/adapters/websocket-approval.ts +0 -224
  165. package/src/approval.ts +0 -131
  166. package/src/bootstrap.ts +0 -55
  167. package/src/completions/exit-code.ts +0 -34
  168. package/src/completions/file-exists.ts +0 -66
  169. package/src/completions/output-check.test.ts +0 -50
  170. package/src/completions/output-check.ts +0 -92
  171. package/src/config-ops.test.ts +0 -70
  172. package/src/config-ops.ts +0 -328
  173. package/src/config.ts +0 -26
  174. package/src/core/dataflow.test.ts +0 -166
  175. package/src/core/dataflow.ts +0 -161
  176. package/src/core/log-prune.test.ts +0 -58
  177. package/src/core/log-prune.ts +0 -43
  178. package/src/core/preflight.test.ts +0 -49
  179. package/src/core/preflight.ts +0 -89
  180. package/src/core/run-context.test.ts +0 -256
  181. package/src/core/run-context.ts +0 -211
  182. package/src/core/run-state.test.ts +0 -98
  183. package/src/core/run-state.ts +0 -122
  184. package/src/core/scheduler.test.ts +0 -83
  185. package/src/core/scheduler.ts +0 -42
  186. package/src/core/task-executor.ts +0 -743
  187. package/src/core/trigger-errors.ts +0 -15
  188. package/src/dag.test.ts +0 -56
  189. package/src/dag.ts +0 -245
  190. package/src/drivers/opencode.ts +0 -410
  191. package/src/engine-ports-mixed.test.ts +0 -156
  192. package/src/engine-ports.test.ts +0 -166
  193. package/src/engine-task-type.test.ts +0 -56
  194. package/src/engine.ts +0 -458
  195. package/src/hooks.ts +0 -193
  196. package/src/index.ts +0 -33
  197. package/src/logger.ts +0 -182
  198. package/src/middlewares/static-context.ts +0 -49
  199. package/src/pipeline-definition.ts +0 -5
  200. package/src/pipeline-runner.test.ts +0 -91
  201. package/src/pipeline-runner.ts +0 -194
  202. package/src/plugin-registry.test.ts +0 -382
  203. package/src/plugins.ts +0 -21
  204. package/src/ports.test.ts +0 -678
  205. package/src/ports.ts +0 -925
  206. package/src/prompt-doc.test.ts +0 -174
  207. package/src/prompt-doc.ts +0 -169
  208. package/src/registry.ts +0 -353
  209. package/src/runner.test.ts +0 -142
  210. package/src/runner.ts +0 -666
  211. package/src/runtime.ts +0 -20
  212. package/src/schema-ports.test.ts +0 -172
  213. package/src/schema.test.ts +0 -213
  214. package/src/schema.ts +0 -379
  215. package/src/tagma.test.ts +0 -155
  216. package/src/tagma.ts +0 -62
  217. package/src/task-ref.test.ts +0 -401
  218. package/src/task-ref.ts +0 -121
  219. package/src/triggers/file.ts +0 -164
  220. package/src/triggers/manual.ts +0 -86
  221. package/src/types.ts +0 -18
  222. package/src/utils-api.ts +0 -8
  223. package/src/utils.test.ts +0 -28
  224. package/src/utils.ts +0 -203
  225. package/src/validate-raw-plugin-types.test.ts +0 -60
  226. package/src/validate-raw-ports.test.ts +0 -136
  227. package/src/validate-raw.ts +0 -852
  228. package/src/yaml-compiler.test.ts +0 -108
  229. package/src/yaml-compiler.ts +0 -110
  230. package/src/yaml.ts +0 -11
@@ -1,15 +0,0 @@
1
- export class TriggerBlockedError extends Error {
2
- readonly code = 'TRIGGER_BLOCKED' as const;
3
- constructor(message: string) {
4
- super(message);
5
- this.name = 'TriggerBlockedError';
6
- }
7
- }
8
-
9
- export class TriggerTimeoutError extends Error {
10
- readonly code = 'TRIGGER_TIMEOUT' as const;
11
- constructor(message: string) {
12
- super(message);
13
- this.name = 'TriggerTimeoutError';
14
- }
15
- }
package/src/dag.test.ts DELETED
@@ -1,56 +0,0 @@
1
- import { describe, expect, test } from 'bun:test';
2
- import { buildDag } from './dag';
3
- import type { PipelineConfig, TaskConfig, TrackConfig, Permissions } from './types';
4
-
5
- const PERMS: Permissions = { read: true, write: false, execute: false };
6
-
7
- function task(id: string, depends_on?: string[]): TaskConfig {
8
- return { id, name: id, prompt: 'x', permissions: PERMS, depends_on };
9
- }
10
-
11
- function track(id: string, tasks: TaskConfig[]): TrackConfig {
12
- return { id, name: id, driver: 'opencode', permissions: PERMS, tasks };
13
- }
14
-
15
- function pipeline(tasks: TaskConfig[]): PipelineConfig {
16
- return { name: 'test', tracks: [track('t', tasks)] };
17
- }
18
-
19
- function qid(id: string): string {
20
- return `t.${id}`;
21
- }
22
-
23
- describe('buildDag', () => {
24
- test('empty pipeline yields empty sorted array', () => {
25
- const dag = buildDag({ name: 'empty', tracks: [track('t', [])] });
26
- expect(dag.sorted).toEqual([]);
27
- expect(dag.nodes.size).toBe(0);
28
- });
29
-
30
- test('single node returns that node', () => {
31
- const dag = buildDag(pipeline([task('only')]));
32
- expect(dag.sorted).toEqual([qid('only')]);
33
- expect(dag.nodes.size).toBe(1);
34
- });
35
-
36
- test('linear chain A -> B -> C produces correct order', () => {
37
- const dag = buildDag(pipeline([task('a'), task('b', ['a']), task('c', ['b'])]));
38
- expect(dag.sorted).toEqual([qid('a'), qid('b'), qid('c')]);
39
- });
40
-
41
- test('diamond A -> B,C; B,C -> D: A first, D last, B/C in between', () => {
42
- const dag = buildDag(
43
- pipeline([task('a'), task('b', ['a']), task('c', ['a']), task('d', ['b', 'c'])]),
44
- );
45
- expect(dag.sorted[0]).toBe(qid('a'));
46
- expect(dag.sorted[dag.sorted.length - 1]).toBe(qid('d'));
47
- const mid = dag.sorted.slice(1, -1).sort();
48
- expect(mid).toEqual([qid('b'), qid('c')]);
49
- });
50
-
51
- test('cycle detection throws', () => {
52
- expect(() => buildDag(pipeline([task('a', ['b']), task('b', ['a'])]))).toThrow(
53
- /[Cc]ircular|cycle/,
54
- );
55
- });
56
- });
package/src/dag.ts DELETED
@@ -1,245 +0,0 @@
1
- import type {
2
- PipelineConfig,
3
- RawPipelineConfig,
4
- RawTaskConfig,
5
- TaskConfig,
6
- TrackConfig,
7
- } from './types';
8
- import { buildTaskIndex, qualifyTaskId, resolveTaskRef } from './task-ref';
9
-
10
- export interface DagNode {
11
- readonly taskId: string; // fully qualified: track_id.task_id or just task_id
12
- readonly task: TaskConfig;
13
- readonly track: TrackConfig;
14
- readonly dependsOn: readonly string[];
15
- /**
16
- * H1: `task.continue_from` may be written by users as a bare task id
17
- * (e.g. `review`) or a same-track shorthand. The driver needs the
18
- * fully-qualified upstream id to look up output/session/normalized maps
19
- * deterministically — bare lookups race when two tracks happen to share
20
- * a task name. dag.ts performs the qualification once, here, so the
21
- * engine never has to.
22
- */
23
- readonly resolvedContinueFrom?: string;
24
- }
25
-
26
- export interface Dag {
27
- readonly nodes: ReadonlyMap<string, DagNode>;
28
- readonly sorted: readonly string[]; // topological order
29
- }
30
-
31
- export function buildDag(config: PipelineConfig): Dag {
32
- const nodes = new Map<string, DagNode>();
33
-
34
- // 1. Register all nodes. Duplicates throw — same-track task-id collisions
35
- // would otherwise silently overwrite one another in the DAG.
36
- for (const track of config.tracks) {
37
- for (const task of track.tasks) {
38
- const qid = qualifyTaskId(track.id, task.id);
39
- if (nodes.has(qid)) {
40
- throw new Error(`Duplicate task ID: "${qid}"`);
41
- }
42
- nodes.set(qid, {
43
- taskId: qid,
44
- task,
45
- track,
46
- dependsOn: [], // filled below
47
- });
48
- }
49
- }
50
-
51
- // Shared index for ref resolution — same code path validate-raw uses.
52
- const index = buildTaskIndex(config);
53
-
54
- function resolveRef(ref: string, fromTrackId: string): string {
55
- const result = resolveTaskRef(ref, fromTrackId, index);
56
- if (result.kind === 'ambiguous') {
57
- throw new Error(
58
- `Ambiguous task reference "${ref}" exists in multiple tracks. ` +
59
- `Use "track_id.task_id" format.`,
60
- );
61
- }
62
- if (result.kind === 'not_found') {
63
- throw new Error(`Task reference "${ref}" not found`);
64
- }
65
- return result.qid;
66
- }
67
-
68
- // 2. Resolve depends_on and continue_from to qualified IDs
69
- for (const track of config.tracks) {
70
- for (const task of track.tasks) {
71
- const qid = qualifyTaskId(track.id, task.id);
72
- const deps: string[] = [];
73
- let resolvedContinueFrom: string | undefined;
74
-
75
- if (task.depends_on) {
76
- for (const dep of task.depends_on) {
77
- deps.push(resolveRef(dep, track.id));
78
- }
79
- }
80
- if (task.continue_from) {
81
- // Preserve the ambiguous-vs-not-found distinction in the user-facing
82
- // error: rewording "ambiguous" as "no such task found" (the previous
83
- // behavior) hid the real problem and sent users searching for a
84
- // missing task that actually existed in two places.
85
- const result = resolveTaskRef(task.continue_from, track.id, index);
86
- if (result.kind === 'ambiguous') {
87
- throw new Error(
88
- `Task "${qid}": continue_from "${task.continue_from}" is ambiguous — ` +
89
- `multiple tracks have a task with this id. Use the fully-qualified ` +
90
- `form "trackId.${task.continue_from}".`,
91
- );
92
- }
93
- if (result.kind === 'not_found') {
94
- throw new Error(
95
- `Task "${qid}": continue_from "${task.continue_from}" — no such task found. ` +
96
- `Use a fully-qualified reference (trackId.taskId) or ensure the target task exists.`,
97
- );
98
- }
99
- resolvedContinueFrom = result.qid;
100
- if (!deps.includes(result.qid)) {
101
- deps.push(result.qid); // continue_from implies dependency
102
- }
103
- }
104
-
105
- // Replace node with resolved deps + qualified continue_from.
106
- const node = nodes.get(qid)!;
107
- nodes.set(qid, { ...node, dependsOn: deps, resolvedContinueFrom });
108
- }
109
- }
110
-
111
- // 3. Topological sort + cycle detection (Kahn's algorithm)
112
- const inDegree = new Map<string, number>();
113
- const adjacency = new Map<string, string[]>(); // parent → children
114
-
115
- for (const [id] of nodes) {
116
- inDegree.set(id, 0);
117
- adjacency.set(id, []);
118
- }
119
-
120
- for (const [id, node] of nodes) {
121
- for (const dep of node.dependsOn) {
122
- adjacency.get(dep)!.push(id);
123
- inDegree.set(id, (inDegree.get(id) ?? 0) + 1);
124
- }
125
- }
126
-
127
- // D20: deterministic topo order. Kahn's algorithm dequeues in insertion
128
- // order by default, which depends on map iteration order — itself a
129
- // function of the (track, task) order in the YAML. Two pipelines that
130
- // are DAG-equivalent but written in a different order produced different
131
- // `sorted` arrays, leading to subtle run-to-run non-determinism for
132
- // parallel tasks with side effects (writing the same file, touching the
133
- // same repo). Break the tie by qualified id so identical DAG shapes
134
- // always yield identical schedules across machines and across YAML
135
- // round-trips.
136
- const ready: string[] = [];
137
- for (const [id, degree] of inDegree) {
138
- if (degree === 0) ready.push(id);
139
- }
140
- ready.sort();
141
-
142
- const sorted: string[] = [];
143
- let qi = 0;
144
- while (qi < ready.length) {
145
- const current = ready[qi++]!;
146
- sorted.push(current);
147
- // Collect children whose in-degree hits zero in this step, then push
148
- // them into the ready bucket in sorted order — keeps each "wave" of
149
- // parallel-eligible tasks ordered by qid.
150
- const newlyReady: string[] = [];
151
- for (const child of adjacency.get(current)!) {
152
- const newDegree = inDegree.get(child)! - 1;
153
- inDegree.set(child, newDegree);
154
- if (newDegree === 0) newlyReady.push(child);
155
- }
156
- if (newlyReady.length > 1) newlyReady.sort();
157
- for (const child of newlyReady) ready.push(child);
158
- }
159
-
160
- if (sorted.length !== nodes.size) {
161
- // Only report nodes that are actually part of cycles (in-degree > 0
162
- // after Kahn's algorithm), not their downstream dependents.
163
- const sortedSet = new Set(sorted);
164
- const cycleMembers = [...nodes.keys()].filter(
165
- (id) => !sortedSet.has(id) && (inDegree.get(id) ?? 0) > 0,
166
- );
167
- throw new Error(`Circular dependency detected involving tasks: ${cycleMembers.join(', ')}`);
168
- }
169
-
170
- return { nodes, sorted };
171
- }
172
-
173
- // ═══ Raw DAG (for visual editor — no workDir required) ═══
174
-
175
- export interface RawDagNode {
176
- readonly taskId: string; // fully qualified: track_id.task_id
177
- readonly trackId: string;
178
- readonly rawTask: RawTaskConfig;
179
- readonly dependsOn: readonly string[]; // fully qualified IDs, best-effort resolved
180
- }
181
-
182
- export interface RawDag {
183
- readonly nodes: ReadonlyMap<string, RawDagNode>;
184
- /** Directed edges: from → to means "from must complete before to starts" */
185
- readonly edges: readonly { readonly from: string; readonly to: string }[];
186
- }
187
-
188
- /**
189
- * Build a lightweight DAG from a raw (unresolved) pipeline config.
190
- * Unlike buildDag, this function:
191
- * - Does not require a workDir or resolved PipelineConfig
192
- * - Is lenient: missing or ambiguous refs are silently skipped
193
- *
194
- * Intended for the visual editor to render the flow graph before a pipeline is run.
195
- */
196
- export function buildRawDag(config: RawPipelineConfig): RawDag {
197
- const nodes = new Map<string, RawDagNode>();
198
-
199
- // 1. Register all concrete tasks. Duplicates are skipped (not thrown) so
200
- // partially-typed editor state doesn't produce a hard error.
201
- for (const track of config.tracks) {
202
- for (const task of track.tasks) {
203
- const qid = qualifyTaskId(track.id, task.id);
204
- if (nodes.has(qid)) continue;
205
- nodes.set(qid, { taskId: qid, trackId: track.id, rawTask: task, dependsOn: [] });
206
- }
207
- }
208
-
209
- const index = buildTaskIndex(config);
210
-
211
- function tryResolve(ref: string, fromTrackId: string): string | null {
212
- const result = resolveTaskRef(ref, fromTrackId, index);
213
- return result.kind === 'resolved' ? result.qid : null;
214
- }
215
-
216
- // 2. Resolve dependency refs leniently (missing / ambiguous refs are skipped)
217
- const edges: { from: string; to: string }[] = [];
218
-
219
- for (const track of config.tracks) {
220
- for (const task of track.tasks) {
221
- const qid = qualifyTaskId(track.id, task.id);
222
- const deps: string[] = [];
223
-
224
- for (const ref of task.depends_on ?? []) {
225
- const resolved = tryResolve(ref, track.id);
226
- if (resolved && !deps.includes(resolved)) {
227
- deps.push(resolved);
228
- edges.push({ from: resolved, to: qid });
229
- }
230
- }
231
- if (task.continue_from) {
232
- const resolved = tryResolve(task.continue_from, track.id);
233
- if (resolved && !deps.includes(resolved)) {
234
- deps.push(resolved);
235
- edges.push({ from: resolved, to: qid });
236
- }
237
- }
238
-
239
- const node = nodes.get(qid)!;
240
- nodes.set(qid, { ...node, dependsOn: deps });
241
- }
242
- }
243
-
244
- return { nodes, edges };
245
- }