@prismatic-io/lux 0.0.1
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/LICENSE +21 -0
- package/lib/answerers/claude-code/index.d.ts +17 -0
- package/lib/answerers/claude-code/index.d.ts.map +1 -0
- package/lib/answerers/claude-code/index.js +280 -0
- package/lib/answerers/claude-code/index.js.map +1 -0
- package/lib/answerers/persona/index.d.ts +40 -0
- package/lib/answerers/persona/index.d.ts.map +1 -0
- package/lib/answerers/persona/index.js +265 -0
- package/lib/answerers/persona/index.js.map +1 -0
- package/lib/answerers/scripted/index.d.ts +8 -0
- package/lib/answerers/scripted/index.d.ts.map +1 -0
- package/lib/answerers/scripted/index.js +163 -0
- package/lib/answerers/scripted/index.js.map +1 -0
- package/lib/answerers/shared.d.ts +13 -0
- package/lib/answerers/shared.d.ts.map +1 -0
- package/lib/answerers/shared.js +17 -0
- package/lib/answerers/shared.js.map +1 -0
- package/lib/answerers/terminal/index.d.ts +9 -0
- package/lib/answerers/terminal/index.d.ts.map +1 -0
- package/lib/answerers/terminal/index.js +97 -0
- package/lib/answerers/terminal/index.js.map +1 -0
- package/lib/assertions/core/command-exits-zero.d.ts +21 -0
- package/lib/assertions/core/command-exits-zero.d.ts.map +1 -0
- package/lib/assertions/core/command-exits-zero.js +87 -0
- package/lib/assertions/core/command-exits-zero.js.map +1 -0
- package/lib/assertions/core/event-checks.d.ts +57 -0
- package/lib/assertions/core/event-checks.d.ts.map +1 -0
- package/lib/assertions/core/event-checks.js +123 -0
- package/lib/assertions/core/event-checks.js.map +1 -0
- package/lib/assertions/core/file-checks.d.ts +103 -0
- package/lib/assertions/core/file-checks.d.ts.map +1 -0
- package/lib/assertions/core/file-checks.js +288 -0
- package/lib/assertions/core/file-checks.js.map +1 -0
- package/lib/assertions/core/helpers.d.ts +66 -0
- package/lib/assertions/core/helpers.d.ts.map +1 -0
- package/lib/assertions/core/helpers.js +170 -0
- package/lib/assertions/core/helpers.js.map +1 -0
- package/lib/assertions/core/index.d.ts +15 -0
- package/lib/assertions/core/index.d.ts.map +1 -0
- package/lib/assertions/core/index.js +56 -0
- package/lib/assertions/core/index.js.map +1 -0
- package/lib/assertions/core/json-pointer-equals.d.ts +19 -0
- package/lib/assertions/core/json-pointer-equals.d.ts.map +1 -0
- package/lib/assertions/core/json-pointer-equals.js +71 -0
- package/lib/assertions/core/json-pointer-equals.js.map +1 -0
- package/lib/assertions/core/output-checks.d.ts +46 -0
- package/lib/assertions/core/output-checks.d.ts.map +1 -0
- package/lib/assertions/core/output-checks.js +121 -0
- package/lib/assertions/core/output-checks.js.map +1 -0
- package/lib/assertions/core/predicate.d.ts +14 -0
- package/lib/assertions/core/predicate.d.ts.map +1 -0
- package/lib/assertions/core/predicate.js +55 -0
- package/lib/assertions/core/predicate.js.map +1 -0
- package/lib/assertions/core/resource-checks.d.ts +71 -0
- package/lib/assertions/core/resource-checks.d.ts.map +1 -0
- package/lib/assertions/core/resource-checks.js +159 -0
- package/lib/assertions/core/resource-checks.js.map +1 -0
- package/lib/assertions/core/safe-regex.d.ts +23 -0
- package/lib/assertions/core/safe-regex.d.ts.map +1 -0
- package/lib/assertions/core/safe-regex.js +102 -0
- package/lib/assertions/core/safe-regex.js.map +1 -0
- package/lib/assertions/core/tool-called-with.d.ts +21 -0
- package/lib/assertions/core/tool-called-with.d.ts.map +1 -0
- package/lib/assertions/core/tool-called-with.js +69 -0
- package/lib/assertions/core/tool-called-with.js.map +1 -0
- package/lib/assertions/core/tool-calls.d.ts +22 -0
- package/lib/assertions/core/tool-calls.d.ts.map +1 -0
- package/lib/assertions/core/tool-calls.js +17 -0
- package/lib/assertions/core/tool-calls.js.map +1 -0
- package/lib/assertions/core/tool-invocation.d.ts +36 -0
- package/lib/assertions/core/tool-invocation.d.ts.map +1 -0
- package/lib/assertions/core/tool-invocation.js +170 -0
- package/lib/assertions/core/tool-invocation.js.map +1 -0
- package/lib/assertions/core/tool-result-checks.d.ts +59 -0
- package/lib/assertions/core/tool-result-checks.d.ts.map +1 -0
- package/lib/assertions/core/tool-result-checks.js +193 -0
- package/lib/assertions/core/tool-result-checks.js.map +1 -0
- package/lib/assertions/mcp/discovery-checks.d.ts +36 -0
- package/lib/assertions/mcp/discovery-checks.d.ts.map +1 -0
- package/lib/assertions/mcp/discovery-checks.js +122 -0
- package/lib/assertions/mcp/discovery-checks.js.map +1 -0
- package/lib/assertions/mcp/index.d.ts +10 -0
- package/lib/assertions/mcp/index.d.ts.map +1 -0
- package/lib/assertions/mcp/index.js +25 -0
- package/lib/assertions/mcp/index.js.map +1 -0
- package/lib/assertions/rubric/index.d.ts +104 -0
- package/lib/assertions/rubric/index.d.ts.map +1 -0
- package/lib/assertions/rubric/index.js +191 -0
- package/lib/assertions/rubric/index.js.map +1 -0
- package/lib/assertions/rubric/internal.d.ts +14 -0
- package/lib/assertions/rubric/internal.d.ts.map +1 -0
- package/lib/assertions/rubric/internal.js +335 -0
- package/lib/assertions/rubric/internal.js.map +1 -0
- package/lib/authoring.d.ts +3 -0
- package/lib/authoring.d.ts.map +1 -0
- package/lib/authoring.js +3 -0
- package/lib/authoring.js.map +1 -0
- package/lib/cli/bin.d.ts +3 -0
- package/lib/cli/bin.d.ts.map +1 -0
- package/lib/cli/bin.js +15 -0
- package/lib/cli/bin.js.map +1 -0
- package/lib/cli/command-runtime.d.ts +5 -0
- package/lib/cli/command-runtime.d.ts.map +1 -0
- package/lib/cli/command-runtime.js +30 -0
- package/lib/cli/command-runtime.js.map +1 -0
- package/lib/cli/init.d.ts +21 -0
- package/lib/cli/init.d.ts.map +1 -0
- package/lib/cli/init.js +340 -0
- package/lib/cli/init.js.map +1 -0
- package/lib/cli/program.d.ts +22 -0
- package/lib/cli/program.d.ts.map +1 -0
- package/lib/cli/program.js +757 -0
- package/lib/cli/program.js.map +1 -0
- package/lib/cli/render/format.d.ts +14 -0
- package/lib/cli/render/format.d.ts.map +1 -0
- package/lib/cli/render/format.js +71 -0
- package/lib/cli/render/format.js.map +1 -0
- package/lib/cli/render/reporter.d.ts +73 -0
- package/lib/cli/render/reporter.d.ts.map +1 -0
- package/lib/cli/render/reporter.js +519 -0
- package/lib/cli/render/reporter.js.map +1 -0
- package/lib/cli/render/tty.d.ts +77 -0
- package/lib/cli/render/tty.d.ts.map +1 -0
- package/lib/cli/render/tty.js +283 -0
- package/lib/cli/render/tty.js.map +1 -0
- package/lib/cli/run-options.d.ts +27 -0
- package/lib/cli/run-options.d.ts.map +1 -0
- package/lib/cli/run-options.js +58 -0
- package/lib/cli/run-options.js.map +1 -0
- package/lib/cli/skills.d.ts +38 -0
- package/lib/cli/skills.d.ts.map +1 -0
- package/lib/cli/skills.js +84 -0
- package/lib/cli/skills.js.map +1 -0
- package/lib/core/annotation.d.ts +56 -0
- package/lib/core/annotation.d.ts.map +1 -0
- package/lib/core/annotation.js +92 -0
- package/lib/core/annotation.js.map +1 -0
- package/lib/core/answerer.d.ts +68 -0
- package/lib/core/answerer.d.ts.map +1 -0
- package/lib/core/answerer.js +17 -0
- package/lib/core/answerer.js.map +1 -0
- package/lib/core/artifact-evidence.d.ts +50 -0
- package/lib/core/artifact-evidence.d.ts.map +1 -0
- package/lib/core/artifact-evidence.js +185 -0
- package/lib/core/artifact-evidence.js.map +1 -0
- package/lib/core/artifact-snapshot.d.ts +37 -0
- package/lib/core/artifact-snapshot.d.ts.map +1 -0
- package/lib/core/artifact-snapshot.js +339 -0
- package/lib/core/artifact-snapshot.js.map +1 -0
- package/lib/core/assertion.d.ts +129 -0
- package/lib/core/assertion.d.ts.map +1 -0
- package/lib/core/assertion.js +75 -0
- package/lib/core/assertion.js.map +1 -0
- package/lib/core/case.d.ts +79 -0
- package/lib/core/case.d.ts.map +1 -0
- package/lib/core/case.js +90 -0
- package/lib/core/case.js.map +1 -0
- package/lib/core/conversation-turn.d.ts +23 -0
- package/lib/core/conversation-turn.d.ts.map +1 -0
- package/lib/core/conversation-turn.js +31 -0
- package/lib/core/conversation-turn.js.map +1 -0
- package/lib/core/driver.d.ts +64 -0
- package/lib/core/driver.d.ts.map +1 -0
- package/lib/core/driver.js +18 -0
- package/lib/core/driver.js.map +1 -0
- package/lib/core/emitter.d.ts +20 -0
- package/lib/core/emitter.d.ts.map +1 -0
- package/lib/core/emitter.js +34 -0
- package/lib/core/emitter.js.map +1 -0
- package/lib/core/events.d.ts +202 -0
- package/lib/core/events.d.ts.map +1 -0
- package/lib/core/events.js +107 -0
- package/lib/core/events.js.map +1 -0
- package/lib/core/exec.d.ts +82 -0
- package/lib/core/exec.d.ts.map +1 -0
- package/lib/core/exec.js +168 -0
- package/lib/core/exec.js.map +1 -0
- package/lib/core/experiment.d.ts +285 -0
- package/lib/core/experiment.d.ts.map +1 -0
- package/lib/core/experiment.js +389 -0
- package/lib/core/experiment.js.map +1 -0
- package/lib/core/glob.d.ts +3 -0
- package/lib/core/glob.d.ts.map +1 -0
- package/lib/core/glob.js +32 -0
- package/lib/core/glob.js.map +1 -0
- package/lib/core/hash.d.ts +8 -0
- package/lib/core/hash.d.ts.map +1 -0
- package/lib/core/hash.js +214 -0
- package/lib/core/hash.js.map +1 -0
- package/lib/core/index.d.ts +29 -0
- package/lib/core/index.d.ts.map +1 -0
- package/lib/core/index.js +29 -0
- package/lib/core/index.js.map +1 -0
- package/lib/core/lifecycle-fixtures.d.ts +20 -0
- package/lib/core/lifecycle-fixtures.d.ts.map +1 -0
- package/lib/core/lifecycle-fixtures.js +109 -0
- package/lib/core/lifecycle-fixtures.js.map +1 -0
- package/lib/core/lifecycle-hooks.d.ts +52 -0
- package/lib/core/lifecycle-hooks.d.ts.map +1 -0
- package/lib/core/lifecycle-hooks.js +42 -0
- package/lib/core/lifecycle-hooks.js.map +1 -0
- package/lib/core/mcp-events.d.ts +44 -0
- package/lib/core/mcp-events.d.ts.map +1 -0
- package/lib/core/mcp-events.js +23 -0
- package/lib/core/mcp-events.js.map +1 -0
- package/lib/core/model-cli.d.ts +57 -0
- package/lib/core/model-cli.d.ts.map +1 -0
- package/lib/core/model-cli.js +237 -0
- package/lib/core/model-cli.js.map +1 -0
- package/lib/core/observer.d.ts +31 -0
- package/lib/core/observer.d.ts.map +1 -0
- package/lib/core/observer.js +25 -0
- package/lib/core/observer.js.map +1 -0
- package/lib/core/platform-process.d.ts +33 -0
- package/lib/core/platform-process.d.ts.map +1 -0
- package/lib/core/platform-process.js +214 -0
- package/lib/core/platform-process.js.map +1 -0
- package/lib/core/registry.d.ts +22 -0
- package/lib/core/registry.d.ts.map +1 -0
- package/lib/core/registry.js +45 -0
- package/lib/core/registry.js.map +1 -0
- package/lib/core/rubric.d.ts +18 -0
- package/lib/core/rubric.d.ts.map +1 -0
- package/lib/core/rubric.js +49 -0
- package/lib/core/rubric.js.map +1 -0
- package/lib/core/run.d.ts +419 -0
- package/lib/core/run.d.ts.map +1 -0
- package/lib/core/run.js +126 -0
- package/lib/core/run.js.map +1 -0
- package/lib/core/statistics.d.ts +39 -0
- package/lib/core/statistics.d.ts.map +1 -0
- package/lib/core/statistics.js +163 -0
- package/lib/core/statistics.js.map +1 -0
- package/lib/core/subject.d.ts +4 -0
- package/lib/core/subject.d.ts.map +1 -0
- package/lib/core/subject.js +46 -0
- package/lib/core/subject.js.map +1 -0
- package/lib/core/tool-events.d.ts +69 -0
- package/lib/core/tool-events.d.ts.map +1 -0
- package/lib/core/tool-events.js +242 -0
- package/lib/core/tool-events.js.map +1 -0
- package/lib/core/usage.d.ts +78 -0
- package/lib/core/usage.d.ts.map +1 -0
- package/lib/core/usage.js +104 -0
- package/lib/core/usage.js.map +1 -0
- package/lib/core/wire.d.ts +83 -0
- package/lib/core/wire.d.ts.map +1 -0
- package/lib/core/wire.js +101 -0
- package/lib/core/wire.js.map +1 -0
- package/lib/core/zod.d.ts +10 -0
- package/lib/core/zod.d.ts.map +1 -0
- package/lib/core/zod.js +18 -0
- package/lib/core/zod.js.map +1 -0
- package/lib/drivers/claude-code/index.d.ts +55 -0
- package/lib/drivers/claude-code/index.d.ts.map +1 -0
- package/lib/drivers/claude-code/index.js +779 -0
- package/lib/drivers/claude-code/index.js.map +1 -0
- package/lib/drivers/claude-code/parse-events.d.ts +46 -0
- package/lib/drivers/claude-code/parse-events.d.ts.map +1 -0
- package/lib/drivers/claude-code/parse-events.js +387 -0
- package/lib/drivers/claude-code/parse-events.js.map +1 -0
- package/lib/drivers/codex/app-events.d.ts +16 -0
- package/lib/drivers/codex/app-events.d.ts.map +1 -0
- package/lib/drivers/codex/app-events.js +184 -0
- package/lib/drivers/codex/app-events.js.map +1 -0
- package/lib/drivers/codex/config.d.ts +55 -0
- package/lib/drivers/codex/config.d.ts.map +1 -0
- package/lib/drivers/codex/config.js +125 -0
- package/lib/drivers/codex/config.js.map +1 -0
- package/lib/drivers/codex/index.d.ts +8 -0
- package/lib/drivers/codex/index.d.ts.map +1 -0
- package/lib/drivers/codex/index.js +904 -0
- package/lib/drivers/codex/index.js.map +1 -0
- package/lib/drivers/mcp/index.d.ts +52 -0
- package/lib/drivers/mcp/index.d.ts.map +1 -0
- package/lib/drivers/mcp/index.js +282 -0
- package/lib/drivers/mcp/index.js.map +1 -0
- package/lib/drivers/mcp/transport.d.ts +50 -0
- package/lib/drivers/mcp/transport.d.ts.map +1 -0
- package/lib/drivers/mcp/transport.js +190 -0
- package/lib/drivers/mcp/transport.js.map +1 -0
- package/lib/drivers/shared/artifacts.d.ts +4 -0
- package/lib/drivers/shared/artifacts.d.ts.map +1 -0
- package/lib/drivers/shared/artifacts.js +81 -0
- package/lib/drivers/shared/artifacts.js.map +1 -0
- package/lib/drivers/shared/secure-copy.d.ts +2 -0
- package/lib/drivers/shared/secure-copy.d.ts.map +1 -0
- package/lib/drivers/shared/secure-copy.js +35 -0
- package/lib/drivers/shared/secure-copy.js.map +1 -0
- package/lib/drivers/subprocess/index.d.ts +24 -0
- package/lib/drivers/subprocess/index.d.ts.map +1 -0
- package/lib/drivers/subprocess/index.js +451 -0
- package/lib/drivers/subprocess/index.js.map +1 -0
- package/lib/index.d.ts +40 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +48 -0
- package/lib/index.js.map +1 -0
- package/lib/optimization/reflective.d.ts +27 -0
- package/lib/optimization/reflective.d.ts.map +1 -0
- package/lib/optimization/reflective.js +257 -0
- package/lib/optimization/reflective.js.map +1 -0
- package/lib/orchestrator/annotation-loader.d.ts +65 -0
- package/lib/orchestrator/annotation-loader.d.ts.map +1 -0
- package/lib/orchestrator/annotation-loader.js +73 -0
- package/lib/orchestrator/annotation-loader.js.map +1 -0
- package/lib/orchestrator/annotation-store.d.ts +3 -0
- package/lib/orchestrator/annotation-store.d.ts.map +1 -0
- package/lib/orchestrator/annotation-store.js +100 -0
- package/lib/orchestrator/annotation-store.js.map +1 -0
- package/lib/orchestrator/authored-dependencies.d.ts +3 -0
- package/lib/orchestrator/authored-dependencies.d.ts.map +1 -0
- package/lib/orchestrator/authored-dependencies.js +146 -0
- package/lib/orchestrator/authored-dependencies.js.map +1 -0
- package/lib/orchestrator/campaign-lifecycle.d.ts +105 -0
- package/lib/orchestrator/campaign-lifecycle.d.ts.map +1 -0
- package/lib/orchestrator/campaign-lifecycle.js +141 -0
- package/lib/orchestrator/campaign-lifecycle.js.map +1 -0
- package/lib/orchestrator/candidate-integrity.d.ts +4 -0
- package/lib/orchestrator/candidate-integrity.d.ts.map +1 -0
- package/lib/orchestrator/candidate-integrity.js +14 -0
- package/lib/orchestrator/candidate-integrity.js.map +1 -0
- package/lib/orchestrator/candidates.d.ts +13 -0
- package/lib/orchestrator/candidates.d.ts.map +1 -0
- package/lib/orchestrator/candidates.js +577 -0
- package/lib/orchestrator/candidates.js.map +1 -0
- package/lib/orchestrator/compare.d.ts +80 -0
- package/lib/orchestrator/compare.d.ts.map +1 -0
- package/lib/orchestrator/compare.js +270 -0
- package/lib/orchestrator/compare.js.map +1 -0
- package/lib/orchestrator/comparison-identity.d.ts +10 -0
- package/lib/orchestrator/comparison-identity.d.ts.map +1 -0
- package/lib/orchestrator/comparison-identity.js +39 -0
- package/lib/orchestrator/comparison-identity.js.map +1 -0
- package/lib/orchestrator/config.d.ts +121 -0
- package/lib/orchestrator/config.d.ts.map +1 -0
- package/lib/orchestrator/config.js +176 -0
- package/lib/orchestrator/config.js.map +1 -0
- package/lib/orchestrator/content-bound-json.d.ts +5 -0
- package/lib/orchestrator/content-bound-json.d.ts.map +1 -0
- package/lib/orchestrator/content-bound-json.js +59 -0
- package/lib/orchestrator/content-bound-json.js.map +1 -0
- package/lib/orchestrator/discover.d.ts +45 -0
- package/lib/orchestrator/discover.d.ts.map +1 -0
- package/lib/orchestrator/discover.js +98 -0
- package/lib/orchestrator/discover.js.map +1 -0
- package/lib/orchestrator/doctor.d.ts +141 -0
- package/lib/orchestrator/doctor.d.ts.map +1 -0
- package/lib/orchestrator/doctor.js +525 -0
- package/lib/orchestrator/doctor.js.map +1 -0
- package/lib/orchestrator/driver-session.d.ts +177 -0
- package/lib/orchestrator/driver-session.d.ts.map +1 -0
- package/lib/orchestrator/driver-session.js +396 -0
- package/lib/orchestrator/driver-session.js.map +1 -0
- package/lib/orchestrator/evaluator-identity.d.ts +7 -0
- package/lib/orchestrator/evaluator-identity.d.ts.map +1 -0
- package/lib/orchestrator/evaluator-identity.js +42 -0
- package/lib/orchestrator/evaluator-identity.js.map +1 -0
- package/lib/orchestrator/experiment-budget.d.ts +11 -0
- package/lib/orchestrator/experiment-budget.d.ts.map +1 -0
- package/lib/orchestrator/experiment-budget.js +51 -0
- package/lib/orchestrator/experiment-budget.js.map +1 -0
- package/lib/orchestrator/experiment-context.d.ts +43 -0
- package/lib/orchestrator/experiment-context.d.ts.map +1 -0
- package/lib/orchestrator/experiment-context.js +9 -0
- package/lib/orchestrator/experiment-context.js.map +1 -0
- package/lib/orchestrator/experiment-contracts.d.ts +290 -0
- package/lib/orchestrator/experiment-contracts.d.ts.map +1 -0
- package/lib/orchestrator/experiment-contracts.js +38 -0
- package/lib/orchestrator/experiment-contracts.js.map +1 -0
- package/lib/orchestrator/experiment-corpus.d.ts +21 -0
- package/lib/orchestrator/experiment-corpus.d.ts.map +1 -0
- package/lib/orchestrator/experiment-corpus.js +276 -0
- package/lib/orchestrator/experiment-corpus.js.map +1 -0
- package/lib/orchestrator/experiment-evaluation.d.ts +44 -0
- package/lib/orchestrator/experiment-evaluation.d.ts.map +1 -0
- package/lib/orchestrator/experiment-evaluation.js +542 -0
- package/lib/orchestrator/experiment-evaluation.js.map +1 -0
- package/lib/orchestrator/experiment-finish.d.ts +6 -0
- package/lib/orchestrator/experiment-finish.d.ts.map +1 -0
- package/lib/orchestrator/experiment-finish.js +19 -0
- package/lib/orchestrator/experiment-finish.js.map +1 -0
- package/lib/orchestrator/experiment-identity.d.ts +6 -0
- package/lib/orchestrator/experiment-identity.d.ts.map +1 -0
- package/lib/orchestrator/experiment-identity.js +257 -0
- package/lib/orchestrator/experiment-identity.js.map +1 -0
- package/lib/orchestrator/experiment-loader.d.ts +175 -0
- package/lib/orchestrator/experiment-loader.d.ts.map +1 -0
- package/lib/orchestrator/experiment-loader.js +77 -0
- package/lib/orchestrator/experiment-loader.js.map +1 -0
- package/lib/orchestrator/experiment-report.d.ts +450 -0
- package/lib/orchestrator/experiment-report.d.ts.map +1 -0
- package/lib/orchestrator/experiment-report.js +570 -0
- package/lib/orchestrator/experiment-report.js.map +1 -0
- package/lib/orchestrator/experiment-runs.d.ts +379 -0
- package/lib/orchestrator/experiment-runs.d.ts.map +1 -0
- package/lib/orchestrator/experiment-runs.js +796 -0
- package/lib/orchestrator/experiment-runs.js.map +1 -0
- package/lib/orchestrator/experiment-runtime-identity.d.ts +41 -0
- package/lib/orchestrator/experiment-runtime-identity.d.ts.map +1 -0
- package/lib/orchestrator/experiment-runtime-identity.js +411 -0
- package/lib/orchestrator/experiment-runtime-identity.js.map +1 -0
- package/lib/orchestrator/experiment-selection.d.ts +25 -0
- package/lib/orchestrator/experiment-selection.d.ts.map +1 -0
- package/lib/orchestrator/experiment-selection.js +286 -0
- package/lib/orchestrator/experiment-selection.js.map +1 -0
- package/lib/orchestrator/experiment.d.ts +11 -0
- package/lib/orchestrator/experiment.d.ts.map +1 -0
- package/lib/orchestrator/experiment.js +639 -0
- package/lib/orchestrator/experiment.js.map +1 -0
- package/lib/orchestrator/fixture-identity.d.ts +7 -0
- package/lib/orchestrator/fixture-identity.d.ts.map +1 -0
- package/lib/orchestrator/fixture-identity.js +55 -0
- package/lib/orchestrator/fixture-identity.js.map +1 -0
- package/lib/orchestrator/fs-read.d.ts +19 -0
- package/lib/orchestrator/fs-read.d.ts.map +1 -0
- package/lib/orchestrator/fs-read.js +113 -0
- package/lib/orchestrator/fs-read.js.map +1 -0
- package/lib/orchestrator/grader-experiment.d.ts +190 -0
- package/lib/orchestrator/grader-experiment.d.ts.map +1 -0
- package/lib/orchestrator/grader-experiment.js +579 -0
- package/lib/orchestrator/grader-experiment.js.map +1 -0
- package/lib/orchestrator/grading.d.ts +31 -0
- package/lib/orchestrator/grading.d.ts.map +1 -0
- package/lib/orchestrator/grading.js +186 -0
- package/lib/orchestrator/grading.js.map +1 -0
- package/lib/orchestrator/index.d.ts +22 -0
- package/lib/orchestrator/index.d.ts.map +1 -0
- package/lib/orchestrator/index.js +30 -0
- package/lib/orchestrator/index.js.map +1 -0
- package/lib/orchestrator/lifecycle-hook-execution.d.ts +4 -0
- package/lib/orchestrator/lifecycle-hook-execution.d.ts.map +1 -0
- package/lib/orchestrator/lifecycle-hook-execution.js +67 -0
- package/lib/orchestrator/lifecycle-hook-execution.js.map +1 -0
- package/lib/orchestrator/list-runs.d.ts +33 -0
- package/lib/orchestrator/list-runs.d.ts.map +1 -0
- package/lib/orchestrator/list-runs.js +308 -0
- package/lib/orchestrator/list-runs.js.map +1 -0
- package/lib/orchestrator/loader.d.ts +3 -0
- package/lib/orchestrator/loader.d.ts.map +1 -0
- package/lib/orchestrator/loader.js +17 -0
- package/lib/orchestrator/loader.js.map +1 -0
- package/lib/orchestrator/optimization-lifecycle.d.ts +12 -0
- package/lib/orchestrator/optimization-lifecycle.d.ts.map +1 -0
- package/lib/orchestrator/optimization-lifecycle.js +92 -0
- package/lib/orchestrator/optimization-lifecycle.js.map +1 -0
- package/lib/orchestrator/orchestrator.d.ts +144 -0
- package/lib/orchestrator/orchestrator.d.ts.map +1 -0
- package/lib/orchestrator/orchestrator.js +632 -0
- package/lib/orchestrator/orchestrator.js.map +1 -0
- package/lib/orchestrator/owned-lock.d.ts +17 -0
- package/lib/orchestrator/owned-lock.d.ts.map +1 -0
- package/lib/orchestrator/owned-lock.js +149 -0
- package/lib/orchestrator/owned-lock.js.map +1 -0
- package/lib/orchestrator/package-version.d.ts +2 -0
- package/lib/orchestrator/package-version.d.ts.map +1 -0
- package/lib/orchestrator/package-version.js +4 -0
- package/lib/orchestrator/package-version.js.map +1 -0
- package/lib/orchestrator/provenance.d.ts +5 -0
- package/lib/orchestrator/provenance.d.ts.map +1 -0
- package/lib/orchestrator/provenance.js +137 -0
- package/lib/orchestrator/provenance.js.map +1 -0
- package/lib/orchestrator/regrade.d.ts +80 -0
- package/lib/orchestrator/regrade.d.ts.map +1 -0
- package/lib/orchestrator/regrade.js +433 -0
- package/lib/orchestrator/regrade.js.map +1 -0
- package/lib/orchestrator/rubric-loader.d.ts +7 -0
- package/lib/orchestrator/rubric-loader.d.ts.map +1 -0
- package/lib/orchestrator/rubric-loader.js +65 -0
- package/lib/orchestrator/rubric-loader.js.map +1 -0
- package/lib/orchestrator/run-dir.d.ts +40 -0
- package/lib/orchestrator/run-dir.d.ts.map +1 -0
- package/lib/orchestrator/run-dir.js +161 -0
- package/lib/orchestrator/run-dir.js.map +1 -0
- package/lib/orchestrator/run-execution.d.ts +30 -0
- package/lib/orchestrator/run-execution.d.ts.map +1 -0
- package/lib/orchestrator/run-execution.js +531 -0
- package/lib/orchestrator/run-execution.js.map +1 -0
- package/lib/orchestrator/run-lifecycle.d.ts +115 -0
- package/lib/orchestrator/run-lifecycle.d.ts.map +1 -0
- package/lib/orchestrator/run-lifecycle.js +136 -0
- package/lib/orchestrator/run-lifecycle.js.map +1 -0
- package/lib/orchestrator/suite-compare.d.ts +76 -0
- package/lib/orchestrator/suite-compare.d.ts.map +1 -0
- package/lib/orchestrator/suite-compare.js +159 -0
- package/lib/orchestrator/suite-compare.js.map +1 -0
- package/lib/orchestrator/suite-lifecycle.d.ts +157 -0
- package/lib/orchestrator/suite-lifecycle.d.ts.map +1 -0
- package/lib/orchestrator/suite-lifecycle.js +253 -0
- package/lib/orchestrator/suite-lifecycle.js.map +1 -0
- package/lib/orchestrator/suite-runs.d.ts +91 -0
- package/lib/orchestrator/suite-runs.d.ts.map +1 -0
- package/lib/orchestrator/suite-runs.js +157 -0
- package/lib/orchestrator/suite-runs.js.map +1 -0
- package/lib/orchestrator/suite-summary.d.ts +109 -0
- package/lib/orchestrator/suite-summary.d.ts.map +1 -0
- package/lib/orchestrator/suite-summary.js +213 -0
- package/lib/orchestrator/suite-summary.js.map +1 -0
- package/lib/orchestrator/trace-limits.d.ts +20 -0
- package/lib/orchestrator/trace-limits.d.ts.map +1 -0
- package/lib/orchestrator/trace-limits.js +28 -0
- package/lib/orchestrator/trace-limits.js.map +1 -0
- package/lib/orchestrator/validate-plugin-config.d.ts +10 -0
- package/lib/orchestrator/validate-plugin-config.d.ts.map +1 -0
- package/lib/orchestrator/validate-plugin-config.js +26 -0
- package/lib/orchestrator/validate-plugin-config.js.map +1 -0
- package/package.json +84 -0
- package/skills/lux/SKILL.md +85 -0
- package/skills/lux/references/cli.md +102 -0
- package/skills/lux/references/eval-authoring.md +105 -0
- package/skills/lux-answerer/SKILL.md +169 -0
- package/src/answerers/claude-code/index.ts +342 -0
- package/src/answerers/persona/index.ts +327 -0
- package/src/answerers/scripted/index.ts +186 -0
- package/src/answerers/shared.ts +23 -0
- package/src/answerers/terminal/index.ts +117 -0
- package/src/assertions/core/command-exits-zero.ts +94 -0
- package/src/assertions/core/event-checks.ts +138 -0
- package/src/assertions/core/file-checks.ts +336 -0
- package/src/assertions/core/helpers.ts +203 -0
- package/src/assertions/core/index.ts +80 -0
- package/src/assertions/core/json-pointer-equals.ts +84 -0
- package/src/assertions/core/output-checks.ts +134 -0
- package/src/assertions/core/predicate.ts +67 -0
- package/src/assertions/core/resource-checks.ts +180 -0
- package/src/assertions/core/safe-regex.ts +196 -0
- package/src/assertions/core/tool-called-with.ts +68 -0
- package/src/assertions/core/tool-calls.ts +28 -0
- package/src/assertions/core/tool-invocation.ts +198 -0
- package/src/assertions/core/tool-result-checks.ts +211 -0
- package/src/assertions/mcp/discovery-checks.ts +139 -0
- package/src/assertions/mcp/index.ts +37 -0
- package/src/assertions/rubric/index.ts +258 -0
- package/src/assertions/rubric/internal.ts +367 -0
- package/src/authoring.ts +2 -0
- package/src/cli/bin.ts +14 -0
- package/src/cli/command-runtime.ts +34 -0
- package/src/cli/init.ts +410 -0
- package/src/cli/program.ts +992 -0
- package/src/cli/render/format.ts +69 -0
- package/src/cli/render/reporter.ts +643 -0
- package/src/cli/render/tty.ts +314 -0
- package/src/cli/run-options.ts +82 -0
- package/src/cli/skills.ts +129 -0
- package/src/core/annotation.ts +104 -0
- package/src/core/answerer.ts +75 -0
- package/src/core/artifact-evidence.ts +249 -0
- package/src/core/artifact-snapshot.ts +429 -0
- package/src/core/assertion.ts +156 -0
- package/src/core/case.ts +103 -0
- package/src/core/conversation-turn.ts +47 -0
- package/src/core/driver.ts +75 -0
- package/src/core/emitter.ts +38 -0
- package/src/core/events.ts +135 -0
- package/src/core/exec.ts +263 -0
- package/src/core/experiment.ts +467 -0
- package/src/core/glob.ts +31 -0
- package/src/core/hash.ts +237 -0
- package/src/core/index.ts +28 -0
- package/src/core/lifecycle-fixtures.ts +145 -0
- package/src/core/lifecycle-hooks.ts +101 -0
- package/src/core/mcp-events.ts +57 -0
- package/src/core/model-cli.ts +271 -0
- package/src/core/observer.ts +50 -0
- package/src/core/platform-process.ts +284 -0
- package/src/core/registry.ts +57 -0
- package/src/core/rubric.ts +52 -0
- package/src/core/run.ts +144 -0
- package/src/core/statistics.ts +194 -0
- package/src/core/subject.ts +50 -0
- package/src/core/tool-events.ts +292 -0
- package/src/core/usage.ts +123 -0
- package/src/core/wire.ts +135 -0
- package/src/core/zod.ts +20 -0
- package/src/drivers/claude-code/index.ts +866 -0
- package/src/drivers/claude-code/parse-events.ts +464 -0
- package/src/drivers/codex/app-events.ts +218 -0
- package/src/drivers/codex/config.ts +128 -0
- package/src/drivers/codex/index.ts +995 -0
- package/src/drivers/mcp/index.ts +351 -0
- package/src/drivers/mcp/transport.ts +222 -0
- package/src/drivers/shared/artifacts.ts +86 -0
- package/src/drivers/shared/secure-copy.ts +40 -0
- package/src/drivers/subprocess/index.ts +490 -0
- package/src/index.ts +594 -0
- package/src/optimization/reflective.ts +319 -0
- package/src/orchestrator/annotation-loader.ts +97 -0
- package/src/orchestrator/annotation-store.ts +112 -0
- package/src/orchestrator/authored-dependencies.ts +193 -0
- package/src/orchestrator/campaign-lifecycle.ts +181 -0
- package/src/orchestrator/candidate-integrity.ts +18 -0
- package/src/orchestrator/candidates.ts +683 -0
- package/src/orchestrator/compare.ts +358 -0
- package/src/orchestrator/comparison-identity.ts +45 -0
- package/src/orchestrator/config.ts +205 -0
- package/src/orchestrator/content-bound-json.ts +71 -0
- package/src/orchestrator/discover.ts +132 -0
- package/src/orchestrator/doctor.ts +781 -0
- package/src/orchestrator/driver-session.ts +507 -0
- package/src/orchestrator/evaluator-identity.ts +45 -0
- package/src/orchestrator/experiment-budget.ts +61 -0
- package/src/orchestrator/experiment-context.ts +41 -0
- package/src/orchestrator/experiment-contracts.ts +43 -0
- package/src/orchestrator/experiment-corpus.ts +416 -0
- package/src/orchestrator/experiment-evaluation.ts +749 -0
- package/src/orchestrator/experiment-finish.ts +33 -0
- package/src/orchestrator/experiment-identity.ts +356 -0
- package/src/orchestrator/experiment-loader.ts +105 -0
- package/src/orchestrator/experiment-report.ts +788 -0
- package/src/orchestrator/experiment-runs.ts +960 -0
- package/src/orchestrator/experiment-runtime-identity.ts +465 -0
- package/src/orchestrator/experiment-selection.ts +467 -0
- package/src/orchestrator/experiment.ts +991 -0
- package/src/orchestrator/fixture-identity.ts +67 -0
- package/src/orchestrator/fs-read.ts +126 -0
- package/src/orchestrator/grader-experiment.ts +856 -0
- package/src/orchestrator/grading.ts +260 -0
- package/src/orchestrator/index.ts +186 -0
- package/src/orchestrator/lifecycle-hook-execution.ts +90 -0
- package/src/orchestrator/list-runs.ts +384 -0
- package/src/orchestrator/loader.ts +19 -0
- package/src/orchestrator/optimization-lifecycle.ts +126 -0
- package/src/orchestrator/orchestrator.ts +919 -0
- package/src/orchestrator/owned-lock.ts +147 -0
- package/src/orchestrator/package-version.ts +5 -0
- package/src/orchestrator/provenance.ts +140 -0
- package/src/orchestrator/regrade.ts +580 -0
- package/src/orchestrator/rubric-loader.ts +74 -0
- package/src/orchestrator/run-dir.ts +209 -0
- package/src/orchestrator/run-execution.ts +694 -0
- package/src/orchestrator/run-lifecycle.ts +174 -0
- package/src/orchestrator/suite-compare.ts +195 -0
- package/src/orchestrator/suite-lifecycle.ts +335 -0
- package/src/orchestrator/suite-runs.ts +202 -0
- package/src/orchestrator/suite-summary.ts +276 -0
- package/src/orchestrator/trace-limits.ts +65 -0
- package/src/orchestrator/validate-plugin-config.ts +34 -0
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { tryParseJson } from "./zod.js";
|
|
3
|
+
export const TOOL_CALL_KIND = "tool-call";
|
|
4
|
+
export const TOOL_RESULT_KIND = "tool-result";
|
|
5
|
+
export const ToolCallPayloadSchema = z
|
|
6
|
+
.object({
|
|
7
|
+
name: z.string().min(1),
|
|
8
|
+
input: z.unknown(),
|
|
9
|
+
toolUseId: z.string().min(1),
|
|
10
|
+
parentToolUseId: z.string().min(1).optional(),
|
|
11
|
+
})
|
|
12
|
+
.loose()
|
|
13
|
+
.superRefine((payload, ctx) => {
|
|
14
|
+
if (!Object.hasOwn(payload, "input")) {
|
|
15
|
+
ctx.addIssue({
|
|
16
|
+
code: "custom",
|
|
17
|
+
path: ["input"],
|
|
18
|
+
message: "input is required",
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
export const ToolResultPayloadSchema = z
|
|
23
|
+
.object({
|
|
24
|
+
name: z.string().min(1),
|
|
25
|
+
toolUseId: z.string().min(1),
|
|
26
|
+
content: z.unknown(),
|
|
27
|
+
structuredContent: z.record(z.string(), z.unknown()).optional(),
|
|
28
|
+
isError: z.boolean(),
|
|
29
|
+
text: z.string(),
|
|
30
|
+
durationMs: z.number().nonnegative().optional(),
|
|
31
|
+
parentToolUseId: z.string().min(1).optional(),
|
|
32
|
+
})
|
|
33
|
+
.loose()
|
|
34
|
+
.superRefine((payload, ctx) => {
|
|
35
|
+
if (!Object.hasOwn(payload, "content")) {
|
|
36
|
+
ctx.addIssue({
|
|
37
|
+
code: "custom",
|
|
38
|
+
path: ["content"],
|
|
39
|
+
message: "content is required",
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
export const ToolOutcomeSummarySchema = z
|
|
44
|
+
.object({
|
|
45
|
+
reportedCalls: z.number().int().nonnegative(),
|
|
46
|
+
total: z.number().int().nonnegative(),
|
|
47
|
+
succeeded: z.number().int().nonnegative(),
|
|
48
|
+
failed: z.number().int().nonnegative(),
|
|
49
|
+
unresolved: z.number().int().nonnegative(),
|
|
50
|
+
unmatchedResults: z.number().int().nonnegative(),
|
|
51
|
+
malformedEvents: z.number().int().nonnegative(),
|
|
52
|
+
})
|
|
53
|
+
.superRefine((summary, ctx) => {
|
|
54
|
+
if (summary.reportedCalls < summary.total) {
|
|
55
|
+
ctx.addIssue({
|
|
56
|
+
code: "custom",
|
|
57
|
+
path: ["reportedCalls"],
|
|
58
|
+
message: "reportedCalls cannot be less than total",
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
if (summary.total !== summary.succeeded + summary.failed + summary.unresolved) {
|
|
62
|
+
ctx.addIssue({
|
|
63
|
+
code: "custom",
|
|
64
|
+
path: ["total"],
|
|
65
|
+
message: "total must equal succeeded + failed + unresolved",
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
const isProgressKind = (event, kind) => event.type === "progress" && event.kind === kind;
|
|
70
|
+
export const isToolCallEvent = (event) => isProgressKind(event, TOOL_CALL_KIND);
|
|
71
|
+
export const isToolResultEvent = (event) => isProgressKind(event, TOOL_RESULT_KIND);
|
|
72
|
+
export const toolCallProgress = (seq, payload, ts) => ({
|
|
73
|
+
id: `tc-${payload.toolUseId || seq}`,
|
|
74
|
+
kind: TOOL_CALL_KIND,
|
|
75
|
+
payload,
|
|
76
|
+
ts,
|
|
77
|
+
});
|
|
78
|
+
export const toolResultProgress = (seq, payload, ts) => ({
|
|
79
|
+
id: `tr-${payload.toolUseId || seq}`,
|
|
80
|
+
kind: TOOL_RESULT_KIND,
|
|
81
|
+
payload,
|
|
82
|
+
ts,
|
|
83
|
+
});
|
|
84
|
+
export const toolEventCalls = (events, name) => events
|
|
85
|
+
.filter(isToolCallEvent)
|
|
86
|
+
.map((event) => ToolCallPayloadSchema.safeParse(event.payload).data)
|
|
87
|
+
.filter((payload) => payload !== undefined)
|
|
88
|
+
.filter((payload) => name === undefined || payload.name === name);
|
|
89
|
+
export const toolResults = (events, name) => events
|
|
90
|
+
.filter(isToolResultEvent)
|
|
91
|
+
.map((event) => ToolResultPayloadSchema.safeParse(event.payload).data)
|
|
92
|
+
.filter((payload) => payload !== undefined)
|
|
93
|
+
.filter((payload) => name === undefined || payload.name === name);
|
|
94
|
+
export const malformedToolEventCount = (events, kinds = [
|
|
95
|
+
TOOL_CALL_KIND,
|
|
96
|
+
TOOL_RESULT_KIND,
|
|
97
|
+
]) => {
|
|
98
|
+
const selected = new Set(kinds);
|
|
99
|
+
return events.filter((event) => {
|
|
100
|
+
if (event.type !== "progress" || !selected.has(event.kind))
|
|
101
|
+
return false;
|
|
102
|
+
const schema = event.kind === TOOL_CALL_KIND ? ToolCallPayloadSchema : ToolResultPayloadSchema;
|
|
103
|
+
return !schema.safeParse(event.payload).success;
|
|
104
|
+
}).length;
|
|
105
|
+
};
|
|
106
|
+
export const toolResultValue = (result) => {
|
|
107
|
+
if (result.structuredContent !== undefined)
|
|
108
|
+
return result.structuredContent;
|
|
109
|
+
const parsedText = tryParseJson(result.text);
|
|
110
|
+
if (Array.isArray(result.content)) {
|
|
111
|
+
return parsedText !== undefined ? parsedText : result.content;
|
|
112
|
+
}
|
|
113
|
+
if (typeof result.content === "string") {
|
|
114
|
+
const parsedContent = tryParseJson(result.content);
|
|
115
|
+
return parsedContent !== undefined ? parsedContent : result.content;
|
|
116
|
+
}
|
|
117
|
+
if (result.content !== null && result.content !== undefined) {
|
|
118
|
+
return result.content;
|
|
119
|
+
}
|
|
120
|
+
return parsedText !== undefined ? parsedText : result.text;
|
|
121
|
+
};
|
|
122
|
+
/**
|
|
123
|
+
* Correlate standardized calls with the first later result in the same agent
|
|
124
|
+
* scope. Evidence without the required correlation fields is ignored.
|
|
125
|
+
*/
|
|
126
|
+
const correlationKey = (toolName, toolUseId, parentToolUseId) => JSON.stringify([parentToolUseId ?? null, toolName, toolUseId]);
|
|
127
|
+
class ToolOutcomeAccumulatorImpl {
|
|
128
|
+
name;
|
|
129
|
+
correlatedInvocations = [];
|
|
130
|
+
pending = new Map();
|
|
131
|
+
ambiguous = new Map();
|
|
132
|
+
reportedCalls = 0;
|
|
133
|
+
succeeded = 0;
|
|
134
|
+
failed = 0;
|
|
135
|
+
unresolved = 0;
|
|
136
|
+
unmatchedResults = 0;
|
|
137
|
+
malformedEvents = 0;
|
|
138
|
+
constructor(name) {
|
|
139
|
+
this.name = name;
|
|
140
|
+
}
|
|
141
|
+
add = (event) => {
|
|
142
|
+
if (isToolCallEvent(event)) {
|
|
143
|
+
if (this.name === undefined)
|
|
144
|
+
this.reportedCalls++;
|
|
145
|
+
const call = ToolCallPayloadSchema.safeParse(event.payload).data;
|
|
146
|
+
if (!call) {
|
|
147
|
+
if (this.name === undefined)
|
|
148
|
+
this.malformedEvents++;
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
if (this.name !== undefined && call.name !== this.name)
|
|
152
|
+
return;
|
|
153
|
+
if (this.name !== undefined)
|
|
154
|
+
this.reportedCalls++;
|
|
155
|
+
const index = this.correlatedInvocations.push({ call }) - 1;
|
|
156
|
+
this.unresolved++;
|
|
157
|
+
const key = correlationKey(call.name, call.toolUseId, call.parentToolUseId);
|
|
158
|
+
const ambiguousCalls = this.ambiguous.get(key);
|
|
159
|
+
if (ambiguousCalls !== undefined) {
|
|
160
|
+
this.ambiguous.set(key, ambiguousCalls + 1);
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
if (this.pending.has(key)) {
|
|
164
|
+
this.pending.delete(key);
|
|
165
|
+
this.ambiguous.set(key, 2);
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
this.pending.set(key, index);
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
if (!isToolResultEvent(event))
|
|
172
|
+
return;
|
|
173
|
+
const result = ToolResultPayloadSchema.safeParse(event.payload).data;
|
|
174
|
+
if (!result) {
|
|
175
|
+
if (this.name === undefined)
|
|
176
|
+
this.malformedEvents++;
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
if (this.name !== undefined && result.name !== this.name)
|
|
180
|
+
return;
|
|
181
|
+
const key = correlationKey(result.name, result.toolUseId, result.parentToolUseId);
|
|
182
|
+
const ambiguousCalls = this.ambiguous.get(key);
|
|
183
|
+
if (ambiguousCalls !== undefined) {
|
|
184
|
+
this.unmatchedResults++;
|
|
185
|
+
if (ambiguousCalls === 1)
|
|
186
|
+
this.ambiguous.delete(key);
|
|
187
|
+
else
|
|
188
|
+
this.ambiguous.set(key, ambiguousCalls - 1);
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
const index = this.pending.get(key);
|
|
192
|
+
if (index === undefined) {
|
|
193
|
+
this.unmatchedResults++;
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
this.pending.delete(key);
|
|
197
|
+
const invocation = this.correlatedInvocations[index];
|
|
198
|
+
if (!invocation) {
|
|
199
|
+
this.unmatchedResults++;
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
invocation.result = result;
|
|
203
|
+
this.unresolved--;
|
|
204
|
+
if (result.isError)
|
|
205
|
+
this.failed++;
|
|
206
|
+
else
|
|
207
|
+
this.succeeded++;
|
|
208
|
+
};
|
|
209
|
+
summary = () => ({
|
|
210
|
+
reportedCalls: this.reportedCalls,
|
|
211
|
+
total: this.correlatedInvocations.length,
|
|
212
|
+
succeeded: this.succeeded,
|
|
213
|
+
failed: this.failed,
|
|
214
|
+
unresolved: this.unresolved,
|
|
215
|
+
unmatchedResults: this.unmatchedResults,
|
|
216
|
+
malformedEvents: this.malformedEvents,
|
|
217
|
+
});
|
|
218
|
+
correlation = () => ({
|
|
219
|
+
invocations: this.correlatedInvocations,
|
|
220
|
+
unmatchedResults: this.unmatchedResults,
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
export const createToolOutcomeAccumulator = () => new ToolOutcomeAccumulatorImpl();
|
|
224
|
+
export const correlateToolEvents = (events, name) => {
|
|
225
|
+
const accumulator = new ToolOutcomeAccumulatorImpl(name);
|
|
226
|
+
for (const event of events)
|
|
227
|
+
accumulator.add(event);
|
|
228
|
+
return accumulator.correlation();
|
|
229
|
+
};
|
|
230
|
+
export const toolInvocations = (events, name) => correlateToolEvents(events, name).invocations;
|
|
231
|
+
export const toolInvocationOutcome = (invocation) => {
|
|
232
|
+
if (!invocation.result)
|
|
233
|
+
return "unresolved";
|
|
234
|
+
return invocation.result.isError ? "failed" : "succeeded";
|
|
235
|
+
};
|
|
236
|
+
export const summarizeToolOutcomes = (events) => {
|
|
237
|
+
const accumulator = createToolOutcomeAccumulator();
|
|
238
|
+
for (const event of events)
|
|
239
|
+
accumulator.add(event);
|
|
240
|
+
return accumulator.summary();
|
|
241
|
+
};
|
|
242
|
+
//# sourceMapping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AE,CAAC;IACnD,KAAK,MAAM,KAAK,IAAI,MAAM;QAAE,WAAW,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACnD,OAAO,WAAW,CAAC,OAAO,EAAE,CAAC;AAC/B,CAAC,CAAC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Token accounting. A Lux run spends tokens in three places: the agent
|
|
4
|
+
* under test (the driver), the answerer playing the user, and the LLM
|
|
5
|
+
* judge grading the result. Only the first is the thing being measured —
|
|
6
|
+
* the other two are eval overhead — so usage is tracked per source and
|
|
7
|
+
* summed at the edges rather than pooled into one number.
|
|
8
|
+
*/
|
|
9
|
+
export declare const TokenUsageSchema: z.ZodObject<{
|
|
10
|
+
input: z.ZodNumber;
|
|
11
|
+
output: z.ZodNumber;
|
|
12
|
+
cacheRead: z.ZodNumber;
|
|
13
|
+
cacheCreation: z.ZodNumber;
|
|
14
|
+
}, z.core.$strip>;
|
|
15
|
+
export type TokenUsage = z.infer<typeof TokenUsageSchema>;
|
|
16
|
+
/**
|
|
17
|
+
* One API call's usage, tagged with what the agent did on it — a tool name,
|
|
18
|
+
* a snippet of its reply — so a per-turn breakdown reads as more than a number.
|
|
19
|
+
*/
|
|
20
|
+
export declare const TurnUsageSchema: z.ZodObject<{
|
|
21
|
+
input: z.ZodNumber;
|
|
22
|
+
output: z.ZodNumber;
|
|
23
|
+
cacheRead: z.ZodNumber;
|
|
24
|
+
cacheCreation: z.ZodNumber;
|
|
25
|
+
label: z.ZodExactOptional<z.ZodString>;
|
|
26
|
+
}, z.core.$strip>;
|
|
27
|
+
export type TurnUsage = z.infer<typeof TurnUsageSchema>;
|
|
28
|
+
/**
|
|
29
|
+
* The vocabulary a turn label is built from: one glyph per facet an API call
|
|
30
|
+
* exercised. Kept beside the turn model — not in the driver that stamps them
|
|
31
|
+
* onto labels nor the reporter that documents them in its legend — so the two
|
|
32
|
+
* cannot drift out of agreement.
|
|
33
|
+
*/
|
|
34
|
+
export declare const TURN_GLYPHS: {
|
|
35
|
+
readonly thinking: "✻";
|
|
36
|
+
readonly ask: "?";
|
|
37
|
+
readonly tool: "⚙";
|
|
38
|
+
readonly reply: "¶";
|
|
39
|
+
};
|
|
40
|
+
export declare const emptyUsage: () => TokenUsage;
|
|
41
|
+
export declare const addUsage: (a: TokenUsage, b: TokenUsage) => TokenUsage;
|
|
42
|
+
export declare const sumUsage: (usages: readonly TokenUsage[]) => TokenUsage;
|
|
43
|
+
/** Every token the call touched, cached or not. */
|
|
44
|
+
export declare const totalTokens: (u: TokenUsage) => number;
|
|
45
|
+
export declare const isUsageEmpty: (u: TokenUsage) => boolean;
|
|
46
|
+
/** Usage split by who spent it. `agent` is the subject; the rest is harness. */
|
|
47
|
+
export declare const RunUsageSchema: z.ZodObject<{
|
|
48
|
+
agent: z.ZodObject<{
|
|
49
|
+
input: z.ZodNumber;
|
|
50
|
+
output: z.ZodNumber;
|
|
51
|
+
cacheRead: z.ZodNumber;
|
|
52
|
+
cacheCreation: z.ZodNumber;
|
|
53
|
+
}, z.core.$strip>;
|
|
54
|
+
answerer: z.ZodObject<{
|
|
55
|
+
input: z.ZodNumber;
|
|
56
|
+
output: z.ZodNumber;
|
|
57
|
+
cacheRead: z.ZodNumber;
|
|
58
|
+
cacheCreation: z.ZodNumber;
|
|
59
|
+
}, z.core.$strip>;
|
|
60
|
+
grading: z.ZodObject<{
|
|
61
|
+
input: z.ZodNumber;
|
|
62
|
+
output: z.ZodNumber;
|
|
63
|
+
cacheRead: z.ZodNumber;
|
|
64
|
+
cacheCreation: z.ZodNumber;
|
|
65
|
+
}, z.core.$strip>;
|
|
66
|
+
}, z.core.$strip>;
|
|
67
|
+
export type RunUsage = z.infer<typeof RunUsageSchema>;
|
|
68
|
+
export declare const emptyRunUsage: () => RunUsage;
|
|
69
|
+
/** What Lux spent to run the eval, as opposed to what the agent spent. */
|
|
70
|
+
export declare const harnessUsage: (u: RunUsage) => TokenUsage;
|
|
71
|
+
/**
|
|
72
|
+
* Returns null when the object is absent or carries none of the recognized
|
|
73
|
+
* usage keys, so a driver can distinguish "reported zero" from "reported
|
|
74
|
+
* nothing". A partial or malformed report still parses — unrecognized or
|
|
75
|
+
* missing counts read as 0, per `AgentTokenCountSchema`'s never-fail rule.
|
|
76
|
+
*/
|
|
77
|
+
export declare const parseAgentUsage: (raw: unknown) => TokenUsage | null;
|
|
78
|
+
//# sourceMappingURL=usage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usage.d.ts","sourceRoot":"","sources":["../../src/core/usage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB;;;;;iBAO3B,CAAC;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAE1D;;;GAGG;AACH,eAAO,MAAM,eAAe;;;;;;iBAE1B,CAAC;AACH,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAExD;;;;;GAKG;AACH,eAAO,MAAM,WAAW;aACtB,QAAQ,EAAE,GAAG;aACb,GAAG,EAAE,GAAG;aACR,IAAI,EAAE,GAAG;aACT,KAAK,EAAE,GAAG;CACF,CAAC;AAEX,eAAO,MAAM,UAAU,QAAO,UAK5B,CAAC;AAEH,eAAO,MAAM,QAAQ,MAAO,UAAU,KAAK,UAAU,KAAG,UAKtD,CAAC;AAEH,eAAO,MAAM,QAAQ,WAAY,SAAS,UAAU,EAAE,KAAG,UAClB,CAAC;AAExC,mDAAmD;AACnD,eAAO,MAAM,WAAW,MAAO,UAAU,KAAG,MACQ,CAAC;AAErD,eAAO,MAAM,YAAY,MAAO,UAAU,KAAG,OAA+B,CAAC;AAE7E,gFAAgF;AAChF,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;iBAIzB,CAAC;AACH,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAEtD,eAAO,MAAM,aAAa,QAAO,QAI/B,CAAC;AAEH,0EAA0E;AAC1E,eAAO,MAAM,YAAY,MAAO,QAAQ,KAAG,UAA6C,CAAC;AAiCzF;;;;;GAKG;AACH,eAAO,MAAM,eAAe,QAAS,OAAO,KAAG,UAAU,GAAG,IAI3D,CAAC"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Token accounting. A Lux run spends tokens in three places: the agent
|
|
4
|
+
* under test (the driver), the answerer playing the user, and the LLM
|
|
5
|
+
* judge grading the result. Only the first is the thing being measured —
|
|
6
|
+
* the other two are eval overhead — so usage is tracked per source and
|
|
7
|
+
* summed at the edges rather than pooled into one number.
|
|
8
|
+
*/
|
|
9
|
+
export const TokenUsageSchema = z.object({
|
|
10
|
+
input: z.number().int().nonnegative(),
|
|
11
|
+
output: z.number().int().nonnegative(),
|
|
12
|
+
/** Prompt tokens served from the cache. Billed, but far cheaper than `input`. */
|
|
13
|
+
cacheRead: z.number().int().nonnegative(),
|
|
14
|
+
/** Prompt tokens written to the cache on this call. */
|
|
15
|
+
cacheCreation: z.number().int().nonnegative(),
|
|
16
|
+
});
|
|
17
|
+
/**
|
|
18
|
+
* One API call's usage, tagged with what the agent did on it — a tool name,
|
|
19
|
+
* a snippet of its reply — so a per-turn breakdown reads as more than a number.
|
|
20
|
+
*/
|
|
21
|
+
export const TurnUsageSchema = TokenUsageSchema.extend({
|
|
22
|
+
label: z.exactOptional(z.string()),
|
|
23
|
+
});
|
|
24
|
+
/**
|
|
25
|
+
* The vocabulary a turn label is built from: one glyph per facet an API call
|
|
26
|
+
* exercised. Kept beside the turn model — not in the driver that stamps them
|
|
27
|
+
* onto labels nor the reporter that documents them in its legend — so the two
|
|
28
|
+
* cannot drift out of agreement.
|
|
29
|
+
*/
|
|
30
|
+
export const TURN_GLYPHS = {
|
|
31
|
+
thinking: "✻",
|
|
32
|
+
ask: "?",
|
|
33
|
+
tool: "⚙",
|
|
34
|
+
reply: "¶",
|
|
35
|
+
};
|
|
36
|
+
export const emptyUsage = () => ({
|
|
37
|
+
input: 0,
|
|
38
|
+
output: 0,
|
|
39
|
+
cacheRead: 0,
|
|
40
|
+
cacheCreation: 0,
|
|
41
|
+
});
|
|
42
|
+
export const addUsage = (a, b) => ({
|
|
43
|
+
input: a.input + b.input,
|
|
44
|
+
output: a.output + b.output,
|
|
45
|
+
cacheRead: a.cacheRead + b.cacheRead,
|
|
46
|
+
cacheCreation: a.cacheCreation + b.cacheCreation,
|
|
47
|
+
});
|
|
48
|
+
export const sumUsage = (usages) => usages.reduce(addUsage, emptyUsage());
|
|
49
|
+
/** Every token the call touched, cached or not. */
|
|
50
|
+
export const totalTokens = (u) => u.input + u.output + u.cacheRead + u.cacheCreation;
|
|
51
|
+
export const isUsageEmpty = (u) => totalTokens(u) === 0;
|
|
52
|
+
/** Usage split by who spent it. `agent` is the subject; the rest is harness. */
|
|
53
|
+
export const RunUsageSchema = z.object({
|
|
54
|
+
agent: TokenUsageSchema,
|
|
55
|
+
answerer: TokenUsageSchema,
|
|
56
|
+
grading: TokenUsageSchema,
|
|
57
|
+
});
|
|
58
|
+
export const emptyRunUsage = () => ({
|
|
59
|
+
agent: emptyUsage(),
|
|
60
|
+
answerer: emptyUsage(),
|
|
61
|
+
grading: emptyUsage(),
|
|
62
|
+
});
|
|
63
|
+
/** What Lux spent to run the eval, as opposed to what the agent spent. */
|
|
64
|
+
export const harnessUsage = (u) => addUsage(u.answerer, u.grading);
|
|
65
|
+
// Token accounting must never be the reason a run fails to grade.
|
|
66
|
+
const AgentTokenCountSchema = z.number().int().nonnegative().catch(0);
|
|
67
|
+
/**
|
|
68
|
+
* The snake_case `usage` object the Claude CLI reports (on the
|
|
69
|
+
* `--output-format json` envelope, and on the final `result` line of a
|
|
70
|
+
* `stream-json` stream).
|
|
71
|
+
*/
|
|
72
|
+
const AgentUsageSchema = z
|
|
73
|
+
.object({
|
|
74
|
+
input_tokens: AgentTokenCountSchema,
|
|
75
|
+
output_tokens: AgentTokenCountSchema,
|
|
76
|
+
cache_read_input_tokens: AgentTokenCountSchema,
|
|
77
|
+
cache_creation_input_tokens: AgentTokenCountSchema,
|
|
78
|
+
})
|
|
79
|
+
.transform((usage) => ({
|
|
80
|
+
input: usage.input_tokens,
|
|
81
|
+
output: usage.output_tokens,
|
|
82
|
+
cacheRead: usage.cache_read_input_tokens,
|
|
83
|
+
cacheCreation: usage.cache_creation_input_tokens,
|
|
84
|
+
}));
|
|
85
|
+
const AGENT_USAGE_KEYS = [
|
|
86
|
+
"input_tokens",
|
|
87
|
+
"output_tokens",
|
|
88
|
+
"cache_read_input_tokens",
|
|
89
|
+
"cache_creation_input_tokens",
|
|
90
|
+
];
|
|
91
|
+
/**
|
|
92
|
+
* Returns null when the object is absent or carries none of the recognized
|
|
93
|
+
* usage keys, so a driver can distinguish "reported zero" from "reported
|
|
94
|
+
* nothing". A partial or malformed report still parses — unrecognized or
|
|
95
|
+
* missing counts read as 0, per `AgentTokenCountSchema`'s never-fail rule.
|
|
96
|
+
*/
|
|
97
|
+
export const parseAgentUsage = (raw) => {
|
|
98
|
+
if (typeof raw !== "object" || raw === null)
|
|
99
|
+
return null;
|
|
100
|
+
if (!AGENT_USAGE_KEYS.some((key) => key in raw))
|
|
101
|
+
return null;
|
|
102
|
+
return AgentUsageSchema.safeParse(raw).data ?? null;
|
|
103
|
+
};
|
|
104
|
+
//# sourceMappingURL=usage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usage.js","sourceRoot":"","sources":["../../src/core/usage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC;IACvC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,EAAc,EAAE,CAAC,CAAC;IACtB,KAAK,EAAE,KAAK,CAAC,YAAY;IACzB,MAAM,EAAE,KAAK,CAAC,aAAa;IAC3B,SAAS,EAAE,KAAK,CAAC,uBAAuB;IACxC,aAAa,EAAE,KAAK,CAAC,2BAA2B;CACjD,CAAC,CACH,CAAC;AAEJ,MAAM,gBAAgB,GAAG;IACvB,cAAc;IACd,eAAe;IACf,yBAAyB;IACzB,6BAA6B;CACrB,CAAC;AAEX;;;;;GAKG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,GAAY,EAAqB,EAAE;IACjE,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IACzD,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,IAAI,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC;IAC7D,OAAO,gBAAgB,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,IAAI,IAAI,IAAI,CAAC;AACtD,CAAC,CAAC"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { type Answer, type Done, type ErrorEvent, type Interrupt, type Progress, type ReadyState } from "./events.js";
|
|
3
|
+
export declare const WireEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
4
|
+
agentId: z.ZodString;
|
|
5
|
+
agentVersion: z.ZodExactOptional<z.ZodString>;
|
|
6
|
+
model: z.ZodExactOptional<z.ZodString>;
|
|
7
|
+
detail: z.ZodExactOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
8
|
+
type: z.ZodLiteral<"ready">;
|
|
9
|
+
}, z.core.$strip>, z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
10
|
+
kind: z.ZodLiteral<"ask">;
|
|
11
|
+
id: z.ZodString;
|
|
12
|
+
question: z.ZodString;
|
|
13
|
+
context: z.ZodOptional<z.ZodUnknown>;
|
|
14
|
+
type: z.ZodLiteral<"interrupt">;
|
|
15
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
16
|
+
kind: z.ZodLiteral<"approve">;
|
|
17
|
+
id: z.ZodString;
|
|
18
|
+
request: z.ZodString;
|
|
19
|
+
context: z.ZodOptional<z.ZodUnknown>;
|
|
20
|
+
type: z.ZodLiteral<"interrupt">;
|
|
21
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
22
|
+
kind: z.ZodLiteral<"custom">;
|
|
23
|
+
id: z.ZodString;
|
|
24
|
+
payload: z.ZodUnknown;
|
|
25
|
+
context: z.ZodOptional<z.ZodUnknown>;
|
|
26
|
+
type: z.ZodLiteral<"interrupt">;
|
|
27
|
+
}, z.core.$strip>], "kind">, z.ZodObject<{
|
|
28
|
+
id: z.ZodString;
|
|
29
|
+
kind: z.ZodString;
|
|
30
|
+
payload: z.ZodUnknown;
|
|
31
|
+
type: z.ZodLiteral<"progress">;
|
|
32
|
+
ts: z.ZodDefault<z.ZodNumber>;
|
|
33
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
34
|
+
type: z.ZodLiteral<"done">;
|
|
35
|
+
summary: z.ZodOptional<z.ZodUnknown>;
|
|
36
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
37
|
+
type: z.ZodLiteral<"error">;
|
|
38
|
+
exitReason: z.ZodDefault<z.ZodEnum<{
|
|
39
|
+
error: "error";
|
|
40
|
+
"idle-timeout": "idle-timeout";
|
|
41
|
+
"max-interactions": "max-interactions";
|
|
42
|
+
}>>;
|
|
43
|
+
reason: z.ZodString;
|
|
44
|
+
}, z.core.$strip>], "type">;
|
|
45
|
+
export type WireEvent = z.infer<typeof WireEventSchema>;
|
|
46
|
+
export type ParsedDriverEvent = {
|
|
47
|
+
tag: "ready";
|
|
48
|
+
ready: ReadyState;
|
|
49
|
+
} | {
|
|
50
|
+
tag: "interrupt";
|
|
51
|
+
interrupt: Interrupt;
|
|
52
|
+
} | {
|
|
53
|
+
tag: "progress";
|
|
54
|
+
progress: Progress;
|
|
55
|
+
} | {
|
|
56
|
+
tag: "done";
|
|
57
|
+
done: Done;
|
|
58
|
+
} | {
|
|
59
|
+
tag: "error";
|
|
60
|
+
error: ErrorEvent;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Parse a single line from a `lux-jsonl` agent. Returns null for empty
|
|
64
|
+
* lines, malformed JSON, or events that don't match the wire schema.
|
|
65
|
+
* Validation failures are silent by design — drivers may interleave
|
|
66
|
+
* non-protocol log lines on stdout.
|
|
67
|
+
*/
|
|
68
|
+
export declare const parseWireEvent: (line: string) => ParsedDriverEvent | null;
|
|
69
|
+
/**
|
|
70
|
+
* Serialize an Answer to a `lux-jsonl` line (newline-terminated). The
|
|
71
|
+
* inverse of an agent reading its stdin and dispatching to whatever
|
|
72
|
+
* pending interrupt the answer is for.
|
|
73
|
+
*/
|
|
74
|
+
export declare const formatWireAnswer: (answer: Answer) => string;
|
|
75
|
+
/**
|
|
76
|
+
* Parse one stdout line into zero, one, or many Lux driver events. A single
|
|
77
|
+
* line can carry multiple events — e.g. a Claude Code assistant message with
|
|
78
|
+
* a text block followed by a tool_use block — so returning an array lets a
|
|
79
|
+
* driver surface all of them rather than dropping every block after the first.
|
|
80
|
+
*/
|
|
81
|
+
export type ParseEventFn = (line: string) => ParsedDriverEvent | ParsedDriverEvent[] | null;
|
|
82
|
+
export type FormatAnswerFn = (answer: Answer) => string;
|
|
83
|
+
//# sourceMappingURL=wire.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wire.d.ts","sourceRoot":"","sources":["../../src/core/wire.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,KAAK,MAAM,EAIX,KAAK,IAAI,EACT,KAAK,UAAU,EAEf,KAAK,SAAS,EACd,KAAK,QAAQ,EAEb,KAAK,UAAU,EAEhB,MAAM,aAAa,CAAC;AAqCrB,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2BAM1B,CAAC;AAEH,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAExD,MAAM,MAAM,iBAAiB,GACzB;IAAE,GAAG,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,UAAU,CAAA;CAAE,GACnC;IAAE,GAAG,EAAE,WAAW,CAAC;IAAC,SAAS,EAAE,SAAS,CAAA;CAAE,GAC1C;IAAE,GAAG,EAAE,UAAU,CAAC;IAAC,QAAQ,EAAE,QAAQ,CAAA;CAAE,GACvC;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,IAAI,CAAA;CAAE,GAC3B;IAAE,GAAG,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,UAAU,CAAA;CAAE,CAAC;AAwBxC;;;;;GAKG;AACH,eAAO,MAAM,cAAc,SAAU,MAAM,KAAG,iBAAiB,GAAG,IAYjE,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,WAAY,MAAM,KAAG,MAUjD,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,iBAAiB,GAAG,iBAAiB,EAAE,GAAG,IAAI,CAAC;AAC5F,MAAM,MAAM,cAAc,GAAG,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,CAAC"}
|
package/lib/core/wire.js
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { ApproveInterruptSchema, AskInterruptSchema, CustomInterruptSchema, ErrorEventReasonSchema, ProgressSchema, ReadyStateSchema, } from "./events.js";
|
|
3
|
+
/**
|
|
4
|
+
* The `lux-jsonl` wire protocol. Drivers that talk to a subprocess agent
|
|
5
|
+
* over stdio (or any line-delimited transport) parse incoming lines with
|
|
6
|
+
* {@link parseWireEvent} and serialize outgoing answers with
|
|
7
|
+
* {@link formatWireAnswer}. Drivers that speak a foreign protocol can
|
|
8
|
+
* import {@link ParsedDriverEvent} and emit it directly.
|
|
9
|
+
*
|
|
10
|
+
* Each arm is the internal event schema plus a `type` discriminator. The wire
|
|
11
|
+
* is looser in two places — `progress.ts` and `error.exitReason` may be omitted
|
|
12
|
+
* — and those two `z.default()`s are the whole difference.
|
|
13
|
+
*/
|
|
14
|
+
const ReadyEventSchema = ReadyStateSchema.extend({ type: z.literal("ready") });
|
|
15
|
+
const InterruptEventSchema = z.discriminatedUnion("kind", [
|
|
16
|
+
AskInterruptSchema.extend({ type: z.literal("interrupt") }),
|
|
17
|
+
ApproveInterruptSchema.extend({ type: z.literal("interrupt") }),
|
|
18
|
+
CustomInterruptSchema.extend({ type: z.literal("interrupt") }),
|
|
19
|
+
]);
|
|
20
|
+
const ProgressEventSchema = ProgressSchema.extend({
|
|
21
|
+
type: z.literal("progress"),
|
|
22
|
+
ts: z.number().default(() => Date.now()),
|
|
23
|
+
});
|
|
24
|
+
const DoneEventSchema = z.object({
|
|
25
|
+
type: z.literal("done"),
|
|
26
|
+
summary: z.unknown().optional(),
|
|
27
|
+
});
|
|
28
|
+
const ErrorEventSchema = z.object({
|
|
29
|
+
type: z.literal("error"),
|
|
30
|
+
exitReason: ErrorEventReasonSchema.default("error"),
|
|
31
|
+
reason: z.string(),
|
|
32
|
+
});
|
|
33
|
+
export const WireEventSchema = z.discriminatedUnion("type", [
|
|
34
|
+
ReadyEventSchema,
|
|
35
|
+
InterruptEventSchema,
|
|
36
|
+
ProgressEventSchema,
|
|
37
|
+
DoneEventSchema,
|
|
38
|
+
ErrorEventSchema,
|
|
39
|
+
]);
|
|
40
|
+
// Rebuilding (never re-parsing) drops the wire's `type` key; a re-parse
|
|
41
|
+
// against an internal schema would start throwing if that schema gained a
|
|
42
|
+
// required field the wire arm defaults.
|
|
43
|
+
const wireEventToParsed = (event) => {
|
|
44
|
+
if (event.type === "ready") {
|
|
45
|
+
const { type: _type, ...ready } = event;
|
|
46
|
+
return { tag: "ready", ready };
|
|
47
|
+
}
|
|
48
|
+
if (event.type === "interrupt") {
|
|
49
|
+
const { type: _type, ...interrupt } = event;
|
|
50
|
+
return { tag: "interrupt", interrupt };
|
|
51
|
+
}
|
|
52
|
+
if (event.type === "progress") {
|
|
53
|
+
const { type: _type, ...progress } = event;
|
|
54
|
+
return { tag: "progress", progress };
|
|
55
|
+
}
|
|
56
|
+
if (event.type === "done") {
|
|
57
|
+
return { tag: "done", done: { exitReason: "done", summary: event.summary } };
|
|
58
|
+
}
|
|
59
|
+
return { tag: "error", error: { exitReason: event.exitReason, reason: event.reason } };
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Parse a single line from a `lux-jsonl` agent. Returns null for empty
|
|
63
|
+
* lines, malformed JSON, or events that don't match the wire schema.
|
|
64
|
+
* Validation failures are silent by design — drivers may interleave
|
|
65
|
+
* non-protocol log lines on stdout.
|
|
66
|
+
*/
|
|
67
|
+
export const parseWireEvent = (line) => {
|
|
68
|
+
const trimmed = line.trim();
|
|
69
|
+
if (!trimmed)
|
|
70
|
+
return null;
|
|
71
|
+
let raw;
|
|
72
|
+
try {
|
|
73
|
+
raw = JSON.parse(trimmed);
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
const parsed = WireEventSchema.safeParse(raw);
|
|
79
|
+
if (!parsed.success)
|
|
80
|
+
return null;
|
|
81
|
+
return wireEventToParsed(parsed.data);
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* Serialize an Answer to a `lux-jsonl` line (newline-terminated). The
|
|
85
|
+
* inverse of an agent reading its stdin and dispatching to whatever
|
|
86
|
+
* pending interrupt the answer is for.
|
|
87
|
+
*/
|
|
88
|
+
export const formatWireAnswer = (answer) => {
|
|
89
|
+
let message;
|
|
90
|
+
if (answer.kind === "ask") {
|
|
91
|
+
message = { type: "answer", id: answer.id, text: answer.text };
|
|
92
|
+
}
|
|
93
|
+
else if (answer.kind === "approve") {
|
|
94
|
+
message = { type: answer.approved ? "approve" : "deny", id: answer.id, reason: answer.reason };
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
message = { type: "customToolResponse", id: answer.id, payload: answer.payload };
|
|
98
|
+
}
|
|
99
|
+
return `${JSON.stringify(message)}\n`;
|
|
100
|
+
};
|
|
101
|
+
//# sourceMappingURL=wire.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wire.js","sourceRoot":"","sources":["../../src/core/wire.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAEL,sBAAsB,EACtB,kBAAkB,EAClB,qBAAqB,EAGrB,sBAAsB,EAGtB,cAAc,EAEd,gBAAgB,GACjB,MAAM,aAAa,CAAC;AAErB;;;;;;;;;;GAUG;AACH,MAAM,gBAAgB,GAAG,gBAAgB,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;AAE/E,MAAM,oBAAoB,GAAG,CAAC,CAAC,kBAAkB,CAAC,MAAM,EAAE;IACxD,kBAAkB,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC;IAC3D,sBAAsB,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC;IAC/D,qBAAqB,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC;CAC/D,CAAC,CAAC;AAEH,MAAM,mBAAmB,GAAG,cAAc,CAAC,MAAM,CAAC;IAChD,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC;IAC3B,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,OA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AAQ,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC;IACjE,CAAC;SAAM,IAAI,MAAM,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QACrC,OAAO,GAAG,EAAE,IAAI,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC;IACjG,CAAC;SAAM,CAAC;QACN,OAAO,GAAG,EAAE,IAAI,EAAE,oBAAoB,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC;IACnF,CAAC;IACD,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC;AACxC,CAAC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Render a failed parse's issues as one `path: message; path: message` line.
|
|
4
|
+
* The one place that decides how Lux surfaces schema errors, so every
|
|
5
|
+
* `Invalid …: <issues>` message the loaders and validators throw reads the
|
|
6
|
+
* same. `<root>` stands in for an issue at the top level (empty path).
|
|
7
|
+
*/
|
|
8
|
+
export declare const formatZodIssues: (error: z.ZodError) => string;
|
|
9
|
+
export declare const tryParseJson: (text: string) => unknown;
|
|
10
|
+
//# sourceMappingURL=zod.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zod.d.ts","sourceRoot":"","sources":["../../src/core/zod.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAE7B;;;;;GAKG;AACH,eAAO,MAAM,eAAe,UAAW,CAAC,CAAC,QAAQ,KAAG,MACiC,CAAC;AAItF,eAAO,MAAM,YAAY,SAAU,MAAM,KAAG,OAM3C,CAAC"}
|