@llm-dev-ops/agentics-cli 2.7.42 → 2.8.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/agents/analytics-hub/consensus/consensus.md +47 -0
- package/agents/analytics-hub/recommendation/recommendation.md +47 -0
- package/agents/auto-optimizer/model-select/model-select.md +49 -0
- package/agents/auto-optimizer/self-optimize/self-optimize.md +44 -0
- package/agents/auto-optimizer/token/token.md +50 -0
- package/agents/benchmark-exchange/publish/publish.md +29 -0
- package/agents/config-manager/validate/validate.md +40 -0
- package/agents/connector-hub/auth-identity/auth-identity.md +29 -0
- package/agents/connector-hub/database-query/database-query.md +29 -0
- package/agents/connector-hub/erp-surface/erp-surface.md +29 -0
- package/agents/connector-hub/event-normalize/event-normalize.md +29 -0
- package/agents/connector-hub/webhook-ingest/webhook-ingest.md +29 -0
- package/agents/copilot/clarifier/clarifier.md +47 -0
- package/agents/copilot/config/config.md +37 -0
- package/agents/copilot/decomposer/decomposer.md +46 -0
- package/agents/copilot/intent/intent.md +43 -0
- package/agents/copilot/meta-reasoner/meta-reasoner.md +43 -0
- package/agents/copilot/planner/planner.md +47 -0
- package/agents/copilot/reflection/reflection.md +40 -0
- package/agents/costops/attribution/attribution.md +39 -0
- package/agents/costops/budget/budget.md +40 -0
- package/agents/costops/forecast/forecast.md +40 -0
- package/agents/costops/roi/roi.md +37 -0
- package/agents/costops/tradeoff/tradeoff.md +39 -0
- package/agents/data-vault/access-control/access-control.md +46 -0
- package/agents/data-vault/anonymize/anonymize.md +54 -0
- package/agents/edge/caching/caching.md +46 -0
- package/agents/edge/circuit-breaker/circuit-breaker.md +44 -0
- package/agents/edge/execution-guard/execution-guard.md +41 -0
- package/agents/edge/failover/failover.md +45 -0
- package/agents/edge/tool-invoke/tool-invoke.md +44 -0
- package/agents/forge/api-translation/api-translation.md +29 -0
- package/agents/forge/cli/cli.md +29 -0
- package/agents/forge/sdk/sdk.md +29 -0
- package/agents/forge/version-compat/version-compat.md +29 -0
- package/agents/governance-dashboard/audit/audit.md +39 -0
- package/agents/governance-dashboard/impact/impact.md +37 -0
- package/agents/governance-dashboard/oversight/oversight.md +41 -0
- package/agents/incident-manager/escalation/escalation.md +45 -0
- package/agents/incident-manager/hitl/hitl.md +46 -0
- package/agents/incident-manager/post-mortem/post-mortem.md +52 -0
- package/agents/inference-gateway/route/route.md +29 -0
- package/agents/latency-lens/cold-start/cold-start.md +29 -0
- package/agents/latency-lens/latency/latency.md +29 -0
- package/agents/marketplace/deprecation/deprecation.md +29 -0
- package/agents/marketplace/package/package.md +29 -0
- package/agents/memory-graph/conversation/conversation.md +37 -0
- package/agents/memory-graph/decisions/decisions.md +45 -0
- package/agents/memory-graph/knowledge-graph/knowledge-graph.md +46 -0
- package/agents/memory-graph/lineage/lineage.md +37 -0
- package/agents/memory-graph/patterns/patterns.md +45 -0
- package/agents/memory-graph/retrieval/retrieval.md +43 -0
- package/agents/observatory/failures/failures.md +29 -0
- package/agents/observatory/health-check/health-check.md +29 -0
- package/agents/observatory/post-mortem/post-mortem.md +29 -0
- package/agents/observatory/slo/slo.md +29 -0
- package/agents/observatory/telemetry/telemetry.md +29 -0
- package/agents/observatory/usage-patterns/usage-patterns.md +29 -0
- package/agents/observatory/visualization/visualization.md +29 -0
- package/agents/orchestrator/dependencies/dependencies.md +40 -0
- package/agents/orchestrator/parallel/parallel.md +43 -0
- package/agents/orchestrator/retry/retry.md +45 -0
- package/agents/orchestrator/scheduler/scheduler.md +44 -0
- package/agents/orchestrator/state-machine/state-machine.md +53 -0
- package/agents/orchestrator/swarm/swarm.md +44 -0
- package/agents/orchestrator/workflow/workflow.md +48 -0
- package/agents/platform/decision/decision.md +40 -0
- package/agents/platform/decision-memo/decision-memo.md +69 -0
- package/agents/platform/executive-summary/executive-summary.md +44 -0
- package/agents/platform/risk-score/risk-score.md +50 -0
- package/agents/policy-engine/approval/approval.md +40 -0
- package/agents/policy-engine/constraints/constraints.md +38 -0
- package/agents/policy-engine/enforce/enforce.md +39 -0
- package/agents/registry/bootstrap/bootstrap.md +29 -0
- package/agents/registry/index/index.md +29 -0
- package/agents/registry/reputation/reputation.md +29 -0
- package/agents/research-lab/hypothesis/hypothesis.md +50 -0
- package/agents/research-lab/metrics/metrics.md +50 -0
- package/agents/schema-registry/validate/validate.md +37 -0
- package/agents/sentinel/alert/alert.md +29 -0
- package/agents/sentinel/anomaly/anomaly.md +29 -0
- package/agents/sentinel/correlation/correlation.md +29 -0
- package/agents/sentinel/drift/drift.md +29 -0
- package/agents/sentinel/rca/rca.md +29 -0
- package/agents/shield/abuse/abuse.md +29 -0
- package/agents/shield/credential-exposure/credential-exposure.md +29 -0
- package/agents/shield/moderation/moderation.md +29 -0
- package/agents/shield/pii/pii.md +29 -0
- package/agents/shield/prompt-injection/prompt-injection.md +29 -0
- package/agents/shield/redaction/redaction.md +29 -0
- package/agents/shield/safety-boundary/safety-boundary.md +29 -0
- package/agents/shield/secrets/secrets.md +29 -0
- package/agents/shield/toxicity/toxicity.md +29 -0
- package/agents/simulator/scenario/scenario.md +53 -0
- package/agents/simulator/what-if/what-if.md +52 -0
- package/agents/test-bench/adversarial/adversarial.md +33 -0
- package/agents/test-bench/benchmark/benchmark.md +34 -0
- package/agents/test-bench/bias/bias.md +33 -0
- package/agents/test-bench/compare/compare.md +33 -0
- package/agents/test-bench/consistency/consistency.md +33 -0
- package/agents/test-bench/faithfulness/faithfulness.md +34 -0
- package/agents/test-bench/golden-dataset/golden-dataset.md +33 -0
- package/agents/test-bench/hallucination/hallucination.md +34 -0
- package/agents/test-bench/prompt-sensitivity/prompt-sensitivity.md +33 -0
- package/agents/test-bench/quality/quality.md +33 -0
- package/agents/test-bench/red-team/red-team.md +33 -0
- package/agents/test-bench/regression/regression.md +33 -0
- package/agents/test-bench/stress/stress.md +34 -0
- package/agents/test-bench/synthetic-data/synthetic-data.md +35 -0
- package/dist/agents/agent-prompts.d.ts +77 -0
- package/dist/agents/agent-prompts.d.ts.map +1 -0
- package/dist/agents/agent-prompts.js +230 -0
- package/dist/agents/agent-prompts.js.map +1 -0
- package/dist/agents/repo-agent-runner.d.ts +1 -0
- package/dist/agents/repo-agent-runner.d.ts.map +1 -1
- package/dist/agents/repo-agent-runner.js +67 -35
- package/dist/agents/repo-agent-runner.js.map +1 -1
- package/dist/cli/index.js +22 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/commands/agents.d.ts +19 -0
- package/dist/commands/agents.d.ts.map +1 -1
- package/dist/commands/agents.js +344 -144
- package/dist/commands/agents.js.map +1 -1
- package/dist/pipeline/fleet-dispatch-bounds.d.ts +115 -0
- package/dist/pipeline/fleet-dispatch-bounds.d.ts.map +1 -0
- package/dist/pipeline/fleet-dispatch-bounds.js +190 -0
- package/dist/pipeline/fleet-dispatch-bounds.js.map +1 -0
- package/dist/pipeline/phase3/phases/domain-codegen.d.ts.map +1 -1
- package/dist/pipeline/phase3/phases/domain-codegen.js +8 -2
- package/dist/pipeline/phase3/phases/domain-codegen.js.map +1 -1
- package/dist/pipeline/phase4/phases/schema-generator.js +3 -3
- package/dist/pipeline/phase4/phases/schema-generator.js.map +1 -1
- package/dist/pipeline/phase7/coherence-gate.d.ts.map +1 -1
- package/dist/pipeline/phase7/coherence-gate.js +8 -24
- package/dist/pipeline/phase7/coherence-gate.js.map +1 -1
- package/dist/pipeline/phase7/coordinator.d.ts +34 -0
- package/dist/pipeline/phase7/coordinator.d.ts.map +1 -1
- package/dist/pipeline/phase7/coordinator.js +131 -71
- package/dist/pipeline/phase7/coordinator.js.map +1 -1
- package/dist/pipeline/phase7/field-mappers.d.ts +43 -0
- package/dist/pipeline/phase7/field-mappers.d.ts.map +1 -0
- package/dist/pipeline/phase7/field-mappers.js +278 -0
- package/dist/pipeline/phase7/field-mappers.js.map +1 -0
- package/dist/pipeline/phase7/field-writer.d.ts +53 -0
- package/dist/pipeline/phase7/field-writer.d.ts.map +1 -0
- package/dist/pipeline/phase7/field-writer.js +178 -0
- package/dist/pipeline/phase7/field-writer.js.map +1 -0
- package/dist/pipeline/phase7/writer-agent.d.ts +83 -0
- package/dist/pipeline/phase7/writer-agent.d.ts.map +1 -0
- package/dist/pipeline/phase7/writer-agent.js +174 -0
- package/dist/pipeline/phase7/writer-agent.js.map +1 -0
- package/dist/pipeline/ruflo-phase-executor.d.ts.map +1 -1
- package/dist/pipeline/ruflo-phase-executor.js +21 -6
- package/dist/pipeline/ruflo-phase-executor.js.map +1 -1
- package/dist/pipeline/swarm-orchestrator.d.ts +3 -41
- package/dist/pipeline/swarm-orchestrator.d.ts.map +1 -1
- package/dist/pipeline/swarm-orchestrator.js +9 -75
- package/dist/pipeline/swarm-orchestrator.js.map +1 -1
- package/dist/synthesis/fcv-coherence.d.ts +24 -0
- package/dist/synthesis/fcv-coherence.d.ts.map +1 -0
- package/dist/synthesis/fcv-coherence.js +36 -0
- package/dist/synthesis/fcv-coherence.js.map +1 -0
- package/dist/synthesis/financial-claim-extractor.d.ts +8 -0
- package/dist/synthesis/financial-claim-extractor.d.ts.map +1 -1
- package/dist/synthesis/financial-claim-extractor.js +74 -1
- package/dist/synthesis/financial-claim-extractor.js.map +1 -1
- package/dist/synthesis/financial-consistency-rules.d.ts.map +1 -1
- package/dist/synthesis/financial-consistency-rules.js +21 -12
- package/dist/synthesis/financial-consistency-rules.js.map +1 -1
- package/dist/synthesis/financial-consistency-runner.d.ts +12 -0
- package/dist/synthesis/financial-consistency-runner.d.ts.map +1 -1
- package/dist/synthesis/financial-consistency-runner.js +25 -3
- package/dist/synthesis/financial-consistency-runner.js.map +1 -1
- package/dist/synthesis/simulation-artifact-generator.d.ts.map +1 -1
- package/dist/synthesis/simulation-artifact-generator.js +5 -0
- package/dist/synthesis/simulation-artifact-generator.js.map +1 -1
- package/dist/synthesis/simulation-renderers.d.ts +2 -0
- package/dist/synthesis/simulation-renderers.d.ts.map +1 -1
- package/dist/synthesis/simulation-renderers.js +8 -8
- package/dist/synthesis/simulation-renderers.js.map +1 -1
- package/dist/synthesis/unit-economics-loader.d.ts +7 -0
- package/dist/synthesis/unit-economics-loader.d.ts.map +1 -1
- package/dist/synthesis/unit-economics-loader.js +11 -2
- package/dist/synthesis/unit-economics-loader.js.map +1 -1
- package/package.json +8 -7
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Phase 7 — Template-Family Field Mappers (ADR-PIPELINE-111 D4)
|
|
3
|
+
*
|
|
4
|
+
* The 87 deliverables collapse to 33 `templateId` families. Rather than a
|
|
5
|
+
* hand-coded projection per report (87×) or a single generic synthesizer
|
|
6
|
+
* (which produced undifferentiated prose), each family carries a small,
|
|
7
|
+
* data-only spec: what that document type is *for* and which agent outputs
|
|
8
|
+
* inform it. The LLM field-writer (`field-writer.ts`) consumes the spec to
|
|
9
|
+
* produce report-type-specific, grounded field values.
|
|
10
|
+
*
|
|
11
|
+
* This file is pure data + lookups — no I/O, no LLM calls, no template logic.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Generic fallback used when a templateId has no explicit spec. Keeps the
|
|
15
|
+
* writer functional for any future template without a registry edit.
|
|
16
|
+
*/
|
|
17
|
+
export const GENERIC_FAMILY_SPEC = {
|
|
18
|
+
templateId: '__generic__',
|
|
19
|
+
label: 'Consulting Deliverable',
|
|
20
|
+
focus: 'Produce a clear, decision-grade consulting document. Fill each field with ' +
|
|
21
|
+
'specific, evidence-backed content derived from the run artifacts and agent ' +
|
|
22
|
+
'analysis. Be concrete and tied to the business context; never invent dollar ' +
|
|
23
|
+
'figures — reuse the figures already provided in the document.',
|
|
24
|
+
emphasizeAgents: ['platform', 'analytics-hub', 'copilot'],
|
|
25
|
+
};
|
|
26
|
+
const SPECS = [
|
|
27
|
+
{
|
|
28
|
+
templateId: 'executive-summary',
|
|
29
|
+
label: 'Executive Summary / Decision Memo',
|
|
30
|
+
focus: 'A board-level summary: the recommendation, the opportunity, key findings, ' +
|
|
31
|
+
'financial impact, risk profile, and recommended next steps. Lead with the ' +
|
|
32
|
+
'decision requested. Every claim ties to agent evidence; figures reuse the ' +
|
|
33
|
+
'provided fcv values.',
|
|
34
|
+
emphasizeAgents: ['platform/executive-summary', 'platform/decision-memo', 'analytics-hub/recommendation', 'platform/risk-score'],
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
templateId: 'recommendation-paper',
|
|
38
|
+
label: 'Recommendation Paper',
|
|
39
|
+
focus: 'A structured recommendation: the options considered, the chosen option and ' +
|
|
40
|
+
'why, expected outcomes, and the implementation ask. Make the rationale and ' +
|
|
41
|
+
'trade-offs explicit.',
|
|
42
|
+
emphasizeAgents: ['analytics-hub/recommendation', 'analytics-hub/consensus', 'platform/decision'],
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
templateId: 'board-deck',
|
|
46
|
+
label: 'Board / Steering Committee Deck',
|
|
47
|
+
focus: 'Slide-style talking points for a board: situation, complication, ' +
|
|
48
|
+
'recommendation, financials, risks, ask. Each field is a tight, presentable ' +
|
|
49
|
+
'bullet block, not prose paragraphs.',
|
|
50
|
+
emphasizeAgents: ['platform/executive-summary', 'platform/decision', 'analytics-hub/recommendation'],
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
templateId: 'scenario-analysis',
|
|
54
|
+
label: 'Scenario Analysis & Sensitivity',
|
|
55
|
+
focus: 'Scenario and sensitivity analysis: the variables driving outcomes, their ' +
|
|
56
|
+
'ranges, decision trees / sensitivity tables, and which assumptions are ' +
|
|
57
|
+
'load-bearing. Distinguish ranges from point estimates.',
|
|
58
|
+
emphasizeAgents: ['simulator/what-if', 'simulator/scenario', 'platform/risk-score'],
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
templateId: 'business-case-scenario',
|
|
62
|
+
label: 'Business Case (Base / Best / Worst)',
|
|
63
|
+
focus: 'A scenario-weighted business case: assumptions, the investment, the ' +
|
|
64
|
+
'expected benefits, and the net outcome for this scenario. Numbers are ' +
|
|
65
|
+
'derived views of the canonical figures — never new origins.',
|
|
66
|
+
emphasizeAgents: ['costops/roi', 'costops/forecast', 'simulator/scenario'],
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
templateId: 'financial-model',
|
|
70
|
+
label: 'Financial Model / ROI / Cost-Benefit / Unit Economics',
|
|
71
|
+
focus: 'A financial model view: cost-benefit breakdown, ROI / IRR / NPV / payback, ' +
|
|
72
|
+
'and unit economics. ALL monetary values come from the provided canonical ' +
|
|
73
|
+
'figures; show derivation, never invent. Narrate what the numbers mean.',
|
|
74
|
+
emphasizeAgents: ['costops/roi', 'costops/attribution', 'costops/forecast', 'costops/tradeoff'],
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
templateId: 'tco',
|
|
78
|
+
label: 'Total Cost of Ownership',
|
|
79
|
+
focus: 'A TCO analysis: cost categories over the horizon, one-time vs recurring, ' +
|
|
80
|
+
'and the cumulative total. Reuse canonical cost figures.',
|
|
81
|
+
emphasizeAgents: ['costops/attribution', 'costops/forecast'],
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
templateId: 'value-capture',
|
|
85
|
+
label: 'Value Capture / Benefits Realization',
|
|
86
|
+
focus: 'A value-capture plan: the benefit streams, how each is measured, owners, ' +
|
|
87
|
+
'and the realization timeline. Tie benefits to the canonical savings figures.',
|
|
88
|
+
emphasizeAgents: ['costops/roi', 'research-lab/metrics', 'observatory/slo'],
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
templateId: 'cost-reduction-plan',
|
|
92
|
+
label: 'Cost Reduction / Optimization Plan',
|
|
93
|
+
focus: 'A cost-optimization plan: where cost is today, the optimization levers, the ' +
|
|
94
|
+
'expected savings per lever, and the sequencing.',
|
|
95
|
+
emphasizeAgents: ['costops/attribution', 'costops/tradeoff', 'auto-optimizer/token', 'auto-optimizer/model-select'],
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
templateId: 'strategy-doc',
|
|
99
|
+
label: 'Strategy Document',
|
|
100
|
+
focus: 'A strategy document for the specific strategy kind: the strategic context, ' +
|
|
101
|
+
'objectives, the chosen approach, and the execution implications. Be ' +
|
|
102
|
+
'specific to the strategy kind named in the title.',
|
|
103
|
+
emphasizeAgents: ['platform/decision', 'research-lab/hypothesis', 'analytics-hub/recommendation'],
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
templateId: 'transformation-blueprint',
|
|
107
|
+
label: 'Transformation / Roadmap Blueprint',
|
|
108
|
+
focus: 'A transformation roadmap: the target state, the phased path to it, ' +
|
|
109
|
+
'milestones with absolute dates, and dependencies. Anchor dates to the ' +
|
|
110
|
+
'pilot-start anchor in the roadmap artifact.',
|
|
111
|
+
emphasizeAgents: ['orchestrator/workflow', 'orchestrator/dependencies', 'platform/decision'],
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
templateId: 'operating-model-design',
|
|
115
|
+
label: 'Operating Model Design',
|
|
116
|
+
focus: 'A target operating model: capabilities, the org-and-process shape, ' +
|
|
117
|
+
'governance, and the operating rhythm.',
|
|
118
|
+
emphasizeAgents: ['orchestrator/workflow', 'governance-dashboard/oversight'],
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
templateId: 'capability-maturity',
|
|
122
|
+
label: 'Capability Maturity Assessment',
|
|
123
|
+
focus: 'A maturity assessment: the capability dimensions, current vs target level ' +
|
|
124
|
+
'per dimension, and the gaps to close.',
|
|
125
|
+
emphasizeAgents: ['observatory/health-check', 'research-lab/metrics'],
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
templateId: 'target-state-architecture',
|
|
129
|
+
label: 'Target-State / Integration Architecture',
|
|
130
|
+
focus: 'A target architecture: the component blueprint, integration points, and the ' +
|
|
131
|
+
'current→target delta. Ground in the integration assessment.',
|
|
132
|
+
emphasizeAgents: ['connector-hub/event-normalize', 'connector-hub/erp-surface', 'edge/tool-invoke'],
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
templateId: 'org-structure',
|
|
136
|
+
label: 'Org Structure / Workforce / Resource Plan',
|
|
137
|
+
focus: 'An org and resourcing plan: roles and reporting lines, the workforce/talent ' +
|
|
138
|
+
'needs, and the resource plan to staff the initiative.',
|
|
139
|
+
emphasizeAgents: ['orchestrator/scheduler', 'orchestrator/parallel'],
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
templateId: 'raci',
|
|
143
|
+
label: 'RACI Matrix',
|
|
144
|
+
focus: 'A RACI matrix: the key activities, and Responsible/Accountable/Consulted/' +
|
|
145
|
+
'Informed assignments per activity. Output a clean table.',
|
|
146
|
+
emphasizeAgents: ['orchestrator/workflow', 'governance-dashboard/oversight'],
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
templateId: 'process-maps',
|
|
150
|
+
label: 'Process Maps (L2–L5) / Service Delivery',
|
|
151
|
+
focus: 'Process maps: the end-to-end process steps at the requested level, hand-offs, ' +
|
|
152
|
+
'and the service-delivery model.',
|
|
153
|
+
emphasizeAgents: ['orchestrator/workflow', 'orchestrator/state-machine'],
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
templateId: 'performance-dashboard',
|
|
157
|
+
label: 'KPI / OKR / Performance Dashboard / Scorecards',
|
|
158
|
+
focus: 'A performance measurement design: the KPIs/OKRs, their definitions and ' +
|
|
159
|
+
'targets, the SLA/KPI thresholds, and the dashboard/scorecard layout.',
|
|
160
|
+
emphasizeAgents: ['observatory/slo', 'observatory/telemetry', 'research-lab/metrics'],
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
templateId: 'vendor-strategy',
|
|
164
|
+
label: 'Vendor / Partner Strategy & Scorecards',
|
|
165
|
+
focus: 'A vendor/partner strategy: selection criteria, the evaluation scorecard, and ' +
|
|
166
|
+
'the partnering recommendation.',
|
|
167
|
+
emphasizeAgents: ['platform/decision', 'analytics-hub/recommendation'],
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
templateId: 'platform-selection',
|
|
171
|
+
label: 'Platform Selection / Build-vs-Buy / ML Eval',
|
|
172
|
+
focus: 'A platform/option evaluation: the options, the weighted scoring against ' +
|
|
173
|
+
'criteria, build-vs-buy-vs-partner, and the selection with rationale.',
|
|
174
|
+
emphasizeAgents: ['inference-gateway/route', 'test-bench/compare', 'platform/decision'],
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
templateId: 'data-strategy',
|
|
178
|
+
label: 'Data Strategy & Data Model',
|
|
179
|
+
focus: 'A data strategy: the data domains, the target data model, governance, and ' +
|
|
180
|
+
'the data quality / lineage approach.',
|
|
181
|
+
emphasizeAgents: ['memory-graph/knowledge-graph', 'memory-graph/lineage', 'connector-hub/database-query'],
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
templateId: 'risk-register',
|
|
185
|
+
label: 'Risk Register / Mitigation / Cyber Risk',
|
|
186
|
+
focus: 'A risk register: enumerated risks with likelihood × impact, scoring, the ' +
|
|
187
|
+
'mitigation plan and owner per risk. Output a structured risk table.',
|
|
188
|
+
emphasizeAgents: ['platform/risk-score', 'sentinel/anomaly', 'shield/safety-boundary'],
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
templateId: 'regulatory-impact',
|
|
192
|
+
label: 'Regulatory / Compliance / Audit / Responsible-AI',
|
|
193
|
+
focus: 'A compliance assessment: the applicable obligations, the impact, the control ' +
|
|
194
|
+
'framework, audit-readiness, and any responsible-AI considerations.',
|
|
195
|
+
emphasizeAgents: ['governance-dashboard/audit', 'policy-engine/enforce', 'shield/pii', 'data-vault/access-control'],
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
templateId: 'research-report',
|
|
199
|
+
label: 'Market Research / Segmentation / VoC / Benchmarking / SWOT-RCA',
|
|
200
|
+
focus: 'A research report for the specific research kind: the method, the findings, ' +
|
|
201
|
+
'the segments/competitors/benchmarks/SWOT as applicable, and the implications.',
|
|
202
|
+
emphasizeAgents: ['research-lab/hypothesis', 'research-lab/metrics', 'analytics-hub/recommendation'],
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
templateId: 'internal-diagnostic',
|
|
206
|
+
label: 'Internal Diagnostic Assessment',
|
|
207
|
+
focus: 'An internal diagnostic: current-state health across dimensions, the issues ' +
|
|
208
|
+
'found, and the prioritised gaps.',
|
|
209
|
+
emphasizeAgents: ['observatory/health-check', 'observatory/failures', 'sentinel/rca'],
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
templateId: 'program-charter',
|
|
213
|
+
label: 'Program Charter',
|
|
214
|
+
focus: 'A program charter: objectives, scope, governance, stakeholders, and success ' +
|
|
215
|
+
'criteria.',
|
|
216
|
+
emphasizeAgents: ['orchestrator/workflow', 'governance-dashboard/oversight'],
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
templateId: 'pmo-framework',
|
|
220
|
+
label: 'PMO / Milestone / Dependency / Budget / Comms',
|
|
221
|
+
focus: 'A program-management artifact: the PMO operating framework, milestones with ' +
|
|
222
|
+
'dates, the dependency map, budget plan, or communication plan as the slug ' +
|
|
223
|
+
'indicates.',
|
|
224
|
+
emphasizeAgents: ['orchestrator/scheduler', 'orchestrator/dependencies', 'incident-manager/hitl'],
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
templateId: 'implementation-roadmap',
|
|
228
|
+
label: 'Implementation Roadmap / Backlog / Delivery',
|
|
229
|
+
focus: 'An implementation plan: the roadmap, the initiative backlog/WBS, and the ' +
|
|
230
|
+
'delivery sequencing with dependencies.',
|
|
231
|
+
emphasizeAgents: ['orchestrator/workflow', 'orchestrator/dependencies', 'orchestrator/parallel'],
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
templateId: 'deployment-plan',
|
|
235
|
+
label: 'Delivery / Release / Pilot / Deployment / Hypercare',
|
|
236
|
+
focus: 'A delivery/deployment artifact: the release plan, pilot/MVP definition, ' +
|
|
237
|
+
'deployment steps, and hypercare/support as the slug indicates.',
|
|
238
|
+
emphasizeAgents: ['edge/failover', 'edge/circuit-breaker', 'incident-manager/escalation'],
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
templateId: 'testing-strategy',
|
|
242
|
+
label: 'Testing Strategy',
|
|
243
|
+
focus: 'A testing strategy: the test levels, coverage targets, environments, and the ' +
|
|
244
|
+
'quality gates.',
|
|
245
|
+
emphasizeAgents: ['test-bench/benchmark', 'test-bench/regression', 'test-bench/quality'],
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
templateId: 'continuous-improvement',
|
|
249
|
+
label: 'Continuous Improvement / Post-Implementation Review',
|
|
250
|
+
focus: 'A continuous-improvement artifact: the improvement loop, the metrics ' +
|
|
251
|
+
'reviewed, lessons learned, and the post-implementation review findings.',
|
|
252
|
+
emphasizeAgents: ['observatory/usage-patterns', 'research-lab/metrics', 'auto-optimizer/self-optimize'],
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
templateId: 'rfp-response',
|
|
256
|
+
label: 'RFP/RFQ/RFI Response / Commercial Model',
|
|
257
|
+
focus: 'A commercial response: the requirement responses, the commercial/pricing ' +
|
|
258
|
+
'model, and the contracting position.',
|
|
259
|
+
emphasizeAgents: ['costops/tradeoff', 'platform/decision'],
|
|
260
|
+
},
|
|
261
|
+
{
|
|
262
|
+
templateId: 'digital-twin',
|
|
263
|
+
label: 'Digital Twin / Experimentation Framework',
|
|
264
|
+
focus: 'A digital-twin / experimentation artifact: the model of the system, the ' +
|
|
265
|
+
'experiments to run, and the metrics that decide them.',
|
|
266
|
+
emphasizeAgents: ['simulator/what-if', 'simulator/scenario', 'research-lab/hypothesis'],
|
|
267
|
+
},
|
|
268
|
+
];
|
|
269
|
+
const BY_TEMPLATE_ID = new Map(SPECS.map((s) => [s.templateId, s]));
|
|
270
|
+
/** Resolve the family spec for a templateId, falling back to the generic spec. */
|
|
271
|
+
export function getFamilySpec(templateId) {
|
|
272
|
+
return BY_TEMPLATE_ID.get(templateId) ?? GENERIC_FAMILY_SPEC;
|
|
273
|
+
}
|
|
274
|
+
/** All explicitly-registered template families (excludes the generic fallback). */
|
|
275
|
+
export function registeredFamilyIds() {
|
|
276
|
+
return [...BY_TEMPLATE_ID.keys()];
|
|
277
|
+
}
|
|
278
|
+
//# sourceMappingURL=field-mappers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"field-mappers.js","sourceRoot":"","sources":["../../../src/pipeline/phase7/field-mappers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAwBH;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAe;IAC7C,UAAU,EAAE,aAAa;IACzB,KAAK,EAAE,wBAAwB;IAC/B,KAAK,EACH,4EAA4E;QAC5E,6EAA6E;QAC7E,8EAA8E;QAC9E,+DAA+D;IACjE,eAAe,EAAE,CAAC,UAAU,EAAE,eAAe,EAAE,SAAS,CAAC;CAC1D,CAAC;AAEF,MAAM,KAAK,GAA8B;IACvC;QACE,UAAU,EAAE,mBAAmB;QAC/B,KAAK,EAAE,mCAAmC;QAC1C,KAAK,EACH,4EAA4E;YAC5E,4EAA4E;YAC5E,4EAA4E;YAC5E,sBAAsB;QACxB,eAAe,EAAE,CAAC,4BAA4B,EAAE,wBAAwB,EAAE,8BAA8B,EAAE,qBAAqB,CAAC;KACjI;IACD;QACE,UAAU,EAAE,sBAAsB;QAClC,KAAK,EAAE,sBAAsB;QAC7B,KAAK,EACH,6EAA6E;YAC7E,6EAA6E;YAC7E,sBAAsB;QACxB,eAAe,EAAE,CAAC,8BAA8B,EAAE,yBAAyB,EAAE,mBAAmB,CAAC;KAClG;IACD;QACE,UAAU,EAAE,YAAY;QACxB,KAAK,EAAE,iCAAiC;QACxC,KAAK,EACH,mEAAmE;YACnE,6EAA6E;YAC7E,qCAAqC;QACvC,eAAe,EAAE,CAAC,4BAA4B,EAAE,mBAAmB,EAAE,8BAA8B,CAAC;KACrG;IACD;QACE,UAAU,EAAE,mBAAmB;QAC/B,KAAK,EAAE,iCAAiC;QACxC,KAAK,EACH,2EAA2E;YAC3E,yEAAyE;YACzE,wDAAwD;QAC1D,eAAe,EAAE,CAAC,mBAAmB,EA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BAAmB,EAAE,oBAAoB,EAAE,yBAAyB,CAAC;KACxF;CACF,CAAC;AAEF,MAAM,cAAc,GAAoC,IAAI,GAAG,CAC7D,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,CACpC,CAAC;AAEF,kFAAkF;AAClF,MAAM,UAAU,aAAa,CAAC,UAAkB;IAC9C,OAAO,cAAc,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,mBAAmB,CAAC;AAC/D,CAAC;AAED,mFAAmF;AACnF,MAAM,UAAU,mBAAmB;IACjC,OAAO,CAAC,GAAG,cAAc,CAAC,IAAI,EAAE,CAAC,CAAC;AACpC,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Phase 7 — LLM Field Writer (ADR-PIPELINE-111 D2/D4)
|
|
3
|
+
*
|
|
4
|
+
* Given the placeholders a template still needs, the grounded agent outputs,
|
|
5
|
+
* and the family spec, produce a JSON `Record<placeholder,string>` of values.
|
|
6
|
+
*
|
|
7
|
+
* Channel policy (ADR-PIPELINE-098 / 110): Claude Code Max only — the local
|
|
8
|
+
* `claude --print` binary. NEVER the billed Anthropic API. If the binary is
|
|
9
|
+
* unavailable the writer returns `{}` and the caller degrades to the
|
|
10
|
+
* deterministic render (skeleton), exactly like `synthesizeExecutiveDocument`.
|
|
11
|
+
*
|
|
12
|
+
* Coherence (ADR-PIPELINE-111 D5): the prompt forbids inventing dollar figures
|
|
13
|
+
* and a post-parse guard drops any returned value that introduces a `$` amount
|
|
14
|
+
* not already present in the provided figures — financial values stay owned by
|
|
15
|
+
* `unit-economics.json`.
|
|
16
|
+
*/
|
|
17
|
+
import type { FamilySpec } from './field-mappers.js';
|
|
18
|
+
export interface FieldWriterInput {
|
|
19
|
+
readonly slug: string;
|
|
20
|
+
readonly templateId: string;
|
|
21
|
+
readonly family: FamilySpec;
|
|
22
|
+
/** Placeholder keys the writer should fill (already-filled keys excluded). */
|
|
23
|
+
readonly placeholders: ReadonlyArray<string>;
|
|
24
|
+
/** The user's business context for the run. */
|
|
25
|
+
readonly scenarioQuery: string;
|
|
26
|
+
/** Grounded structured outputs from the row's sourceAgents (D3). */
|
|
27
|
+
readonly agentEvidence: string;
|
|
28
|
+
/** Deterministic fields already resolved (artifact/slug/reserved) — context. */
|
|
29
|
+
readonly knownFields: Readonly<Record<string, string>>;
|
|
30
|
+
/** Canonical financial figures the writer MAY cite verbatim (never alter). */
|
|
31
|
+
readonly canonicalFigures: string;
|
|
32
|
+
/** Trace id for degradation logging. */
|
|
33
|
+
readonly traceId?: string;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Produce field values for the requested placeholders. Returns `{}` on any
|
|
37
|
+
* failure (no binary, timeout, unparseable output) — never throws.
|
|
38
|
+
*/
|
|
39
|
+
export declare function writeFieldsViaLLM(input: FieldWriterInput): Promise<Record<string, string>>;
|
|
40
|
+
/** Build the family-scoped, JSON-returning prompt. */
|
|
41
|
+
export declare function buildFieldWriterPrompt(input: FieldWriterInput): string;
|
|
42
|
+
/**
|
|
43
|
+
* Extract the first balanced top-level JSON object from arbitrary LLM text
|
|
44
|
+
* (handles ```json fences and leading/trailing prose).
|
|
45
|
+
*/
|
|
46
|
+
export declare function extractJsonObject(text: string): Record<string, unknown> | null;
|
|
47
|
+
/**
|
|
48
|
+
* Keep only requested keys with non-empty string values, and drop any value
|
|
49
|
+
* that introduces a dollar figure not present in the canonical figures
|
|
50
|
+
* (ADR-111 D5 — financials stay owned by unit-economics.json).
|
|
51
|
+
*/
|
|
52
|
+
export declare function sanitizeFields(parsed: Record<string, unknown>, input: FieldWriterInput): Record<string, string>;
|
|
53
|
+
//# sourceMappingURL=field-writer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"field-writer.d.ts","sourceRoot":"","sources":["../../../src/pipeline/phase7/field-writer.ts"],"names":[],"mappings":"AAAA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
|
+
* Phase 7 — LLM Field Writer (ADR-PIPELINE-111 D2/D4)
|
|
3
|
+
*
|
|
4
|
+
* Given the placeholders a template still needs, the grounded agent outputs,
|
|
5
|
+
* and the family spec, produce a JSON `Record<placeholder,string>` of values.
|
|
6
|
+
*
|
|
7
|
+
* Channel policy (ADR-PIPELINE-098 / 110): Claude Code Max only — the local
|
|
8
|
+
* `claude --print` binary. NEVER the billed Anthropic API. If the binary is
|
|
9
|
+
* unavailable the writer returns `{}` and the caller degrades to the
|
|
10
|
+
* deterministic render (skeleton), exactly like `synthesizeExecutiveDocument`.
|
|
11
|
+
*
|
|
12
|
+
* Coherence (ADR-PIPELINE-111 D5): the prompt forbids inventing dollar figures
|
|
13
|
+
* and a post-parse guard drops any returned value that introduces a `$` amount
|
|
14
|
+
* not already present in the provided figures — financial values stay owned by
|
|
15
|
+
* `unit-economics.json`.
|
|
16
|
+
*/
|
|
17
|
+
const PROMPT_TIMEOUT_MS = 90_000;
|
|
18
|
+
const MAX_EVIDENCE = 6000;
|
|
19
|
+
const MAX_CONTEXT = 2500;
|
|
20
|
+
/**
|
|
21
|
+
* Produce field values for the requested placeholders. Returns `{}` on any
|
|
22
|
+
* failure (no binary, timeout, unparseable output) — never throws.
|
|
23
|
+
*/
|
|
24
|
+
export async function writeFieldsViaLLM(input) {
|
|
25
|
+
if (input.placeholders.length === 0)
|
|
26
|
+
return {};
|
|
27
|
+
const prompt = buildFieldWriterPrompt(input);
|
|
28
|
+
try {
|
|
29
|
+
const { execSync } = await import('node:child_process');
|
|
30
|
+
const { writeFileSync, unlinkSync } = await import('node:fs');
|
|
31
|
+
const claudeBin = process.env['AGENTICS_CLAUDE_BIN'] || 'claude';
|
|
32
|
+
const tmpFile = `/tmp/agentics-p7-fields-${input.slug}-${Date.now()}.txt`;
|
|
33
|
+
writeFileSync(tmpFile, prompt, 'utf-8');
|
|
34
|
+
try {
|
|
35
|
+
const raw = execSync(`${claudeBin} --print < "${tmpFile}"`, {
|
|
36
|
+
encoding: 'utf-8',
|
|
37
|
+
timeout: PROMPT_TIMEOUT_MS,
|
|
38
|
+
maxBuffer: 2_000_000,
|
|
39
|
+
shell: '/bin/sh',
|
|
40
|
+
});
|
|
41
|
+
const parsed = extractJsonObject(raw);
|
|
42
|
+
if (!parsed)
|
|
43
|
+
return {};
|
|
44
|
+
return sanitizeFields(parsed, input);
|
|
45
|
+
}
|
|
46
|
+
finally {
|
|
47
|
+
try {
|
|
48
|
+
unlinkSync(tmpFile);
|
|
49
|
+
}
|
|
50
|
+
catch { /* ignore */ }
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
// Binary unavailable / timeout / non-zero exit — caller degrades.
|
|
55
|
+
return {};
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/** Build the family-scoped, JSON-returning prompt. */
|
|
59
|
+
export function buildFieldWriterPrompt(input) {
|
|
60
|
+
const placeholderList = input.placeholders.map((p) => ` - ${p}`).join('\n');
|
|
61
|
+
const known = Object.entries(input.knownFields)
|
|
62
|
+
.filter(([, v]) => typeof v === 'string' && v.trim().length > 0)
|
|
63
|
+
.slice(0, 20)
|
|
64
|
+
.map(([k, v]) => ` ${k}: ${truncate(v, 200)}`)
|
|
65
|
+
.join('\n');
|
|
66
|
+
return [
|
|
67
|
+
`You are a senior management-consulting writer producing the "${input.family.label}" deliverable (slug: ${input.slug}).`,
|
|
68
|
+
'',
|
|
69
|
+
`DOCUMENT PURPOSE:\n${input.family.focus}`,
|
|
70
|
+
'',
|
|
71
|
+
`BUSINESS CONTEXT (for understanding — do not echo verbatim):\n${truncate(input.scenarioQuery, MAX_CONTEXT)}`,
|
|
72
|
+
'',
|
|
73
|
+
input.agentEvidence.trim()
|
|
74
|
+
? `AGENT ANALYSIS (your evidence — use these findings, do not contradict them):\n${truncate(input.agentEvidence, MAX_EVIDENCE)}`
|
|
75
|
+
: 'AGENT ANALYSIS: (none available — derive from business context and known fields)',
|
|
76
|
+
'',
|
|
77
|
+
input.canonicalFigures.trim()
|
|
78
|
+
? `CANONICAL FINANCIAL FIGURES (the ONLY dollar amounts you may use — cite verbatim, never alter or invent):\n${truncate(input.canonicalFigures, 1500)}`
|
|
79
|
+
: '',
|
|
80
|
+
'',
|
|
81
|
+
known ? `ALREADY-FILLED FIELDS (for consistency — do not restate):\n${known}` : '',
|
|
82
|
+
'',
|
|
83
|
+
'TASK: Return a single JSON object whose keys are EXACTLY the field names below and whose values are the Markdown content for each field. Each value must be specific to this document type and grounded in the agent analysis and business context.',
|
|
84
|
+
'',
|
|
85
|
+
`FIELDS TO FILL:\n${placeholderList}`,
|
|
86
|
+
'',
|
|
87
|
+
'RULES:',
|
|
88
|
+
'- Output ONLY the JSON object. No prose, no markdown fences, no commentary.',
|
|
89
|
+
'- Keys must be exactly the field names listed (omit a key only if you genuinely cannot produce content for it).',
|
|
90
|
+
'- Values are Markdown strings (may contain lists, short tables, bold). Keep each focused and decision-grade.',
|
|
91
|
+
'- NEVER invent dollar figures. Use ONLY the canonical figures provided above; if a field needs money you do not have, describe it qualitatively.',
|
|
92
|
+
'- Be concrete and specific to the business context — no generic filler.',
|
|
93
|
+
].filter((l) => l !== '').join('\n');
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Extract the first balanced top-level JSON object from arbitrary LLM text
|
|
97
|
+
* (handles ```json fences and leading/trailing prose).
|
|
98
|
+
*/
|
|
99
|
+
export function extractJsonObject(text) {
|
|
100
|
+
if (typeof text !== 'string')
|
|
101
|
+
return null;
|
|
102
|
+
const fence = text.match(/```(?:json)?\s*([\s\S]*?)```/);
|
|
103
|
+
const candidate = fence ? fence[1] : text;
|
|
104
|
+
const start = candidate.indexOf('{');
|
|
105
|
+
if (start < 0)
|
|
106
|
+
return null;
|
|
107
|
+
let depth = 0;
|
|
108
|
+
let inStr = false;
|
|
109
|
+
let esc = false;
|
|
110
|
+
for (let i = start; i < candidate.length; i++) {
|
|
111
|
+
const ch = candidate[i];
|
|
112
|
+
if (inStr) {
|
|
113
|
+
if (esc)
|
|
114
|
+
esc = false;
|
|
115
|
+
else if (ch === '\\')
|
|
116
|
+
esc = true;
|
|
117
|
+
else if (ch === '"')
|
|
118
|
+
inStr = false;
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
if (ch === '"')
|
|
122
|
+
inStr = true;
|
|
123
|
+
else if (ch === '{')
|
|
124
|
+
depth++;
|
|
125
|
+
else if (ch === '}') {
|
|
126
|
+
depth--;
|
|
127
|
+
if (depth === 0) {
|
|
128
|
+
const slice = candidate.slice(start, i + 1);
|
|
129
|
+
try {
|
|
130
|
+
const obj = JSON.parse(slice);
|
|
131
|
+
return obj && typeof obj === 'object' && !Array.isArray(obj) ? obj : null;
|
|
132
|
+
}
|
|
133
|
+
catch {
|
|
134
|
+
return null;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return null;
|
|
140
|
+
}
|
|
141
|
+
/** Detects a `$<number>` money token (e.g. $340K, $8.5M, $1,200). */
|
|
142
|
+
const MONEY_RE = /\$\s?\d[\d,.]*\s?[KkMmBb]?/g;
|
|
143
|
+
/**
|
|
144
|
+
* Keep only requested keys with non-empty string values, and drop any value
|
|
145
|
+
* that introduces a dollar figure not present in the canonical figures
|
|
146
|
+
* (ADR-111 D5 — financials stay owned by unit-economics.json).
|
|
147
|
+
*/
|
|
148
|
+
export function sanitizeFields(parsed, input) {
|
|
149
|
+
const allowed = new Set(input.placeholders);
|
|
150
|
+
const canonicalMoney = new Set((input.canonicalFigures.match(MONEY_RE) ?? []).map(normalizeMoney));
|
|
151
|
+
const out = {};
|
|
152
|
+
for (const [k, v] of Object.entries(parsed)) {
|
|
153
|
+
if (!allowed.has(k))
|
|
154
|
+
continue;
|
|
155
|
+
if (typeof v !== 'string')
|
|
156
|
+
continue;
|
|
157
|
+
const value = v.trim();
|
|
158
|
+
if (value.length === 0)
|
|
159
|
+
continue;
|
|
160
|
+
const introduced = (value.match(MONEY_RE) ?? []).map(normalizeMoney);
|
|
161
|
+
const invents = introduced.some((m) => !canonicalMoney.has(m));
|
|
162
|
+
if (invents)
|
|
163
|
+
continue; // drop fields that fabricate dollar figures
|
|
164
|
+
out[k] = value;
|
|
165
|
+
}
|
|
166
|
+
return out;
|
|
167
|
+
}
|
|
168
|
+
function normalizeMoney(s) {
|
|
169
|
+
// Strip whitespace, uppercase the magnitude suffix, and trim any trailing
|
|
170
|
+
// punctuation the greedy `[\d,.]*` may have captured (e.g. "$1,200." → "$1,200").
|
|
171
|
+
return s.replace(/\s/g, '').replace(/[.,]+$/, '').toUpperCase();
|
|
172
|
+
}
|
|
173
|
+
function truncate(s, max) {
|
|
174
|
+
if (typeof s !== 'string')
|
|
175
|
+
return '';
|
|
176
|
+
return s.length > max ? `${s.slice(0, max)}…` : s;
|
|
177
|
+
}
|
|
178
|
+
//# sourceMappingURL=field-writer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"field-writer.js","sourceRoot":"","sources":["../../../src/pipeline/phase7/field-writer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAsBH,MAAM,iBAAiB,GAAG,MAAM,CAAC;AACjC,MAAM,YAAY,GAAG,IAAI,CAAC;AAC1B,MAAM,WAAW,GAAG,IAAI,CAAC;AAEzB;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,KAAuB;IAEvB,IAAI,KAAK,CAAC,YAAY,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IAE/C,MAAM,MAAM,GAAG,sBAAsB,CAAC,KAAK,CAAC,CAAC;IAE7C,IAAI,CAAC;QACH,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,MAAM,CAAC,oBAAoB,CAAC,CAAC;QACxD,MAAM,EAAE,aAAa,EAAE,UAAU,EAAE,GAAG,MAAM,MAAM,CAAC,SAAS,CAAC,CAAC;QAC9D,MAAM,SAAS,GAAG,OAAO,CAAC,GAA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,CAAC,CAAC,CAAC,CAAC;QAC/D,IAAI,OAAO;YAAE,SAAS,CAAC,4CAA4C;QACnE,GAAG,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC;IACjB,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,SAAS,cAAc,CAAC,CAAS;IAC/B,0EAA0E;IAC1E,kFAAkF;IAClF,OAAO,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;AAClE,CAAC;AAED,SAAS,QAAQ,CAAC,CAAS,EAAE,GAAW;IACtC,IAAI,OAAO,CAAC,KAAK,QAAQ;QAAE,OAAO,EAAE,CAAC;IACrC,OAAO,CAAC,CAAC,MAAM,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AACpD,CAAC"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Phase 7 — Writer-Agent Field Contract & Agent-Sourced Generation
|
|
3
|
+
* (ADR-PIPELINE-111 D1, D2, D3, D8)
|
|
4
|
+
*
|
|
5
|
+
* Closes the ADR-098 "Q-future" hole: the Ruflo writer fan-out returned only
|
|
6
|
+
* metadata (`RufloPhaseResult`), so its result was discarded (`void rufloResult`)
|
|
7
|
+
* and every deliverable fell back to shared local extraction. This module
|
|
8
|
+
* produces a real, per-deliverable field map by:
|
|
9
|
+
*
|
|
10
|
+
* 1. Invoking the row's `sourceAgents` through the repo-backed dispatch
|
|
11
|
+
* (`executeAgentsInvokeCommand`, lazy-imported to avoid a load-time cycle),
|
|
12
|
+
* cached per run (D3).
|
|
13
|
+
* 2. Resolving each template placeholder by precedence — agent > artifact >
|
|
14
|
+
* slug > llm > _TBD_ — with financial/structural fields reserved so they
|
|
15
|
+
* always come from `unit-economics.json` (D2/D5).
|
|
16
|
+
* 3. Filling remaining gaps with the family-scoped LLM field-writer (D4),
|
|
17
|
+
* grounded on the agent evidence.
|
|
18
|
+
*
|
|
19
|
+
* Never throws. Agent / LLM failures degrade gracefully (D8); the caller turns
|
|
20
|
+
* an empty/under-filled result into the existing skeleton.
|
|
21
|
+
*/
|
|
22
|
+
import type { DeliverableSpec } from './deliverables-registry.js';
|
|
23
|
+
export type FieldProvenance = 'agent' | 'artifact' | 'slug' | 'llm';
|
|
24
|
+
export interface AgentCallRecord {
|
|
25
|
+
/** `domain/agent` reference. */
|
|
26
|
+
readonly ref: string;
|
|
27
|
+
readonly status: number;
|
|
28
|
+
readonly tier?: string;
|
|
29
|
+
}
|
|
30
|
+
export interface WriterResult {
|
|
31
|
+
readonly slug: string;
|
|
32
|
+
readonly templateId: string;
|
|
33
|
+
/** Resolved placeholder → value (non-reserved fields the writer produced). */
|
|
34
|
+
readonly fields: Record<string, string>;
|
|
35
|
+
/** Per-field source for the values in `fields`. */
|
|
36
|
+
readonly field_provenance: Record<string, FieldProvenance>;
|
|
37
|
+
/** Placeholders left unfilled after all tiers (will render as `_TBD_`). */
|
|
38
|
+
readonly unfilled: string[];
|
|
39
|
+
/** Agents actually invoked this row and their status (D7). */
|
|
40
|
+
readonly agents_called: AgentCallRecord[];
|
|
41
|
+
}
|
|
42
|
+
export interface WriterContext {
|
|
43
|
+
readonly scenarioQuery: string;
|
|
44
|
+
readonly runDir: string;
|
|
45
|
+
readonly traceId: string;
|
|
46
|
+
/** Deterministic fields from run-artifact extraction (artifact tier). */
|
|
47
|
+
readonly artifactFields: Readonly<Record<string, string>>;
|
|
48
|
+
/** Deterministic fields derived from the slug (slug tier). */
|
|
49
|
+
readonly slugFields: Readonly<Record<string, string>>;
|
|
50
|
+
/**
|
|
51
|
+
* Reserved fields that ALWAYS win (financial fcv values, title, date,
|
|
52
|
+
* consensusBanner, fcvBlock, attribution). Never overridden by agent/LLM —
|
|
53
|
+
* this is the D5 coherence guarantee. Keys present here are excluded from
|
|
54
|
+
* agent/LLM filling.
|
|
55
|
+
*/
|
|
56
|
+
readonly reservedFields: Readonly<Record<string, string>>;
|
|
57
|
+
/** Canonical financial figures the LLM may cite verbatim (the fcv block). */
|
|
58
|
+
readonly canonicalFigures: string;
|
|
59
|
+
/** D3 toggle — false skips agent dispatch (AGENTICS_PHASE7_NO_AGENTS=1). */
|
|
60
|
+
readonly enableAgents: boolean;
|
|
61
|
+
/** D4 toggle — false skips the LLM field-writer (AGENTICS_PHASE7_NO_LLM=1). */
|
|
62
|
+
readonly enableLLM: boolean;
|
|
63
|
+
}
|
|
64
|
+
/** Cached agent output for the current run, keyed by `domain/agent`. */
|
|
65
|
+
export interface CachedAgentOutput {
|
|
66
|
+
readonly status: number;
|
|
67
|
+
readonly tier?: string;
|
|
68
|
+
readonly data: unknown;
|
|
69
|
+
}
|
|
70
|
+
export type AgentOutputCache = Map<string, CachedAgentOutput>;
|
|
71
|
+
/** Signature of the dispatch function (injectable for tests). */
|
|
72
|
+
export type AgentDispatch = (domain: string, agent: string, payload: Record<string, unknown>) => Promise<{
|
|
73
|
+
status: number;
|
|
74
|
+
tier?: string;
|
|
75
|
+
data: unknown;
|
|
76
|
+
}>;
|
|
77
|
+
/**
|
|
78
|
+
* Generate the field map for one deliverable. Pure orchestration over the
|
|
79
|
+
* three tiers; the renderer remains the single place that turns fields into
|
|
80
|
+
* Markdown (determinism preserved).
|
|
81
|
+
*/
|
|
82
|
+
export declare function generateDeliverableFields(spec: DeliverableSpec, templateBody: string, ctx: WriterContext, agentCache: AgentOutputCache, dispatch?: AgentDispatch): Promise<WriterResult>;
|
|
83
|
+
//# sourceMappingURL=writer-agent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"writer-agent.d.ts","sourceRoot":"","sources":["../../../src/pipeline/phase7/writer-agent.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAKH,OAAO,KAAK,EAAE,eAAe,E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