@relayflows/sdk 2.0.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/authored-flow-error.d.ts +9 -0
- package/dist/authored-flow-error.d.ts.map +1 -0
- package/dist/authored-flow-error.js +13 -0
- package/dist/authored-flow-error.js.map +1 -0
- package/dist/authored-flow-executor.d.ts +28 -0
- package/dist/authored-flow-executor.d.ts.map +1 -0
- package/dist/authored-flow-executor.js +203 -0
- package/dist/authored-flow-executor.js.map +1 -0
- package/dist/authored-flow-lifecycle.d.ts +61 -0
- package/dist/authored-flow-lifecycle.d.ts.map +1 -0
- package/dist/authored-flow-lifecycle.js +284 -0
- package/dist/authored-flow-lifecycle.js.map +1 -0
- package/dist/authored-flow-loader.d.ts +7 -0
- package/dist/authored-flow-loader.d.ts.map +1 -0
- package/dist/authored-flow-loader.js +39 -0
- package/dist/authored-flow-loader.js.map +1 -0
- package/dist/authored-flow-operation.d.ts +43 -0
- package/dist/authored-flow-operation.d.ts.map +1 -0
- package/dist/authored-flow-operation.js +176 -0
- package/dist/authored-flow-operation.js.map +1 -0
- package/dist/authored-flow.d.ts +12 -0
- package/dist/authored-flow.d.ts.map +1 -0
- package/dist/authored-flow.js +13 -0
- package/dist/authored-flow.js.map +1 -0
- package/dist/authored-promise-graph.d.ts +67 -0
- package/dist/authored-promise-graph.d.ts.map +1 -0
- package/dist/authored-promise-graph.js +206 -0
- package/dist/authored-promise-graph.js.map +1 -0
- package/dist/backlog-picker.d.ts +55 -0
- package/dist/backlog-picker.d.ts.map +1 -0
- package/dist/backlog-picker.js +117 -0
- package/dist/backlog-picker.js.map +1 -0
- package/dist/canonical.d.ts +18 -0
- package/dist/canonical.d.ts.map +1 -0
- package/dist/canonical.js +55 -0
- package/dist/canonical.js.map +1 -0
- package/dist/cli/check.d.ts +30 -0
- package/dist/cli/check.d.ts.map +1 -0
- package/dist/cli/check.js +324 -0
- package/dist/cli/check.js.map +1 -0
- package/dist/cli/direct-run.d.ts +3 -0
- package/dist/cli/direct-run.d.ts.map +1 -0
- package/dist/cli/direct-run.js +69 -0
- package/dist/cli/direct-run.js.map +1 -0
- package/dist/cli/hn-monitor.d.ts +107 -0
- package/dist/cli/hn-monitor.d.ts.map +1 -0
- package/dist/cli/hn-monitor.js +220 -0
- package/dist/cli/hn-monitor.js.map +1 -0
- package/dist/cli/interruptible-sleep.d.ts +13 -0
- package/dist/cli/interruptible-sleep.d.ts.map +1 -0
- package/dist/cli/interruptible-sleep.js +31 -0
- package/dist/cli/interruptible-sleep.js.map +1 -0
- package/dist/cli/run.d.ts +54 -0
- package/dist/cli/run.d.ts.map +1 -0
- package/dist/cli/run.js +316 -0
- package/dist/cli/run.js.map +1 -0
- package/dist/cli/tick-runner.d.ts +151 -0
- package/dist/cli/tick-runner.d.ts.map +1 -0
- package/dist/cli/tick-runner.js +258 -0
- package/dist/cli/tick-runner.js.map +1 -0
- package/dist/cli-adapter.d.ts +29 -0
- package/dist/cli-adapter.d.ts.map +1 -0
- package/dist/cli-adapter.js +92 -0
- package/dist/cli-adapter.js.map +1 -0
- package/dist/cli-executable.d.ts +3 -0
- package/dist/cli-executable.d.ts.map +1 -0
- package/dist/cli-executable.js +10 -0
- package/dist/cli-executable.js.map +1 -0
- package/dist/cli.d.ts +9 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +348 -0
- package/dist/cli.js.map +1 -0
- package/dist/compile.d.ts +42 -0
- package/dist/compile.d.ts.map +1 -0
- package/dist/compile.js +515 -0
- package/dist/compile.js.map +1 -0
- package/dist/demo-hn-monitor.d.ts +2 -0
- package/dist/demo-hn-monitor.d.ts.map +1 -0
- package/dist/demo-hn-monitor.js +118 -0
- package/dist/demo-hn-monitor.js.map +1 -0
- package/dist/dir-watcher-poller.d.ts +73 -0
- package/dist/dir-watcher-poller.d.ts.map +1 -0
- package/dist/dir-watcher-poller.js +80 -0
- package/dist/dir-watcher-poller.js.map +1 -0
- package/dist/direct-input.d.ts +10 -0
- package/dist/direct-input.d.ts.map +1 -0
- package/dist/direct-input.js +61 -0
- package/dist/direct-input.js.map +1 -0
- package/dist/failure-kinds.d.ts +25 -0
- package/dist/failure-kinds.d.ts.map +1 -0
- package/dist/failure-kinds.js +64 -0
- package/dist/failure-kinds.js.map +1 -0
- package/dist/gate-contract.d.ts +24 -0
- package/dist/gate-contract.d.ts.map +1 -0
- package/dist/gate-contract.js +50 -0
- package/dist/gate-contract.js.map +1 -0
- package/dist/hn-poller.d.ts +50 -0
- package/dist/hn-poller.d.ts.map +1 -0
- package/dist/hn-poller.js +79 -0
- package/dist/hn-poller.js.map +1 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +30 -0
- package/dist/index.js.map +1 -0
- package/dist/journal-client.d.ts +122 -0
- package/dist/journal-client.d.ts.map +1 -0
- package/dist/journal-client.js +277 -0
- package/dist/journal-client.js.map +1 -0
- package/dist/json-schema-bound.d.ts +7 -0
- package/dist/json-schema-bound.d.ts.map +1 -0
- package/dist/json-schema-bound.js +353 -0
- package/dist/json-schema-bound.js.map +1 -0
- package/dist/json-schema.d.ts +5 -0
- package/dist/json-schema.d.ts.map +1 -0
- package/dist/json-schema.js +72 -0
- package/dist/json-schema.js.map +1 -0
- package/dist/json-value.d.ts +6 -0
- package/dist/json-value.d.ts.map +1 -0
- package/dist/json-value.js +94 -0
- package/dist/json-value.js.map +1 -0
- package/dist/model-name.d.ts +7 -0
- package/dist/model-name.d.ts.map +1 -0
- package/dist/model-name.js +21 -0
- package/dist/model-name.js.map +1 -0
- package/dist/output-schema.d.ts +8 -0
- package/dist/output-schema.d.ts.map +1 -0
- package/dist/output-schema.js +28 -0
- package/dist/output-schema.js.map +1 -0
- package/dist/preflight.d.ts +80 -0
- package/dist/preflight.d.ts.map +1 -0
- package/dist/preflight.js +361 -0
- package/dist/preflight.js.map +1 -0
- package/dist/protocol.d.ts +359 -0
- package/dist/protocol.d.ts.map +1 -0
- package/dist/protocol.js +15 -0
- package/dist/protocol.js.map +1 -0
- package/dist/spec.d.ts +294 -0
- package/dist/spec.d.ts.map +1 -0
- package/dist/spec.js +13 -0
- package/dist/spec.js.map +1 -0
- package/dist/step-dependencies.d.ts +2 -0
- package/dist/step-dependencies.d.ts.map +1 -0
- package/dist/step-dependencies.js +88 -0
- package/dist/step-dependencies.js.map +1 -0
- package/dist/step-fields.d.ts +17 -0
- package/dist/step-fields.d.ts.map +1 -0
- package/dist/step-fields.js +32 -0
- package/dist/step-fields.js.map +1 -0
- package/dist/tick-source.d.ts +205 -0
- package/dist/tick-source.d.ts.map +1 -0
- package/dist/tick-source.js +234 -0
- package/dist/tick-source.js.map +1 -0
- package/dist/unknown-keys.d.ts +7 -0
- package/dist/unknown-keys.d.ts.map +1 -0
- package/dist/unknown-keys.js +47 -0
- package/dist/unknown-keys.js.map +1 -0
- package/dist/validate.d.ts +7 -0
- package/dist/validate.d.ts.map +1 -0
- package/dist/validate.js +458 -0
- package/dist/validate.js.map +1 -0
- package/dist/work-package-consumer.d.ts +33 -0
- package/dist/work-package-consumer.d.ts.map +1 -0
- package/dist/work-package-consumer.js +44 -0
- package/dist/work-package-consumer.js.map +1 -0
- package/dist/work-package-validator.d.ts +15 -0
- package/dist/work-package-validator.d.ts.map +1 -0
- package/dist/work-package-validator.js +72 -0
- package/dist/work-package-validator.js.map +1 -0
- package/dist/worker-cli.d.ts +16 -0
- package/dist/worker-cli.d.ts.map +1 -0
- package/dist/worker-cli.js +77 -0
- package/dist/worker-cli.js.map +1 -0
- package/dist/worker.d.ts +57 -0
- package/dist/worker.d.ts.map +1 -0
- package/dist/worker.js +129 -0
- package/dist/worker.js.map +1 -0
- package/dist/wrapper-runtime.d.ts +10 -0
- package/dist/wrapper-runtime.d.ts.map +1 -0
- package/dist/wrapper-runtime.js +83 -0
- package/dist/wrapper-runtime.js.map +1 -0
- package/dist/wrapper-session.d.ts +16 -0
- package/dist/wrapper-session.d.ts.map +1 -0
- package/dist/wrapper-session.js +244 -0
- package/dist/wrapper-session.js.map +1 -0
- package/package.json +50 -0
- package/src/authored-flow-error.ts +31 -0
- package/src/authored-flow-executor.ts +365 -0
- package/src/authored-flow-lifecycle.ts +344 -0
- package/src/authored-flow-loader.ts +44 -0
- package/src/authored-flow-operation.ts +252 -0
- package/src/authored-flow.ts +21 -0
- package/src/authored-promise-graph.ts +196 -0
- package/src/backlog-picker.ts +153 -0
- package/src/canonical.ts +57 -0
- package/src/cli/check.ts +391 -0
- package/src/cli/direct-run.ts +86 -0
- package/src/cli/hn-monitor.ts +286 -0
- package/src/cli/interruptible-sleep.ts +27 -0
- package/src/cli/run.ts +439 -0
- package/src/cli/tick-runner.ts +378 -0
- package/src/cli-adapter.ts +115 -0
- package/src/cli-executable.ts +12 -0
- package/src/cli.ts +364 -0
- package/src/compile.ts +573 -0
- package/src/demo-hn-monitor.ts +132 -0
- package/src/dir-watcher-poller.ts +122 -0
- package/src/direct-input.ts +69 -0
- package/src/failure-kinds.ts +77 -0
- package/src/gate-contract.ts +72 -0
- package/src/hn-poller.ts +104 -0
- package/src/index.ts +195 -0
- package/src/journal-client.ts +379 -0
- package/src/json-schema-bound.ts +357 -0
- package/src/json-schema.ts +65 -0
- package/src/json-value.ts +110 -0
- package/src/model-name.ts +20 -0
- package/src/output-schema.ts +33 -0
- package/src/preflight.ts +482 -0
- package/src/protocol.ts +364 -0
- package/src/spec.ts +343 -0
- package/src/step-dependencies.ts +100 -0
- package/src/step-fields.ts +36 -0
- package/src/tick-source.ts +334 -0
- package/src/unknown-keys.ts +52 -0
- package/src/validate.ts +503 -0
- package/src/work-package-consumer.ts +73 -0
- package/src/work-package-validator.ts +90 -0
- package/src/worker-cli.ts +110 -0
- package/src/worker.ts +150 -0
- package/src/wrapper-runtime.ts +93 -0
- package/src/wrapper-session.ts +287 -0
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
import { spawn } from 'node:child_process';
|
|
2
|
+
import { WRAPPER_EXECUTE_TOKEN, WRAPPER_IDENTIFY_ARG, WRAPPER_IDENTIFY_TOKEN, } from './cli-adapter.js';
|
|
3
|
+
import { captureWrapperIdentity, sameWrapperIdentity, } from './wrapper-runtime.js';
|
|
4
|
+
const DEFAULT_LIMITS = {
|
|
5
|
+
handshakeTimeoutMs: 10_000,
|
|
6
|
+
executionTimeoutMs: 300_000,
|
|
7
|
+
maxOutputBytes: 1_048_576,
|
|
8
|
+
};
|
|
9
|
+
const HANDSHAKE_OUTPUT_LIMIT = 8_192;
|
|
10
|
+
const FORCE_KILL_DELAY_MS = 1_000;
|
|
11
|
+
/**
|
|
12
|
+
* Grace after `SIGKILL` before the reader settles on its own. Node emits
|
|
13
|
+
* `'close'` only once every inherited stdio pipe is closed, which any
|
|
14
|
+
* descendant of the wrapper can withhold forever. Resolution therefore may
|
|
15
|
+
* not depend on `'close'`: past this point the reader settles regardless.
|
|
16
|
+
*/
|
|
17
|
+
const SETTLE_AFTER_KILL_MS = 250;
|
|
18
|
+
/**
|
|
19
|
+
* Identify and execute a custom wrapper in one pinned process. No private
|
|
20
|
+
* request is written until its declared path still names the captured file.
|
|
21
|
+
*/
|
|
22
|
+
export function runWrapperSession(cli, instruction, wakeContext, model, env, overrides = {}) {
|
|
23
|
+
const limits = sessionLimits(overrides);
|
|
24
|
+
let request;
|
|
25
|
+
try {
|
|
26
|
+
request = JSON.stringify({
|
|
27
|
+
protocol: WRAPPER_IDENTIFY_TOKEN,
|
|
28
|
+
instruction,
|
|
29
|
+
...(model !== undefined ? { model } : {}),
|
|
30
|
+
...(wakeContext !== undefined ? { wakeContext } : {}),
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
return Promise.resolve(failure(`wake_context could not be JSON-serialized for the CLI: ${String(error)}`));
|
|
35
|
+
}
|
|
36
|
+
let identity;
|
|
37
|
+
try {
|
|
38
|
+
identity = captureWrapperIdentity(cli, env);
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
return Promise.resolve(failure(`CLI ${JSON.stringify(cli)} wrapper identity could not be pinned: ${String(error)}`));
|
|
42
|
+
}
|
|
43
|
+
return executePinnedWrapper(cli, identity, request, env, limits);
|
|
44
|
+
}
|
|
45
|
+
function executePinnedWrapper(cli, identity, request, env, limits) {
|
|
46
|
+
return new Promise((resolve) => {
|
|
47
|
+
const child = spawn(identity.executable, [WRAPPER_IDENTIFY_ARG], {
|
|
48
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
49
|
+
env,
|
|
50
|
+
});
|
|
51
|
+
const stdout = [];
|
|
52
|
+
const stderr = [];
|
|
53
|
+
let handshakePending = '';
|
|
54
|
+
let executionPending = '';
|
|
55
|
+
let capturedBytes = 0;
|
|
56
|
+
let phase = 'identity';
|
|
57
|
+
let protocolError;
|
|
58
|
+
let settled = false;
|
|
59
|
+
let lifecycleTimer;
|
|
60
|
+
let killTimer;
|
|
61
|
+
let settleTimer;
|
|
62
|
+
const clearTimers = () => {
|
|
63
|
+
if (lifecycleTimer !== undefined)
|
|
64
|
+
clearTimeout(lifecycleTimer);
|
|
65
|
+
if (killTimer !== undefined)
|
|
66
|
+
clearTimeout(killTimer);
|
|
67
|
+
if (settleTimer !== undefined)
|
|
68
|
+
clearTimeout(settleTimer);
|
|
69
|
+
};
|
|
70
|
+
const finish = (result) => {
|
|
71
|
+
if (settled)
|
|
72
|
+
return;
|
|
73
|
+
settled = true;
|
|
74
|
+
clearTimers();
|
|
75
|
+
resolve(result);
|
|
76
|
+
};
|
|
77
|
+
const terminate = (message) => {
|
|
78
|
+
if (protocolError !== undefined)
|
|
79
|
+
return;
|
|
80
|
+
protocolError = message;
|
|
81
|
+
if (lifecycleTimer !== undefined)
|
|
82
|
+
clearTimeout(lifecycleTimer);
|
|
83
|
+
child.kill('SIGTERM');
|
|
84
|
+
killTimer = setTimeout(() => child.kill('SIGKILL'), FORCE_KILL_DELAY_MS);
|
|
85
|
+
killTimer.unref();
|
|
86
|
+
// The reader owns the bound. `'close'` is emitted only after every
|
|
87
|
+
// inherited stdio pipe closes, so a wrapper that leaves a descendant
|
|
88
|
+
// holding one withholds it forever and strands the step with no
|
|
89
|
+
// `completionReason` at all. Settle on our own deadline instead — the
|
|
90
|
+
// same shape `spawnInvocation` uses in worker-cli.ts, where the timer
|
|
91
|
+
// resolves rather than delegating to a child-controlled event. The
|
|
92
|
+
// result is byte-identical to the one the `'close'` path would build
|
|
93
|
+
// for this `protocolError`, so this changes only WHEN we settle.
|
|
94
|
+
settleTimer = setTimeout(() => finish(failure(message)), FORCE_KILL_DELAY_MS + SETTLE_AFTER_KILL_MS);
|
|
95
|
+
};
|
|
96
|
+
const startExecutionTimer = () => {
|
|
97
|
+
if (lifecycleTimer !== undefined)
|
|
98
|
+
clearTimeout(lifecycleTimer);
|
|
99
|
+
lifecycleTimer = setTimeout(() => terminate(`CLI ${JSON.stringify(cli)} execution timed out after ${limits.executionTimeoutMs}ms.`), limits.executionTimeoutMs);
|
|
100
|
+
};
|
|
101
|
+
const exceedsOutputLimit = (additionalBytes) => {
|
|
102
|
+
const pendingBytes = Buffer.byteLength(executionPending);
|
|
103
|
+
if (capturedBytes + pendingBytes + additionalBytes <= limits.maxOutputBytes)
|
|
104
|
+
return false;
|
|
105
|
+
terminate(`CLI ${JSON.stringify(cli)} exceeded the captured output limit of ${limits.maxOutputBytes} bytes.`);
|
|
106
|
+
return true;
|
|
107
|
+
};
|
|
108
|
+
const appendStdout = (value) => {
|
|
109
|
+
const bytes = Buffer.byteLength(value);
|
|
110
|
+
capturedBytes += bytes;
|
|
111
|
+
stdout.push(value);
|
|
112
|
+
};
|
|
113
|
+
const acceptHandshakeLine = (line) => {
|
|
114
|
+
const normalized = normalizeLine(line);
|
|
115
|
+
if (phase === 'identity') {
|
|
116
|
+
if (normalized !== WRAPPER_IDENTIFY_TOKEN) {
|
|
117
|
+
terminate(`CLI ${JSON.stringify(cli)} did not identify as ${WRAPPER_IDENTIFY_TOKEN} at worker execution.`);
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
if (!sameWrapperIdentity(cli, env, identity)) {
|
|
121
|
+
terminate(`CLI ${JSON.stringify(cli)} wrapper identity changed before private request delivery.`);
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
phase = 'ack';
|
|
125
|
+
child.stdin.end(`${request}\n`);
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
if (phase === 'ack') {
|
|
129
|
+
if (normalized !== WRAPPER_EXECUTE_TOKEN) {
|
|
130
|
+
terminate(`CLI ${JSON.stringify(cli)} did not accept the ${WRAPPER_IDENTIFY_TOKEN} same-process execution request.`);
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
phase = 'execute';
|
|
134
|
+
startExecutionTimer();
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
const acceptExecutionData = (chunk) => {
|
|
138
|
+
executionPending += chunk;
|
|
139
|
+
if (exceedsOutputLimit(0))
|
|
140
|
+
return;
|
|
141
|
+
while (true) {
|
|
142
|
+
const newline = executionPending.indexOf('\n');
|
|
143
|
+
if (newline < 0)
|
|
144
|
+
return;
|
|
145
|
+
const line = executionPending.slice(0, newline);
|
|
146
|
+
executionPending = executionPending.slice(newline + 1);
|
|
147
|
+
if (normalizeLine(line) === WRAPPER_EXECUTE_TOKEN) {
|
|
148
|
+
terminate(`CLI ${JSON.stringify(cli)} emitted a duplicate execute protocol frame.`);
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
appendStdout(`${line}\n`);
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
const handshakeComplete = () => phase === 'execute';
|
|
155
|
+
lifecycleTimer = setTimeout(() => terminate(`CLI ${JSON.stringify(cli)} did not identify as ${WRAPPER_IDENTIFY_TOKEN} within ${limits.handshakeTimeoutMs}ms.`), limits.handshakeTimeoutMs);
|
|
156
|
+
child.stdout.setEncoding('utf8');
|
|
157
|
+
child.stdout.on('data', (chunk) => {
|
|
158
|
+
if (protocolError !== undefined)
|
|
159
|
+
return;
|
|
160
|
+
if (phase === 'execute') {
|
|
161
|
+
acceptExecutionData(chunk);
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
handshakePending += chunk;
|
|
165
|
+
// Drain every complete line FIRST. The handshake bound belongs to the
|
|
166
|
+
// handshake, and a line that is already terminated is no longer part
|
|
167
|
+
// of it: the execute token sitting at the front of this buffer ends
|
|
168
|
+
// the handshake, and the bytes behind it are execution output bound by
|
|
169
|
+
// `maxOutputBytes`. Measuring the whole buffer before draining capped a
|
|
170
|
+
// conforming wrapper's first result flush at HANDSHAKE_OUTPUT_LIMIT
|
|
171
|
+
// whenever the OS coalesced its writes, and named the wrong bound.
|
|
172
|
+
while (!handshakeComplete()) {
|
|
173
|
+
const newline = handshakePending.indexOf('\n');
|
|
174
|
+
if (newline < 0)
|
|
175
|
+
break;
|
|
176
|
+
const line = handshakePending.slice(0, newline);
|
|
177
|
+
handshakePending = handshakePending.slice(newline + 1);
|
|
178
|
+
acceptHandshakeLine(line);
|
|
179
|
+
if (protocolError !== undefined)
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
if (handshakeComplete()) {
|
|
183
|
+
if (handshakePending.length > 0) {
|
|
184
|
+
const remainder = handshakePending;
|
|
185
|
+
handshakePending = '';
|
|
186
|
+
acceptExecutionData(remainder);
|
|
187
|
+
}
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
// Still handshaking: bound the un-terminated residue, which is the only
|
|
191
|
+
// buffer the handshake still owns.
|
|
192
|
+
if (Buffer.byteLength(handshakePending) > HANDSHAKE_OUTPUT_LIMIT) {
|
|
193
|
+
terminate(`CLI ${JSON.stringify(cli)} exceeded the wrapper handshake limit of ${HANDSHAKE_OUTPUT_LIMIT} bytes before completing the ${WRAPPER_IDENTIFY_TOKEN} handshake.`);
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
child.stderr.on('data', (chunk) => {
|
|
197
|
+
if (protocolError !== undefined || exceedsOutputLimit(chunk.byteLength))
|
|
198
|
+
return;
|
|
199
|
+
capturedBytes += chunk.byteLength;
|
|
200
|
+
stderr.push(chunk);
|
|
201
|
+
});
|
|
202
|
+
child.stdin.on('error', () => {
|
|
203
|
+
// A child that closes stdin before acknowledgement is classified on close.
|
|
204
|
+
});
|
|
205
|
+
child.once('error', (error) => finish(failure(error.message)));
|
|
206
|
+
child.once('close', (code) => {
|
|
207
|
+
if (protocolError === undefined && phase === 'execute' && executionPending.length > 0) {
|
|
208
|
+
if (normalizeLine(executionPending) === WRAPPER_EXECUTE_TOKEN) {
|
|
209
|
+
protocolError = `CLI ${JSON.stringify(cli)} emitted a duplicate execute protocol frame.`;
|
|
210
|
+
}
|
|
211
|
+
else if (!exceedsOutputLimit(0)) {
|
|
212
|
+
appendStdout(executionPending);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
if (protocolError !== undefined || phase !== 'execute') {
|
|
216
|
+
finish(failure(protocolError
|
|
217
|
+
?? `CLI ${JSON.stringify(cli)} exited before completing the ${WRAPPER_IDENTIFY_TOKEN} same-process handshake.`));
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
finish({
|
|
221
|
+
exit_code: code,
|
|
222
|
+
stdout_tail: stdout.join(''),
|
|
223
|
+
stderr_tail: Buffer.concat(stderr).toString('utf8'),
|
|
224
|
+
});
|
|
225
|
+
});
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
function sessionLimits(overrides) {
|
|
229
|
+
return {
|
|
230
|
+
handshakeTimeoutMs: positiveLimit(overrides.handshakeTimeoutMs, DEFAULT_LIMITS.handshakeTimeoutMs),
|
|
231
|
+
executionTimeoutMs: positiveLimit(overrides.executionTimeoutMs, DEFAULT_LIMITS.executionTimeoutMs),
|
|
232
|
+
maxOutputBytes: positiveLimit(overrides.maxOutputBytes, DEFAULT_LIMITS.maxOutputBytes),
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
function positiveLimit(value, fallback) {
|
|
236
|
+
return value !== undefined && Number.isSafeInteger(value) && value > 0 ? value : fallback;
|
|
237
|
+
}
|
|
238
|
+
function normalizeLine(line) {
|
|
239
|
+
return line.endsWith('\r') ? line.slice(0, -1) : line;
|
|
240
|
+
}
|
|
241
|
+
function failure(stderr_tail) {
|
|
242
|
+
return { exit_code: null, stdout_tail: '', stderr_tail };
|
|
243
|
+
}
|
|
244
|
+
//# sourceMappingURL=wrapper-session.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wrapper-session.js","sourceRoot":"","sources":["../src/wrapper-session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,sBAAsB,GACvB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,sBAAsB,EACtB,mBAAmB,GAEpB,MAAM,sBAAsB,CAAC;AAc9B,MAAM,cAAc,GAAyB;IAC3C,kBAAkB,EAAE,MAAM;IAC1B,kBAAkB,EAAE,OAAO;IAC3B,cAAc,EAAE,SAAS;CAC1B,CAAC;AACF,MAAM,sBAAsB,GAAG,KAAK,CAAC;AACrC,MAAM,mBAAmB,GAAG,KAAK,CAAC;AAClC;;;;;GAKG;AACH,MAAM,oBAAoB,GAAG,GAAG,CAAC;AAEjC;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAC/B,GAAW,EACX,WAAmB,EACnB,WAAoB,EACpB,KAAyB,EACzB,GAAsB,EACtB,YAA2C,EAAE;IAE7C,MAAM,MAAM,GAAG,aAAa,CAAC,SAAS,CAAC,CAAC;IACxC,IAAI,OAAe,CAAC;IACpB,IAAI,CAAC;QACH,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC;YACvB,QAAQ,EAAE,sBAAsB;YAChC,WAAW;YACX,GAAG,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACzC,GAAG,CAAC,WAAW,KAAK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C,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AACxD,CAAC;AAED,SAAS,OAAO,CAAC,WAAmB;IAClC,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,WAAW,EAAE,EAAE,EAAE,WAAW,EAAE,CAAC;AAC3D,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@relayflows/sdk",
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"description": "TypeScript-first authoring SDK for Relayflows. Compiles specs; speaks the journal protocol.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"bin": {
|
|
9
|
+
"flows": "./dist/cli.js"
|
|
10
|
+
},
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"import": "./dist/index.js"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist",
|
|
19
|
+
"src"
|
|
20
|
+
],
|
|
21
|
+
"scripts": {
|
|
22
|
+
"build": "tsc && node scripts/make-cli-executable.mjs",
|
|
23
|
+
"demo:hn": "npm run build && node dist/demo-hn-monitor.js",
|
|
24
|
+
"prepare": "npm run build",
|
|
25
|
+
"typecheck": "tsc --noEmit && tsc -p tsconfig.type-tests.json",
|
|
26
|
+
"typecheck:tests": "tsc -p tsconfig.tests.json",
|
|
27
|
+
"test:prep": "( cd ../../kernel && sh ../ops/cargo.sh build ) && ( [ ! -d ../../testdata/preflight ] || find ../../testdata/preflight -name '*-cli' -type f -exec chmod +x {} + )",
|
|
28
|
+
"test": "sh scripts/test.sh",
|
|
29
|
+
"test:watch": "vitest"
|
|
30
|
+
},
|
|
31
|
+
"license": "Apache-2.0",
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@relayflows/surface": "2.0.0",
|
|
34
|
+
"@types/js-yaml": "^4.0.9",
|
|
35
|
+
"ajv": "^8.17.1",
|
|
36
|
+
"ajv-draft-04": "^1.0.0",
|
|
37
|
+
"js-yaml": "^5.4.1",
|
|
38
|
+
"yaml": "^2.5.1"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@types/node": "^22.7.0",
|
|
42
|
+
"typescript": "^5.6.0",
|
|
43
|
+
"vitest": "^2.1.0"
|
|
44
|
+
},
|
|
45
|
+
"repository": {
|
|
46
|
+
"type": "git",
|
|
47
|
+
"url": "git+https://github.com/AgentWorkforce/flows.git",
|
|
48
|
+
"directory": "packages/sdk"
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
CompletionReason as ProtocolCompletionReason,
|
|
3
|
+
RunCompletionReason as ProtocolRunCompletionReason,
|
|
4
|
+
} from './protocol.js';
|
|
5
|
+
|
|
6
|
+
export type AuthoredFlowExecutionErrorCode =
|
|
7
|
+
| 'duplicate_completion'
|
|
8
|
+
| 'journal_protocol_violation'
|
|
9
|
+
| 'missing_completion'
|
|
10
|
+
| 'operation_after_completion'
|
|
11
|
+
| 'operation_callback_failed'
|
|
12
|
+
| 'step_failed'
|
|
13
|
+
| 'unsupported_completion'
|
|
14
|
+
| 'unsupported_gate'
|
|
15
|
+
| 'unsupported_header'
|
|
16
|
+
| 'unsettled_derived_work'
|
|
17
|
+
| 'unsupported_promise_lifecycle'
|
|
18
|
+
| 'unawaited_step'
|
|
19
|
+
| 'unsupported_verb';
|
|
20
|
+
|
|
21
|
+
export class AuthoredFlowExecutionError extends Error {
|
|
22
|
+
constructor(
|
|
23
|
+
readonly code: AuthoredFlowExecutionErrorCode,
|
|
24
|
+
message: string,
|
|
25
|
+
readonly completionReason?: ProtocolCompletionReason | ProtocolRunCompletionReason,
|
|
26
|
+
readonly runId?: string,
|
|
27
|
+
) {
|
|
28
|
+
super(`${code}: ${message}`);
|
|
29
|
+
this.name = 'AuthoredFlowExecutionError';
|
|
30
|
+
}
|
|
31
|
+
}
|