@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,464 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import {
|
|
3
|
+
type Interrupt,
|
|
4
|
+
type ParsedDriverEvent,
|
|
5
|
+
parseAgentUsage,
|
|
6
|
+
type TokenUsage,
|
|
7
|
+
TURN_GLYPHS,
|
|
8
|
+
toolResultProgress,
|
|
9
|
+
} from "../../core/index.js";
|
|
10
|
+
|
|
11
|
+
const ContentBlockSchema = z.discriminatedUnion("type", [
|
|
12
|
+
z.object({ type: z.literal("text"), text: z.string() }),
|
|
13
|
+
z.object({ type: z.literal("tool_use"), id: z.string(), name: z.string(), input: z.unknown() }),
|
|
14
|
+
z.object({ type: z.literal("thinking"), thinking: z.exactOptional(z.string()) }),
|
|
15
|
+
]);
|
|
16
|
+
|
|
17
|
+
// Unmodeled block/line types are skipped, not fatal.
|
|
18
|
+
export const ClaudeCodeLineSchema = z.discriminatedUnion("type", [
|
|
19
|
+
z.object({
|
|
20
|
+
type: z.literal("system"),
|
|
21
|
+
subtype: z.literal("init"),
|
|
22
|
+
model: z.string().optional().catch(undefined),
|
|
23
|
+
session_id: z.string().optional().catch(undefined),
|
|
24
|
+
}),
|
|
25
|
+
z.object({
|
|
26
|
+
type: z.literal("user"),
|
|
27
|
+
message: z.object({ content: z.array(z.unknown()).catch([]) }),
|
|
28
|
+
parent_tool_use_id: z.string().optional().catch(undefined),
|
|
29
|
+
}),
|
|
30
|
+
z.object({
|
|
31
|
+
type: z.literal("assistant"),
|
|
32
|
+
message: z.object({
|
|
33
|
+
id: z.string().optional().catch(undefined),
|
|
34
|
+
content: z.array(z.unknown()).catch([]),
|
|
35
|
+
usage: z.unknown().optional(),
|
|
36
|
+
}),
|
|
37
|
+
parent_tool_use_id: z.string().optional().catch(undefined),
|
|
38
|
+
}),
|
|
39
|
+
z.object({
|
|
40
|
+
type: z.literal("result"),
|
|
41
|
+
subtype: z.string().optional().catch(undefined),
|
|
42
|
+
is_error: z.boolean().optional().catch(undefined),
|
|
43
|
+
result: z.unknown().optional(),
|
|
44
|
+
usage: z.unknown().optional(),
|
|
45
|
+
session_id: z.string().optional().catch(undefined),
|
|
46
|
+
total_cost_usd: z.unknown().optional(),
|
|
47
|
+
duration_ms: z.unknown().optional(),
|
|
48
|
+
num_turns: z.number().optional().catch(undefined),
|
|
49
|
+
stop_reason: z.string().optional().catch(undefined),
|
|
50
|
+
deferred_tool_use: z
|
|
51
|
+
.object({
|
|
52
|
+
id: z.string(),
|
|
53
|
+
name: z.string(),
|
|
54
|
+
input: z.unknown(),
|
|
55
|
+
})
|
|
56
|
+
.optional()
|
|
57
|
+
.catch(undefined),
|
|
58
|
+
}),
|
|
59
|
+
]);
|
|
60
|
+
|
|
61
|
+
// Loose so the option/header fields `context` forwards to the answerer survive.
|
|
62
|
+
const AskToolInputSchema = z.looseObject({
|
|
63
|
+
question: z.unknown().optional(),
|
|
64
|
+
questions: z.array(z.unknown()).optional().catch(undefined),
|
|
65
|
+
message: z.unknown().optional(),
|
|
66
|
+
text: z.unknown().optional(),
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
const AskToolQuestionSchema = z.looseObject({ question: z.string() });
|
|
70
|
+
|
|
71
|
+
type ClaudeCodeLine = z.infer<typeof ClaudeCodeLineSchema>;
|
|
72
|
+
type SystemLine = Extract<ClaudeCodeLine, { type: "system" }>;
|
|
73
|
+
type UserLine = Extract<ClaudeCodeLine, { type: "user" }>;
|
|
74
|
+
type AssistantLine = Extract<ClaudeCodeLine, { type: "assistant" }>;
|
|
75
|
+
type ResultLine = Extract<ClaudeCodeLine, { type: "result" }>;
|
|
76
|
+
type ContentBlock = z.infer<typeof ContentBlockSchema>;
|
|
77
|
+
type ParserOutput = ParsedDriverEvent | ParsedDriverEvent[] | null;
|
|
78
|
+
|
|
79
|
+
type ParserConfig = {
|
|
80
|
+
askToolName: string;
|
|
81
|
+
interactionMode: "defer-resume" | "stream-json";
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
type PendingTurn = {
|
|
85
|
+
id: string;
|
|
86
|
+
usage: TokenUsage;
|
|
87
|
+
tools: string[];
|
|
88
|
+
asked: boolean;
|
|
89
|
+
thought: boolean;
|
|
90
|
+
text?: string;
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
type AssistantContent = {
|
|
94
|
+
events: ParsedDriverEvent[];
|
|
95
|
+
tools: string[];
|
|
96
|
+
asked: boolean;
|
|
97
|
+
thought: boolean;
|
|
98
|
+
firstText?: string;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
const questionTextOf = (raw: unknown): string =>
|
|
102
|
+
AskToolQuestionSchema.safeParse(raw).data?.question ?? "";
|
|
103
|
+
|
|
104
|
+
/** Build an `ask` interrupt from the configured deferred user-message tool. */
|
|
105
|
+
const parseAskInterrupt = (block: { id: string; input: unknown }): Interrupt => {
|
|
106
|
+
const input = AskToolInputSchema.safeParse(block.input).data;
|
|
107
|
+
const questions = input?.questions ?? null;
|
|
108
|
+
let question: string;
|
|
109
|
+
if (questions) {
|
|
110
|
+
question = questions.map(questionTextOf).filter(Boolean).join("\n");
|
|
111
|
+
} else if (typeof input?.question === "string") {
|
|
112
|
+
question = input.question;
|
|
113
|
+
} else if (typeof input?.message === "string") {
|
|
114
|
+
question = input.message;
|
|
115
|
+
} else if (typeof input?.text === "string") {
|
|
116
|
+
question = input.text;
|
|
117
|
+
} else if (typeof block.input === "string") {
|
|
118
|
+
question = block.input;
|
|
119
|
+
} else {
|
|
120
|
+
question = JSON.stringify(block.input);
|
|
121
|
+
}
|
|
122
|
+
return {
|
|
123
|
+
kind: "ask",
|
|
124
|
+
id: block.id,
|
|
125
|
+
question,
|
|
126
|
+
context: { toolUseId: block.id, ...(questions ? { questions } : {}) },
|
|
127
|
+
};
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
// A glyph badge of every facet the call exercised, then its most telling
|
|
131
|
+
// detail — the tools it ran or a snippet of its reply.
|
|
132
|
+
const turnLabel = (turn: PendingTurn): string | undefined => {
|
|
133
|
+
const badge =
|
|
134
|
+
(turn.thought ? TURN_GLYPHS.thinking : "") +
|
|
135
|
+
(turn.asked ? TURN_GLYPHS.ask : "") +
|
|
136
|
+
(turn.tools.length > 0 ? TURN_GLYPHS.tool : "") +
|
|
137
|
+
(turn.text ? TURN_GLYPHS.reply : "");
|
|
138
|
+
if (!badge) return undefined;
|
|
139
|
+
const detail =
|
|
140
|
+
turn.tools.length > 0
|
|
141
|
+
? turn.tools.join(", ")
|
|
142
|
+
: turn.text?.replace(/\s+/g, " ").trim().slice(0, 120);
|
|
143
|
+
return detail ? `${badge} ${detail}` : badge;
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
const collapseEvents = (events: ParsedDriverEvent[]): ParserOutput => {
|
|
147
|
+
if (events.length === 0) return null;
|
|
148
|
+
return events.length === 1 ? (events[0] ?? null) : events;
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
const toolResultText = (content: unknown): string => {
|
|
152
|
+
if (typeof content === "string") return content;
|
|
153
|
+
if (!Array.isArray(content)) return JSON.stringify(content);
|
|
154
|
+
return content
|
|
155
|
+
.filter(
|
|
156
|
+
(part): part is { type: "text"; text: string } =>
|
|
157
|
+
typeof part === "object" &&
|
|
158
|
+
part !== null &&
|
|
159
|
+
(part as { type?: unknown }).type === "text" &&
|
|
160
|
+
typeof (part as { text?: unknown }).text === "string",
|
|
161
|
+
)
|
|
162
|
+
.map((part) => part.text)
|
|
163
|
+
.join("\n");
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
const toolInfrastructureFailure = (text: string): string | null =>
|
|
167
|
+
/Could not start .+E2BIG[\s\S]+sandbox profile/i.test(text)
|
|
168
|
+
? `Claude Code could not start a sandboxed tool process: ${text}`
|
|
169
|
+
: null;
|
|
170
|
+
|
|
171
|
+
class ClaudeEventParser {
|
|
172
|
+
private eventSequence = 0;
|
|
173
|
+
private pendingTurn: PendingTurn | null = null;
|
|
174
|
+
private readonly toolNames = new Map<string, string>();
|
|
175
|
+
private readonly config: ParserConfig;
|
|
176
|
+
private readonly cliVersion: string | undefined;
|
|
177
|
+
|
|
178
|
+
constructor(config: ParserConfig, cliVersion?: string) {
|
|
179
|
+
this.config = config;
|
|
180
|
+
this.cliVersion = cliVersion;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
readonly parse = (line: string): ParserOutput => {
|
|
184
|
+
const event = this.parseLine(line);
|
|
185
|
+
if (!event) return null;
|
|
186
|
+
|
|
187
|
+
switch (event.type) {
|
|
188
|
+
case "system":
|
|
189
|
+
return this.readyEvent(event);
|
|
190
|
+
case "user":
|
|
191
|
+
return this.userEvents(event);
|
|
192
|
+
case "assistant":
|
|
193
|
+
return this.assistantEvents(event);
|
|
194
|
+
case "result":
|
|
195
|
+
return this.resultEvents(event);
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
private parseLine(line: string): ClaudeCodeLine | null {
|
|
200
|
+
try {
|
|
201
|
+
return ClaudeCodeLineSchema.safeParse(JSON.parse(line)).data ?? null;
|
|
202
|
+
} catch {
|
|
203
|
+
return null;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
private readyEvent(event: SystemLine): ParsedDriverEvent {
|
|
208
|
+
return {
|
|
209
|
+
tag: "ready",
|
|
210
|
+
ready: {
|
|
211
|
+
agentId: "claude-code",
|
|
212
|
+
...(event.model !== undefined ? { model: event.model } : {}),
|
|
213
|
+
detail: {
|
|
214
|
+
sessionId: event.session_id,
|
|
215
|
+
...(this.cliVersion ? { cliVersion: this.cliVersion } : {}),
|
|
216
|
+
},
|
|
217
|
+
},
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
private userEvents(event: UserLine): ParserOutput {
|
|
222
|
+
const events: ParsedDriverEvent[] = [];
|
|
223
|
+
for (const rawBlock of event.message.content) {
|
|
224
|
+
const block = this.toolResultBlock(rawBlock, event.parent_tool_use_id);
|
|
225
|
+
if (!block) continue;
|
|
226
|
+
events.push(block);
|
|
227
|
+
if (block.tag !== "progress") continue;
|
|
228
|
+
const text = (block.progress.payload as { text?: unknown }).text;
|
|
229
|
+
const failure = typeof text === "string" ? toolInfrastructureFailure(text) : null;
|
|
230
|
+
if (failure) {
|
|
231
|
+
events.push({
|
|
232
|
+
tag: "error",
|
|
233
|
+
error: { exitReason: "error", reason: failure },
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
return collapseEvents(events);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
private toolResultBlock(rawBlock: unknown, parentToolUseId?: string): ParsedDriverEvent | null {
|
|
241
|
+
if (!rawBlock || typeof rawBlock !== "object") return null;
|
|
242
|
+
const block = rawBlock as Record<string, unknown>;
|
|
243
|
+
if (block.type !== "tool_result" || typeof block.tool_use_id !== "string") return null;
|
|
244
|
+
|
|
245
|
+
const toolUseId = block.tool_use_id;
|
|
246
|
+
const content = block.content ?? [];
|
|
247
|
+
return {
|
|
248
|
+
tag: "progress",
|
|
249
|
+
progress: toolResultProgress(
|
|
250
|
+
this.eventSequence++,
|
|
251
|
+
{
|
|
252
|
+
name: this.toolNames.get(toolUseId) ?? "unknown",
|
|
253
|
+
toolUseId,
|
|
254
|
+
content,
|
|
255
|
+
isError: block.is_error === true,
|
|
256
|
+
text: toolResultText(content),
|
|
257
|
+
...(parentToolUseId ? { parentToolUseId } : {}),
|
|
258
|
+
},
|
|
259
|
+
Date.now(),
|
|
260
|
+
),
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
private assistantEvents(event: AssistantLine): ParserOutput {
|
|
265
|
+
const events: ParsedDriverEvent[] = [];
|
|
266
|
+
const id = event.message.id;
|
|
267
|
+
this.flushPreviousTurn(id, events);
|
|
268
|
+
|
|
269
|
+
const content = this.assistantContent(event);
|
|
270
|
+
events.push(...content.events);
|
|
271
|
+
this.recordTurn(id, parseAgentUsage(event.message.usage), content, events);
|
|
272
|
+
return collapseEvents(events);
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
private flushPreviousTurn(id: string | undefined, events: ParsedDriverEvent[]): void {
|
|
276
|
+
if (!id || !this.pendingTurn || this.pendingTurn.id === id) return;
|
|
277
|
+
const flushed = this.flushTurn();
|
|
278
|
+
if (flushed) events.push(flushed);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
private assistantContent(event: AssistantLine): AssistantContent {
|
|
282
|
+
const content: AssistantContent = {
|
|
283
|
+
events: [],
|
|
284
|
+
tools: [],
|
|
285
|
+
asked: false,
|
|
286
|
+
thought: false,
|
|
287
|
+
};
|
|
288
|
+
for (const rawBlock of event.message.content) {
|
|
289
|
+
const block = ContentBlockSchema.safeParse(rawBlock).data;
|
|
290
|
+
if (block) this.recordContentBlock(block, event.parent_tool_use_id, content);
|
|
291
|
+
}
|
|
292
|
+
return content;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
private recordContentBlock(
|
|
296
|
+
block: ContentBlock,
|
|
297
|
+
parentToolUseId: string | undefined,
|
|
298
|
+
content: AssistantContent,
|
|
299
|
+
): void {
|
|
300
|
+
switch (block.type) {
|
|
301
|
+
case "thinking":
|
|
302
|
+
content.thought = true;
|
|
303
|
+
return;
|
|
304
|
+
case "text":
|
|
305
|
+
this.recordAgentMessage(block.text, parentToolUseId, content);
|
|
306
|
+
return;
|
|
307
|
+
case "tool_use":
|
|
308
|
+
this.recordToolUse(block, parentToolUseId, content);
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
private recordAgentMessage(
|
|
313
|
+
text: string,
|
|
314
|
+
parentToolUseId: string | undefined,
|
|
315
|
+
content: AssistantContent,
|
|
316
|
+
): void {
|
|
317
|
+
if (!text) return;
|
|
318
|
+
content.firstText ??= text;
|
|
319
|
+
content.events.push({
|
|
320
|
+
tag: "progress",
|
|
321
|
+
progress: {
|
|
322
|
+
id: `am-${this.eventSequence++}`,
|
|
323
|
+
kind: "agent-message",
|
|
324
|
+
payload: { text, ...(parentToolUseId ? { parentToolUseId } : {}) },
|
|
325
|
+
ts: Date.now(),
|
|
326
|
+
},
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
private recordToolUse(
|
|
331
|
+
block: Extract<ContentBlock, { type: "tool_use" }>,
|
|
332
|
+
parentToolUseId: string | undefined,
|
|
333
|
+
content: AssistantContent,
|
|
334
|
+
): void {
|
|
335
|
+
if (block.name === this.config.askToolName) {
|
|
336
|
+
content.asked = true;
|
|
337
|
+
if (this.config.interactionMode === "stream-json") {
|
|
338
|
+
content.events.push({ tag: "interrupt", interrupt: parseAskInterrupt(block) });
|
|
339
|
+
}
|
|
340
|
+
return;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
this.toolNames.set(block.id, block.name);
|
|
344
|
+
if (!content.tools.includes(block.name)) content.tools.push(block.name);
|
|
345
|
+
content.events.push({
|
|
346
|
+
tag: "progress",
|
|
347
|
+
progress: {
|
|
348
|
+
id: `tc-${block.id}`,
|
|
349
|
+
kind: "tool-call",
|
|
350
|
+
payload: {
|
|
351
|
+
name: block.name,
|
|
352
|
+
input: block.input,
|
|
353
|
+
toolUseId: block.id,
|
|
354
|
+
...(parentToolUseId ? { parentToolUseId } : {}),
|
|
355
|
+
},
|
|
356
|
+
ts: Date.now(),
|
|
357
|
+
},
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
private recordTurn(
|
|
362
|
+
id: string | undefined,
|
|
363
|
+
usage: TokenUsage | null,
|
|
364
|
+
content: AssistantContent,
|
|
365
|
+
events: ParsedDriverEvent[],
|
|
366
|
+
): void {
|
|
367
|
+
if (!usage) return;
|
|
368
|
+
if (!id && this.pendingTurn) {
|
|
369
|
+
const flushed = this.flushTurn();
|
|
370
|
+
if (flushed) events.push(flushed);
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
this.pendingTurn ??= {
|
|
374
|
+
id: id ?? "",
|
|
375
|
+
usage,
|
|
376
|
+
tools: [],
|
|
377
|
+
asked: false,
|
|
378
|
+
thought: false,
|
|
379
|
+
};
|
|
380
|
+
this.pendingTurn.usage = usage;
|
|
381
|
+
this.pendingTurn.asked ||= content.asked;
|
|
382
|
+
this.pendingTurn.thought ||= content.thought;
|
|
383
|
+
for (const tool of content.tools) {
|
|
384
|
+
if (!this.pendingTurn.tools.includes(tool)) this.pendingTurn.tools.push(tool);
|
|
385
|
+
}
|
|
386
|
+
if (content.firstText && this.pendingTurn.text === undefined) {
|
|
387
|
+
this.pendingTurn.text = content.firstText;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
if (!id) {
|
|
391
|
+
const flushed = this.flushTurn();
|
|
392
|
+
if (flushed) events.push(flushed);
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
private resultEvents(event: ResultLine): ParserOutput {
|
|
397
|
+
if (event.stop_reason === "tool_deferred" && event.deferred_tool_use) {
|
|
398
|
+
return this.withPendingUsage({
|
|
399
|
+
tag: "interrupt",
|
|
400
|
+
interrupt: this.deferredInterrupt(event.deferred_tool_use),
|
|
401
|
+
});
|
|
402
|
+
}
|
|
403
|
+
if (event.is_error === true || event.subtype?.startsWith("error")) {
|
|
404
|
+
return this.withPendingUsage({
|
|
405
|
+
tag: "error",
|
|
406
|
+
error: {
|
|
407
|
+
exitReason: "error",
|
|
408
|
+
reason: typeof event.result === "string" ? event.result : "claude reported error",
|
|
409
|
+
},
|
|
410
|
+
});
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
const usage = parseAgentUsage(event.usage);
|
|
414
|
+
return this.withPendingUsage({
|
|
415
|
+
tag: "done",
|
|
416
|
+
done: {
|
|
417
|
+
exitReason: "done",
|
|
418
|
+
summary: {
|
|
419
|
+
sessionId: event.session_id,
|
|
420
|
+
cost: event.total_cost_usd,
|
|
421
|
+
durationMs: event.duration_ms,
|
|
422
|
+
...(event.num_turns !== undefined ? { numTurns: event.num_turns } : {}),
|
|
423
|
+
...(usage ? { usage } : {}),
|
|
424
|
+
},
|
|
425
|
+
},
|
|
426
|
+
});
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
private deferredInterrupt(deferred: NonNullable<ResultLine["deferred_tool_use"]>): Interrupt {
|
|
430
|
+
if (deferred.name === this.config.askToolName) return parseAskInterrupt(deferred);
|
|
431
|
+
return {
|
|
432
|
+
kind: "custom",
|
|
433
|
+
id: deferred.id,
|
|
434
|
+
payload: deferred.input,
|
|
435
|
+
context: { toolUseId: deferred.id, toolName: deferred.name },
|
|
436
|
+
};
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
private withPendingUsage(event: ParsedDriverEvent): ParsedDriverEvent | ParsedDriverEvent[] {
|
|
440
|
+
const usage = this.flushTurn();
|
|
441
|
+
return usage ? [usage, event] : event;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
private flushTurn(): ParsedDriverEvent | null {
|
|
445
|
+
if (!this.pendingTurn) return null;
|
|
446
|
+
const label = turnLabel(this.pendingTurn);
|
|
447
|
+
const event: ParsedDriverEvent = {
|
|
448
|
+
tag: "progress",
|
|
449
|
+
progress: {
|
|
450
|
+
id: `usage-${this.eventSequence++}`,
|
|
451
|
+
kind: "usage",
|
|
452
|
+
payload: { ...this.pendingTurn.usage, ...(label ? { label } : {}) },
|
|
453
|
+
ts: Date.now(),
|
|
454
|
+
},
|
|
455
|
+
};
|
|
456
|
+
this.pendingTurn = null;
|
|
457
|
+
return event;
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
export const makeParseEvent = (
|
|
462
|
+
config: ParserConfig,
|
|
463
|
+
cliVersion?: string,
|
|
464
|
+
): ((line: string) => ParserOutput) => new ClaudeEventParser(config, cliVersion).parse;
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type ParsedDriverEvent,
|
|
3
|
+
type TokenUsage,
|
|
4
|
+
TURN_GLYPHS,
|
|
5
|
+
toolResultProgress,
|
|
6
|
+
} from "../../core/index.js";
|
|
7
|
+
|
|
8
|
+
const resultText = (content: unknown): string => {
|
|
9
|
+
if (typeof content === "string") return content;
|
|
10
|
+
if (!Array.isArray(content)) return "";
|
|
11
|
+
return content
|
|
12
|
+
.filter(
|
|
13
|
+
(block): block is { type: "text"; text: string } =>
|
|
14
|
+
typeof block === "object" &&
|
|
15
|
+
block !== null &&
|
|
16
|
+
(block as { type?: unknown }).type === "text" &&
|
|
17
|
+
typeof (block as { text?: unknown }).text === "string",
|
|
18
|
+
)
|
|
19
|
+
.map((block) => block.text)
|
|
20
|
+
.join("\n");
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export type RpcId = string | number;
|
|
24
|
+
export type RpcRecord = Record<string, unknown>;
|
|
25
|
+
export type AppTurnFacets = {
|
|
26
|
+
tools: string[];
|
|
27
|
+
asked: boolean;
|
|
28
|
+
thought: boolean;
|
|
29
|
+
text?: string;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export const asRecord = (value: unknown): RpcRecord | null =>
|
|
33
|
+
typeof value === "object" && value !== null && !Array.isArray(value)
|
|
34
|
+
? (value as RpcRecord)
|
|
35
|
+
: null;
|
|
36
|
+
export const messageOf = (error: unknown): string =>
|
|
37
|
+
error instanceof Error ? error.message : String(error);
|
|
38
|
+
|
|
39
|
+
export const appTurnLabel = (facets: AppTurnFacets | undefined): string | undefined => {
|
|
40
|
+
if (!facets) return undefined;
|
|
41
|
+
const badge =
|
|
42
|
+
(facets.thought ? TURN_GLYPHS.thinking : "") +
|
|
43
|
+
(facets.asked ? TURN_GLYPHS.ask : "") +
|
|
44
|
+
(facets.tools.length > 0 ? TURN_GLYPHS.tool : "") +
|
|
45
|
+
(facets.text ? TURN_GLYPHS.reply : "");
|
|
46
|
+
if (!badge) return undefined;
|
|
47
|
+
const detail =
|
|
48
|
+
facets.tools.length > 0
|
|
49
|
+
? facets.tools.join(", ")
|
|
50
|
+
: facets.text?.replace(/\s+/g, " ").trim().slice(0, 120);
|
|
51
|
+
return detail ? `${badge} ${detail}` : badge;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export const appUsage = (raw: unknown): TokenUsage | null => {
|
|
55
|
+
const value = asRecord(raw);
|
|
56
|
+
if (!value) return null;
|
|
57
|
+
const input = typeof value.inputTokens === "number" ? value.inputTokens : 0;
|
|
58
|
+
const cached = typeof value.cachedInputTokens === "number" ? value.cachedInputTokens : 0;
|
|
59
|
+
const output = typeof value.outputTokens === "number" ? value.outputTokens : 0;
|
|
60
|
+
const cacheCreation =
|
|
61
|
+
typeof value.cacheWriteInputTokens === "number" ? value.cacheWriteInputTokens : 0;
|
|
62
|
+
return {
|
|
63
|
+
input: Math.max(0, input - cached),
|
|
64
|
+
output,
|
|
65
|
+
cacheRead: cached,
|
|
66
|
+
cacheCreation,
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export const appItemToolName = (item: RpcRecord): string | null => {
|
|
71
|
+
switch (item.type) {
|
|
72
|
+
case "commandExecution":
|
|
73
|
+
return "command_execution";
|
|
74
|
+
case "fileChange":
|
|
75
|
+
return "file_change";
|
|
76
|
+
case "webSearch":
|
|
77
|
+
return "web_search";
|
|
78
|
+
case "mcpToolCall":
|
|
79
|
+
case "dynamicToolCall":
|
|
80
|
+
return String(item.tool ?? item.type);
|
|
81
|
+
case "collabAgentToolCall":
|
|
82
|
+
return String(item.tool ?? "collab_agent");
|
|
83
|
+
default:
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
const appItemInput = (item: RpcRecord): unknown => {
|
|
89
|
+
switch (item.type) {
|
|
90
|
+
case "commandExecution":
|
|
91
|
+
return { command: item.command, cwd: item.cwd };
|
|
92
|
+
case "fileChange":
|
|
93
|
+
return { changes: item.changes };
|
|
94
|
+
case "webSearch":
|
|
95
|
+
return { query: item.query };
|
|
96
|
+
case "collabAgentToolCall":
|
|
97
|
+
return {
|
|
98
|
+
prompt: item.prompt,
|
|
99
|
+
model: item.model,
|
|
100
|
+
reasoningEffort: item.reasoningEffort,
|
|
101
|
+
receiverThreadIds: item.receiverThreadIds,
|
|
102
|
+
};
|
|
103
|
+
default:
|
|
104
|
+
return item.arguments;
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
const appItemContent = (item: RpcRecord, result: RpcRecord | null): unknown => {
|
|
109
|
+
switch (item.type) {
|
|
110
|
+
case "commandExecution":
|
|
111
|
+
return { output: item.aggregatedOutput ?? "", exitCode: item.exitCode };
|
|
112
|
+
case "fileChange":
|
|
113
|
+
return { changes: item.changes, status: item.status };
|
|
114
|
+
case "webSearch":
|
|
115
|
+
return { query: item.query, results: item.results };
|
|
116
|
+
case "dynamicToolCall":
|
|
117
|
+
return item.contentItems;
|
|
118
|
+
case "collabAgentToolCall":
|
|
119
|
+
return { receiverThreadIds: item.receiverThreadIds, agentsStates: item.agentsStates };
|
|
120
|
+
default:
|
|
121
|
+
return result?.content ?? [];
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
const appItemResultText = (item: RpcRecord, error: RpcRecord | null, content: unknown): string => {
|
|
126
|
+
if (typeof item.aggregatedOutput === "string") return item.aggregatedOutput;
|
|
127
|
+
if (typeof error?.message === "string") return error.message;
|
|
128
|
+
return resultText(content);
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
export const appItemProgress = (
|
|
132
|
+
item: RpcRecord,
|
|
133
|
+
phase: "started" | "completed",
|
|
134
|
+
parentToolUseId?: string,
|
|
135
|
+
): ParsedDriverEvent | null => {
|
|
136
|
+
const id = typeof item.id === "string" ? item.id : `${String(item.type)}-${Date.now()}`;
|
|
137
|
+
if (item.type === "agentMessage" && phase === "completed" && typeof item.text === "string") {
|
|
138
|
+
return {
|
|
139
|
+
tag: "progress",
|
|
140
|
+
progress: {
|
|
141
|
+
id: `am-${id}`,
|
|
142
|
+
kind: "agent-message",
|
|
143
|
+
payload: { text: item.text, ...(parentToolUseId ? { parentToolUseId } : {}) },
|
|
144
|
+
ts: Date.now(),
|
|
145
|
+
},
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
if (item.type === "reasoning" && phase === "completed") {
|
|
149
|
+
const summary = Array.isArray(item.summary)
|
|
150
|
+
? item.summary.filter((part): part is string => typeof part === "string").join("\n")
|
|
151
|
+
: "";
|
|
152
|
+
const content = Array.isArray(item.content)
|
|
153
|
+
? item.content.filter((part): part is string => typeof part === "string").join("\n")
|
|
154
|
+
: "";
|
|
155
|
+
return {
|
|
156
|
+
tag: "progress",
|
|
157
|
+
progress: {
|
|
158
|
+
id: `reasoning-${id}`,
|
|
159
|
+
kind: "reasoning",
|
|
160
|
+
payload: {
|
|
161
|
+
text: summary || content,
|
|
162
|
+
...(parentToolUseId ? { parentToolUseId } : {}),
|
|
163
|
+
},
|
|
164
|
+
ts: Date.now(),
|
|
165
|
+
},
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
const tool = appItemToolName(item);
|
|
170
|
+
if (!tool) return null;
|
|
171
|
+
|
|
172
|
+
if (phase === "started") {
|
|
173
|
+
const input = appItemInput(item);
|
|
174
|
+
return {
|
|
175
|
+
tag: "progress",
|
|
176
|
+
progress: {
|
|
177
|
+
id: `tc-${id}`,
|
|
178
|
+
kind: "tool-call",
|
|
179
|
+
payload: {
|
|
180
|
+
name: tool,
|
|
181
|
+
input,
|
|
182
|
+
toolUseId: id,
|
|
183
|
+
...(typeof item.server === "string" ? { server: item.server } : {}),
|
|
184
|
+
...(parentToolUseId ? { parentToolUseId } : {}),
|
|
185
|
+
},
|
|
186
|
+
ts: Date.now(),
|
|
187
|
+
},
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
const result = asRecord(item.result);
|
|
192
|
+
const content = appItemContent(item, result);
|
|
193
|
+
const structuredContent = result?.structuredContent;
|
|
194
|
+
const error = asRecord(item.error);
|
|
195
|
+
const isError =
|
|
196
|
+
item.status === "failed" ||
|
|
197
|
+
item.success === false ||
|
|
198
|
+
(typeof item.exitCode === "number" && item.exitCode !== 0) ||
|
|
199
|
+
error !== null;
|
|
200
|
+
return {
|
|
201
|
+
tag: "progress",
|
|
202
|
+
progress: toolResultProgress(
|
|
203
|
+
0,
|
|
204
|
+
{
|
|
205
|
+
name: tool,
|
|
206
|
+
toolUseId: id,
|
|
207
|
+
content,
|
|
208
|
+
...(asRecord(structuredContent)
|
|
209
|
+
? { structuredContent: asRecord(structuredContent) ?? {} }
|
|
210
|
+
: {}),
|
|
211
|
+
isError,
|
|
212
|
+
text: appItemResultText(item, error, content),
|
|
213
|
+
...(parentToolUseId ? { parentToolUseId } : {}),
|
|
214
|
+
},
|
|
215
|
+
Date.now(),
|
|
216
|
+
),
|
|
217
|
+
};
|
|
218
|
+
};
|