@relayflows/sdk 2.0.36 → 2.0.37
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-executor.d.ts +2 -0
- package/dist/authored-flow-executor.d.ts.map +1 -1
- package/dist/authored-flow-executor.js +2 -1
- package/dist/authored-flow-executor.js.map +1 -1
- package/dist/authored-helper-effect.d.ts.map +1 -1
- package/dist/authored-helper-effect.js +3 -2
- package/dist/authored-helper-effect.js.map +1 -1
- package/dist/authored-mcp.d.ts.map +1 -1
- package/dist/authored-mcp.js +2 -0
- package/dist/authored-mcp.js.map +1 -1
- package/dist/authored-node-entry.js +6 -0
- package/dist/authored-node-entry.js.map +1 -1
- package/dist/authored-node-runner.d.ts.map +1 -1
- package/dist/authored-node-runner.js +2 -1
- package/dist/authored-node-runner.js.map +1 -1
- package/dist/authored-plugin-effect.d.ts.map +1 -1
- package/dist/authored-plugin-effect.js +2 -0
- package/dist/authored-plugin-effect.js.map +1 -1
- package/dist/authored-preflight.d.ts +1 -1
- package/dist/authored-preflight.d.ts.map +1 -1
- package/dist/authored-preflight.js +2 -2
- package/dist/authored-preflight.js.map +1 -1
- package/dist/authored-root.d.ts +2 -0
- package/dist/authored-root.d.ts.map +1 -1
- package/dist/authored-root.js +5 -0
- package/dist/authored-root.js.map +1 -1
- package/dist/authored-verdict.d.ts +2 -0
- package/dist/authored-verdict.d.ts.map +1 -1
- package/dist/authored-verdict.js +2 -1
- package/dist/authored-verdict.js.map +1 -1
- package/dist/authored-worker-step.d.ts +1 -1
- package/dist/authored-worker-step.d.ts.map +1 -1
- package/dist/authored-worker-step.js +2 -2
- package/dist/authored-worker-step.js.map +1 -1
- package/dist/cli/check.d.ts +2 -0
- package/dist/cli/check.d.ts.map +1 -1
- package/dist/cli/check.js +3 -3
- package/dist/cli/check.js.map +1 -1
- package/dist/cli/cli-probe.d.ts +2 -2
- package/dist/cli/cli-probe.d.ts.map +1 -1
- package/dist/cli/cli-probe.js +8 -7
- package/dist/cli/cli-probe.js.map +1 -1
- package/dist/cli/direct-run.d.ts.map +1 -1
- package/dist/cli/direct-run.js +7 -2
- package/dist/cli/direct-run.js.map +1 -1
- package/dist/cli/run.d.ts.map +1 -1
- package/dist/cli/run.js +15 -9
- package/dist/cli/run.js.map +1 -1
- package/dist/communication/local.d.ts +1 -1
- package/dist/communication/local.d.ts.map +1 -1
- package/dist/communication/local.js +2 -2
- package/dist/communication/local.js.map +1 -1
- package/dist/communication/worker.d.ts +1 -1
- package/dist/communication/worker.d.ts.map +1 -1
- package/dist/communication/worker.js +4 -4
- package/dist/communication/worker.js.map +1 -1
- package/dist/decimal-dollars.d.ts +12 -0
- package/dist/decimal-dollars.d.ts.map +1 -0
- package/dist/decimal-dollars.js +39 -0
- package/dist/decimal-dollars.js.map +1 -0
- package/dist/effect-channel.d.ts.map +1 -1
- package/dist/effect-channel.js +2 -0
- package/dist/effect-channel.js.map +1 -1
- package/dist/helper-instruction.d.ts +3 -0
- package/dist/helper-instruction.d.ts.map +1 -0
- package/dist/helper-instruction.js +3 -0
- package/dist/helper-instruction.js.map +1 -0
- package/dist/journal-client.d.ts +5 -2
- package/dist/journal-client.d.ts.map +1 -1
- package/dist/journal-client.js +12 -4
- package/dist/journal-client.js.map +1 -1
- package/dist/llm-worker.d.ts +2 -1
- package/dist/llm-worker.d.ts.map +1 -1
- package/dist/llm-worker.js +7 -2
- package/dist/llm-worker.js.map +1 -1
- package/dist/local-agent-environment.d.ts +13 -0
- package/dist/local-agent-environment.d.ts.map +1 -0
- package/dist/local-agent-environment.js +104 -0
- package/dist/local-agent-environment.js.map +1 -0
- package/dist/local-agent.d.ts +1 -1
- package/dist/local-agent.d.ts.map +1 -1
- package/dist/local-agent.js +2 -2
- package/dist/local-agent.js.map +1 -1
- package/dist/protocol.d.ts +21 -0
- package/dist/protocol.d.ts.map +1 -1
- package/dist/reported-cost-total.d.ts +41 -0
- package/dist/reported-cost-total.d.ts.map +1 -0
- package/dist/reported-cost-total.js +63 -0
- package/dist/reported-cost-total.js.map +1 -0
- package/dist/reported-cost.d.ts +24 -0
- package/dist/reported-cost.d.ts.map +1 -0
- package/dist/reported-cost.js +49 -0
- package/dist/reported-cost.js.map +1 -0
- package/dist/run-state.d.ts +9 -11
- package/dist/run-state.d.ts.map +1 -1
- package/dist/run-state.js +15 -38
- package/dist/run-state.js.map +1 -1
- package/dist/worker-cli.d.ts +1 -1
- package/dist/worker-cli.d.ts.map +1 -1
- package/dist/worker-cli.js +3 -3
- package/dist/worker-cli.js.map +1 -1
- package/dist/worker.d.ts +2 -0
- package/dist/worker.d.ts.map +1 -1
- package/dist/worker.js +5 -2
- package/dist/worker.js.map +1 -1
- package/dist/yaml-helper-effect.d.ts.map +1 -1
- package/dist/yaml-helper-effect.js +2 -1
- package/dist/yaml-helper-effect.js.map +1 -1
- package/dist/yaml-helpers.d.ts.map +1 -1
- package/dist/yaml-helpers.js +2 -1
- package/dist/yaml-helpers.js.map +1 -1
- package/package.json +2 -2
- package/src/authored-flow-executor.ts +4 -1
- package/src/authored-helper-effect.ts +3 -2
- package/src/authored-mcp.ts +2 -0
- package/src/authored-node-entry.ts +8 -1
- package/src/authored-node-runner.ts +2 -1
- package/src/authored-plugin-effect.ts +2 -0
- package/src/authored-preflight.ts +2 -2
- package/src/authored-root.ts +7 -0
- package/src/authored-verdict.ts +2 -1
- package/src/authored-worker-step.ts +2 -1
- package/src/cli/check.ts +6 -3
- package/src/cli/cli-probe.ts +8 -6
- package/src/cli/direct-run.ts +7 -1
- package/src/cli/run.ts +15 -7
- package/src/communication/local.ts +3 -2
- package/src/communication/worker.ts +7 -4
- package/src/decimal-dollars.ts +38 -0
- package/src/effect-channel.ts +2 -0
- package/src/helper-instruction.ts +2 -0
- package/src/journal-client.ts +14 -5
- package/src/llm-worker.ts +6 -1
- package/src/local-agent-environment.ts +92 -0
- package/src/local-agent.ts +2 -1
- package/src/protocol.ts +22 -0
- package/src/reported-cost-total.ts +82 -0
- package/src/reported-cost.ts +51 -0
- package/src/run-state.ts +25 -37
- package/src/worker-cli.ts +3 -2
- package/src/worker.ts +9 -2
- package/src/yaml-helper-effect.ts +2 -1
- package/src/yaml-helpers.ts +2 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"yaml-helper-effect.d.ts","sourceRoot":"","sources":["../src/yaml-helper-effect.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAEvD,OAAO,EAAgB,KAAK,UAAU,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"yaml-helper-effect.d.ts","sourceRoot":"","sources":["../src/yaml-helper-effect.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAEvD,OAAO,EAAgB,KAAK,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAIlE,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,oBAAc,GAAG,MAAM,GAAG,SAAS,CAMnF;AAED,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAErD;AA6BD,sFAAsF;AACtF,wBAAsB,sBAAsB,CAC1C,MAAM,EAAE,aAAa,EAAE,QAAQ,EAAE,iBAAiB,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,GACpF,OAAO,CAAC,IAAI,CAAC,CAwBf"}
|
|
@@ -5,6 +5,7 @@ import { writeJsonFile } from '@relayfile/adapter-core/vfs-client';
|
|
|
5
5
|
import { atomicJson, readSlackReceipt, receiptPath, slackWriteback } from './slack-writeback.js';
|
|
6
6
|
import { invokeHelper } from './yaml-helpers.js';
|
|
7
7
|
import { withWorkerLease } from './worker-lease.js';
|
|
8
|
+
import { NO_MODEL_COST } from './reported-cost.js';
|
|
8
9
|
export function helperMount(provider, env = process.env) {
|
|
9
10
|
const root = [env.RELAYFILE_MOUNT_PATH, env.WORKSPACE_ROOT, env.WORKFORCE_SANDBOX_ROOT,
|
|
10
11
|
env.RELAYFILE_MOUNT_ROOT, env.RELAYFILE_ROOT].find(value => value?.trim());
|
|
@@ -73,7 +74,7 @@ export async function completeHelperDispatch(client, dispatch, call, dataDir) {
|
|
|
73
74
|
receipt = await readSlackReceipt(file);
|
|
74
75
|
return { ...call, idempotencyKey: `${dispatch.run_id}:${dispatch.step_id}`, receipt };
|
|
75
76
|
});
|
|
76
|
-
await client.stepComplete(dispatch.run_id, dispatch.step_id, dispatch.attempt, dispatch.idempotency_key, 'success', { output, started_pins: dispatch.pins, end_pins: dispatch.pins,
|
|
77
|
+
await client.stepComplete(dispatch.run_id, dispatch.step_id, dispatch.attempt, dispatch.idempotency_key, 'success', { output, started_pins: dispatch.pins, end_pins: dispatch.pins, reported_cost: NO_MODEL_COST,
|
|
77
78
|
effects: [{ surface_path: surfacePath, idempotency_key: dispatch.idempotency_key }] });
|
|
78
79
|
}
|
|
79
80
|
//# sourceMappingURL=yaml-helper-effect.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"yaml-helper-effect.js","sourceRoot":"","sources":["../src/yaml-helper-effect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AAInE,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACjG,OAAO,EAAE,YAAY,EAAmB,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,mBAA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e,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"yaml-helpers.d.ts","sourceRoot":"","sources":["../src/yaml-helpers.ts"],"names":[],"mappings":"AACA,OAAO,EAA2C,KAAK,cAAc,EAAE,MAAM,0BAA0B,CAAC;AACxG,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AA0DlF,MAAM,MAAM,UAAU,GAAG;KAAG,CAAC,IAAI,MAAM,gBAAgB,GAAG;SAAG,CAAC,IAAI,MAAM,gBAAgB,CAAC,CAAC,CAAC,GACzF;YAAE,IAAI,EAAE,QAAQ,CAAC;YAAC,QAAQ,EAAE,CAAC,CAAC;YAAC,IAAI,EAAE,CAAC,CAAC;YAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;SAAE;KACzE,CAAC,MAAM,gBAAgB,CAAC,CAAC,CAAC,CAAC;CAAE,CAAC,MAAM,gBAAgB,CAAC,CAAC;AA2BvD,wEAAwE;AACxE,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CA4BxD;AAED,sFAAsF;AACtF,wBAAgB,UAAU,CAAC,IAAI,EAAE,OAAO,CAAC,aAAa,GAAG,eAAe,CAAC,GAAG,UAAU,GAAG,SAAS,CAKjG;AAED,wBAAsB,YAAY,CAAC,IAAI,EAAE,UAAU,EAAE,SAAS,EAAE,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC,CAGhG"}
|
package/dist/yaml-helpers.js
CHANGED
|
@@ -2,6 +2,7 @@ import Ajv from 'ajv';
|
|
|
2
2
|
import { githubClient, linearClient, slackClient } from '@relayfile/relay-helpers';
|
|
3
3
|
import { canonicalize } from './canonical.js';
|
|
4
4
|
import { unknownKeyErrors } from './unknown-keys.js';
|
|
5
|
+
import { HELPER_INSTRUCTION_PREFIX } from './helper-instruction.js';
|
|
5
6
|
const string = { type: 'string', minLength: 1 };
|
|
6
7
|
const text = { type: 'string' };
|
|
7
8
|
const strings = { type: 'array', items: string };
|
|
@@ -40,7 +41,7 @@ const helpers = {
|
|
|
40
41
|
args: object(issueChanges, []) }), (p, transport) => linearClient({ transport }).updateIssue(p.issueId, p.args)),
|
|
41
42
|
},
|
|
42
43
|
};
|
|
43
|
-
const prefix =
|
|
44
|
+
const prefix = HELPER_INSTRUCTION_PREFIX;
|
|
44
45
|
const commonFields = ['id', 'dependsOn', 'maxIterations', 'verification', 'output'];
|
|
45
46
|
const isObject = (value) => value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
46
47
|
function descriptor(provider, name) {
|
package/dist/yaml-helpers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"yaml-helpers.js","sourceRoot":"","sources":["../src/yaml-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,WAAW,EAAuB,MAAM,0BAA0B,CAAC;AAExG,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"yaml-helpers.js","sourceRoot":"","sources":["../src/yaml-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,WAAW,EAAuB,MAAM,0BAA0B,CAAC;AAExG,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AAEpE,MAAM,MAAM,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC;AAChD,MAAM,IAAI,GAAG,EAAE,IAAI,EAAE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AW,CAAC,UAAU,CAAC,MAAM,CAAC;QAAE,OAAO,SAAS,CAAC;IAC5H,MAAM,IAAI,GAAG,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAC7E,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAC,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,wDAAwD,CAAC,CAAC;IACvI,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,IAAgB,EAAE,SAAyB;IAC5E,MAAM,SAAS,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;IACrC,OAAO,CAAC,MAAM,UAAU,CAAC,SAAS,CAAC,QAAQ,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,IAAI,IAAI,CAAC;AAC5G,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@relayflows/sdk",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.37",
|
|
4
4
|
"description": "TypeScript-first authoring SDK for Relayflows. Compiles specs; speaks the journal protocol.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"@modelcontextprotocol/sdk": "^1.30.0",
|
|
50
50
|
"@relayfile/adapter-core": "0.6.2",
|
|
51
51
|
"@relayfile/relay-helpers": "0.4.12",
|
|
52
|
-
"@relayflows/surface": "2.0.
|
|
52
|
+
"@relayflows/surface": "2.0.37",
|
|
53
53
|
"@types/js-yaml": "^4.0.9",
|
|
54
54
|
"acorn": "^8.18.0",
|
|
55
55
|
"ai-hist": "0.4.1",
|
|
@@ -185,6 +185,8 @@ export interface ExecuteAuthoredFlowOptions {
|
|
|
185
185
|
readonly onWait?: RunLifecycleOptions['onWait'];
|
|
186
186
|
readonly onProgress?: (event: ProgressEvent) => void;
|
|
187
187
|
readonly localAgentStream?: string;
|
|
188
|
+
/** Environment reserved for provider probes and local agent subprocesses. */
|
|
189
|
+
readonly agentEnvironment?: NodeJS.ProcessEnv;
|
|
188
190
|
/**
|
|
189
191
|
* How many agent (and, separately, LLM) dispatches the attached local
|
|
190
192
|
* workers hold at once. Set, it caps this body's concurrent `f.agent` /
|
|
@@ -320,7 +322,7 @@ export async function executeAuthoredFlow<Input = undefined>(
|
|
|
320
322
|
const worker = authoredWorkerRunner(
|
|
321
323
|
definition, journal, flowPath, journalSteps, waitOptions,
|
|
322
324
|
localAgentStream, budget, definition.header.budget, options.rootRunId, options.workerCapacity, stepEdges,
|
|
323
|
-
options.workerSlots,
|
|
325
|
+
options.workerSlots, options.agentEnvironment,
|
|
324
326
|
);
|
|
325
327
|
|
|
326
328
|
/**
|
|
@@ -685,6 +687,7 @@ export async function executeAuthoredFlow<Input = undefined>(
|
|
|
685
687
|
dataDir: options.dataDir,
|
|
686
688
|
flowPath: child.path,
|
|
687
689
|
...(localAgentStream === undefined ? {} : { localAgentStream }),
|
|
690
|
+
...(options.agentEnvironment === undefined ? {} : { agentEnvironment: options.agentEnvironment }),
|
|
688
691
|
...(options.workerCapacity === undefined ? {} : { workerCapacity: options.workerCapacity }),
|
|
689
692
|
...(options.rootRunId === undefined ? {} : { rootRunId: options.rootRunId }),
|
|
690
693
|
flowGraph: options.flowGraph,
|
|
@@ -14,6 +14,7 @@ import { helperWriteback, HelperDeliveryError } from './helper-writeback.js';
|
|
|
14
14
|
import { checkSlackHelpers } from './slack-preflight.js';
|
|
15
15
|
import { atomicJson, readSlackReceipt, receiptPath, slackWriteback, type SlackCall } from './slack-writeback.js';
|
|
16
16
|
import { authoredChildAdmissionKey } from './authored-admission.js';
|
|
17
|
+
import { NO_MODEL_COST } from './reported-cost.js';
|
|
17
18
|
|
|
18
19
|
type ProviderCall = HelperCall | SlackCall;
|
|
19
20
|
|
|
@@ -135,11 +136,11 @@ async function completeHelperDispatch(client: JournalClient, dispatch: StepDispa
|
|
|
135
136
|
await client.stepComplete(dispatch.run_id, dispatch.step_id, dispatch.attempt,
|
|
136
137
|
dispatch.idempotency_key, 'worker_error', {
|
|
137
138
|
output: { ...call, diagnostic: error.message },
|
|
138
|
-
started_pins: dispatch.pins, end_pins: dispatch.pins, effects: [],
|
|
139
|
+
started_pins: dispatch.pins, end_pins: dispatch.pins, effects: [], reported_cost: NO_MODEL_COST,
|
|
139
140
|
});
|
|
140
141
|
return;
|
|
141
142
|
}
|
|
142
143
|
await client.stepComplete(dispatch.run_id, dispatch.step_id, dispatch.attempt,
|
|
143
|
-
dispatch.idempotency_key, 'success', { output, started_pins: dispatch.pins, end_pins: dispatch.pins,
|
|
144
|
+
dispatch.idempotency_key, 'success', { output, started_pins: dispatch.pins, end_pins: dispatch.pins, reported_cost: NO_MODEL_COST,
|
|
144
145
|
effects: [{ surface_path: `/${call.provider}`, idempotency_key: dispatch.idempotency_key }] });
|
|
145
146
|
}
|
package/src/authored-mcp.ts
CHANGED
|
@@ -12,6 +12,7 @@ import type { AuthoredFlowJournalStep } from './authored-flow-executor.js';
|
|
|
12
12
|
import { readCompletedStepOutput } from './authored-step-output.js';
|
|
13
13
|
import { withWorkerLease } from './worker-lease.js';
|
|
14
14
|
import { authoredChildAdmissionKey } from './authored-admission.js';
|
|
15
|
+
import { NO_MODEL_COST } from './reported-cost.js';
|
|
15
16
|
|
|
16
17
|
/** Own keys expose precisely the preflight inventory, including prototype-like names. */
|
|
17
18
|
export function buildMcpProxy(
|
|
@@ -116,6 +117,7 @@ export async function runMcpEffect(
|
|
|
116
117
|
output: { ...receipt, output: output ?? null, ...(diagnostic ? { diagnostic } : {}) },
|
|
117
118
|
started_pins: event.pins, end_pins: event.pins,
|
|
118
119
|
...(diagnostic ? { trajectory_tail: { ...receipt, diagnostic } } : {}),
|
|
120
|
+
reported_cost: NO_MODEL_COST,
|
|
119
121
|
effects: confirmed ? [{ surface_path: surfacePath, idempotency_key: event.idempotency_key }] : [],
|
|
120
122
|
});
|
|
121
123
|
}
|
|
@@ -8,6 +8,7 @@ import { assertAuthoredNodeVersion, parseAuthoredParentPid } from './authored-ru
|
|
|
8
8
|
import { AuthoredFlowExecutionError, AuthoredHumanParked } from './authored-flow-error.js';
|
|
9
9
|
import { isAgentCapacity } from './worker-slots.js';
|
|
10
10
|
import type { AuthoredRootMetadata } from './authored-root.js';
|
|
11
|
+
import { validatedLocalAgentEnvironment } from './local-agent-environment.js';
|
|
11
12
|
|
|
12
13
|
let channelKey: string | undefined, sequence = 0;
|
|
13
14
|
// Capture writers before loading authored modules; credentials never enter env.
|
|
@@ -49,7 +50,8 @@ try {
|
|
|
49
50
|
send({ type: 'ready', runtime: { kind: 'node', version: process.versions.node,
|
|
50
51
|
executableSha256: hash(process.execPath), payloadSha256: hash(process.argv[1]!) } });
|
|
51
52
|
const request = await new Promise<{ channelKey: string; metadata: AuthoredRootMetadata; socketPath: string;
|
|
52
|
-
rootRunId: string; dataDir: string; localAgentStream?: string; workerCapacity?: number
|
|
53
|
+
rootRunId: string; dataDir: string; localAgentStream?: string; workerCapacity?: number;
|
|
54
|
+
agentEnvironment?: unknown }>((resolve, reject) => {
|
|
53
55
|
let buffer = '';
|
|
54
56
|
process.stdin.setEncoding('utf8');
|
|
55
57
|
const onData = (chunk: string): void => {
|
|
@@ -65,6 +67,10 @@ try {
|
|
|
65
67
|
if (typeof request.channelKey !== 'string' || !/^[a-f0-9]{64}$/.test(request.channelKey)) throw new Error('invalid authored channel key');
|
|
66
68
|
channelKey = request.channelKey;
|
|
67
69
|
controller.signal.throwIfAborted();
|
|
70
|
+
// Validate the parent handoff before evaluating any authored module. Only
|
|
71
|
+
// provider credentials may cross this channel; controls such as PATH and
|
|
72
|
+
// NODE_OPTIONS remain the child's inherited values.
|
|
73
|
+
const agentEnvironment = validatedLocalAgentEnvironment(request.agentEnvironment);
|
|
68
74
|
const loaded = await loadPinnedAuthoredSource(request.metadata, true);
|
|
69
75
|
if (request.localAgentStream !== request.metadata.localAgentStream) throw new Error('authored root local agent surface mismatch');
|
|
70
76
|
if (request.workerCapacity !== undefined && !isAgentCapacity(request.workerCapacity)) throw new Error('invalid authored worker capacity');
|
|
@@ -78,6 +84,7 @@ try {
|
|
|
78
84
|
flowGraph: loaded.graph,
|
|
79
85
|
localAgentStream: request.localAgentStream, signal: controller.signal,
|
|
80
86
|
...(request.workerCapacity === undefined ? {} : { workerCapacity: request.workerCapacity }),
|
|
87
|
+
...(agentEnvironment === undefined ? {} : { agentEnvironment: { ...process.env, ...agentEnvironment } }),
|
|
81
88
|
onProgress: event => send({ type: 'progress', event }),
|
|
82
89
|
onWait: event => send({ type: 'wait', event }),
|
|
83
90
|
});
|
|
@@ -134,7 +134,8 @@ export async function runAuthoredInNode(
|
|
|
134
134
|
// Keep stdin open: EOF tells the child its lease-owning parent died.
|
|
135
135
|
child.stdin!.write(JSON.stringify({ channelKey, metadata, socketPath, rootRunId,
|
|
136
136
|
dataDir: options.dataDir, localAgentStream: options.localAgentStream,
|
|
137
|
-
workerCapacity: options.workerCapacity
|
|
137
|
+
workerCapacity: options.workerCapacity,
|
|
138
|
+
agentEnvironment: options.agentEnvironment }) + '\n');
|
|
138
139
|
} else if (!ready || result) throw new Error('unexpected authored runtime message');
|
|
139
140
|
else if (message.type === 'progress') options.onProgress?.(message.event);
|
|
140
141
|
else if (message.type === 'wait') options.onWait?.(message.event);
|
|
@@ -11,6 +11,7 @@ import type { AuthoredFlowJournalStep } from './authored-flow-executor.js';
|
|
|
11
11
|
import { readCompletedStepOutput } from './authored-step-output.js';
|
|
12
12
|
import { withWorkerLease } from './worker-lease.js';
|
|
13
13
|
import { authoredChildAdmissionKey } from './authored-admission.js';
|
|
14
|
+
import { NO_MODEL_COST } from './reported-cost.js';
|
|
14
15
|
|
|
15
16
|
export class PluginStepError extends AuthoredFlowExecutionError {
|
|
16
17
|
constructor(readonly diagnostic: string, runId: string) {
|
|
@@ -88,6 +89,7 @@ export async function runPluginEffect(
|
|
|
88
89
|
output: { ...receipt, output: output ?? null, ...(diagnostic ? { diagnostic } : {}) },
|
|
89
90
|
started_pins: event.pins, end_pins: event.pins,
|
|
90
91
|
...(diagnostic ? { trajectory_tail: { ...receipt, diagnostic } } : {}),
|
|
92
|
+
reported_cost: NO_MODEL_COST,
|
|
91
93
|
effects: confirmed ? [{ surface_path: surfacePath, idempotency_key: event.idempotency_key }] : [],
|
|
92
94
|
});
|
|
93
95
|
}
|
|
@@ -6,7 +6,7 @@ import { cliProbeKey, CliProbeError, resolvePreflight, type CliProbeOutcome } fr
|
|
|
6
6
|
import type { FlowSpec } from './spec.js';
|
|
7
7
|
|
|
8
8
|
/** Auth/model facts belong to one execution, including concurrent cold callers. */
|
|
9
|
-
export function authoredPreflight(path: string) {
|
|
9
|
+
export function authoredPreflight(path: string, environment?: NodeJS.ProcessEnv) {
|
|
10
10
|
const probeCache = new Map<string, CliProbeOutcome>();
|
|
11
11
|
const pending = new Map<string, Promise<void>>();
|
|
12
12
|
const directory = dirname(resolve(path));
|
|
@@ -30,7 +30,7 @@ export function authoredPreflight(path: string) {
|
|
|
30
30
|
try {
|
|
31
31
|
probeCache.set(key, { result: await probeCliAsync(resolution.cli,
|
|
32
32
|
resolution.source === 'project' ? config.directory : directory,
|
|
33
|
-
resolution.model, managed ? 'managed' : undefined) });
|
|
33
|
+
resolution.model, managed ? 'managed' : undefined, environment) });
|
|
34
34
|
} catch (error) {
|
|
35
35
|
probeCache.set(key, { failure: error instanceof CliProbeError ? error.detail : null });
|
|
36
36
|
}
|
package/src/authored-root.ts
CHANGED
|
@@ -21,6 +21,7 @@ import { AuthoredFlowExecutionError, AuthoredHumanParked } from './authored-flow
|
|
|
21
21
|
import { readOpenHumanWaits } from './authored-human.js';
|
|
22
22
|
import { isSurfaceCompletionReason } from './authored-step-output.js';
|
|
23
23
|
import { readSubscriptionPark } from './authored-subscription-park.js';
|
|
24
|
+
import { localAgentCredentialEnvironment } from './local-agent-environment.js';
|
|
24
25
|
|
|
25
26
|
export type DurableAuthoredFlowResult =
|
|
26
27
|
| (AuthoredFlowExecutionResult & { readonly rootRunId: string })
|
|
@@ -67,6 +68,8 @@ export interface DurableAuthoredOptions {
|
|
|
67
68
|
readonly localAgentStream?: string;
|
|
68
69
|
/** Concurrency of the attached local workers; see `ExecuteAuthoredFlowOptions.workerCapacity`. */
|
|
69
70
|
readonly workerCapacity?: number;
|
|
71
|
+
/** Provider-only environment consumed by preflight and local workers. */
|
|
72
|
+
readonly agentEnvironment?: NodeJS.ProcessEnv;
|
|
70
73
|
readonly lifecycle?: RunLifecycleOptions;
|
|
71
74
|
}
|
|
72
75
|
|
|
@@ -226,6 +229,9 @@ async function driveRoot(
|
|
|
226
229
|
if (process.versions['bun'] !== undefined) {
|
|
227
230
|
return runAuthoredInNode(metadata, journal.socketPath, dispatch.run_id, {
|
|
228
231
|
dataDir: options.dataDir, localAgentStream: options.localAgentStream,
|
|
232
|
+
...(options.agentEnvironment === undefined ? {} : {
|
|
233
|
+
agentEnvironment: localAgentCredentialEnvironment(options.agentEnvironment),
|
|
234
|
+
}),
|
|
229
235
|
...(options.workerCapacity === undefined ? {} : { workerCapacity: options.workerCapacity }),
|
|
230
236
|
...options.lifecycle, signal,
|
|
231
237
|
});
|
|
@@ -239,6 +245,7 @@ async function driveRoot(
|
|
|
239
245
|
dataDir: options.dataDir,
|
|
240
246
|
flowPath: metadata.flowPath,
|
|
241
247
|
localAgentStream: options.localAgentStream,
|
|
248
|
+
...(options.agentEnvironment === undefined ? {} : { agentEnvironment: options.agentEnvironment }),
|
|
242
249
|
...(options.workerCapacity === undefined ? {} : { workerCapacity: options.workerCapacity }),
|
|
243
250
|
rootRunId: dispatch.run_id,
|
|
244
251
|
extensions: loaded.extensions,
|
package/src/authored-verdict.ts
CHANGED
|
@@ -67,7 +67,8 @@ export function authoredVerdictOf(events: readonly JournalEvent[]): AuthoredVerd
|
|
|
67
67
|
return Object.freeze({ reason, ...(detail === undefined ? {} : { detail }) });
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
|
|
70
|
+
/** Whether a journal's spawned spec is a real authored root, not a step merely named `authored-root`. */
|
|
71
|
+
export function declaresAuthoredRoot(spawned: JournalEvent): boolean {
|
|
71
72
|
const spec = record(record(spawned.payload)?.['spec']);
|
|
72
73
|
const steps = spec?.['steps'];
|
|
73
74
|
if (!Array.isArray(steps)) return false;
|
|
@@ -27,6 +27,7 @@ export function authoredWorkerRunner(
|
|
|
27
27
|
localAgentStream?: string, budget?: AuthoredBudget, headerBudget?: unknown,
|
|
28
28
|
rootRunId?: string, workerCapacity?: number, stepEdges?: AuthoredStepContext['stepEdges'],
|
|
29
29
|
sharedSlots?: AuthoredWorkerSlots,
|
|
30
|
+
agentEnvironment?: NodeJS.ProcessEnv,
|
|
30
31
|
) {
|
|
31
32
|
// Sized to the attached local workers, so concurrent calls wait here for a
|
|
32
33
|
// slot instead of being admitted and parked for want of a free worker.
|
|
@@ -36,7 +37,7 @@ export function authoredWorkerRunner(
|
|
|
36
37
|
agent: slots.agent.scope(),
|
|
37
38
|
llm: slots.llm.scope(),
|
|
38
39
|
};
|
|
39
|
-
const check = authoredPreflight(flowPath);
|
|
40
|
+
const check = authoredPreflight(flowPath, agentEnvironment);
|
|
40
41
|
const context: AuthoredStepContext = {
|
|
41
42
|
...(rootRunId === undefined ? {} : { rootRunId }),
|
|
42
43
|
...(waitOptions.dataDir === undefined ? {} : { dataDir: waitOptions.dataDir }),
|
package/src/cli/check.ts
CHANGED
|
@@ -123,6 +123,8 @@ type CliProbeOutcomeMap = Map<string, CliProbeOutcome>;
|
|
|
123
123
|
* anything that depends on how the flow is about to be invoked opts in here.
|
|
124
124
|
*/
|
|
125
125
|
export interface CheckInvocation {
|
|
126
|
+
/** Environment used only by provider executable/auth/model probes. */
|
|
127
|
+
environment?: NodeJS.ProcessEnv;
|
|
126
128
|
/**
|
|
127
129
|
* Report `agent_worker_unresolved` when the spec has `agent` steps.
|
|
128
130
|
*
|
|
@@ -202,7 +204,7 @@ export function checkAuthoredFlow(
|
|
|
202
204
|
: projectConfigOrOptions as ProjectConfig | undefined;
|
|
203
205
|
const effectiveProbeCache = cliProbeCache ?? options?.probeCache;
|
|
204
206
|
const config = projectConfig ?? readProjectConfig(dirname(absolutePath));
|
|
205
|
-
const probes = systemProbes(dirname(absolutePath), config);
|
|
207
|
+
const probes = systemProbes(dirname(absolutePath), config, invocation.environment);
|
|
206
208
|
const result = preflight(authoring, {
|
|
207
209
|
...(effectiveProbeCache === undefined ? {} : { cliProbeCache: effectiveProbeCache }),
|
|
208
210
|
projectCli: config.cli,
|
|
@@ -450,10 +452,11 @@ function findConfig(start: string): string | undefined {
|
|
|
450
452
|
}
|
|
451
453
|
}
|
|
452
454
|
|
|
453
|
-
function systemProbes(flowDirectory: string, config: ProjectConfig): PreflightProbes {
|
|
455
|
+
function systemProbes(flowDirectory: string, config: ProjectConfig, environment?: NodeJS.ProcessEnv): PreflightProbes {
|
|
454
456
|
return {
|
|
455
457
|
helper: helperReady,
|
|
456
|
-
cli: (cli, source, model, execution) => probeCli(cli,
|
|
458
|
+
cli: (cli, source, model, execution) => probeCli(cli,
|
|
459
|
+
source === 'project' ? config.directory : flowDirectory, model, execution, environment),
|
|
457
460
|
executor: (trigger) => config.executors.includes(trigger.executor),
|
|
458
461
|
// A deterministic step runs in the daemon's working directory — the
|
|
459
462
|
// directory `flows run` was invoked from, or Cloud's code mount — not in
|
package/src/cli/cli-probe.ts
CHANGED
|
@@ -27,8 +27,8 @@ export async function probeCliAsync(...args: Parameters<typeof probeSequence>):
|
|
|
27
27
|
return next.value;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
export function resolveExecutable(command: string, directory: string): string | undefined {
|
|
31
|
-
return driveSync(executableSequence(command, directory));
|
|
30
|
+
export function resolveExecutable(command: string, directory: string, environment: NodeJS.ProcessEnv = process.env): string | undefined {
|
|
31
|
+
return driveSync(executableSequence(command, directory, environment));
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
function driveSync<T>(sequence: Generator<ProbeRequest, T, ProbeOutput>): T {
|
|
@@ -79,8 +79,9 @@ function* probeSequence(
|
|
|
79
79
|
directory: string,
|
|
80
80
|
model?: string,
|
|
81
81
|
execution?: 'managed',
|
|
82
|
+
sourceEnvironment: NodeJS.ProcessEnv = process.env,
|
|
82
83
|
): Generator<ProbeRequest, CliProbeResult, ProbeOutput> {
|
|
83
|
-
const executable = yield* executableSequence(cli, directory);
|
|
84
|
+
const executable = yield* executableSequence(cli, directory, sourceEnvironment);
|
|
84
85
|
if (executable === undefined) return { exists: false, authenticated: false };
|
|
85
86
|
const kind = cliAdapterKind(executable);
|
|
86
87
|
// Relay owns interactive CLI launch/injection. Its generic PTY path is not
|
|
@@ -90,7 +91,8 @@ function* probeSequence(
|
|
|
90
91
|
return { exists: true, supported: true, authenticated: 'unverified' };
|
|
91
92
|
}
|
|
92
93
|
const environment = execution === 'managed'
|
|
93
|
-
? { ...brokerEnvironment(
|
|
94
|
+
? { ...brokerEnvironment(sourceEnvironment), ...agentEnvironment(executable, sourceEnvironment) }
|
|
95
|
+
: sourceEnvironment;
|
|
94
96
|
const probe = (invocation: CliInvocation): ProbeRequest => ({ executable, directory, invocation, environment });
|
|
95
97
|
const identification = adapterIdentification(kind);
|
|
96
98
|
const identified = yield probe(identification.invocation);
|
|
@@ -176,7 +178,7 @@ function redactProbeOutput(text: string): string {
|
|
|
176
178
|
.replace(/\b[A-Fa-f0-9]{32,}\b/g, '<redacted-hex>');
|
|
177
179
|
}
|
|
178
180
|
|
|
179
|
-
function* executableSequence(command: string, directory: string): Generator<ProbeRequest, string | undefined, ProbeOutput> {
|
|
181
|
+
function* executableSequence(command: string, directory: string, environment: NodeJS.ProcessEnv): Generator<ProbeRequest, string | undefined, ProbeOutput> {
|
|
180
182
|
if (command.includes('/') || isAbsolute(command)) {
|
|
181
183
|
const path = isAbsolute(command) ? command : resolve(directory, command);
|
|
182
184
|
try {
|
|
@@ -187,7 +189,7 @@ function* executableSequence(command: string, directory: string): Generator<Prob
|
|
|
187
189
|
}
|
|
188
190
|
}
|
|
189
191
|
const result = yield { executable: 'which', directory: process.cwd(),
|
|
190
|
-
invocation: { args: [command], timeoutMs: 5_000 }, environment
|
|
192
|
+
invocation: { args: [command], timeoutMs: 5_000 }, environment };
|
|
191
193
|
return result.status === 0 ? result.stdout.trim() : undefined;
|
|
192
194
|
}
|
|
193
195
|
|
package/src/cli/direct-run.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { McpPreflightError } from './check-typescript.js';
|
|
|
6
6
|
import { attachLocalAgent } from '../local-agent.js';
|
|
7
7
|
import { LlmWorker } from '../llm-worker.js';
|
|
8
8
|
import { DEFAULT_LOCAL_AGENT_CAPACITY } from '../worker-slots.js';
|
|
9
|
+
import { localAgentEnvironment } from '../local-agent-environment.js';
|
|
9
10
|
import {
|
|
10
11
|
AuthoredFlowExecutionError,
|
|
11
12
|
} from '../authored-flow-executor.js';
|
|
@@ -38,6 +39,9 @@ export async function runDirectFlow(
|
|
|
38
39
|
dataDir: string,
|
|
39
40
|
options: RunLifecycleOptions = {},
|
|
40
41
|
): Promise<RunExecution> {
|
|
42
|
+
// Consume and close the agent-only descriptor before authored source is
|
|
43
|
+
// imported by trigger preflight. Authored code never receives this object.
|
|
44
|
+
const agentEnvironment = localAgentEnvironment();
|
|
41
45
|
let input: unknown;
|
|
42
46
|
try {
|
|
43
47
|
input = parseDirectInput(inputArgument);
|
|
@@ -78,13 +82,14 @@ export async function runDirectFlow(
|
|
|
78
82
|
if (options.localAgent) {
|
|
79
83
|
localAgent = await attachLocalAgent(
|
|
80
84
|
client, dataDir, options.onPtyReady, authoredLocalAgentStream(admissionIdentity), workerCapacity,
|
|
85
|
+
undefined, [], agentEnvironment,
|
|
81
86
|
);
|
|
82
87
|
// A session owns one worker registration. Keep the workspace-free LLM
|
|
83
88
|
// worker on its own connection so it cannot replace the agent worker.
|
|
84
89
|
llmClient = new JournalClient(socketPath);
|
|
85
90
|
await llmClient.connect();
|
|
86
91
|
await llmClient.hello('flows-local-llm');
|
|
87
|
-
localLlm = new LlmWorker(llmClient, `${localAgent.stream}-llm`, workerCapacity);
|
|
92
|
+
localLlm = new LlmWorker(llmClient, `${localAgent.stream}-llm`, workerCapacity, agentEnvironment);
|
|
88
93
|
localLlm.on('error', onWorkerFailure('local-llm', error => { llmFailure = error; client.close(); }));
|
|
89
94
|
await localLlm.attach();
|
|
90
95
|
}
|
|
@@ -96,6 +101,7 @@ export async function runDirectFlow(
|
|
|
96
101
|
onAdmitted: runId => { base.rootRunId = runId; },
|
|
97
102
|
localAgentStream: localAgent?.stream,
|
|
98
103
|
...(localAgent === undefined ? {} : { workerCapacity }),
|
|
104
|
+
...(agentEnvironment === undefined ? {} : { agentEnvironment }),
|
|
99
105
|
lifecycle: {
|
|
100
106
|
onProgress: options.onProgress,
|
|
101
107
|
...(options.onRunStarted !== undefined ? { onRunStarted: options.onRunStarted } : {}),
|
package/src/cli/run.ts
CHANGED
|
@@ -39,6 +39,7 @@ import {
|
|
|
39
39
|
type LoweredCompletionReason,
|
|
40
40
|
} from '../authored-completion.js';
|
|
41
41
|
import { DEFAULT_LOCAL_AGENT_CAPACITY } from '../worker-slots.js';
|
|
42
|
+
import { localAgentEnvironment } from '../local-agent-environment.js';
|
|
42
43
|
import {
|
|
43
44
|
checkFlow,
|
|
44
45
|
type CheckReport,
|
|
@@ -176,20 +177,22 @@ export async function runFlow(
|
|
|
176
177
|
dataDir: string,
|
|
177
178
|
options: RunLifecycleOptions = {},
|
|
178
179
|
): Promise<RunExecution> {
|
|
180
|
+
const agentEnvironment = localAgentEnvironment();
|
|
179
181
|
const prepared = parseDigestReference(path) ? await prepareDigestRun(path, options.bucket) : undefined;
|
|
180
182
|
if (prepared && 'exitCode' in prepared) return prepared;
|
|
181
|
-
const checked = prepared ?? checkFlow(path);
|
|
183
|
+
const checked = prepared ?? checkFlow(path, { environment: agentEnvironment });
|
|
182
184
|
if (!checked.report.ok || checked.flow === undefined) {
|
|
183
185
|
return { exitCode: 2, report: fromCheckReport('run', checked.report) };
|
|
184
186
|
}
|
|
185
187
|
|
|
186
|
-
return executeCheckedFlow(checked, dataDir, options);
|
|
188
|
+
return executeCheckedFlow(checked, dataDir, options, agentEnvironment);
|
|
187
189
|
}
|
|
188
190
|
|
|
189
191
|
async function executeCheckedFlow(
|
|
190
192
|
checked: ReturnType<typeof checkFlow>,
|
|
191
193
|
dataDir: string,
|
|
192
194
|
options: RunLifecycleOptions,
|
|
195
|
+
agentEnvironment?: NodeJS.ProcessEnv,
|
|
193
196
|
): Promise<RunExecution> {
|
|
194
197
|
const socketPath = socketFor(dataDir);
|
|
195
198
|
// Carry the preflight's diagnostics as a RunReport from here on, so the
|
|
@@ -213,12 +216,12 @@ async function executeCheckedFlow(
|
|
|
213
216
|
if (options.localAgent) {
|
|
214
217
|
localAgent = await attachLocalAgent(
|
|
215
218
|
client, dataDir, options.onPtyReady, undefined, options.agentCapacity,
|
|
216
|
-
undefined, declaredLocalAgentStreams(spec),
|
|
219
|
+
undefined, declaredLocalAgentStreams(spec), agentEnvironment,
|
|
217
220
|
);
|
|
218
221
|
}
|
|
219
222
|
if (options.localAgent && spec.steps.some(step => step.type === 'agent' && communicationInstruction(step.instruction))) {
|
|
220
223
|
const { attachCommunicationWorkers } = await import('../communication/local.js');
|
|
221
|
-
communicationWorkers = await attachCommunicationWorkers(spec, socketPath, dataDir);
|
|
224
|
+
communicationWorkers = await attachCommunicationWorkers(spec, socketPath, dataDir, agentEnvironment);
|
|
222
225
|
}
|
|
223
226
|
if (options.onJournalEntry !== undefined) client.on('entry', options.onJournalEntry);
|
|
224
227
|
const outcome = await startWatched(client, spec, options);
|
|
@@ -281,6 +284,9 @@ export async function resumeFlow(
|
|
|
281
284
|
dataDir: string,
|
|
282
285
|
options: RunLifecycleOptions = {},
|
|
283
286
|
): Promise<RunExecution> {
|
|
287
|
+
// Resume can load authored source; consume the descriptor before reading the
|
|
288
|
+
// journal so no source evaluation can race credential pickup.
|
|
289
|
+
const agentEnvironment = localAgentEnvironment();
|
|
284
290
|
const socketPath = socketFor(dataDir);
|
|
285
291
|
const base = emptyReport('resume');
|
|
286
292
|
const client = new JournalClient(socketPath);
|
|
@@ -323,11 +329,12 @@ export async function resumeFlow(
|
|
|
323
329
|
if (options.localAgent) {
|
|
324
330
|
authoredAgent = await attachLocalAgent(
|
|
325
331
|
client, dataDir, options.onPtyReady, authoredRoot.localAgentStream, workerCapacity,
|
|
332
|
+
undefined, [], agentEnvironment,
|
|
326
333
|
);
|
|
327
334
|
authoredLlmClient = new JournalClient(socketPath);
|
|
328
335
|
await authoredLlmClient.connect();
|
|
329
336
|
await authoredLlmClient.hello('flows-authored-resume-llm');
|
|
330
|
-
authoredLlm = new LlmWorker(authoredLlmClient, `${authoredAgent.stream}-llm`, workerCapacity);
|
|
337
|
+
authoredLlm = new LlmWorker(authoredLlmClient, `${authoredAgent.stream}-llm`, workerCapacity, agentEnvironment);
|
|
331
338
|
authoredLlm.on('error', onWorkerFailure('resume-llm', error => {
|
|
332
339
|
llmFailure = error;
|
|
333
340
|
client.close();
|
|
@@ -338,6 +345,7 @@ export async function resumeFlow(
|
|
|
338
345
|
dataDir,
|
|
339
346
|
localAgentStream: authoredAgent?.stream,
|
|
340
347
|
...(authoredAgent === undefined ? {} : { workerCapacity }),
|
|
348
|
+
...(agentEnvironment === undefined ? {} : { agentEnvironment }),
|
|
341
349
|
lifecycle: options,
|
|
342
350
|
});
|
|
343
351
|
if (result === undefined) throw new Error('authored root disappeared during resume');
|
|
@@ -356,11 +364,11 @@ export async function resumeFlow(
|
|
|
356
364
|
if (!spec) throw new Error('Cannot attach a local worker: the journaled run spec is missing');
|
|
357
365
|
authoredAgent = await attachLocalAgent(
|
|
358
366
|
client, dataDir, options.onPtyReady, undefined, options.agentCapacity,
|
|
359
|
-
undefined, declaredLocalAgentStreams(spec),
|
|
367
|
+
undefined, declaredLocalAgentStreams(spec), agentEnvironment,
|
|
360
368
|
);
|
|
361
369
|
if (spec?.steps.some(step => step.type === 'agent' && communicationInstruction(step.instruction))) {
|
|
362
370
|
const { attachCommunicationWorkers } = await import('../communication/local.js');
|
|
363
|
-
communicationWorkers = await attachCommunicationWorkers(spec, socketPath, dataDir);
|
|
371
|
+
communicationWorkers = await attachCommunicationWorkers(spec, socketPath, dataDir, agentEnvironment);
|
|
364
372
|
}
|
|
365
373
|
}
|
|
366
374
|
const onEntry = options.onJournalEntry;
|
|
@@ -8,7 +8,8 @@ import { loadRelayModules } from './relay.js';
|
|
|
8
8
|
import { checkCommunicationEnvironment, CommunicationEnvironmentError } from './preflight.js';
|
|
9
9
|
import { requireCommunicationCli } from './worker.js';
|
|
10
10
|
|
|
11
|
-
export async function attachCommunicationWorkers(spec: KernelRunSpec, socketPath: string, dataDir: string
|
|
11
|
+
export async function attachCommunicationWorkers(spec: KernelRunSpec, socketPath: string, dataDir: string,
|
|
12
|
+
environment?: NodeJS.ProcessEnv) {
|
|
12
13
|
const steps = spec.steps.filter(step => step.type === 'agent' && communicationInstruction(step.instruction));
|
|
13
14
|
checkCommunicationEnvironment(spec);
|
|
14
15
|
try { await loadRelayModules(); }
|
|
@@ -28,7 +29,7 @@ export async function attachCommunicationWorkers(spec: KernelRunSpec, socketPath
|
|
|
28
29
|
requireCommunicationCli(step.cli ?? spec.cli);
|
|
29
30
|
if (step.surfaces?.workspace?.length) throw new Error('Local communication workers support stream surfaces only');
|
|
30
31
|
const client = new JournalClient(socketPath);
|
|
31
|
-
const worker = new AgentWorker(client, { workerId: `communication-${randomUUID()}`, dataDir,
|
|
32
|
+
const worker = new AgentWorker(client, { workerId: `communication-${randomUUID()}`, dataDir, environment,
|
|
32
33
|
requiredStreams: [channelName(step.id, '$receipts')],
|
|
33
34
|
pins: { workspace: [], streams: step.surfaces?.streams?.map(({ stream }) => ({ stream, read_offset: 0 })) ?? [] } });
|
|
34
35
|
workers.push({ client, worker });
|
|
@@ -18,13 +18,15 @@ export function requireCommunicationCli(cli: string | undefined): void {
|
|
|
18
18
|
if (!cli?.trim()) throw new Error('Agent communication requires a declared CLI executable');
|
|
19
19
|
}
|
|
20
20
|
export async function completeCommunicationDispatch(client: JournalClient, dispatch: StepDispatchEvent,
|
|
21
|
-
instruction: CommunicationInstruction, dataDir: string, runRoot?: string
|
|
21
|
+
instruction: CommunicationInstruction, dataDir: string, runRoot?: string,
|
|
22
|
+
environment?: NodeJS.ProcessEnv): Promise<void> {
|
|
22
23
|
const spec = dispatch.spec as KernelAgentStep;
|
|
23
24
|
requireCommunicationCli(spec.cli);
|
|
24
25
|
let output: unknown;
|
|
25
26
|
let completionReason: 'success' | 'worker_error' = 'success';
|
|
26
27
|
try {
|
|
27
|
-
output = await withWorkerLease(client, dispatch, signal =>
|
|
28
|
+
output = await withWorkerLease(client, dispatch, signal =>
|
|
29
|
+
run(client, dispatch, instruction, spec, dataDir, signal, runRoot, environment));
|
|
28
30
|
} catch (error) {
|
|
29
31
|
completionReason = 'worker_error';
|
|
30
32
|
output = { error: error instanceof Error ? error.message : String(error) };
|
|
@@ -34,7 +36,8 @@ export async function completeCommunicationDispatch(client: JournalClient, dispa
|
|
|
34
36
|
started_pins: dispatch.pins, end_pins: dispatch.pins });
|
|
35
37
|
}
|
|
36
38
|
async function run(client: JournalClient, dispatch: StepDispatchEvent, instruction: CommunicationInstruction,
|
|
37
|
-
spec: KernelAgentStep, dataDir: string, lease: AbortSignal, runRoot?: string
|
|
39
|
+
spec: KernelAgentStep, dataDir: string, lease: AbortSignal, runRoot?: string,
|
|
40
|
+
environment?: NodeJS.ProcessEnv): Promise<unknown> {
|
|
38
41
|
// Same contract as the CLI worker: a declared directory is resolved and held
|
|
39
42
|
// inside the same run root the CLI worker measures against, before anything
|
|
40
43
|
// is spawned. Thrown, not reported, because `completeCommunicationDispatch`
|
|
@@ -80,7 +83,7 @@ async function run(client: JournalClient, dispatch: StepDispatchEvent, instructi
|
|
|
80
83
|
handle = await relay.broker.spawnPty({ name, cli: basename(spec.cli!).replace(/\.exe$/i, ''), task: prompt, channels: [], skipRelayPrompt: true,
|
|
81
84
|
model: resolveCliModel(spec.cli!, spec.model), cwd: directory,
|
|
82
85
|
harnessConfig: { runtime: 'pty', command: quote(spec.cli!), args: [],
|
|
83
|
-
cwd: directory, env: { ...agentEnvironment(spec.cli
|
|
86
|
+
cwd: directory, env: { ...agentEnvironment(spec.cli!, environment ?? process.env),
|
|
84
87
|
RELAYFLOW_COMMUNICATION_SOCKET: tools.path, RELAYFLOW_COMMUNICATION_TOKEN: tools.token },
|
|
85
88
|
delivery: { mode: 'pty-injection', format: 'relay-block' } } });
|
|
86
89
|
const ready = await handle.waitForReady(Math.min(instruction.timeoutMs, 90_000));
|