@relayflows/sdk 2.0.27 → 2.0.28

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 (123) hide show
  1. package/dist/authored-flow-executor.d.ts +8 -1
  2. package/dist/authored-flow-executor.d.ts.map +1 -1
  3. package/dist/authored-flow-executor.js +16 -7
  4. package/dist/authored-flow-executor.js.map +1 -1
  5. package/dist/authored-flow-lifecycle.d.ts +68 -1
  6. package/dist/authored-flow-lifecycle.d.ts.map +1 -1
  7. package/dist/authored-flow-lifecycle.js +108 -10
  8. package/dist/authored-flow-lifecycle.js.map +1 -1
  9. package/dist/authored-flow-operation.d.ts +9 -1
  10. package/dist/authored-flow-operation.d.ts.map +1 -1
  11. package/dist/authored-flow-operation.js +7 -1
  12. package/dist/authored-flow-operation.js.map +1 -1
  13. package/dist/authored-node-entry.js +4 -0
  14. package/dist/authored-node-entry.js.map +1 -1
  15. package/dist/authored-node-runner.d.ts.map +1 -1
  16. package/dist/authored-node-runner.js +2 -1
  17. package/dist/authored-node-runner.js.map +1 -1
  18. package/dist/authored-promise-graph.d.ts +19 -4
  19. package/dist/authored-promise-graph.d.ts.map +1 -1
  20. package/dist/authored-promise-graph.js +44 -19
  21. package/dist/authored-promise-graph.js.map +1 -1
  22. package/dist/authored-root.d.ts +2 -0
  23. package/dist/authored-root.d.ts.map +1 -1
  24. package/dist/authored-root.js +2 -0
  25. package/dist/authored-root.js.map +1 -1
  26. package/dist/authored-step-graph.d.ts +83 -0
  27. package/dist/authored-step-graph.d.ts.map +1 -0
  28. package/dist/authored-step-graph.js +217 -0
  29. package/dist/authored-step-graph.js.map +1 -0
  30. package/dist/authored-step-index.d.ts +30 -0
  31. package/dist/authored-step-index.d.ts.map +1 -1
  32. package/dist/authored-step-index.js +26 -1
  33. package/dist/authored-step-index.js.map +1 -1
  34. package/dist/authored-step-output.d.ts +3 -0
  35. package/dist/authored-step-output.d.ts.map +1 -1
  36. package/dist/authored-step-output.js +4 -2
  37. package/dist/authored-step-output.js.map +1 -1
  38. package/dist/authored-worker-step.d.ts +3 -1
  39. package/dist/authored-worker-step.d.ts.map +1 -1
  40. package/dist/authored-worker-step.js +25 -6
  41. package/dist/authored-worker-step.js.map +1 -1
  42. package/dist/cli/direct-run.d.ts.map +1 -1
  43. package/dist/cli/direct-run.js +5 -2
  44. package/dist/cli/direct-run.js.map +1 -1
  45. package/dist/cli/run.d.ts +2 -0
  46. package/dist/cli/run.d.ts.map +1 -1
  47. package/dist/cli/run.js +9 -5
  48. package/dist/cli/run.js.map +1 -1
  49. package/dist/cli/step-excerpt.d.ts +48 -0
  50. package/dist/cli/step-excerpt.d.ts.map +1 -0
  51. package/dist/cli/step-excerpt.js +302 -0
  52. package/dist/cli/step-excerpt.js.map +1 -0
  53. package/dist/cli/step-failure.d.ts.map +1 -1
  54. package/dist/cli/step-failure.js +9 -20
  55. package/dist/cli/step-failure.js.map +1 -1
  56. package/dist/cli-commands.d.ts +8 -0
  57. package/dist/cli-commands.d.ts.map +1 -1
  58. package/dist/cli-commands.js +6 -0
  59. package/dist/cli-commands.js.map +1 -1
  60. package/dist/cli.d.ts +2 -0
  61. package/dist/cli.d.ts.map +1 -1
  62. package/dist/cli.js +38 -7
  63. package/dist/cli.js.map +1 -1
  64. package/dist/failure-kinds.d.ts +10 -2
  65. package/dist/failure-kinds.d.ts.map +1 -1
  66. package/dist/failure-kinds.js.map +1 -1
  67. package/dist/journal-client.d.ts +8 -2
  68. package/dist/journal-client.d.ts.map +1 -1
  69. package/dist/journal-client.js +22 -6
  70. package/dist/journal-client.js.map +1 -1
  71. package/dist/llm-worker.d.ts +2 -1
  72. package/dist/llm-worker.d.ts.map +1 -1
  73. package/dist/llm-worker.js +5 -2
  74. package/dist/llm-worker.js.map +1 -1
  75. package/dist/local-agent.d.ts +1 -1
  76. package/dist/local-agent.d.ts.map +1 -1
  77. package/dist/local-agent.js +8 -3
  78. package/dist/local-agent.js.map +1 -1
  79. package/dist/preflight.d.ts.map +1 -1
  80. package/dist/preflight.js +29 -3
  81. package/dist/preflight.js.map +1 -1
  82. package/dist/promise-ancestry.d.ts +20 -0
  83. package/dist/promise-ancestry.d.ts.map +1 -0
  84. package/dist/promise-ancestry.js +104 -0
  85. package/dist/promise-ancestry.js.map +1 -0
  86. package/dist/validate.d.ts.map +1 -1
  87. package/dist/validate.js +7 -0
  88. package/dist/validate.js.map +1 -1
  89. package/dist/worker-cli.d.ts +7 -0
  90. package/dist/worker-cli.d.ts.map +1 -1
  91. package/dist/worker-cli.js +42 -10
  92. package/dist/worker-cli.js.map +1 -1
  93. package/dist/worker-slots.d.ts +42 -0
  94. package/dist/worker-slots.d.ts.map +1 -0
  95. package/dist/worker-slots.js +94 -0
  96. package/dist/worker-slots.js.map +1 -0
  97. package/package.json +2 -2
  98. package/src/authored-flow-executor.ts +22 -3
  99. package/src/authored-flow-lifecycle.ts +111 -16
  100. package/src/authored-flow-operation.ts +10 -0
  101. package/src/authored-node-entry.ts +4 -1
  102. package/src/authored-node-runner.ts +2 -1
  103. package/src/authored-promise-graph.ts +46 -19
  104. package/src/authored-root.ts +4 -0
  105. package/src/authored-step-graph.ts +246 -0
  106. package/src/authored-step-index.ts +44 -1
  107. package/src/authored-step-output.ts +7 -3
  108. package/src/authored-worker-step.ts +25 -6
  109. package/src/cli/direct-run.ts +5 -2
  110. package/src/cli/run.ts +11 -4
  111. package/src/cli/step-excerpt.ts +332 -0
  112. package/src/cli/step-failure.ts +9 -20
  113. package/src/cli-commands.ts +6 -0
  114. package/src/cli.ts +40 -9
  115. package/src/failure-kinds.ts +10 -2
  116. package/src/journal-client.ts +25 -6
  117. package/src/llm-worker.ts +7 -2
  118. package/src/local-agent.ts +8 -2
  119. package/src/preflight.ts +37 -2
  120. package/src/promise-ancestry.ts +98 -0
  121. package/src/validate.ts +7 -0
  122. package/src/worker-cli.ts +41 -9
  123. package/src/worker-slots.ts +92 -0
