avorelo 0.1.0 → 0.3.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 +23 -16
- package/README.md +90 -51
- package/bin/avorelo.mjs +7 -0
- package/dist/avorelo.mjs +19741 -0
- package/package.json +135 -120
- package/bin/avorelo +0 -9
- package/scripts/README.md +0 -40
- package/scripts/cco-dashboard.js +0 -252
- package/scripts/cco-status.js +0 -430
- package/scripts/lib/activation/account-state.js +0 -37
- package/scripts/lib/activation/activation-runner.js +0 -546
- package/scripts/lib/activation/activation-self-healing.js +0 -480
- package/scripts/lib/activation/activation-state.js +0 -83
- package/scripts/lib/activation/activation-summary.js +0 -191
- package/scripts/lib/activation/adapters/claude-code.js +0 -77
- package/scripts/lib/activation/adapters/codex-cli.js +0 -52
- package/scripts/lib/activation/adapters/cursor.js +0 -37
- package/scripts/lib/activation/adapters/github-agent.js +0 -39
- package/scripts/lib/activation/adapters/terminal.js +0 -42
- package/scripts/lib/activation/adapters/vscode.js +0 -39
- package/scripts/lib/activation/adapters/windsurf.js +0 -37
- package/scripts/lib/activation/ai-surface-detector.js +0 -151
- package/scripts/lib/activation/connect-account.js +0 -145
- package/scripts/lib/activation/detect-environment.js +0 -75
- package/scripts/lib/activation/detect-hosts.js +0 -62
- package/scripts/lib/activation/format-activation-output.js +0 -109
- package/scripts/lib/activation/next-action.js +0 -43
- package/scripts/lib/activation/repair-engine.js +0 -219
- package/scripts/lib/activation-distribution-readiness.js +0 -507
- package/scripts/lib/adapter-conformance.js +0 -176
- package/scripts/lib/adapter-readiness.js +0 -417
- package/scripts/lib/adapter-safety-boundaries.js +0 -335
- package/scripts/lib/adapter-technical-readiness-gate.js +0 -205
- package/scripts/lib/agent-access-governance.js +0 -455
- package/scripts/lib/agent-enforcement.js +0 -765
- package/scripts/lib/agent-policy-profile.js +0 -210
- package/scripts/lib/agent-security/action-evaluator.js +0 -507
- package/scripts/lib/agent-security/adapter-registry.js +0 -98
- package/scripts/lib/agent-security/auto-policy.js +0 -139
- package/scripts/lib/agent-security/bounded-scan.js +0 -93
- package/scripts/lib/agent-security/enforcement-adapter.js +0 -174
- package/scripts/lib/agent-security/enforcement-engine.js +0 -1129
- package/scripts/lib/agent-security/file-write-adapter.js +0 -183
- package/scripts/lib/agent-security/file-write-rules.js +0 -178
- package/scripts/lib/agent-security/index.js +0 -3342
- package/scripts/lib/agent-security/instruction-risk.js +0 -181
- package/scripts/lib/agent-security/mcp-action-adapter.js +0 -185
- package/scripts/lib/agent-security/mcp-action-rules.js +0 -184
- package/scripts/lib/agent-security/package-action-adapter.js +0 -175
- package/scripts/lib/agent-security/package-action-rules.js +0 -233
- package/scripts/lib/agent-security/performance.js +0 -148
- package/scripts/lib/agent-security/permission-minimizer.js +0 -403
- package/scripts/lib/agent-security/scan-cache.js +0 -74
- package/scripts/lib/agent-security/source-trust.js +0 -146
- package/scripts/lib/ai-install-prompt.js +0 -288
- package/scripts/lib/ai-workspace-hygiene.js +0 -1499
- package/scripts/lib/alpha-activation.js +0 -520
- package/scripts/lib/alpha-feedback.js +0 -263
- package/scripts/lib/alpha-readiness-gate.js +0 -332
- package/scripts/lib/anti-gaming.js +0 -169
- package/scripts/lib/artifact-health.js +0 -431
- package/scripts/lib/attribution.js +0 -180
- package/scripts/lib/audit.js +0 -289
- package/scripts/lib/avorelo-skill-registry.js +0 -810
- package/scripts/lib/batch-jobs.js +0 -71
- package/scripts/lib/brain-pack.js +0 -578
- package/scripts/lib/brand-boundary.js +0 -424
- package/scripts/lib/brand.js +0 -74
- package/scripts/lib/browser-capability.js +0 -1048
- package/scripts/lib/browser-proof-preflight.js +0 -321
- package/scripts/lib/cache-readiness.js +0 -187
- package/scripts/lib/canonical-reentry.js +0 -162
- package/scripts/lib/capability-packs.js +0 -314
- package/scripts/lib/capability-recommender.js +0 -512
- package/scripts/lib/capability-registry.js +0 -1059
- package/scripts/lib/carry-forward-surfacing.js +0 -194
- package/scripts/lib/ccusage-adapter.js +0 -188
- package/scripts/lib/company-loop.js +0 -1149
- package/scripts/lib/config.js +0 -637
- package/scripts/lib/context-acquisition-plan.js +0 -287
- package/scripts/lib/context-budget-guard.js +0 -170
- package/scripts/lib/context-budget-scanner.js +0 -257
- package/scripts/lib/context-optimizer.js +0 -715
- package/scripts/lib/context-reduction-plan.js +0 -178
- package/scripts/lib/context-safety.js +0 -88
- package/scripts/lib/context-savings-engine.js +0 -158
- package/scripts/lib/cost-evidence.js +0 -254
- package/scripts/lib/cross-host-install-plan.js +0 -308
- package/scripts/lib/cross-host-install-readiness.js +0 -237
- package/scripts/lib/cross-host-value-flow.js +0 -268
- package/scripts/lib/dashboard.js +0 -900
- package/scripts/lib/design-partner-feedback.js +0 -346
- package/scripts/lib/entitlements.js +0 -100
- package/scripts/lib/execution-packet.js +0 -559
- package/scripts/lib/experimentation-events.js +0 -547
- package/scripts/lib/external-capability-compliance.js +0 -107
- package/scripts/lib/external-user-simulation.js +0 -166
- package/scripts/lib/failure-recovery-readiness.js +0 -81
- package/scripts/lib/failure-recovery.js +0 -419
- package/scripts/lib/feedback-intelligence.js +0 -537
- package/scripts/lib/feedback-signals.js +0 -205
- package/scripts/lib/file-integrity.js +0 -68
- package/scripts/lib/fsx.js +0 -127
- package/scripts/lib/full-readiness-gate.js +0 -451
- package/scripts/lib/guidance-builder.js +0 -174
- package/scripts/lib/hook-apply.js +0 -1019
- package/scripts/lib/hook-baseline.js +0 -310
- package/scripts/lib/hook-config-preview.js +0 -275
- package/scripts/lib/hook-contracts.js +0 -290
- package/scripts/lib/hook-safety-boundary-readiness.js +0 -80
- package/scripts/lib/host-capability-matrix.js +0 -351
- package/scripts/lib/host-support-context.js +0 -254
- package/scripts/lib/http-hook-action.js +0 -538
- package/scripts/lib/install-ai-readiness.js +0 -84
- package/scripts/lib/install-intake-risk.js +0 -1037
- package/scripts/lib/install-journey-intelligence.js +0 -329
- package/scripts/lib/intervention-guidance.js +0 -57
- package/scripts/lib/known-limitations.js +0 -115
- package/scripts/lib/l8-path-truth.js +0 -146
- package/scripts/lib/launch-hardening-gate.js +0 -436
- package/scripts/lib/launch-readiness.js +0 -628
- package/scripts/lib/learning-memory.js +0 -686
- package/scripts/lib/lifecycle-hooks.js +0 -802
- package/scripts/lib/local-package-smoke.js +0 -423
- package/scripts/lib/local-pricing.js +0 -299
- package/scripts/lib/mcp-enforcement.js +0 -311
- package/scripts/lib/mcp-least-privilege-policy.js +0 -303
- package/scripts/lib/mcp-tool-inventory.js +0 -388
- package/scripts/lib/mcp-tool-risk.js +0 -0
- package/scripts/lib/memory.js +0 -335
- package/scripts/lib/metrics.js +0 -699
- package/scripts/lib/micro-proof.js +0 -133
- package/scripts/lib/next-run-context.js +0 -436
- package/scripts/lib/operating-value.js +0 -1648
- package/scripts/lib/optimization-v3.js +0 -122
- package/scripts/lib/orchestration/adapters/_shared.js +0 -49
- package/scripts/lib/orchestration/adapters/aider.js +0 -18
- package/scripts/lib/orchestration/adapters/claude-code.js +0 -35
- package/scripts/lib/orchestration/adapters/codex.js +0 -35
- package/scripts/lib/orchestration/adapters/gemini-cli.js +0 -18
- package/scripts/lib/orchestration/adapters/git.js +0 -25
- package/scripts/lib/orchestration/adapters/index.js +0 -31
- package/scripts/lib/orchestration/adapters/lm-studio.js +0 -18
- package/scripts/lib/orchestration/adapters/ollama.js +0 -18
- package/scripts/lib/orchestration/adapters/opencode.js +0 -18
- package/scripts/lib/orchestration/adapters/openrouter.js +0 -18
- package/scripts/lib/orchestration/adapters/test-runner.js +0 -25
- package/scripts/lib/orchestration/cli.js +0 -438
- package/scripts/lib/orchestration/execution-manager.js +0 -279
- package/scripts/lib/orchestration/handoff.js +0 -314
- package/scripts/lib/orchestration/index.js +0 -456
- package/scripts/lib/orchestration/inventory.js +0 -47
- package/scripts/lib/orchestration/model-discovery.js +0 -498
- package/scripts/lib/orchestration/model-profiler.js +0 -170
- package/scripts/lib/orchestration/model-profiles.js +0 -252
- package/scripts/lib/orchestration/model-refresh-policy.js +0 -72
- package/scripts/lib/orchestration/proof-writer.js +0 -349
- package/scripts/lib/orchestration/provider-discovery/aider.js +0 -49
- package/scripts/lib/orchestration/provider-discovery/claude-code.js +0 -56
- package/scripts/lib/orchestration/provider-discovery/codex.js +0 -49
- package/scripts/lib/orchestration/provider-discovery/common.js +0 -186
- package/scripts/lib/orchestration/provider-discovery/gemini.js +0 -106
- package/scripts/lib/orchestration/provider-discovery/lm-studio.js +0 -118
- package/scripts/lib/orchestration/provider-discovery/models-dev.js +0 -12
- package/scripts/lib/orchestration/provider-discovery/ollama.js +0 -100
- package/scripts/lib/orchestration/provider-discovery/opencode.js +0 -47
- package/scripts/lib/orchestration/provider-discovery/openrouter.js +0 -44
- package/scripts/lib/orchestration/risk-classifier.js +0 -130
- package/scripts/lib/orchestration/routing-policy.js +0 -486
- package/scripts/lib/orchestration/settings.js +0 -112
- package/scripts/lib/orchestration/state.js +0 -165
- package/scripts/lib/orchestration/verification-manager.js +0 -138
- package/scripts/lib/output-profiles.js +0 -146
- package/scripts/lib/package-content-audit.js +0 -368
- package/scripts/lib/package-runtime.js +0 -278
- package/scripts/lib/plan-surface.js +0 -53
- package/scripts/lib/plans.js +0 -2318
- package/scripts/lib/policy-provider.js +0 -27
- package/scripts/lib/prelaunch-activation-readiness.js +0 -409
- package/scripts/lib/prelaunch-evidence-store.js +0 -816
- package/scripts/lib/prelaunch-intelligence.js +0 -869
- package/scripts/lib/pricing-experiment.js +0 -118
- package/scripts/lib/pro-moment-events.js +0 -77
- package/scripts/lib/pro-moment-state.js +0 -227
- package/scripts/lib/pro-moments.js +0 -1216
- package/scripts/lib/product-learning-events.js +0 -629
- package/scripts/lib/project-profile.js +0 -555
- package/scripts/lib/prompt-compiler.js +0 -280
- package/scripts/lib/prompt-lint.js +0 -32
- package/scripts/lib/prompt-suggestions.js +0 -52
- package/scripts/lib/proof-canonical.js +0 -398
- package/scripts/lib/proof-drilldown.js +0 -383
- package/scripts/lib/proof-events.js +0 -342
- package/scripts/lib/proof-history.js +0 -243
- package/scripts/lib/proof-metrics.js +0 -296
- package/scripts/lib/proof-outcome-evidence.js +0 -134
- package/scripts/lib/proof-receipt.js +0 -335
- package/scripts/lib/proof-record.js +0 -461
- package/scripts/lib/public-activation-distribution-gate.js +0 -258
- package/scripts/lib/public-cli.js +0 -3891
- package/scripts/lib/public-distribution-truth.js +0 -211
- package/scripts/lib/public-install-claim-checker.js +0 -294
- package/scripts/lib/publish-provenance-readiness.js +0 -283
- package/scripts/lib/readiness-delta.js +0 -218
- package/scripts/lib/readiness-evidence-closure.js +0 -196
- package/scripts/lib/reentry-memory-capture.js +0 -241
- package/scripts/lib/reentry-memory-retrieval.js +0 -302
- package/scripts/lib/reentry-memory-status.js +0 -146
- package/scripts/lib/reentry-memory-store.js +0 -178
- package/scripts/lib/reentry-state.js +0 -66
- package/scripts/lib/release-candidate-bundle.js +0 -166
- package/scripts/lib/remediation.js +0 -81
- package/scripts/lib/repo-map.js +0 -391
- package/scripts/lib/run-improvements-lifecycle.js +0 -330
- package/scripts/lib/run-improvements.js +0 -789
- package/scripts/lib/runtime-decision-policy.js +0 -387
- package/scripts/lib/safe-path-engine.js +0 -705
- package/scripts/lib/safe-run-controller.js +0 -887
- package/scripts/lib/score.js +0 -262
- package/scripts/lib/seamless-enforcement.js +0 -329
- package/scripts/lib/seamless-outcome.js +0 -689
- package/scripts/lib/seamless-reality-gate.js +0 -5043
- package/scripts/lib/security-risk-classifier.js +0 -511
- package/scripts/lib/security-scan.js +0 -384
- package/scripts/lib/session-context-optimizer.js +0 -1211
- package/scripts/lib/session-timing.js +0 -315
- package/scripts/lib/skill-hygiene.js +0 -805
- package/scripts/lib/skill-packs.js +0 -161
- package/scripts/lib/skills-operating-layer.js +0 -580
- package/scripts/lib/smart-work-routing.js +0 -768
- package/scripts/lib/source-catalog.js +0 -700
- package/scripts/lib/status-value-summary.js +0 -32
- package/scripts/lib/support-bundle.js +0 -578
- package/scripts/lib/task-continuation.js +0 -440
- package/scripts/lib/test-helpers.js +0 -15
- package/scripts/lib/tier.js +0 -38
- package/scripts/lib/token-context-quality-gate.js +0 -370
- package/scripts/lib/token-cost-capture.js +0 -187
- package/scripts/lib/token-cost-intelligence.js +0 -358
- package/scripts/lib/token-efficiency-evidence.js +0 -213
- package/scripts/lib/token-evidence.js +0 -699
- package/scripts/lib/tokenish.js +0 -17
- package/scripts/lib/tool-output-sandbox.js +0 -304
- package/scripts/lib/trust-audit.js +0 -136
- package/scripts/lib/unified-events.js +0 -396
- package/scripts/lib/upgrade-interruption-recovery.js +0 -407
- package/scripts/lib/usage-ledger.js +0 -201
- package/scripts/lib/value-ledger.js +0 -130
- package/scripts/lib/value-proof-calibration.js +0 -531
- package/scripts/lib/visual-qa.js +0 -231
- package/scripts/lib/voice-alpha.js +0 -29
- package/scripts/lib/work-aware-orchestration.js +0 -976
- package/scripts/lib/work-control-receipts.js +0 -577
- package/scripts/lib/work-ledger.js +0 -1123
- package/scripts/lib/work-panel-preview.js +0 -352
- package/scripts/lib/workflow-discipline.js +0 -280
- package/scripts/lib/workflow-signals.js +0 -419
- package/scripts/lib/workspace-map.js +0 -281
- package/scripts/lib/workspace-registry.js +0 -1367
- package/scripts/lib/workspace-resolver.js +0 -480
|
@@ -1,486 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const { detectProfile } = require("./model-profiles");
|
|
4
|
-
|
|
5
|
-
const COST_SCORE = { free_local: 0, local: 0, low: 1, medium: 2, high: 3, premium: 4, highest: 4, unknown: 2 };
|
|
6
|
-
const QUALITY_SCORE = { deterministic: 5, low: 1, medium: 2, medium_high: 3, high: 4, premium: 5, highest: 5, unknown: 1 };
|
|
7
|
-
const TRUST_SCORE = { local: 5, trusted: 4, unknown: 2, external: 1 };
|
|
8
|
-
const PRIVACY_SCORE = { local_only: 5, trusted_remote: 4, gateway_remote: 2, external_remote: 1, unknown: 1 };
|
|
9
|
-
|
|
10
|
-
const FALLBACK_REASON_CODES = {
|
|
11
|
-
WORKER_RECENTLY_LIMITED: "WORKER_RECENTLY_LIMITED",
|
|
12
|
-
WORKER_NEEDS_LOGIN: "WORKER_NEEDS_LOGIN",
|
|
13
|
-
WORKER_RECENTLY_FAILED: "WORKER_RECENTLY_FAILED",
|
|
14
|
-
WORKER_UNAVAILABLE: "WORKER_UNAVAILABLE",
|
|
15
|
-
LOCAL_WORKER_AVAILABLE: "LOCAL_WORKER_AVAILABLE",
|
|
16
|
-
LOCAL_WORKER_NOT_RUNNING: "LOCAL_WORKER_NOT_RUNNING",
|
|
17
|
-
FALLBACK_RECOMMENDED: "FALLBACK_RECOMMENDED",
|
|
18
|
-
ESCALATION_RECOMMENDED: "ESCALATION_RECOMMENDED",
|
|
19
|
-
PREMIUM_CONFIRMATION_REQUIRED: "PREMIUM_CONFIRMATION_REQUIRED",
|
|
20
|
-
LOCAL_PRIVATE_ONLY_MODE: "LOCAL_PRIVATE_ONLY_MODE",
|
|
21
|
-
SENSITIVE_TASK_BLOCKS_EXTERNAL: "SENSITIVE_TASK_BLOCKS_EXTERNAL",
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
function isExternalTool(tool) {
|
|
25
|
-
return tool.privacyTier === "external_remote" || tool.trustTier === "external" || tool.privacyTier === "gateway_remote";
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function supportsRole(tool, role) {
|
|
29
|
-
return Array.isArray(tool.supportedRoles) && tool.supportedRoles.includes(role);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function chooseProfile(tool, task, settings) {
|
|
33
|
-
const profiles = Array.isArray(tool.candidateProfiles) ? tool.candidateProfiles : [];
|
|
34
|
-
const confirmed = profiles.find((profile) => profile.availability === "confirmed");
|
|
35
|
-
if (confirmed) return confirmed;
|
|
36
|
-
if (task.risk === "low" || task.taskType === "docs") {
|
|
37
|
-
return profiles.find((profile) => /fast|mini|cheap|flash|summary|local_private/i.test(profile.id)) || profiles[0] || null;
|
|
38
|
-
}
|
|
39
|
-
if (task.risk === "high") {
|
|
40
|
-
return profiles.find((profile) => /high|reason|opus/i.test(profile.id)) || profiles.find((profile) => /default|coding|sonnet/i.test(profile.id)) || profiles[0] || null;
|
|
41
|
-
}
|
|
42
|
-
return profiles.find((profile) => /default|coding|sonnet|standard/i.test(profile.id)) || profiles[0] || null;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
function chooseModel(tool, task, settings) {
|
|
46
|
-
const models = Array.isArray(tool.models) ? tool.models : [];
|
|
47
|
-
if (models.length === 0) return null;
|
|
48
|
-
const confirmed = models.filter((model) => model.availability === "confirmed");
|
|
49
|
-
const configured = models.filter((model) => model.availability === "configured");
|
|
50
|
-
const candidate = models.filter((model) => model.availability === "candidate");
|
|
51
|
-
const pool = confirmed.length ? confirmed : (configured.length ? configured : candidate);
|
|
52
|
-
if (task.risk === "high") {
|
|
53
|
-
return pool.find((model) => model.safeForHighRisk) || pool.find((model) => model.qualityTier === "highest" || model.qualityTier === "high") || null;
|
|
54
|
-
}
|
|
55
|
-
if (task.taskType === "docs" || task.risk === "low") {
|
|
56
|
-
return pool.find((model) => model.costTier === "free_local" || model.costTier === "low") || pool[0] || null;
|
|
57
|
-
}
|
|
58
|
-
return pool.find((model) => model.profiles.includes("coding_candidate")) || pool.find((model) => model.qualityTier === "high") || pool[0] || null;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
function safeForTask(tool, task, settings) {
|
|
62
|
-
const reasons = [];
|
|
63
|
-
if (tool.enabled === false) reasons.push("disabled_by_user");
|
|
64
|
-
if (["unavailable", "missing", "stale"].includes(tool.workerState) || tool.installStatus === "not_installed") reasons.push("unavailable");
|
|
65
|
-
if (tool.workerState === "needs_login" || tool.availability === "needs_login") reasons.push("needs_login");
|
|
66
|
-
if (tool.workerState === "recently_limited") reasons.push("recently_limited");
|
|
67
|
-
if (tool.workerState === "recently_failed") reasons.push("recently_failed");
|
|
68
|
-
if (settings.mode === "disabled" || settings.enabled === false) reasons.push("orchestration_disabled");
|
|
69
|
-
|
|
70
|
-
if (settings.mode === "local_private_only" && tool.privacyTier !== "local_only" && !["git", "test_runner"].includes(tool.toolId)) {
|
|
71
|
-
reasons.push("local_private_only_mode");
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
if (task.risk === "high" && !tool.safeForHighRisk && !["git", "test_runner"].includes(tool.toolId)) {
|
|
75
|
-
reasons.push("not_safe_for_high_risk");
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
if (task.risk === "high" && settings.safety.blockCheapExternalHighRisk && isExternalTool(tool) && ["low", "free_local"].includes(tool.costTier)) {
|
|
79
|
-
reasons.push("cheap_external_blocked_for_high_risk");
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
if (["secret_risk", "customer_data_risk", "security_sensitive"].includes(task.sensitivity)
|
|
83
|
-
&& settings.safety.blockExternalSecrets
|
|
84
|
-
&& isExternalTool(tool)
|
|
85
|
-
&& !["git", "test_runner"].includes(tool.toolId)) {
|
|
86
|
-
reasons.push("external_blocked_for_sensitive_task");
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
return {
|
|
90
|
-
allowed: reasons.every((reason) => ![
|
|
91
|
-
"disabled_by_user",
|
|
92
|
-
"unavailable",
|
|
93
|
-
"needs_login",
|
|
94
|
-
"orchestration_disabled",
|
|
95
|
-
"local_private_only_mode",
|
|
96
|
-
"not_safe_for_high_risk",
|
|
97
|
-
"cheap_external_blocked_for_high_risk",
|
|
98
|
-
"external_blocked_for_sensitive_task",
|
|
99
|
-
"recently_limited",
|
|
100
|
-
"recently_failed",
|
|
101
|
-
].includes(reason)),
|
|
102
|
-
reasons,
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
function scoreTool(tool, role, task, settings, surface) {
|
|
107
|
-
if (!supportsRole(tool, role)) return -Infinity;
|
|
108
|
-
const safety = safeForTask(tool, task, settings);
|
|
109
|
-
if (!safety.allowed) return -Infinity;
|
|
110
|
-
|
|
111
|
-
let score = 10;
|
|
112
|
-
const profile = chooseProfile(tool, task, settings);
|
|
113
|
-
const model = chooseModel(tool, task, settings);
|
|
114
|
-
score += QUALITY_SCORE[tool.qualityTier] * (task.risk === "high" ? 3 : 2);
|
|
115
|
-
score -= COST_SCORE[tool.costTier] * (task.risk === "low" ? 2 : 1);
|
|
116
|
-
score += TRUST_SCORE[tool.trustTier] * (task.risk === "high" ? 3 : 1);
|
|
117
|
-
score += PRIVACY_SCORE[tool.privacyTier] * (settings.mode === "local_private_only" ? 3 : 1);
|
|
118
|
-
|
|
119
|
-
if (tool.availability === "confirmed") score += 3;
|
|
120
|
-
if (tool.availability === "configured") score += 2;
|
|
121
|
-
if (tool.executionMode === "in_session") score += 2;
|
|
122
|
-
if (surface === "claude_code" && tool.toolId === "claude_code") score += 2;
|
|
123
|
-
if (surface === "codex_cli" && tool.toolId === "codex") score += 2;
|
|
124
|
-
if (role === "verify" && ["test_runner", "git"].includes(tool.toolId)) score += 6;
|
|
125
|
-
if (task.taskType === "docs" && tool.toolId === "codex" && profile?.id === "fast_mini") score += 8;
|
|
126
|
-
if (["lm_studio", "ollama"].includes(tool.toolId) && settings.mode !== "local_private_only") score -= 6;
|
|
127
|
-
if (task.taskType === "security" && ["claude_code", "codex", "git", "test_runner"].includes(tool.toolId)) score += 4;
|
|
128
|
-
if (task.taskType === "docs" && ["lm_studio", "ollama"].includes(tool.toolId) && settings.mode === "local_private_only") score += 2;
|
|
129
|
-
if (model?.profiles?.includes("coding_candidate") && task.risk !== "high") score += 2;
|
|
130
|
-
if (settings.mode === "prefer_highest_quality") score += QUALITY_SCORE[tool.qualityTier] * 2;
|
|
131
|
-
return score;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
function rankTools(tools, role, task, settings, surface) {
|
|
135
|
-
return tools
|
|
136
|
-
.map((tool) => ({
|
|
137
|
-
tool,
|
|
138
|
-
profile: chooseProfile(tool, task, settings),
|
|
139
|
-
model: chooseModel(tool, task, settings),
|
|
140
|
-
score: scoreTool(tool, role, task, settings, surface),
|
|
141
|
-
safety: safeForTask(tool, task, settings),
|
|
142
|
-
}))
|
|
143
|
-
.sort((a, b) => b.score - a.score);
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
function describeWhyChosen(selected, task, settings, role) {
|
|
147
|
-
const reasons = [];
|
|
148
|
-
reasons.push(`${selected.tool.label} is available for ${role}`);
|
|
149
|
-
if (selected.model?.modelId) reasons.push(`model ${selected.model.modelId} is available`);
|
|
150
|
-
if (task.risk === "high") reasons.push("high-risk work prefers trusted higher-quality paths");
|
|
151
|
-
if (settings.mode === "prefer_lowest_cost" || task.risk === "low") reasons.push("cost was optimized only after safety and capability checks");
|
|
152
|
-
if (settings.mode === "local_private_only") reasons.push("local/private-only mode restricted external routes");
|
|
153
|
-
if (selected.tool.executionMode === "in_session") reasons.push("the current surface can continue without a brittle external handoff");
|
|
154
|
-
if (selected.profile?.id) reasons.push(`profile ${selected.profile.id} matched the task quality/cost target`);
|
|
155
|
-
return reasons;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
function describeWhyNotChosen(rankings, selectedToolId) {
|
|
159
|
-
return rankings
|
|
160
|
-
.filter((entry) => entry.tool.toolId !== selectedToolId)
|
|
161
|
-
.slice(0, 6)
|
|
162
|
-
.map((entry) => {
|
|
163
|
-
const safetyReason = entry.safety.reasons[0];
|
|
164
|
-
if (safetyReason) return `${entry.tool.label} was not chosen because ${safetyReason.replace(/_/g, " ")}`;
|
|
165
|
-
return `${entry.tool.label} was available but scored lower for this task`;
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
function blockedOptions(tools, task, settings) {
|
|
170
|
-
return tools
|
|
171
|
-
.map((tool) => ({ tool, safety: safeForTask(tool, task, settings), model: chooseModel(tool, task, settings) }))
|
|
172
|
-
.filter((entry) => !entry.safety.allowed || entry.safety.reasons.length > 0)
|
|
173
|
-
.map((entry) => ({
|
|
174
|
-
toolId: entry.tool.toolId,
|
|
175
|
-
label: entry.tool.label,
|
|
176
|
-
modelId: entry.model?.modelId || null,
|
|
177
|
-
reasons: entry.safety.reasons,
|
|
178
|
-
}));
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
function deriveQuotaSignal(tool) {
|
|
182
|
-
if (tool.workerState === "recently_limited") return "limited";
|
|
183
|
-
if (tool.quotaSignal === "local" || tool.costTier === "free_local") return "local";
|
|
184
|
-
if (tool.availability === "confirmed" || tool.availability === "configured") return "healthy";
|
|
185
|
-
return "unknown";
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
function deriveFallbackReasonCodes(tools, task, settings) {
|
|
189
|
-
const codes = [];
|
|
190
|
-
const localAvailable = tools.some((t) =>
|
|
191
|
-
["lm_studio", "ollama"].includes(t.toolId) &&
|
|
192
|
-
!["unavailable", "missing"].includes(t.workerState)
|
|
193
|
-
);
|
|
194
|
-
const localNotRunning = tools.some((t) =>
|
|
195
|
-
["lm_studio", "ollama"].includes(t.toolId) &&
|
|
196
|
-
t.installStatus === "installed_or_configured_but_not_running"
|
|
197
|
-
);
|
|
198
|
-
if (localAvailable) codes.push(FALLBACK_REASON_CODES.LOCAL_WORKER_AVAILABLE);
|
|
199
|
-
if (localNotRunning) codes.push(FALLBACK_REASON_CODES.LOCAL_WORKER_NOT_RUNNING);
|
|
200
|
-
|
|
201
|
-
tools.forEach((t) => {
|
|
202
|
-
if (t.workerState === "recently_limited") codes.push(FALLBACK_REASON_CODES.WORKER_RECENTLY_LIMITED);
|
|
203
|
-
if (t.workerState === "needs_login") codes.push(FALLBACK_REASON_CODES.WORKER_NEEDS_LOGIN);
|
|
204
|
-
if (t.workerState === "recently_failed") codes.push(FALLBACK_REASON_CODES.WORKER_RECENTLY_FAILED);
|
|
205
|
-
if (["unavailable", "missing"].includes(t.workerState) && t.toolId !== "test_runner" && t.toolId !== "git") {
|
|
206
|
-
codes.push(FALLBACK_REASON_CODES.WORKER_UNAVAILABLE);
|
|
207
|
-
}
|
|
208
|
-
});
|
|
209
|
-
|
|
210
|
-
if (task.risk === "high") codes.push(FALLBACK_REASON_CODES.ESCALATION_RECOMMENDED);
|
|
211
|
-
if (settings.mode === "local_private_only") codes.push(FALLBACK_REASON_CODES.LOCAL_PRIVATE_ONLY_MODE);
|
|
212
|
-
if (["secret_risk", "customer_data_risk", "security_sensitive"].includes(task.sensitivity)) {
|
|
213
|
-
codes.push(FALLBACK_REASON_CODES.SENSITIVE_TASK_BLOCKS_EXTERNAL);
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
return [...new Set(codes)];
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
function buildLocalWorkerRecommendation(tools, task) {
|
|
220
|
-
const localWorkers = tools.filter((t) =>
|
|
221
|
-
["lm_studio", "ollama"].includes(t.toolId) &&
|
|
222
|
-
!["unavailable", "missing", "recently_failed"].includes(t.workerState)
|
|
223
|
-
);
|
|
224
|
-
if (!localWorkers.length) return null;
|
|
225
|
-
const available = localWorkers.filter((t) => t.workerState !== "recently_limited");
|
|
226
|
-
if (!available.length) return null;
|
|
227
|
-
const w = available[0];
|
|
228
|
-
return {
|
|
229
|
-
workerId: w.toolId,
|
|
230
|
-
label: w.label,
|
|
231
|
-
recommendedFor: ["inspect", "summarize", "repo_reading", "planning"].filter((role) =>
|
|
232
|
-
(w.supportedRoles || []).includes(role) || ["planning", "summaries", "repo_reading"].some((r) => (w.supportedRoles || []).includes(r))
|
|
233
|
-
),
|
|
234
|
-
costTier: w.costTier,
|
|
235
|
-
quotaSignal: deriveQuotaSignal(w),
|
|
236
|
-
reason: "local worker is available and safe for low-sensitivity inspection/planning stages",
|
|
237
|
-
};
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
function buildStage(id, role, selected, fallback, task, settings, routeSummary, extras = {}) {
|
|
241
|
-
return {
|
|
242
|
-
id,
|
|
243
|
-
role,
|
|
244
|
-
state: "pending",
|
|
245
|
-
chosenTool: selected.tool.toolId,
|
|
246
|
-
chosenLabel: selected.tool.label,
|
|
247
|
-
chosenModel: selected.model?.modelId || selected.tool.activeModel || null,
|
|
248
|
-
chosenModelProfile: selected.profile?.id || selected.tool.activeProfile || selected.tool.activeModel || "unknown",
|
|
249
|
-
executionMode: selected.tool.executionMode,
|
|
250
|
-
fallbackTool: fallback?.tool.toolId || null,
|
|
251
|
-
fallbackModel: fallback?.model?.modelId || fallback?.tool.activeModel || null,
|
|
252
|
-
fallbackModelProfile: fallback?.profile?.id || fallback?.tool.activeProfile || fallback?.tool.activeModel || null,
|
|
253
|
-
whyChosen: describeWhyChosen(selected, task, settings, role),
|
|
254
|
-
safetyNotes: routeSummary.safetyNotes,
|
|
255
|
-
requiresConfirmation: routeSummary.requiresConfirmation,
|
|
256
|
-
quotaSignal: deriveQuotaSignal(selected.tool),
|
|
257
|
-
...extras,
|
|
258
|
-
};
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
function planRoute({ taskText, task, inventory, settings, surface = "avorelo_cli" }) {
|
|
262
|
-
const tools = Array.isArray(inventory?.tools) ? inventory.tools : [];
|
|
263
|
-
const blocked = blockedOptions(tools, task, settings);
|
|
264
|
-
|
|
265
|
-
if (settings.mode === "disabled" || settings.enabled === false) {
|
|
266
|
-
return {
|
|
267
|
-
routeVersion: 2,
|
|
268
|
-
state: "blocked",
|
|
269
|
-
selectedRoute: "disabled",
|
|
270
|
-
stageList: [],
|
|
271
|
-
chosenTool: null,
|
|
272
|
-
selectedModel: null,
|
|
273
|
-
chosenModelProfile: null,
|
|
274
|
-
fallbackTool: null,
|
|
275
|
-
fallbackModel: null,
|
|
276
|
-
fallbackModelProfile: null,
|
|
277
|
-
whyChosen: ["Orchestration is disabled in settings"],
|
|
278
|
-
whyNotChosen: [],
|
|
279
|
-
blockedOptions: blocked,
|
|
280
|
-
expectedVerification: [],
|
|
281
|
-
safetyNotes: ["Avorelo will not route or hand off work while orchestration is disabled."],
|
|
282
|
-
requiresConfirmation: false,
|
|
283
|
-
externalModelInvolved: false,
|
|
284
|
-
premiumUseInvolved: false,
|
|
285
|
-
inventorySource: inventory?.inventorySource || "cache",
|
|
286
|
-
cacheUsed: inventory?.inventorySource === "cache",
|
|
287
|
-
lastFullModelRefreshAt: inventory?.lastFullModelRefreshAt || null,
|
|
288
|
-
nextFullModelRefreshAfter: inventory?.nextFullModelRefreshAfter || null,
|
|
289
|
-
refreshLevel: inventory?.refreshLevel || "cache",
|
|
290
|
-
task,
|
|
291
|
-
taskText,
|
|
292
|
-
surface,
|
|
293
|
-
};
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
const fallbackReasonCodes = deriveFallbackReasonCodes(tools, task, settings);
|
|
297
|
-
const localWorkerRecommendation = buildLocalWorkerRecommendation(tools, task);
|
|
298
|
-
|
|
299
|
-
const planRoleNeeded = task.risk !== "high" && task.taskType !== "docs";
|
|
300
|
-
const needsInspectStage = task.taskType !== "docs" && task.contextNeed !== "small";
|
|
301
|
-
const needsSecurityReview = task.taskType === "security" || task.sensitivity === "security_sensitive" || task.risk === "high";
|
|
302
|
-
const implementationRole = task.taskType === "docs" ? "docs" : (task.taskType === "tests" ? "tests" : "implementation");
|
|
303
|
-
const planningRank = rankTools(tools, "planning", task, settings, surface);
|
|
304
|
-
const implementationRank = rankTools(tools, implementationRole, task, settings, surface);
|
|
305
|
-
const verificationRank = rankTools(tools, "verify", task, settings, surface);
|
|
306
|
-
const reviewRank = rankTools(tools, "review", task, settings, surface);
|
|
307
|
-
const summaryRank = rankTools(tools, "summaries", task, settings, surface);
|
|
308
|
-
const securityRank = rankTools(tools, "security", task, settings, surface);
|
|
309
|
-
|
|
310
|
-
const selectedPlan = planRoleNeeded ? planningRank.find((entry) => Number.isFinite(entry.score) && entry.score > -Infinity) : null;
|
|
311
|
-
const selectedImplement = implementationRank.find((entry) => Number.isFinite(entry.score) && entry.score > -Infinity);
|
|
312
|
-
const selectedVerify = verificationRank.find((entry) => Number.isFinite(entry.score) && entry.score > -Infinity);
|
|
313
|
-
const selectedFallback = reviewRank.find((entry) => Number.isFinite(entry.score) && entry.score > -Infinity && entry.tool.toolId !== selectedImplement?.tool.toolId)
|
|
314
|
-
|| implementationRank.find((entry) => Number.isFinite(entry.score) && entry.score > -Infinity && entry.tool.toolId !== selectedImplement?.tool.toolId);
|
|
315
|
-
const selectedSummary = summaryRank.find((entry) => Number.isFinite(entry.score) && entry.score > -Infinity);
|
|
316
|
-
const selectedSecurityReview = needsSecurityReview ? (securityRank.find((entry) => Number.isFinite(entry.score) && entry.score > -Infinity && entry.tool.toolId !== selectedImplement?.tool.toolId) || selectedFallback) : null;
|
|
317
|
-
|
|
318
|
-
if (!selectedImplement) {
|
|
319
|
-
return {
|
|
320
|
-
routeVersion: 2,
|
|
321
|
-
state: tools.length ? "blocked" : "unavailable",
|
|
322
|
-
selectedRoute: task.risk === "high" ? "high_risk_blocked" : "no_capable_worker",
|
|
323
|
-
stageList: [],
|
|
324
|
-
chosenTool: null,
|
|
325
|
-
selectedModel: null,
|
|
326
|
-
chosenModelProfile: null,
|
|
327
|
-
fallbackTool: null,
|
|
328
|
-
fallbackModel: null,
|
|
329
|
-
fallbackModelProfile: null,
|
|
330
|
-
whyChosen: [],
|
|
331
|
-
whyNotChosen: describeWhyNotChosen(implementationRank, null),
|
|
332
|
-
blockedOptions: blocked,
|
|
333
|
-
expectedVerification: ["git diff"],
|
|
334
|
-
safetyNotes: task.risk === "high"
|
|
335
|
-
? ["Cheap or untrusted workers were blocked for this high-risk task."]
|
|
336
|
-
: ["No installed worker met the current safety/capability requirements."],
|
|
337
|
-
requiresConfirmation: false,
|
|
338
|
-
externalModelInvolved: false,
|
|
339
|
-
premiumUseInvolved: false,
|
|
340
|
-
inventorySource: inventory?.inventorySource || "cache",
|
|
341
|
-
cacheUsed: inventory?.inventorySource === "cache",
|
|
342
|
-
lastFullModelRefreshAt: inventory?.lastFullModelRefreshAt || null,
|
|
343
|
-
nextFullModelRefreshAfter: inventory?.nextFullModelRefreshAfter || null,
|
|
344
|
-
refreshLevel: inventory?.refreshLevel || "cache",
|
|
345
|
-
task,
|
|
346
|
-
taskText,
|
|
347
|
-
surface,
|
|
348
|
-
};
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
const premiumUseInvolved = ["high", "highest"].includes(selectedImplement.tool.costTier) || /high_reasoning|opus/i.test(selectedImplement.profile?.id || "");
|
|
352
|
-
const externalModelInvolved = isExternalTool(selectedImplement.tool) || (selectedPlan ? isExternalTool(selectedPlan.tool) : false) || (selectedFallback ? isExternalTool(selectedFallback.tool) : false);
|
|
353
|
-
const requiresConfirmation = Boolean(settings.askBeforePremium || settings.mode === "ask_before_premium") && premiumUseInvolved;
|
|
354
|
-
const safetyNotes = [];
|
|
355
|
-
if (task.risk === "high") safetyNotes.push("High-risk tasks block cheap external workers by default.");
|
|
356
|
-
if (["secret_risk", "customer_data_risk", "security_sensitive"].includes(task.sensitivity)) {
|
|
357
|
-
safetyNotes.push("External routing stays blocked when secrets, customer data, or security-sensitive scope is detected.");
|
|
358
|
-
}
|
|
359
|
-
if (settings.mode === "local_private_only") safetyNotes.push("Only local/private workers were considered.");
|
|
360
|
-
if (settings.safety.stopAfterRepeatedFailures) safetyNotes.push("Repeated worker failures stop or escalate instead of looping.");
|
|
361
|
-
|
|
362
|
-
const routeSummary = { requiresConfirmation, safetyNotes };
|
|
363
|
-
const stageList = [];
|
|
364
|
-
|
|
365
|
-
if (needsInspectStage && selectedSummary) {
|
|
366
|
-
stageList.push(buildStage("inspect", "summaries", selectedSummary, selectedPlan || null, task, settings, routeSummary, {
|
|
367
|
-
taskSlice: "Inspect repo structure, changed files, and relevant context",
|
|
368
|
-
contextNeed: "small",
|
|
369
|
-
reasoningNeed: "low",
|
|
370
|
-
}));
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
if (selectedPlan) {
|
|
374
|
-
stageList.push(buildStage("plan", "planning", selectedPlan, selectedFallback, task, settings, routeSummary, {
|
|
375
|
-
taskSlice: "Plan implementation approach, identify affected files and tests",
|
|
376
|
-
contextNeed: task.risk === "high" ? "large" : "medium",
|
|
377
|
-
reasoningNeed: task.risk === "high" ? "high" : "medium",
|
|
378
|
-
}));
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
stageList.push(buildStage("implement", implementationRole, selectedImplement, selectedFallback, task, settings, routeSummary, {
|
|
382
|
-
taskSlice: "Implement the changes with tests",
|
|
383
|
-
contextNeed: "large",
|
|
384
|
-
reasoningNeed: task.risk === "high" ? "high" : "medium",
|
|
385
|
-
}));
|
|
386
|
-
|
|
387
|
-
if (selectedVerify) {
|
|
388
|
-
stageList.push(buildStage("verify", "verify", selectedVerify, null, task, settings, routeSummary, {
|
|
389
|
-
taskSlice: "Run deterministic verification: tests, lint, git diff",
|
|
390
|
-
contextNeed: "small",
|
|
391
|
-
reasoningNeed: "low",
|
|
392
|
-
}));
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
if (needsSecurityReview && selectedSecurityReview) {
|
|
396
|
-
stageList.push(buildStage("security_review", "security", selectedSecurityReview, null, task, settings, routeSummary, {
|
|
397
|
-
taskSlice: "Security review: check for regressions in safety/governance/safe-path",
|
|
398
|
-
contextNeed: "medium",
|
|
399
|
-
reasoningNeed: "high",
|
|
400
|
-
}));
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
if (task.risk === "high" && selectedFallback) {
|
|
404
|
-
stageList.push(buildStage("review", "review", selectedFallback, null, task, settings, routeSummary, {
|
|
405
|
-
taskSlice: "Final review and merge readiness check",
|
|
406
|
-
contextNeed: "medium",
|
|
407
|
-
reasoningNeed: "high",
|
|
408
|
-
}));
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
if (selectedImplement.tool.executionMode === "handoff") {
|
|
412
|
-
stageList.push({
|
|
413
|
-
id: "handoff",
|
|
414
|
-
role: "handoff",
|
|
415
|
-
state: "pending",
|
|
416
|
-
chosenTool: "avorelo_handoff",
|
|
417
|
-
chosenLabel: "Avorelo handoff prompt",
|
|
418
|
-
chosenModel: null,
|
|
419
|
-
chosenModelProfile: "compact_handoff",
|
|
420
|
-
executionMode: "local_command",
|
|
421
|
-
fallbackTool: null,
|
|
422
|
-
fallbackModel: null,
|
|
423
|
-
fallbackModelProfile: null,
|
|
424
|
-
whyChosen: ["A handoff is needed to pass context to the next worker/session"],
|
|
425
|
-
safetyNotes: routeSummary.safetyNotes,
|
|
426
|
-
requiresConfirmation: false,
|
|
427
|
-
quotaSignal: "local",
|
|
428
|
-
taskSlice: "Generate compact handoff prompt for next worker/session",
|
|
429
|
-
contextNeed: "small",
|
|
430
|
-
reasoningNeed: "low",
|
|
431
|
-
});
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
const limitedWorkers = tools.filter((t) => t.workerState === "recently_limited").map((t) => ({
|
|
435
|
-
toolId: t.toolId,
|
|
436
|
-
label: t.label,
|
|
437
|
-
reasonCode: FALLBACK_REASON_CODES.WORKER_RECENTLY_LIMITED,
|
|
438
|
-
}));
|
|
439
|
-
|
|
440
|
-
const localWorkersAvailable = tools.filter((t) =>
|
|
441
|
-
["lm_studio", "ollama"].includes(t.toolId) &&
|
|
442
|
-
!["unavailable", "missing"].includes(t.workerState)
|
|
443
|
-
).map((t) => t.toolId);
|
|
444
|
-
|
|
445
|
-
const state = selectedVerify ? (selectedImplement.tool.executionMode === "handoff" ? "partial" : "ready") : "partial";
|
|
446
|
-
return {
|
|
447
|
-
routeVersion: 3,
|
|
448
|
-
state,
|
|
449
|
-
selectedRoute: `${task.risk}_${settings.mode}`,
|
|
450
|
-
stageList,
|
|
451
|
-
stageCount: stageList.length,
|
|
452
|
-
chosenTool: selectedImplement.tool.toolId,
|
|
453
|
-
selectedModel: selectedImplement.model?.modelId || selectedImplement.tool.activeModel || null,
|
|
454
|
-
chosenModelProfile: selectedImplement.profile?.id || selectedImplement.tool.activeProfile || selectedImplement.tool.activeModel || "unknown",
|
|
455
|
-
fallbackTool: selectedFallback?.tool.toolId || null,
|
|
456
|
-
fallbackModel: selectedFallback?.model?.modelId || selectedFallback?.tool.activeModel || null,
|
|
457
|
-
fallbackModelProfile: selectedFallback?.profile?.id || selectedFallback?.tool.activeProfile || selectedFallback?.tool.activeModel || null,
|
|
458
|
-
whyChosen: describeWhyChosen(selectedImplement, task, settings, implementationRole),
|
|
459
|
-
whyNotChosen: describeWhyNotChosen(implementationRank, selectedImplement.tool.toolId),
|
|
460
|
-
blockedOptions: blocked,
|
|
461
|
-
expectedVerification: selectedVerify ? [`${selectedVerify.tool.label} deterministic verification`] : ["Verification is currently insufficient; Avorelo will still capture proof."],
|
|
462
|
-
safetyNotes,
|
|
463
|
-
requiresConfirmation,
|
|
464
|
-
externalModelInvolved,
|
|
465
|
-
premiumUseInvolved,
|
|
466
|
-
selectionReason: describeWhyChosen(selectedImplement, task, settings, implementationRole),
|
|
467
|
-
fallbackReasonCodes,
|
|
468
|
-
limitedWorkers,
|
|
469
|
-
localWorkersAvailable,
|
|
470
|
-
localWorkerRecommendation,
|
|
471
|
-
handoffAvailable: selectedImplement.tool.executionMode === "handoff",
|
|
472
|
-
inventorySource: inventory?.inventorySource || "cache",
|
|
473
|
-
cacheUsed: inventory?.inventorySource === "cache",
|
|
474
|
-
lastFullModelRefreshAt: inventory?.lastFullModelRefreshAt || null,
|
|
475
|
-
nextFullModelRefreshAfter: inventory?.nextFullModelRefreshAfter || null,
|
|
476
|
-
refreshLevel: inventory?.refreshLevel || "cache",
|
|
477
|
-
task,
|
|
478
|
-
taskText,
|
|
479
|
-
surface,
|
|
480
|
-
};
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
module.exports = {
|
|
484
|
-
planRoute,
|
|
485
|
-
FALLBACK_REASON_CODES,
|
|
486
|
-
};
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const { readProjectConfig, writeProjectConfig, ORCHESTRATION_WORKER_IDS } = require("../config");
|
|
4
|
-
|
|
5
|
-
const MODE_LABELS = {
|
|
6
|
-
auto_recommended: "Auto recommended",
|
|
7
|
-
prefer_lowest_cost: "Prefer lower cost",
|
|
8
|
-
prefer_highest_quality: "Prefer highest quality",
|
|
9
|
-
local_private_only: "Local/private only",
|
|
10
|
-
ask_before_premium: "Ask before premium tools",
|
|
11
|
-
premium_only_for_risky: "Premium only for risky",
|
|
12
|
-
disabled: "Disable orchestration",
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
function getSettings(cwd) {
|
|
16
|
-
return readProjectConfig(cwd).orchestration;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function updateSettings(cwd, mutator) {
|
|
20
|
-
const config = readProjectConfig(cwd);
|
|
21
|
-
const next = mutator(config);
|
|
22
|
-
return writeProjectConfig(cwd, next).orchestration;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function setMode(cwd, mode) {
|
|
26
|
-
return updateSettings(cwd, (config) => ({
|
|
27
|
-
...config,
|
|
28
|
-
orchestration: {
|
|
29
|
-
...config.orchestration,
|
|
30
|
-
mode,
|
|
31
|
-
enabled: mode !== "disabled",
|
|
32
|
-
askBeforePremium: mode === "ask_before_premium" ? true : config.orchestration.askBeforePremium,
|
|
33
|
-
},
|
|
34
|
-
}));
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function setBooleanFlag(cwd, keyPath, value) {
|
|
38
|
-
return updateSettings(cwd, (config) => {
|
|
39
|
-
const next = { ...config, orchestration: { ...config.orchestration, safety: { ...(config.orchestration?.safety || {}) } } };
|
|
40
|
-
if (keyPath === "askBeforePremium") {
|
|
41
|
-
next.orchestration.askBeforePremium = value;
|
|
42
|
-
} else {
|
|
43
|
-
next.orchestration.safety[keyPath] = value;
|
|
44
|
-
}
|
|
45
|
-
return next;
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
function setWorkerEnabled(cwd, workerId, enabled) {
|
|
50
|
-
if (!ORCHESTRATION_WORKER_IDS.includes(workerId)) {
|
|
51
|
-
throw new Error(`Unknown orchestration worker: ${workerId}`);
|
|
52
|
-
}
|
|
53
|
-
return updateSettings(cwd, (config) => ({
|
|
54
|
-
...config,
|
|
55
|
-
orchestration: {
|
|
56
|
-
...config.orchestration,
|
|
57
|
-
allowedWorkers: {
|
|
58
|
-
...(config.orchestration?.allowedWorkers || {}),
|
|
59
|
-
[workerId]: enabled,
|
|
60
|
-
},
|
|
61
|
-
},
|
|
62
|
-
}));
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
function formatSettingsText(settings, inventory = null) {
|
|
66
|
-
const lines = [
|
|
67
|
-
"Avorelo Orchestration Settings",
|
|
68
|
-
`Mode: ${MODE_LABELS[settings.mode] || settings.mode}`,
|
|
69
|
-
`Ask before premium: ${settings.askBeforePremium ? "on" : "off"}`,
|
|
70
|
-
`Block cheap external models for high-risk tasks: ${settings.safety.blockCheapExternalHighRisk ? "on" : "off"}`,
|
|
71
|
-
`Block external models for secrets/customer-data risk: ${settings.safety.blockExternalSecrets ? "on" : "off"}`,
|
|
72
|
-
`Stop after repeated failures: ${settings.safety.stopAfterRepeatedFailures ? "on" : "off"}`,
|
|
73
|
-
`Require proof before completion: ${settings.safety.requireProofBeforeCompletion ? "on" : "off"}`,
|
|
74
|
-
`Full model refresh interval: ${settings.refreshPolicy?.fullRefreshIntervalHours || 72}h`,
|
|
75
|
-
`Single-model refresh on new usage: ${settings.refreshPolicy?.singleModelRefreshOnNewUsage !== false ? "on" : "off"}`,
|
|
76
|
-
"",
|
|
77
|
-
"Allowed workers:",
|
|
78
|
-
...ORCHESTRATION_WORKER_IDS.map((workerId) => `- ${workerId}: ${settings.allowedWorkers[workerId] !== false ? "enabled" : "disabled"}`),
|
|
79
|
-
];
|
|
80
|
-
|
|
81
|
-
if (inventory && Array.isArray(inventory.tools)) {
|
|
82
|
-
lines.push("", "Advanced detected tools/models:");
|
|
83
|
-
inventory.tools.forEach((tool) => {
|
|
84
|
-
lines.push(
|
|
85
|
-
`- ${tool.label}: ${tool.installStatus}/${tool.availability} · active ${tool.activeModel || tool.activeProfile || "unknown"} · roles ${(tool.supportedRoles || []).join(", ") || "n/a"} · cost ${tool.costTier} · trust ${tool.trustTier} · quota ${tool.quotaSignal}`
|
|
86
|
-
);
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
return lines.join("\n");
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
function settingsMetadata(settings) {
|
|
94
|
-
return {
|
|
95
|
-
currentMode: settings.mode,
|
|
96
|
-
options: Object.entries(MODE_LABELS).map(([value, label]) => ({ value, label })),
|
|
97
|
-
askBeforePremium: settings.askBeforePremium,
|
|
98
|
-
safety: settings.safety,
|
|
99
|
-
allowedWorkers: settings.allowedWorkers,
|
|
100
|
-
refreshPolicy: settings.refreshPolicy,
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
module.exports = {
|
|
105
|
-
MODE_LABELS,
|
|
106
|
-
getSettings,
|
|
107
|
-
setMode,
|
|
108
|
-
setBooleanFlag,
|
|
109
|
-
setWorkerEnabled,
|
|
110
|
-
formatSettingsText,
|
|
111
|
-
settingsMetadata,
|
|
112
|
-
};
|