@kontourai/flow-agents 3.12.0 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/ci.yml +76 -0
- package/CHANGELOG.md +48 -0
- package/build/generated/capability-declarations.json +177 -0
- package/build/src/builder-flow-runtime.d.ts +37 -0
- package/build/src/builder-flow-runtime.js +71 -1
- package/build/src/builder-gate-action-envelope.d.ts +59 -7
- package/build/src/builder-gate-action-envelope.js +163 -30
- package/build/src/builder-lifecycle-authority.d.ts +26 -0
- package/build/src/builder-lifecycle-authority.js +38 -0
- package/build/src/cli/builder-run.js +71 -2
- package/build/src/cli/narrative-render.d.ts +95 -0
- package/build/src/cli/narrative-render.js +466 -0
- package/build/src/cli/narrative-sources.d.ts +2 -0
- package/build/src/cli/narrative-sources.js +282 -0
- package/build/src/cli/public-contracts.d.ts +257 -0
- package/build/src/cli/public-contracts.js +87 -0
- package/build/src/cli/workflow-sidecar.d.ts +28 -12
- package/build/src/cli/workflow-sidecar.js +599 -180
- package/build/src/cli/workflow.js +11 -1
- package/build/src/cli.js +8 -0
- package/build/src/continuation-driver.d.ts +12 -0
- package/build/src/continuation-driver.js +16 -2
- package/build/src/continuation-validation.js +349 -3
- package/build/src/flow-kit/action-metadata.js +21 -1
- package/build/src/index.d.ts +33 -2
- package/build/src/index.js +24 -0
- package/build/src/lib/capability-declarations.d.ts +83 -0
- package/build/src/lib/capability-declarations.js +209 -0
- package/build/src/narrative/envelope.d.ts +111 -0
- package/build/src/narrative/envelope.js +590 -0
- package/build/src/narrative/eval-result.d.ts +60 -0
- package/build/src/narrative/eval-result.js +158 -0
- package/build/src/narrative/grounding-validator.d.ts +104 -0
- package/build/src/narrative/grounding-validator.js +472 -0
- package/build/src/narrative/integrity.d.ts +17 -0
- package/build/src/narrative/integrity.js +39 -0
- package/build/src/narrative/intent-economics.d.ts +42 -0
- package/build/src/narrative/intent-economics.js +82 -0
- package/build/src/narrative/intent.d.ts +94 -0
- package/build/src/narrative/intent.js +132 -0
- package/build/src/narrative/policy-filter.d.ts +15 -0
- package/build/src/narrative/policy-filter.js +58 -0
- package/build/src/narrative/projection.d.ts +58 -0
- package/build/src/narrative/projection.js +502 -0
- package/build/src/narrative/readers.d.ts +84 -0
- package/build/src/narrative/readers.js +406 -0
- package/build/src/narrative/render.d.ts +3 -0
- package/build/src/narrative/render.js +83 -0
- package/build/src/narrative/resolver.d.ts +52 -0
- package/build/src/narrative/resolver.js +190 -0
- package/build/src/narrative/snapshot.d.ts +90 -0
- package/build/src/narrative/snapshot.js +325 -0
- package/build/src/narrative/source-ids.d.ts +121 -0
- package/build/src/narrative/source-ids.js +201 -0
- package/build/src/narrative/statements.d.ts +84 -0
- package/build/src/narrative/statements.js +347 -0
- package/build/src/narrative/turn-spine.d.ts +19 -0
- package/build/src/narrative/turn-spine.js +73 -0
- package/build/src/tools/build-universal-bundles.js +8 -0
- package/build/src/tools/generate-capability-matrix.d.ts +7 -0
- package/build/src/tools/generate-capability-matrix.js +207 -0
- package/build/src/tools/validate-source-tree.js +5 -1
- package/context/scripts/hooks/stop-goal-fit.js +182 -9
- package/context/scripts/hooks/workflow-steering.js +160 -19
- package/context/scripts/telemetry/lib/session.sh +3 -0
- package/context/scripts/telemetry/lib/transport.sh +12 -3
- package/context/scripts/telemetry/telemetry.sh +480 -59
- package/dist/base/build/generated/capability-declarations.json +177 -0
- package/dist/base/build/package.json +1 -1
- package/dist/base/build/src/builder-flow-runtime.d.ts +37 -0
- package/dist/base/build/src/builder-flow-runtime.js +71 -1
- package/dist/base/build/src/builder-gate-action-envelope.d.ts +59 -7
- package/dist/base/build/src/builder-gate-action-envelope.js +163 -30
- package/dist/base/build/src/builder-lifecycle-authority.d.ts +26 -0
- package/dist/base/build/src/builder-lifecycle-authority.js +38 -0
- package/dist/base/build/src/cli/builder-run.js +71 -2
- package/dist/base/build/src/cli/narrative-render.d.ts +95 -0
- package/dist/base/build/src/cli/narrative-render.js +466 -0
- package/dist/base/build/src/cli/narrative-sources.d.ts +2 -0
- package/dist/base/build/src/cli/narrative-sources.js +282 -0
- package/dist/base/build/src/cli/public-contracts.d.ts +257 -0
- package/dist/base/build/src/cli/public-contracts.js +87 -0
- package/dist/base/build/src/cli/workflow-sidecar.d.ts +28 -12
- package/dist/base/build/src/cli/workflow-sidecar.js +599 -180
- package/dist/base/build/src/cli/workflow.js +11 -1
- package/dist/base/build/src/cli.js +8 -0
- package/dist/base/build/src/continuation-driver.d.ts +12 -0
- package/dist/base/build/src/continuation-driver.js +16 -2
- package/dist/base/build/src/continuation-validation.js +349 -3
- package/dist/base/build/src/flow-kit/action-metadata.js +21 -1
- package/dist/base/build/src/index.d.ts +33 -2
- package/dist/base/build/src/index.js +24 -0
- package/dist/base/build/src/lib/capability-declarations.d.ts +83 -0
- package/dist/base/build/src/lib/capability-declarations.js +209 -0
- package/dist/base/build/src/narrative/envelope.d.ts +111 -0
- package/dist/base/build/src/narrative/envelope.js +590 -0
- package/dist/base/build/src/narrative/eval-result.d.ts +60 -0
- package/dist/base/build/src/narrative/eval-result.js +158 -0
- package/dist/base/build/src/narrative/grounding-validator.d.ts +104 -0
- package/dist/base/build/src/narrative/grounding-validator.js +472 -0
- package/dist/base/build/src/narrative/integrity.d.ts +17 -0
- package/dist/base/build/src/narrative/integrity.js +39 -0
- package/dist/base/build/src/narrative/intent-economics.d.ts +42 -0
- package/dist/base/build/src/narrative/intent-economics.js +82 -0
- package/dist/base/build/src/narrative/intent.d.ts +94 -0
- package/dist/base/build/src/narrative/intent.js +132 -0
- package/dist/base/build/src/narrative/policy-filter.d.ts +15 -0
- package/dist/base/build/src/narrative/policy-filter.js +58 -0
- package/dist/base/build/src/narrative/projection.d.ts +58 -0
- package/dist/base/build/src/narrative/projection.js +502 -0
- package/dist/base/build/src/narrative/readers.d.ts +84 -0
- package/dist/base/build/src/narrative/readers.js +406 -0
- package/dist/base/build/src/narrative/render.d.ts +3 -0
- package/dist/base/build/src/narrative/render.js +83 -0
- package/dist/base/build/src/narrative/resolver.d.ts +52 -0
- package/dist/base/build/src/narrative/resolver.js +190 -0
- package/dist/base/build/src/narrative/snapshot.d.ts +90 -0
- package/dist/base/build/src/narrative/snapshot.js +325 -0
- package/dist/base/build/src/narrative/source-ids.d.ts +121 -0
- package/dist/base/build/src/narrative/source-ids.js +201 -0
- package/dist/base/build/src/narrative/statements.d.ts +84 -0
- package/dist/base/build/src/narrative/statements.js +347 -0
- package/dist/base/build/src/narrative/turn-spine.d.ts +19 -0
- package/dist/base/build/src/narrative/turn-spine.js +73 -0
- package/dist/base/build/src/tools/build-universal-bundles.js +8 -0
- package/dist/base/build/src/tools/generate-capability-matrix.d.ts +7 -0
- package/dist/base/build/src/tools/generate-capability-matrix.js +207 -0
- package/dist/base/build/src/tools/validate-source-tree.js +5 -1
- package/dist/base/context/scripts/hooks/stop-goal-fit.js +182 -9
- package/dist/base/context/scripts/hooks/workflow-steering.js +160 -19
- package/dist/base/context/scripts/telemetry/lib/session.sh +3 -0
- package/dist/base/context/scripts/telemetry/lib/transport.sh +12 -3
- package/dist/base/context/scripts/telemetry/telemetry.sh +480 -59
- package/dist/base/docs/context-map.md +4 -0
- package/dist/base/docs/decisions/index.md +1 -0
- package/dist/base/docs/decisions/writer-observed-execution.md +51 -0
- package/dist/base/docs/fixture-ownership.md +5 -1
- package/dist/base/docs/migrations.md +20 -0
- package/dist/base/docs/public-workflow-cli.md +9 -0
- package/dist/base/docs/spec/builder-flow-runtime.md +49 -8
- package/dist/base/docs/spec/runtime-hook-surface.md +29 -1
- package/dist/base/docs/specs/economics-record-contract.md +1 -1
- package/dist/base/docs/specs/harness-capability-matrix.md +63 -21
- package/dist/base/docs/workflow-usage-guide.md +4 -1
- package/dist/base/evals/ci/run-baseline.sh +38 -0
- package/dist/base/evals/fixtures/narrative-evals/README.md +62 -0
- package/dist/base/evals/fixtures/narrative-evals/corpus.json +129 -0
- package/dist/base/evals/fixtures/narrative-evals/scorer.mjs +522 -0
- package/dist/base/evals/fixtures/narrative-grounding-validator/corpus.json +20 -0
- package/dist/base/evals/fixtures/narrative-grounding-validator/prompt-injection-adversarial.txt +1 -0
- package/dist/base/evals/fixtures/narrative-grounding-validator/prompt-injection-control.txt +1 -0
- package/dist/base/evals/fixtures/narrative-grounding-validator/scorer.mjs +201 -0
- package/dist/base/evals/fixtures/narrative-prose-renderer/corpus.json +15 -0
- package/dist/base/evals/fixtures/narrative-prose-renderer/scorer.mjs +201 -0
- package/dist/base/evals/fixtures/narrative-sources/expected-capture-completeness.json +13 -0
- package/dist/base/evals/fixtures/narrative-sources/flow/runs/run-fixture/report.json +1 -0
- package/dist/base/evals/fixtures/narrative-sources/flow/runs/run-fixture/state.json +1 -0
- package/dist/base/evals/fixtures/narrative-sources/flow/runs/run-runtime/state.json +1 -0
- package/dist/base/evals/fixtures/narrative-sources/repo/created.txt +1 -0
- package/dist/base/evals/fixtures/narrative-sources/repo/fixture.txt +1 -0
- package/dist/base/evals/fixtures/narrative-sources/session/agents/agent-fixture/events.jsonl +2 -0
- package/dist/base/evals/fixtures/narrative-sources/session/agents/nested-worker/events.jsonl +1 -0
- package/dist/base/evals/fixtures/narrative-sources/session/trust.bundle +1 -0
- package/dist/base/evals/fixtures/narrative-sources/telemetry/full.jsonl +3 -0
- package/dist/base/evals/fixtures/narrative-sources/telemetry/runtime.jsonl +4 -0
- package/dist/base/evals/fixtures/narrative-sources/transcripts/session.txt +1 -0
- package/dist/base/evals/integration/test_capability_declarations.sh +183 -0
- package/dist/base/evals/integration/test_economics_record.sh +42 -0
- package/dist/base/evals/integration/test_fixture_retirement_audit.sh +2 -2
- package/dist/base/evals/integration/test_gate_review_inquiry_records.sh +42 -35
- package/dist/base/evals/integration/test_goal_fit_hook.sh +13 -5
- package/dist/base/evals/integration/test_goal_fit_narrative_exclusion.sh +68 -0
- package/dist/base/evals/integration/test_narrative_evals.sh +174 -0
- package/dist/base/evals/integration/test_narrative_grounded_envelope.sh +280 -0
- package/dist/base/evals/integration/test_narrative_grounding_validator.sh +166 -0
- package/dist/base/evals/integration/test_narrative_intent_annotation.sh +205 -0
- package/dist/base/evals/integration/test_narrative_prose_renderer.sh +239 -0
- package/dist/base/evals/integration/test_narrative_redaction_failclosed.sh +120 -0
- package/dist/base/evals/integration/test_narrative_runtime_projection.sh +146 -0
- package/dist/base/evals/integration/test_narrative_source_contract.sh +228 -0
- package/dist/base/evals/integration/test_narrative_trust_isolation.sh +408 -0
- package/dist/base/evals/integration/test_plain_stop_messaging.sh +91 -0
- package/dist/base/evals/integration/test_session_resume_roundtrip.sh +228 -0
- package/dist/base/evals/integration/test_telemetry_action_class.sh +265 -0
- package/dist/base/evals/integration/test_telemetry_delegation.sh +291 -0
- package/dist/base/evals/integration/test_telemetry_sanitize_usage.sh +155 -0
- package/dist/base/evals/integration/test_telemetry_task_slug.sh +158 -0
- package/dist/base/evals/integration/test_telemetry_tool_outcome.sh +279 -0
- package/dist/base/evals/integration/test_workflow_sidecar_writer.sh +111 -2
- package/dist/base/evals/run.sh +12 -0
- package/dist/base/evals/static/test_library_exports.sh +5 -0
- package/dist/base/install.sh +1 -1
- package/dist/base/schemas/grounded-execution-narrative.schema.json +292 -0
- package/dist/base/schemas/narrative-eval-result.schema.json +205 -0
- package/dist/base/schemas/narrative-runtime-projection.schema.json +134 -0
- package/dist/base/schemas/narrative-source-manifest.schema.json +294 -0
- package/dist/base/scripts/check-hachure-boundary.mjs +81 -0
- package/dist/base/scripts/hooks/stop-goal-fit.js +182 -9
- package/dist/base/scripts/hooks/workflow-steering.js +160 -19
- package/dist/base/scripts/telemetry/economics-record.schema.json +1 -1
- package/dist/base/scripts/telemetry/economics-record.sh +47 -3
- package/dist/base/scripts/telemetry/lib/session.sh +3 -0
- package/dist/base/scripts/telemetry/lib/transport.sh +12 -3
- package/dist/base/scripts/telemetry/telemetry.sh +480 -59
- package/dist/claude-code/build/generated/capability-declarations.json +177 -0
- package/dist/claude-code/build/package.json +1 -1
- package/dist/claude-code/build/src/builder-flow-runtime.d.ts +37 -0
- package/dist/claude-code/build/src/builder-flow-runtime.js +71 -1
- package/dist/claude-code/build/src/builder-gate-action-envelope.d.ts +59 -7
- package/dist/claude-code/build/src/builder-gate-action-envelope.js +163 -30
- package/dist/claude-code/build/src/builder-lifecycle-authority.d.ts +26 -0
- package/dist/claude-code/build/src/builder-lifecycle-authority.js +38 -0
- package/dist/claude-code/build/src/cli/builder-run.js +71 -2
- package/dist/claude-code/build/src/cli/narrative-render.d.ts +95 -0
- package/dist/claude-code/build/src/cli/narrative-render.js +466 -0
- package/dist/claude-code/build/src/cli/narrative-sources.d.ts +2 -0
- package/dist/claude-code/build/src/cli/narrative-sources.js +282 -0
- package/dist/claude-code/build/src/cli/public-contracts.d.ts +257 -0
- package/dist/claude-code/build/src/cli/public-contracts.js +87 -0
- package/dist/claude-code/build/src/cli/workflow-sidecar.d.ts +28 -12
- package/dist/claude-code/build/src/cli/workflow-sidecar.js +599 -180
- package/dist/claude-code/build/src/cli/workflow.js +11 -1
- package/dist/claude-code/build/src/cli.js +8 -0
- package/dist/claude-code/build/src/continuation-driver.d.ts +12 -0
- package/dist/claude-code/build/src/continuation-driver.js +16 -2
- package/dist/claude-code/build/src/continuation-validation.js +349 -3
- package/dist/claude-code/build/src/flow-kit/action-metadata.js +21 -1
- package/dist/claude-code/build/src/index.d.ts +33 -2
- package/dist/claude-code/build/src/index.js +24 -0
- package/dist/claude-code/build/src/lib/capability-declarations.d.ts +83 -0
- package/dist/claude-code/build/src/lib/capability-declarations.js +209 -0
- package/dist/claude-code/build/src/narrative/envelope.d.ts +111 -0
- package/dist/claude-code/build/src/narrative/envelope.js +590 -0
- package/dist/claude-code/build/src/narrative/eval-result.d.ts +60 -0
- package/dist/claude-code/build/src/narrative/eval-result.js +158 -0
- package/dist/claude-code/build/src/narrative/grounding-validator.d.ts +104 -0
- package/dist/claude-code/build/src/narrative/grounding-validator.js +472 -0
- package/dist/claude-code/build/src/narrative/integrity.d.ts +17 -0
- package/dist/claude-code/build/src/narrative/integrity.js +39 -0
- package/dist/claude-code/build/src/narrative/intent-economics.d.ts +42 -0
- package/dist/claude-code/build/src/narrative/intent-economics.js +82 -0
- package/dist/claude-code/build/src/narrative/intent.d.ts +94 -0
- package/dist/claude-code/build/src/narrative/intent.js +132 -0
- package/dist/claude-code/build/src/narrative/policy-filter.d.ts +15 -0
- package/dist/claude-code/build/src/narrative/policy-filter.js +58 -0
- package/dist/claude-code/build/src/narrative/projection.d.ts +58 -0
- package/dist/claude-code/build/src/narrative/projection.js +502 -0
- package/dist/claude-code/build/src/narrative/readers.d.ts +84 -0
- package/dist/claude-code/build/src/narrative/readers.js +406 -0
- package/dist/claude-code/build/src/narrative/render.d.ts +3 -0
- package/dist/claude-code/build/src/narrative/render.js +83 -0
- package/dist/claude-code/build/src/narrative/resolver.d.ts +52 -0
- package/dist/claude-code/build/src/narrative/resolver.js +190 -0
- package/dist/claude-code/build/src/narrative/snapshot.d.ts +90 -0
- package/dist/claude-code/build/src/narrative/snapshot.js +325 -0
- package/dist/claude-code/build/src/narrative/source-ids.d.ts +121 -0
- package/dist/claude-code/build/src/narrative/source-ids.js +201 -0
- package/dist/claude-code/build/src/narrative/statements.d.ts +84 -0
- package/dist/claude-code/build/src/narrative/statements.js +347 -0
- package/dist/claude-code/build/src/narrative/turn-spine.d.ts +19 -0
- package/dist/claude-code/build/src/narrative/turn-spine.js +73 -0
- package/dist/claude-code/build/src/tools/build-universal-bundles.js +8 -0
- package/dist/claude-code/build/src/tools/generate-capability-matrix.d.ts +7 -0
- package/dist/claude-code/build/src/tools/generate-capability-matrix.js +207 -0
- package/dist/claude-code/build/src/tools/validate-source-tree.js +5 -1
- package/dist/claude-code/context/scripts/hooks/stop-goal-fit.js +182 -9
- package/dist/claude-code/context/scripts/hooks/workflow-steering.js +160 -19
- package/dist/claude-code/context/scripts/telemetry/lib/session.sh +3 -0
- package/dist/claude-code/context/scripts/telemetry/lib/transport.sh +12 -3
- package/dist/claude-code/context/scripts/telemetry/telemetry.sh +480 -59
- package/dist/claude-code/docs/context-map.md +4 -0
- package/dist/claude-code/docs/decisions/index.md +1 -0
- package/dist/claude-code/docs/decisions/writer-observed-execution.md +51 -0
- package/dist/claude-code/docs/fixture-ownership.md +5 -1
- package/dist/claude-code/docs/migrations.md +20 -0
- package/dist/claude-code/docs/public-workflow-cli.md +9 -0
- package/dist/claude-code/docs/spec/builder-flow-runtime.md +49 -8
- package/dist/claude-code/docs/spec/runtime-hook-surface.md +29 -1
- package/dist/claude-code/docs/specs/economics-record-contract.md +1 -1
- package/dist/claude-code/docs/specs/harness-capability-matrix.md +63 -21
- package/dist/claude-code/docs/workflow-usage-guide.md +4 -1
- package/dist/claude-code/evals/ci/run-baseline.sh +38 -0
- package/dist/claude-code/evals/fixtures/narrative-evals/README.md +62 -0
- package/dist/claude-code/evals/fixtures/narrative-evals/corpus.json +129 -0
- package/dist/claude-code/evals/fixtures/narrative-evals/scorer.mjs +522 -0
- package/dist/claude-code/evals/fixtures/narrative-grounding-validator/corpus.json +20 -0
- package/dist/claude-code/evals/fixtures/narrative-grounding-validator/prompt-injection-adversarial.txt +1 -0
- package/dist/claude-code/evals/fixtures/narrative-grounding-validator/prompt-injection-control.txt +1 -0
- package/dist/claude-code/evals/fixtures/narrative-grounding-validator/scorer.mjs +201 -0
- package/dist/claude-code/evals/fixtures/narrative-prose-renderer/corpus.json +15 -0
- package/dist/claude-code/evals/fixtures/narrative-prose-renderer/scorer.mjs +201 -0
- package/dist/claude-code/evals/fixtures/narrative-sources/expected-capture-completeness.json +13 -0
- package/dist/claude-code/evals/fixtures/narrative-sources/flow/runs/run-fixture/report.json +1 -0
- package/dist/claude-code/evals/fixtures/narrative-sources/flow/runs/run-fixture/state.json +1 -0
- package/dist/claude-code/evals/fixtures/narrative-sources/flow/runs/run-runtime/state.json +1 -0
- package/dist/claude-code/evals/fixtures/narrative-sources/repo/created.txt +1 -0
- package/dist/claude-code/evals/fixtures/narrative-sources/repo/fixture.txt +1 -0
- package/dist/claude-code/evals/fixtures/narrative-sources/session/agents/agent-fixture/events.jsonl +2 -0
- package/dist/claude-code/evals/fixtures/narrative-sources/session/agents/nested-worker/events.jsonl +1 -0
- package/dist/claude-code/evals/fixtures/narrative-sources/session/trust.bundle +1 -0
- package/dist/claude-code/evals/fixtures/narrative-sources/telemetry/full.jsonl +3 -0
- package/dist/claude-code/evals/fixtures/narrative-sources/telemetry/runtime.jsonl +4 -0
- package/dist/claude-code/evals/fixtures/narrative-sources/transcripts/session.txt +1 -0
- package/dist/claude-code/evals/integration/test_capability_declarations.sh +183 -0
- package/dist/claude-code/evals/integration/test_economics_record.sh +42 -0
- package/dist/claude-code/evals/integration/test_fixture_retirement_audit.sh +2 -2
- package/dist/claude-code/evals/integration/test_gate_review_inquiry_records.sh +42 -35
- package/dist/claude-code/evals/integration/test_goal_fit_hook.sh +13 -5
- package/dist/claude-code/evals/integration/test_goal_fit_narrative_exclusion.sh +68 -0
- package/dist/claude-code/evals/integration/test_narrative_evals.sh +174 -0
- package/dist/claude-code/evals/integration/test_narrative_grounded_envelope.sh +280 -0
- package/dist/claude-code/evals/integration/test_narrative_grounding_validator.sh +166 -0
- package/dist/claude-code/evals/integration/test_narrative_intent_annotation.sh +205 -0
- package/dist/claude-code/evals/integration/test_narrative_prose_renderer.sh +239 -0
- package/dist/claude-code/evals/integration/test_narrative_redaction_failclosed.sh +120 -0
- package/dist/claude-code/evals/integration/test_narrative_runtime_projection.sh +146 -0
- package/dist/claude-code/evals/integration/test_narrative_source_contract.sh +228 -0
- package/dist/claude-code/evals/integration/test_narrative_trust_isolation.sh +408 -0
- package/dist/claude-code/evals/integration/test_plain_stop_messaging.sh +91 -0
- package/dist/claude-code/evals/integration/test_session_resume_roundtrip.sh +228 -0
- package/dist/claude-code/evals/integration/test_telemetry_action_class.sh +265 -0
- package/dist/claude-code/evals/integration/test_telemetry_delegation.sh +291 -0
- package/dist/claude-code/evals/integration/test_telemetry_sanitize_usage.sh +155 -0
- package/dist/claude-code/evals/integration/test_telemetry_task_slug.sh +158 -0
- package/dist/claude-code/evals/integration/test_telemetry_tool_outcome.sh +279 -0
- package/dist/claude-code/evals/integration/test_workflow_sidecar_writer.sh +111 -2
- package/dist/claude-code/evals/run.sh +12 -0
- package/dist/claude-code/evals/static/test_library_exports.sh +5 -0
- package/dist/claude-code/install.sh +1 -1
- package/dist/claude-code/schemas/grounded-execution-narrative.schema.json +292 -0
- package/dist/claude-code/schemas/narrative-eval-result.schema.json +205 -0
- package/dist/claude-code/schemas/narrative-runtime-projection.schema.json +134 -0
- package/dist/claude-code/schemas/narrative-source-manifest.schema.json +294 -0
- package/dist/claude-code/scripts/check-hachure-boundary.mjs +81 -0
- package/dist/claude-code/scripts/hooks/stop-goal-fit.js +182 -9
- package/dist/claude-code/scripts/hooks/workflow-steering.js +160 -19
- package/dist/claude-code/scripts/telemetry/economics-record.schema.json +1 -1
- package/dist/claude-code/scripts/telemetry/economics-record.sh +47 -3
- package/dist/claude-code/scripts/telemetry/lib/session.sh +3 -0
- package/dist/claude-code/scripts/telemetry/lib/transport.sh +12 -3
- package/dist/claude-code/scripts/telemetry/telemetry.sh +480 -59
- package/dist/codex/build/generated/capability-declarations.json +177 -0
- package/dist/codex/build/package.json +1 -1
- package/dist/codex/build/src/builder-flow-runtime.d.ts +37 -0
- package/dist/codex/build/src/builder-flow-runtime.js +71 -1
- package/dist/codex/build/src/builder-gate-action-envelope.d.ts +59 -7
- package/dist/codex/build/src/builder-gate-action-envelope.js +163 -30
- package/dist/codex/build/src/builder-lifecycle-authority.d.ts +26 -0
- package/dist/codex/build/src/builder-lifecycle-authority.js +38 -0
- package/dist/codex/build/src/cli/builder-run.js +71 -2
- package/dist/codex/build/src/cli/narrative-render.d.ts +95 -0
- package/dist/codex/build/src/cli/narrative-render.js +466 -0
- package/dist/codex/build/src/cli/narrative-sources.d.ts +2 -0
- package/dist/codex/build/src/cli/narrative-sources.js +282 -0
- package/dist/codex/build/src/cli/public-contracts.d.ts +257 -0
- package/dist/codex/build/src/cli/public-contracts.js +87 -0
- package/dist/codex/build/src/cli/workflow-sidecar.d.ts +28 -12
- package/dist/codex/build/src/cli/workflow-sidecar.js +599 -180
- package/dist/codex/build/src/cli/workflow.js +11 -1
- package/dist/codex/build/src/cli.js +8 -0
- package/dist/codex/build/src/continuation-driver.d.ts +12 -0
- package/dist/codex/build/src/continuation-driver.js +16 -2
- package/dist/codex/build/src/continuation-validation.js +349 -3
- package/dist/codex/build/src/flow-kit/action-metadata.js +21 -1
- package/dist/codex/build/src/index.d.ts +33 -2
- package/dist/codex/build/src/index.js +24 -0
- package/dist/codex/build/src/lib/capability-declarations.d.ts +83 -0
- package/dist/codex/build/src/lib/capability-declarations.js +209 -0
- package/dist/codex/build/src/narrative/envelope.d.ts +111 -0
- package/dist/codex/build/src/narrative/envelope.js +590 -0
- package/dist/codex/build/src/narrative/eval-result.d.ts +60 -0
- package/dist/codex/build/src/narrative/eval-result.js +158 -0
- package/dist/codex/build/src/narrative/grounding-validator.d.ts +104 -0
- package/dist/codex/build/src/narrative/grounding-validator.js +472 -0
- package/dist/codex/build/src/narrative/integrity.d.ts +17 -0
- package/dist/codex/build/src/narrative/integrity.js +39 -0
- package/dist/codex/build/src/narrative/intent-economics.d.ts +42 -0
- package/dist/codex/build/src/narrative/intent-economics.js +82 -0
- package/dist/codex/build/src/narrative/intent.d.ts +94 -0
- package/dist/codex/build/src/narrative/intent.js +132 -0
- package/dist/codex/build/src/narrative/policy-filter.d.ts +15 -0
- package/dist/codex/build/src/narrative/policy-filter.js +58 -0
- package/dist/codex/build/src/narrative/projection.d.ts +58 -0
- package/dist/codex/build/src/narrative/projection.js +502 -0
- package/dist/codex/build/src/narrative/readers.d.ts +84 -0
- package/dist/codex/build/src/narrative/readers.js +406 -0
- package/dist/codex/build/src/narrative/render.d.ts +3 -0
- package/dist/codex/build/src/narrative/render.js +83 -0
- package/dist/codex/build/src/narrative/resolver.d.ts +52 -0
- package/dist/codex/build/src/narrative/resolver.js +190 -0
- package/dist/codex/build/src/narrative/snapshot.d.ts +90 -0
- package/dist/codex/build/src/narrative/snapshot.js +325 -0
- package/dist/codex/build/src/narrative/source-ids.d.ts +121 -0
- package/dist/codex/build/src/narrative/source-ids.js +201 -0
- package/dist/codex/build/src/narrative/statements.d.ts +84 -0
- package/dist/codex/build/src/narrative/statements.js +347 -0
- package/dist/codex/build/src/narrative/turn-spine.d.ts +19 -0
- package/dist/codex/build/src/narrative/turn-spine.js +73 -0
- package/dist/codex/build/src/tools/build-universal-bundles.js +8 -0
- package/dist/codex/build/src/tools/generate-capability-matrix.d.ts +7 -0
- package/dist/codex/build/src/tools/generate-capability-matrix.js +207 -0
- package/dist/codex/build/src/tools/validate-source-tree.js +5 -1
- package/dist/codex/context/scripts/hooks/stop-goal-fit.js +182 -9
- package/dist/codex/context/scripts/hooks/workflow-steering.js +160 -19
- package/dist/codex/context/scripts/telemetry/lib/session.sh +3 -0
- package/dist/codex/context/scripts/telemetry/lib/transport.sh +12 -3
- package/dist/codex/context/scripts/telemetry/telemetry.sh +480 -59
- package/dist/codex/docs/context-map.md +4 -0
- package/dist/codex/docs/decisions/index.md +1 -0
- package/dist/codex/docs/decisions/writer-observed-execution.md +51 -0
- package/dist/codex/docs/fixture-ownership.md +5 -1
- package/dist/codex/docs/migrations.md +20 -0
- package/dist/codex/docs/public-workflow-cli.md +9 -0
- package/dist/codex/docs/spec/builder-flow-runtime.md +49 -8
- package/dist/codex/docs/spec/runtime-hook-surface.md +29 -1
- package/dist/codex/docs/specs/economics-record-contract.md +1 -1
- package/dist/codex/docs/specs/harness-capability-matrix.md +63 -21
- package/dist/codex/docs/workflow-usage-guide.md +4 -1
- package/dist/codex/evals/ci/run-baseline.sh +38 -0
- package/dist/codex/evals/fixtures/narrative-evals/README.md +62 -0
- package/dist/codex/evals/fixtures/narrative-evals/corpus.json +129 -0
- package/dist/codex/evals/fixtures/narrative-evals/scorer.mjs +522 -0
- package/dist/codex/evals/fixtures/narrative-grounding-validator/corpus.json +20 -0
- package/dist/codex/evals/fixtures/narrative-grounding-validator/prompt-injection-adversarial.txt +1 -0
- package/dist/codex/evals/fixtures/narrative-grounding-validator/prompt-injection-control.txt +1 -0
- package/dist/codex/evals/fixtures/narrative-grounding-validator/scorer.mjs +201 -0
- package/dist/codex/evals/fixtures/narrative-prose-renderer/corpus.json +15 -0
- package/dist/codex/evals/fixtures/narrative-prose-renderer/scorer.mjs +201 -0
- package/dist/codex/evals/fixtures/narrative-sources/expected-capture-completeness.json +13 -0
- package/dist/codex/evals/fixtures/narrative-sources/flow/runs/run-fixture/report.json +1 -0
- package/dist/codex/evals/fixtures/narrative-sources/flow/runs/run-fixture/state.json +1 -0
- package/dist/codex/evals/fixtures/narrative-sources/flow/runs/run-runtime/state.json +1 -0
- package/dist/codex/evals/fixtures/narrative-sources/repo/created.txt +1 -0
- package/dist/codex/evals/fixtures/narrative-sources/repo/fixture.txt +1 -0
- package/dist/codex/evals/fixtures/narrative-sources/session/agents/agent-fixture/events.jsonl +2 -0
- package/dist/codex/evals/fixtures/narrative-sources/session/agents/nested-worker/events.jsonl +1 -0
- package/dist/codex/evals/fixtures/narrative-sources/session/trust.bundle +1 -0
- package/dist/codex/evals/fixtures/narrative-sources/telemetry/full.jsonl +3 -0
- package/dist/codex/evals/fixtures/narrative-sources/telemetry/runtime.jsonl +4 -0
- package/dist/codex/evals/fixtures/narrative-sources/transcripts/session.txt +1 -0
- package/dist/codex/evals/integration/test_capability_declarations.sh +183 -0
- package/dist/codex/evals/integration/test_economics_record.sh +42 -0
- package/dist/codex/evals/integration/test_fixture_retirement_audit.sh +2 -2
- package/dist/codex/evals/integration/test_gate_review_inquiry_records.sh +42 -35
- package/dist/codex/evals/integration/test_goal_fit_hook.sh +13 -5
- package/dist/codex/evals/integration/test_goal_fit_narrative_exclusion.sh +68 -0
- package/dist/codex/evals/integration/test_narrative_evals.sh +174 -0
- package/dist/codex/evals/integration/test_narrative_grounded_envelope.sh +280 -0
- package/dist/codex/evals/integration/test_narrative_grounding_validator.sh +166 -0
- package/dist/codex/evals/integration/test_narrative_intent_annotation.sh +205 -0
- package/dist/codex/evals/integration/test_narrative_prose_renderer.sh +239 -0
- package/dist/codex/evals/integration/test_narrative_redaction_failclosed.sh +120 -0
- package/dist/codex/evals/integration/test_narrative_runtime_projection.sh +146 -0
- package/dist/codex/evals/integration/test_narrative_source_contract.sh +228 -0
- package/dist/codex/evals/integration/test_narrative_trust_isolation.sh +408 -0
- package/dist/codex/evals/integration/test_plain_stop_messaging.sh +91 -0
- package/dist/codex/evals/integration/test_session_resume_roundtrip.sh +228 -0
- package/dist/codex/evals/integration/test_telemetry_action_class.sh +265 -0
- package/dist/codex/evals/integration/test_telemetry_delegation.sh +291 -0
- package/dist/codex/evals/integration/test_telemetry_sanitize_usage.sh +155 -0
- package/dist/codex/evals/integration/test_telemetry_task_slug.sh +158 -0
- package/dist/codex/evals/integration/test_telemetry_tool_outcome.sh +279 -0
- package/dist/codex/evals/integration/test_workflow_sidecar_writer.sh +111 -2
- package/dist/codex/evals/run.sh +12 -0
- package/dist/codex/evals/static/test_library_exports.sh +5 -0
- package/dist/codex/install.sh +1 -1
- package/dist/codex/schemas/grounded-execution-narrative.schema.json +292 -0
- package/dist/codex/schemas/narrative-eval-result.schema.json +205 -0
- package/dist/codex/schemas/narrative-runtime-projection.schema.json +134 -0
- package/dist/codex/schemas/narrative-source-manifest.schema.json +294 -0
- package/dist/codex/scripts/check-hachure-boundary.mjs +81 -0
- package/dist/codex/scripts/hooks/stop-goal-fit.js +182 -9
- package/dist/codex/scripts/hooks/workflow-steering.js +160 -19
- package/dist/codex/scripts/telemetry/economics-record.schema.json +1 -1
- package/dist/codex/scripts/telemetry/economics-record.sh +47 -3
- package/dist/codex/scripts/telemetry/lib/session.sh +3 -0
- package/dist/codex/scripts/telemetry/lib/transport.sh +12 -3
- package/dist/codex/scripts/telemetry/telemetry.sh +480 -59
- package/dist/kiro/build/generated/capability-declarations.json +177 -0
- package/dist/kiro/build/package.json +1 -1
- package/dist/kiro/build/src/builder-flow-runtime.d.ts +37 -0
- package/dist/kiro/build/src/builder-flow-runtime.js +71 -1
- package/dist/kiro/build/src/builder-gate-action-envelope.d.ts +59 -7
- package/dist/kiro/build/src/builder-gate-action-envelope.js +163 -30
- package/dist/kiro/build/src/builder-lifecycle-authority.d.ts +26 -0
- package/dist/kiro/build/src/builder-lifecycle-authority.js +38 -0
- package/dist/kiro/build/src/cli/builder-run.js +71 -2
- package/dist/kiro/build/src/cli/narrative-render.d.ts +95 -0
- package/dist/kiro/build/src/cli/narrative-render.js +466 -0
- package/dist/kiro/build/src/cli/narrative-sources.d.ts +2 -0
- package/dist/kiro/build/src/cli/narrative-sources.js +282 -0
- package/dist/kiro/build/src/cli/public-contracts.d.ts +257 -0
- package/dist/kiro/build/src/cli/public-contracts.js +87 -0
- package/dist/kiro/build/src/cli/workflow-sidecar.d.ts +28 -12
- package/dist/kiro/build/src/cli/workflow-sidecar.js +599 -180
- package/dist/kiro/build/src/cli/workflow.js +11 -1
- package/dist/kiro/build/src/cli.js +8 -0
- package/dist/kiro/build/src/continuation-driver.d.ts +12 -0
- package/dist/kiro/build/src/continuation-driver.js +16 -2
- package/dist/kiro/build/src/continuation-validation.js +349 -3
- package/dist/kiro/build/src/flow-kit/action-metadata.js +21 -1
- package/dist/kiro/build/src/index.d.ts +33 -2
- package/dist/kiro/build/src/index.js +24 -0
- package/dist/kiro/build/src/lib/capability-declarations.d.ts +83 -0
- package/dist/kiro/build/src/lib/capability-declarations.js +209 -0
- package/dist/kiro/build/src/narrative/envelope.d.ts +111 -0
- package/dist/kiro/build/src/narrative/envelope.js +590 -0
- package/dist/kiro/build/src/narrative/eval-result.d.ts +60 -0
- package/dist/kiro/build/src/narrative/eval-result.js +158 -0
- package/dist/kiro/build/src/narrative/grounding-validator.d.ts +104 -0
- package/dist/kiro/build/src/narrative/grounding-validator.js +472 -0
- package/dist/kiro/build/src/narrative/integrity.d.ts +17 -0
- package/dist/kiro/build/src/narrative/integrity.js +39 -0
- package/dist/kiro/build/src/narrative/intent-economics.d.ts +42 -0
- package/dist/kiro/build/src/narrative/intent-economics.js +82 -0
- package/dist/kiro/build/src/narrative/intent.d.ts +94 -0
- package/dist/kiro/build/src/narrative/intent.js +132 -0
- package/dist/kiro/build/src/narrative/policy-filter.d.ts +15 -0
- package/dist/kiro/build/src/narrative/policy-filter.js +58 -0
- package/dist/kiro/build/src/narrative/projection.d.ts +58 -0
- package/dist/kiro/build/src/narrative/projection.js +502 -0
- package/dist/kiro/build/src/narrative/readers.d.ts +84 -0
- package/dist/kiro/build/src/narrative/readers.js +406 -0
- package/dist/kiro/build/src/narrative/render.d.ts +3 -0
- package/dist/kiro/build/src/narrative/render.js +83 -0
- package/dist/kiro/build/src/narrative/resolver.d.ts +52 -0
- package/dist/kiro/build/src/narrative/resolver.js +190 -0
- package/dist/kiro/build/src/narrative/snapshot.d.ts +90 -0
- package/dist/kiro/build/src/narrative/snapshot.js +325 -0
- package/dist/kiro/build/src/narrative/source-ids.d.ts +121 -0
- package/dist/kiro/build/src/narrative/source-ids.js +201 -0
- package/dist/kiro/build/src/narrative/statements.d.ts +84 -0
- package/dist/kiro/build/src/narrative/statements.js +347 -0
- package/dist/kiro/build/src/narrative/turn-spine.d.ts +19 -0
- package/dist/kiro/build/src/narrative/turn-spine.js +73 -0
- package/dist/kiro/build/src/tools/build-universal-bundles.js +8 -0
- package/dist/kiro/build/src/tools/generate-capability-matrix.d.ts +7 -0
- package/dist/kiro/build/src/tools/generate-capability-matrix.js +207 -0
- package/dist/kiro/build/src/tools/validate-source-tree.js +5 -1
- package/dist/kiro/context/scripts/hooks/stop-goal-fit.js +182 -9
- package/dist/kiro/context/scripts/hooks/workflow-steering.js +160 -19
- package/dist/kiro/context/scripts/telemetry/lib/session.sh +3 -0
- package/dist/kiro/context/scripts/telemetry/lib/transport.sh +12 -3
- package/dist/kiro/context/scripts/telemetry/telemetry.sh +480 -59
- package/dist/kiro/docs/context-map.md +4 -0
- package/dist/kiro/docs/decisions/index.md +1 -0
- package/dist/kiro/docs/decisions/writer-observed-execution.md +51 -0
- package/dist/kiro/docs/fixture-ownership.md +5 -1
- package/dist/kiro/docs/migrations.md +20 -0
- package/dist/kiro/docs/public-workflow-cli.md +9 -0
- package/dist/kiro/docs/spec/builder-flow-runtime.md +49 -8
- package/dist/kiro/docs/spec/runtime-hook-surface.md +29 -1
- package/dist/kiro/docs/specs/economics-record-contract.md +1 -1
- package/dist/kiro/docs/specs/harness-capability-matrix.md +63 -21
- package/dist/kiro/docs/workflow-usage-guide.md +4 -1
- package/dist/kiro/evals/ci/run-baseline.sh +38 -0
- package/dist/kiro/evals/fixtures/narrative-evals/README.md +62 -0
- package/dist/kiro/evals/fixtures/narrative-evals/corpus.json +129 -0
- package/dist/kiro/evals/fixtures/narrative-evals/scorer.mjs +522 -0
- package/dist/kiro/evals/fixtures/narrative-grounding-validator/corpus.json +20 -0
- package/dist/kiro/evals/fixtures/narrative-grounding-validator/prompt-injection-adversarial.txt +1 -0
- package/dist/kiro/evals/fixtures/narrative-grounding-validator/prompt-injection-control.txt +1 -0
- package/dist/kiro/evals/fixtures/narrative-grounding-validator/scorer.mjs +201 -0
- package/dist/kiro/evals/fixtures/narrative-prose-renderer/corpus.json +15 -0
- package/dist/kiro/evals/fixtures/narrative-prose-renderer/scorer.mjs +201 -0
- package/dist/kiro/evals/fixtures/narrative-sources/expected-capture-completeness.json +13 -0
- package/dist/kiro/evals/fixtures/narrative-sources/flow/runs/run-fixture/report.json +1 -0
- package/dist/kiro/evals/fixtures/narrative-sources/flow/runs/run-fixture/state.json +1 -0
- package/dist/kiro/evals/fixtures/narrative-sources/flow/runs/run-runtime/state.json +1 -0
- package/dist/kiro/evals/fixtures/narrative-sources/repo/created.txt +1 -0
- package/dist/kiro/evals/fixtures/narrative-sources/repo/fixture.txt +1 -0
- package/dist/kiro/evals/fixtures/narrative-sources/session/agents/agent-fixture/events.jsonl +2 -0
- package/dist/kiro/evals/fixtures/narrative-sources/session/agents/nested-worker/events.jsonl +1 -0
- package/dist/kiro/evals/fixtures/narrative-sources/session/trust.bundle +1 -0
- package/dist/kiro/evals/fixtures/narrative-sources/telemetry/full.jsonl +3 -0
- package/dist/kiro/evals/fixtures/narrative-sources/telemetry/runtime.jsonl +4 -0
- package/dist/kiro/evals/fixtures/narrative-sources/transcripts/session.txt +1 -0
- package/dist/kiro/evals/integration/test_capability_declarations.sh +183 -0
- package/dist/kiro/evals/integration/test_economics_record.sh +42 -0
- package/dist/kiro/evals/integration/test_fixture_retirement_audit.sh +2 -2
- package/dist/kiro/evals/integration/test_gate_review_inquiry_records.sh +42 -35
- package/dist/kiro/evals/integration/test_goal_fit_hook.sh +13 -5
- package/dist/kiro/evals/integration/test_goal_fit_narrative_exclusion.sh +68 -0
- package/dist/kiro/evals/integration/test_narrative_evals.sh +174 -0
- package/dist/kiro/evals/integration/test_narrative_grounded_envelope.sh +280 -0
- package/dist/kiro/evals/integration/test_narrative_grounding_validator.sh +166 -0
- package/dist/kiro/evals/integration/test_narrative_intent_annotation.sh +205 -0
- package/dist/kiro/evals/integration/test_narrative_prose_renderer.sh +239 -0
- package/dist/kiro/evals/integration/test_narrative_redaction_failclosed.sh +120 -0
- package/dist/kiro/evals/integration/test_narrative_runtime_projection.sh +146 -0
- package/dist/kiro/evals/integration/test_narrative_source_contract.sh +228 -0
- package/dist/kiro/evals/integration/test_narrative_trust_isolation.sh +408 -0
- package/dist/kiro/evals/integration/test_plain_stop_messaging.sh +91 -0
- package/dist/kiro/evals/integration/test_session_resume_roundtrip.sh +228 -0
- package/dist/kiro/evals/integration/test_telemetry_action_class.sh +265 -0
- package/dist/kiro/evals/integration/test_telemetry_delegation.sh +291 -0
- package/dist/kiro/evals/integration/test_telemetry_sanitize_usage.sh +155 -0
- package/dist/kiro/evals/integration/test_telemetry_task_slug.sh +158 -0
- package/dist/kiro/evals/integration/test_telemetry_tool_outcome.sh +279 -0
- package/dist/kiro/evals/integration/test_workflow_sidecar_writer.sh +111 -2
- package/dist/kiro/evals/run.sh +12 -0
- package/dist/kiro/evals/static/test_library_exports.sh +5 -0
- package/dist/kiro/install.sh +1 -1
- package/dist/kiro/schemas/grounded-execution-narrative.schema.json +292 -0
- package/dist/kiro/schemas/narrative-eval-result.schema.json +205 -0
- package/dist/kiro/schemas/narrative-runtime-projection.schema.json +134 -0
- package/dist/kiro/schemas/narrative-source-manifest.schema.json +294 -0
- package/dist/kiro/scripts/check-hachure-boundary.mjs +81 -0
- package/dist/kiro/scripts/hooks/stop-goal-fit.js +182 -9
- package/dist/kiro/scripts/hooks/workflow-steering.js +160 -19
- package/dist/kiro/scripts/telemetry/economics-record.schema.json +1 -1
- package/dist/kiro/scripts/telemetry/economics-record.sh +47 -3
- package/dist/kiro/scripts/telemetry/lib/session.sh +3 -0
- package/dist/kiro/scripts/telemetry/lib/transport.sh +12 -3
- package/dist/kiro/scripts/telemetry/telemetry.sh +480 -59
- package/dist/opencode/build/generated/capability-declarations.json +177 -0
- package/dist/opencode/build/package.json +1 -1
- package/dist/opencode/build/src/builder-flow-runtime.d.ts +37 -0
- package/dist/opencode/build/src/builder-flow-runtime.js +71 -1
- package/dist/opencode/build/src/builder-gate-action-envelope.d.ts +59 -7
- package/dist/opencode/build/src/builder-gate-action-envelope.js +163 -30
- package/dist/opencode/build/src/builder-lifecycle-authority.d.ts +26 -0
- package/dist/opencode/build/src/builder-lifecycle-authority.js +38 -0
- package/dist/opencode/build/src/cli/builder-run.js +71 -2
- package/dist/opencode/build/src/cli/narrative-render.d.ts +95 -0
- package/dist/opencode/build/src/cli/narrative-render.js +466 -0
- package/dist/opencode/build/src/cli/narrative-sources.d.ts +2 -0
- package/dist/opencode/build/src/cli/narrative-sources.js +282 -0
- package/dist/opencode/build/src/cli/public-contracts.d.ts +257 -0
- package/dist/opencode/build/src/cli/public-contracts.js +87 -0
- package/dist/opencode/build/src/cli/workflow-sidecar.d.ts +28 -12
- package/dist/opencode/build/src/cli/workflow-sidecar.js +599 -180
- package/dist/opencode/build/src/cli/workflow.js +11 -1
- package/dist/opencode/build/src/cli.js +8 -0
- package/dist/opencode/build/src/continuation-driver.d.ts +12 -0
- package/dist/opencode/build/src/continuation-driver.js +16 -2
- package/dist/opencode/build/src/continuation-validation.js +349 -3
- package/dist/opencode/build/src/flow-kit/action-metadata.js +21 -1
- package/dist/opencode/build/src/index.d.ts +33 -2
- package/dist/opencode/build/src/index.js +24 -0
- package/dist/opencode/build/src/lib/capability-declarations.d.ts +83 -0
- package/dist/opencode/build/src/lib/capability-declarations.js +209 -0
- package/dist/opencode/build/src/narrative/envelope.d.ts +111 -0
- package/dist/opencode/build/src/narrative/envelope.js +590 -0
- package/dist/opencode/build/src/narrative/eval-result.d.ts +60 -0
- package/dist/opencode/build/src/narrative/eval-result.js +158 -0
- package/dist/opencode/build/src/narrative/grounding-validator.d.ts +104 -0
- package/dist/opencode/build/src/narrative/grounding-validator.js +472 -0
- package/dist/opencode/build/src/narrative/integrity.d.ts +17 -0
- package/dist/opencode/build/src/narrative/integrity.js +39 -0
- package/dist/opencode/build/src/narrative/intent-economics.d.ts +42 -0
- package/dist/opencode/build/src/narrative/intent-economics.js +82 -0
- package/dist/opencode/build/src/narrative/intent.d.ts +94 -0
- package/dist/opencode/build/src/narrative/intent.js +132 -0
- package/dist/opencode/build/src/narrative/policy-filter.d.ts +15 -0
- package/dist/opencode/build/src/narrative/policy-filter.js +58 -0
- package/dist/opencode/build/src/narrative/projection.d.ts +58 -0
- package/dist/opencode/build/src/narrative/projection.js +502 -0
- package/dist/opencode/build/src/narrative/readers.d.ts +84 -0
- package/dist/opencode/build/src/narrative/readers.js +406 -0
- package/dist/opencode/build/src/narrative/render.d.ts +3 -0
- package/dist/opencode/build/src/narrative/render.js +83 -0
- package/dist/opencode/build/src/narrative/resolver.d.ts +52 -0
- package/dist/opencode/build/src/narrative/resolver.js +190 -0
- package/dist/opencode/build/src/narrative/snapshot.d.ts +90 -0
- package/dist/opencode/build/src/narrative/snapshot.js +325 -0
- package/dist/opencode/build/src/narrative/source-ids.d.ts +121 -0
- package/dist/opencode/build/src/narrative/source-ids.js +201 -0
- package/dist/opencode/build/src/narrative/statements.d.ts +84 -0
- package/dist/opencode/build/src/narrative/statements.js +347 -0
- package/dist/opencode/build/src/narrative/turn-spine.d.ts +19 -0
- package/dist/opencode/build/src/narrative/turn-spine.js +73 -0
- package/dist/opencode/build/src/tools/build-universal-bundles.js +8 -0
- package/dist/opencode/build/src/tools/generate-capability-matrix.d.ts +7 -0
- package/dist/opencode/build/src/tools/generate-capability-matrix.js +207 -0
- package/dist/opencode/build/src/tools/validate-source-tree.js +5 -1
- package/dist/opencode/context/scripts/hooks/stop-goal-fit.js +182 -9
- package/dist/opencode/context/scripts/hooks/workflow-steering.js +160 -19
- package/dist/opencode/context/scripts/telemetry/lib/session.sh +3 -0
- package/dist/opencode/context/scripts/telemetry/lib/transport.sh +12 -3
- package/dist/opencode/context/scripts/telemetry/telemetry.sh +480 -59
- package/dist/opencode/docs/context-map.md +4 -0
- package/dist/opencode/docs/decisions/index.md +1 -0
- package/dist/opencode/docs/decisions/writer-observed-execution.md +51 -0
- package/dist/opencode/docs/fixture-ownership.md +5 -1
- package/dist/opencode/docs/migrations.md +20 -0
- package/dist/opencode/docs/public-workflow-cli.md +9 -0
- package/dist/opencode/docs/spec/builder-flow-runtime.md +49 -8
- package/dist/opencode/docs/spec/runtime-hook-surface.md +29 -1
- package/dist/opencode/docs/specs/economics-record-contract.md +1 -1
- package/dist/opencode/docs/specs/harness-capability-matrix.md +63 -21
- package/dist/opencode/docs/workflow-usage-guide.md +4 -1
- package/dist/opencode/evals/ci/run-baseline.sh +38 -0
- package/dist/opencode/evals/fixtures/narrative-evals/README.md +62 -0
- package/dist/opencode/evals/fixtures/narrative-evals/corpus.json +129 -0
- package/dist/opencode/evals/fixtures/narrative-evals/scorer.mjs +522 -0
- package/dist/opencode/evals/fixtures/narrative-grounding-validator/corpus.json +20 -0
- package/dist/opencode/evals/fixtures/narrative-grounding-validator/prompt-injection-adversarial.txt +1 -0
- package/dist/opencode/evals/fixtures/narrative-grounding-validator/prompt-injection-control.txt +1 -0
- package/dist/opencode/evals/fixtures/narrative-grounding-validator/scorer.mjs +201 -0
- package/dist/opencode/evals/fixtures/narrative-prose-renderer/corpus.json +15 -0
- package/dist/opencode/evals/fixtures/narrative-prose-renderer/scorer.mjs +201 -0
- package/dist/opencode/evals/fixtures/narrative-sources/expected-capture-completeness.json +13 -0
- package/dist/opencode/evals/fixtures/narrative-sources/flow/runs/run-fixture/report.json +1 -0
- package/dist/opencode/evals/fixtures/narrative-sources/flow/runs/run-fixture/state.json +1 -0
- package/dist/opencode/evals/fixtures/narrative-sources/flow/runs/run-runtime/state.json +1 -0
- package/dist/opencode/evals/fixtures/narrative-sources/repo/created.txt +1 -0
- package/dist/opencode/evals/fixtures/narrative-sources/repo/fixture.txt +1 -0
- package/dist/opencode/evals/fixtures/narrative-sources/session/agents/agent-fixture/events.jsonl +2 -0
- package/dist/opencode/evals/fixtures/narrative-sources/session/agents/nested-worker/events.jsonl +1 -0
- package/dist/opencode/evals/fixtures/narrative-sources/session/trust.bundle +1 -0
- package/dist/opencode/evals/fixtures/narrative-sources/telemetry/full.jsonl +3 -0
- package/dist/opencode/evals/fixtures/narrative-sources/telemetry/runtime.jsonl +4 -0
- package/dist/opencode/evals/fixtures/narrative-sources/transcripts/session.txt +1 -0
- package/dist/opencode/evals/integration/test_capability_declarations.sh +183 -0
- package/dist/opencode/evals/integration/test_economics_record.sh +42 -0
- package/dist/opencode/evals/integration/test_fixture_retirement_audit.sh +2 -2
- package/dist/opencode/evals/integration/test_gate_review_inquiry_records.sh +42 -35
- package/dist/opencode/evals/integration/test_goal_fit_hook.sh +13 -5
- package/dist/opencode/evals/integration/test_goal_fit_narrative_exclusion.sh +68 -0
- package/dist/opencode/evals/integration/test_narrative_evals.sh +174 -0
- package/dist/opencode/evals/integration/test_narrative_grounded_envelope.sh +280 -0
- package/dist/opencode/evals/integration/test_narrative_grounding_validator.sh +166 -0
- package/dist/opencode/evals/integration/test_narrative_intent_annotation.sh +205 -0
- package/dist/opencode/evals/integration/test_narrative_prose_renderer.sh +239 -0
- package/dist/opencode/evals/integration/test_narrative_redaction_failclosed.sh +120 -0
- package/dist/opencode/evals/integration/test_narrative_runtime_projection.sh +146 -0
- package/dist/opencode/evals/integration/test_narrative_source_contract.sh +228 -0
- package/dist/opencode/evals/integration/test_narrative_trust_isolation.sh +408 -0
- package/dist/opencode/evals/integration/test_plain_stop_messaging.sh +91 -0
- package/dist/opencode/evals/integration/test_session_resume_roundtrip.sh +228 -0
- package/dist/opencode/evals/integration/test_telemetry_action_class.sh +265 -0
- package/dist/opencode/evals/integration/test_telemetry_delegation.sh +291 -0
- package/dist/opencode/evals/integration/test_telemetry_sanitize_usage.sh +155 -0
- package/dist/opencode/evals/integration/test_telemetry_task_slug.sh +158 -0
- package/dist/opencode/evals/integration/test_telemetry_tool_outcome.sh +279 -0
- package/dist/opencode/evals/integration/test_workflow_sidecar_writer.sh +111 -2
- package/dist/opencode/evals/run.sh +12 -0
- package/dist/opencode/evals/static/test_library_exports.sh +5 -0
- package/dist/opencode/install.sh +1 -1
- package/dist/opencode/schemas/grounded-execution-narrative.schema.json +292 -0
- package/dist/opencode/schemas/narrative-eval-result.schema.json +205 -0
- package/dist/opencode/schemas/narrative-runtime-projection.schema.json +134 -0
- package/dist/opencode/schemas/narrative-source-manifest.schema.json +294 -0
- package/dist/opencode/scripts/check-hachure-boundary.mjs +81 -0
- package/dist/opencode/scripts/hooks/stop-goal-fit.js +182 -9
- package/dist/opencode/scripts/hooks/workflow-steering.js +160 -19
- package/dist/opencode/scripts/telemetry/economics-record.schema.json +1 -1
- package/dist/opencode/scripts/telemetry/economics-record.sh +47 -3
- package/dist/opencode/scripts/telemetry/lib/session.sh +3 -0
- package/dist/opencode/scripts/telemetry/lib/transport.sh +12 -3
- package/dist/opencode/scripts/telemetry/telemetry.sh +480 -59
- package/dist/pi/build/generated/capability-declarations.json +177 -0
- package/dist/pi/build/package.json +1 -1
- package/dist/pi/build/src/builder-flow-runtime.d.ts +37 -0
- package/dist/pi/build/src/builder-flow-runtime.js +71 -1
- package/dist/pi/build/src/builder-gate-action-envelope.d.ts +59 -7
- package/dist/pi/build/src/builder-gate-action-envelope.js +163 -30
- package/dist/pi/build/src/builder-lifecycle-authority.d.ts +26 -0
- package/dist/pi/build/src/builder-lifecycle-authority.js +38 -0
- package/dist/pi/build/src/cli/builder-run.js +71 -2
- package/dist/pi/build/src/cli/narrative-render.d.ts +95 -0
- package/dist/pi/build/src/cli/narrative-render.js +466 -0
- package/dist/pi/build/src/cli/narrative-sources.d.ts +2 -0
- package/dist/pi/build/src/cli/narrative-sources.js +282 -0
- package/dist/pi/build/src/cli/public-contracts.d.ts +257 -0
- package/dist/pi/build/src/cli/public-contracts.js +87 -0
- package/dist/pi/build/src/cli/workflow-sidecar.d.ts +28 -12
- package/dist/pi/build/src/cli/workflow-sidecar.js +599 -180
- package/dist/pi/build/src/cli/workflow.js +11 -1
- package/dist/pi/build/src/cli.js +8 -0
- package/dist/pi/build/src/continuation-driver.d.ts +12 -0
- package/dist/pi/build/src/continuation-driver.js +16 -2
- package/dist/pi/build/src/continuation-validation.js +349 -3
- package/dist/pi/build/src/flow-kit/action-metadata.js +21 -1
- package/dist/pi/build/src/index.d.ts +33 -2
- package/dist/pi/build/src/index.js +24 -0
- package/dist/pi/build/src/lib/capability-declarations.d.ts +83 -0
- package/dist/pi/build/src/lib/capability-declarations.js +209 -0
- package/dist/pi/build/src/narrative/envelope.d.ts +111 -0
- package/dist/pi/build/src/narrative/envelope.js +590 -0
- package/dist/pi/build/src/narrative/eval-result.d.ts +60 -0
- package/dist/pi/build/src/narrative/eval-result.js +158 -0
- package/dist/pi/build/src/narrative/grounding-validator.d.ts +104 -0
- package/dist/pi/build/src/narrative/grounding-validator.js +472 -0
- package/dist/pi/build/src/narrative/integrity.d.ts +17 -0
- package/dist/pi/build/src/narrative/integrity.js +39 -0
- package/dist/pi/build/src/narrative/intent-economics.d.ts +42 -0
- package/dist/pi/build/src/narrative/intent-economics.js +82 -0
- package/dist/pi/build/src/narrative/intent.d.ts +94 -0
- package/dist/pi/build/src/narrative/intent.js +132 -0
- package/dist/pi/build/src/narrative/policy-filter.d.ts +15 -0
- package/dist/pi/build/src/narrative/policy-filter.js +58 -0
- package/dist/pi/build/src/narrative/projection.d.ts +58 -0
- package/dist/pi/build/src/narrative/projection.js +502 -0
- package/dist/pi/build/src/narrative/readers.d.ts +84 -0
- package/dist/pi/build/src/narrative/readers.js +406 -0
- package/dist/pi/build/src/narrative/render.d.ts +3 -0
- package/dist/pi/build/src/narrative/render.js +83 -0
- package/dist/pi/build/src/narrative/resolver.d.ts +52 -0
- package/dist/pi/build/src/narrative/resolver.js +190 -0
- package/dist/pi/build/src/narrative/snapshot.d.ts +90 -0
- package/dist/pi/build/src/narrative/snapshot.js +325 -0
- package/dist/pi/build/src/narrative/source-ids.d.ts +121 -0
- package/dist/pi/build/src/narrative/source-ids.js +201 -0
- package/dist/pi/build/src/narrative/statements.d.ts +84 -0
- package/dist/pi/build/src/narrative/statements.js +347 -0
- package/dist/pi/build/src/narrative/turn-spine.d.ts +19 -0
- package/dist/pi/build/src/narrative/turn-spine.js +73 -0
- package/dist/pi/build/src/tools/build-universal-bundles.js +8 -0
- package/dist/pi/build/src/tools/generate-capability-matrix.d.ts +7 -0
- package/dist/pi/build/src/tools/generate-capability-matrix.js +207 -0
- package/dist/pi/build/src/tools/validate-source-tree.js +5 -1
- package/dist/pi/context/scripts/hooks/stop-goal-fit.js +182 -9
- package/dist/pi/context/scripts/hooks/workflow-steering.js +160 -19
- package/dist/pi/context/scripts/telemetry/lib/session.sh +3 -0
- package/dist/pi/context/scripts/telemetry/lib/transport.sh +12 -3
- package/dist/pi/context/scripts/telemetry/telemetry.sh +480 -59
- package/dist/pi/docs/context-map.md +4 -0
- package/dist/pi/docs/decisions/index.md +1 -0
- package/dist/pi/docs/decisions/writer-observed-execution.md +51 -0
- package/dist/pi/docs/fixture-ownership.md +5 -1
- package/dist/pi/docs/migrations.md +20 -0
- package/dist/pi/docs/public-workflow-cli.md +9 -0
- package/dist/pi/docs/spec/builder-flow-runtime.md +49 -8
- package/dist/pi/docs/spec/runtime-hook-surface.md +29 -1
- package/dist/pi/docs/specs/economics-record-contract.md +1 -1
- package/dist/pi/docs/specs/harness-capability-matrix.md +63 -21
- package/dist/pi/docs/workflow-usage-guide.md +4 -1
- package/dist/pi/evals/ci/run-baseline.sh +38 -0
- package/dist/pi/evals/fixtures/narrative-evals/README.md +62 -0
- package/dist/pi/evals/fixtures/narrative-evals/corpus.json +129 -0
- package/dist/pi/evals/fixtures/narrative-evals/scorer.mjs +522 -0
- package/dist/pi/evals/fixtures/narrative-grounding-validator/corpus.json +20 -0
- package/dist/pi/evals/fixtures/narrative-grounding-validator/prompt-injection-adversarial.txt +1 -0
- package/dist/pi/evals/fixtures/narrative-grounding-validator/prompt-injection-control.txt +1 -0
- package/dist/pi/evals/fixtures/narrative-grounding-validator/scorer.mjs +201 -0
- package/dist/pi/evals/fixtures/narrative-prose-renderer/corpus.json +15 -0
- package/dist/pi/evals/fixtures/narrative-prose-renderer/scorer.mjs +201 -0
- package/dist/pi/evals/fixtures/narrative-sources/expected-capture-completeness.json +13 -0
- package/dist/pi/evals/fixtures/narrative-sources/flow/runs/run-fixture/report.json +1 -0
- package/dist/pi/evals/fixtures/narrative-sources/flow/runs/run-fixture/state.json +1 -0
- package/dist/pi/evals/fixtures/narrative-sources/flow/runs/run-runtime/state.json +1 -0
- package/dist/pi/evals/fixtures/narrative-sources/repo/created.txt +1 -0
- package/dist/pi/evals/fixtures/narrative-sources/repo/fixture.txt +1 -0
- package/dist/pi/evals/fixtures/narrative-sources/session/agents/agent-fixture/events.jsonl +2 -0
- package/dist/pi/evals/fixtures/narrative-sources/session/agents/nested-worker/events.jsonl +1 -0
- package/dist/pi/evals/fixtures/narrative-sources/session/trust.bundle +1 -0
- package/dist/pi/evals/fixtures/narrative-sources/telemetry/full.jsonl +3 -0
- package/dist/pi/evals/fixtures/narrative-sources/telemetry/runtime.jsonl +4 -0
- package/dist/pi/evals/fixtures/narrative-sources/transcripts/session.txt +1 -0
- package/dist/pi/evals/integration/test_capability_declarations.sh +183 -0
- package/dist/pi/evals/integration/test_economics_record.sh +42 -0
- package/dist/pi/evals/integration/test_fixture_retirement_audit.sh +2 -2
- package/dist/pi/evals/integration/test_gate_review_inquiry_records.sh +42 -35
- package/dist/pi/evals/integration/test_goal_fit_hook.sh +13 -5
- package/dist/pi/evals/integration/test_goal_fit_narrative_exclusion.sh +68 -0
- package/dist/pi/evals/integration/test_narrative_evals.sh +174 -0
- package/dist/pi/evals/integration/test_narrative_grounded_envelope.sh +280 -0
- package/dist/pi/evals/integration/test_narrative_grounding_validator.sh +166 -0
- package/dist/pi/evals/integration/test_narrative_intent_annotation.sh +205 -0
- package/dist/pi/evals/integration/test_narrative_prose_renderer.sh +239 -0
- package/dist/pi/evals/integration/test_narrative_redaction_failclosed.sh +120 -0
- package/dist/pi/evals/integration/test_narrative_runtime_projection.sh +146 -0
- package/dist/pi/evals/integration/test_narrative_source_contract.sh +228 -0
- package/dist/pi/evals/integration/test_narrative_trust_isolation.sh +408 -0
- package/dist/pi/evals/integration/test_plain_stop_messaging.sh +91 -0
- package/dist/pi/evals/integration/test_session_resume_roundtrip.sh +228 -0
- package/dist/pi/evals/integration/test_telemetry_action_class.sh +265 -0
- package/dist/pi/evals/integration/test_telemetry_delegation.sh +291 -0
- package/dist/pi/evals/integration/test_telemetry_sanitize_usage.sh +155 -0
- package/dist/pi/evals/integration/test_telemetry_task_slug.sh +158 -0
- package/dist/pi/evals/integration/test_telemetry_tool_outcome.sh +279 -0
- package/dist/pi/evals/integration/test_workflow_sidecar_writer.sh +111 -2
- package/dist/pi/evals/run.sh +12 -0
- package/dist/pi/evals/static/test_library_exports.sh +5 -0
- package/dist/pi/install.sh +1 -1
- package/dist/pi/schemas/grounded-execution-narrative.schema.json +292 -0
- package/dist/pi/schemas/narrative-eval-result.schema.json +205 -0
- package/dist/pi/schemas/narrative-runtime-projection.schema.json +134 -0
- package/dist/pi/schemas/narrative-source-manifest.schema.json +294 -0
- package/dist/pi/scripts/check-hachure-boundary.mjs +81 -0
- package/dist/pi/scripts/hooks/stop-goal-fit.js +182 -9
- package/dist/pi/scripts/hooks/workflow-steering.js +160 -19
- package/dist/pi/scripts/telemetry/economics-record.schema.json +1 -1
- package/dist/pi/scripts/telemetry/economics-record.sh +47 -3
- package/dist/pi/scripts/telemetry/lib/session.sh +3 -0
- package/dist/pi/scripts/telemetry/lib/transport.sh +12 -3
- package/dist/pi/scripts/telemetry/telemetry.sh +480 -59
- package/docs/context-map.md +4 -0
- package/docs/decisions/index.md +1 -0
- package/docs/decisions/writer-observed-execution.md +51 -0
- package/docs/fixture-ownership.md +5 -1
- package/docs/migrations.md +20 -0
- package/docs/public-workflow-cli.md +9 -0
- package/docs/spec/builder-flow-runtime.md +49 -8
- package/docs/spec/runtime-hook-surface.md +29 -1
- package/docs/specs/economics-record-contract.md +1 -1
- package/docs/specs/harness-capability-matrix.md +63 -21
- package/docs/workflow-usage-guide.md +4 -1
- package/evals/ci/run-baseline.sh +38 -0
- package/evals/fixtures/narrative-evals/README.md +62 -0
- package/evals/fixtures/narrative-evals/corpus.json +129 -0
- package/evals/fixtures/narrative-evals/scorer.mjs +522 -0
- package/evals/fixtures/narrative-grounding-validator/corpus.json +20 -0
- package/evals/fixtures/narrative-grounding-validator/prompt-injection-adversarial.txt +1 -0
- package/evals/fixtures/narrative-grounding-validator/prompt-injection-control.txt +1 -0
- package/evals/fixtures/narrative-grounding-validator/scorer.mjs +201 -0
- package/evals/fixtures/narrative-prose-renderer/corpus.json +15 -0
- package/evals/fixtures/narrative-prose-renderer/scorer.mjs +201 -0
- package/evals/fixtures/narrative-sources/expected-capture-completeness.json +13 -0
- package/evals/fixtures/narrative-sources/flow/runs/run-fixture/report.json +1 -0
- package/evals/fixtures/narrative-sources/flow/runs/run-fixture/state.json +1 -0
- package/evals/fixtures/narrative-sources/flow/runs/run-runtime/state.json +1 -0
- package/evals/fixtures/narrative-sources/repo/created.txt +1 -0
- package/evals/fixtures/narrative-sources/repo/fixture.txt +1 -0
- package/evals/fixtures/narrative-sources/session/agents/agent-fixture/events.jsonl +2 -0
- package/evals/fixtures/narrative-sources/session/agents/nested-worker/events.jsonl +1 -0
- package/evals/fixtures/narrative-sources/session/trust.bundle +1 -0
- package/evals/fixtures/narrative-sources/telemetry/full.jsonl +3 -0
- package/evals/fixtures/narrative-sources/telemetry/runtime.jsonl +4 -0
- package/evals/fixtures/narrative-sources/transcripts/session.txt +1 -0
- package/evals/integration/test_capability_declarations.sh +183 -0
- package/evals/integration/test_economics_record.sh +42 -0
- package/evals/integration/test_fixture_retirement_audit.sh +2 -2
- package/evals/integration/test_gate_review_inquiry_records.sh +42 -35
- package/evals/integration/test_goal_fit_hook.sh +13 -5
- package/evals/integration/test_goal_fit_narrative_exclusion.sh +68 -0
- package/evals/integration/test_narrative_evals.sh +174 -0
- package/evals/integration/test_narrative_grounded_envelope.sh +280 -0
- package/evals/integration/test_narrative_grounding_validator.sh +166 -0
- package/evals/integration/test_narrative_intent_annotation.sh +205 -0
- package/evals/integration/test_narrative_prose_renderer.sh +239 -0
- package/evals/integration/test_narrative_redaction_failclosed.sh +120 -0
- package/evals/integration/test_narrative_runtime_projection.sh +146 -0
- package/evals/integration/test_narrative_source_contract.sh +228 -0
- package/evals/integration/test_narrative_trust_isolation.sh +408 -0
- package/evals/integration/test_plain_stop_messaging.sh +91 -0
- package/evals/integration/test_session_resume_roundtrip.sh +228 -0
- package/evals/integration/test_telemetry_action_class.sh +265 -0
- package/evals/integration/test_telemetry_delegation.sh +291 -0
- package/evals/integration/test_telemetry_sanitize_usage.sh +155 -0
- package/evals/integration/test_telemetry_task_slug.sh +158 -0
- package/evals/integration/test_telemetry_tool_outcome.sh +279 -0
- package/evals/integration/test_workflow_sidecar_writer.sh +111 -2
- package/evals/run.sh +12 -0
- package/evals/static/test_library_exports.sh +5 -0
- package/package.json +9 -5
- package/schemas/grounded-execution-narrative.schema.json +292 -0
- package/schemas/narrative-eval-result.schema.json +205 -0
- package/schemas/narrative-runtime-projection.schema.json +134 -0
- package/schemas/narrative-source-manifest.schema.json +294 -0
- package/scripts/check-hachure-boundary.mjs +81 -0
- package/scripts/hooks/stop-goal-fit.js +182 -9
- package/scripts/hooks/workflow-steering.js +160 -19
- package/scripts/telemetry/economics-record.schema.json +1 -1
- package/scripts/telemetry/economics-record.sh +47 -3
- package/scripts/telemetry/lib/session.sh +3 -0
- package/scripts/telemetry/lib/transport.sh +12 -3
- package/scripts/telemetry/telemetry.sh +480 -59
- package/src/builder-flow-runtime.ts +102 -1
- package/src/builder-gate-action-envelope.ts +216 -37
- package/src/builder-lifecycle-authority.ts +48 -0
- package/src/cli/builder-flow-runtime.test.mjs +220 -7
- package/src/cli/builder-run.ts +71 -1
- package/src/cli/capability-declarations.test.mjs +117 -0
- package/src/cli/continuation-driver.test.mjs +332 -10
- package/src/cli/kit-metadata-security.test.mjs +90 -2
- package/src/cli/narrative-arch-isolation.test.mjs +198 -0
- package/src/cli/narrative-envelope.test.mjs +367 -0
- package/src/cli/narrative-grounding-validator.test.mjs +322 -0
- package/src/cli/narrative-intent.test.mjs +177 -0
- package/src/cli/narrative-policy-filter.test.mjs +66 -0
- package/src/cli/narrative-projection.test.mjs +236 -0
- package/src/cli/narrative-readers.test.mjs +196 -0
- package/src/cli/narrative-render.test.mjs +221 -0
- package/src/cli/narrative-render.ts +589 -0
- package/src/cli/narrative-resolver.test.mjs +114 -0
- package/src/cli/narrative-snapshot.test.mjs +149 -0
- package/src/cli/narrative-source-ids.test.mjs +84 -0
- package/src/cli/narrative-sources.ts +276 -0
- package/src/cli/narrative-statements.test.mjs +369 -0
- package/src/cli/narrative-turn-spine.test.mjs +74 -0
- package/src/cli/public-api.test.mjs +17 -0
- package/src/cli/public-contracts.ts +95 -0
- package/src/cli/sidecar-pure-helpers.test.mjs +216 -24
- package/src/cli/trust-bundle-policy-order.test.mjs +134 -1
- package/src/cli/workflow-sidecar.ts +563 -167
- package/src/cli/workflow.ts +15 -1
- package/src/cli/writer-observed-execution.test.mjs +102 -0
- package/src/cli.ts +8 -0
- package/src/continuation-driver.ts +32 -3
- package/src/continuation-validation.ts +362 -4
- package/src/flow-kit/action-metadata.ts +20 -1
- package/src/index.ts +241 -0
- package/src/lib/capability-declarations.ts +261 -0
- package/src/narrative/envelope.ts +624 -0
- package/src/narrative/eval-result.ts +175 -0
- package/src/narrative/grounding-validator.ts +610 -0
- package/src/narrative/integrity.ts +53 -0
- package/src/narrative/intent-economics.ts +119 -0
- package/src/narrative/intent.ts +216 -0
- package/src/narrative/policy-filter.ts +66 -0
- package/src/narrative/projection.ts +530 -0
- package/src/narrative/readers.ts +427 -0
- package/src/narrative/render.ts +82 -0
- package/src/narrative/resolver.ts +195 -0
- package/src/narrative/snapshot.ts +365 -0
- package/src/narrative/source-ids.ts +294 -0
- package/src/narrative/statements.ts +423 -0
- package/src/narrative/turn-spine.ts +99 -0
- package/src/tools/build-universal-bundles.ts +8 -0
- package/src/tools/generate-capability-matrix.ts +215 -0
- package/src/tools/validate-source-tree.ts +5 -1
- package/build/src/cli/sidecar-claim-explain.d.ts +0 -45
- package/build/src/cli/sidecar-claim-explain.js +0 -87
- package/dist/base/build/src/cli/sidecar-claim-explain.d.ts +0 -45
- package/dist/base/build/src/cli/sidecar-claim-explain.js +0 -87
- package/dist/claude-code/build/src/cli/sidecar-claim-explain.d.ts +0 -45
- package/dist/claude-code/build/src/cli/sidecar-claim-explain.js +0 -87
- package/dist/codex/build/src/cli/sidecar-claim-explain.d.ts +0 -45
- package/dist/codex/build/src/cli/sidecar-claim-explain.js +0 -87
- package/dist/kiro/build/src/cli/sidecar-claim-explain.d.ts +0 -45
- package/dist/kiro/build/src/cli/sidecar-claim-explain.js +0 -87
- package/dist/opencode/build/src/cli/sidecar-claim-explain.d.ts +0 -45
- package/dist/opencode/build/src/cli/sidecar-claim-explain.js +0 -87
- package/dist/pi/build/src/cli/sidecar-claim-explain.d.ts +0 -45
- package/dist/pi/build/src/cli/sidecar-claim-explain.js +0 -87
- package/src/cli/sidecar-claim-explain.ts +0 -130
|
@@ -0,0 +1,466 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import * as fs from "node:fs";
|
|
3
|
+
import * as http from "node:http";
|
|
4
|
+
import * as https from "node:https";
|
|
5
|
+
import * as path from "node:path";
|
|
6
|
+
import { ensureSafeDirectory } from "../lib/fs.js";
|
|
7
|
+
import { flagString, parseArgs } from "../lib/args.js";
|
|
8
|
+
import { composeGroundedNarrative, validateGroundedNarrative, writeEnvelope, } from "../narrative/envelope.js";
|
|
9
|
+
import { NarrativeGroundingError, validateNarrativeGrounding, } from "../narrative/grounding-validator.js";
|
|
10
|
+
import { stableStringify } from "../narrative/projection.js";
|
|
11
|
+
import { resolveSource } from "../narrative/resolver.js";
|
|
12
|
+
import { parseSourceId } from "../narrative/source-ids.js";
|
|
13
|
+
import { summarizerInferredConnective } from "../narrative/statements.js";
|
|
14
|
+
export const PROSE_PROMPT_VERSION = "narrative-prose-renderer/v1";
|
|
15
|
+
export const PROSE_ECONOMICS_FILE = "prose-economics.jsonl";
|
|
16
|
+
function sha256(bytes) {
|
|
17
|
+
return createHash("sha256").update(bytes).digest("hex");
|
|
18
|
+
}
|
|
19
|
+
// ── Deterministic hermetic stub generator (CI default, D5) ──────────────────
|
|
20
|
+
//
|
|
21
|
+
// Emits one connective sentence per atomic (observed/deterministic_derived)
|
|
22
|
+
// statement, quoting its proposition verbatim and citing exactly that
|
|
23
|
+
// statement's own source_refs. This is deliberately unable to omit a failure
|
|
24
|
+
// or relabel an outcome: it never invents text beyond the frozen statement
|
|
25
|
+
// set, so R2 (inherited-never-upgraded), R3 (counterevidence preservation),
|
|
26
|
+
// and D3 (citation provenance-subset) all hold trivially for its output.
|
|
27
|
+
const STUB_IDENTITY = { model: "deterministic-stub", provider: "local-stub", config_hash: "stub-v1" };
|
|
28
|
+
function estimateTokens(text) {
|
|
29
|
+
return Math.max(1, Math.ceil(text.length / 4));
|
|
30
|
+
}
|
|
31
|
+
export const stubGenerator = {
|
|
32
|
+
identity: STUB_IDENTITY,
|
|
33
|
+
async generate(input) {
|
|
34
|
+
const atomic = input.statements.filter((statement) => statement.class === "observed" || statement.class === "deterministic_derived");
|
|
35
|
+
// Deliberately does NOT restate the atomic proposition's outcome verbs (observed/
|
|
36
|
+
// passed/failed/succeeded/timed out/created, etc.) -- grounding-validator.ts's dormant
|
|
37
|
+
// epistemic backstop (isAssertionProhibited) bans summarizer_inferred statements from
|
|
38
|
+
// asserting observed_outcome-shaped language even when quoted, by design (#623). A
|
|
39
|
+
// purely referential connective sentence still satisfies D3's citation-subset contract
|
|
40
|
+
// (it carries the atomic statement's own real fa1 refs) without laundering the claim.
|
|
41
|
+
const sentences = atomic.map((statement) => ({
|
|
42
|
+
text: `The frozen record includes statement \`${statement.id}\`, grounded in ${statement.source_refs.length} cited source(s).`,
|
|
43
|
+
statement_refs: [...statement.source_refs],
|
|
44
|
+
}));
|
|
45
|
+
const inputChars = input.statements.reduce((total, statement) => total + statement.proposition.length, 0)
|
|
46
|
+
+ input.sourceViews.reduce((total, view) => total + view.content.length, 0);
|
|
47
|
+
const outputChars = sentences.reduce((total, sentence) => total + sentence.text.length, 0);
|
|
48
|
+
return {
|
|
49
|
+
sentences,
|
|
50
|
+
usage: { input_tokens: estimateTokens("x".repeat(inputChars)), output_tokens: estimateTokens("x".repeat(Math.max(outputChars, 1))) },
|
|
51
|
+
};
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
function parseUrl(value) {
|
|
55
|
+
try {
|
|
56
|
+
return new URL(value);
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function isLocalHostname(hostname) {
|
|
63
|
+
return hostname === "localhost" || hostname === "127.0.0.1" || hostname === "::1" || hostname.endsWith(".localhost");
|
|
64
|
+
}
|
|
65
|
+
function nonEmpty(value) {
|
|
66
|
+
return typeof value === "string" && value.length > 0;
|
|
67
|
+
}
|
|
68
|
+
export function providerAllowed(config, endpoint) {
|
|
69
|
+
if (!endpoint || endpoint.includes("\n") || endpoint.includes("\r") || endpoint.includes('"'))
|
|
70
|
+
return false;
|
|
71
|
+
const url = parseUrl(endpoint);
|
|
72
|
+
if (!url)
|
|
73
|
+
return false;
|
|
74
|
+
if (url.username || url.password)
|
|
75
|
+
return false;
|
|
76
|
+
if (url.protocol !== "http:" && url.protocol !== "https:")
|
|
77
|
+
return false;
|
|
78
|
+
if (isLocalHostname(url.hostname))
|
|
79
|
+
return true;
|
|
80
|
+
const optIn = config.optIn;
|
|
81
|
+
return Boolean(optIn && nonEmpty(optIn.tenant) && nonEmpty(optIn.data_residency) && nonEmpty(optIn.payload_policy));
|
|
82
|
+
}
|
|
83
|
+
export class ProviderNotAllowedError extends Error {
|
|
84
|
+
endpoint;
|
|
85
|
+
name = "ProviderNotAllowedError";
|
|
86
|
+
constructor(endpoint) {
|
|
87
|
+
super(`generator endpoint is not allowed without opt-in (declared tenant/data_residency/payload_policy): ${endpoint}`);
|
|
88
|
+
this.endpoint = endpoint;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
function coerceGeneratedProse(raw) {
|
|
92
|
+
const sentences = Array.isArray(raw.sentences)
|
|
93
|
+
? raw.sentences
|
|
94
|
+
.map((sentence) => ({
|
|
95
|
+
text: typeof sentence?.text === "string" ? sentence.text : "",
|
|
96
|
+
statement_refs: Array.isArray(sentence?.statement_refs)
|
|
97
|
+
? sentence.statement_refs.filter((ref) => typeof ref === "string")
|
|
98
|
+
: [],
|
|
99
|
+
}))
|
|
100
|
+
.filter((sentence) => sentence.text.length > 0)
|
|
101
|
+
: [];
|
|
102
|
+
const inputTokens = Number.isSafeInteger(raw.usage?.input_tokens) ? raw.usage.input_tokens : 0;
|
|
103
|
+
const outputTokens = Number.isSafeInteger(raw.usage?.output_tokens) ? raw.usage.output_tokens : 0;
|
|
104
|
+
return { sentences, usage: { input_tokens: inputTokens, output_tokens: outputTokens } };
|
|
105
|
+
}
|
|
106
|
+
/** The ONLY place a socket may be opened; callers must run providerAllowed() first. */
|
|
107
|
+
function callGeneratorEndpoint(endpoint, payload, timeoutMs) {
|
|
108
|
+
return new Promise((resolve, reject) => {
|
|
109
|
+
const url = parseUrl(endpoint);
|
|
110
|
+
if (!url) {
|
|
111
|
+
reject(new Error("generator endpoint URL is malformed"));
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
const client = url.protocol === "https:" ? https : http;
|
|
115
|
+
const body = Buffer.from(JSON.stringify(payload), "utf8");
|
|
116
|
+
let settled = false;
|
|
117
|
+
const req = client.request(url, {
|
|
118
|
+
method: "POST",
|
|
119
|
+
timeout: timeoutMs,
|
|
120
|
+
headers: { "content-type": "application/json", "content-length": String(body.length) },
|
|
121
|
+
}, (res) => {
|
|
122
|
+
const chunks = [];
|
|
123
|
+
res.on("data", (chunk) => chunks.push(chunk));
|
|
124
|
+
res.on("end", () => {
|
|
125
|
+
if (settled)
|
|
126
|
+
return;
|
|
127
|
+
settled = true;
|
|
128
|
+
try {
|
|
129
|
+
if (!res.statusCode || res.statusCode >= 300)
|
|
130
|
+
throw new Error(`generator endpoint responded with status ${res.statusCode}`);
|
|
131
|
+
resolve(JSON.parse(Buffer.concat(chunks).toString("utf8")));
|
|
132
|
+
}
|
|
133
|
+
catch (error) {
|
|
134
|
+
reject(error instanceof Error ? error : new Error("malformed generator response"));
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
req.on("timeout", () => {
|
|
139
|
+
if (settled)
|
|
140
|
+
return;
|
|
141
|
+
settled = true;
|
|
142
|
+
req.destroy();
|
|
143
|
+
reject(new Error(`generator endpoint timed out after ${timeoutMs}ms`));
|
|
144
|
+
});
|
|
145
|
+
req.on("error", (error) => {
|
|
146
|
+
if (settled)
|
|
147
|
+
return;
|
|
148
|
+
settled = true;
|
|
149
|
+
reject(error);
|
|
150
|
+
});
|
|
151
|
+
req.end(body);
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
function generatorConfigHash(config) {
|
|
155
|
+
return sha256(stableStringify(config));
|
|
156
|
+
}
|
|
157
|
+
/** Local-first default real path (D5): an operator-configured local model server. */
|
|
158
|
+
export function localModelGenerator(config) {
|
|
159
|
+
const endpoint = config.endpoint ?? "http://127.0.0.1:11434/api/generate";
|
|
160
|
+
return {
|
|
161
|
+
identity: { model: config.model, provider: config.provider || "local", config_hash: generatorConfigHash(config) },
|
|
162
|
+
async generate(input) {
|
|
163
|
+
if (!providerAllowed(config, endpoint))
|
|
164
|
+
throw new ProviderNotAllowedError(endpoint);
|
|
165
|
+
const raw = await callGeneratorEndpoint(endpoint, input, config.timeoutMs ?? 10_000);
|
|
166
|
+
return coerceGeneratedProse(raw);
|
|
167
|
+
},
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
/** Hosted path (D5/R6/AC8): inert without EXPLICIT opt-in; never dials without it. */
|
|
171
|
+
export function hostedModelGenerator(config) {
|
|
172
|
+
return {
|
|
173
|
+
identity: { model: config.model, provider: config.provider, config_hash: generatorConfigHash(config) },
|
|
174
|
+
async generate(input) {
|
|
175
|
+
const endpoint = config.endpoint;
|
|
176
|
+
if (!endpoint || !providerAllowed(config, endpoint))
|
|
177
|
+
throw new ProviderNotAllowedError(endpoint ?? "(missing endpoint)");
|
|
178
|
+
const raw = await callGeneratorEndpoint(endpoint, input, config.timeoutMs ?? 10_000);
|
|
179
|
+
return coerceGeneratedProse(raw);
|
|
180
|
+
},
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
// ── Fail-closed orchestrator (D4) ────────────────────────────────────────────
|
|
184
|
+
export class GeneratorTimeoutError extends Error {
|
|
185
|
+
name = "GeneratorTimeoutError";
|
|
186
|
+
}
|
|
187
|
+
function withTimeout(factory, timeoutMs) {
|
|
188
|
+
return new Promise((resolve, reject) => {
|
|
189
|
+
let settled = false;
|
|
190
|
+
const timer = setTimeout(() => {
|
|
191
|
+
if (settled)
|
|
192
|
+
return;
|
|
193
|
+
settled = true;
|
|
194
|
+
reject(new GeneratorTimeoutError(`generator exceeded ${timeoutMs}ms`));
|
|
195
|
+
}, timeoutMs);
|
|
196
|
+
Promise.resolve().then(factory).then((value) => {
|
|
197
|
+
if (settled)
|
|
198
|
+
return;
|
|
199
|
+
settled = true;
|
|
200
|
+
clearTimeout(timer);
|
|
201
|
+
resolve(value);
|
|
202
|
+
}, (error) => {
|
|
203
|
+
if (settled)
|
|
204
|
+
return;
|
|
205
|
+
settled = true;
|
|
206
|
+
clearTimeout(timer);
|
|
207
|
+
reject(error);
|
|
208
|
+
});
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
function runtimeStatements(envelope) {
|
|
212
|
+
const runtime = envelope.sections.find((section) => section.authority === "flow-agents" && section.kind === "runtime-projection");
|
|
213
|
+
if (!runtime || runtime.authority !== "flow-agents")
|
|
214
|
+
throw new Error("narrative prose renderer requires one runtime projection section");
|
|
215
|
+
return [...runtime.embedded.turns.flatMap((turn) => turn.statements), ...runtime.embedded.document_statements];
|
|
216
|
+
}
|
|
217
|
+
function augmentWithSummaryStatements(envelope, extra) {
|
|
218
|
+
const clone = structuredClone(envelope);
|
|
219
|
+
const runtime = clone.sections.find((section) => section.authority === "flow-agents" && section.kind === "runtime-projection");
|
|
220
|
+
if (!runtime || runtime.authority !== "flow-agents")
|
|
221
|
+
throw new Error("narrative prose renderer requires one runtime projection section");
|
|
222
|
+
runtime.embedded.document_statements = [...runtime.embedded.document_statements, ...extra];
|
|
223
|
+
return clone;
|
|
224
|
+
}
|
|
225
|
+
function buildSourceViews(narrativeDir, statements) {
|
|
226
|
+
const refs = [...new Set(statements.flatMap((statement) => statement.source_refs))].sort();
|
|
227
|
+
const views = [];
|
|
228
|
+
for (const sourceRef of refs) {
|
|
229
|
+
const resolved = resolveSource(narrativeDir, sourceRef);
|
|
230
|
+
if (resolved.status !== "resolved")
|
|
231
|
+
continue;
|
|
232
|
+
let stream = "unknown";
|
|
233
|
+
try {
|
|
234
|
+
stream = parseSourceId(sourceRef).stream;
|
|
235
|
+
}
|
|
236
|
+
catch { /* best-effort label only */ }
|
|
237
|
+
views.push({ source_ref: sourceRef, stream, content: Buffer.from(resolved.content).toString("utf8") });
|
|
238
|
+
}
|
|
239
|
+
return views;
|
|
240
|
+
}
|
|
241
|
+
function summarizeViolation(violation) {
|
|
242
|
+
const parts = [violation.code];
|
|
243
|
+
if ("statement_id" in violation)
|
|
244
|
+
parts.push(violation.statement_id);
|
|
245
|
+
if ("source_ref" in violation)
|
|
246
|
+
parts.push(violation.source_ref);
|
|
247
|
+
if ("event_kind" in violation)
|
|
248
|
+
parts.push(violation.event_kind);
|
|
249
|
+
return parts.join(" ");
|
|
250
|
+
}
|
|
251
|
+
const ESTIMATED_COST_PER_1K_INPUT_TOKENS_USD = 0.0005;
|
|
252
|
+
const ESTIMATED_COST_PER_1K_OUTPUT_TOKENS_USD = 0.0015;
|
|
253
|
+
function estimateCost(usage) {
|
|
254
|
+
const cost = (usage.input_tokens / 1000) * ESTIMATED_COST_PER_1K_INPUT_TOKENS_USD
|
|
255
|
+
+ (usage.output_tokens / 1000) * ESTIMATED_COST_PER_1K_OUTPUT_TOKENS_USD;
|
|
256
|
+
return Math.round(cost * 1_000_000) / 1_000_000;
|
|
257
|
+
}
|
|
258
|
+
// Append-only local sink, mirroring writeEnvelope's envelope-lineage.jsonl discipline
|
|
259
|
+
// (O_APPEND|O_CREAT|O_WRONLY, mode 0600, no-follow). Recorded UNCONDITIONALLY on every
|
|
260
|
+
// generation attempt -- success or fallback (D6/AC6) -- and NEVER leaves narrativeDir.
|
|
261
|
+
function appendEconomics(narrativeDir, record) {
|
|
262
|
+
const file = path.join(narrativeDir, PROSE_ECONOMICS_FILE);
|
|
263
|
+
if (fs.existsSync(file)) {
|
|
264
|
+
const stat = fs.lstatSync(file);
|
|
265
|
+
if (stat.isSymbolicLink() || !stat.isFile())
|
|
266
|
+
throw new Error(`refusing unsafe economics target at ${file}`);
|
|
267
|
+
}
|
|
268
|
+
const noFollow = typeof fs.constants.O_NOFOLLOW === "number" ? fs.constants.O_NOFOLLOW : 0;
|
|
269
|
+
const descriptor = fs.openSync(file, fs.constants.O_APPEND | fs.constants.O_CREAT | fs.constants.O_WRONLY | noFollow, 0o600);
|
|
270
|
+
try {
|
|
271
|
+
fs.writeSync(descriptor, `${JSON.stringify(record)}\n`, undefined, "utf8");
|
|
272
|
+
}
|
|
273
|
+
finally {
|
|
274
|
+
fs.closeSync(descriptor);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Fail-closed orchestrator (D4/LB1). The #613/#623 compose -> schema-validate ->
|
|
279
|
+
* grounding-validate prefix is unchanged and still throws before ANY write on a
|
|
280
|
+
* malformed/ungrounded envelope (nothing to attempt generation over). Once that
|
|
281
|
+
* substrate is valid, the deterministic #613 output is ALWAYS written first (R4's
|
|
282
|
+
* guarantee), then generation is attempted under a bounded timeout. ANY
|
|
283
|
+
* generator error/timeout/validator error/reject leaves ZERO prose artifacts and
|
|
284
|
+
* records economics for the attempt; only an accepted, re-validated, prose-augmented
|
|
285
|
+
* statement set is published alongside the deterministic narrative.
|
|
286
|
+
*/
|
|
287
|
+
export async function renderProse(narrativeDir, opts) {
|
|
288
|
+
const envelope = composeGroundedNarrative(narrativeDir, { compiledAt: opts.compiledAt });
|
|
289
|
+
const schemaIssues = validateGroundedNarrative(envelope);
|
|
290
|
+
if (schemaIssues.length > 0) {
|
|
291
|
+
throw new Error(`grounded execution narrative validation failed: ${schemaIssues.map((issue) => `${issue.path} ${issue.message}`).join("; ")}`);
|
|
292
|
+
}
|
|
293
|
+
const baseGrounding = validateNarrativeGrounding(envelope, narrativeDir);
|
|
294
|
+
if (!baseGrounding.ok)
|
|
295
|
+
throw new NarrativeGroundingError(baseGrounding.violations);
|
|
296
|
+
const written = writeEnvelope(narrativeDir, envelope, { outDir: opts.outDir, render: true });
|
|
297
|
+
const statements = runtimeStatements(envelope);
|
|
298
|
+
const sourceViews = buildSourceViews(narrativeDir, statements);
|
|
299
|
+
const generatorInput = { statements, sourceViews };
|
|
300
|
+
const sourceHash = sha256(stableStringify(generatorInput));
|
|
301
|
+
const attemptedAt = new Date().toISOString();
|
|
302
|
+
const startedAt = process.hrtime.bigint();
|
|
303
|
+
const timeoutMs = opts.timeoutMs ?? 15_000;
|
|
304
|
+
const elapsedMs = () => Number((process.hrtime.bigint() - startedAt) / 1000000n);
|
|
305
|
+
const recordAndFallback = (outcome, detail, usage, outputBytes) => {
|
|
306
|
+
const provenance = {
|
|
307
|
+
...opts.generator.identity,
|
|
308
|
+
prompt_version: PROSE_PROMPT_VERSION,
|
|
309
|
+
input_tokens: usage.input_tokens,
|
|
310
|
+
output_tokens: usage.output_tokens,
|
|
311
|
+
estimated_cost_usd: estimateCost(usage),
|
|
312
|
+
wall_clock_ms: elapsedMs(),
|
|
313
|
+
verdicts: [],
|
|
314
|
+
source_hash: sourceHash,
|
|
315
|
+
output_hash: sha256(outputBytes),
|
|
316
|
+
attempted_at: attemptedAt,
|
|
317
|
+
outcome,
|
|
318
|
+
detail,
|
|
319
|
+
};
|
|
320
|
+
appendEconomics(narrativeDir, provenance);
|
|
321
|
+
return { envelope, written, outcome: "deterministic_only", reason: detail, provenance };
|
|
322
|
+
};
|
|
323
|
+
let generated;
|
|
324
|
+
try {
|
|
325
|
+
generated = await withTimeout(() => opts.generator.generate(generatorInput), timeoutMs);
|
|
326
|
+
}
|
|
327
|
+
catch (error) {
|
|
328
|
+
const isTimeout = error instanceof GeneratorTimeoutError;
|
|
329
|
+
return recordAndFallback(isTimeout ? "generator_timeout" : "generator_error", error instanceof Error ? error.message : "generator failed", { input_tokens: 0, output_tokens: 0 }, "");
|
|
330
|
+
}
|
|
331
|
+
const outputBytes = stableStringify(generated);
|
|
332
|
+
let summaryStatements;
|
|
333
|
+
let augmented;
|
|
334
|
+
try {
|
|
335
|
+
summaryStatements = generated.sentences.map((sentence, index) => summarizerInferredConnective({
|
|
336
|
+
id: `${written.envelopeSha256.slice(0, 12)}-prose-${index}`,
|
|
337
|
+
proposition: sentence.text,
|
|
338
|
+
source_refs: [...new Set(sentence.statement_refs)],
|
|
339
|
+
}));
|
|
340
|
+
augmented = augmentWithSummaryStatements(envelope, summaryStatements);
|
|
341
|
+
}
|
|
342
|
+
catch (error) {
|
|
343
|
+
return recordAndFallback("validator_error", error instanceof Error ? error.message : "summary statement construction failed", generated.usage, outputBytes);
|
|
344
|
+
}
|
|
345
|
+
let proseGrounding;
|
|
346
|
+
try {
|
|
347
|
+
proseGrounding = validateNarrativeGrounding(augmented, narrativeDir);
|
|
348
|
+
}
|
|
349
|
+
catch (error) {
|
|
350
|
+
return recordAndFallback("validator_error", error instanceof Error ? error.message : "grounding validator raised", generated.usage, outputBytes);
|
|
351
|
+
}
|
|
352
|
+
if (!proseGrounding.ok) {
|
|
353
|
+
return recordAndFallback("validator_reject", proseGrounding.violations.map(summarizeViolation).join("; "), generated.usage, outputBytes);
|
|
354
|
+
}
|
|
355
|
+
// Accept: publish the prose artifact ALONGSIDE (never instead of) the deterministic
|
|
356
|
+
// narrative. Content-addressed, wx create-only -- same discipline as writeEnvelope.
|
|
357
|
+
const prosePayload = { statements: summaryStatements, sentences: generated.sentences };
|
|
358
|
+
const proseBytes = Buffer.from(`${stableStringify(prosePayload)}\n`);
|
|
359
|
+
const proseSha256 = sha256(proseBytes);
|
|
360
|
+
const proseDir = path.resolve(opts.outDir);
|
|
361
|
+
ensureSafeDirectory(proseDir, proseDir);
|
|
362
|
+
const prosePath = path.join(proseDir, `${written.envelopeSha256}.prose.json`);
|
|
363
|
+
try {
|
|
364
|
+
fs.writeFileSync(prosePath, proseBytes, { flag: "wx" });
|
|
365
|
+
}
|
|
366
|
+
catch (error) {
|
|
367
|
+
if (error.code !== "EEXIST")
|
|
368
|
+
throw error;
|
|
369
|
+
const stat = fs.lstatSync(prosePath);
|
|
370
|
+
if (stat.isSymbolicLink() || !stat.isFile())
|
|
371
|
+
throw new Error(`refusing unsafe prose target at ${prosePath}`);
|
|
372
|
+
const existing = fs.readFileSync(prosePath);
|
|
373
|
+
if (!existing.equals(proseBytes))
|
|
374
|
+
throw new Error(`content-addressed prose artifact collision at ${prosePath}`);
|
|
375
|
+
}
|
|
376
|
+
const provenance = {
|
|
377
|
+
...opts.generator.identity,
|
|
378
|
+
prompt_version: PROSE_PROMPT_VERSION,
|
|
379
|
+
input_tokens: generated.usage.input_tokens,
|
|
380
|
+
output_tokens: generated.usage.output_tokens,
|
|
381
|
+
estimated_cost_usd: estimateCost(generated.usage),
|
|
382
|
+
wall_clock_ms: elapsedMs(),
|
|
383
|
+
verdicts: [],
|
|
384
|
+
source_hash: sourceHash,
|
|
385
|
+
output_hash: proseSha256,
|
|
386
|
+
attempted_at: attemptedAt,
|
|
387
|
+
outcome: "accepted",
|
|
388
|
+
};
|
|
389
|
+
appendEconomics(narrativeDir, provenance);
|
|
390
|
+
return { envelope, written, outcome: "prose_published", prose: { path: prosePath, sha256: proseSha256 }, provenance };
|
|
391
|
+
}
|
|
392
|
+
// ── CLI verb ──────────────────────────────────────────────────────────────
|
|
393
|
+
function usage() {
|
|
394
|
+
console.error(`usage: flow-agents narrative-render <render> [options]
|
|
395
|
+
|
|
396
|
+
render:
|
|
397
|
+
--narrative-dir PATH --compiled-at DATE-TIME --out-dir DIR
|
|
398
|
+
[--generator stub|local|hosted] (default: stub)
|
|
399
|
+
[--timeout-ms N] (default: 15000)
|
|
400
|
+
[--model NAME] [--provider NAME] [--endpoint URL]
|
|
401
|
+
[--opt-in-tenant ID --opt-in-data-residency REGION --opt-in-payload-policy POLICY]
|
|
402
|
+
(required together to allow a non-local --endpoint; local endpoints never need opt-in)`);
|
|
403
|
+
}
|
|
404
|
+
function required(flags, name) {
|
|
405
|
+
const value = flagString(flags, name);
|
|
406
|
+
if (!value)
|
|
407
|
+
throw new Error(`--${name} is required`);
|
|
408
|
+
return value;
|
|
409
|
+
}
|
|
410
|
+
function buildGenerator(flags) {
|
|
411
|
+
const kind = flagString(flags, "generator", "stub");
|
|
412
|
+
if (kind === "stub" || !kind)
|
|
413
|
+
return stubGenerator;
|
|
414
|
+
if (kind !== "local" && kind !== "hosted")
|
|
415
|
+
throw new Error(`unknown --generator: ${kind}`);
|
|
416
|
+
const model = flagString(flags, "model") ?? "unconfigured-model";
|
|
417
|
+
const provider = flagString(flags, "provider") ?? kind;
|
|
418
|
+
const endpoint = flagString(flags, "endpoint");
|
|
419
|
+
const timeoutRaw = flagString(flags, "timeout-ms");
|
|
420
|
+
const timeoutMs = timeoutRaw ? Number.parseInt(timeoutRaw, 10) : undefined;
|
|
421
|
+
const tenant = flagString(flags, "opt-in-tenant");
|
|
422
|
+
const dataResidency = flagString(flags, "opt-in-data-residency");
|
|
423
|
+
const payloadPolicy = flagString(flags, "opt-in-payload-policy");
|
|
424
|
+
const optIn = tenant && dataResidency && payloadPolicy ? { tenant, data_residency: dataResidency, payload_policy: payloadPolicy } : undefined;
|
|
425
|
+
const config = {
|
|
426
|
+
model, provider,
|
|
427
|
+
...(endpoint ? { endpoint } : {}),
|
|
428
|
+
...(optIn ? { optIn } : {}),
|
|
429
|
+
...(timeoutMs !== undefined && Number.isFinite(timeoutMs) ? { timeoutMs } : {}),
|
|
430
|
+
};
|
|
431
|
+
return kind === "local" ? localModelGenerator(config) : hostedModelGenerator(config);
|
|
432
|
+
}
|
|
433
|
+
async function render(flags) {
|
|
434
|
+
const narrativeDir = required(flags, "narrative-dir");
|
|
435
|
+
const compiledAt = required(flags, "compiled-at");
|
|
436
|
+
const outDir = required(flags, "out-dir");
|
|
437
|
+
const generator = buildGenerator(flags);
|
|
438
|
+
const timeoutRaw = flagString(flags, "timeout-ms");
|
|
439
|
+
const timeoutMs = timeoutRaw ? Number.parseInt(timeoutRaw, 10) : undefined;
|
|
440
|
+
const result = await renderProse(narrativeDir, {
|
|
441
|
+
compiledAt, outDir, generator,
|
|
442
|
+
...(timeoutMs !== undefined && Number.isFinite(timeoutMs) ? { timeoutMs } : {}),
|
|
443
|
+
});
|
|
444
|
+
process.stdout.write(`${stableStringify({
|
|
445
|
+
outcome: result.outcome,
|
|
446
|
+
reason: result.reason,
|
|
447
|
+
envelope_sha256: result.written.envelopeSha256,
|
|
448
|
+
prose: result.prose,
|
|
449
|
+
provenance: result.provenance,
|
|
450
|
+
})}\n`);
|
|
451
|
+
return result.outcome === "prose_published" ? 0 : (result.outcome === "deterministic_only" ? 0 : 1);
|
|
452
|
+
}
|
|
453
|
+
export async function main(argv = process.argv.slice(2)) {
|
|
454
|
+
const args = parseArgs(argv);
|
|
455
|
+
const verb = args.positionals[0];
|
|
456
|
+
try {
|
|
457
|
+
if (verb === "render")
|
|
458
|
+
return await render(args.flags);
|
|
459
|
+
usage();
|
|
460
|
+
return 64;
|
|
461
|
+
}
|
|
462
|
+
catch (error) {
|
|
463
|
+
console.error(error instanceof Error ? error.message : "narrative render command failed");
|
|
464
|
+
return 64;
|
|
465
|
+
}
|
|
466
|
+
}
|