@relayflows/sdk 2.0.42 → 2.0.43
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/adapters/base.d.ts +12 -1
- package/dist/adapters/base.d.ts.map +1 -1
- package/dist/adapters/base.js +11 -1
- package/dist/adapters/base.js.map +1 -1
- package/dist/adapters/claude.d.ts.map +1 -1
- package/dist/adapters/claude.js +8 -4
- package/dist/adapters/claude.js.map +1 -1
- package/dist/adapters/codex.d.ts.map +1 -1
- package/dist/adapters/codex.js +15 -6
- package/dist/adapters/codex.js.map +1 -1
- package/dist/agent-resume.d.ts +8 -0
- package/dist/agent-resume.d.ts.map +1 -0
- package/dist/agent-resume.js +37 -0
- package/dist/agent-resume.js.map +1 -0
- package/dist/agent-transcript.d.ts.map +1 -1
- package/dist/agent-transcript.js +5 -3
- package/dist/agent-transcript.js.map +1 -1
- package/dist/authored-flow-error.d.ts +10 -2
- package/dist/authored-flow-error.d.ts.map +1 -1
- package/dist/authored-flow-error.js.map +1 -1
- package/dist/authored-flow-executor.d.ts.map +1 -1
- package/dist/authored-flow-executor.js +16 -2
- package/dist/authored-flow-executor.js.map +1 -1
- package/dist/authored-flow-loader.d.ts +6 -0
- package/dist/authored-flow-loader.d.ts.map +1 -1
- package/dist/authored-flow-loader.js +18 -6
- package/dist/authored-flow-loader.js.map +1 -1
- package/dist/authored-helper-effect.js +3 -2
- package/dist/authored-helper-effect.js.map +1 -1
- package/dist/authored-human.d.ts +2 -0
- package/dist/authored-human.d.ts.map +1 -1
- package/dist/authored-human.js +4 -0
- package/dist/authored-human.js.map +1 -1
- package/dist/authored-memory.d.ts +47 -2
- package/dist/authored-memory.d.ts.map +1 -1
- package/dist/authored-memory.js +394 -15
- package/dist/authored-memory.js.map +1 -1
- package/dist/authored-node-entry.js +6 -1
- package/dist/authored-node-entry.js.map +1 -1
- package/dist/authored-node-runner.d.ts +1 -1
- package/dist/authored-node-runner.d.ts.map +1 -1
- package/dist/authored-node-runner.js +6 -3
- package/dist/authored-node-runner.js.map +1 -1
- package/dist/authored-root-readback.d.ts +21 -0
- package/dist/authored-root-readback.d.ts.map +1 -0
- package/dist/authored-root-readback.js +90 -0
- package/dist/authored-root-readback.js.map +1 -0
- package/dist/authored-root.d.ts.map +1 -1
- package/dist/authored-root.js +53 -74
- package/dist/authored-root.js.map +1 -1
- package/dist/authored-step-output.d.ts +2 -0
- package/dist/authored-step-output.d.ts.map +1 -1
- package/dist/authored-step-output.js +1 -0
- package/dist/authored-step-output.js.map +1 -1
- package/dist/authored-worker-step.d.ts.map +1 -1
- package/dist/authored-worker-step.js +26 -4
- package/dist/authored-worker-step.js.map +1 -1
- package/dist/cli/check-helper-body.d.ts +2 -2
- package/dist/cli/check-helper-body.d.ts.map +1 -1
- package/dist/cli/check-helper-body.js +7 -2
- package/dist/cli/check-helper-body.js.map +1 -1
- package/dist/cli/check-helper-surface.d.ts +8 -0
- package/dist/cli/check-helper-surface.d.ts.map +1 -0
- package/dist/cli/check-helper-surface.js +37 -0
- package/dist/cli/check-helper-surface.js.map +1 -0
- package/dist/cli/check-triggers.d.ts +4 -3
- package/dist/cli/check-triggers.d.ts.map +1 -1
- package/dist/cli/check-triggers.js +7 -3
- package/dist/cli/check-triggers.js.map +1 -1
- package/dist/cli/check.d.ts +7 -1
- package/dist/cli/check.d.ts.map +1 -1
- package/dist/cli/check.js +35 -8
- package/dist/cli/check.js.map +1 -1
- package/dist/cli/cloud-answer.d.ts +9 -0
- package/dist/cli/cloud-answer.d.ts.map +1 -0
- package/dist/cli/cloud-answer.js +39 -0
- package/dist/cli/cloud-answer.js.map +1 -0
- package/dist/cli/cloud-connect-cli.d.ts +2 -1
- package/dist/cli/cloud-connect-cli.d.ts.map +1 -1
- package/dist/cli/cloud-connect-cli.js +10 -2
- package/dist/cli/cloud-connect-cli.js.map +1 -1
- package/dist/cli/cloud-human.d.ts +7 -0
- package/dist/cli/cloud-human.d.ts.map +1 -0
- package/dist/cli/cloud-human.js +22 -0
- package/dist/cli/cloud-human.js.map +1 -0
- package/dist/cli/cloud-live.d.ts +2 -2
- package/dist/cli/cloud-live.d.ts.map +1 -1
- package/dist/cli/cloud-live.js +9 -2
- package/dist/cli/cloud-live.js.map +1 -1
- package/dist/cli/cloud-mirror-session.d.ts.map +1 -1
- package/dist/cli/cloud-mirror-session.js +3 -2
- package/dist/cli/cloud-mirror-session.js.map +1 -1
- package/dist/cli/cloud-run.d.ts +1 -1
- package/dist/cli/cloud-run.d.ts.map +1 -1
- package/dist/cli/cloud-run.js +12 -0
- package/dist/cli/cloud-run.js.map +1 -1
- package/dist/cli/detached-record.d.ts +22 -0
- package/dist/cli/detached-record.d.ts.map +1 -0
- package/dist/cli/detached-record.js +57 -0
- package/dist/cli/detached-record.js.map +1 -0
- package/dist/cli/detached-run.d.ts +28 -0
- package/dist/cli/detached-run.d.ts.map +1 -0
- package/dist/cli/detached-run.js +122 -0
- package/dist/cli/detached-run.js.map +1 -0
- package/dist/cli/diagnostic-fold.d.ts +19 -0
- package/dist/cli/diagnostic-fold.d.ts.map +1 -0
- package/dist/cli/diagnostic-fold.js +19 -0
- package/dist/cli/diagnostic-fold.js.map +1 -0
- package/dist/cli/direct-run.d.ts.map +1 -1
- package/dist/cli/direct-run.js +16 -2
- package/dist/cli/direct-run.js.map +1 -1
- package/dist/cli/eval.d.ts +22 -0
- package/dist/cli/eval.d.ts.map +1 -0
- package/dist/cli/eval.js +131 -0
- package/dist/cli/eval.js.map +1 -0
- package/dist/cli/journal-timeout.d.ts +12 -0
- package/dist/cli/journal-timeout.d.ts.map +1 -0
- package/dist/cli/journal-timeout.js +42 -0
- package/dist/cli/journal-timeout.js.map +1 -0
- package/dist/cli/local-agent-remedy.d.ts.map +1 -1
- package/dist/cli/local-agent-remedy.js +5 -4
- package/dist/cli/local-agent-remedy.js.map +1 -1
- package/dist/cli/observer-session.d.ts +1 -0
- package/dist/cli/observer-session.d.ts.map +1 -1
- package/dist/cli/observer-session.js +8 -1
- package/dist/cli/observer-session.js.map +1 -1
- package/dist/cli/reuse.d.ts +8 -0
- package/dist/cli/reuse.d.ts.map +1 -1
- package/dist/cli/reuse.js +24 -0
- package/dist/cli/reuse.js.map +1 -1
- package/dist/cli/run.d.ts +8 -2
- package/dist/cli/run.d.ts.map +1 -1
- package/dist/cli/run.js +72 -56
- package/dist/cli/run.js.map +1 -1
- package/dist/cli/running-step.d.ts +9 -0
- package/dist/cli/running-step.d.ts.map +1 -0
- package/dist/cli/running-step.js +156 -0
- package/dist/cli/running-step.js.map +1 -0
- package/dist/cli-adapter.d.ts +3 -1
- package/dist/cli-adapter.d.ts.map +1 -1
- package/dist/cli-adapter.js +6 -2
- package/dist/cli-adapter.js.map +1 -1
- package/dist/cli-commands.d.ts +77 -11
- package/dist/cli-commands.d.ts.map +1 -1
- package/dist/cli-commands.js +41 -7
- package/dist/cli-commands.js.map +1 -1
- package/dist/cli-watch.d.ts +6 -2
- package/dist/cli-watch.d.ts.map +1 -1
- package/dist/cli-watch.js +7 -6
- package/dist/cli-watch.js.map +1 -1
- package/dist/cli.d.ts +22 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +154 -50
- package/dist/cli.js.map +1 -1
- package/dist/cloud-answer.d.ts +35 -0
- package/dist/cloud-answer.d.ts.map +1 -0
- package/dist/cloud-answer.js +194 -0
- package/dist/cloud-answer.js.map +1 -0
- package/dist/cloud-auth-store.d.ts +46 -0
- package/dist/cloud-auth-store.d.ts.map +1 -0
- package/dist/cloud-auth-store.js +171 -0
- package/dist/cloud-auth-store.js.map +1 -0
- package/dist/cloud-http.d.ts +7 -16
- package/dist/cloud-http.d.ts.map +1 -1
- package/dist/cloud-http.js +59 -40
- package/dist/cloud-http.js.map +1 -1
- package/dist/cloud-human-wait.d.ts +10 -0
- package/dist/cloud-human-wait.d.ts.map +1 -0
- package/dist/cloud-human-wait.js +17 -0
- package/dist/cloud-human-wait.js.map +1 -0
- package/dist/cloud-mirror-transport.d.ts.map +1 -1
- package/dist/cloud-mirror-transport.js +1 -0
- package/dist/cloud-mirror-transport.js.map +1 -1
- package/dist/cloud-run-record.d.ts +7 -2
- package/dist/cloud-run-record.d.ts.map +1 -1
- package/dist/cloud-run-record.js +13 -5
- package/dist/cloud-run-record.js.map +1 -1
- package/dist/cloud-run.d.ts +9 -0
- package/dist/cloud-run.d.ts.map +1 -1
- package/dist/cloud-run.js +36 -2
- package/dist/cloud-run.js.map +1 -1
- package/dist/communication/local.d.ts.map +1 -1
- package/dist/communication/local.js +6 -1
- package/dist/communication/local.js.map +1 -1
- package/dist/communication/worker.d.ts.map +1 -1
- package/dist/communication/worker.js +12 -2
- package/dist/communication/worker.js.map +1 -1
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js +5 -3
- package/dist/compile.js.map +1 -1
- package/dist/daemon-spec-validation.d.ts +31 -0
- package/dist/daemon-spec-validation.d.ts.map +1 -0
- package/dist/daemon-spec-validation.js +115 -0
- package/dist/daemon-spec-validation.js.map +1 -0
- package/dist/failure-kinds.d.ts +6 -4
- package/dist/failure-kinds.d.ts.map +1 -1
- package/dist/failure-kinds.js +17 -1
- package/dist/failure-kinds.js.map +1 -1
- package/dist/flow-eval-cloud.d.ts +25 -0
- package/dist/flow-eval-cloud.d.ts.map +1 -0
- package/dist/flow-eval-cloud.js +108 -0
- package/dist/flow-eval-cloud.js.map +1 -0
- package/dist/flow-eval-error.d.ts +7 -0
- package/dist/flow-eval-error.d.ts.map +1 -0
- package/dist/flow-eval-error.js +10 -0
- package/dist/flow-eval-error.js.map +1 -0
- package/dist/flow-eval-gate.d.ts +15 -0
- package/dist/flow-eval-gate.d.ts.map +1 -0
- package/dist/flow-eval-gate.js +102 -0
- package/dist/flow-eval-gate.js.map +1 -0
- package/dist/flow-eval-local.d.ts +54 -0
- package/dist/flow-eval-local.d.ts.map +1 -0
- package/dist/flow-eval-local.js +220 -0
- package/dist/flow-eval-local.js.map +1 -0
- package/dist/flow-eval-outcome.d.ts +22 -0
- package/dist/flow-eval-outcome.d.ts.map +1 -0
- package/dist/flow-eval-outcome.js +37 -0
- package/dist/flow-eval-outcome.js.map +1 -0
- package/dist/flow-eval-report.d.ts +106 -0
- package/dist/flow-eval-report.d.ts.map +1 -0
- package/dist/flow-eval-report.js +4 -0
- package/dist/flow-eval-report.js.map +1 -0
- package/dist/flow-eval-suite.d.ts +46 -0
- package/dist/flow-eval-suite.d.ts.map +1 -0
- package/dist/flow-eval-suite.js +144 -0
- package/dist/flow-eval-suite.js.map +1 -0
- package/dist/flow-eval-version.d.ts +59 -0
- package/dist/flow-eval-version.d.ts.map +1 -0
- package/dist/flow-eval-version.js +303 -0
- package/dist/flow-eval-version.js.map +1 -0
- package/dist/flow-eval.d.ts +41 -0
- package/dist/flow-eval.d.ts.map +1 -0
- package/dist/flow-eval.js +201 -0
- package/dist/flow-eval.js.map +1 -0
- package/dist/helper-operation-use.d.ts +18 -0
- package/dist/helper-operation-use.d.ts.map +1 -0
- package/dist/helper-operation-use.js +336 -0
- package/dist/helper-operation-use.js.map +1 -0
- package/dist/helper-preflight.d.ts.map +1 -1
- package/dist/helper-preflight.js +16 -2
- package/dist/helper-preflight.js.map +1 -1
- package/dist/helper-reference.d.ts +33 -0
- package/dist/helper-reference.d.ts.map +1 -1
- package/dist/helper-reference.js +5 -5
- package/dist/helper-reference.js.map +1 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/journal-budgeted-reads.d.ts +41 -0
- package/dist/journal-budgeted-reads.d.ts.map +1 -0
- package/dist/journal-budgeted-reads.js +142 -0
- package/dist/journal-budgeted-reads.js.map +1 -0
- package/dist/journal-client.d.ts +34 -29
- package/dist/journal-client.d.ts.map +1 -1
- package/dist/journal-client.js +45 -151
- package/dist/journal-client.js.map +1 -1
- package/dist/journal-connection.d.ts +42 -0
- package/dist/journal-connection.d.ts.map +1 -0
- package/dist/journal-connection.js +209 -0
- package/dist/journal-connection.js.map +1 -0
- package/dist/journal-read-policy.d.ts +38 -0
- package/dist/journal-read-policy.d.ts.map +1 -0
- package/dist/journal-read-policy.js +126 -0
- package/dist/journal-read-policy.js.map +1 -0
- package/dist/named-gate-lowering.d.ts.map +1 -1
- package/dist/named-gate-lowering.js +2 -6
- package/dist/named-gate-lowering.js.map +1 -1
- package/dist/re2js-embedded.d.ts +3 -0
- package/dist/re2js-embedded.d.ts.map +1 -0
- package/dist/re2js-embedded.js +4 -0
- package/dist/re2js-embedded.js.map +1 -0
- package/dist/spec.d.ts +10 -0
- package/dist/spec.d.ts.map +1 -1
- package/dist/spec.js.map +1 -1
- package/dist/step-fields.d.ts +1 -1
- package/dist/step-fields.js +1 -1
- package/dist/step-fields.js.map +1 -1
- package/dist/validate.d.ts.map +1 -1
- package/dist/validate.js +15 -0
- package/dist/validate.js.map +1 -1
- package/dist/worker-cli.d.ts +3 -1
- package/dist/worker-cli.d.ts.map +1 -1
- package/dist/worker-cli.js +15 -5
- package/dist/worker-cli.js.map +1 -1
- package/dist/worker-lease.d.ts.map +1 -1
- package/dist/worker-lease.js +11 -3
- package/dist/worker-lease.js.map +1 -1
- package/dist/worker.js +1 -1
- package/dist/worker.js.map +1 -1
- package/package.json +5 -3
- package/src/adapters/base.ts +16 -1
- package/src/adapters/claude.ts +8 -4
- package/src/adapters/codex.ts +15 -6
- package/src/agent-resume.ts +36 -0
- package/src/agent-transcript.ts +5 -3
- package/src/authored-flow-error.ts +9 -0
- package/src/authored-flow-executor.ts +18 -1
- package/src/authored-flow-loader.ts +27 -10
- package/src/authored-helper-effect.ts +3 -2
- package/src/authored-human.ts +5 -0
- package/src/authored-memory.ts +445 -15
- package/src/authored-node-entry.ts +6 -1
- package/src/authored-node-runner.ts +6 -3
- package/src/authored-root-readback.ts +100 -0
- package/src/authored-root.ts +58 -85
- package/src/authored-step-output.ts +3 -0
- package/src/authored-worker-step.ts +29 -4
- package/src/cli/check-helper-body.ts +9 -3
- package/src/cli/check-helper-surface.ts +43 -0
- package/src/cli/check-triggers.ts +9 -4
- package/src/cli/check.ts +37 -7
- package/src/cli/cloud-answer.ts +40 -0
- package/src/cli/cloud-connect-cli.ts +9 -2
- package/src/cli/cloud-human.ts +24 -0
- package/src/cli/cloud-live.ts +10 -5
- package/src/cli/cloud-mirror-session.ts +3 -2
- package/src/cli/cloud-run.ts +10 -1
- package/src/cli/detached-record.ts +71 -0
- package/src/cli/detached-run.ts +131 -0
- package/src/cli/diagnostic-fold.ts +28 -0
- package/src/cli/direct-run.ts +14 -1
- package/src/cli/eval.ts +141 -0
- package/src/cli/journal-timeout.ts +49 -0
- package/src/cli/local-agent-remedy.ts +6 -4
- package/src/cli/observer-session.ts +7 -1
- package/src/cli/reuse.ts +25 -0
- package/src/cli/run.ts +75 -67
- package/src/cli/running-step.ts +140 -0
- package/src/cli-adapter.ts +7 -1
- package/src/cli-commands.ts +43 -7
- package/src/cli-watch.ts +8 -5
- package/src/cli.ts +158 -51
- package/src/cloud-answer.ts +202 -0
- package/src/cloud-auth-store.ts +185 -0
- package/src/cloud-http.ts +61 -50
- package/src/cloud-human-wait.ts +23 -0
- package/src/cloud-mirror-transport.ts +1 -0
- package/src/cloud-run-record.ts +14 -5
- package/src/cloud-run.ts +46 -2
- package/src/communication/local.ts +6 -1
- package/src/communication/worker.ts +11 -3
- package/src/compile.ts +5 -3
- package/src/daemon-spec-validation.ts +126 -0
- package/src/failure-kinds.ts +17 -1
- package/src/flow-eval-cloud.ts +114 -0
- package/src/flow-eval-error.ts +10 -0
- package/src/flow-eval-gate.ts +114 -0
- package/src/flow-eval-local.ts +236 -0
- package/src/flow-eval-outcome.ts +43 -0
- package/src/flow-eval-report.ts +102 -0
- package/src/flow-eval-suite.ts +169 -0
- package/src/flow-eval-version.ts +316 -0
- package/src/flow-eval.ts +234 -0
- package/src/helper-operation-use.ts +285 -0
- package/src/helper-preflight.ts +17 -2
- package/src/helper-reference.ts +6 -6
- package/src/index.ts +15 -1
- package/src/journal-budgeted-reads.ts +134 -0
- package/src/journal-client.ts +59 -166
- package/src/journal-connection.ts +222 -0
- package/src/journal-read-policy.ts +123 -0
- package/src/named-gate-lowering.ts +2 -6
- package/src/re2js-embedded.ts +3 -0
- package/src/spec.ts +10 -0
- package/src/step-fields.ts +1 -1
- package/src/validate.ts +14 -0
- package/src/worker-cli.ts +14 -3
- package/src/worker-lease.ts +11 -3
- package/src/worker.ts +1 -1
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { FlowEvalExecutor, FlowEvalRun } from './flow-eval-report.js';
|
|
2
|
+
import type { RunExecution } from './cli/run.js';
|
|
3
|
+
export interface LocalFlowEvalExecutorOptions {
|
|
4
|
+
/** Daemon data directory. Defaults to `.relayflowd`. */
|
|
5
|
+
dataDir?: string;
|
|
6
|
+
/** Attach a local agent/LLM worker, as `flows run --local-agent`. */
|
|
7
|
+
localAgent?: boolean;
|
|
8
|
+
agentCapacity?: number;
|
|
9
|
+
/** `{ spawn: false }` refuses instead of starting a daemon, as `flows run --no-spawn`. */
|
|
10
|
+
daemon?: {
|
|
11
|
+
spawn?: boolean;
|
|
12
|
+
};
|
|
13
|
+
/** The `flows` CLI entry point. Defaults to this package's own `dist/cli.js`. */
|
|
14
|
+
cliPath?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Working directory for each run. Defaults to the snapshot directory holding
|
|
17
|
+
* the flow, so a relative read (`readFileSync('./prompt.txt')`) resolves
|
|
18
|
+
* inside the sealed copy — and fails there if the file is not part of the
|
|
19
|
+
* version — instead of reading the caller's mutable working tree. Setting it
|
|
20
|
+
* deliberately reintroduces that dependency.
|
|
21
|
+
*/
|
|
22
|
+
cwd?: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Execute each case as a fresh local run, in its own `flows run` process.
|
|
26
|
+
*
|
|
27
|
+
* A child process per case is deliberate. Authored source is loaded with
|
|
28
|
+
* `import()`, and an ES module is cached by URL for the life of a process: an
|
|
29
|
+
* in-process run would keep executing the FIRST version of a `.flow.ts` it saw,
|
|
30
|
+
* while the report named the edited bytes on disk. A gate must run what it
|
|
31
|
+
* judges, so each case gets a process that has never seen the flow before.
|
|
32
|
+
*
|
|
33
|
+
* Authored `.flow.ts` receives the case input (`{}` when the case has none);
|
|
34
|
+
* declarative YAML/JSON specs take no input, so a case that declares one is
|
|
35
|
+
* refused rather than silently run without it.
|
|
36
|
+
*/
|
|
37
|
+
export declare function localFlowEvalExecutor(options?: LocalFlowEvalExecutorOptions): FlowEvalExecutor;
|
|
38
|
+
/** Map a local `RunExecution` onto the eval vocabulary. Exported for tests. */
|
|
39
|
+
export declare function localRunOutcome(execution: RunExecution): FlowEvalRun;
|
|
40
|
+
/**
|
|
41
|
+
* Spend from the local journals.
|
|
42
|
+
*
|
|
43
|
+
* Summed from each step's own `step.completed` budget, never from a run's
|
|
44
|
+
* `budget_total`: an authored child run starts from the flow's `prior_spend`,
|
|
45
|
+
* so its total already includes every earlier child, and adding totals would
|
|
46
|
+
* count the same dollars repeatedly.
|
|
47
|
+
*
|
|
48
|
+
* An authored root runs each step as a child run with its own journal. The
|
|
49
|
+
* children are found in the root's `authored-steps` stream, which is written
|
|
50
|
+
* as each child opens and so survives a failed body, and in the root step's
|
|
51
|
+
* success output (`journalSteps`).
|
|
52
|
+
*/
|
|
53
|
+
export declare function localRunSpend(runId: string, dataDir: string): Promise<Pick<FlowEvalRun, 'costUsd' | 'tokensIn' | 'tokensOut' | 'steps'>>;
|
|
54
|
+
//# sourceMappingURL=flow-eval-local.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flow-eval-local.d.ts","sourceRoot":"","sources":["../src/flow-eval-local.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAgB,MAAM,uBAAuB,CAAC;AAEzF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEjD,MAAM,WAAW,4BAA4B;IAC3C,wDAAwD;IACxD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,qEAAqE;IACrE,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,0FAA0F;IAC1F,MAAM,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;IAC7B,iFAAiF;IACjF,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;;;OAMG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,GAAE,4BAAiC,GAAG,gBAAgB,CAgClG;AAkCD,+EAA+E;AAC/E,wBAAgB,eAAe,CAAC,SAAS,EAAE,YAAY,GAAG,WAAW,CAMpE;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,SAAS,GAAG,UAAU,GAAG,WAAW,GAAG,OAAO,CAAC,CAAC,CAqB9I"}
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
// The local executor for `evaluateFlow`: one fresh `flows run` per case
|
|
2
|
+
// against relayflowd, and the case's spend read back from the journals.
|
|
3
|
+
// Memoization (`--reuse-from`) is never used: an evaluation must judge the
|
|
4
|
+
// candidate's own step results, not a prior version's.
|
|
5
|
+
import { spawn } from 'node:child_process';
|
|
6
|
+
import { existsSync } from 'node:fs';
|
|
7
|
+
import { mkdtemp, rm, writeFile } from 'node:fs/promises';
|
|
8
|
+
import { tmpdir } from 'node:os';
|
|
9
|
+
import { dirname, join, resolve } from 'node:path';
|
|
10
|
+
import { fileURLToPath } from 'node:url';
|
|
11
|
+
import { canonicalize } from './canonical.js';
|
|
12
|
+
import { isAuthoredFlowPath } from './direct-input.js';
|
|
13
|
+
import { walkJournal } from './journal-reader.js';
|
|
14
|
+
import { runReportOutcome } from './flow-eval-outcome.js';
|
|
15
|
+
/**
|
|
16
|
+
* Execute each case as a fresh local run, in its own `flows run` process.
|
|
17
|
+
*
|
|
18
|
+
* A child process per case is deliberate. Authored source is loaded with
|
|
19
|
+
* `import()`, and an ES module is cached by URL for the life of a process: an
|
|
20
|
+
* in-process run would keep executing the FIRST version of a `.flow.ts` it saw,
|
|
21
|
+
* while the report named the edited bytes on disk. A gate must run what it
|
|
22
|
+
* judges, so each case gets a process that has never seen the flow before.
|
|
23
|
+
*
|
|
24
|
+
* Authored `.flow.ts` receives the case input (`{}` when the case has none);
|
|
25
|
+
* declarative YAML/JSON specs take no input, so a case that declares one is
|
|
26
|
+
* refused rather than silently run without it.
|
|
27
|
+
*/
|
|
28
|
+
export function localFlowEvalExecutor(options = {}) {
|
|
29
|
+
const dataDir = resolve(options.dataDir ?? '.relayflowd');
|
|
30
|
+
return async ({ flow, input, signal }) => {
|
|
31
|
+
if (!('path' in flow) || typeof flow.path !== 'string') {
|
|
32
|
+
throw new Error('The local executor runs flow files; write the spec to a file or use a custom executor.');
|
|
33
|
+
}
|
|
34
|
+
const authored = isAuthoredFlowPath(flow.path);
|
|
35
|
+
if (!authored && input !== undefined)
|
|
36
|
+
throw new Error('Declarative flows take no input; remove `input` from the case.');
|
|
37
|
+
const scratch = authored ? await mkdtemp(join(tmpdir(), 'flows-eval-')) : undefined;
|
|
38
|
+
try {
|
|
39
|
+
const args = [options.cliPath ?? defaultCliPath(), 'run', '--json', '--no-observer-link', '--data-dir', dataDir];
|
|
40
|
+
if (options.daemon?.spawn === false)
|
|
41
|
+
args.push('--no-spawn');
|
|
42
|
+
if (options.localAgent)
|
|
43
|
+
args.push('--local-agent');
|
|
44
|
+
if (options.agentCapacity !== undefined)
|
|
45
|
+
args.push('--agent-capacity', String(options.agentCapacity));
|
|
46
|
+
args.push(resolve(flow.path));
|
|
47
|
+
if (scratch !== undefined) {
|
|
48
|
+
// A file, never inline: an inline argument that happens to name a file
|
|
49
|
+
// in the working directory would be read as that file.
|
|
50
|
+
const inputPath = join(scratch, 'input.json');
|
|
51
|
+
await writeFile(inputPath, canonicalize(input ?? {}));
|
|
52
|
+
args.push('--input', inputPath);
|
|
53
|
+
}
|
|
54
|
+
const execution = await runCliProcess(args, options.cwd ?? dirname(resolve(flow.path)), signal);
|
|
55
|
+
const run = localRunOutcome(execution);
|
|
56
|
+
if (run.runId !== undefined && run.completionReason !== 'refused') {
|
|
57
|
+
Object.assign(run, await localRunSpend(run.runId, dataDir));
|
|
58
|
+
}
|
|
59
|
+
return run;
|
|
60
|
+
}
|
|
61
|
+
finally {
|
|
62
|
+
if (scratch !== undefined)
|
|
63
|
+
await rm(scratch, { recursive: true, force: true });
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
function defaultCliPath() {
|
|
68
|
+
// Built: this file sits beside cli.js in dist/. From source (tests), use the build.
|
|
69
|
+
const sibling = fileURLToPath(new URL('./cli.js', import.meta.url));
|
|
70
|
+
return existsSync(sibling) ? sibling : fileURLToPath(new URL('../dist/cli.js', import.meta.url));
|
|
71
|
+
}
|
|
72
|
+
function runCliProcess(args, cwd, signal) {
|
|
73
|
+
return new Promise((resolvePromise, reject) => {
|
|
74
|
+
const child = spawn(process.execPath, args, {
|
|
75
|
+
...(cwd === undefined ? {} : { cwd }), stdio: ['ignore', 'pipe', 'pipe'],
|
|
76
|
+
...(signal === undefined ? {} : { signal }),
|
|
77
|
+
});
|
|
78
|
+
let stdout = '';
|
|
79
|
+
let stderr = '';
|
|
80
|
+
child.stdout.setEncoding('utf8').on('data', (chunk) => { stdout += chunk; });
|
|
81
|
+
child.stderr.setEncoding('utf8').on('data', (chunk) => { stderr = (stderr + chunk).slice(-4_000); });
|
|
82
|
+
child.once('error', reject);
|
|
83
|
+
child.once('close', (code) => {
|
|
84
|
+
const line = stdout.trim().split('\n').reverse().find(candidate => candidate.startsWith('{'));
|
|
85
|
+
let report;
|
|
86
|
+
try {
|
|
87
|
+
report = line === undefined ? undefined : JSON.parse(line);
|
|
88
|
+
}
|
|
89
|
+
catch { /* reported below */ }
|
|
90
|
+
if (report === undefined || typeof report.ok !== 'boolean' || !Array.isArray(report.diagnostics)) {
|
|
91
|
+
reject(new Error(`flows run exited ${code} without a JSON report: ${stderr.trim() || stdout.trim() || '(no output)'}`));
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
resolvePromise({ exitCode: (code ?? 1), report });
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
/** Map a local `RunExecution` onto the eval vocabulary. Exported for tests. */
|
|
99
|
+
export function localRunOutcome(execution) {
|
|
100
|
+
const { report } = execution;
|
|
101
|
+
// The root, not the failing child: a failed authored run reports the child
|
|
102
|
+
// that failed as `runId`, and spend must be read from the whole run.
|
|
103
|
+
const runId = report.rootRunId ?? report.runId;
|
|
104
|
+
return { ...(runId === undefined ? {} : { runId }), ...runReportOutcome(report, execution.exitCode) };
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Spend from the local journals.
|
|
108
|
+
*
|
|
109
|
+
* Summed from each step's own `step.completed` budget, never from a run's
|
|
110
|
+
* `budget_total`: an authored child run starts from the flow's `prior_spend`,
|
|
111
|
+
* so its total already includes every earlier child, and adding totals would
|
|
112
|
+
* count the same dollars repeatedly.
|
|
113
|
+
*
|
|
114
|
+
* An authored root runs each step as a child run with its own journal. The
|
|
115
|
+
* children are found in the root's `authored-steps` stream, which is written
|
|
116
|
+
* as each child opens and so survives a failed body, and in the root step's
|
|
117
|
+
* success output (`journalSteps`).
|
|
118
|
+
*/
|
|
119
|
+
export async function localRunSpend(runId, dataDir) {
|
|
120
|
+
try {
|
|
121
|
+
const spend = { dollars: 0, tokensIn: 0, tokensOut: 0 };
|
|
122
|
+
const steps = [];
|
|
123
|
+
const visited = new Set();
|
|
124
|
+
const queue = [{ runId, depth: 0 }];
|
|
125
|
+
while (queue.length > 0) {
|
|
126
|
+
const next = queue.shift();
|
|
127
|
+
if (visited.has(next.runId))
|
|
128
|
+
continue;
|
|
129
|
+
visited.add(next.runId);
|
|
130
|
+
const read = await readJournal(next.runId, dataDir);
|
|
131
|
+
addSpend(spend, read.spend);
|
|
132
|
+
steps.push(...read.steps);
|
|
133
|
+
// Bounded like `f.dispatch` (depth <= 3).
|
|
134
|
+
if (next.depth < 3)
|
|
135
|
+
for (const child of read.children)
|
|
136
|
+
queue.push({ runId: child, depth: next.depth + 1 });
|
|
137
|
+
}
|
|
138
|
+
return { costUsd: spend.dollars === null ? null : roundUsd(spend.dollars), tokensIn: spend.tokensIn, tokensOut: spend.tokensOut, steps };
|
|
139
|
+
}
|
|
140
|
+
catch {
|
|
141
|
+
// Spend is evidence, not the verdict: an unreadable journal leaves cost unknown.
|
|
142
|
+
return { costUsd: null, tokensIn: null, tokensOut: null };
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
const AUTHORED_STEP_RECORD = 'relayflows.authored-step.v1';
|
|
146
|
+
const RUN_ID = /^[A-Za-z0-9][A-Za-z0-9_-]*$/u;
|
|
147
|
+
async function readJournal(runId, dataDir) {
|
|
148
|
+
const spend = { dollars: 0, tokensIn: 0, tokensOut: 0 };
|
|
149
|
+
const steps = new Map();
|
|
150
|
+
const children = new Set();
|
|
151
|
+
for await (const event of walkJournal(runId, dataDir)) {
|
|
152
|
+
const payload = (event.payload !== null && typeof event.payload === 'object' ? event.payload : {});
|
|
153
|
+
if (event.entry_type === 'step.attempt.started' && event.step_id !== null) {
|
|
154
|
+
const step = steps.get(event.step_id) ?? { id: event.step_id, status: 'running' };
|
|
155
|
+
step.startedAt ??= event.at_ms;
|
|
156
|
+
steps.set(event.step_id, step);
|
|
157
|
+
}
|
|
158
|
+
else if (event.entry_type === 'step.completed' && event.step_id !== null) {
|
|
159
|
+
const budget = readBudget(payload['budget']);
|
|
160
|
+
const step = steps.get(event.step_id) ?? { id: event.step_id, status: 'done' };
|
|
161
|
+
step.status = typeof payload['completionReason'] === 'string' ? payload['completionReason'] : 'done';
|
|
162
|
+
if (step.startedAt !== undefined)
|
|
163
|
+
step.durationMs = event.at_ms - step.startedAt;
|
|
164
|
+
if (budget !== undefined) {
|
|
165
|
+
step.costUsd = budget.dollars;
|
|
166
|
+
addSpend(spend, budget);
|
|
167
|
+
}
|
|
168
|
+
steps.set(event.step_id, step);
|
|
169
|
+
for (const child of journalStepRunIds(payload['output']))
|
|
170
|
+
children.add(child);
|
|
171
|
+
}
|
|
172
|
+
else if (event.entry_type === 'stream.appended') {
|
|
173
|
+
for (const child of authoredStepRunIds(payload))
|
|
174
|
+
children.add(child);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
children.delete(runId);
|
|
178
|
+
return { spend, steps: [...steps.values()].map(({ startedAt: _startedAt, ...step }) => step), children: [...children] };
|
|
179
|
+
}
|
|
180
|
+
function journalStepRunIds(output) {
|
|
181
|
+
if (output === null || typeof output !== 'object')
|
|
182
|
+
return [];
|
|
183
|
+
const journalSteps = output['journalSteps'];
|
|
184
|
+
if (!Array.isArray(journalSteps))
|
|
185
|
+
return [];
|
|
186
|
+
return journalSteps.flatMap(step => {
|
|
187
|
+
const id = step !== null && typeof step === 'object' ? step['runId'] : undefined;
|
|
188
|
+
return typeof id === 'string' && RUN_ID.test(id) ? [id] : [];
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
/** Child run ids from an `authored-steps` index record, wherever the stream envelope nests it. */
|
|
192
|
+
function authoredStepRunIds(value, depth = 0) {
|
|
193
|
+
if (value === null || typeof value !== 'object' || depth > 4)
|
|
194
|
+
return [];
|
|
195
|
+
const record = value;
|
|
196
|
+
if (record['index'] === AUTHORED_STEP_RECORD) {
|
|
197
|
+
return typeof record['runId'] === 'string' && RUN_ID.test(record['runId']) ? [record['runId']] : [];
|
|
198
|
+
}
|
|
199
|
+
return Object.values(record).flatMap(nested => authoredStepRunIds(nested, depth + 1));
|
|
200
|
+
}
|
|
201
|
+
function addSpend(into, add) {
|
|
202
|
+
into.tokensIn += add.tokensIn;
|
|
203
|
+
into.tokensOut += add.tokensOut;
|
|
204
|
+
into.dollars = into.dollars === null || add.dollars === null ? null : into.dollars + add.dollars;
|
|
205
|
+
}
|
|
206
|
+
function roundUsd(value) {
|
|
207
|
+
return Math.round(value * 1e6) / 1e6;
|
|
208
|
+
}
|
|
209
|
+
function readBudget(value) {
|
|
210
|
+
if (value === null || typeof value !== 'object')
|
|
211
|
+
return undefined;
|
|
212
|
+
const budget = value;
|
|
213
|
+
const dollars = typeof budget['dollars'] === 'string' ? Number(budget['dollars']) : NaN;
|
|
214
|
+
return {
|
|
215
|
+
dollars: budget['dollars_unmetered'] === true || !Number.isFinite(dollars) || dollars < 0 ? null : dollars,
|
|
216
|
+
tokensIn: typeof budget['tokens_in'] === 'number' ? budget['tokens_in'] : 0,
|
|
217
|
+
tokensOut: typeof budget['tokens_out'] === 'number' ? budget['tokens_out'] : 0,
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
//# sourceMappingURL=flow-eval-local.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flow-eval-local.js","sourceRoot":"","sources":["../src/flow-eval-local.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,wEAAwE;AACxE,2EAA2E;AAC3E,uDAAuD;AAEvD,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MA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C,OAAO,CAAC,IAAI,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO;QAC1G,QAAQ,EAAE,OAAO,MAAM,CAAC,WAAW,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;QAC3E,SAAS,EAAE,OAAO,MAAM,CAAC,YAAY,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;KAC/E,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { FlowEvalRun } from './flow-eval-report.js';
|
|
2
|
+
/** The fields of a `RunReport` the verdict reads. */
|
|
3
|
+
export interface RunReportVerdict {
|
|
4
|
+
ok?: unknown;
|
|
5
|
+
status?: unknown;
|
|
6
|
+
completionReason?: unknown;
|
|
7
|
+
completionDetail?: unknown;
|
|
8
|
+
parkCause?: unknown;
|
|
9
|
+
diagnostics?: unknown;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Map a run report onto the eval vocabulary.
|
|
13
|
+
*
|
|
14
|
+
* - `declined`: the report says `success` with a `run_declined` diagnostic —
|
|
15
|
+
* the body chose not to act. Scoring it as `success` would let a flow that
|
|
16
|
+
* did nothing pass a suite expecting it to act.
|
|
17
|
+
* - `worker_unavailable` vs `needs_human`: both park (exit 3); only the second
|
|
18
|
+
* reached a human wait.
|
|
19
|
+
* - `refused`: preflight refused the run (exit 2); nothing executed.
|
|
20
|
+
*/
|
|
21
|
+
export declare function runReportOutcome(report: RunReportVerdict, exitCode?: number): Pick<FlowEvalRun, 'completionReason' | 'completionDetail'>;
|
|
22
|
+
//# sourceMappingURL=flow-eval-outcome.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flow-eval-outcome.d.ts","sourceRoot":"","sources":["../src/flow-eval-outcome.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEzD,qDAAqD;AACrD,MAAM,WAAW,gBAAgB;IAC/B,EAAE,CAAC,EAAE,OAAO,CAAC;IACb,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,gBAAgB,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC,WAAW,EAAE,kBAAkB,GAAG,kBAAkB,CAAC,CAexI"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// One vocabulary for a finished run's verdict, whoever ran it: a local
|
|
2
|
+
// `flows run` report and a hosted run's stored result are the same RunReport
|
|
3
|
+
// shape, and must map to the same completion reason, or a suite would pass
|
|
4
|
+
// locally and fail on Cloud for the same flow behavior.
|
|
5
|
+
/**
|
|
6
|
+
* Map a run report onto the eval vocabulary.
|
|
7
|
+
*
|
|
8
|
+
* - `declined`: the report says `success` with a `run_declined` diagnostic —
|
|
9
|
+
* the body chose not to act. Scoring it as `success` would let a flow that
|
|
10
|
+
* did nothing pass a suite expecting it to act.
|
|
11
|
+
* - `worker_unavailable` vs `needs_human`: both park (exit 3); only the second
|
|
12
|
+
* reached a human wait.
|
|
13
|
+
* - `refused`: preflight refused the run (exit 2); nothing executed.
|
|
14
|
+
*/
|
|
15
|
+
export function runReportOutcome(report, exitCode) {
|
|
16
|
+
const diagnostics = Array.isArray(report.diagnostics)
|
|
17
|
+
? report.diagnostics.filter((d) => d !== null && typeof d === 'object') : [];
|
|
18
|
+
const message = diagnostics.find(d => ['failure', 'refusal', 'parked'].includes(d['severity']))?.['message'];
|
|
19
|
+
const detail = typeof report.completionDetail === 'string' ? report.completionDetail
|
|
20
|
+
: typeof message === 'string' ? message : undefined;
|
|
21
|
+
let completionReason;
|
|
22
|
+
if (exitCode === 2)
|
|
23
|
+
completionReason = 'refused';
|
|
24
|
+
else if (report.status === 'parked' || exitCode === 3) {
|
|
25
|
+
completionReason = report.parkCause === 'worker_unavailable' ? 'worker_unavailable' : 'needs_human';
|
|
26
|
+
}
|
|
27
|
+
else if (report.ok === true && diagnostics.some(d => d['kind'] === 'run_declined'))
|
|
28
|
+
completionReason = 'declined';
|
|
29
|
+
else if (report.ok === true)
|
|
30
|
+
completionReason = 'success';
|
|
31
|
+
else if (typeof report.completionReason === 'string')
|
|
32
|
+
completionReason = report.completionReason;
|
|
33
|
+
else
|
|
34
|
+
completionReason = report.status === 'suspended' ? 'suspended' : 'failed';
|
|
35
|
+
return { completionReason, ...(detail === undefined ? {} : { completionDetail: detail }) };
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=flow-eval-outcome.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flow-eval-outcome.js","sourceRoot":"","sources":["../src/flow-eval-outcome.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,6EAA6E;AAC7E,2EAA2E;AAC3E,wDAAwD;AAcxD;;;;;;;;;GASG;AACH,MAAM,UAAU,gBAAgB,CAAC,MAAwB,EAAE,QAAiB;IAC1E,MAAM,WAAW,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC;QACnD,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,EAAgC,EAAE,CAAC,CAAC,KAAK,IAAI,IAAI,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAC7G,MAAM,OAAO,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,SAAS,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,C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valCase } from './flow-eval-suite.js';
|
|
2
|
+
import type { JsonValue } from './json-value.js';
|
|
3
|
+
import type { FlowEvalTarget } from './flow-eval-version.js';
|
|
4
|
+
export declare const FLOW_EVAL_REPORT_SCHEMA_VERSION = 1;
|
|
5
|
+
/** One step of an executed case, as far as the executor can say. */
|
|
6
|
+
export interface FlowEvalStep {
|
|
7
|
+
id: string;
|
|
8
|
+
status: string;
|
|
9
|
+
durationMs?: number | null;
|
|
10
|
+
costUsd?: number | null;
|
|
11
|
+
}
|
|
12
|
+
/** What an executor reports for one execution. */
|
|
13
|
+
export interface FlowEvalRun {
|
|
14
|
+
runId?: string;
|
|
15
|
+
/**
|
|
16
|
+
* `success`, `declined`, `step_failed`, `budget_exceeded`, `canceled`,
|
|
17
|
+
* `needs_human`, `worker_unavailable` (parked with nothing attached to run
|
|
18
|
+
* it), or `refused` (preflight refused the run).
|
|
19
|
+
*/
|
|
20
|
+
completionReason: string;
|
|
21
|
+
completionDetail?: string;
|
|
22
|
+
/** `null` when the executor cannot attest a dollar cost. */
|
|
23
|
+
costUsd?: number | null;
|
|
24
|
+
tokensIn?: number | null;
|
|
25
|
+
tokensOut?: number | null;
|
|
26
|
+
steps?: FlowEvalStep[];
|
|
27
|
+
/** Executor-supplied numeric metrics, merged into the case's metrics. */
|
|
28
|
+
metrics?: Record<string, number>;
|
|
29
|
+
}
|
|
30
|
+
export interface FlowEvalExecutionRequest {
|
|
31
|
+
/** The sealed snapshot to execute (a path inside it, or the in-memory spec), never the working tree. */
|
|
32
|
+
flow: FlowEvalTarget;
|
|
33
|
+
caseId: string;
|
|
34
|
+
/** Absent when the case declares no input. */
|
|
35
|
+
input?: JsonValue;
|
|
36
|
+
signal?: AbortSignal;
|
|
37
|
+
}
|
|
38
|
+
/** Executes the flow once. Throwing marks the case `error`, never `pass`. */
|
|
39
|
+
export type FlowEvalExecutor = (request: FlowEvalExecutionRequest) => Promise<FlowEvalRun>;
|
|
40
|
+
export interface FlowEvalScore {
|
|
41
|
+
/** Numeric value recorded under the scorer's name in the case's metrics. */
|
|
42
|
+
value?: number;
|
|
43
|
+
/** False fails the case. Absent means the scorer only measures. */
|
|
44
|
+
pass?: boolean;
|
|
45
|
+
detail?: string;
|
|
46
|
+
}
|
|
47
|
+
/** A caller-defined metric over one executed case. */
|
|
48
|
+
export interface FlowEvalScorer {
|
|
49
|
+
name: string;
|
|
50
|
+
score(run: FlowEvalRun, testCase: FlowEvalCase): FlowEvalScore | Promise<FlowEvalScore>;
|
|
51
|
+
}
|
|
52
|
+
export type FlowEvalOutcome = 'pass' | 'fail' | 'error';
|
|
53
|
+
export interface FlowEvalCaseResult {
|
|
54
|
+
id: string;
|
|
55
|
+
outcome: FlowEvalOutcome;
|
|
56
|
+
runId?: string;
|
|
57
|
+
completionReason?: string;
|
|
58
|
+
latencyMs: number;
|
|
59
|
+
costUsd: number | null;
|
|
60
|
+
tokensIn: number | null;
|
|
61
|
+
tokensOut: number | null;
|
|
62
|
+
metrics: Record<string, number>;
|
|
63
|
+
steps?: FlowEvalStep[];
|
|
64
|
+
/** Why the case did not pass; empty when it did. */
|
|
65
|
+
failures: string[];
|
|
66
|
+
}
|
|
67
|
+
export interface FlowEvalReport {
|
|
68
|
+
schemaVersion: typeof FLOW_EVAL_REPORT_SCHEMA_VERSION;
|
|
69
|
+
kind: 'flows.eval.report';
|
|
70
|
+
/** `files`: the local sources the version covers, relative to the entry's directory. */
|
|
71
|
+
flow: {
|
|
72
|
+
path?: string;
|
|
73
|
+
version: string;
|
|
74
|
+
files: string[];
|
|
75
|
+
};
|
|
76
|
+
suite: {
|
|
77
|
+
name: string;
|
|
78
|
+
sha256: string;
|
|
79
|
+
cases: number;
|
|
80
|
+
};
|
|
81
|
+
executor: string;
|
|
82
|
+
startedAt: string;
|
|
83
|
+
finishedAt: string;
|
|
84
|
+
cases: FlowEvalCaseResult[];
|
|
85
|
+
summary: {
|
|
86
|
+
total: number;
|
|
87
|
+
passed: number;
|
|
88
|
+
failed: number;
|
|
89
|
+
errored: number;
|
|
90
|
+
passRate: number;
|
|
91
|
+
/** `null` when any case's cost is unknown. */
|
|
92
|
+
totalCostUsd: number | null;
|
|
93
|
+
latencyMs: {
|
|
94
|
+
p50: number;
|
|
95
|
+
p95: number;
|
|
96
|
+
max: number;
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
/** The deploy decision: pass only when every threshold and regression check holds. */
|
|
100
|
+
gate: {
|
|
101
|
+
pass: boolean;
|
|
102
|
+
reasons: string[];
|
|
103
|
+
regressions: string[];
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=flow-eval-report.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flow-eval-report.d.ts","sourceRoot":"","sources":["../src/flow-eval-report.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAE7D,eAAO,MAAM,+BAA+B,IAAI,CAAC;AAEjD,oEAAoE;AACpE,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB;AAED,kDAAkD;AAClD,MAAM,WAAW,WAAW;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;OAIG;IACH,gBAAgB,EAAE,MAAM,CAAC;IACzB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,4DAA4D;IAC5D,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,GAAG,I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AAC9E,sDAAsD;AAMtD,MAAM,CAAC,MAAM,+BAA+B,GAAG,CAAC,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { type JsonValue } from './json-value.js';
|
|
2
|
+
export declare const MAX_FLOW_EVAL_CASES = 1000;
|
|
3
|
+
/** What a case must observe to pass. Every field present must hold. */
|
|
4
|
+
export interface FlowEvalExpectation {
|
|
5
|
+
/**
|
|
6
|
+
* The run's outcome. Defaults to `success`. `declined` is a successful run
|
|
7
|
+
* whose body chose not to act; `needs_human` is a parked run.
|
|
8
|
+
*/
|
|
9
|
+
completionReason?: string;
|
|
10
|
+
/** Substrings the run's completion detail must contain. */
|
|
11
|
+
detailIncludes?: string[];
|
|
12
|
+
/** A regular expression (JavaScript syntax) the completion detail must match. */
|
|
13
|
+
detailMatches?: string;
|
|
14
|
+
/** Upper bound on this case's wall-clock latency. */
|
|
15
|
+
maxLatencyMs?: number;
|
|
16
|
+
/** Upper bound on this case's reported cost; an unknown cost fails it. */
|
|
17
|
+
maxCostUsd?: number;
|
|
18
|
+
}
|
|
19
|
+
export interface FlowEvalCase {
|
|
20
|
+
/** Stable identity across suite revisions; unique within the suite. */
|
|
21
|
+
id: string;
|
|
22
|
+
/** The run's input. Required by authored `.flow.ts`; refused by declarative specs on Cloud. */
|
|
23
|
+
input?: JsonValue;
|
|
24
|
+
expect?: FlowEvalExpectation;
|
|
25
|
+
}
|
|
26
|
+
export interface FlowEvalThresholds {
|
|
27
|
+
/** Fraction of cases that must pass, 0..1. Defaults to 1: every case. */
|
|
28
|
+
minPassRate?: number;
|
|
29
|
+
/** Ceiling on the summed cost of every case; an unknown cost fails it. */
|
|
30
|
+
maxTotalCostUsd?: number;
|
|
31
|
+
/** Ceiling on the 95th-percentile case latency. */
|
|
32
|
+
maxP95LatencyMs?: number;
|
|
33
|
+
}
|
|
34
|
+
export interface FlowEvalSuite {
|
|
35
|
+
name: string;
|
|
36
|
+
cases: FlowEvalCase[];
|
|
37
|
+
thresholds?: FlowEvalThresholds;
|
|
38
|
+
}
|
|
39
|
+
/** Validate untrusted suite data (parsed JSON) into a frozen suite. */
|
|
40
|
+
export declare function parseFlowEvalSuite(value: unknown): FlowEvalSuite;
|
|
41
|
+
/** Read and validate a suite file (JSON). */
|
|
42
|
+
export declare function loadFlowEvalSuite(path: string): Promise<FlowEvalSuite>;
|
|
43
|
+
/** The suite's identity: sha256 of its canonical JSON. */
|
|
44
|
+
export declare function flowEvalSuiteSha256(suite: FlowEvalSuite): string;
|
|
45
|
+
export declare function isRecord(value: unknown): value is Record<string, unknown>;
|
|
46
|
+
//# sourceMappingURL=flow-eval-suite.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flow-eval-suite.d.ts","sourceRoot":"","sources":["../src/flow-eval-suite.ts"],"names":[],"mappings":"AAOA,OAAO,EAA8C,KAAK,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI7F,eAAO,MAAM,mBAAmB,OAAQ,CAAC;AAKzC,uEAAuE;AACvE,MAAM,WAAW,mBAAmB;IAClC;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,2DAA2D;IAC3D,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,iFAAiF;IACjF,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,qDAAqD;IACrD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,0EAA0E;IAC1E,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,YAAY;IAC3B,uEAAuE;IACvE,EAAE,EAAE,MAAM,CAAC;IACX,+FAA+F;IAC/F,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,MAAM,CAAC,EAAE,mBAAmB,CAAC;CAC9B;AAED,MAAM,WAAW,kBAAkB;IACjC,yEAAyE;IACzE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,0EAA0E;IAC1E,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,mDAAm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