@tangle-network/browser-agent-driver 0.33.2 → 0.34.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/README.md +42 -1
- package/discovery/llms.txt +27 -0
- package/discovery/tangle-agent.json +36 -0
- package/dist/brain/action-parse.d.ts +16 -0
- package/dist/brain/action-parse.d.ts.map +1 -0
- package/dist/brain/action-parse.js +191 -0
- package/dist/brain/action-parse.js.map +1 -0
- package/dist/brain/decide.d.ts +58 -0
- package/dist/brain/decide.d.ts.map +1 -0
- package/dist/brain/decide.js +418 -0
- package/dist/brain/decide.js.map +1 -0
- package/dist/brain/history-compact.d.ts +19 -0
- package/dist/brain/history-compact.d.ts.map +1 -0
- package/dist/brain/history-compact.js +153 -0
- package/dist/brain/history-compact.js.map +1 -0
- package/dist/brain/index.d.ts +78 -152
- package/dist/brain/index.d.ts.map +1 -1
- package/dist/brain/index.js +62 -2268
- package/dist/brain/index.js.map +1 -1
- package/dist/brain/model-client.d.ts +101 -0
- package/dist/brain/model-client.d.ts.map +1 -0
- package/dist/brain/model-client.js +391 -0
- package/dist/brain/model-client.js.map +1 -0
- package/dist/brain/plan.d.ts +57 -0
- package/dist/brain/plan.d.ts.map +1 -0
- package/dist/brain/plan.js +194 -0
- package/dist/brain/plan.js.map +1 -0
- package/dist/brain/prompts.d.ts +37 -0
- package/dist/brain/prompts.d.ts.map +1 -0
- package/dist/brain/prompts.js +455 -0
- package/dist/brain/prompts.js.map +1 -0
- package/dist/brain/provider-fetch.d.ts +26 -0
- package/dist/brain/provider-fetch.d.ts.map +1 -0
- package/dist/brain/provider-fetch.js +45 -0
- package/dist/brain/provider-fetch.js.map +1 -0
- package/dist/brain/snapshot-budget.d.ts +20 -0
- package/dist/brain/snapshot-budget.d.ts.map +1 -0
- package/dist/brain/snapshot-budget.js +202 -0
- package/dist/brain/snapshot-budget.js.map +1 -0
- package/dist/brain/system-prompt.d.ts +67 -0
- package/dist/brain/system-prompt.d.ts.map +1 -0
- package/dist/brain/system-prompt.js +128 -0
- package/dist/brain/system-prompt.js.map +1 -0
- package/dist/brain/tasks/design-audit.d.ts +33 -0
- package/dist/brain/tasks/design-audit.d.ts.map +1 -0
- package/dist/brain/tasks/design-audit.js +100 -0
- package/dist/brain/tasks/design-audit.js.map +1 -0
- package/dist/brain/tasks/evaluate.d.ts +25 -0
- package/dist/brain/tasks/evaluate.d.ts.map +1 -0
- package/dist/brain/tasks/evaluate.js +55 -0
- package/dist/brain/tasks/evaluate.js.map +1 -0
- package/dist/brain/tasks/goal-verification.d.ts +32 -0
- package/dist/brain/tasks/goal-verification.d.ts.map +1 -0
- package/dist/brain/tasks/goal-verification.js +68 -0
- package/dist/brain/tasks/goal-verification.js.map +1 -0
- package/dist/brain/tasks/knowledge.d.ts +26 -0
- package/dist/brain/tasks/knowledge.d.ts.map +1 -0
- package/dist/brain/tasks/knowledge.js +56 -0
- package/dist/brain/tasks/knowledge.js.map +1 -0
- package/dist/brain/tasks/link-scout.d.ts +37 -0
- package/dist/brain/tasks/link-scout.d.ts.map +1 -0
- package/dist/brain/tasks/link-scout.js +69 -0
- package/dist/brain/tasks/link-scout.js.map +1 -0
- package/dist/brain/types.d.ts +55 -0
- package/dist/brain/types.d.ts.map +1 -0
- package/dist/brain/types.js +7 -0
- package/dist/brain/types.js.map +1 -0
- package/dist/browser/stealth-init-script.d.ts +9 -0
- package/dist/browser/stealth-init-script.d.ts.map +1 -0
- package/dist/browser/stealth-init-script.js +128 -0
- package/dist/browser/stealth-init-script.js.map +1 -0
- package/dist/browser/storage-state.d.ts +29 -0
- package/dist/browser/storage-state.d.ts.map +1 -0
- package/dist/browser/storage-state.js +47 -0
- package/dist/browser/storage-state.js.map +1 -0
- package/dist/cli/args.d.ts +141 -0
- package/dist/cli/args.d.ts.map +1 -0
- package/dist/cli/args.js +167 -0
- package/dist/cli/args.js.map +1 -0
- package/dist/cli/benchmark-sync.d.ts +9 -0
- package/dist/cli/benchmark-sync.d.ts.map +1 -0
- package/dist/cli/benchmark-sync.js +43 -0
- package/dist/cli/benchmark-sync.js.map +1 -0
- package/dist/cli/build-config.d.ts +11 -0
- package/dist/cli/build-config.d.ts.map +1 -0
- package/dist/cli/build-config.js +355 -0
- package/dist/cli/build-config.js.map +1 -0
- package/dist/cli/commands/auth.d.ts +3 -0
- package/dist/cli/commands/auth.d.ts.map +1 -0
- package/dist/cli/commands/auth.js +36 -0
- package/dist/cli/commands/auth.js.map +1 -0
- package/dist/cli/commands/chrome-debug.d.ts +7 -0
- package/dist/cli/commands/chrome-debug.d.ts.map +1 -0
- package/dist/cli/commands/chrome-debug.js +11 -0
- package/dist/cli/commands/chrome-debug.js.map +1 -0
- package/dist/cli/commands/design-audit.d.ts +3 -0
- package/dist/cli/commands/design-audit.d.ts.map +1 -0
- package/dist/cli/commands/design-audit.js +68 -0
- package/dist/cli/commands/design-audit.js.map +1 -0
- package/dist/cli/commands/preview.d.ts +14 -0
- package/dist/cli/commands/preview.d.ts.map +1 -0
- package/dist/cli/commands/preview.js +31 -0
- package/dist/cli/commands/preview.js.map +1 -0
- package/dist/cli/commands/run.d.ts +3 -0
- package/dist/cli/commands/run.d.ts.map +1 -0
- package/dist/cli/commands/run.js +728 -0
- package/dist/cli/commands/run.js.map +1 -0
- package/dist/cli/commands/runs.d.ts +8 -0
- package/dist/cli/commands/runs.d.ts.map +1 -0
- package/dist/cli/commands/runs.js +35 -0
- package/dist/cli/commands/runs.js.map +1 -0
- package/dist/cli/commands/share.d.ts +10 -0
- package/dist/cli/commands/share.d.ts.map +1 -0
- package/dist/cli/commands/share.js +32 -0
- package/dist/cli/commands/share.js.map +1 -0
- package/dist/cli/commands/showcase.d.ts +17 -0
- package/dist/cli/commands/showcase.d.ts.map +1 -0
- package/dist/cli/commands/showcase.js +20 -0
- package/dist/cli/commands/showcase.js.map +1 -0
- package/dist/cli/commands/snapshot.d.ts +12 -0
- package/dist/cli/commands/snapshot.d.ts.map +1 -0
- package/dist/cli/commands/snapshot.js +24 -0
- package/dist/cli/commands/snapshot.js.map +1 -0
- package/dist/cli/commands/view.d.ts +7 -0
- package/dist/cli/commands/view.d.ts.map +1 -0
- package/dist/cli/commands/view.js +23 -0
- package/dist/cli/commands/view.js.map +1 -0
- package/dist/cli/constants.d.ts +6 -0
- package/dist/cli/constants.d.ts.map +1 -0
- package/dist/cli/constants.js +3 -0
- package/dist/cli/constants.js.map +1 -0
- package/dist/cli/version.d.ts +7 -0
- package/dist/cli/version.d.ts.map +1 -0
- package/dist/cli/version.js +16 -0
- package/dist/cli/version.js.map +1 -0
- package/dist/cli-design-audit.d.ts +44 -36
- package/dist/cli-design-audit.d.ts.map +1 -1
- package/dist/cli-design-audit.js +137 -1646
- package/dist/cli-design-audit.js.map +1 -1
- package/dist/cli-jobs.js +2 -1
- package/dist/cli-jobs.js.map +1 -1
- package/dist/cli.js +66 -1697
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +5 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +8 -0
- package/dist/config.js.map +1 -1
- package/dist/design/audit/evolve/agent.d.ts +23 -0
- package/dist/design/audit/evolve/agent.d.ts.map +1 -0
- package/dist/design/audit/evolve/agent.js +272 -0
- package/dist/design/audit/evolve/agent.js.map +1 -0
- package/dist/design/audit/evolve/css.d.ts +10 -0
- package/dist/design/audit/evolve/css.d.ts.map +1 -0
- package/dist/design/audit/evolve/css.js +206 -0
- package/dist/design/audit/evolve/css.js.map +1 -0
- package/dist/design/audit/evolve/index.d.ts +13 -0
- package/dist/design/audit/evolve/index.d.ts.map +1 -0
- package/dist/design/audit/evolve/index.js +12 -0
- package/dist/design/audit/evolve/index.js.map +1 -0
- package/dist/design/audit/evolve/report.d.ts +3 -0
- package/dist/design/audit/evolve/report.d.ts.map +1 -0
- package/dist/design/audit/evolve/report.js +45 -0
- package/dist/design/audit/evolve/report.js.map +1 -0
- package/dist/design/audit/evolve/types.d.ts +14 -0
- package/dist/design/audit/evolve/types.d.ts.map +1 -0
- package/dist/design/audit/evolve/types.js +2 -0
- package/dist/design/audit/evolve/types.js.map +1 -0
- package/dist/design/audit/pipeline.d.ts +12 -0
- package/dist/design/audit/pipeline.d.ts.map +1 -1
- package/dist/design/audit/pipeline.js +43 -27
- package/dist/design/audit/pipeline.js.map +1 -1
- package/dist/design/audit/reference/artifact/build.d.ts +33 -0
- package/dist/design/audit/reference/artifact/build.d.ts.map +1 -0
- package/dist/design/audit/reference/artifact/build.js +64 -0
- package/dist/design/audit/reference/artifact/build.js.map +1 -0
- package/dist/design/audit/reference/artifact/render.d.ts +39 -0
- package/dist/design/audit/reference/artifact/render.d.ts.map +1 -0
- package/dist/design/audit/reference/artifact/render.js +213 -0
- package/dist/design/audit/reference/artifact/render.js.map +1 -0
- package/dist/design/audit/reference/artifact/text.d.ts +11 -0
- package/dist/design/audit/reference/artifact/text.d.ts.map +1 -0
- package/dist/design/audit/reference/artifact/text.js +20 -0
- package/dist/design/audit/reference/artifact/text.js.map +1 -0
- package/dist/design/audit/reference/artifact/to-findings.d.ts +57 -0
- package/dist/design/audit/reference/artifact/to-findings.d.ts.map +1 -0
- package/dist/design/audit/reference/artifact/to-findings.js +314 -0
- package/dist/design/audit/reference/artifact/to-findings.js.map +1 -0
- package/dist/design/audit/reference/config.d.ts +50 -0
- package/dist/design/audit/reference/config.d.ts.map +1 -0
- package/dist/design/audit/reference/config.js +108 -0
- package/dist/design/audit/reference/config.js.map +1 -0
- package/dist/design/audit/reference/contracts.d.ts +1030 -0
- package/dist/design/audit/reference/contracts.d.ts.map +1 -0
- package/dist/design/audit/reference/contracts.js +28 -0
- package/dist/design/audit/reference/contracts.js.map +1 -0
- package/dist/design/audit/reference/corpus/build.d.ts +115 -0
- package/dist/design/audit/reference/corpus/build.d.ts.map +1 -0
- package/dist/design/audit/reference/corpus/build.js +152 -0
- package/dist/design/audit/reference/corpus/build.js.map +1 -0
- package/dist/design/audit/reference/corpus/schema.d.ts +33 -0
- package/dist/design/audit/reference/corpus/schema.d.ts.map +1 -0
- package/dist/design/audit/reference/corpus/schema.js +249 -0
- package/dist/design/audit/reference/corpus/schema.js.map +1 -0
- package/dist/design/audit/reference/corpus/store.d.ts +26 -0
- package/dist/design/audit/reference/corpus/store.d.ts.map +1 -0
- package/dist/design/audit/reference/corpus/store.js +104 -0
- package/dist/design/audit/reference/corpus/store.js.map +1 -0
- package/dist/design/audit/reference/dna/delta.d.ts +21 -0
- package/dist/design/audit/reference/dna/delta.d.ts.map +1 -0
- package/dist/design/audit/reference/dna/delta.js +126 -0
- package/dist/design/audit/reference/dna/delta.js.map +1 -0
- package/dist/design/audit/reference/dna/derive.d.ts +31 -0
- package/dist/design/audit/reference/dna/derive.d.ts.map +1 -0
- package/dist/design/audit/reference/dna/derive.js +381 -0
- package/dist/design/audit/reference/dna/derive.js.map +1 -0
- package/dist/design/audit/reference/dna/descriptor.d.ts +36 -0
- package/dist/design/audit/reference/dna/descriptor.d.ts.map +1 -0
- package/dist/design/audit/reference/dna/descriptor.js +209 -0
- package/dist/design/audit/reference/dna/descriptor.js.map +1 -0
- package/dist/design/audit/reference/dna/page-adapter.d.ts +17 -0
- package/dist/design/audit/reference/dna/page-adapter.d.ts.map +1 -0
- package/dist/design/audit/reference/dna/page-adapter.js +35 -0
- package/dist/design/audit/reference/dna/page-adapter.js.map +1 -0
- package/dist/design/audit/reference/dna/scroll-capture.d.ts +93 -0
- package/dist/design/audit/reference/dna/scroll-capture.d.ts.map +1 -0
- package/dist/design/audit/reference/dna/scroll-capture.js +374 -0
- package/dist/design/audit/reference/dna/scroll-capture.js.map +1 -0
- package/dist/design/audit/reference/engine/budget.d.ts +63 -0
- package/dist/design/audit/reference/engine/budget.d.ts.map +1 -0
- package/dist/design/audit/reference/engine/budget.js +110 -0
- package/dist/design/audit/reference/engine/budget.js.map +1 -0
- package/dist/design/audit/reference/engine/core.d.ts +32 -0
- package/dist/design/audit/reference/engine/core.d.ts.map +1 -0
- package/dist/design/audit/reference/engine/core.js +261 -0
- package/dist/design/audit/reference/engine/core.js.map +1 -0
- package/dist/design/audit/reference/engine/guard.d.ts +43 -0
- package/dist/design/audit/reference/engine/guard.d.ts.map +1 -0
- package/dist/design/audit/reference/engine/guard.js +43 -0
- package/dist/design/audit/reference/engine/guard.js.map +1 -0
- package/dist/design/audit/reference/engine/score-core.d.ts +48 -0
- package/dist/design/audit/reference/engine/score-core.d.ts.map +1 -0
- package/dist/design/audit/reference/engine/score-core.js +134 -0
- package/dist/design/audit/reference/engine/score-core.js.map +1 -0
- package/dist/design/audit/reference/engine/wiring.d.ts +35 -0
- package/dist/design/audit/reference/engine/wiring.d.ts.map +1 -0
- package/dist/design/audit/reference/engine/wiring.js +80 -0
- package/dist/design/audit/reference/engine/wiring.js.map +1 -0
- package/dist/design/audit/reference/eval/taste-core.d.ts +77 -0
- package/dist/design/audit/reference/eval/taste-core.d.ts.map +1 -0
- package/dist/design/audit/reference/eval/taste-core.js +95 -0
- package/dist/design/audit/reference/eval/taste-core.js.map +1 -0
- package/dist/design/audit/reference/generate/generator.d.ts +49 -0
- package/dist/design/audit/reference/generate/generator.d.ts.map +1 -0
- package/dist/design/audit/reference/generate/generator.js +94 -0
- package/dist/design/audit/reference/generate/generator.js.map +1 -0
- package/dist/design/audit/reference/generate/parse.d.ts +28 -0
- package/dist/design/audit/reference/generate/parse.d.ts.map +1 -0
- package/dist/design/audit/reference/generate/parse.js +180 -0
- package/dist/design/audit/reference/generate/parse.js.map +1 -0
- package/dist/design/audit/reference/generate/prompt.d.ts +36 -0
- package/dist/design/audit/reference/generate/prompt.d.ts.map +1 -0
- package/dist/design/audit/reference/generate/prompt.js +124 -0
- package/dist/design/audit/reference/generate/prompt.js.map +1 -0
- package/dist/design/audit/reference/index.d.ts +26 -0
- package/dist/design/audit/reference/index.d.ts.map +1 -0
- package/dist/design/audit/reference/index.js +31 -0
- package/dist/design/audit/reference/index.js.map +1 -0
- package/dist/design/audit/reference/judge/image-clamp.d.ts +34 -0
- package/dist/design/audit/reference/judge/image-clamp.d.ts.map +1 -0
- package/dist/design/audit/reference/judge/image-clamp.js +88 -0
- package/dist/design/audit/reference/judge/image-clamp.js.map +1 -0
- package/dist/design/audit/reference/judge/pairwise.d.ts +34 -0
- package/dist/design/audit/reference/judge/pairwise.d.ts.map +1 -0
- package/dist/design/audit/reference/judge/pairwise.js +105 -0
- package/dist/design/audit/reference/judge/pairwise.js.map +1 -0
- package/dist/design/audit/reference/judge/parse.d.ts +31 -0
- package/dist/design/audit/reference/judge/parse.d.ts.map +1 -0
- package/dist/design/audit/reference/judge/parse.js +113 -0
- package/dist/design/audit/reference/judge/parse.js.map +1 -0
- package/dist/design/audit/reference/judge/prompt.d.ts +38 -0
- package/dist/design/audit/reference/judge/prompt.d.ts.map +1 -0
- package/dist/design/audit/reference/judge/prompt.js +111 -0
- package/dist/design/audit/reference/judge/prompt.js.map +1 -0
- package/dist/design/audit/reference/judge/quality.d.ts +28 -0
- package/dist/design/audit/reference/judge/quality.d.ts.map +1 -0
- package/dist/design/audit/reference/judge/quality.js +62 -0
- package/dist/design/audit/reference/judge/quality.js.map +1 -0
- package/dist/design/audit/reference/judge/rank.d.ts +41 -0
- package/dist/design/audit/reference/judge/rank.d.ts.map +1 -0
- package/dist/design/audit/reference/judge/rank.js +196 -0
- package/dist/design/audit/reference/judge/rank.js.map +1 -0
- package/dist/design/audit/reference/judge/text-judge.d.ts +31 -0
- package/dist/design/audit/reference/judge/text-judge.d.ts.map +1 -0
- package/dist/design/audit/reference/judge/text-judge.js +43 -0
- package/dist/design/audit/reference/judge/text-judge.js.map +1 -0
- package/dist/design/audit/reference/judge/vision-judge.d.ts +59 -0
- package/dist/design/audit/reference/judge/vision-judge.d.ts.map +1 -0
- package/dist/design/audit/reference/judge/vision-judge.js +150 -0
- package/dist/design/audit/reference/judge/vision-judge.js.map +1 -0
- package/dist/design/audit/reference/judge/vision-model.d.ts +65 -0
- package/dist/design/audit/reference/judge/vision-model.d.ts.map +1 -0
- package/dist/design/audit/reference/judge/vision-model.js +110 -0
- package/dist/design/audit/reference/judge/vision-model.js.map +1 -0
- package/dist/design/audit/reference/pipeline/evaluate-reference.d.ts +68 -0
- package/dist/design/audit/reference/pipeline/evaluate-reference.d.ts.map +1 -0
- package/dist/design/audit/reference/pipeline/evaluate-reference.js +52 -0
- package/dist/design/audit/reference/pipeline/evaluate-reference.js.map +1 -0
- package/dist/design/audit/reference/reference-context.d.ts +31 -0
- package/dist/design/audit/reference/reference-context.d.ts.map +1 -0
- package/dist/design/audit/reference/reference-context.js +73 -0
- package/dist/design/audit/reference/reference-context.js.map +1 -0
- package/dist/design/audit/reference/retrieval/embedding-hash.d.ts +30 -0
- package/dist/design/audit/reference/retrieval/embedding-hash.d.ts.map +1 -0
- package/dist/design/audit/reference/retrieval/embedding-hash.js +87 -0
- package/dist/design/audit/reference/retrieval/embedding-hash.js.map +1 -0
- package/dist/design/audit/reference/retrieval/embedding-openai.d.ts +38 -0
- package/dist/design/audit/reference/retrieval/embedding-openai.d.ts.map +1 -0
- package/dist/design/audit/reference/retrieval/embedding-openai.js +73 -0
- package/dist/design/audit/reference/retrieval/embedding-openai.js.map +1 -0
- package/dist/design/audit/reference/retrieval/matcher.d.ts +34 -0
- package/dist/design/audit/reference/retrieval/matcher.d.ts.map +1 -0
- package/dist/design/audit/reference/retrieval/matcher.js +107 -0
- package/dist/design/audit/reference/retrieval/matcher.js.map +1 -0
- package/dist/design/audit/reference/run.d.ts +59 -0
- package/dist/design/audit/reference/run.d.ts.map +1 -0
- package/dist/design/audit/reference/run.js +99 -0
- package/dist/design/audit/reference/run.js.map +1 -0
- package/dist/design/audit/report.d.ts +35 -0
- package/dist/design/audit/report.d.ts.map +1 -0
- package/dist/design/audit/report.js +195 -0
- package/dist/design/audit/report.js.map +1 -0
- package/dist/design/audit/tokens/extract.d.ts +71 -0
- package/dist/design/audit/tokens/extract.d.ts.map +1 -0
- package/dist/design/audit/tokens/extract.js +1034 -0
- package/dist/design/audit/tokens/extract.js.map +1 -0
- package/dist/design/audit/types.d.ts +8 -0
- package/dist/design/audit/types.d.ts.map +1 -1
- package/dist/design/compare.d.ts.map +1 -1
- package/dist/design/compare.js +2 -6
- package/dist/design/compare.js.map +1 -1
- package/dist/design/cookie-consent.d.ts +3 -0
- package/dist/design/cookie-consent.d.ts.map +1 -0
- package/dist/design/cookie-consent.js +26 -0
- package/dist/design/cookie-consent.js.map +1 -0
- package/dist/design/viewports.d.ts +18 -0
- package/dist/design/viewports.d.ts.map +1 -0
- package/dist/design/viewports.js +10 -0
- package/dist/design/viewports.js.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/memory/store.d.ts +19 -1
- package/dist/memory/store.d.ts.map +1 -1
- package/dist/memory/store.js +47 -0
- package/dist/memory/store.js.map +1 -1
- package/dist/provider-defaults.d.ts +18 -0
- package/dist/provider-defaults.d.ts.map +1 -1
- package/dist/provider-defaults.js +33 -0
- package/dist/provider-defaults.js.map +1 -1
- package/dist/runner/allowed-domains.d.ts +11 -0
- package/dist/runner/allowed-domains.d.ts.map +1 -0
- package/dist/runner/allowed-domains.js +14 -0
- package/dist/runner/allowed-domains.js.map +1 -0
- package/dist/runner/batch-fill.d.ts +28 -0
- package/dist/runner/batch-fill.d.ts.map +1 -0
- package/dist/runner/batch-fill.js +80 -0
- package/dist/runner/batch-fill.js.map +1 -0
- package/dist/runner/completion-policy.d.ts +26 -0
- package/dist/runner/completion-policy.d.ts.map +1 -0
- package/dist/runner/completion-policy.js +76 -0
- package/dist/runner/completion-policy.js.map +1 -0
- package/dist/runner/constants.d.ts +14 -0
- package/dist/runner/constants.d.ts.map +1 -0
- package/dist/runner/constants.js +23 -0
- package/dist/runner/constants.js.map +1 -0
- package/dist/runner/decision-screenshot.d.ts +24 -0
- package/dist/runner/decision-screenshot.d.ts.map +1 -0
- package/dist/runner/decision-screenshot.js +23 -0
- package/dist/runner/decision-screenshot.js.map +1 -0
- package/dist/runner/domain-boundary.d.ts +36 -0
- package/dist/runner/domain-boundary.d.ts.map +1 -0
- package/dist/runner/domain-boundary.js +81 -0
- package/dist/runner/domain-boundary.js.map +1 -0
- package/dist/runner/effect-verify.d.ts +28 -0
- package/dist/runner/effect-verify.d.ts.map +1 -0
- package/dist/runner/effect-verify.js +42 -0
- package/dist/runner/effect-verify.js.map +1 -0
- package/dist/runner/execute-plan.d.ts +58 -0
- package/dist/runner/execute-plan.d.ts.map +1 -0
- package/dist/runner/execute-plan.js +426 -0
- package/dist/runner/execute-plan.js.map +1 -0
- package/dist/runner/max-turns-extension.d.ts +19 -0
- package/dist/runner/max-turns-extension.d.ts.map +1 -0
- package/dist/runner/max-turns-extension.js +25 -0
- package/dist/runner/max-turns-extension.js.map +1 -0
- package/dist/runner/micro-plan.d.ts +11 -0
- package/dist/runner/micro-plan.d.ts.map +1 -0
- package/dist/runner/micro-plan.js +29 -0
- package/dist/runner/micro-plan.js.map +1 -0
- package/dist/runner/prompt-snippets.d.ts +5 -0
- package/dist/runner/prompt-snippets.d.ts.map +1 -0
- package/dist/runner/prompt-snippets.js +13 -0
- package/dist/runner/prompt-snippets.js.map +1 -0
- package/dist/runner/replay/contracts.d.ts +300 -0
- package/dist/runner/replay/contracts.d.ts.map +1 -0
- package/dist/runner/replay/contracts.js +42 -0
- package/dist/runner/replay/contracts.js.map +1 -0
- package/dist/runner/replay/controller.d.ts +27 -0
- package/dist/runner/replay/controller.d.ts.map +1 -0
- package/dist/runner/replay/controller.js +197 -0
- package/dist/runner/replay/controller.js.map +1 -0
- package/dist/runner/replay/guard.d.ts +28 -0
- package/dist/runner/replay/guard.d.ts.map +1 -0
- package/dist/runner/replay/guard.js +100 -0
- package/dist/runner/replay/guard.js.map +1 -0
- package/dist/runner/runner.d.ts +44 -51
- package/dist/runner/runner.d.ts.map +1 -1
- package/dist/runner/runner.js +155 -851
- package/dist/runner/runner.js.map +1 -1
- package/dist/runner/scout-feedback.d.ts +51 -0
- package/dist/runner/scout-feedback.d.ts.map +1 -0
- package/dist/runner/scout-feedback.js +149 -0
- package/dist/runner/scout-feedback.js.map +1 -0
- package/dist/skills/macro-loader.d.ts +1 -1
- package/dist/test-runner.d.ts.map +1 -1
- package/dist/test-runner.js +25 -0
- package/dist/test-runner.js.map +1 -1
- package/dist/types/actions.d.ts +241 -0
- package/dist/types/actions.d.ts.map +1 -0
- package/dist/types/actions.js +5 -0
- package/dist/types/actions.js.map +1 -0
- package/dist/types/config.d.ts +211 -0
- package/dist/types/config.d.ts.map +1 -0
- package/dist/types/config.js +2 -0
- package/dist/types/config.js.map +1 -0
- package/dist/types/design-audit.d.ts +92 -0
- package/dist/types/design-audit.d.ts.map +1 -0
- package/dist/types/design-audit.js +5 -0
- package/dist/types/design-audit.js.map +1 -0
- package/dist/types/design-tokens.d.ts +138 -0
- package/dist/types/design-tokens.d.ts.map +1 -0
- package/dist/types/design-tokens.js +5 -0
- package/dist/types/design-tokens.js.map +1 -0
- package/dist/types/page.d.ts +16 -0
- package/dist/types/page.d.ts.map +1 -0
- package/dist/types/page.js +2 -0
- package/dist/types/page.js.map +1 -0
- package/dist/types/plan.d.ts +50 -0
- package/dist/types/plan.d.ts.map +1 -0
- package/dist/types/plan.js +2 -0
- package/dist/types/plan.js.map +1 -0
- package/dist/types/preview.d.ts +9 -0
- package/dist/types/preview.d.ts.map +1 -0
- package/dist/types/preview.js +5 -0
- package/dist/types/preview.js.map +1 -0
- package/dist/types/result.d.ts +62 -0
- package/dist/types/result.d.ts.map +1 -0
- package/dist/types/result.js +2 -0
- package/dist/types/result.js.map +1 -0
- package/dist/types/scenario.d.ts +20 -0
- package/dist/types/scenario.d.ts.map +1 -0
- package/dist/types/scenario.js +5 -0
- package/dist/types/scenario.js.map +1 -0
- package/dist/types/test-runner.d.ts +145 -0
- package/dist/types/test-runner.d.ts.map +1 -0
- package/dist/types/test-runner.js +10 -0
- package/dist/types/test-runner.js.map +1 -0
- package/dist/types/trajectory.d.ts +38 -0
- package/dist/types/trajectory.d.ts.map +1 -0
- package/dist/types/trajectory.js +2 -0
- package/dist/types/trajectory.js.map +1 -0
- package/dist/types/turn.d.ts +50 -0
- package/dist/types/turn.d.ts.map +1 -0
- package/dist/types/turn.js +2 -0
- package/dist/types/turn.js.map +1 -0
- package/dist/types.d.ts +16 -1017
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +15 -8
- package/dist/types.js.map +1 -1
- package/dist/wallet/rpc-interception.d.ts +15 -0
- package/dist/wallet/rpc-interception.d.ts.map +1 -0
- package/dist/wallet/rpc-interception.js +95 -0
- package/dist/wallet/rpc-interception.js.map +1 -0
- package/package.json +7 -3
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Scoring core — the SINGLE scoring authority for the reference-grounded engine.
|
|
3
|
+
*
|
|
4
|
+
* Everything the pipeline scores derives from ONE `QualityAssessment` (the
|
|
5
|
+
* absolute leg: the page-under-audit's win-rate vs the retrieved world-class
|
|
6
|
+
* exemplars). This module turns that one assessment into three honest surfaces,
|
|
7
|
+
* eliminating the double-scoring the v1 path risked:
|
|
8
|
+
*
|
|
9
|
+
* - `deriveHeadlineScore` → the 0-10 headline, monotonic in `overallWinRate`,
|
|
10
|
+
* capped when deterministic measurements flag blocking issues (you cannot be
|
|
11
|
+
* world-class with critical a11y/contrast failures).
|
|
12
|
+
* - `toDimensionScores` → the rich 5-`Dimension` `Record<Dimension, DimensionScore>`
|
|
13
|
+
* that IS stage-8's `precomputedScores` hook. Each dimension is scored ONLY
|
|
14
|
+
* from a genuinely judge-resolved per-dimension win-rate; a dimension with no
|
|
15
|
+
* signal is filled at `confidence:'low'` with an explicit "not assessed"
|
|
16
|
+
* summary — never the overall number stamped across dimensions.
|
|
17
|
+
* - `toDesignSystemScore` → the flat 8-axis `DesignSystemScore` back-compat
|
|
18
|
+
* field, an HONESTLY coarse projection of `overallWinRate` (not a second
|
|
19
|
+
* per-axis authority).
|
|
20
|
+
*
|
|
21
|
+
* Pure and deterministic: no IO, no LLM, no clock. Notably does NOT borrow
|
|
22
|
+
* `conservativeScore` — there are no per-pass page scores in this mode, so
|
|
23
|
+
* importing it would be scoring fiction.
|
|
24
|
+
*/
|
|
25
|
+
import { DIMENSIONS } from '../../score-types.js';
|
|
26
|
+
// Headline runs on a 0-10 scale; dimension + design-system axes run on the
|
|
27
|
+
// 1-10 scale the rest of the audit uses (see evaluate.ts / DimensionScore).
|
|
28
|
+
const HEADLINE_MAX = 10;
|
|
29
|
+
// A page with deterministic blocking issues (critical/serious a11y or contrast
|
|
30
|
+
// failures, `MeasurementBundle.hasBlockingIssues`) cannot earn a top headline.
|
|
31
|
+
// Mirrors the ethics gate's major-floor cap (6) — a measurement ceiling, not a
|
|
32
|
+
// floor in the colloquial sense.
|
|
33
|
+
const BLOCKING_ISSUE_HEADLINE_CAP = 6;
|
|
34
|
+
// Neutral placeholder for a dimension the budget never judged. NOT derived from
|
|
35
|
+
// `overallWinRate`; paired with `confidence:'low'` + a full [1,10] range so it
|
|
36
|
+
// reads as "unassessed", never as a real per-dimension verdict.
|
|
37
|
+
const UNASSESSED_DIMENSION_SCORE = 5;
|
|
38
|
+
// Per-dimension confidence tiers keyed off how many comparisons backed the
|
|
39
|
+
// quality leg. More comparisons ⇒ higher confidence ⇒ a tighter range.
|
|
40
|
+
const HIGH_CONFIDENCE_COMPARISONS = 8;
|
|
41
|
+
const MEDIUM_CONFIDENCE_COMPARISONS = 4;
|
|
42
|
+
const clamp01 = (n) => Number.isFinite(n) ? Math.min(1, Math.max(0, n)) : 0;
|
|
43
|
+
const round1 = (n) => Math.round(n * 10) / 10;
|
|
44
|
+
/** Map a 0-1 win-rate onto the 1-10 dimension/design-system scale. */
|
|
45
|
+
function winRateToScore(winRate) {
|
|
46
|
+
return Math.max(1, Math.min(10, Math.round(clamp01(winRate) * 10)));
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Derive the 0-10 headline from the absolute win-rate, capped when measurements
|
|
50
|
+
* flag blocking issues. Monotonic non-decreasing in `overallWinRate`: a higher
|
|
51
|
+
* win-rate never yields a lower headline.
|
|
52
|
+
*/
|
|
53
|
+
export function deriveHeadlineScore(quality, measurements) {
|
|
54
|
+
const raw = clamp01(quality.overallWinRate) * HEADLINE_MAX;
|
|
55
|
+
const capped = measurements.hasBlockingIssues
|
|
56
|
+
? Math.min(raw, BLOCKING_ISSUE_HEADLINE_CAP)
|
|
57
|
+
: raw;
|
|
58
|
+
return round1(Math.min(HEADLINE_MAX, Math.max(0, capped)));
|
|
59
|
+
}
|
|
60
|
+
function confidenceFor(comparisons) {
|
|
61
|
+
if (comparisons >= HIGH_CONFIDENCE_COMPARISONS)
|
|
62
|
+
return 'high';
|
|
63
|
+
if (comparisons >= MEDIUM_CONFIDENCE_COMPARISONS)
|
|
64
|
+
return 'medium';
|
|
65
|
+
return 'low';
|
|
66
|
+
}
|
|
67
|
+
function rangeSpread(confidence) {
|
|
68
|
+
if (confidence === 'high')
|
|
69
|
+
return 1;
|
|
70
|
+
if (confidence === 'medium')
|
|
71
|
+
return 2;
|
|
72
|
+
return 3;
|
|
73
|
+
}
|
|
74
|
+
function judgedDimensionScore(dim, winRate, comparisons) {
|
|
75
|
+
const score = winRateToScore(winRate);
|
|
76
|
+
const confidence = confidenceFor(comparisons);
|
|
77
|
+
const spread = rangeSpread(confidence);
|
|
78
|
+
return {
|
|
79
|
+
score,
|
|
80
|
+
range: [Math.max(1, score - spread), Math.min(10, score + spread)],
|
|
81
|
+
confidence,
|
|
82
|
+
summary: `${dim}: ${Math.round(clamp01(winRate) * 100)}% win-rate vs world-class exemplars across ${comparisons} pairwise comparison(s).`,
|
|
83
|
+
primaryFindings: [],
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
function unassessedDimensionScore(dim) {
|
|
87
|
+
return {
|
|
88
|
+
score: UNASSESSED_DIMENSION_SCORE,
|
|
89
|
+
range: [1, 10],
|
|
90
|
+
confidence: 'low',
|
|
91
|
+
summary: `${dim}: not independently judged — no dimension-scoped comparison ran under this run's judge budget (overall-only leg). Placeholder, not derived from the overall win-rate.`,
|
|
92
|
+
primaryFindings: [],
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Map the per-`Dimension` win-rates onto the rich `Record<Dimension, DimensionScore>`
|
|
97
|
+
* stage-8 consumes as `precomputedScores`. Every one of the 5 dimensions is
|
|
98
|
+
* present. Dimensions with a real per-dimension win-rate are scored from it
|
|
99
|
+
* (win-rate → score, comparison count → range + confidence); dimensions with no
|
|
100
|
+
* win-rate are filled as explicit, low-confidence placeholders so the absence of
|
|
101
|
+
* a dimension-scoped leg is honest rather than fabricated.
|
|
102
|
+
*/
|
|
103
|
+
export function toDimensionScores(quality) {
|
|
104
|
+
const rates = quality.dimensionWinRates ?? {};
|
|
105
|
+
const out = {};
|
|
106
|
+
for (const dim of DIMENSIONS) {
|
|
107
|
+
const winRate = rates[dim];
|
|
108
|
+
out[dim] =
|
|
109
|
+
winRate === undefined
|
|
110
|
+
? unassessedDimensionScore(dim)
|
|
111
|
+
: judgedDimensionScore(dim, winRate, quality.comparisons);
|
|
112
|
+
}
|
|
113
|
+
return out;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Project `overallWinRate` onto the flat 8-axis `DesignSystemScore` back-compat
|
|
117
|
+
* field. Every axis carries the same overall-derived 1-10 number — this is an
|
|
118
|
+
* honest coarse projection, NOT a second per-axis scoring authority (the judge
|
|
119
|
+
* resolves the 5 product dimensions, not these 8 design-system axes).
|
|
120
|
+
*/
|
|
121
|
+
export function toDesignSystemScore(quality) {
|
|
122
|
+
const s = winRateToScore(quality.overallWinRate);
|
|
123
|
+
return {
|
|
124
|
+
layout: s,
|
|
125
|
+
typography: s,
|
|
126
|
+
color: s,
|
|
127
|
+
spacing: s,
|
|
128
|
+
components: s,
|
|
129
|
+
interactions: s,
|
|
130
|
+
accessibility: s,
|
|
131
|
+
polish: s,
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
//# sourceMappingURL=score-core.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"score-core.js","sourceRoot":"","sources":["../../../../../src/design/audit/reference/engine/score-core.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AASH,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAEjD,2EAA2E;AAC3E,4EAA4E;AAC5E,MAAM,YAAY,GAAG,EAAE,CAAA;AACvB,+EAA+E;AAC/E,+EAA+E;AAC/E,+EAA+E;AAC/E,iCAAiC;AACjC,MAAM,2BAA2B,GAAG,CAAC,CAAA;AACrC,gFAAgF;AAChF,+EAA+E;AAC/E,gEAAgE;AAChE,MAAM,0BAA0B,GAAG,CAAC,CAAA;AACpC,2EAA2E;AAC3E,uEAAuE;AACvE,MAAM,2BAA2B,GAAG,CAAC,CAAA;AACrC,MAAM,6BAA6B,GAAG,CAAC,CAAA;AAEvC,MAAM,OAAO,GAAG,CAAC,CAAS,EAAU,EAAE,CACpC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AAEtD,MAAM,MAAM,GAAG,CAAC,CAAS,EAAU,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,CAAA;AAE7D,sEAAsE;AACtE,SAAS,cAAc,CAAC,OAAe;IACrC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAA;AACrE,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CACjC,OAA0B,EAC1B,YAA+B;IAE/B,MAAM,GAAG,G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
4
|
+
*
|
|
5
|
+
* `buildDefaultDeps` assembles the `ReferenceEngineDeps` bundle `engine/core`
|
|
6
|
+
* depends on, picking each concrete implementation of the seven narrow boundary
|
|
7
|
+
* interfaces: the page→DNA extractor, the file corpus store (exposed as its
|
|
8
|
+
* read-only half), the embedding provider, the pure matcher, the brain-backed
|
|
9
|
+
* generator, the default text judge, and the pure ranker. The core never sees a
|
|
10
|
+
* concrete — it receives only these interfaces — and this module never imports
|
|
11
|
+
* `engine/core`, so the two L3 siblings have no edge between them.
|
|
12
|
+
*
|
|
13
|
+
* The model is injected through the narrow `ReferenceBrain` seam (exactly
|
|
14
|
+
* `brain.complete`'s shape, shared by the generator + judge adapters). The real
|
|
15
|
+
* `Brain` satisfies it structurally, so the L4 entrypoints pass `brain`
|
|
16
|
+
* unchanged while tests inject a deterministic stub with no live model.
|
|
17
|
+
*/
|
|
18
|
+
import type { ReferenceEngineDeps, ReferenceGroundedConfig } from '../contracts.js';
|
|
19
|
+
import { type GenerationModel } from '../generate/generator.js';
|
|
20
|
+
import { type JudgeModel } from '../judge/text-judge.js';
|
|
21
|
+
/**
|
|
22
|
+
* The model seam the default wiring needs. The generator and the default text
|
|
23
|
+
* judge both reduce to `brain.complete`, so a single narrow interface satisfies
|
|
24
|
+
* both adapters; the concrete `Brain` is assignable to it.
|
|
25
|
+
*/
|
|
26
|
+
export interface ReferenceBrain extends GenerationModel, JudgeModel {
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Assemble the default dependency bundle for {@link runRedesignCore}. The corpus
|
|
30
|
+
* store is created here but only its `CorpusReader` half reaches the core
|
|
31
|
+
* (`ReferenceEngineDeps.store` is typed `CorpusReader`), so the audit hot path
|
|
32
|
+
* can never touch the authoring mutators.
|
|
33
|
+
*/
|
|
34
|
+
export declare function buildDefaultDeps(brain: ReferenceBrain, config: ReferenceGroundedConfig): ReferenceEngineDeps;
|
|
35
|
+
//# sourceMappingURL=wiring.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wiring.d.ts","sourceRoot":"","sources":["../../../../../src/design/audit/reference/engine/wiring.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EACV,mBAAmB,EACnB,uBAAuB,EAKxB,MAAM,iBAAiB,CAAA;AAMxB,OAAO,EAAwB,KAAK,eAAe,EAAE,MAAM,0BAA0B,CAAA;AACrF,OAAO,EAAmB,KAAK,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAKzE;;;;GAIG;AACH,MAAM,WAAW,cAAe,SAAQ,eAAe,EAAE,UAAU;CAAG;AAsCtE;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,cAAc,EACrB,MAAM,EAAE,uBAAuB,GAC9B,mBAAmB,CAarB"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Composition root — the ONE place concrete adapters meet. ORCH, zero domain
|
|
3
|
+
* logic.
|
|
4
|
+
*
|
|
5
|
+
* `buildDefaultDeps` assembles the `ReferenceEngineDeps` bundle `engine/core`
|
|
6
|
+
* depends on, picking each concrete implementation of the seven narrow boundary
|
|
7
|
+
* interfaces: the page→DNA extractor, the file corpus store (exposed as its
|
|
8
|
+
* read-only half), the embedding provider, the pure matcher, the brain-backed
|
|
9
|
+
* generator, the default text judge, and the pure ranker. The core never sees a
|
|
10
|
+
* concrete — it receives only these interfaces — and this module never imports
|
|
11
|
+
* `engine/core`, so the two L3 siblings have no edge between them.
|
|
12
|
+
*
|
|
13
|
+
* The model is injected through the narrow `ReferenceBrain` seam (exactly
|
|
14
|
+
* `brain.complete`'s shape, shared by the generator + judge adapters). The real
|
|
15
|
+
* `Brain` satisfies it structurally, so the L4 entrypoints pass `brain`
|
|
16
|
+
* unchanged while tests inject a deterministic stub with no live model.
|
|
17
|
+
*/
|
|
18
|
+
import { createPageDnaExtractor } from '../dna/page-adapter.js';
|
|
19
|
+
import { createFileCorpusStore } from '../corpus/store.js';
|
|
20
|
+
import { resolveEmbeddingProvider } from '../retrieval/embedding-openai.js';
|
|
21
|
+
import { HashEmbeddingProvider } from '../retrieval/embedding-hash.js';
|
|
22
|
+
import { retrieve } from '../retrieval/matcher.js';
|
|
23
|
+
import { createBrainGenerator } from '../generate/generator.js';
|
|
24
|
+
import { createTextJudge } from '../judge/text-judge.js';
|
|
25
|
+
import { createVisionJudge } from '../judge/vision-judge.js';
|
|
26
|
+
import { buildVisionModels } from '../judge/vision-model.js';
|
|
27
|
+
import { rankDirections } from '../judge/rank.js';
|
|
28
|
+
/**
|
|
29
|
+
* Pick the concrete embedding provider for the config:
|
|
30
|
+
* - `'deterministic'` → the literally-pure offline hash embedder (zero network);
|
|
31
|
+
* - `'provider'` → the network provider when a key resolves, else the hash
|
|
32
|
+
* embedder (fail-safe: a missing key yields a working offline run, not an error).
|
|
33
|
+
*/
|
|
34
|
+
function selectEmbedder(config) {
|
|
35
|
+
return config.embedder === 'provider' ? resolveEmbeddingProvider() : HashEmbeddingProvider;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Pick the concrete taste judge. `'text'` is the shipped default (judges from DNA
|
|
39
|
+
* summaries via `brain.complete`). `'vision'` builds the screenshot-grounded
|
|
40
|
+
* ensemble from `config.visionModels`: ONE Brain per `{ provider, model }` ref
|
|
41
|
+
* (each with its own provider key, constructed in `buildVisionModels`), wrapped
|
|
42
|
+
* in the pure `createVisionJudge`. The injected text `brain` is reused as the
|
|
43
|
+
* fallback for screenshot-less subjects (the direction-ranking leg), so the
|
|
44
|
+
* vision judge stays a single drop-in for both legs. Fails closed: an empty
|
|
45
|
+
* `visionModels` list throws rather than silently degrading to text.
|
|
46
|
+
*
|
|
47
|
+
* This is the composition root, so constructing concrete vision Brains here is by
|
|
48
|
+
* design — the engine core only ever sees the narrow `TasteJudge`. Unit tests
|
|
49
|
+
* inject `deps.judge` (or call `createVisionJudge` with stub models) and never
|
|
50
|
+
* reach this Brain construction.
|
|
51
|
+
*/
|
|
52
|
+
function selectJudge(brain, config) {
|
|
53
|
+
if (config.judge !== 'vision')
|
|
54
|
+
return createTextJudge(brain);
|
|
55
|
+
const refs = config.visionModels ?? [];
|
|
56
|
+
if (refs.length === 0) {
|
|
57
|
+
throw new Error('reference engine: judge "vision" requires at least one visionModels ref — none resolved');
|
|
58
|
+
}
|
|
59
|
+
return createVisionJudge(buildVisionModels(refs), { textFallback: createTextJudge(brain) });
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Assemble the default dependency bundle for {@link runRedesignCore}. The corpus
|
|
63
|
+
* store is created here but only its `CorpusReader` half reaches the core
|
|
64
|
+
* (`ReferenceEngineDeps.store` is typed `CorpusReader`), so the audit hot path
|
|
65
|
+
* can never touch the authoring mutators.
|
|
66
|
+
*/
|
|
67
|
+
export function buildDefaultDeps(brain, config) {
|
|
68
|
+
const matcher = { retrieve };
|
|
69
|
+
const ranker = { rank: rankDirections };
|
|
70
|
+
return {
|
|
71
|
+
extractor: createPageDnaExtractor(),
|
|
72
|
+
store: createFileCorpusStore(config.corpusDir),
|
|
73
|
+
embedder: selectEmbedder(config),
|
|
74
|
+
matcher,
|
|
75
|
+
generator: createBrainGenerator(brain, { count: config.directionCount }),
|
|
76
|
+
judge: selectJudge(brain, config),
|
|
77
|
+
ranker,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=wiring.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wiring.js","sourceRoot":"","sources":["../../../../../src/design/audit/reference/engine/wiring.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAUH,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAA;AAC/D,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAA;AAC1D,OAAO,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAA;AAC3E,OAAO,EAAE,qBAAqB,EAAE,MAAM,g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SAAS,CAAC;QAC9C,QAAQ,EAAE,cAAc,CAAC,MAAM,CAAC;QAChC,OAAO;QACP,SAAS,EAAE,oBAAoB,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,cAAc,EAAE,CAAC;QACxE,KAAK,EAAE,WAAW,CAAC,KAAK,EAAE,MAAM,CAAC;QACjC,MAAM;KACP,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Taste-eval cores — the PURE bridge from debiased `TasteVerdict`s to the
|
|
3
|
+
* bench-layer taste metrics. Given verdicts (and the corpus ground-truth labels
|
|
4
|
+
* that produced them), these functions report how trustworthy the taste judge is
|
|
5
|
+
* and how the generated directions stack up against the operator reference.
|
|
6
|
+
*
|
|
7
|
+
* Everything here is pure and deterministic: NO IO, NO model, NO bench framework.
|
|
8
|
+
* The win-rate CIs (`wilsonInterval` / `bootstrapDiff95`) are computed at the
|
|
9
|
+
* bench layer from the raw counts these functions return — never re-implemented
|
|
10
|
+
* here — so this module stays a thin, framework-free numeric core.
|
|
11
|
+
*
|
|
12
|
+
* Tie-handling is uniform with the rest of the engine (`assessPageQuality`,
|
|
13
|
+
* `calibrateAgainstVotes`): a tie is never a win and never inflates a
|
|
14
|
+
* denominator, so every rate is a clean decisive proportion with integer
|
|
15
|
+
* `successes`/`n` the bench layer can hand straight to `wilsonInterval`.
|
|
16
|
+
*/
|
|
17
|
+
import type { RawVerdict, TasteAgreementResult, TasteMetrics, TastePair, TasteVerdict } from '../contracts.js';
|
|
18
|
+
export { calibrateAgainstVotes } from '../judge/rank.js';
|
|
19
|
+
/**
|
|
20
|
+
* One position-swapped comparison: the two slot-order raw verdicts for a single
|
|
21
|
+
* unordered pair. `ab` presented `aId`→SLOT A and `bId`→SLOT B; `ba` is the swap
|
|
22
|
+
* (`bId`→SLOT A, `aId`→SLOT B). This mirrors the two `judge.compare` calls
|
|
23
|
+
* `judgePair` issues per repetition, so a bench harness can record both raw
|
|
24
|
+
* verdicts and feed them here to diagnose slot bias the reconciled
|
|
25
|
+
* `TasteVerdict` has already absorbed.
|
|
26
|
+
*/
|
|
27
|
+
export interface SwappedRun {
|
|
28
|
+
aId: string;
|
|
29
|
+
bId: string;
|
|
30
|
+
ab: RawVerdict;
|
|
31
|
+
ba: RawVerdict;
|
|
32
|
+
}
|
|
33
|
+
/** Judge position-bias diagnosis over a set of swapped runs. */
|
|
34
|
+
export interface PositionBiasResult {
|
|
35
|
+
/**
|
|
36
|
+
* Fraction of DECISIVE swapped runs (both orders named a winner) whose winning
|
|
37
|
+
* id flipped with the slot — i.e. the judge tracked the physical position, not
|
|
38
|
+
* the design. 0 = no measurable slot bias; 1 = pure slot bias.
|
|
39
|
+
*/
|
|
40
|
+
biasRate: number;
|
|
41
|
+
/** Number of swapped runs where BOTH orders were decisive (the denominator). */
|
|
42
|
+
n: number;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Judge-vs-label agreement over corpus-vs-corpus taste pairs. Each `TastePair`
|
|
46
|
+
* carries a known-stronger / known-weaker member (the ground-truth label); the
|
|
47
|
+
* judge agrees when its debiased verdict for that pair picks the stronger id.
|
|
48
|
+
* Ties (judge said tie) and pairs the judge never compared are excluded from
|
|
49
|
+
* `n`. Empty → `{ agreementRate: 0, n: 0 }`, never NaN.
|
|
50
|
+
*
|
|
51
|
+
* Reuses `calibrateAgainstVotes`: a corpus label IS exactly a human vote for the
|
|
52
|
+
* stronger id, so the same agreement walk applies — pair lookup is unordered, so
|
|
53
|
+
* a verdict recorded in either slot order resolves correctly.
|
|
54
|
+
*/
|
|
55
|
+
export declare function tasteAgreement(pairs: TastePair[], verdicts: TasteVerdict[]): TasteAgreementResult;
|
|
56
|
+
/**
|
|
57
|
+
* Generated-vs-reference metrics: how often a generated direction beats the
|
|
58
|
+
* single operator reference. `winsVsReference` counts the decisive comparisons
|
|
59
|
+
* the generated side won; `comparisons` counts the decisive comparisons that
|
|
60
|
+
* backed it. Ties, self-pairs, and verdicts not involving `referenceId` are
|
|
61
|
+
* excluded from `comparisons`, so the bench layer can form a clean Wilson
|
|
62
|
+
* interval `wilsonInterval(winsVsReference, comparisons)`. `corpusOrderAgreement`
|
|
63
|
+
* is intentionally left undefined here — it is a DIFFERENT verdict set
|
|
64
|
+
* (corpus-vs-corpus); the caller folds it in from `tasteAgreement`. Empty → 0
|
|
65
|
+
* wins / 0 comparisons, never NaN.
|
|
66
|
+
*/
|
|
67
|
+
export declare function tasteMetricsFromVerdicts(referenceId: string, verdicts: TasteVerdict[]): TasteMetrics;
|
|
68
|
+
/**
|
|
69
|
+
* Position-bias rate from swapped runs. A run is DECISIVE when both slot orders
|
|
70
|
+
* named a winner; among decisive runs, the judge is position-biased on that run
|
|
71
|
+
* when the winning id flips with the slot (it picked the same physical slot both
|
|
72
|
+
* times — exactly the `reconcileVerdicts` "position bias → tie" branch, measured
|
|
73
|
+
* here as a rate). Runs where either order tied are excluded from `n`. Empty →
|
|
74
|
+
* `{ biasRate: 0, n: 0 }`, never NaN.
|
|
75
|
+
*/
|
|
76
|
+
export declare function positionBiasRate(runs: SwappedRun[]): PositionBiasResult;
|
|
77
|
+
//# sourceMappingURL=taste-core.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"taste-core.d.ts","sourceRoot":"","sources":["../../../../../src/design/audit/reference/eval/taste-core.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAEV,UAAU,EACV,oBAAoB,EACpB,YAAY,EACZ,SAAS,EACT,YAAY,EACb,MAAM,iBAAiB,CAAA;AAMxB,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAA;AAUxD;;;;;;;GAOG;AACH,MAAM,WAAW,UAAU;IACzB,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,MAAM,CAAA;IACX,EAAE,EAAE,UAAU,CAAA;IACd,EAAE,EAAE,UAAU,CAAA;CACf;AAED,gEAAgE;AAChE,MAAM,WAAW,kBAAkB;IACjC;;;;OAIG;IACH,QAAQ,EAAE,MAAM,CAAA;IAChB,gFAAgF;IAChF,CAAC,EAAE,MAAM,CAAA;CACV;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,SAAS,EAAE,EAAE,QAAQ,EAAE,YAAY,EAAE,GAAG,oBAAoB,CAIjG;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,wBAAwB,CAAC,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,EAAE,GAAG,YAAY,CAWpG;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,UAAU,EAAE,GAAG,kBAAkB,CAWvE"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Taste-eval cores — the PURE bridge from debiased `TasteVerdict`s to the
|
|
3
|
+
* bench-layer taste metrics. Given verdicts (and the corpus ground-truth labels
|
|
4
|
+
* that produced them), these functions report how trustworthy the taste judge is
|
|
5
|
+
* and how the generated directions stack up against the operator reference.
|
|
6
|
+
*
|
|
7
|
+
* Everything here is pure and deterministic: NO IO, NO model, NO bench framework.
|
|
8
|
+
* The win-rate CIs (`wilsonInterval` / `bootstrapDiff95`) are computed at the
|
|
9
|
+
* bench layer from the raw counts these functions return — never re-implemented
|
|
10
|
+
* here — so this module stays a thin, framework-free numeric core.
|
|
11
|
+
*
|
|
12
|
+
* Tie-handling is uniform with the rest of the engine (`assessPageQuality`,
|
|
13
|
+
* `calibrateAgainstVotes`): a tie is never a win and never inflates a
|
|
14
|
+
* denominator, so every rate is a clean decisive proportion with integer
|
|
15
|
+
* `successes`/`n` the bench layer can hand straight to `wilsonInterval`.
|
|
16
|
+
*/
|
|
17
|
+
import { calibrateAgainstVotes } from '../judge/rank.js';
|
|
18
|
+
// Re-export the human-vote calibration hook so the taste eval has a single
|
|
19
|
+
// import surface. The implementation lives in judge/rank — one solver, no
|
|
20
|
+
// duplicated agreement math.
|
|
21
|
+
export { calibrateAgainstVotes } from '../judge/rank.js';
|
|
22
|
+
const round4 = (n) => Math.round(n * 10000) / 10000;
|
|
23
|
+
function slotToId(slot, idForSlotA, idForSlotB) {
|
|
24
|
+
if (slot === 'A')
|
|
25
|
+
return idForSlotA;
|
|
26
|
+
if (slot === 'B')
|
|
27
|
+
return idForSlotB;
|
|
28
|
+
return 'tie';
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Judge-vs-label agreement over corpus-vs-corpus taste pairs. Each `TastePair`
|
|
32
|
+
* carries a known-stronger / known-weaker member (the ground-truth label); the
|
|
33
|
+
* judge agrees when its debiased verdict for that pair picks the stronger id.
|
|
34
|
+
* Ties (judge said tie) and pairs the judge never compared are excluded from
|
|
35
|
+
* `n`. Empty → `{ agreementRate: 0, n: 0 }`, never NaN.
|
|
36
|
+
*
|
|
37
|
+
* Reuses `calibrateAgainstVotes`: a corpus label IS exactly a human vote for the
|
|
38
|
+
* stronger id, so the same agreement walk applies — pair lookup is unordered, so
|
|
39
|
+
* a verdict recorded in either slot order resolves correctly.
|
|
40
|
+
*/
|
|
41
|
+
export function tasteAgreement(pairs, verdicts) {
|
|
42
|
+
const votes = pairs.map((p) => ({ aId: p.strongId, bId: p.weakId, winner: p.strongId }));
|
|
43
|
+
const { agreement, n } = calibrateAgainstVotes(verdicts, votes);
|
|
44
|
+
return { agreementRate: agreement, n };
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Generated-vs-reference metrics: how often a generated direction beats the
|
|
48
|
+
* single operator reference. `winsVsReference` counts the decisive comparisons
|
|
49
|
+
* the generated side won; `comparisons` counts the decisive comparisons that
|
|
50
|
+
* backed it. Ties, self-pairs, and verdicts not involving `referenceId` are
|
|
51
|
+
* excluded from `comparisons`, so the bench layer can form a clean Wilson
|
|
52
|
+
* interval `wilsonInterval(winsVsReference, comparisons)`. `corpusOrderAgreement`
|
|
53
|
+
* is intentionally left undefined here — it is a DIFFERENT verdict set
|
|
54
|
+
* (corpus-vs-corpus); the caller folds it in from `tasteAgreement`. Empty → 0
|
|
55
|
+
* wins / 0 comparisons, never NaN.
|
|
56
|
+
*/
|
|
57
|
+
export function tasteMetricsFromVerdicts(referenceId, verdicts) {
|
|
58
|
+
let winsVsReference = 0;
|
|
59
|
+
let comparisons = 0;
|
|
60
|
+
for (const v of verdicts) {
|
|
61
|
+
if (v.aId === v.bId)
|
|
62
|
+
continue;
|
|
63
|
+
if (v.aId !== referenceId && v.bId !== referenceId)
|
|
64
|
+
continue;
|
|
65
|
+
if (v.winner === 'tie')
|
|
66
|
+
continue;
|
|
67
|
+
comparisons += 1;
|
|
68
|
+
if (v.winner !== referenceId)
|
|
69
|
+
winsVsReference += 1;
|
|
70
|
+
}
|
|
71
|
+
return { winsVsReference, comparisons };
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Position-bias rate from swapped runs. A run is DECISIVE when both slot orders
|
|
75
|
+
* named a winner; among decisive runs, the judge is position-biased on that run
|
|
76
|
+
* when the winning id flips with the slot (it picked the same physical slot both
|
|
77
|
+
* times — exactly the `reconcileVerdicts` "position bias → tie" branch, measured
|
|
78
|
+
* here as a rate). Runs where either order tied are excluded from `n`. Empty →
|
|
79
|
+
* `{ biasRate: 0, n: 0 }`, never NaN.
|
|
80
|
+
*/
|
|
81
|
+
export function positionBiasRate(runs) {
|
|
82
|
+
let n = 0;
|
|
83
|
+
let biased = 0;
|
|
84
|
+
for (const run of runs) {
|
|
85
|
+
const w1 = slotToId(run.ab.winnerSlot, run.aId, run.bId);
|
|
86
|
+
const w2 = slotToId(run.ba.winnerSlot, run.bId, run.aId);
|
|
87
|
+
if (w1 === 'tie' || w2 === 'tie')
|
|
88
|
+
continue;
|
|
89
|
+
n += 1;
|
|
90
|
+
if (w1 !== w2)
|
|
91
|
+
biased += 1;
|
|
92
|
+
}
|
|
93
|
+
return { biasRate: n > 0 ? round4(biased / n) : 0, n };
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=taste-core.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"taste-core.js","sourceRoot":"","sources":["../../../../../src/design/audit/reference/eval/taste-core.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAUH,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAA;AAExD,2EAA2E;AAC3E,0EAA0E;AAC1E,6BAA6B;AAC7B,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAA;AAExD,MAAM,MAAM,GAAG,CAAC,CAAS,EAAU,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,KAAK,CAAC,GAAG,KAAK,CAAA;AAEnE,SAAS,QAAQ,CAAC,IAA8B,EAAE,UAAkB,EAAE,UAAkB;IACtF,IAAI,IAAI,KAAK,GAAG;QAAE,OAAO,UAAU,CAAA;IACnC,IAAI,IAAI,KAAK,GAAG;QAAE,OAAO,UAAU,CAAA;IACnC,OAAO,KAAK,CAAA;AACd,CAAC;AA6BD;;;;;;;;;;GAUG;AACH,MAAM,UAAU,cAAc,CAAC,KAAkB,EAAE,QAAwB;IACzE,MAAM,KAAK,GAAgB,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,QAAQ,EAAE,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAA;IACrG,MAAM,EAAE,SAAS,EAAE,CAAC,EAAE,GAAG,qBAAqB,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAA;IAC/D,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,CAAC,EAAE,CAAA;AACxC,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,wBAAwB,CAAC,WAAmB,EAAE,QAAwB;IACpF,IAAI,eAAe,GAAG,CAAC,CAAA;IACvB,IA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|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reference-grounded redesign generator — the LLM ADAPTER of the generative
|
|
3
|
+
* layer. Implements the `RedesignGenerator` contract.
|
|
4
|
+
*
|
|
5
|
+
* Responsibility is thin: for the top `count` retrieved exemplars it fans out
|
|
6
|
+
* one model call each (built by the pure `buildDirectionPrompt`), parses every
|
|
7
|
+
* response with the pure fail-closed `parseDirection`, streams each accepted
|
|
8
|
+
* direction through `onDirection`, and returns the directions in stable slot
|
|
9
|
+
* order. All grounding/prompt/parse decisions live in the pure cores; this file
|
|
10
|
+
* owns only the IO orchestration.
|
|
11
|
+
*
|
|
12
|
+
* Dependency injection: the model is supplied as a narrow `GenerationModel`
|
|
13
|
+
* callable, so the real `Brain` (which structurally satisfies it) is wired at
|
|
14
|
+
* the composition root while tests inject a deterministic mock — no model id is
|
|
15
|
+
* hard-coded here.
|
|
16
|
+
*
|
|
17
|
+
* Fan-out width is the direction `count` (2-3, budget-capped upstream by
|
|
18
|
+
* `engine/budget.planJudgeBudget`/`config.directionCount`), so the calls run
|
|
19
|
+
* fully in parallel via `Promise.allSettled` — no separate concurrency limiter
|
|
20
|
+
* is needed at this small, bounded width. A single failed or malformed call is
|
|
21
|
+
* dropped, never fatal and never fabricated.
|
|
22
|
+
*/
|
|
23
|
+
import type { RedesignGenerator } from '../contracts.js';
|
|
24
|
+
/**
|
|
25
|
+
* The narrow model boundary this adapter depends on — exactly `Brain.complete`'s
|
|
26
|
+
* shape, so the concrete `Brain` is assignable and a stub is trivial to inject.
|
|
27
|
+
*/
|
|
28
|
+
export interface GenerationModel {
|
|
29
|
+
complete(system: string, user: string, options?: {
|
|
30
|
+
maxOutputTokens?: number;
|
|
31
|
+
}): Promise<{
|
|
32
|
+
text: string;
|
|
33
|
+
tokensUsed?: number;
|
|
34
|
+
}>;
|
|
35
|
+
}
|
|
36
|
+
/** Construction-time defaults for the generator adapter. */
|
|
37
|
+
export interface BrainGeneratorOptions {
|
|
38
|
+
/** Default direction count when `generate` is called without one. */
|
|
39
|
+
count?: number;
|
|
40
|
+
/** Output-token cap per generation call (a full direction is large). */
|
|
41
|
+
maxOutputTokens?: number;
|
|
42
|
+
/** Forwarded to `buildDirectionPrompt` to bound injected DNA. */
|
|
43
|
+
maxRefChars?: number;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Build a `RedesignGenerator` backed by an injected `GenerationModel`.
|
|
47
|
+
*/
|
|
48
|
+
export declare function createBrainGenerator(brain: GenerationModel, opts?: BrainGeneratorOptions): RedesignGenerator;
|
|
49
|
+
//# sourceMappingURL=generator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../../../../src/design/audit/reference/generate/generator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,KAAK,EACV,iBAAiB,EAKlB,MAAM,iBAAiB,CAAA;AAIxB;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,QAAQ,CACN,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE;QAAE,eAAe,CAAC,EAAE,MAAM,CAAA;KAAE,GACrC,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAClD;AAED,4DAA4D;AAC5D,MAAM,WAAW,qBAAqB;IACpC,qEAAqE;IACrE,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,wEAAwE;IACxE,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,iEAAiE;IACjE,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AA+CD;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,eAAe,EACtB,IAAI,GAAE,qBAA0B,GAC/B,iBAAiB,CA0CnB"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reference-grounded redesign generator — the LLM ADAPTER of the generative
|
|
3
|
+
* layer. Implements the `RedesignGenerator` contract.
|
|
4
|
+
*
|
|
5
|
+
* Responsibility is thin: for the top `count` retrieved exemplars it fans out
|
|
6
|
+
* one model call each (built by the pure `buildDirectionPrompt`), parses every
|
|
7
|
+
* response with the pure fail-closed `parseDirection`, streams each accepted
|
|
8
|
+
* direction through `onDirection`, and returns the directions in stable slot
|
|
9
|
+
* order. All grounding/prompt/parse decisions live in the pure cores; this file
|
|
10
|
+
* owns only the IO orchestration.
|
|
11
|
+
*
|
|
12
|
+
* Dependency injection: the model is supplied as a narrow `GenerationModel`
|
|
13
|
+
* callable, so the real `Brain` (which structurally satisfies it) is wired at
|
|
14
|
+
* the composition root while tests inject a deterministic mock — no model id is
|
|
15
|
+
* hard-coded here.
|
|
16
|
+
*
|
|
17
|
+
* Fan-out width is the direction `count` (2-3, budget-capped upstream by
|
|
18
|
+
* `engine/budget.planJudgeBudget`/`config.directionCount`), so the calls run
|
|
19
|
+
* fully in parallel via `Promise.allSettled` — no separate concurrency limiter
|
|
20
|
+
* is needed at this small, bounded width. A single failed or malformed call is
|
|
21
|
+
* dropped, never fatal and never fabricated.
|
|
22
|
+
*/
|
|
23
|
+
import { buildDirectionPrompt } from './prompt.js';
|
|
24
|
+
import { parseDirection } from './parse.js';
|
|
25
|
+
const DEFAULT_MAX_OUTPUT_TOKENS = 2200;
|
|
26
|
+
const clampCount = (requested, available) => Math.max(0, Math.min(Math.floor(requested), available));
|
|
27
|
+
async function generateOne(model, ctx, hit, slot, allowedIds, opts, reasons, onDirection) {
|
|
28
|
+
try {
|
|
29
|
+
const { system, user } = buildDirectionPrompt(ctx, hit, { maxRefChars: opts.maxRefChars });
|
|
30
|
+
const { text, tokensUsed } = await model.complete(system, user, {
|
|
31
|
+
maxOutputTokens: opts.maxOutputTokens ?? DEFAULT_MAX_OUTPUT_TOKENS,
|
|
32
|
+
});
|
|
33
|
+
// The call's tokens count toward cost even when its response fails to parse —
|
|
34
|
+
// a malformed completion still billed. Only a thrown call (caught below)
|
|
35
|
+
// reports nothing, because it never produced a usage figure.
|
|
36
|
+
const tokens = tokensUsed ?? 0;
|
|
37
|
+
const parsed = parseDirection(text, allowedIds);
|
|
38
|
+
if (!parsed.ok) {
|
|
39
|
+
reasons.push(`slot ${slot} parse failed (len=${text.length})`);
|
|
40
|
+
if (process.env.BAD_DEBUG_REFGEN)
|
|
41
|
+
console.error(`[refgen] slot ${slot} parse failed: ${JSON.stringify(parsed)} | len=${text.length} head=${JSON.stringify(text.slice(0, 240))}`);
|
|
42
|
+
return { direction: null, tokensUsed: tokens };
|
|
43
|
+
}
|
|
44
|
+
// Normalise the id to a deterministic, collision-free slot id — parallel
|
|
45
|
+
// calls share a prompt skeleton and may echo the same example id. The
|
|
46
|
+
// model's evocative `name` and grounding are preserved.
|
|
47
|
+
const direction = { ...parsed.direction, id: `direction-${slot + 1}` };
|
|
48
|
+
onDirection?.(direction);
|
|
49
|
+
return { direction, tokensUsed: tokens };
|
|
50
|
+
}
|
|
51
|
+
catch (err) {
|
|
52
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
53
|
+
reasons.push(`slot ${slot} call failed: ${message}`);
|
|
54
|
+
if (process.env.BAD_DEBUG_REFGEN)
|
|
55
|
+
console.error(`[refgen] slot ${slot} call failed: ${message}`);
|
|
56
|
+
return { direction: null, tokensUsed: 0 };
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Build a `RedesignGenerator` backed by an injected `GenerationModel`.
|
|
61
|
+
*/
|
|
62
|
+
export function createBrainGenerator(brain, opts = {}) {
|
|
63
|
+
return {
|
|
64
|
+
async generate(ctx, exemplars, genOpts) {
|
|
65
|
+
const count = clampCount(genOpts?.count ?? opts.count ?? exemplars.length, exemplars.length);
|
|
66
|
+
const selected = exemplars.slice(0, count);
|
|
67
|
+
// Grounding is validated against the FULL retrieved set, so a direction may
|
|
68
|
+
// legitimately cite any retrieved exemplar, not only the one it was seeded
|
|
69
|
+
// with.
|
|
70
|
+
const allowedIds = exemplars.map((r) => r.exemplar.id);
|
|
71
|
+
// Per-call failure reasons collected here so a total wipeout reports WHY
|
|
72
|
+
// (e.g. an auth error) instead of a silent empty result downstream.
|
|
73
|
+
const reasons = [];
|
|
74
|
+
const settled = await Promise.allSettled(selected.map((hit, slot) => generateOne(brain, ctx, hit, slot, allowedIds, opts, reasons, genOpts?.onDirection)));
|
|
75
|
+
// Stable slot order; dropped (errored/rejected) calls simply leave a gap.
|
|
76
|
+
// Tokens accrue from EVERY completed call (parsed or not) so the cost the
|
|
77
|
+
// engine reports reflects what generation actually spent.
|
|
78
|
+
const directions = [];
|
|
79
|
+
let tokensUsed = 0;
|
|
80
|
+
for (const r of settled) {
|
|
81
|
+
if (r.status === 'fulfilled') {
|
|
82
|
+
tokensUsed += r.value.tokensUsed;
|
|
83
|
+
if (r.value.direction)
|
|
84
|
+
directions.push(r.value.direction);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
if (directions.length === 0 && selected.length > 0 && reasons.length > 0) {
|
|
88
|
+
console.warn(`[reference] all ${selected.length} redesign generation call(s) failed — first reason: ${reasons[0]}`);
|
|
89
|
+
}
|
|
90
|
+
return { directions, tokensUsed };
|
|
91
|
+
},
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=generator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../src/design/audit/reference/generate/generator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AASH,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAwB3C,MAAM,yBAAyB,GAAG,IAAI,CAAA;AAEtC,MAAM,UAAU,GAAG,CAAC,SAAiB,EAAE,SAAiB,EAAU,EAAE,CAClE,IAAI,C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C,EAAE,CAAC,CAAA;YAEtD,yEAAyE;YACzE,oEAAoE;YACpE,MAAM,OAAO,GAAa,EAAE,CAAA;YAC5B,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,UAAU,CACtC,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,CACzB,WAAW,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,WAAW,CAAC,CACpF,CACF,CAAA;YAED,0EAA0E;YAC1E,0EAA0E;YAC1E,0DAA0D;YAC1D,MAAM,UAAU,GAAwB,EAAE,CAAA;YAC1C,IAAI,UAAU,GAAG,CAAC,CAAA;YAClB,KAAK,MAAM,CAAC,IAAI,OAAO,EAAE,CAAC;gBACxB,IAAI,CAAC,CAAC,MAAM,KAAK,WAAW,EAAE,CAAC;oBAC7B,UAAU,IAAI,CAAC,CAAC,KAAK,CAAC,UAAU,CAAA;oBAChC,IAAI,CAAC,CAAC,KAAK,CAAC,SAAS;wBAAE,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,CAAA;gBAC3D,CAAC;YACH,CAAC;YACD,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACzE,OAAO,CAAC,IAAI,CACV,mBAAmB,QAAQ,CAAC,MAAM,uDAAuD,OAAO,CAAC,CAAC,CAAC,EAAE,CACtG,CAAA;YACH,CAAC;YACD,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,CAAA;QACnC,CAAC;KACF,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Redesign-direction parser — a PURE core of the generative layer.
|
|
3
|
+
*
|
|
4
|
+
* `parseDirection` turns one raw model response into a typed `RedesignDirection`
|
|
5
|
+
* or a typed `DirectionParseError`. It is FAIL-CLOSED by construction: malformed
|
|
6
|
+
* JSON, a missing/ill-typed field, an ungrounded direction, or a hallucinated
|
|
7
|
+
* exemplar id all yield an explicit error — never a fabricated or half-built
|
|
8
|
+
* direction. The generator drops errored calls rather than inventing content.
|
|
9
|
+
*
|
|
10
|
+
* Hostile-input safe: the response is parsed with `JSON.parse` only (no eval),
|
|
11
|
+
* and the returned direction is assembled FIELD-BY-FIELD from validated values,
|
|
12
|
+
* so unexpected keys (including `__proto__`) never leak into the result and no
|
|
13
|
+
* prototype is mutated.
|
|
14
|
+
*
|
|
15
|
+
* No IO, no LLM, no browser — unit-tested on string fixtures alone.
|
|
16
|
+
*/
|
|
17
|
+
import type { RedesignDirection, DirectionParseResult } from '../contracts.js';
|
|
18
|
+
/**
|
|
19
|
+
* Ids in `d.groundedInExemplarIds` that are NOT in `allowedIds` (the retrieved
|
|
20
|
+
* set). Empty ⇒ the direction is grounded only in real, retrieved exemplars.
|
|
21
|
+
*/
|
|
22
|
+
export declare function validateGrounding(d: RedesignDirection, allowedIds: string[]): string[];
|
|
23
|
+
/**
|
|
24
|
+
* Parse one model response into a `RedesignDirection`. Fail-closed: any defect
|
|
25
|
+
* returns a `DirectionParseError`, never a partial or invented direction.
|
|
26
|
+
*/
|
|
27
|
+
export declare function parseDirection(raw: string, allowedIds: string[]): DirectionParseResult;
|
|
28
|
+
//# sourceMappingURL=parse.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../../../../../src/design/audit/reference/generate/parse.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EACV,iBAAiB,EACjB,oBAAoB,EAKrB,MAAM,iBAAiB,CAAA;AAgFxB;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAGtF;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,oBAAoB,CAwDtF"}
|