@@ -0,0 +1,83 @@
1
+ import { type AuthoredStepEdges } from './authored-step-index.js';
2
+ /**
3
+ * The named DAG an authored body draws, recorded as it runs.
4
+ *
5
+ * An authored flow is plain TypeScript, so the shape Cloud wants to draw — which
6
+ * `f.agent` waited for which — is not declared anywhere. It is, however, a fact
7
+ * the runtime already holds: the promise graph (`authored-promise-graph.ts`)
8
+ * records, for every promise the body creates, what triggered it, what resolved
9
+ * it, and which context created it. A step's causal predecessors are the step
10
+ * promises reachable backward from the context that invoked it.
11
+ *
12
+ * Three rules make that walk an answer rather than an approximation:
13
+ *
14
+ * 1. **Stop at steps.** A step promise is a frontier; what it waited for is its
15
+ * own `after`, not ours.
16
+ * 2. **Expand an aggregate that waited for every member.** The runtime links a
17
+ * combinator's aggregate only to the member whose settlement settled it.
18
+ * That member is the whole answer when the aggregate settled on the first
19
+ * member that could decide it — a rejected `all`, a fulfilled `any`, any
20
+ * `race` — and a fraction of it when the aggregate had to wait for all of
21
+ * them: a fulfilled `all`, a rejected `any`, every `allSettled`. Which case
22
+ * applies is known only once the aggregate settles, so it is decided when a
23
+ * walk reaches the aggregate (`registerAggregate`, `promiseOutcome`).
24
+ * 3. **Reduce transitively.** `a → b → c` reaches both `a` and `b` from `c`;
25
+ * `a` is an ancestor of `b`, so it is dropped.
26
+ *
27
+ * Cost is bounded, not quadratic. Each invocation context's frontier is
28
+ * memoized, and a walk that reaches an already-answered context takes its
29
+ * answer instead of re-walking the history behind it — so a long sequential
30
+ * body walks a few nodes per step. A walk that still exceeds `walkLimit` stops
31
+ * and says so (`afterTruncated`) rather than guessing silently.
32
+ *
33
+ * This is observational metadata: it never gates execution, and it changes no
34
+ * step id, admission key or resume identity.
35
+ */
36
+ export declare const MAX_WALK = 10000;
37
+ type Combinator = 'all' | 'allSettled' | 'any' | 'race';
38
+ type Outcome = 'pending' | 'fulfilled' | 'rejected';
39
+ export declare class AuthoredStepGraph {
40
+ private readonly causesOf;
41
+ private readonly walkLimit;
42
+ private readonly stepPromises;
43
+ private readonly aggregates;
44
+ private readonly contexts;
45
+ private readonly nodes;
46
+ private readonly edges;
47
+ constructor(causesOf: (asyncId: number) => readonly number[], walkLimit?: number);
48
+ /** A combinator's aggregate and its members, for expansion once it settles. */
49
+ registerAggregate(aggregateId: number, promise: Promise<unknown>, combinator: Combinator, members: readonly number[]): void;
50
+ /**
51
+ * Record a step invoked from `contextId`. `promiseId` is the step's own
52
+ * promise, when the promise graph saw it, so later walks stop there.
53
+ */
54
+ registerStep(step: string, promiseId: number | undefined, contextId: number, label?: string): AuthoredStepEdges;
55
+ edgesOf(step: string): AuthoredStepEdges | undefined;
56
+ /** Drop the walk state; recorded edges stay readable for late record writes. */
57
+ release(): void;
58
+ private frontierOf;
59
+ /** The members an aggregate waited for beyond its own resolution edge. */
60
+ private waitedFor;
61
+ /**
62
+ * Drop every candidate that is an ancestor of another candidate. The
63
+ * reduction reads recorded `after` lists; when one it reads is incomplete,
64
+ * a redundant ancestor can survive, and the result says so.
65
+ */
66
+ private reduce;
67
+ private orderOf;
68
+ }
69
+ /**
70
+ * Whether a promise has settled, and how, read without attaching a handler.
71
+ *
72
+ * Attaching one would mark an author's rejected aggregate as handled and hide
73
+ * an unhandled rejection the process would otherwise report, so the state is
74
+ * read the one public way that has no such effect: Node's own inspection.
75
+ * `customInspect`, `getters` and `showProxy` keep author code and proxy traps
76
+ * from running; `depth: 0` and the length caps keep the rendered value small.
77
+ * Every option the match depends on is set here, because `inspect` fills the
78
+ * rest from `util.inspect.defaultOptions`, which any code in the process can
79
+ * change — `colors: true` there would wrap `<rejected>` in ANSI escapes.
80
+ */
81
+ export declare function promiseOutcome(promise: Promise<unknown>): Outcome;
82
+ export {};
83
+ //# sourceMappingURL=authored-step-graph.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authored-step-graph.d.ts","sourceRoot":"","sources":["../src/authored-step-graph.ts"],"names":[],"mappings":"AACA,OAAO,EAA2B,KAAK,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAE3F;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA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CAAC,GAAG,OAAO,CAOjE"}
@@ -0,0 +1,217 @@
1
+ import { inspect } from 'node:util';
2
+ import { MAX_AFTER, displayLabel } from './authored-step-index.js';
3
+ /**
4
+ * The named DAG an authored body draws, recorded as it runs.
5
+ *
6
+ * An authored flow is plain TypeScript, so the shape Cloud wants to draw — which
7
+ * `f.agent` waited for which — is not declared anywhere. It is, however, a fact
8
+ * the runtime already holds: the promise graph (`authored-promise-graph.ts`)
9
+ * records, for every promise the body creates, what triggered it, what resolved
10
+ * it, and which context created it. A step's causal predecessors are the step
11
+ * promises reachable backward from the context that invoked it.
12
+ *
13
+ * Three rules make that walk an answer rather than an approximation:
14
+ *
15
+ * 1. **Stop at steps.** A step promise is a frontier; what it waited for is its
16
+ * own `after`, not ours.
17
+ * 2. **Expand an aggregate that waited for every member.** The runtime links a
18
+ * combinator's aggregate only to the member whose settlement settled it.
19
+ * That member is the whole answer when the aggregate settled on the first
20
+ * member that could decide it — a rejected `all`, a fulfilled `any`, any
21
+ * `race` — and a fraction of it when the aggregate had to wait for all of
22
+ * them: a fulfilled `all`, a rejected `any`, every `allSettled`. Which case
23
+ * applies is known only once the aggregate settles, so it is decided when a
24
+ * walk reaches the aggregate (`registerAggregate`, `promiseOutcome`).
25
+ * 3. **Reduce transitively.** `a → b → c` reaches both `a` and `b` from `c`;
26
+ * `a` is an ancestor of `b`, so it is dropped.
27
+ *
28
+ * Cost is bounded, not quadratic. Each invocation context's frontier is
29
+ * memoized, and a walk that reaches an already-answered context takes its
30
+ * answer instead of re-walking the history behind it — so a long sequential
31
+ * body walks a few nodes per step. A walk that still exceeds `walkLimit` stops
32
+ * and says so (`afterTruncated`) rather than guessing silently.
33
+ *
34
+ * This is observational metadata: it never gates execution, and it changes no
35
+ * step id, admission key or resume identity.
36
+ */
37
+ export const MAX_WALK = 10_000;
38
+ /** The settlement on which a combinator had waited for every member. */
39
+ const EXPANDS_ON = {
40
+ all: 'fulfilled',
41
+ allSettled: 'always',
42
+ any: 'rejected',
43
+ race: undefined,
44
+ };
45
+ export class AuthoredStepGraph {
46
+ causesOf;
47
+ walkLimit;
48
+ stepPromises = new Map();
49
+ aggregates = new Map();
50
+ contexts = new Map();
51
+ nodes = new Map();
52
+ edges = new Map();
53
+ constructor(causesOf, walkLimit = MAX_WALK) {
54
+ this.causesOf = causesOf;
55
+ this.walkLimit = walkLimit;
56
+ }
57
+ /** A combinator's aggregate and its members, for expansion once it settles. */
58
+ registerAggregate(aggregateId, promise, combinator, members) {
59
+ const expandsOn = EXPANDS_ON[combinator];
60
+ if (expandsOn === undefined || members.length === 0)
61
+ return;
62
+ this.aggregates.set(aggregateId, { promise, expandsOn, members });
63
+ }
64
+ /**
65
+ * Record a step invoked from `contextId`. `promiseId` is the step's own
66
+ * promise, when the promise graph saw it, so later walks stop there.
67
+ */
68
+ registerStep(step, promiseId, contextId, label) {
69
+ const frontier = this.frontierOf(contextId);
70
+ this.nodes.set(step, { order: this.nodes.size, after: frontier.steps, truncated: frontier.truncated });
71
+ if (promiseId !== undefined)
72
+ this.stepPromises.set(promiseId, step);
73
+ const truncated = frontier.truncated || frontier.steps.length > MAX_AFTER;
74
+ const edges = Object.freeze({
75
+ ...displayLabel(label),
76
+ ...(frontier.steps.length === 0 ? {} : { after: Object.freeze(frontier.steps.slice(0, MAX_AFTER)) }),
77
+ ...(truncated ? { afterTruncated: true } : {}),
78
+ });
79
+ this.edges.set(step, edges);
80
+ return edges;
81
+ }
82
+ edgesOf(step) {
83
+ return this.edges.get(step);
84
+ }
85
+ /** Drop the walk state; recorded edges stay readable for late record writes. */
86
+ release() {
87
+ this.stepPromises.clear();
88
+ this.aggregates.clear();
89
+ this.contexts.clear();
90
+ this.nodes.clear();
91
+ }
92
+ frontierOf(start) {
93
+ const memo = this.contexts.get(start);
94
+ if (memo !== undefined)
95
+ return memo;
96
+ const candidates = new Set();
97
+ let truncated = false;
98
+ const visited = new Set([start]);
99
+ const queue = [start];
100
+ // Breadth-first, so that a walk cut short by the limit has already found
101
+ // the nearest predecessors and lost only distant history.
102
+ for (let head = 0; head < queue.length; head++) {
103
+ const current = queue[head];
104
+ const step = this.stepPromises.get(current);
105
+ if (step !== undefined) {
106
+ candidates.add(step);
107
+ continue;
108
+ }
109
+ const answered = current === start ? undefined : this.contexts.get(current);
110
+ if (answered !== undefined) {
111
+ for (const found of answered.steps)
112
+ candidates.add(found);
113
+ truncated ||= answered.truncated;
114
+ continue;
115
+ }
116
+ for (const id of [...this.waitedFor(current), ...this.causesOf(current)]) {
117
+ if (visited.has(id))
118
+ continue;
119
+ // At the limit, stop growing the walk but still drain what is queued:
120
+ // those nodes are already known and cost one lookup each.
121
+ if (visited.size >= this.walkLimit) {
122
+ truncated = true;
123
+ break;
124
+ }
125
+ visited.add(id);
126
+ queue.push(id);
127
+ }
128
+ }
129
+ const reduced = this.reduce(candidates);
130
+ const frontier = Object.freeze({ steps: reduced.steps, truncated: truncated || reduced.truncated });
131
+ this.contexts.set(start, frontier);
132
+ return frontier;
133
+ }
134
+ /** The members an aggregate waited for beyond its own resolution edge. */
135
+ waitedFor(asyncId) {
136
+ const aggregate = this.aggregates.get(asyncId);
137
+ if (aggregate === undefined)
138
+ return [];
139
+ if (aggregate.expandsOn === 'always')
140
+ return aggregate.members;
141
+ if (aggregate.outcome === undefined) {
142
+ const outcome = promiseOutcome(aggregate.promise);
143
+ if (outcome !== 'pending')
144
+ aggregate.outcome = outcome;
145
+ }
146
+ return aggregate.outcome === aggregate.expandsOn ? aggregate.members : [];
147
+ }
148
+ /**
149
+ * Drop every candidate that is an ancestor of another candidate. The
150
+ * reduction reads recorded `after` lists; when one it reads is incomplete,
151
+ * a redundant ancestor can survive, and the result says so.
152
+ */
153
+ reduce(candidates) {
154
+ const ordered = [...candidates].sort((a, b) => this.orderOf(a) - this.orderOf(b));
155
+ if (ordered.length <= 1)
156
+ return { steps: ordered, truncated: false };
157
+ // An ancestor is always registered before its descendant, so nothing
158
+ // older than the oldest candidate can be one: the walk stops there.
159
+ const oldest = this.orderOf(ordered[0]);
160
+ const reached = new Set();
161
+ // Predecessor lists are read through cursors, never copied onto the stack, and every entry
162
+ // inspected counts toward the limit — duplicates included — so a wide fan-in bounds both
163
+ // allocation and work, not just the number of distinct steps reached.
164
+ const stack = [];
165
+ const pushList = (values) => {
166
+ if (values !== undefined && values.length > 0)
167
+ stack.push({ values, next: 0 });
168
+ };
169
+ for (const step of ordered)
170
+ pushList(this.nodes.get(step)?.after);
171
+ let inspected = 0;
172
+ let truncated = ordered.some((step) => this.nodes.get(step)?.truncated === true);
173
+ while (stack.length > 0) {
174
+ const frame = stack[stack.length - 1];
175
+ const step = frame.values[frame.next++];
176
+ if (frame.next === frame.values.length)
177
+ stack.pop();
178
+ if (++inspected > this.walkLimit) {
179
+ truncated = true;
180
+ break;
181
+ }
182
+ if (reached.has(step))
183
+ continue;
184
+ reached.add(step);
185
+ const node = this.nodes.get(step);
186
+ if (node === undefined || node.order <= oldest)
187
+ continue;
188
+ truncated ||= node.truncated;
189
+ pushList(node.after);
190
+ }
191
+ return { steps: ordered.filter((step) => !reached.has(step)), truncated };
192
+ }
193
+ orderOf(step) {
194
+ return this.nodes.get(step)?.order ?? -1;
195
+ }
196
+ }
197
+ /**
198
+ * Whether a promise has settled, and how, read without attaching a handler.
199
+ *
200
+ * Attaching one would mark an author's rejected aggregate as handled and hide
201
+ * an unhandled rejection the process would otherwise report, so the state is
202
+ * read the one public way that has no such effect: Node's own inspection.
203
+ * `customInspect`, `getters` and `showProxy` keep author code and proxy traps
204
+ * from running; `depth: 0` and the length caps keep the rendered value small.
205
+ * Every option the match depends on is set here, because `inspect` fills the
206
+ * rest from `util.inspect.defaultOptions`, which any code in the process can
207
+ * change — `colors: true` there would wrap `<rejected>` in ANSI escapes.
208
+ */
209
+ export function promiseOutcome(promise) {
210
+ const shown = inspect(promise, {
211
+ depth: 0, customInspect: false, getters: false, showProxy: true, colors: false,
212
+ compact: 3, sorted: false, maxArrayLength: 0, maxStringLength: 0, breakLength: Infinity,
213
+ });
214
+ const state = /^[^{]*\{\s*<(pending|rejected)>/u.exec(shown)?.[1];
215
+ return state === 'pending' ? 'pending' : state === 'rejected' ? 'rejected' : 'fulfilled';
216
+ }
217
+ //# sourceMappingURL=authored-step-graph.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authored-step-graph.js","sourceRoot":"","sources":["../src/authored-step-graph.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,YAAY,EAA0B,MAAM,0BAA0B,CAAC;AAE3F;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,MAAM,CAAC;AAiB/B,wEAAwE;AACxE,MAAM,UAAU,GAAiE;IAC/E,GAAG,EAAE,WAAW;IAChB,UAAU,EAAE,QAAQ;IACpB,GAAG,EAAE,UAAU;IACf,IAAI,EAAE,SAAS;CAChB,CAAC;AAUF,MAAM,OAAO,iBAAiB;IAQT;IACA;IARF,YAAY,GAAG,IAAI,GAAG,EAAkB,CAAC;IACzC,UAAU,GAAG,IAAI,GAAG,EAAqB,CAAC;IAC1C,QAAQ,GAAG,IAAI,GAAG,EAAoB,CAAC;IACvC,KAAK,GAAG,IAAI,GAAG,EAAoB,CAAC;IACpC,KAAK,GAAG,IAAI,GAAG,EAA6B,CAAC;IAE9D,YACmB,QAAgD,EAChD,YAAY,QAAQ;QADpB,aAAQ,GAAR,QAAQ,CAAwC;QAChD,cAAS,GAAT,SAAS,CAAW;IACpC,CAAC;IAEJ,+EAA+E;IAC/E,iBAAiB,CACf,WAAmB,EACnB,OAAyB,EACzB,UAAsB,EACtB,OAA0B;QAE1B,MAAM,SAAS,GAAG,UAAU,CAAC,UAAU,CAAC,CAAC;QACzC,IAAI,SAAS,KAAK,SAAS,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO;QAC5D,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC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CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,KAAK,IAAI,CAAC,CAAC,CAAC;IAC3C,CAAC;CACF;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,cAAc,CAAC,OAAyB;IACtD,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,EAAE;QAC7B,KAAK,EAAE,CAAC,EAAE,aAAa,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK;QAC9E,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,cAAc,EAAE,CAAC,EAAE,eAAe,EAAE,CAAC,EAAE,WAAW,EAAE,QAAQ;KACxF,CAAC,CAAC;IACH,MAAM,KAAK,GAAG,kCAAkC,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAClE,OAAO,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,KAAK,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,WAAW,CAAC;AAC3F,CAAC"}
@@ -48,7 +48,37 @@ export interface AuthoredStepRecord {
48
48
  * `<step>` — saying which is the difference between an index and a guess.
49
49
  */
50
50
  readonly kernelStep?: string;
51
+ /**
52
+ * Human name for the step: the author-chosen `f.agent` or `f.hook` name,
53
+ * whole or not at all (`displayLabel`).
54
+ */
55
+ readonly label?: string;
56
+ /**
57
+ * The steps this one causally waited for, transitively reduced
58
+ * (`authored-step-graph.ts`). Absent means none were found, not unknown.
59
+ */
60
+ readonly after?: readonly string[];
61
+ /** Present when `after` is incomplete: the walk hit its limit or the list its cap. */
62
+ readonly afterTruncated?: true;
51
63
  }
64
+ /** The graph fields one authored step carries on every record about it. */
65
+ export type AuthoredStepEdges = Pick<AuthoredStepRecord, 'label' | 'after' | 'afterTruncated'>;
66
+ /** Most predecessors one record lists; the rest are marked `afterTruncated`. */
67
+ export declare const MAX_AFTER = 32;
68
+ /** Longest label a record carries. A longer one is omitted, never cut. */
69
+ export declare const MAX_LABEL = 256;
70
+ /**
71
+ * A label, whole, or nothing.
72
+ *
73
+ * A label is displayed and persisted by Cloud after its redactor runs, and the
74
+ * redactor matches whole secret values: a label cut mid-secret would arrive as
75
+ * an unredactable prefix. So a label is never truncated — one over the bound
76
+ * is dropped — and only author-chosen names are labels at all. Commands are
77
+ * not: they carry literal tokens and URLs, so `f.run` has no label.
78
+ */
79
+ export declare function displayLabel(label: string | undefined): {
80
+ readonly label?: string;
81
+ };
52
82
  /**
53
83
  * Append one record, or do nothing when there is no root to append to.
54
84
  *
@@ -1 +1 @@
1
- {"version":3,"file":"authored-step-index.d.ts","sourceRoot":"","sources":["../src/authored-step-index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,oBAAoB,mBAAmB,CAAC;AAErD,oEAAoE;AACpE,QAAA,MAAM,WAAW,gCAAgC,CAAC;AAQlD;;;;;;;GAOG;AACH,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,KAAK,EAAE,OAAO,WAAW,CAAC;IACnC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,UAAU,GAAG,WAAW,CAAC;IACzC,mCAAmC;IACnC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IACnC;;;;;OAKG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,aAAa,EACtB,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,MAAM,EAAE,IAAI,CAAC,kBAAkB,EAAE,OAAO,CAAC,GACxC,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M,iBAAiB,GAAG,IAAI,CAAC,kBAAkB,EAAE,OAAO,GAAG,OAAO,GAAG,gBAAgB,CAAC,CAAC;AAE/F,gFAAgF;AAChF,eAAO,MAAM,SAAS,KAAK,CAAC;AAE5B,0EAA0E;AAC1E,eAAO,MAAM,SAAS,MAAM,CAAC;AAE7B;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG;IAAE,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAEnF;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,aAAa,EACtB,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,MAAM,EAAE,IAAI,CAAC,kBAAkB,EAAE,OAAO,CAAC,GACxC,OAAO,CAAC,IAAI,CAAC,CAef;AAED;;;;;;GAMG;AACH,wBAAsB,UAAU,CAC9B,OAAO,EAAE,aAAa,EACtB,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,MAAM,EAAE,IAAI,CAAC,kBAAkB,EAAE,OAAO,CAAC,GACxC,OAAO,CAAC,MAAM,CAAC,CAOjB;AAED;;;;;;GAMG;AACH,wBAAsB,qBAAqB,CACzC,OAAO,EAAE,aAAa,EACtB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAqB/B"}
@@ -30,6 +30,22 @@ const RECORD_KIND = 'relayflows.authored-step.v1';
30
30
  * exists so a hostile or buggy id cannot make one record unbounded.
31
31
  */
32
32
  const FIELD_CHARS = 256;
33
+ /** Most predecessors one record lists; the rest are marked `afterTruncated`. */
34
+ export const MAX_AFTER = 32;
35
+ /** Longest label a record carries. A longer one is omitted, never cut. */
36
+ export const MAX_LABEL = 256;
37
+ /**
38
+ * A label, whole, or nothing.
39
+ *
40
+ * A label is displayed and persisted by Cloud after its redactor runs, and the
41
+ * redactor matches whole secret values: a label cut mid-secret would arrive as
42
+ * an unredactable prefix. So a label is never truncated — one over the bound
43
+ * is dropped — and only author-chosen names are labels at all. Commands are
44
+ * not: they carry literal tokens and URLs, so `f.run` has no label.
45
+ */
46
+ export function displayLabel(label) {
47
+ return label === undefined || label.trim() === '' || label.length > MAX_LABEL ? {} : { label };
48
+ }
33
49
  /**
34
50
  * Append one record, or do nothing when there is no root to append to.
35
51
  *
@@ -53,6 +69,10 @@ export async function recordAuthoredChild(journal, rootRunId, record) {
53
69
  ...(record.completionReason === undefined ? {} : { completionReason: bound(record.completionReason) }),
54
70
  ...(record.kernelStep === undefined || record.kernelStep === record.step
55
71
  ? {} : { kernelStep: bound(record.kernelStep) }),
72
+ ...displayLabel(record.label),
73
+ ...(record.after === undefined ? {} : { after: record.after.slice(0, MAX_AFTER).map(bound) }),
74
+ ...(record.afterTruncated === true || (record.after?.length ?? 0) > MAX_AFTER
75
+ ? { afterTruncated: true } : {}),
56
76
  });
57
77
  }
58
78
  /**
@@ -112,7 +132,12 @@ function isAuthoredStepRecord(value) {
112
132
  && typeof record.runId === 'string' && record.runId.length > 0
113
133
  && (record.state === 'admitted' || record.state === 'completed')
114
134
  && (record.completionReason === undefined || typeof record.completionReason === 'string')
115
- && (record.kernelStep === undefined || typeof record.kernelStep === 'string');
135
+ && (record.kernelStep === undefined || typeof record.kernelStep === 'string')
136
+ && (record.label === undefined || (typeof record.label === 'string' && record.label.length <= MAX_LABEL))
137
+ && (record.after === undefined || (Array.isArray(record.after)
138
+ && record.after.length <= MAX_AFTER
139
+ && record.after.every((step) => typeof step === 'string' && step.length > 0)))
140
+ && (record.afterTruncated === undefined || record.afterTruncated === true);
116
141
  }
117
142
  function bound(value) {
118
143
  return value.length <= FIELD_CHARS ? value : `${value.slice(0, FIELD_CHARS)}…`;
@@ -1 +1 @@
1
- {"version":3,"file":"authored-step-index.js","sourceRoot":"","sources":["../src/authored-step-index.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,CAAC,MAAM,oBAA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S,CAAC,CAAC;WACtG,CAAC,MAAM,CAAC,KAAK,KAAK,SAAS,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC;eACzD,MAAM,CAAC,KAAK,CAAC,MAAM,IAAI,SAAS;eAChC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;WAC7E,CAAC,MAAM,CAAC,cAAc,KAAK,SAAS,IAAI,MAAM,CAAC,cAAc,KAAK,IAAI,CAAC,CAAC;AAC/E,CAAC;AAED,SAAS,KAAK,CAAC,KAAa;IAC1B,OAAO,KAAK,CAAC,MAAM,IAAI,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,WAAW,CAAC,GAAG,CAAC;AACjF,CAAC"}
@@ -2,6 +2,7 @@ import { type FlowCompletionReason } from '@relayflows/surface';
2
2
  import type { JournalClient } from './journal-client.js';
3
3
  import type { CompletionReason as ProtocolCompletionReason, RunCompletionReason as ProtocolRunCompletionReason, RunOutcome } from './protocol.js';
4
4
  import type { AuthoredFlowJournalStep } from './authored-flow-executor.js';
5
+ import { type AuthoredStepEdges } from './authored-step-index.js';
5
6
  /**
6
7
  * What an authored operation needs in order to leave readable evidence:
7
8
  * the root run its child index belongs to, and the data dir whose journals
@@ -12,6 +13,8 @@ import type { AuthoredFlowJournalStep } from './authored-flow-executor.js';
12
13
  export interface AuthoredStepContext {
13
14
  readonly rootRunId?: string;
14
15
  readonly dataDir?: string;
16
+ /** The step's label and causal predecessors, carried on every record about it. */
17
+ readonly stepEdges?: (step: string) => AuthoredStepEdges | undefined;
15
18
  }
16
19
  /**
17
20
  * Shared by every `f.*` verb that lowers to one kernel step run in isolation:
@@ -1 +1 @@
1
- {"version":3,"file":"authored-step-output.d.ts","sourceRoot":"","sources":["../src/authored-step-output.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuE,KAAK,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAErI,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,EAAE,gBAAgB,IAAI,wBAAwB,EAAE,mBAAmB,IAAI,2BAA2B,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAClJ,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAK3E;;;;;;GAMG;AACH,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAsB,uBAAuB,CAC3C,OAAO,EAAE,aAAa,EACtB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,uBAAuB,EAAE,EACvC,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,OAAO,CAAC,CAkClB;AAED,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,aAAa,EACtB,OAAO,EAAE,UAAU,EACnB,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,uBAAuB,EAAE,EACvC,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,MAAM,CAAC,CAkBjB;AAqBD,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,wBAAwB,CAG3F;AAED,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,2BAA2B,CAGjG;AAED,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,oBAAoB,CAG3F"}
1
+ {"version":3,"file":"authored-step-output.d.ts","sourceRoot":"","sources":["../src/authored-step-output.ts"],"names":[],"mappings":"AAAA,OAA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KAAK,IAAI,oBAAoB,CAG3F"}
@@ -34,7 +34,8 @@ export async function readCompletedStepOutput(journal, runId, stepId, journalSte
34
34
  throw protocolViolation(runId, `journal has no step.completed for "${stepId}"`);
35
35
  }
36
36
  const reason = completed.payload.completionReason;
37
- journalSteps.push(Object.freeze({ id: stepId, runId, completionReason: reason }));
37
+ const edges = context.stepEdges?.(stepId);
38
+ journalSteps.push(Object.freeze({ id: stepId, runId, completionReason: reason, ...edges }));
38
39
  if (reason !== 'success') {
39
40
  let message = `journal step "${stepId}" completed with ${reason}`;
40
41
  let details;
@@ -55,11 +56,12 @@ export async function readCompletedStepOutput(journal, runId, stepId, journalSte
55
56
  message += await alsoRecord(journal, context.rootRunId, {
56
57
  step: stepId, runId, state: 'completed', completionReason: reason,
57
58
  ...(details?.stepId === undefined ? {} : { kernelStep: details.stepId }),
59
+ ...edges,
58
60
  });
59
61
  throw new AuthoredFlowExecutionError('step_failed', message, reason, runId, { ...details, ...where });
60
62
  }
61
63
  await recordAuthoredChild(journal, context.rootRunId, {
62
- step: stepId, runId, state: 'completed', completionReason: reason,
64
+ step: stepId, runId, state: 'completed', completionReason: reason, ...edges,
63
65
  });
64
66
  return completed.payload.output;
65
67
  }
@@ -1 +1 @@
1
- {"version":3,"file":"authored-step-output.js","sourceRoot":"","sources":["../src/authored-step-output.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,uBAAuB,EAA6B,MAAM,qBAAqB,CAAC;AACrI,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AAKtE,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AACjH,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAc3E;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAC3C,OAAsB,EAC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AAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC;AAED,SAAS,YAAY,CAAC,KAAc;IAClC,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAChE,CAAC;AAED,SAAS,iBAAiB,CAAC,KAAa,EAAE,MAAc;IACtD,OAAO,IAAI,0BAA0B,CACnC,4BAA4B,EAC5B,MAAM,EACN,SAAS,EACT,KAAK,CACN,CAAC;AACJ,CAAC"}
@@ -7,7 +7,9 @@ import type { AuthoredFlowJournalStep } from './authored-flow-executor.js';
7
7
  /** Agent and LLM calls share the exact declarative preflight and lease wait. */
8
8
  export declare function authoredWorkerRunner(definition: {
9
9
  name: string;
10
- }, journal: JournalClient, flowPath: string, journalSteps: AuthoredFlowJournalStep[], waitOptions: RunLifecycleOptions, localAgentStream?: string, budget?: AuthoredBudget, headerBudget?: unknown, rootRunId?: string): {
10
+ }, journal: JournalClient, flowPath: string, journalSteps: AuthoredFlowJournalStep[], waitOptions: RunLifecycleOptions, localAgentStream?: string, budget?: AuthoredBudget, headerBudget?: unknown, rootRunId?: string, workerCapacity?: number, stepEdges?: AuthoredStepContext['stepEdges']): {
11
+ /** Refuse every agent/LLM call still waiting for a worker slot (body teardown). */
12
+ stop(reason: unknown): void;
11
13
  agent(id: string, options: AgentOptions, verification?: NamedGate): Promise<AgentResult>;
12
14
  llm(id: string, prompt: string, options?: LlmOptions, verification?: NamedGate): Promise<unknown>;
13
15
  };
