avorelo 0.1.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/LICENSE +21 -0
- package/README.md +56 -0
- package/bin/avorelo +9 -0
- package/package.json +135 -0
- package/scripts/README.md +40 -0
- package/scripts/cco-dashboard.js +252 -0
- package/scripts/cco-status.js +430 -0
- package/scripts/lib/activation/account-state.js +37 -0
- package/scripts/lib/activation/activation-runner.js +546 -0
- package/scripts/lib/activation/activation-self-healing.js +480 -0
- package/scripts/lib/activation/activation-state.js +83 -0
- package/scripts/lib/activation/activation-summary.js +191 -0
- package/scripts/lib/activation/adapters/claude-code.js +77 -0
- package/scripts/lib/activation/adapters/codex-cli.js +52 -0
- package/scripts/lib/activation/adapters/cursor.js +37 -0
- package/scripts/lib/activation/adapters/github-agent.js +39 -0
- package/scripts/lib/activation/adapters/terminal.js +42 -0
- package/scripts/lib/activation/adapters/vscode.js +39 -0
- package/scripts/lib/activation/adapters/windsurf.js +37 -0
- package/scripts/lib/activation/ai-surface-detector.js +151 -0
- package/scripts/lib/activation/connect-account.js +145 -0
- package/scripts/lib/activation/detect-environment.js +75 -0
- package/scripts/lib/activation/detect-hosts.js +62 -0
- package/scripts/lib/activation/format-activation-output.js +109 -0
- package/scripts/lib/activation/next-action.js +43 -0
- package/scripts/lib/activation/repair-engine.js +219 -0
- package/scripts/lib/activation-distribution-readiness.js +507 -0
- package/scripts/lib/adapter-conformance.js +176 -0
- package/scripts/lib/adapter-readiness.js +417 -0
- package/scripts/lib/adapter-safety-boundaries.js +335 -0
- package/scripts/lib/adapter-technical-readiness-gate.js +205 -0
- package/scripts/lib/agent-access-governance.js +455 -0
- package/scripts/lib/agent-enforcement.js +765 -0
- package/scripts/lib/agent-policy-profile.js +210 -0
- package/scripts/lib/agent-security/action-evaluator.js +507 -0
- package/scripts/lib/agent-security/adapter-registry.js +98 -0
- package/scripts/lib/agent-security/auto-policy.js +139 -0
- package/scripts/lib/agent-security/bounded-scan.js +93 -0
- package/scripts/lib/agent-security/enforcement-adapter.js +174 -0
- package/scripts/lib/agent-security/enforcement-engine.js +1129 -0
- package/scripts/lib/agent-security/file-write-adapter.js +183 -0
- package/scripts/lib/agent-security/file-write-rules.js +178 -0
- package/scripts/lib/agent-security/index.js +3342 -0
- package/scripts/lib/agent-security/instruction-risk.js +181 -0
- package/scripts/lib/agent-security/mcp-action-adapter.js +185 -0
- package/scripts/lib/agent-security/mcp-action-rules.js +184 -0
- package/scripts/lib/agent-security/package-action-adapter.js +175 -0
- package/scripts/lib/agent-security/package-action-rules.js +233 -0
- package/scripts/lib/agent-security/performance.js +148 -0
- package/scripts/lib/agent-security/permission-minimizer.js +403 -0
- package/scripts/lib/agent-security/scan-cache.js +74 -0
- package/scripts/lib/agent-security/source-trust.js +146 -0
- package/scripts/lib/ai-install-prompt.js +288 -0
- package/scripts/lib/ai-workspace-hygiene.js +1499 -0
- package/scripts/lib/alpha-activation.js +520 -0
- package/scripts/lib/alpha-feedback.js +263 -0
- package/scripts/lib/alpha-readiness-gate.js +332 -0
- package/scripts/lib/anti-gaming.js +169 -0
- package/scripts/lib/artifact-health.js +431 -0
- package/scripts/lib/attribution.js +180 -0
- package/scripts/lib/audit.js +289 -0
- package/scripts/lib/avorelo-skill-registry.js +810 -0
- package/scripts/lib/batch-jobs.js +71 -0
- package/scripts/lib/brain-pack.js +578 -0
- package/scripts/lib/brand-boundary.js +424 -0
- package/scripts/lib/brand.js +74 -0
- package/scripts/lib/browser-capability.js +1048 -0
- package/scripts/lib/browser-proof-preflight.js +321 -0
- package/scripts/lib/cache-readiness.js +187 -0
- package/scripts/lib/canonical-reentry.js +162 -0
- package/scripts/lib/capability-packs.js +314 -0
- package/scripts/lib/capability-recommender.js +512 -0
- package/scripts/lib/capability-registry.js +1059 -0
- package/scripts/lib/carry-forward-surfacing.js +194 -0
- package/scripts/lib/ccusage-adapter.js +188 -0
- package/scripts/lib/company-loop.js +1149 -0
- package/scripts/lib/config.js +637 -0
- package/scripts/lib/context-acquisition-plan.js +287 -0
- package/scripts/lib/context-budget-guard.js +170 -0
- package/scripts/lib/context-budget-scanner.js +257 -0
- package/scripts/lib/context-optimizer.js +715 -0
- package/scripts/lib/context-reduction-plan.js +178 -0
- package/scripts/lib/context-safety.js +88 -0
- package/scripts/lib/context-savings-engine.js +158 -0
- package/scripts/lib/cost-evidence.js +254 -0
- package/scripts/lib/cross-host-install-plan.js +308 -0
- package/scripts/lib/cross-host-install-readiness.js +237 -0
- package/scripts/lib/cross-host-value-flow.js +268 -0
- package/scripts/lib/dashboard.js +900 -0
- package/scripts/lib/design-partner-feedback.js +346 -0
- package/scripts/lib/entitlements.js +100 -0
- package/scripts/lib/execution-packet.js +559 -0
- package/scripts/lib/experimentation-events.js +547 -0
- package/scripts/lib/external-capability-compliance.js +107 -0
- package/scripts/lib/external-user-simulation.js +166 -0
- package/scripts/lib/failure-recovery-readiness.js +81 -0
- package/scripts/lib/failure-recovery.js +419 -0
- package/scripts/lib/feedback-intelligence.js +537 -0
- package/scripts/lib/feedback-signals.js +205 -0
- package/scripts/lib/file-integrity.js +68 -0
- package/scripts/lib/fsx.js +127 -0
- package/scripts/lib/full-readiness-gate.js +451 -0
- package/scripts/lib/guidance-builder.js +174 -0
- package/scripts/lib/hook-apply.js +1019 -0
- package/scripts/lib/hook-baseline.js +310 -0
- package/scripts/lib/hook-config-preview.js +275 -0
- package/scripts/lib/hook-contracts.js +290 -0
- package/scripts/lib/hook-safety-boundary-readiness.js +80 -0
- package/scripts/lib/host-capability-matrix.js +351 -0
- package/scripts/lib/host-support-context.js +254 -0
- package/scripts/lib/http-hook-action.js +538 -0
- package/scripts/lib/install-ai-readiness.js +84 -0
- package/scripts/lib/install-intake-risk.js +1037 -0
- package/scripts/lib/install-journey-intelligence.js +329 -0
- package/scripts/lib/intervention-guidance.js +57 -0
- package/scripts/lib/known-limitations.js +115 -0
- package/scripts/lib/l8-path-truth.js +146 -0
- package/scripts/lib/launch-hardening-gate.js +436 -0
- package/scripts/lib/launch-readiness.js +628 -0
- package/scripts/lib/learning-memory.js +686 -0
- package/scripts/lib/lifecycle-hooks.js +802 -0
- package/scripts/lib/local-package-smoke.js +423 -0
- package/scripts/lib/local-pricing.js +299 -0
- package/scripts/lib/mcp-enforcement.js +311 -0
- package/scripts/lib/mcp-least-privilege-policy.js +303 -0
- package/scripts/lib/mcp-tool-inventory.js +388 -0
- package/scripts/lib/mcp-tool-risk.js +0 -0
- package/scripts/lib/memory.js +335 -0
- package/scripts/lib/metrics.js +699 -0
- package/scripts/lib/micro-proof.js +133 -0
- package/scripts/lib/next-run-context.js +436 -0
- package/scripts/lib/operating-value.js +1648 -0
- package/scripts/lib/optimization-v3.js +122 -0
- package/scripts/lib/orchestration/adapters/_shared.js +49 -0
- package/scripts/lib/orchestration/adapters/aider.js +18 -0
- package/scripts/lib/orchestration/adapters/claude-code.js +35 -0
- package/scripts/lib/orchestration/adapters/codex.js +35 -0
- package/scripts/lib/orchestration/adapters/gemini-cli.js +18 -0
- package/scripts/lib/orchestration/adapters/git.js +25 -0
- package/scripts/lib/orchestration/adapters/index.js +31 -0
- package/scripts/lib/orchestration/adapters/lm-studio.js +18 -0
- package/scripts/lib/orchestration/adapters/ollama.js +18 -0
- package/scripts/lib/orchestration/adapters/opencode.js +18 -0
- package/scripts/lib/orchestration/adapters/openrouter.js +18 -0
- package/scripts/lib/orchestration/adapters/test-runner.js +25 -0
- package/scripts/lib/orchestration/cli.js +438 -0
- package/scripts/lib/orchestration/execution-manager.js +279 -0
- package/scripts/lib/orchestration/handoff.js +314 -0
- package/scripts/lib/orchestration/index.js +456 -0
- package/scripts/lib/orchestration/inventory.js +47 -0
- package/scripts/lib/orchestration/model-discovery.js +498 -0
- package/scripts/lib/orchestration/model-profiler.js +170 -0
- package/scripts/lib/orchestration/model-profiles.js +252 -0
- package/scripts/lib/orchestration/model-refresh-policy.js +72 -0
- package/scripts/lib/orchestration/proof-writer.js +349 -0
- package/scripts/lib/orchestration/provider-discovery/aider.js +49 -0
- package/scripts/lib/orchestration/provider-discovery/claude-code.js +56 -0
- package/scripts/lib/orchestration/provider-discovery/codex.js +49 -0
- package/scripts/lib/orchestration/provider-discovery/common.js +186 -0
- package/scripts/lib/orchestration/provider-discovery/gemini.js +106 -0
- package/scripts/lib/orchestration/provider-discovery/lm-studio.js +118 -0
- package/scripts/lib/orchestration/provider-discovery/models-dev.js +12 -0
- package/scripts/lib/orchestration/provider-discovery/ollama.js +100 -0
- package/scripts/lib/orchestration/provider-discovery/opencode.js +47 -0
- package/scripts/lib/orchestration/provider-discovery/openrouter.js +44 -0
- package/scripts/lib/orchestration/risk-classifier.js +130 -0
- package/scripts/lib/orchestration/routing-policy.js +486 -0
- package/scripts/lib/orchestration/settings.js +112 -0
- package/scripts/lib/orchestration/state.js +165 -0
- package/scripts/lib/orchestration/verification-manager.js +138 -0
- package/scripts/lib/output-profiles.js +146 -0
- package/scripts/lib/package-content-audit.js +368 -0
- package/scripts/lib/package-runtime.js +278 -0
- package/scripts/lib/plan-surface.js +53 -0
- package/scripts/lib/plans.js +2318 -0
- package/scripts/lib/policy-provider.js +27 -0
- package/scripts/lib/prelaunch-activation-readiness.js +409 -0
- package/scripts/lib/prelaunch-evidence-store.js +816 -0
- package/scripts/lib/prelaunch-intelligence.js +869 -0
- package/scripts/lib/pricing-experiment.js +118 -0
- package/scripts/lib/pro-moment-events.js +77 -0
- package/scripts/lib/pro-moment-state.js +227 -0
- package/scripts/lib/pro-moments.js +1216 -0
- package/scripts/lib/product-learning-events.js +629 -0
- package/scripts/lib/project-profile.js +555 -0
- package/scripts/lib/prompt-compiler.js +280 -0
- package/scripts/lib/prompt-lint.js +32 -0
- package/scripts/lib/prompt-suggestions.js +52 -0
- package/scripts/lib/proof-canonical.js +398 -0
- package/scripts/lib/proof-drilldown.js +383 -0
- package/scripts/lib/proof-events.js +342 -0
- package/scripts/lib/proof-history.js +243 -0
- package/scripts/lib/proof-metrics.js +296 -0
- package/scripts/lib/proof-outcome-evidence.js +134 -0
- package/scripts/lib/proof-receipt.js +335 -0
- package/scripts/lib/proof-record.js +461 -0
- package/scripts/lib/public-activation-distribution-gate.js +258 -0
- package/scripts/lib/public-cli.js +3891 -0
- package/scripts/lib/public-distribution-truth.js +211 -0
- package/scripts/lib/public-install-claim-checker.js +294 -0
- package/scripts/lib/publish-provenance-readiness.js +283 -0
- package/scripts/lib/readiness-delta.js +218 -0
- package/scripts/lib/readiness-evidence-closure.js +196 -0
- package/scripts/lib/reentry-memory-capture.js +241 -0
- package/scripts/lib/reentry-memory-retrieval.js +302 -0
- package/scripts/lib/reentry-memory-status.js +146 -0
- package/scripts/lib/reentry-memory-store.js +178 -0
- package/scripts/lib/reentry-state.js +66 -0
- package/scripts/lib/release-candidate-bundle.js +166 -0
- package/scripts/lib/remediation.js +81 -0
- package/scripts/lib/repo-map.js +391 -0
- package/scripts/lib/run-improvements-lifecycle.js +330 -0
- package/scripts/lib/run-improvements.js +789 -0
- package/scripts/lib/runtime-decision-policy.js +387 -0
- package/scripts/lib/safe-path-engine.js +705 -0
- package/scripts/lib/safe-run-controller.js +887 -0
- package/scripts/lib/score.js +262 -0
- package/scripts/lib/seamless-enforcement.js +329 -0
- package/scripts/lib/seamless-outcome.js +689 -0
- package/scripts/lib/seamless-reality-gate.js +5043 -0
- package/scripts/lib/security-risk-classifier.js +511 -0
- package/scripts/lib/security-scan.js +384 -0
- package/scripts/lib/session-context-optimizer.js +1211 -0
- package/scripts/lib/session-timing.js +315 -0
- package/scripts/lib/skill-hygiene.js +805 -0
- package/scripts/lib/skill-packs.js +161 -0
- package/scripts/lib/skills-operating-layer.js +580 -0
- package/scripts/lib/smart-work-routing.js +768 -0
- package/scripts/lib/source-catalog.js +700 -0
- package/scripts/lib/status-value-summary.js +32 -0
- package/scripts/lib/support-bundle.js +578 -0
- package/scripts/lib/task-continuation.js +440 -0
- package/scripts/lib/test-helpers.js +15 -0
- package/scripts/lib/tier.js +38 -0
- package/scripts/lib/token-context-quality-gate.js +370 -0
- package/scripts/lib/token-cost-capture.js +187 -0
- package/scripts/lib/token-cost-intelligence.js +358 -0
- package/scripts/lib/token-efficiency-evidence.js +213 -0
- package/scripts/lib/token-evidence.js +699 -0
- package/scripts/lib/tokenish.js +17 -0
- package/scripts/lib/tool-output-sandbox.js +304 -0
- package/scripts/lib/trust-audit.js +136 -0
- package/scripts/lib/unified-events.js +396 -0
- package/scripts/lib/upgrade-interruption-recovery.js +407 -0
- package/scripts/lib/usage-ledger.js +201 -0
- package/scripts/lib/value-ledger.js +130 -0
- package/scripts/lib/value-proof-calibration.js +531 -0
- package/scripts/lib/visual-qa.js +231 -0
- package/scripts/lib/voice-alpha.js +29 -0
- package/scripts/lib/work-aware-orchestration.js +976 -0
- package/scripts/lib/work-control-receipts.js +577 -0
- package/scripts/lib/work-ledger.js +1123 -0
- package/scripts/lib/work-panel-preview.js +352 -0
- package/scripts/lib/workflow-discipline.js +280 -0
- package/scripts/lib/workflow-signals.js +419 -0
- package/scripts/lib/workspace-map.js +281 -0
- package/scripts/lib/workspace-registry.js +1367 -0
- package/scripts/lib/workspace-resolver.js +480 -0
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const { normalizeModelIdLower, inferProfilesFromModelId } = require("./model-profiler");
|
|
4
|
+
|
|
5
|
+
const PROFILE_CATALOG = {
|
|
6
|
+
claude_code: [
|
|
7
|
+
{
|
|
8
|
+
id: "haiku",
|
|
9
|
+
provider: "anthropic",
|
|
10
|
+
label: "Haiku / cheap profile",
|
|
11
|
+
modelHints: ["haiku"],
|
|
12
|
+
costTier: "low",
|
|
13
|
+
qualityTier: "medium",
|
|
14
|
+
trustTier: "trusted",
|
|
15
|
+
privacyTier: "trusted_remote",
|
|
16
|
+
supportedRoles: ["planning", "docs", "tests"],
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
id: "sonnet",
|
|
20
|
+
provider: "anthropic",
|
|
21
|
+
label: "Sonnet profile",
|
|
22
|
+
modelHints: ["sonnet", "standard_quality"],
|
|
23
|
+
costTier: "medium",
|
|
24
|
+
qualityTier: "high",
|
|
25
|
+
trustTier: "trusted",
|
|
26
|
+
privacyTier: "trusted_remote",
|
|
27
|
+
supportedRoles: ["planning", "implementation", "review", "security", "ui", "cli", "tests", "docs"],
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
id: "opus",
|
|
31
|
+
provider: "anthropic",
|
|
32
|
+
label: "Opus profile",
|
|
33
|
+
modelHints: ["opus", "deep_reasoning"],
|
|
34
|
+
costTier: "high",
|
|
35
|
+
qualityTier: "highest",
|
|
36
|
+
trustTier: "trusted",
|
|
37
|
+
privacyTier: "trusted_remote",
|
|
38
|
+
supportedRoles: ["implementation", "review", "security", "refactor"],
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
codex: [
|
|
42
|
+
{
|
|
43
|
+
id: "fast_mini",
|
|
44
|
+
provider: "openai",
|
|
45
|
+
label: "Fast / mini profile",
|
|
46
|
+
modelHints: ["mini", "nano", "fast", "fast_low_cost"],
|
|
47
|
+
costTier: "low",
|
|
48
|
+
qualityTier: "medium",
|
|
49
|
+
trustTier: "trusted",
|
|
50
|
+
privacyTier: "trusted_remote",
|
|
51
|
+
supportedRoles: ["planning", "docs", "tests"],
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
id: "default_coding",
|
|
55
|
+
provider: "openai",
|
|
56
|
+
label: "Default coding profile",
|
|
57
|
+
modelHints: ["gpt-5", "codex", "o4", "default", "standard_quality", "coding_candidate"],
|
|
58
|
+
costTier: "medium",
|
|
59
|
+
qualityTier: "high",
|
|
60
|
+
trustTier: "trusted",
|
|
61
|
+
privacyTier: "trusted_remote",
|
|
62
|
+
supportedRoles: ["planning", "implementation", "review", "ui", "cli", "tests", "refactor", "docs"],
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
id: "high_reasoning",
|
|
66
|
+
provider: "openai",
|
|
67
|
+
label: "Higher-reasoning profile",
|
|
68
|
+
modelHints: ["reason", "o3", "high", "deep_reasoning"],
|
|
69
|
+
costTier: "high",
|
|
70
|
+
qualityTier: "highest",
|
|
71
|
+
trustTier: "trusted",
|
|
72
|
+
privacyTier: "trusted_remote",
|
|
73
|
+
supportedRoles: ["implementation", "review", "security", "refactor"],
|
|
74
|
+
},
|
|
75
|
+
],
|
|
76
|
+
gemini_cli: [
|
|
77
|
+
{
|
|
78
|
+
id: "flash",
|
|
79
|
+
provider: "google",
|
|
80
|
+
label: "Flash / cheap profile",
|
|
81
|
+
modelHints: ["flash", "fast_low_cost"],
|
|
82
|
+
costTier: "low",
|
|
83
|
+
qualityTier: "medium",
|
|
84
|
+
trustTier: "external",
|
|
85
|
+
privacyTier: "external_remote",
|
|
86
|
+
supportedRoles: ["planning", "docs", "tests", "ui"],
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
id: "pro",
|
|
90
|
+
provider: "google",
|
|
91
|
+
label: "Pro / long-context profile",
|
|
92
|
+
modelHints: ["pro", "standard_quality", "deep_reasoning"],
|
|
93
|
+
costTier: "medium",
|
|
94
|
+
qualityTier: "high",
|
|
95
|
+
trustTier: "external",
|
|
96
|
+
privacyTier: "external_remote",
|
|
97
|
+
supportedRoles: ["planning", "implementation", "tests", "ui", "docs"],
|
|
98
|
+
},
|
|
99
|
+
],
|
|
100
|
+
lm_studio: [
|
|
101
|
+
{
|
|
102
|
+
id: "local_summary",
|
|
103
|
+
provider: "lm_studio",
|
|
104
|
+
label: "Local/private summary profile",
|
|
105
|
+
modelHints: ["chat_candidate", "standard_quality"],
|
|
106
|
+
costTier: "free_local",
|
|
107
|
+
qualityTier: "unknown",
|
|
108
|
+
trustTier: "local",
|
|
109
|
+
privacyTier: "local_only",
|
|
110
|
+
supportedRoles: ["planning", "docs", "tests", "summaries"],
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
id: "local_coding",
|
|
114
|
+
provider: "lm_studio",
|
|
115
|
+
label: "Local/private coding profile",
|
|
116
|
+
modelHints: ["coding_candidate"],
|
|
117
|
+
costTier: "free_local",
|
|
118
|
+
qualityTier: "medium",
|
|
119
|
+
trustTier: "local",
|
|
120
|
+
privacyTier: "local_only",
|
|
121
|
+
supportedRoles: ["planning", "docs", "tests", "implementation", "refactor", "cli", "summaries"],
|
|
122
|
+
},
|
|
123
|
+
],
|
|
124
|
+
opencode: [
|
|
125
|
+
{
|
|
126
|
+
id: "cheap_coding",
|
|
127
|
+
provider: "opencode",
|
|
128
|
+
label: "Cheap coding profile",
|
|
129
|
+
modelHints: ["cheap", "mini", "flash", "fast_low_cost"],
|
|
130
|
+
costTier: "low",
|
|
131
|
+
qualityTier: "medium",
|
|
132
|
+
trustTier: "external",
|
|
133
|
+
privacyTier: "external_remote",
|
|
134
|
+
supportedRoles: ["planning", "docs", "tests"],
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
id: "standard_coding",
|
|
138
|
+
provider: "opencode",
|
|
139
|
+
label: "Standard coding profile",
|
|
140
|
+
modelHints: ["sonnet", "gpt", "default", "standard", "coding_candidate", "standard_quality"],
|
|
141
|
+
costTier: "medium",
|
|
142
|
+
qualityTier: "high",
|
|
143
|
+
trustTier: "external",
|
|
144
|
+
privacyTier: "external_remote",
|
|
145
|
+
supportedRoles: ["planning", "implementation", "tests", "docs", "ui", "cli"],
|
|
146
|
+
},
|
|
147
|
+
],
|
|
148
|
+
aider: [
|
|
149
|
+
{
|
|
150
|
+
id: "repo_edit",
|
|
151
|
+
provider: "aider",
|
|
152
|
+
label: "Repo editing profile",
|
|
153
|
+
modelHints: ["aider", "default", "coding_candidate"],
|
|
154
|
+
costTier: "medium",
|
|
155
|
+
qualityTier: "high",
|
|
156
|
+
trustTier: "external",
|
|
157
|
+
privacyTier: "external_remote",
|
|
158
|
+
supportedRoles: ["implementation", "refactor", "tests", "cli"],
|
|
159
|
+
},
|
|
160
|
+
],
|
|
161
|
+
ollama: [
|
|
162
|
+
{
|
|
163
|
+
id: "local_private",
|
|
164
|
+
provider: "ollama",
|
|
165
|
+
label: "Local/private profile",
|
|
166
|
+
modelHints: ["chat_candidate", "standard_quality"],
|
|
167
|
+
costTier: "free_local",
|
|
168
|
+
qualityTier: "unknown",
|
|
169
|
+
trustTier: "local",
|
|
170
|
+
privacyTier: "local_only",
|
|
171
|
+
supportedRoles: ["planning", "docs", "tests", "summaries"],
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
id: "local_private_coding",
|
|
175
|
+
provider: "ollama",
|
|
176
|
+
label: "Local/private coding profile",
|
|
177
|
+
modelHints: ["coding_candidate"],
|
|
178
|
+
costTier: "free_local",
|
|
179
|
+
qualityTier: "medium",
|
|
180
|
+
trustTier: "local",
|
|
181
|
+
privacyTier: "local_only",
|
|
182
|
+
supportedRoles: ["planning", "docs", "tests", "implementation", "summaries"],
|
|
183
|
+
},
|
|
184
|
+
],
|
|
185
|
+
openrouter_api: [
|
|
186
|
+
{
|
|
187
|
+
id: "cheap_external",
|
|
188
|
+
provider: "openrouter",
|
|
189
|
+
label: "Cheap external profile",
|
|
190
|
+
modelHints: ["cheap", "mini", "free", "fast_low_cost"],
|
|
191
|
+
costTier: "low",
|
|
192
|
+
qualityTier: "medium",
|
|
193
|
+
trustTier: "external",
|
|
194
|
+
privacyTier: "external_remote",
|
|
195
|
+
supportedRoles: ["planning", "docs", "tests"],
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
id: "fallback_external",
|
|
199
|
+
provider: "openrouter",
|
|
200
|
+
label: "Fallback external profile",
|
|
201
|
+
modelHints: ["sonnet", "gpt", "claude", "coder", "coding_candidate", "standard_quality"],
|
|
202
|
+
costTier: "medium",
|
|
203
|
+
qualityTier: "high",
|
|
204
|
+
trustTier: "external",
|
|
205
|
+
privacyTier: "external_remote",
|
|
206
|
+
supportedRoles: ["planning", "implementation", "docs", "tests"],
|
|
207
|
+
},
|
|
208
|
+
],
|
|
209
|
+
litellm_requesty: [
|
|
210
|
+
{
|
|
211
|
+
id: "gateway_candidate",
|
|
212
|
+
provider: "gateway",
|
|
213
|
+
label: "Gateway candidate profile",
|
|
214
|
+
modelHints: ["gateway", "router", "proxy", "standard_quality"],
|
|
215
|
+
costTier: "medium",
|
|
216
|
+
qualityTier: "unknown",
|
|
217
|
+
trustTier: "unknown",
|
|
218
|
+
privacyTier: "gateway_remote",
|
|
219
|
+
supportedRoles: ["planning", "implementation", "docs", "tests"],
|
|
220
|
+
},
|
|
221
|
+
],
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
function getProfiles(toolId) {
|
|
225
|
+
return (PROFILE_CATALOG[toolId] || []).map((profile) => ({ ...profile }));
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
function detectProfile(toolId, modelId) {
|
|
229
|
+
const normalized = normalizeModelIdLower(modelId);
|
|
230
|
+
if (!normalized) return null;
|
|
231
|
+
const inferred = inferProfilesFromModelId(modelId);
|
|
232
|
+
return getProfiles(toolId).find((profile) => {
|
|
233
|
+
const hints = (profile.modelHints || []).map((hint) => String(hint).toLowerCase());
|
|
234
|
+
return hints.some((hint) => normalized.includes(hint) || inferred.includes(hint));
|
|
235
|
+
}) || null;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
function buildProfileSummary(toolId, activeModel) {
|
|
239
|
+
const profiles = getProfiles(toolId);
|
|
240
|
+
const active = detectProfile(toolId, activeModel);
|
|
241
|
+
return profiles.map((profile) => ({
|
|
242
|
+
...profile,
|
|
243
|
+
availability: active && active.id === profile.id ? "confirmed" : "candidate",
|
|
244
|
+
}));
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
module.exports = {
|
|
248
|
+
PROFILE_CATALOG,
|
|
249
|
+
getProfiles,
|
|
250
|
+
detectProfile,
|
|
251
|
+
buildProfileSummary,
|
|
252
|
+
};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const fs = require("fs");
|
|
4
|
+
const { getCurrentPaths, safeReadJson, writeJson } = require("./state");
|
|
5
|
+
|
|
6
|
+
const INVENTORY_SCHEMA_VERSION = 3;
|
|
7
|
+
const DEFAULT_FULL_REFRESH_INTERVAL_HOURS = 72;
|
|
8
|
+
const LOCK_TTL_MS = 10 * 60 * 1000;
|
|
9
|
+
|
|
10
|
+
function defaultRefreshPolicy(settings = {}) {
|
|
11
|
+
return {
|
|
12
|
+
fullRefreshIntervalHours: Number(settings?.refreshPolicy?.fullRefreshIntervalHours || DEFAULT_FULL_REFRESH_INTERVAL_HOURS),
|
|
13
|
+
singleModelRefreshOnNewUsage: settings?.refreshPolicy?.singleModelRefreshOnNewUsage !== false,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function nextRefreshAfter(lastFullModelRefreshAt, policy) {
|
|
18
|
+
const date = Date.parse(lastFullModelRefreshAt || "");
|
|
19
|
+
if (!Number.isFinite(date)) return null;
|
|
20
|
+
return new Date(date + (policy.fullRefreshIntervalHours * 60 * 60 * 1000)).toISOString();
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function tryAcquireRefreshLock(cwd) {
|
|
24
|
+
const paths = getCurrentPaths(cwd);
|
|
25
|
+
const existing = safeReadJson(paths.inventoryRefreshLock, null);
|
|
26
|
+
const now = Date.now();
|
|
27
|
+
if (existing?.acquiredAt) {
|
|
28
|
+
const age = now - Date.parse(existing.acquiredAt);
|
|
29
|
+
if (Number.isFinite(age) && age < LOCK_TTL_MS) return { ok: false, staleRecovered: false };
|
|
30
|
+
}
|
|
31
|
+
if (existing?.acquiredAt) {
|
|
32
|
+
try { fs.unlinkSync(paths.inventoryRefreshLock); } catch {}
|
|
33
|
+
}
|
|
34
|
+
writeJson(paths.inventoryRefreshLock, { lockVersion: 1, acquiredAt: new Date(now).toISOString() });
|
|
35
|
+
return { ok: true, staleRecovered: Boolean(existing) };
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function releaseRefreshLock(cwd) {
|
|
39
|
+
const paths = getCurrentPaths(cwd);
|
|
40
|
+
try { fs.unlinkSync(paths.inventoryRefreshLock); } catch {}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function determineRefreshDecision(cached, settings, options = {}) {
|
|
44
|
+
const policy = defaultRefreshPolicy(settings);
|
|
45
|
+
if (options.deepRefresh === true) {
|
|
46
|
+
return { refreshLevel: "deep", inventorySource: "rebuilt", lastRefreshReason: "explicit_deep_refresh", policy };
|
|
47
|
+
}
|
|
48
|
+
if (options.refresh === true) {
|
|
49
|
+
return { refreshLevel: "full", inventorySource: "rebuilt", lastRefreshReason: "explicit_refresh", policy };
|
|
50
|
+
}
|
|
51
|
+
if (!cached || cached.schemaVersion !== INVENTORY_SCHEMA_VERSION) {
|
|
52
|
+
return { refreshLevel: "full", inventorySource: cached ? "repaired" : "rebuilt", lastRefreshReason: cached ? "schema_upgrade" : "missing_cache", policy };
|
|
53
|
+
}
|
|
54
|
+
const lastFull = Date.parse(cached.lastFullModelRefreshAt || "");
|
|
55
|
+
if (!Number.isFinite(lastFull)) {
|
|
56
|
+
return { refreshLevel: "full", inventorySource: "repaired", lastRefreshReason: "invalid_timestamp", policy };
|
|
57
|
+
}
|
|
58
|
+
if (Date.now() >= lastFull + (policy.fullRefreshIntervalHours * 60 * 60 * 1000)) {
|
|
59
|
+
return { refreshLevel: "full", inventorySource: "rebuilt", lastRefreshReason: "scheduled_full_refresh", policy };
|
|
60
|
+
}
|
|
61
|
+
return { refreshLevel: "cache", inventorySource: "cache", lastRefreshReason: "fresh_cache", policy };
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
module.exports = {
|
|
65
|
+
INVENTORY_SCHEMA_VERSION,
|
|
66
|
+
DEFAULT_FULL_REFRESH_INTERVAL_HOURS,
|
|
67
|
+
defaultRefreshPolicy,
|
|
68
|
+
nextRefreshAfter,
|
|
69
|
+
determineRefreshDecision,
|
|
70
|
+
tryAcquireRefreshLock,
|
|
71
|
+
releaseRefreshLock,
|
|
72
|
+
};
|
|
@@ -0,0 +1,349 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const path = require("path");
|
|
4
|
+
const {
|
|
5
|
+
ensureOrchestrationDirs,
|
|
6
|
+
getCurrentPaths,
|
|
7
|
+
getRunPaths,
|
|
8
|
+
writeJson,
|
|
9
|
+
writeText,
|
|
10
|
+
relativeFromCwd,
|
|
11
|
+
} = require("./state");
|
|
12
|
+
|
|
13
|
+
function redactText(value) {
|
|
14
|
+
return String(value || "")
|
|
15
|
+
.replace(/(OPENROUTER_API_KEY|ANTHROPIC_AUTH_TOKEN|OPENAI_API_KEY|GEMINI_API_KEY|REQUESTY_API_KEY|LITELLM_API_KEY)=\S+/gi, "$1=[REDACTED]")
|
|
16
|
+
.replace(/sk-[A-Za-z0-9_-]+/g, "[REDACTED]");
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function sanitizeValue(value) {
|
|
20
|
+
if (typeof value === "string") return redactText(value);
|
|
21
|
+
if (Array.isArray(value)) return value.map((item) => sanitizeValue(item));
|
|
22
|
+
if (value && typeof value === "object") {
|
|
23
|
+
return Object.fromEntries(Object.entries(value).map(([key, entry]) => [key, sanitizeValue(entry)]));
|
|
24
|
+
}
|
|
25
|
+
return value;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function renderRouteMarkdown(route) {
|
|
29
|
+
const lines = [
|
|
30
|
+
"# Avorelo Route",
|
|
31
|
+
"",
|
|
32
|
+
`State: ${route.state}`,
|
|
33
|
+
`Selected route: ${route.selectedRoute}`,
|
|
34
|
+
`Inventory source: ${route.inventorySource || "cache"}`,
|
|
35
|
+
`Refresh level: ${route.refreshLevel || "cache"}`,
|
|
36
|
+
`Last full model refresh: ${route.lastFullModelRefreshAt || "unknown"}`,
|
|
37
|
+
`Next full model refresh after: ${route.nextFullModelRefreshAfter || "unknown"}`,
|
|
38
|
+
`Task type: ${route.task.taskType}`,
|
|
39
|
+
`Risk: ${route.task.risk}`,
|
|
40
|
+
`Sensitivity: ${route.task.sensitivity}`,
|
|
41
|
+
`Chosen worker: ${route.chosenTool || "none"}`,
|
|
42
|
+
`Chosen model: ${route.selectedModel || "none"}`,
|
|
43
|
+
`Chosen model/profile: ${route.chosenModelProfile || "none"}`,
|
|
44
|
+
`Fallback worker: ${route.fallbackTool || "none"}`,
|
|
45
|
+
`Fallback model: ${route.fallbackModel || "none"}`,
|
|
46
|
+
`Fallback model/profile: ${route.fallbackModelProfile || "none"}`,
|
|
47
|
+
"",
|
|
48
|
+
"Why chosen:",
|
|
49
|
+
...(route.whyChosen || []).map((item) => `- ${item}`),
|
|
50
|
+
"",
|
|
51
|
+
"Why not chosen:",
|
|
52
|
+
...(route.whyNotChosen || []).map((item) => `- ${item}`),
|
|
53
|
+
"",
|
|
54
|
+
"Safety notes:",
|
|
55
|
+
...(route.safetyNotes || []).map((item) => `- ${item}`),
|
|
56
|
+
"",
|
|
57
|
+
"Stages:",
|
|
58
|
+
...(route.stageList || []).map((stage) => `- ${stage.id}: ${stage.chosenLabel} (${stage.chosenModelProfile}) via ${stage.executionMode}`),
|
|
59
|
+
];
|
|
60
|
+
return lines.join("\n").trim() + "\n";
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function renderTaskMarkdown(taskContext) {
|
|
64
|
+
return [
|
|
65
|
+
"# Avorelo Current Task",
|
|
66
|
+
"",
|
|
67
|
+
redactText(taskContext.taskText),
|
|
68
|
+
"",
|
|
69
|
+
`Surface: ${taskContext.surface}`,
|
|
70
|
+
`Task type: ${taskContext.classification.taskType}`,
|
|
71
|
+
`Risk: ${taskContext.classification.risk}`,
|
|
72
|
+
`Sensitivity: ${taskContext.classification.sensitivity}`,
|
|
73
|
+
"",
|
|
74
|
+
"Signals:",
|
|
75
|
+
...(taskContext.classification.signals || []).map((item) => `- ${item}`),
|
|
76
|
+
].join("\n").trim() + "\n";
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function renderProofMarkdown(proof, options = {}) {
|
|
80
|
+
const debug = options.debug === true || options.verbose === true;
|
|
81
|
+
const blockedOptions = proof.blockedOptions || [];
|
|
82
|
+
const skippedOptions = proof.skippedOptions || [];
|
|
83
|
+
|
|
84
|
+
const workerSummaryLines = debug
|
|
85
|
+
? [
|
|
86
|
+
"",
|
|
87
|
+
"Blocked options:",
|
|
88
|
+
...(blockedOptions.length
|
|
89
|
+
? blockedOptions.map((item) => `- ${item.label}: ${(item.reasons || []).join(", ")}`)
|
|
90
|
+
: ["- none"]),
|
|
91
|
+
"",
|
|
92
|
+
"Skipped workers/models:",
|
|
93
|
+
...(skippedOptions.length
|
|
94
|
+
? skippedOptions.map((item) => `- ${item.label}: ${(item.reasons || []).join(", ")}`)
|
|
95
|
+
: ["- none"]),
|
|
96
|
+
]
|
|
97
|
+
: [
|
|
98
|
+
"",
|
|
99
|
+
`Workers: ${blockedOptions.length} blocked · ${skippedOptions.length} unavailable · details: avorelo proof --debug`,
|
|
100
|
+
];
|
|
101
|
+
|
|
102
|
+
const lines = [
|
|
103
|
+
"# Avorelo Proof",
|
|
104
|
+
"",
|
|
105
|
+
`Run: ${proof.runId}`,
|
|
106
|
+
`Status: ${proof.finalStatus}`,
|
|
107
|
+
`Surface: ${proof.surface}`,
|
|
108
|
+
`Task: ${proof.task}`,
|
|
109
|
+
`Chosen route: ${proof.route.selectedRoute}`,
|
|
110
|
+
`Inventory source: ${proof.inventorySource || "cache"}`,
|
|
111
|
+
`Refresh level: ${proof.refreshLevel || "cache"}`,
|
|
112
|
+
`Last full model refresh: ${proof.lastFullModelRefreshAt || "unknown"}`,
|
|
113
|
+
`Next full model refresh after: ${proof.nextFullModelRefreshAfter || "unknown"}`,
|
|
114
|
+
`Selected worker: ${proof.selectedWorker || "none"}`,
|
|
115
|
+
`Selected model: ${proof.selectedModel || "none"}`,
|
|
116
|
+
`Selected profile: ${proof.selectedProfile || "none"}`,
|
|
117
|
+
`Premium used: ${proof.premiumUsed ? "yes" : "no"}`,
|
|
118
|
+
`Premium avoided: ${proof.premiumAvoided ? "yes" : "no"}`,
|
|
119
|
+
`External model involved: ${proof.externalModelInvolved ? "yes" : "no"}`,
|
|
120
|
+
`Verification: ${proof.verification.status}`,
|
|
121
|
+
"",
|
|
122
|
+
"Tools used:",
|
|
123
|
+
...(proof.toolsUsed || []).map((item) => `- ${item.toolId}: ${item.selectedModel || item.modelProfile || "unknown"} / ${item.modelProfile || "unknown"} (${item.executionMode})`),
|
|
124
|
+
...workerSummaryLines,
|
|
125
|
+
"",
|
|
126
|
+
"Failures / fallbacks:",
|
|
127
|
+
...((proof.failures || []).length
|
|
128
|
+
? proof.failures.map((item) => `- ${item.stepId}: ${item.reason}`)
|
|
129
|
+
: ["- none"]),
|
|
130
|
+
];
|
|
131
|
+
return redactText(lines.join("\n").trim() + "\n");
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function buildProof({ runId, taskContext, route, execution, verification }) {
|
|
135
|
+
const toolsUsed = (execution.steps || [])
|
|
136
|
+
.filter((step) => step.toolId)
|
|
137
|
+
.map((step) => ({
|
|
138
|
+
stepId: step.stepId,
|
|
139
|
+
toolId: step.toolId,
|
|
140
|
+
selectedModel: step.selectedModel || null,
|
|
141
|
+
modelProfile: step.modelProfile || null,
|
|
142
|
+
executionMode: step.executionMode || "unknown",
|
|
143
|
+
status: step.status,
|
|
144
|
+
}));
|
|
145
|
+
|
|
146
|
+
return {
|
|
147
|
+
proofVersion: 1,
|
|
148
|
+
runId,
|
|
149
|
+
task: taskContext.taskText,
|
|
150
|
+
surface: taskContext.surface,
|
|
151
|
+
finalStatus: execution.finalStatus,
|
|
152
|
+
failureReason: execution.failureReason || null,
|
|
153
|
+
route,
|
|
154
|
+
inventorySource: route.inventorySource || "cache",
|
|
155
|
+
cacheUsed: route.cacheUsed === true,
|
|
156
|
+
lastFullModelRefreshAt: route.lastFullModelRefreshAt || null,
|
|
157
|
+
nextFullModelRefreshAfter: route.nextFullModelRefreshAfter || null,
|
|
158
|
+
refreshLevel: route.refreshLevel || "cache",
|
|
159
|
+
selectedWorker: route.chosenTool || null,
|
|
160
|
+
selectedModel: route.selectedModel || null,
|
|
161
|
+
selectedProfile: route.chosenModelProfile || null,
|
|
162
|
+
selectionReason: route.selectionReason || route.whyChosen || [],
|
|
163
|
+
toolsUsed,
|
|
164
|
+
toolsNotUsed: route.whyNotChosen || [],
|
|
165
|
+
skippedOptions: route.blockedOptions || [],
|
|
166
|
+
blockedOptions: route.blockedOptions || [],
|
|
167
|
+
reasons: route.whyChosen || [],
|
|
168
|
+
safetyDecisions: route.safetyNotes || [],
|
|
169
|
+
premiumAvoided: route.premiumUseInvolved !== true,
|
|
170
|
+
premiumUsed: route.premiumUseInvolved === true,
|
|
171
|
+
externalModelInvolved: route.externalModelInvolved === true,
|
|
172
|
+
verification,
|
|
173
|
+
failures: execution.failures || [],
|
|
174
|
+
diffSummary: execution.diffSummary || null,
|
|
175
|
+
createdAt: new Date().toISOString(),
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
function writeHostContracts(cwd, route, taskContext, proof = null) {
|
|
180
|
+
ensureOrchestrationDirs(cwd);
|
|
181
|
+
const current = getCurrentPaths(cwd);
|
|
182
|
+
const claudePath = path.join(current.hostContractsDir, "claude-code.md");
|
|
183
|
+
const codexPath = path.join(current.hostContractsDir, "codex-vscode.md");
|
|
184
|
+
const common = [
|
|
185
|
+
`Task: ${taskContext.taskText}`,
|
|
186
|
+
`Risk: ${taskContext.classification.risk}`,
|
|
187
|
+
`Selected worker: ${route.chosenTool || "none"} (${route.chosenModelProfile || "unknown"})`,
|
|
188
|
+
`Verification: ${(route.expectedVerification || []).join("; ") || "none"}`,
|
|
189
|
+
`Current route file: ${relativeFromCwd(cwd, current.currentRouteMd)}`,
|
|
190
|
+
`Current proof file: ${relativeFromCwd(cwd, current.currentProofMd)}`,
|
|
191
|
+
];
|
|
192
|
+
|
|
193
|
+
writeText(claudePath, [
|
|
194
|
+
"# Claude Code Orchestration Contract",
|
|
195
|
+
"",
|
|
196
|
+
"Avorelo routes the task quietly and keeps the state local-first. Continue the task normally inside Claude Code and use the route/proof files as the bounded contract.",
|
|
197
|
+
"",
|
|
198
|
+
...common,
|
|
199
|
+
"",
|
|
200
|
+
"If the route is blocked, prefer a trusted premium path before changing safety settings.",
|
|
201
|
+
].join("\n"));
|
|
202
|
+
|
|
203
|
+
writeText(codexPath, [
|
|
204
|
+
"# Codex / VS Code Orchestration Contract",
|
|
205
|
+
"",
|
|
206
|
+
"Use the Avorelo route/proof files as the local handoff contract. This path is extension-ready and avoids depending on private Codex UI internals.",
|
|
207
|
+
"",
|
|
208
|
+
...common,
|
|
209
|
+
"",
|
|
210
|
+
"Recommended commands:",
|
|
211
|
+
"- avorelo route \"<task>\"",
|
|
212
|
+
"- avorelo run \"<task>\" --dry-run",
|
|
213
|
+
"- avorelo proof",
|
|
214
|
+
].join("\n"));
|
|
215
|
+
|
|
216
|
+
return {
|
|
217
|
+
claudeCodeContract: relativeFromCwd(cwd, claudePath),
|
|
218
|
+
codexVsCodeContract: relativeFromCwd(cwd, codexPath),
|
|
219
|
+
currentProofAvailable: Boolean(proof),
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
function writeCurrentArtifacts(cwd, taskContext, route, proof) {
|
|
224
|
+
ensureOrchestrationDirs(cwd);
|
|
225
|
+
const current = getCurrentPaths(cwd);
|
|
226
|
+
writeText(current.currentTask, renderTaskMarkdown(taskContext));
|
|
227
|
+
writeJson(current.currentRouteJson, sanitizeValue(route));
|
|
228
|
+
writeText(current.currentRouteMd, renderRouteMarkdown(sanitizeValue(route)));
|
|
229
|
+
if (proof) {
|
|
230
|
+
writeJson(current.currentProofJson, sanitizeValue(proof));
|
|
231
|
+
writeText(current.currentProofMd, renderProofMarkdown(sanitizeValue(proof)));
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
function writeRunArtifacts(cwd, runId, taskContext, route, execution, verification, proof) {
|
|
236
|
+
ensureOrchestrationDirs(cwd);
|
|
237
|
+
const runPaths = getRunPaths(cwd, runId);
|
|
238
|
+
writeJson(runPaths.task, {
|
|
239
|
+
taskText: redactText(taskContext.taskText),
|
|
240
|
+
surface: taskContext.surface,
|
|
241
|
+
classification: sanitizeValue(taskContext.classification),
|
|
242
|
+
});
|
|
243
|
+
writeJson(runPaths.route, sanitizeValue(route));
|
|
244
|
+
writeText(runPaths.diffSummary, redactText(execution.diffSummary || "No diff summary captured.\n"));
|
|
245
|
+
writeJson(runPaths.verification, sanitizeValue(verification));
|
|
246
|
+
writeJson(runPaths.proof, sanitizeValue(proof));
|
|
247
|
+
return runPaths;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
const ORCHESTRATION_RECEIPT_SCHEMA_VERSION = 1;
|
|
251
|
+
|
|
252
|
+
function buildAgentModelOrchestrationReceipt({ route, proof, handoffPath = null, cwd = null }) {
|
|
253
|
+
const paths = cwd ? getCurrentPaths(cwd) : null;
|
|
254
|
+
const stageList = Array.isArray(route?.stageList) ? route.stageList : [];
|
|
255
|
+
const blockedOptions = Array.isArray(route?.blockedOptions) ? route.blockedOptions : [];
|
|
256
|
+
const limitedWorkers = Array.isArray(route?.limitedWorkers) ? route.limitedWorkers : [];
|
|
257
|
+
const localWorkersAvailable = Array.isArray(route?.localWorkersAvailable) ? route.localWorkersAvailable : [];
|
|
258
|
+
|
|
259
|
+
const selectedWorkers = stageList
|
|
260
|
+
.filter((s) => s.chosenTool && s.chosenTool !== "avorelo_handoff")
|
|
261
|
+
.map((s) => ({ stageId: s.id, toolId: s.chosenTool, label: s.chosenLabel || s.chosenTool, model: s.chosenModel || s.chosenModelProfile || null }));
|
|
262
|
+
|
|
263
|
+
const fallbackWorkers = stageList
|
|
264
|
+
.filter((s) => s.fallbackTool)
|
|
265
|
+
.map((s) => ({ stageId: s.id, toolId: s.fallbackTool, model: s.fallbackModel || s.fallbackModelProfile || null }));
|
|
266
|
+
|
|
267
|
+
const skippedWorkers = (route?.whyNotChosen || []).slice(0, 6).map((reason) => ({ reason }));
|
|
268
|
+
|
|
269
|
+
return {
|
|
270
|
+
schemaVersion: ORCHESTRATION_RECEIPT_SCHEMA_VERSION,
|
|
271
|
+
contract: "avorelo.agentModelOrchestration.v1",
|
|
272
|
+
routeId: proof?.runId || `route-${Date.now()}`,
|
|
273
|
+
generatedAt: new Date().toISOString(),
|
|
274
|
+
taskSummary: redactText(String(route?.taskText || proof?.task || "")).slice(0, 200),
|
|
275
|
+
routeState: route?.state || "unknown",
|
|
276
|
+
selectedRoute: route?.selectedRoute || null,
|
|
277
|
+
stagePlan: stageList.map((s) => ({
|
|
278
|
+
id: s.id,
|
|
279
|
+
role: s.role,
|
|
280
|
+
worker: s.chosenLabel || s.chosenTool,
|
|
281
|
+
model: s.chosenModel || s.chosenModelProfile || null,
|
|
282
|
+
executionMode: s.executionMode,
|
|
283
|
+
quotaSignal: s.quotaSignal || "unknown",
|
|
284
|
+
fallback: s.fallbackTool || null,
|
|
285
|
+
})),
|
|
286
|
+
stageCount: stageList.length,
|
|
287
|
+
selectedWorkers,
|
|
288
|
+
fallbackWorkers,
|
|
289
|
+
skippedWorkers,
|
|
290
|
+
blockedWorkers: blockedOptions.map((b) => ({ toolId: b.toolId, label: b.label, reasons: b.reasons })),
|
|
291
|
+
quotaSignals: {
|
|
292
|
+
limitedWorkers: limitedWorkers.map((w) => ({ toolId: w.toolId, label: w.label, reasonCode: w.reasonCode })),
|
|
293
|
+
localWorkersAvailable,
|
|
294
|
+
fallbackReasonCodes: route?.fallbackReasonCodes || [],
|
|
295
|
+
},
|
|
296
|
+
localWorkerUse: localWorkersAvailable.length > 0,
|
|
297
|
+
localWorkerRecommendation: route?.localWorkerRecommendation || null,
|
|
298
|
+
premiumUse: Boolean(route?.premiumUseInvolved),
|
|
299
|
+
premiumAvoided: Boolean(proof?.premiumAvoided),
|
|
300
|
+
escalationRecommendations: (route?.fallbackReasonCodes || []).includes("ESCALATION_RECOMMENDED")
|
|
301
|
+
? ["High-risk task detected — trusted higher-quality worker recommended for implementation/review"]
|
|
302
|
+
: [],
|
|
303
|
+
handoffAvailable: Boolean(route?.handoffAvailable),
|
|
304
|
+
handoffPromptPath: handoffPath || null,
|
|
305
|
+
expectedVerification: route?.expectedVerification || [],
|
|
306
|
+
safetyNotes: route?.safetyNotes || [],
|
|
307
|
+
nextAction: limitedWorkers.length
|
|
308
|
+
? `Use fallback worker (${route?.fallbackTool || "local"}) — primary worker is recently limited`
|
|
309
|
+
: localWorkersAvailable.length
|
|
310
|
+
? `Use local worker (${localWorkersAvailable[0]}) for inspect/plan, premium worker for implementation`
|
|
311
|
+
: `Run: avorelo route "<task>" --json for updated plan`,
|
|
312
|
+
redacted: true,
|
|
313
|
+
notAGateway: true,
|
|
314
|
+
foundationOnly: true,
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
function writeOrchestrationReceipt(cwd, receipt) {
|
|
319
|
+
const current = getCurrentPaths(cwd);
|
|
320
|
+
const receiptDir = path.join(current.root, "receipts");
|
|
321
|
+
const latestPath = path.join(receiptDir, "current-orchestration-receipt.json");
|
|
322
|
+
writeJson(latestPath, receipt);
|
|
323
|
+
return relativeFromCwd(cwd, latestPath);
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
function readOrchestrationReceipt(cwd) {
|
|
327
|
+
const current = getCurrentPaths(cwd);
|
|
328
|
+
const latestPath = path.join(current.root, "receipts", "current-orchestration-receipt.json");
|
|
329
|
+
try {
|
|
330
|
+
return JSON.parse(require("fs").readFileSync(latestPath, "utf8"));
|
|
331
|
+
} catch {
|
|
332
|
+
return null;
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
module.exports = {
|
|
337
|
+
redactText,
|
|
338
|
+
sanitizeValue,
|
|
339
|
+
renderRouteMarkdown,
|
|
340
|
+
renderProofMarkdown,
|
|
341
|
+
buildProof,
|
|
342
|
+
buildAgentModelOrchestrationReceipt,
|
|
343
|
+
writeOrchestrationReceipt,
|
|
344
|
+
readOrchestrationReceipt,
|
|
345
|
+
writeCurrentArtifacts,
|
|
346
|
+
writeRunArtifacts,
|
|
347
|
+
writeHostContracts,
|
|
348
|
+
ORCHESTRATION_RECEIPT_SCHEMA_VERSION,
|
|
349
|
+
};
|