@tagma/sdk 0.6.4 → 0.6.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 (73) hide show
  1. package/README.md +8 -5
  2. package/dist/dag.test.d.ts +2 -0
  3. package/dist/dag.test.d.ts.map +1 -0
  4. package/dist/dag.test.js +42 -0
  5. package/dist/dag.test.js.map +1 -0
  6. package/dist/engine-ports.test.d.ts +2 -0
  7. package/dist/engine-ports.test.d.ts.map +1 -0
  8. package/dist/engine-ports.test.js +378 -0
  9. package/dist/engine-ports.test.js.map +1 -0
  10. package/dist/engine.d.ts.map +1 -1
  11. package/dist/engine.js +194 -21
  12. package/dist/engine.js.map +1 -1
  13. package/dist/pipeline-runner.d.ts.map +1 -1
  14. package/dist/pipeline-runner.js +3 -0
  15. package/dist/pipeline-runner.js.map +1 -1
  16. package/dist/ports.d.ts +118 -0
  17. package/dist/ports.d.ts.map +1 -0
  18. package/dist/ports.js +365 -0
  19. package/dist/ports.js.map +1 -0
  20. package/dist/ports.test.d.ts +2 -0
  21. package/dist/ports.test.d.ts.map +1 -0
  22. package/dist/ports.test.js +262 -0
  23. package/dist/ports.test.js.map +1 -0
  24. package/dist/prompt-doc.d.ts +35 -1
  25. package/dist/prompt-doc.d.ts.map +1 -1
  26. package/dist/prompt-doc.js +110 -0
  27. package/dist/prompt-doc.js.map +1 -1
  28. package/dist/prompt-doc.test.d.ts +2 -0
  29. package/dist/prompt-doc.test.d.ts.map +1 -0
  30. package/dist/prompt-doc.test.js +145 -0
  31. package/dist/prompt-doc.test.js.map +1 -0
  32. package/dist/runner.d.ts +17 -0
  33. package/dist/runner.d.ts.map +1 -1
  34. package/dist/runner.js +171 -8
  35. package/dist/runner.js.map +1 -1
  36. package/dist/runner.test.d.ts +2 -0
  37. package/dist/runner.test.d.ts.map +1 -0
  38. package/dist/runner.test.js +119 -0
  39. package/dist/runner.test.js.map +1 -0
  40. package/dist/schema-ports.test.d.ts +2 -0
  41. package/dist/schema-ports.test.d.ts.map +1 -0
  42. package/dist/schema-ports.test.js +219 -0
  43. package/dist/schema-ports.test.js.map +1 -0
  44. package/dist/schema.d.ts.map +1 -1
  45. package/dist/schema.js +8 -0
  46. package/dist/schema.js.map +1 -1
  47. package/dist/sdk.d.ts +3 -1
  48. package/dist/sdk.d.ts.map +1 -1
  49. package/dist/sdk.js +5 -1
  50. package/dist/sdk.js.map +1 -1
  51. package/dist/validate-raw-ports.test.d.ts +2 -0
  52. package/dist/validate-raw-ports.test.d.ts.map +1 -0
  53. package/dist/validate-raw-ports.test.js +157 -0
  54. package/dist/validate-raw-ports.test.js.map +1 -0
  55. package/dist/validate-raw.d.ts.map +1 -1
  56. package/dist/validate-raw.js +141 -0
  57. package/dist/validate-raw.js.map +1 -1
  58. package/package.json +2 -7
  59. package/src/dag.test.ts +56 -0
  60. package/src/engine-ports.test.ts +404 -0
  61. package/src/engine.ts +231 -24
  62. package/src/pipeline-runner.ts +3 -0
  63. package/src/ports.test.ts +301 -0
  64. package/src/ports.ts +442 -0
  65. package/src/prompt-doc.test.ts +174 -0
  66. package/src/prompt-doc.ts +121 -1
  67. package/src/runner.test.ts +142 -0
  68. package/src/runner.ts +198 -8
  69. package/src/schema-ports.test.ts +236 -0
  70. package/src/schema.ts +8 -0
  71. package/src/sdk.ts +14 -0
  72. package/src/validate-raw-ports.test.ts +198 -0
  73. package/src/validate-raw.ts +155 -1