@@ -1 +1 @@
1
- {"version":3,"file":"authored-worker-step.d.ts","sourceRoot":"","sources":["../src/authored-worker-step.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAE3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AC,MAAM,CAAC,CAoB1H"}
@@ -1,3 +1,4 @@
1
+ import { resolve } from 'node:path';
1
2
  import { parseBudget } from './budget.js';
2
3
  import { compileSpec, toKernelSpec } from './compile.js';
3
4
  import { checkAuthoredFlow } from './cli/check.js';
@@ -8,12 +9,18 @@ import { isSurfaceCompletionReason, readCompletedStepOutput, readSuccessfulOutpu
8
9
  import { snapshotJsonValue } from './json-value.js';
9
10
  import { authoredChildAdmissionKey } from './authored-admission.js';
10
11
  import { alsoRecord, recordAuthoredChild } from './authored-step-index.js';
12
+ import { WorkerSlots } from './worker-slots.js';
11
13
  const WORKSPACE_PERMISSION_ANNOTATION = /:\s*(readonly|readwrite)\s*$/i;
12
14
  /** Agent and LLM calls share the exact declarative preflight and lease wait. */
13
- export function authoredWorkerRunner(definition, journal, flowPath, journalSteps, waitOptions, localAgentStream, budget, headerBudget, rootRunId) {
15
+ export function authoredWorkerRunner(definition, journal, flowPath, journalSteps, waitOptions, localAgentStream, budget, headerBudget, rootRunId, workerCapacity, stepEdges) {
16
+ // Sized to the attached local workers, so concurrent calls wait here for a
17
+ // slot instead of being admitted and parked for want of a free worker.
18
+ const slots = workerCapacity === undefined ? undefined
19
+ : { agent: new WorkerSlots(workerCapacity), llm: new WorkerSlots(workerCapacity) };
14
20
  const context = {
15
21
  ...(rootRunId === undefined ? {} : { rootRunId }),
16
22
  ...(waitOptions.dataDir === undefined ? {} : { dataDir: waitOptions.dataDir }),
23
+ ...(stepEdges === undefined ? {} : { stepEdges }),
17
24
  };
18
25
  async function run(step) {
19
26
  const id = step.id;
@@ -36,7 +43,9 @@ export function authoredWorkerRunner(definition, journal, flowPath, journalSteps
36
43
  // Written BEFORE the wait, not after it. An agent runs for as long as its
37
44
  // lease allows; if this process dies mid-step, this record is the only
38
45
  // thing that still names the child run holding the evidence.
39
- await recordAuthoredChild(journal, rootRunId, { step: id, runId: outcome.run_id, state: 'admitted' });
46
+ await recordAuthoredChild(journal, rootRunId, {
47
+ step: id, runId: outcome.run_id, state: 'admitted', ...stepEdges?.(id),
48
+ });
40
49
  // Reuse the declarative CLI's own wait/classification (cli/run.ts) rather
41
50
  // than a hand-rolled poll: `step.completed` and the run's own terminal
42
51
  // state are appended as two SEPARATE actions (kernel/relayflowd-core/src/machine.rs
@@ -71,12 +80,13 @@ export function authoredWorkerRunner(definition, journal, flowPath, journalSteps
71
80
  // a manufactured completion.
72
81
  if (isSurfaceCompletionReason(details?.completionReason)) {
73
82
  journalSteps.push(Object.freeze({
74
- id, runId: outcome.run_id, completionReason: details.completionReason,
83
+ id, runId: outcome.run_id, completionReason: details.completionReason, ...stepEdges?.(id),
75
84
  }));
76
85
  message += await alsoRecord(journal, rootRunId, {
77
86
  step: id, runId: outcome.run_id, state: 'completed',
78
87
  completionReason: details.completionReason,
79
88
  ...(details.stepId === undefined ? {} : { kernelStep: details.stepId }),
89
+ ...stepEdges?.(id),
80
90
  });
81
91
  }
82
92
  throw new AuthoredFlowExecutionError('step_failed', message, isSurfaceCompletionReason(reason) ? reason : undefined, outcome.run_id, details);
@@ -84,11 +94,17 @@ export function authoredWorkerRunner(definition, journal, flowPath, journalSteps
84
94
  return readCompletedStepOutput(journal, outcome.run_id, id, journalSteps, context);
85
95
  };
86
96
  const admissionKey = authoredChildAdmissionKey(rootRunId, id);
87
- return budget === undefined
97
+ const admit = async () => budget === undefined
88
98
  ? consume(await journal.runStart(spec, undefined, admissionKey))
89
99
  : budget.execute(journal, spec, consume, admissionKey);
100
+ return slots === undefined ? admit() : slots[step.type === 'llm' ? 'llm' : 'agent'].run(admit);
90
101
  }
91
102
  return {
103
+ /** Refuse every agent/LLM call still waiting for a worker slot (body teardown). */
104
+ stop(reason) {
105
+ slots?.agent.close(reason);
106
+ slots?.llm.close(reason);
107
+ },
92
108
  async agent(id, options, verification) {
93
109
  if (options.workspace !== undefined && localAgentStream !== undefined) {
94
110
  throw new AuthoredFlowExecutionError('unsupported_workspace_permission', 'The local agent worker accepts stream-only steps. Remove workspace or attach a worker that holds its revision pins.');
@@ -121,7 +137,8 @@ export function authoredWorkerRunner(definition, journal, flowPath, journalSteps
121
137
  ...(options.workspace === undefined ? {} : { surfaces: { workspace: [{ surface: options.workspace }] } }),
122
138
  ...(options.cli === undefined ? {} : { cli: options.cli }),
123
139
  ...(options.model === undefined ? {} : { model: options.model }),
124
- ...(options.cwd === undefined ? {} : { cwd: options.cwd }),
140
+ // The kernel takes only an absolute cwd; a relative one means the runner's own directory.
141
+ ...(options.cwd === undefined ? {} : { cwd: resolve(options.cwd) }),
125
142
  ...(options.transport === undefined ? {} : { transport: options.transport }),
126
143
  ...(verification === undefined ? {} : { verification }),
127
144
  });
@@ -179,7 +196,9 @@ export function authoredDeterministicRunner(name, journal, journalSteps, budget,
179
196
  }));
180
197
  const admissionKey = authoredChildAdmissionKey(rootRunId, id);
181
198
  const consume = async (outcome) => {
182
- await recordAuthoredChild(journal, rootRunId, { step: id, runId: outcome.run_id, state: 'admitted' });
199
+ await recordAuthoredChild(journal, rootRunId, {
200
+ step: id, runId: outcome.run_id, state: 'admitted', ...context.stepEdges?.(id),
201
+ });
183
202
  return readSuccessfulOutput(journal, outcome, id, journalSteps, context);
184
203
  };
185
204
  if (terminal)