@@ -0,0 +1,118 @@
1
+ import type { TaskConfig, TaskPorts } from './types';
2
+ /**
3
+ * Scan `text` for every `{{inputs.<name>}}` placeholder and return the
4
+ * set of referenced input names. Useful at validation time: the editor
5
+ * can cross-check that each placeholder has a corresponding declared
6
+ * port and flag typos before a run ever starts.
7
+ */
8
+ export declare function extractInputReferences(text: string): string[];
9
+ export interface SubstituteResult {
10
+ readonly text: string;
11
+ /** Port names that appeared in placeholders but weren't in `inputs`. */
12
+ readonly unresolved: readonly string[];
13
+ }
14
+ /**
15
+ * Replace `{{inputs.<name>}}` placeholders in `text` with values from
16
+ * `inputs`. Coercion:
17
+ * - string → as-is
18
+ * - number / boolean → `String(value)`
19
+ * - null / undefined → empty string (name is also reported as unresolved)
20
+ * - anything else (object, array, json port) → `JSON.stringify(value)`
21
+ *
22
+ * Values are substituted *verbatim* — quoting is the user's
23
+ * responsibility in the authored text. For command lines that interpolate
24
+ * user-provided strings, authors should wrap the placeholder in quotes:
25
+ *
26
+ * weather.sh --city "{{inputs.city}}"
27
+ *
28
+ * That's a documented contract rather than a silent shell-escape, because
29
+ * silent escaping would hide the difference between `--city Shanghai` and
30
+ * `--flag $(echo pwned)` — both valid command fragments, one a bug, one a
31
+ * feature. Users know which they want; the engine doesn't.
32
+ */
33
+ export declare function substituteInputs(text: string, inputs: Readonly<Record<string, unknown>>): SubstituteResult;
34
+ export type InputResolution = {
35
+ readonly kind: 'ready';
36
+ readonly inputs: Readonly<Record<string, unknown>>;
37
+ /**
38
+ * Optional inputs that had no upstream producer and no default;
39
+ * they are absent from `inputs` (so placeholders render empty).
40
+ * Separate from `missingRequired` so the engine can log softly
41
+ * without blocking the task.
42
+ */
43
+ readonly missingOptional: readonly string[];
44
+ } | {
45
+ readonly kind: 'blocked';
46
+ /** Required port names that could not be satisfied. */
47
+ readonly missingRequired: readonly string[];
48
+ /** Port names with multiple ambiguous producers. */
49
+ readonly ambiguous: readonly {
50
+ port: string;
51
+ producers: readonly string[];
52
+ }[];
53
+ /** Port names whose resolved value failed type coercion. */
54
+ readonly typeErrors: readonly {
55
+ port: string;
56
+ reason: string;
57
+ }[];
58
+ /** Human-readable multi-line description for the engine to log. */
59
+ readonly reason: string;
60
+ };
61
+ /**
62
+ * Resolve the input values for `task` from the outputs its direct
63
+ * upstreams produced.
64
+ *
65
+ * `upstreamOutputs` is keyed by fully-qualified task id and maps to the
66
+ * outputs that task published (its `TaskResult.outputs`). `dependsOn` is
67
+ * the already-qualified dependency list (from `DagNode.dependsOn`). When
68
+ * an upstream has no outputs entry (e.g. it didn't declare any or it
69
+ * failed), its entry may be missing — we just skip it during matching.
70
+ *
71
+ * Matching rules:
72
+ * - If the input port has `from: "taskId.portName"` → look up that
73
+ * specific upstream / port. Missing = unsatisfied.
74
+ * - If it has `from: "portName"` (bare) → treat as explicit port name
75
+ * but allow any upstream to provide it (useful when the user wants
76
+ * to match by name but still be explicit about the intent).
77
+ * - If no `from` → scan every upstream's outputs for a key matching
78
+ * the input name. Zero hits = unsatisfied; 2+ hits across different
79
+ * upstreams = ambiguous.
80
+ *
81
+ * The function never throws on config errors — every failure mode maps
82
+ * to a field of the `blocked` result so the engine can log a unified
83
+ * message and mark the task blocked.
84
+ */
85
+ export declare function resolveTaskInputs(task: TaskConfig, upstreamOutputs: ReadonlyMap<string, Readonly<Record<string, unknown>>>, dependsOn: readonly string[]): InputResolution;
86
+ export interface ExtractResult {
87
+ /** Coerced values keyed by port name. Ports that failed to resolve are absent. */
88
+ readonly outputs: Readonly<Record<string, unknown>>;
89
+ /**
90
+ * Human-readable diagnostic describing what went wrong, if anything.
91
+ * `null` when every declared output was resolved cleanly. The engine
92
+ * appends this to stderr so the pipeline log explains why downstream
93
+ * inputs are missing.
94
+ */
95
+ readonly diagnostic: string | null;
96
+ }
97
+ /**
98
+ * Extract declared outputs from a terminated task's output streams.
99
+ *
100
+ * Strategy (v1 — intentionally dumb but predictable):
101
+ * 1. Prefer `normalizedOutput` when provided (AI drivers populate this
102
+ * with the canonical assistant message; it's much cleaner than raw
103
+ * stdout, which often has JSONL event dumps). Fall back to stdout
104
+ * otherwise.
105
+ * 2. Scan from the end for the first non-empty line. If it parses as a
106
+ * JSON object, use that as the source record.
107
+ * 3. If (2) fails, try parsing the entire source as JSON (supports
108
+ * commands that pretty-print with line breaks).
109
+ * 4. For each declared output port, read the matching key and coerce
110
+ * to the declared type. Coercion failures produce a diagnostic and
111
+ * the port is absent from `outputs` (treated as missing downstream).
112
+ *
113
+ * When no declared outputs are present this returns an empty `outputs`
114
+ * map and null diagnostic — the engine interprets that as "task has no
115
+ * port contract".
116
+ */
117
+ export declare function extractTaskOutputs(ports: TaskPorts | undefined, stdout: string, normalizedOutput: string | null): ExtractResult;
118
+ //# sourceMappingURL=ports.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ports.d.ts","sourceRoot":"","sources":["../src/ports.ts"],"names":[],"mappings":"AA2BA,OAAO,KAAK,EAAW,UAAU,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAa9D;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAM7D;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,wEAAwE;IACxE,QAAQ,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE,CAAC;CACxC;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GACxC,gBAAgB,CAwBlB;AAID,MAAM,MAAM,eAAe,GACvB;IACE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACnD;;;;;OAKG;IACH,QAAQ,CAAC,eAAe,EAAE,SAAS,MAAM,EAAE,CAAC;CAC7C,GACD;IACE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,uDAAuD;IACvD,QAAQ,CAAC,eAAe,EAAE,SAAS,MAAM,EAAE,CAAC;IAC5C,oDAAoD;IACpD,QAAQ,CAAC,SAAS,EAAE,SAAS;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,SAAS,MAAM,EAAE,CAAA;KAAE,EAAE,CAAC;IAC9E,4DAA4D;IAC5D,QAAQ,CAAC,UAAU,EAAE,SAAS;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACjE,mEAAmE;IACnE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB,CAAC;AAEN;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,UAAU,EAChB,eAAe,EAAE,WAAW,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,EACvE,SAAS,EAAE,SAAS,MAAM,EAAE,GAC3B,eAAe,CAyEjB;AAuGD,MAAM,WAAW,aAAa;IAC5B,kFAAkF;IAClF,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACpD;;;;;OAKG;IACH,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CACpC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,SAAS,GAAG,SAAS,EAC5B,MAAM,EAAE,MAAM,EACd,gBAAgB,EAAE,MAAM,GAAG,IAAI,GAC9B,aAAa,CAiCf"}
package/dist/ports.js ADDED
@@ -0,0 +1,365 @@
1
+ // ═══ Task ports: substitute / resolve / extract ═══
2
+ //
3
+ // One module, three concerns, all keyed on `task.ports`:
4
+ //
5
+ // 1. `substituteInputs(text, inputs)` — expand `{{inputs.<name>}}` in
6
+ // user-authored strings (command lines, prompts). Strict syntax, no
7
+ // arbitrary expressions — the placeholder is a thin pasteboard, not
8
+ // a templating engine. Unknown / undefined references render as empty
9
+ // string with a diagnostic that the caller can surface.
10
+ //
11
+ // 2. `resolveTaskInputs(task, upstreamOutputs, dependsOn)` — gather the
12
+ // values a task will consume from its direct upstreams. Matches by
13
+ // port name (or by explicit `from:`), applies defaults, coerces to
14
+ // the declared type, and classifies the result as ready / missing
15
+ // required / ambiguous. The engine calls this before a task starts
16
+ // and uses the classification to decide whether to block.
17
+ //
18
+ // 3. `extractTaskOutputs(ports, stdout, normalizedOutput)` — after a
19
+ // task succeeds, pull the declared output values from the task's
20
+ // output stream. Default strategy: find the last non-empty line that
21
+ // parses as a JSON object, and read each declared output name from
22
+ // it. Prefer `normalizedOutput` for AI tasks, fall back to raw
23
+ // stdout — command tasks only ever have stdout.
24
+ //
25
+ // Everything here is pure / deterministic so it can be reused by the CLI,
26
+ // the editor (for preview/simulation), and the engine without side effects.
27
+ // ─── Template substitution ────────────────────────────────────────────
28
+ /**
29
+ * Matches `{{inputs.<identifier>}}` with optional whitespace inside the
30
+ * braces. The identifier is restricted to the same character set we use
31
+ * for task IDs (letter/underscore, then letters/digits/underscores) so
32
+ * accidental use of `{{inputs.foo.bar}}` fails loudly rather than
33
+ * silently producing garbage.
34
+ */
35
+ const PLACEHOLDER_RE = /\{\{\s*inputs\.([A-Za-z_][A-Za-z0-9_]*)\s*\}\}/g;
36
+ /**
37
+ * Scan `text` for every `{{inputs.<name>}}` placeholder and return the
38
+ * set of referenced input names. Useful at validation time: the editor
39
+ * can cross-check that each placeholder has a corresponding declared
40
+ * port and flag typos before a run ever starts.
41
+ */
42
+ export function extractInputReferences(text) {
43
+ const names = new Set();
44
+ for (const match of text.matchAll(PLACEHOLDER_RE)) {
45
+ names.add(match[1]);
46
+ }
47
+ return [...names];
48
+ }
49
+ /**
50
+ * Replace `{{inputs.<name>}}` placeholders in `text` with values from
51
+ * `inputs`. Coercion:
52
+ * - string → as-is
53
+ * - number / boolean → `String(value)`
54
+ * - null / undefined → empty string (name is also reported as unresolved)
55
+ * - anything else (object, array, json port) → `JSON.stringify(value)`
56
+ *
57
+ * Values are substituted *verbatim* — quoting is the user's
58
+ * responsibility in the authored text. For command lines that interpolate
59
+ * user-provided strings, authors should wrap the placeholder in quotes:
60
+ *
61
+ * weather.sh --city "{{inputs.city}}"
62
+ *
63
+ * That's a documented contract rather than a silent shell-escape, because
64
+ * silent escaping would hide the difference between `--city Shanghai` and
65
+ * `--flag $(echo pwned)` — both valid command fragments, one a bug, one a
66
+ * feature. Users know which they want; the engine doesn't.
67
+ */
68
+ export function substituteInputs(text, inputs) {
69
+ const unresolved = new Set();
70
+ const out = text.replace(PLACEHOLDER_RE, (_full, name) => {
71
+ if (!(name in inputs)) {
72
+ unresolved.add(name);
73
+ return '';
74
+ }
75
+ const value = inputs[name];
76
+ if (value === null || value === undefined) {
77
+ unresolved.add(name);
78
+ return '';
79
+ }
80
+ if (typeof value === 'string')
81
+ return value;
82
+ if (typeof value === 'number' || typeof value === 'boolean')
83
+ return String(value);
84
+ try {
85
+ return JSON.stringify(value);
86
+ }
87
+ catch {
88
+ // Circular / unserializable — render a placeholder rather than
89
+ // throwing, and mark it unresolved so the caller can warn.
90
+ unresolved.add(name);
91
+ return '';
92
+ }
93
+ });
94
+ return { text: out, unresolved: [...unresolved] };
95
+ }
96
+ /**
97
+ * Resolve the input values for `task` from the outputs its direct
98
+ * upstreams produced.
99
+ *
100
+ * `upstreamOutputs` is keyed by fully-qualified task id and maps to the
101
+ * outputs that task published (its `TaskResult.outputs`). `dependsOn` is
102
+ * the already-qualified dependency list (from `DagNode.dependsOn`). When
103
+ * an upstream has no outputs entry (e.g. it didn't declare any or it
104
+ * failed), its entry may be missing — we just skip it during matching.
105
+ *
106
+ * Matching rules:
107
+ * - If the input port has `from: "taskId.portName"` → look up that
108
+ * specific upstream / port. Missing = unsatisfied.
109
+ * - If it has `from: "portName"` (bare) → treat as explicit port name
110
+ * but allow any upstream to provide it (useful when the user wants
111
+ * to match by name but still be explicit about the intent).
112
+ * - If no `from` → scan every upstream's outputs for a key matching
113
+ * the input name. Zero hits = unsatisfied; 2+ hits across different
114
+ * upstreams = ambiguous.
115
+ *
116
+ * The function never throws on config errors — every failure mode maps
117
+ * to a field of the `blocked` result so the engine can log a unified
118
+ * message and mark the task blocked.
119
+ */
120
+ export function resolveTaskInputs(task, upstreamOutputs, dependsOn) {
121
+ const inputsDecl = task.ports?.inputs;
122
+ if (!inputsDecl || inputsDecl.length === 0) {
123
+ return { kind: 'ready', inputs: {}, missingOptional: [] };
124
+ }
125
+ const inputs = {};
126
+ const missingRequired = [];
127
+ const missingOptional = [];
128
+ const ambiguous = [];
129
+ const typeErrors = [];
130
+ for (const port of inputsDecl) {
131
+ const found = findUpstreamValue(port, upstreamOutputs, dependsOn);
132
+ if (found.kind === 'ambiguous') {
133
+ ambiguous.push({ port: port.name, producers: found.producers });
134
+ continue;
135
+ }
136
+ let value;
137
+ let present = false;
138
+ if (found.kind === 'hit') {
139
+ value = found.value;
140
+ present = true;
141
+ }
142
+ else if (port.default !== undefined) {
143
+ value = port.default;
144
+ present = true;
145
+ }
146
+ if (!present) {
147
+ if (port.required === true) {
148
+ missingRequired.push(port.name);
149
+ }
150
+ else {
151
+ missingOptional.push(port.name);
152
+ }
153
+ continue;
154
+ }
155
+ const coerced = coerceValue(port, value);
156
+ if (coerced.kind === 'error') {
157
+ typeErrors.push({ port: port.name, reason: coerced.reason });
158
+ continue;
159
+ }
160
+ inputs[port.name] = coerced.value;
161
+ }
162
+ if (missingRequired.length > 0 || ambiguous.length > 0 || typeErrors.length > 0) {
163
+ const lines = [];
164
+ if (missingRequired.length > 0) {
165
+ lines.push(`missing required input(s): ${missingRequired.join(', ')}`);
166
+ }
167
+ if (ambiguous.length > 0) {
168
+ for (const amb of ambiguous) {
169
+ lines.push(`input "${amb.port}" is produced by multiple upstreams ` +
170
+ `(${amb.producers.join(', ')}) — disambiguate with "from: taskId.${amb.port}"`);
171
+ }
172
+ }
173
+ if (typeErrors.length > 0) {
174
+ for (const te of typeErrors) {
175
+ lines.push(`input "${te.port}": ${te.reason}`);
176
+ }
177
+ }
178
+ return {
179
+ kind: 'blocked',
180
+ missingRequired,
181
+ ambiguous,
182
+ typeErrors,
183
+ reason: lines.join('\n'),
184
+ };
185
+ }
186
+ return { kind: 'ready', inputs, missingOptional };
187
+ }
188
+ function findUpstreamValue(port, upstreamOutputs, dependsOn) {
189
+ // Explicit fully-qualified binding: "taskId.portName"
190
+ if (port.from && port.from.includes('.')) {
191
+ const dot = port.from.lastIndexOf('.');
192
+ const upstreamId = port.from.slice(0, dot);
193
+ const portName = port.from.slice(dot + 1);
194
+ const upstream = upstreamOutputs.get(upstreamId);
195
+ if (upstream && portName in upstream) {
196
+ return { kind: 'hit', producer: upstreamId, value: upstream[portName] };
197
+ }
198
+ return { kind: 'miss' };
199
+ }
200
+ // Name match (either explicit `from: "portName"` or defaulted to port.name)
201
+ const key = port.from ?? port.name;
202
+ const hits = [];
203
+ for (const upstreamId of dependsOn) {
204
+ const upstream = upstreamOutputs.get(upstreamId);
205
+ if (upstream && key in upstream) {
206
+ hits.push({ producer: upstreamId, value: upstream[key] });
207
+ }
208
+ }
209
+ if (hits.length === 0)
210
+ return { kind: 'miss' };
211
+ if (hits.length === 1)
212
+ return { kind: 'hit', producer: hits[0].producer, value: hits[0].value };
213
+ return { kind: 'ambiguous', producers: hits.map((h) => h.producer) };
214
+ }
215
+ function coerceValue(port, raw) {
216
+ switch (port.type) {
217
+ case 'string': {
218
+ if (typeof raw === 'string')
219
+ return { kind: 'ok', value: raw };
220
+ if (typeof raw === 'number' || typeof raw === 'boolean') {
221
+ return { kind: 'ok', value: String(raw) };
222
+ }
223
+ return { kind: 'error', reason: `expected string, got ${describe(raw)}` };
224
+ }
225
+ case 'number': {
226
+ if (typeof raw === 'number' && Number.isFinite(raw))
227
+ return { kind: 'ok', value: raw };
228
+ if (typeof raw === 'string' && raw.trim() !== '') {
229
+ const n = Number(raw);
230
+ if (Number.isFinite(n))
231
+ return { kind: 'ok', value: n };
232
+ }
233
+ return { kind: 'error', reason: `expected number, got ${describe(raw)}` };
234
+ }
235
+ case 'boolean': {
236
+ if (typeof raw === 'boolean')
237
+ return { kind: 'ok', value: raw };
238
+ if (raw === 'true' || raw === 'false')
239
+ return { kind: 'ok', value: raw === 'true' };
240
+ return { kind: 'error', reason: `expected boolean, got ${describe(raw)}` };
241
+ }
242
+ case 'enum': {
243
+ const allowed = port.enum ?? [];
244
+ if (allowed.length === 0) {
245
+ return { kind: 'error', reason: 'enum port declared without "enum" values' };
246
+ }
247
+ const asStr = typeof raw === 'string' ? raw : String(raw);
248
+ if (!allowed.includes(asStr)) {
249
+ return {
250
+ kind: 'error',
251
+ reason: `value ${JSON.stringify(raw)} not in enum [${allowed.map((v) => JSON.stringify(v)).join(', ')}]`,
252
+ };
253
+ }
254
+ return { kind: 'ok', value: asStr };
255
+ }
256
+ case 'json':
257
+ // 'json' accepts anything that survives JSON round-trip. We don't
258
+ // validate deeply — users opt into `json` precisely because they
259
+ // want a free-form payload.
260
+ return { kind: 'ok', value: raw };
261
+ default: {
262
+ // Exhaustiveness — TypeScript won't let us reach here unless a
263
+ // new PortType is added without updating this switch. The return
264
+ // satisfies the type checker; in practice the default branch is
265
+ // dead code.
266
+ const _exhaustive = port.type;
267
+ void _exhaustive;
268
+ return { kind: 'error', reason: `unknown port type "${String(port.type)}"` };
269
+ }
270
+ }
271
+ }
272
+ function describe(v) {
273
+ if (v === null)
274
+ return 'null';
275
+ if (Array.isArray(v))
276
+ return 'array';
277
+ return typeof v;
278
+ }
279
+ /**
280
+ * Extract declared outputs from a terminated task's output streams.
281
+ *
282
+ * Strategy (v1 — intentionally dumb but predictable):
283
+ * 1. Prefer `normalizedOutput` when provided (AI drivers populate this
284
+ * with the canonical assistant message; it's much cleaner than raw
285
+ * stdout, which often has JSONL event dumps). Fall back to stdout
286
+ * otherwise.
287
+ * 2. Scan from the end for the first non-empty line. If it parses as a
288
+ * JSON object, use that as the source record.
289
+ * 3. If (2) fails, try parsing the entire source as JSON (supports
290
+ * commands that pretty-print with line breaks).
291
+ * 4. For each declared output port, read the matching key and coerce
292
+ * to the declared type. Coercion failures produce a diagnostic and
293
+ * the port is absent from `outputs` (treated as missing downstream).
294
+ *
295
+ * When no declared outputs are present this returns an empty `outputs`
296
+ * map and null diagnostic — the engine interprets that as "task has no
297
+ * port contract".
298
+ */
299
+ export function extractTaskOutputs(ports, stdout, normalizedOutput) {
300
+ const decl = ports?.outputs;
301
+ if (!decl || decl.length === 0) {
302
+ return { outputs: {}, diagnostic: null };
303
+ }
304
+ const source = (normalizedOutput ?? '').length > 0 ? normalizedOutput : stdout;
305
+ const record = parseJsonTail(source);
306
+ if (record === null) {
307
+ return {
308
+ outputs: {},
309
+ diagnostic: 'outputs: could not find a final-line JSON object in task output — declared outputs are unresolved',
310
+ };
311
+ }
312
+ const outputs = {};
313
+ const warnings = [];
314
+ for (const port of decl) {
315
+ if (!(port.name in record)) {
316
+ warnings.push(`missing key "${port.name}"`);
317
+ continue;
318
+ }
319
+ const coerced = coerceValue(port, record[port.name]);
320
+ if (coerced.kind === 'error') {
321
+ warnings.push(`"${port.name}": ${coerced.reason}`);
322
+ continue;
323
+ }
324
+ outputs[port.name] = coerced.value;
325
+ }
326
+ const diagnostic = warnings.length > 0 ? `outputs: ${warnings.join('; ')}` : null;
327
+ return { outputs, diagnostic };
328
+ }
329
+ /**
330
+ * Find the last non-empty line that parses as a JSON object. Returns
331
+ * null when no such line exists. Also tries the whole source as a
332
+ * fallback — covers pretty-printed JSON that spans multiple lines.
333
+ */
334
+ function parseJsonTail(source) {
335
+ const lines = source.split(/\r?\n/);
336
+ for (let i = lines.length - 1; i >= 0; i--) {
337
+ const line = lines[i].trim();
338
+ if (!line)
339
+ continue;
340
+ const parsed = safeParseJson(line);
341
+ if (parsed !== null)
342
+ return parsed;
343
+ // First non-empty line from the tail — if it didn't parse, fall through
344
+ // to the whole-source attempt below rather than scanning further up
345
+ // (otherwise a prior human-readable line would be silently picked up
346
+ // if it happened to contain `{...}` fragments).
347
+ break;
348
+ }
349
+ return safeParseJson(source.trim());
350
+ }
351
+ function safeParseJson(candidate) {
352
+ if (!candidate.startsWith('{'))
353
+ return null;
354
+ try {
355
+ const parsed = JSON.parse(candidate);
356
+ if (parsed && typeof parsed === 'object' && !Array.isArray(parsed)) {
357
+ return parsed;
358
+ }
359
+ }
360
+ catch {
361
+ /* not JSON */
362
+ }
363
+ return null;
364
+ }
365
+ //# sourceMappingURL=ports.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ports.js","sourceRoot":"","sources":["../src/ports.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,EAAE;AACF,yDAAyD;AACzD,EAAE;AACF,wEAAwE;AACxE,yEAAyE;AACzE,yEAAyE;AACzE,2EAA2E;AAC3E,6DAA6D;AAC7D,EAAE;AACF,0EAA0E;AAC1E,wEAAwE;AACxE,wEAAwE;AACxE,uEAAuE;AACvE,wEAAwE;AACxE,+DAA+D;AAC/D,EAAE;AACF,uEAAuE;AACvE,sEAAsE;AACtE,0EAA0E;AAC1E,wEAAwE;AACxE,oEAAoE;AACpE,qDAAqD;AACrD,EAAE;AACF,0EAA0E;AAC1E,4EAA4E;AAI5E,yEAAyE;AAEzE;;;;;;GAMG;AACH,MAAM,cAAc,GAAG,iDAAiD,CAAC;AAEzE;;;;;GAKG;AACH,MAAM,UAAU,sBAAsB,CAAC,IAAY;IACjD,MAAM,KAAK,GAAG,IAAI,GAAG,EAAU,CAAC;IAChC,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC;QAClD,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAE,CAAC,CAAC;IACvB,CAAC;IACD,OAAO,CAAC,GAAG,KAAK,CAAC,CAAC;AACpB,CAAC;AAQD;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,gBAAgB,CAC9B,IAAY,EACZ,MAAyC;IAEzC,MAAM,UAAU,GAAG,IAAI,GAAG,EAAU,CAAC;IACrC,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE,CAAC,KAAK,EAAE,IAAY,EAAE,EAAE;QAC/D,IAAI,CAAC,CAAC,IAAI,IAAI,MAAM,CAAC,EAAE,CAAC;YACtB,UAAU,CAAC,GA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,IAAI,CAAC,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC3C,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAE,CAAC,IAAI,EAAE,CAAC;QAC9B,IAAI,CAAC,IAAI;YAAE,SAAS;QACpB,MAAM,MAAM,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;QACnC,IAAI,MAAM,KAAK,IAAI;YAAE,OAAO,MAAM,CAAC;QACnC,wEAAwE;QACxE,oEAAoE;QACpE,qEAAqE;QACrE,gDAAgD;QAChD,MAAM;IACR,CAAC;IACD,OAAO,aAAa,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;AACtC,CAAC;AAED,SAAS,aAAa,CAAC,SAAiB;IACtC,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC;IAC5C,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;QACrC,IAAI,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;YACnE,OAAO,MAAiC,CAAC;QAC3C,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,cAAc;IAChB,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ports.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ports.test.d.ts","sourceRoot":"","sources":["../src/ports.test.ts"],"names":[],"mappings":""}