@aria_asi/cli 0.2.36 → 0.2.37
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/CLIENT-ONBOARDING.md +4 -2
- package/bin/aria.js +11 -7
- package/dist/aria-connector/src/auth.d.ts +14 -0
- package/dist/aria-connector/src/auth.d.ts.map +1 -1
- package/dist/aria-connector/src/auth.js +103 -1
- package/dist/aria-connector/src/auth.js.map +1 -1
- package/dist/aria-connector/src/chat.d.ts.map +1 -1
- package/dist/aria-connector/src/chat.js +13 -8
- package/dist/aria-connector/src/chat.js.map +1 -1
- package/dist/aria-connector/src/config.d.ts +6 -1
- package/dist/aria-connector/src/config.d.ts.map +1 -1
- package/dist/aria-connector/src/config.js.map +1 -1
- package/dist/aria-connector/src/connectors/claude-code.d.ts.map +1 -1
- package/dist/aria-connector/src/connectors/claude-code.js +50 -6
- package/dist/aria-connector/src/connectors/claude-code.js.map +1 -1
- package/dist/aria-connector/src/connectors/codex.d.ts.map +1 -1
- package/dist/aria-connector/src/connectors/codex.js +310 -10
- package/dist/aria-connector/src/connectors/codex.js.map +1 -1
- package/dist/aria-connector/src/connectors/opencode.d.ts.map +1 -1
- package/dist/aria-connector/src/connectors/opencode.js +35 -11
- package/dist/aria-connector/src/connectors/opencode.js.map +1 -1
- package/dist/aria-connector/src/connectors/repo-guard.d.ts +10 -0
- package/dist/aria-connector/src/connectors/repo-guard.d.ts.map +1 -1
- package/dist/aria-connector/src/connectors/repo-guard.js +110 -164
- package/dist/aria-connector/src/connectors/repo-guard.js.map +1 -1
- package/dist/aria-connector/src/connectors/runtime.d.ts.map +1 -1
- package/dist/aria-connector/src/connectors/runtime.js +17 -7
- package/dist/aria-connector/src/connectors/runtime.js.map +1 -1
- package/dist/aria-connector/src/connectors/shell.d.ts.map +1 -1
- package/dist/aria-connector/src/connectors/shell.js +12 -8
- package/dist/aria-connector/src/connectors/shell.js.map +1 -1
- package/dist/aria-connector/src/harness-client.d.ts +3 -1
- package/dist/aria-connector/src/harness-client.d.ts.map +1 -1
- package/dist/aria-connector/src/harness-client.js +7 -20
- package/dist/aria-connector/src/harness-client.js.map +1 -1
- package/dist/aria-connector/src/model-context.d.ts.map +1 -1
- package/dist/aria-connector/src/model-context.js +5 -0
- package/dist/aria-connector/src/model-context.js.map +1 -1
- package/dist/aria-connector/src/providers/types.d.ts +1 -1
- package/dist/aria-connector/src/providers/types.d.ts.map +1 -1
- package/dist/aria-connector/src/providers/xai.d.ts +3 -0
- package/dist/aria-connector/src/providers/xai.d.ts.map +1 -0
- package/dist/aria-connector/src/providers/xai.js +40 -0
- package/dist/aria-connector/src/providers/xai.js.map +1 -0
- package/dist/aria-connector/src/setup-wizard.js +1 -0
- package/dist/aria-connector/src/setup-wizard.js.map +1 -1
- package/dist/aria-connector/src/types.d.ts +2 -0
- package/dist/aria-connector/src/types.d.ts.map +1 -1
- package/dist/assets/hooks/aria-cognition-substrate-binding.mjs +51 -9
- package/dist/assets/hooks/aria-first-class-coach.mjs +129 -0
- package/dist/assets/hooks/aria-harness-via-sdk.mjs +33 -6
- package/dist/assets/hooks/aria-pre-tool-gate.mjs +33 -8
- package/dist/assets/hooks/aria-preprompt-consult.mjs +5 -6
- package/dist/assets/hooks/aria-preturn-memory-gate.mjs +5 -0
- package/dist/assets/hooks/aria-repo-doctrine-gate.mjs +15 -0
- package/dist/assets/hooks/aria-stop-gate.mjs +125 -17
- package/dist/assets/hooks/doctrine_trigger_map.json +11 -0
- package/dist/assets/hooks/lib/emergency-gateoff-impl.mjs +39 -0
- package/dist/assets/hooks/lib/emergency-gateoff.mjs +6 -0
- package/dist/assets/hooks/lib/first-class-coach.mjs +755 -0
- package/dist/assets/hooks/lib/skill-autoload-gate-impl.mjs +103 -0
- package/dist/assets/hooks/lib/skill-autoload-gate.mjs +1 -14
- package/dist/assets/opencode-plugins/harness-context/auth-token.mjs +126 -0
- package/dist/assets/opencode-plugins/harness-context/inject-context.mjs +62 -22
- package/dist/assets/opencode-plugins/harness-context/task-project-ledger.mjs +290 -0
- package/dist/assets/opencode-plugins/harness-gate/index.js +87 -27
- package/dist/assets/opencode-plugins/harness-gate/lib/skill-autoload-gate.js +1 -14
- package/dist/assets/opencode-plugins/harness-outcome/index.js +29 -24
- package/dist/assets/opencode-plugins/harness-stop/index.js +229 -68
- package/dist/assets/opencode-plugins/harness-stop/lib/skill-autoload-gate.js +1 -14
- package/dist/runtime/auth-token.mjs +121 -0
- package/dist/runtime/coach-kernel.mjs +371 -0
- package/dist/runtime/codex-bridge.mjs +440 -69
- package/dist/runtime/discipline/doctrine_trigger_map.json +11 -0
- package/dist/runtime/discipline/skills/aria-cognition/aria-essence/SKILL.md +18 -0
- package/dist/runtime/discipline/skills/aria-cognition/aria-forge-guardrails/SKILL.md +18 -0
- package/dist/runtime/discipline/skills/aria-cognition/aria-repo-doctrine/SKILL.md +18 -0
- package/dist/runtime/discipline/skills/aria-cognition/forge-quality-rules/SKILL.md +18 -0
- package/dist/runtime/discipline/skills/aria-cognition/ghazali-8lens/SKILL.md +18 -0
- package/dist/runtime/discipline/skills/aria-cognition/istiqra-induction/SKILL.md +18 -0
- package/dist/runtime/discipline/skills/aria-cognition/ladunni-22/SKILL.md +18 -0
- package/dist/runtime/discipline/skills/aria-cognition/mizan/SKILL.md +18 -0
- package/dist/runtime/discipline/skills/aria-cognition/nadia/SKILL.md +18 -0
- package/dist/runtime/discipline/skills/aria-cognition/nadia-psi/SKILL.md +18 -0
- package/dist/runtime/discipline/skills/aria-cognition/predictor/SKILL.md +18 -0
- package/dist/runtime/discipline/skills/aria-cognition/qiyas-analogy/SKILL.md +18 -0
- package/dist/runtime/discipline/skills/aria-cognition/soul-domains/SKILL.md +18 -0
- package/dist/runtime/discipline/skills/aria-harness/aria-aristotle-intra-phase/SKILL.md +18 -0
- package/dist/runtime/discipline/skills/aria-harness/aria-aristotle-post-phase/SKILL.md +18 -0
- package/dist/runtime/discipline/skills/aria-harness/aria-aristotle-pre-phase/SKILL.md +18 -0
- package/dist/runtime/discipline/skills/aria-harness/aria-harness-deploy/SKILL.md +18 -0
- package/dist/runtime/discipline/skills/aria-harness/aria-harness-no-stripping/SKILL.md +18 -0
- package/dist/runtime/discipline/skills/aria-harness/aria-harness-onboarding/SKILL.md +18 -0
- package/dist/runtime/discipline/skills/aria-harness/aria-harness-output-discipline/SKILL.md +18 -0
- package/dist/runtime/discipline/skills/aria-harness/aria-harness-substrate-binding/SKILL.md +18 -0
- package/dist/runtime/doctrine_trigger_map.json +11 -0
- package/dist/runtime/hooks/aria-cognition-substrate-binding.mjs +51 -9
- package/dist/runtime/hooks/aria-first-class-coach.mjs +129 -0
- package/dist/runtime/hooks/aria-harness-via-sdk.mjs +33 -6
- package/dist/runtime/hooks/aria-pre-tool-gate.mjs +33 -8
- package/dist/runtime/hooks/aria-preprompt-consult.mjs +5 -6
- package/dist/runtime/hooks/aria-preturn-memory-gate.mjs +5 -0
- package/dist/runtime/hooks/aria-repo-doctrine-gate.mjs +15 -0
- package/dist/runtime/hooks/aria-stop-gate.mjs +125 -17
- package/dist/runtime/hooks/doctrine_trigger_map.json +11 -0
- package/dist/runtime/hooks/lib/emergency-gateoff-impl.mjs +39 -0
- package/dist/runtime/hooks/lib/emergency-gateoff.mjs +6 -0
- package/dist/runtime/hooks/lib/first-class-coach.mjs +755 -0
- package/dist/runtime/hooks/lib/skill-autoload-gate-impl.mjs +103 -0
- package/dist/runtime/hooks/lib/skill-autoload-gate.mjs +1 -14
- package/dist/runtime/local-phase.mjs +8 -0
- package/dist/runtime/manifest.json +2 -2
- package/dist/runtime/provider-proxy.mjs +136 -33
- package/dist/runtime/sdk/BUNDLED.json +2 -2
- package/dist/runtime/sdk/auth.d.ts +17 -0
- package/dist/runtime/sdk/auth.js +158 -0
- package/dist/runtime/sdk/auth.js.map +1 -0
- package/dist/runtime/sdk/index.d.ts +8 -1
- package/dist/runtime/sdk/index.js +15 -1
- package/dist/runtime/sdk/index.js.map +1 -1
- package/dist/runtime/service.mjs +1711 -74
- package/dist/runtime/task-project-ledger.mjs +290 -0
- package/dist/sdk/BUNDLED.json +2 -2
- package/dist/sdk/auth.d.ts +17 -0
- package/dist/sdk/auth.js +158 -0
- package/dist/sdk/auth.js.map +1 -0
- package/dist/sdk/index.d.ts +8 -1
- package/dist/sdk/index.js +15 -1
- package/dist/sdk/index.js.map +1 -1
- package/hooks/aria-cognition-substrate-binding.mjs +51 -9
- package/hooks/aria-first-class-coach.mjs +129 -0
- package/hooks/aria-harness-via-sdk.mjs +33 -6
- package/hooks/aria-pre-tool-gate.mjs +33 -8
- package/hooks/aria-preprompt-consult.mjs +5 -6
- package/hooks/aria-preturn-memory-gate.mjs +5 -0
- package/hooks/aria-repo-doctrine-gate.mjs +15 -0
- package/hooks/aria-stop-gate.mjs +125 -17
- package/hooks/doctrine_trigger_map.json +11 -0
- package/hooks/lib/emergency-gateoff-impl.mjs +39 -0
- package/hooks/lib/emergency-gateoff.mjs +6 -0
- package/hooks/lib/first-class-coach.mjs +755 -0
- package/hooks/lib/skill-autoload-gate-impl.mjs +103 -0
- package/hooks/lib/skill-autoload-gate.mjs +1 -14
- package/opencode-plugins/harness-context/auth-token.mjs +126 -0
- package/opencode-plugins/harness-context/inject-context.mjs +62 -22
- package/opencode-plugins/harness-context/task-project-ledger.mjs +290 -0
- package/opencode-plugins/harness-gate/index.js +87 -27
- package/opencode-plugins/harness-gate/lib/skill-autoload-gate.js +1 -14
- package/opencode-plugins/harness-outcome/index.js +29 -24
- package/opencode-plugins/harness-stop/index.js +229 -68
- package/opencode-plugins/harness-stop/lib/skill-autoload-gate.js +1 -14
- package/package.json +8 -2
- package/runtime-src/auth-token.mjs +121 -0
- package/runtime-src/coach-kernel.mjs +371 -0
- package/runtime-src/codex-bridge.mjs +440 -69
- package/runtime-src/local-phase.mjs +8 -0
- package/runtime-src/provider-proxy.mjs +136 -33
- package/runtime-src/service.mjs +1711 -74
- package/scripts/bundle-sdk.mjs +8 -0
- package/scripts/check-client-compatibility.mjs +422 -0
- package/scripts/check-coach-kernel.mjs +204 -0
- package/scripts/check-managed-runtime-ledger.mjs +107 -0
- package/scripts/check-opencode-config-contract.mjs +78 -0
- package/scripts/check-quality-ledger.mjs +121 -0
- package/scripts/self-test-harness-gates.mjs +179 -11
- package/scripts/self-test-repo-guard.mjs +38 -0
- package/scripts/validate-skill-prompts.mjs +14 -1
- package/skills/aria-cognition/aria-essence/SKILL.md +18 -0
- package/skills/aria-cognition/aria-forge-guardrails/SKILL.md +18 -0
- package/skills/aria-cognition/aria-repo-doctrine/SKILL.md +18 -0
- package/skills/aria-cognition/forge-quality-rules/SKILL.md +18 -0
- package/skills/aria-cognition/ghazali-8lens/SKILL.md +18 -0
- package/skills/aria-cognition/istiqra-induction/SKILL.md +18 -0
- package/skills/aria-cognition/ladunni-22/SKILL.md +18 -0
- package/skills/aria-cognition/mizan/SKILL.md +18 -0
- package/skills/aria-cognition/nadia/SKILL.md +18 -0
- package/skills/aria-cognition/nadia-psi/SKILL.md +18 -0
- package/skills/aria-cognition/predictor/SKILL.md +18 -0
- package/skills/aria-cognition/qiyas-analogy/SKILL.md +18 -0
- package/skills/aria-cognition/soul-domains/SKILL.md +18 -0
- package/src/auth.ts +136 -1
- package/src/chat.ts +13 -8
- package/src/config.ts +6 -1
- package/src/connectors/claude-code.ts +62 -18
- package/src/connectors/codex.ts +308 -10
- package/src/connectors/opencode.ts +35 -12
- package/src/connectors/repo-guard.ts +117 -172
- package/src/connectors/runtime.ts +19 -7
- package/src/connectors/shell.ts +12 -8
- package/src/harness-client.ts +8 -22
- package/src/model-context.ts +6 -0
- package/src/providers/types.ts +1 -1
- package/src/providers/xai.ts +55 -0
- package/src/setup-wizard.ts +1 -0
- package/src/types.ts +2 -0
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
// ARIA_ALLOW_STUB: this gate helper must match doctrine trigger words as data.
|
|
2
|
+
const POST = /\b(?:post[_ -]?compact[_ -]?continuation|handoff[_ -]?resume|continuation[_ -]?handoff|post-compact|compact(?:ion)? handoff|post\s+commission)\b/i;
|
|
3
|
+
const OFF = /\bGATEOFF\b/i;
|
|
4
|
+
const SKILL_CONTENT_RX = /<skill_content\s+name=["']([^"']+)["']/gi;
|
|
5
|
+
const DEPLOY_VERIFY_RX = /<verify>[\s\S]*?target\s*:[\s\S]*?role\s*:[\s\S]*?verified\s*:[\s\S]*?rollback\s*:[\s\S]*?axiom\s*:[\s\S]*?<\/verify>/i;
|
|
6
|
+
const COGNITION_BLOCK_RX = /<cognition>[\s\S]*?nur\s*:[\s\S]*?mizan\s*:[\s\S]*?hikma\s*:[\s\S]*?tafakkur\s*:[\s\S]*?tadabbur\s*:[\s\S]*?ilham\s*:[\s\S]*?wahi\s*:[\s\S]*?firasah\s*:[\s\S]*?<\/cognition>/i;
|
|
7
|
+
const EXPECTED_BLOCK_RX = /<expected>[\s\S]*?predicate\s*:[\s\S]*?measurable_type\s*:[\s\S]*?<\/expected>/i;
|
|
8
|
+
const APPLIED_COGNITION_RX = /<applied_cognition>[\s\S]*?decision_delta\s*:[\s\S]*?dominant_domain\s*:[\s\S]*?binds_to\s*:[\s\S]*?expected_predicate\s*:[\s\S]*?artifact_change\s*:[\s\S]*?<\/applied_cognition>/i;
|
|
9
|
+
const NO_STRIPPING_BLOCK_RX = /<no_stripping>[\s\S]*?preserved_contract\s*:[\s\S]*?root_mechanism\s*:[\s\S]*?removed_surface\s*:\s*none[\s\S]*?verification\s*:[\s\S]*?<\/no_stripping>/i;
|
|
10
|
+
|
|
11
|
+
function bypass(text) {
|
|
12
|
+
return /^(?:1|true|yes|on)$/i.test(String(process.env.ARIA_GATES_OFF || process.env.ARIA_HARNESS_GATES_OFF || '')) || POST.test(String(text || '')) || OFF.test(String(text || ''));
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function addSkill(set, skill) {
|
|
16
|
+
const normalized = String(skill || '').trim();
|
|
17
|
+
if (normalized) set.add(normalized);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function collectLoadedSkills(options = {}, body = '') {
|
|
21
|
+
const loaded = new Set();
|
|
22
|
+
for (const m of String(body || '').matchAll(SKILL_CONTENT_RX)) addSkill(loaded, m[1]);
|
|
23
|
+
for (const skill of Array.isArray(options.loadedSkills) ? options.loadedSkills : []) addSkill(loaded, skill);
|
|
24
|
+
return loaded;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function collectContractEvidence(options = {}, body = '') {
|
|
28
|
+
const evidence = new Set();
|
|
29
|
+
if (DEPLOY_VERIFY_RX.test(body) && COGNITION_BLOCK_RX.test(body) && EXPECTED_BLOCK_RX.test(body)) {
|
|
30
|
+
evidence.add('aria-harness-deploy');
|
|
31
|
+
evidence.add('aria-forge-guardrails');
|
|
32
|
+
evidence.add('aria-harness-output-discipline');
|
|
33
|
+
}
|
|
34
|
+
if (APPLIED_COGNITION_RX.test(body)) evidence.add('aria-forge-guardrails');
|
|
35
|
+
if (NO_STRIPPING_BLOCK_RX.test(body)) evidence.add('aria-harness-no-stripping');
|
|
36
|
+
if (options.repoDoctrineVerified === true) evidence.add('aria-repo-doctrine');
|
|
37
|
+
if (options.noStrippingVerified === true) evidence.add('aria-harness-no-stripping');
|
|
38
|
+
if (options.outputDisciplineVerified === true) evidence.add('aria-harness-output-discipline');
|
|
39
|
+
return evidence;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function recordSkillLoaded({ skill } = {}) {
|
|
43
|
+
return { skill, recordedAt: new Date().toISOString() };
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function classifyRequiredSkills({ text = '', action = '', toolName = '', filePath = '', isDeploy = false, isMutation = false, isOutputCloseout = false } = {}) {
|
|
47
|
+
const c = [text, action, toolName, filePath].filter(Boolean).join('\n');
|
|
48
|
+
const required = new Set();
|
|
49
|
+
const reasons = [];
|
|
50
|
+
const recoveryMissing = [];
|
|
51
|
+
let redirectOnly = false;
|
|
52
|
+
if (bypass(c)) return { requiredSkills: [], recoveryMissing: [], reasons: ['post-compaction or emergency gate-off bypasses skill autoload classification'] };
|
|
53
|
+
if (isDeploy || /deploy-service\.sh|kubectl\s+(?:apply|set|rollout|delete|scale)|helm\s+upgrade|terraform\s+apply|docker\s+push/i.test(c)) {
|
|
54
|
+
required.add('aria-harness-deploy');
|
|
55
|
+
required.add('aria-forge-guardrails');
|
|
56
|
+
reasons.push('deploy/shared-infrastructure action requires fail-closed deploy and forge guardrails');
|
|
57
|
+
}
|
|
58
|
+
if (isMutation || /^(?:edit|write|notebookedit|patch|apply_patch)$/i.test(toolName)) {
|
|
59
|
+
required.add('aria-repo-doctrine');
|
|
60
|
+
reasons.push('repository/runtime mutation requires repo doctrine');
|
|
61
|
+
}
|
|
62
|
+
if (/remove|delete|strip|drop|omit|disable|bypass|skip|stub|mock|fake|placeholder|temporary|quick scaffold|band-aid/i.test(c)) {
|
|
63
|
+
required.add('aria-harness-no-stripping');
|
|
64
|
+
required.add('aria-forge-guardrails');
|
|
65
|
+
reasons.push('contract-reduction language requires no-stripping and forge guardrails');
|
|
66
|
+
}
|
|
67
|
+
if (isOutputCloseout && /done|complete|completed|ready|verified|fixed|shipped|implemented|production-ready/i.test(c)) {
|
|
68
|
+
required.add('aria-harness-output-discipline');
|
|
69
|
+
reasons.push('owner-facing completion/readiness claim requires output discipline');
|
|
70
|
+
if (!/(verified|passed|success|successful|green|ok|exit\s*0)/i.test(c)) recoveryMissing.push('successful proof from a concrete command/probe');
|
|
71
|
+
}
|
|
72
|
+
if (/production-ready|ready for production|first[- ]class|works in general|general readiness|client packages?|npm packages?|SDKs?|runtimes?|harnesses?|release-ready|ship-ready/i.test(c)) {
|
|
73
|
+
redirectOnly = true;
|
|
74
|
+
reasons.push('broad readiness language requires recovery guidance instead of a permanent skill block');
|
|
75
|
+
}
|
|
76
|
+
if (/done|complete|completed|ready|verified|fixed|shipped|implemented|production-ready/i.test(c) && /but|except|caveat|remaining|not yet|still|separate|later|blocked|skipped|unresolved|follow-up|failed|failing|error|\bred\b|not run|could not verify|untested|no proof|missing proof|without proof/i.test(c)) {
|
|
77
|
+
required.add('aria-harness-output-discipline');
|
|
78
|
+
required.add('aria-forge-guardrails');
|
|
79
|
+
redirectOnly = true;
|
|
80
|
+
reasons.push('completion claim with explicit unresolved state requires recovery guidance');
|
|
81
|
+
}
|
|
82
|
+
if (/non-blocking|warning only|warn only|advisory|fall through|falls through|fail open|soft fail|logged and continue|quality gate warning/i.test(c)) {
|
|
83
|
+
required.add('aria-forge-guardrails');
|
|
84
|
+
reasons.push('advisory/fail-open gate language requires fail-closed hardening discipline');
|
|
85
|
+
}
|
|
86
|
+
return { requiredSkills: [...required].sort(), recoveryMissing: [...new Set(recoveryMissing)], reasons, redirectOnly };
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export function evaluateSkillGate(options = {}) {
|
|
90
|
+
const c = classifyRequiredSkills(options);
|
|
91
|
+
const body = [options.text, options.action].filter(Boolean).join('\n');
|
|
92
|
+
const loaded = collectLoadedSkills(options, body);
|
|
93
|
+
const contractEvidence = collectContractEvidence(options, body);
|
|
94
|
+
const satisfied = new Set([...loaded, ...contractEvidence]);
|
|
95
|
+
const missingSkills = c.requiredSkills.filter((skill) => !satisfied.has(skill));
|
|
96
|
+
const recoveryMissing = contractEvidence.has('aria-harness-deploy') && contractEvidence.has('aria-forge-guardrails') ? [] : c.recoveryMissing;
|
|
97
|
+
return { ok: c.redirectOnly === true || (missingSkills.length === 0 && recoveryMissing.length === 0), redirectOnly: c.redirectOnly === true, surface: options.surface || 'unknown', sessionId: options.sessionId || 'unknown', requiredSkills: c.requiredSkills, loadedSkills: [...loaded].sort(), contractEvidence: [...contractEvidence].sort(), missingSkills, recoveryMissing, reasons: c.reasons, autoLoadAvailable: options.autoLoadAvailable === true };
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export function formatSkillGateBlock(result = {}) {
|
|
101
|
+
const m = result.missingSkills || [], r = result.recoveryMissing || [], reasons = result.reasons || [];
|
|
102
|
+
return ['=== ARIA SKILL AUTOLOAD GATE BLOCK ===', `surface: ${result.surface || 'unknown'}`, `missing_skills: ${m.length ? m.join(', ') : '(none)'}`, `missing_recovery_cycle: ${r.length ? r.join(', ') : '(none)'}`, `required_skills: ${(result.requiredSkills || []).join(', ') || '(none)'}`, reasons.length ? `reasons: ${reasons.join(' | ')}` : 'reasons: no classifier reason recorded', 'Recovery contract:', '1. Do not retry the same blocked text.', `2. Load missing skills first: ${m.length ? m.join(', ') : '(none)'}`, `3. Repair missing recovery cycle items: ${r.length ? r.join(', ') : '(none)'}`, '4. Re-write with concrete proof and an applied_cognition block:', '<applied_cognition>', 'decision_delta: <what changed after the block>', 'dominant_domain: <deploy|code|security|testing|ops|product|writing>', 'binds_to: <specific file, command, endpoint, or user instruction>', 'expected_predicate: <measurable condition such as exit=0, status=healthy, count=N>', 'artifact_change: <exact artifact changed or none>', '</applied_cognition>', '5. Re-test using the concrete command/probe named in the block.', '6. Re-submit only after the proof exists; if blocked twice, escalate through ARIA console/MCP with this full block.'].join('\n');
|
|
103
|
+
}
|
|
@@ -1,14 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { join } from 'node:path';
|
|
3
|
-
import { tmpdir } from 'node:os';
|
|
4
|
-
const RECEIPT_ROOT = process.env.ARIA_SKILL_RECEIPT_DIR || join(tmpdir(), 'aria-skill-receipts');
|
|
5
|
-
const ALIASES = new Map([['deploy', 'aria-harness-deploy'], ['output', 'aria-harness-output-discipline'], ['repo', 'aria-repo-doctrine'], ['forge', 'aria-forge-guardrails']]);
|
|
6
|
-
const RX = { deploy: /deploy-service\.sh|kubectl\s+(?:apply|set|rollout|delete|scale)|helm\s+upgrade|terraform\s+apply|docker\s+push/i, mutationTool: /^(?:edit|write|notebookedit|patch|apply_patch)$/i, mutation: /apply_patch|write file|edit file|modify|delete file|migration|handler|route|runtime|hook|plugin|\btest\b|smoke script/i, strip: /remove|delete|strip|drop|omit|disable|bypass|skip|stub|mock|fake|placeholder|temporary|quick scaffold|band-aid/i, readiness: /production-ready|ready for production|works in general|general readiness|client packages?|npm packages?|SDKs?|runtimes?|harnesses?|release-ready|ship-ready/i, narrow: /single flow|one flow|narrow e2e|covered flow|specific path|widget flow/i, completion: /done|complete|completed|ready|verified|fixed|shipped|implemented|production-ready/i, badProof: /but|except|caveat|remaining|not yet|still|separate|later|blocked|skipped|unresolved|follow-up|failed|failing|error|red|not run|could not verify|untested|no proof|missing proof|without proof/i, advisory: /non-blocking|warning only|warn only|advisory|fall through|falls through|fail open|soft fail|logged and continue|quality gate warning/i, success: /(?:verified|passed|success|successful|green|ok)\s*[:=\-].{0,120}(?:npm|node|playwright|jest|vitest|build|test|lint|typecheck|curl|kubectl|self-test|e2e|probe|smoke)|(?:npm|node|playwright|jest|vitest|build|test|lint|typecheck|curl|kubectl).{0,120}(?:passed|success|successful|green|exit\s*0)/i, resubmit: /re-?submission|resubmit/i, rewrite: /re-?write|rewrite|fix/i, retest: /re-?test|retest|rerun/i, aria: /ARIA console|Aria console|\/chat|aria-pipeline-mcp|aria_chat|escalat(?:e|ion).{0,80}ARIA/i };
|
|
7
|
-
function normalizeSkillName(skill) { return ALIASES.get(String(skill || '').trim()) || String(skill || '').trim(); }
|
|
8
|
-
function sessionDir(sessionId) { return join(RECEIPT_ROOT, encodeURIComponent(String(sessionId || 'unknown'))); }
|
|
9
|
-
function readReceiptSkills(sessionId) { const dir = sessionDir(sessionId); if (!existsSync(dir)) return new Set(); const skills = new Set(); for (const name of readdirSync(dir)) { if (!name.endsWith('.json')) continue; try { const receipt = JSON.parse(readFileSync(join(dir, name), 'utf8')); if (receipt?.skill) skills.add(normalizeSkillName(receipt.skill)); } catch {} } return skills; }
|
|
10
|
-
function readInlineSkills(text) { const skills = new Set(); const value = String(text || ''); for (const match of value.matchAll(/<skill_content\s+name=["']([^"']+)["']/gi)) skills.add(normalizeSkillName(match[1])); return skills; }
|
|
11
|
-
export function recordSkillLoaded({ sessionId, skill, surface = 'unknown', metadata = {} } = {}) { const normalized = normalizeSkillName(skill); if (!normalized) throw new Error('recordSkillLoaded requires a skill name'); const dir = sessionDir(sessionId); mkdirSync(dir, { recursive: true }); const receipt = { skill: normalized, surface, metadata, recordedAt: new Date().toISOString() }; writeFileSync(join(dir, `${encodeURIComponent(normalized)}.json`), `${JSON.stringify(receipt, null, 2)}\n`); return receipt; }
|
|
12
|
-
export function classifyRequiredSkills({ text = '', action = '', toolName = '', filePath = '', isDeploy = false, isMutation = false, isOutputCloseout = false } = {}) { const combined = [text, action, toolName, filePath].filter(Boolean).join('\n'); const required = new Set(); const reasons = []; const recoveryMissing = []; if (isDeploy || RX.deploy.test(combined)) { required.add('aria-harness-deploy'); required.add('aria-forge-guardrails'); reasons.push('deploy/shared-infrastructure action requires fail-closed deploy and forge guardrails'); } if (isMutation || RX.mutationTool.test(toolName)) { required.add('aria-repo-doctrine'); reasons.push('repository/runtime mutation requires repo doctrine'); } if (RX.strip.test(combined)) { required.add('aria-harness-no-stripping'); reasons.push('strip/remove/bypass language requires no-stripping gate'); } if (isOutputCloseout && RX.completion.test(combined)) { required.add('aria-harness-output-discipline'); reasons.push('owner-facing completion/readiness claim requires output discipline'); if (!RX.success.test(combined)) recoveryMissing.push('successful proof from a concrete command/probe'); } if (RX.readiness.test(combined)) { required.add('architecture-decision'); required.add('testing-strategy'); required.add('aria-forge-guardrails'); required.add('aria-harness-output-discipline'); reasons.push('broad production/package/SDK/runtime readiness claim requires architecture, testing, and forge guardrails'); } if (RX.readiness.test(combined) && RX.narrow.test(combined)) { required.add('testing-strategy'); required.add('aria-forge-guardrails'); reasons.push('narrow e2e proof cannot support broad readiness claim without readiness-matrix discipline'); } if (RX.completion.test(combined) && RX.badProof.test(combined)) { required.add('aria-harness-output-discipline'); required.add('aria-forge-guardrails'); reasons.push('completion claim with unresolved or failed proof requires recovery cycle'); if (!RX.resubmit.test(combined)) recoveryMissing.push('re-submission'); if (!RX.rewrite.test(combined)) recoveryMissing.push('re-write'); if (!RX.retest.test(combined)) recoveryMissing.push('re-test'); if (!RX.aria.test(combined)) recoveryMissing.push('ARIA console escalation'); } if (RX.advisory.test(combined)) { required.add('aria-forge-guardrails'); required.add('aria-harness-output-discipline'); reasons.push('advisory/fail-open gate language requires fail-closed hardening discipline'); } return { requiredSkills: [...required].sort(), reasons, recoveryMissing }; }
|
|
13
|
-
export function evaluateSkillGate(options = {}) { const classified = classifyRequiredSkills(options); const text = [options.text, options.action].filter(Boolean).join('\n'); const loaded = new Set([...readReceiptSkills(options.sessionId), ...readInlineSkills(text)]); const missingSkills = classified.requiredSkills.filter((skill) => !loaded.has(skill)); const recoveryMissing = classified.recoveryMissing || []; return { ok: missingSkills.length === 0 && recoveryMissing.length === 0, surface: options.surface || 'unknown', sessionId: options.sessionId || 'unknown', requiredSkills: classified.requiredSkills, loadedSkills: [...loaded].sort(), missingSkills, recoveryMissing, reasons: classified.reasons, autoLoadAvailable: options.autoLoadAvailable === true }; }
|
|
14
|
-
export function formatSkillGateBlock(result = {}) { const missing = Array.isArray(result.missingSkills) ? result.missingSkills : []; const recovery = Array.isArray(result.recoveryMissing) ? result.recoveryMissing : []; const reasons = Array.isArray(result.reasons) ? result.reasons : []; return ['=== ARIA SKILL AUTOLOAD GATE BLOCK ===', `surface: ${result.surface || 'unknown'}`, `missing_skills: ${missing.length ? missing.join(', ') : '(none)'}`, `missing_recovery_cycle: ${recovery.length ? recovery.join(', ') : '(none)'}`, `required_skills: ${(result.requiredSkills || []).join(', ') || '(none)'}`, reasons.length ? `reasons: ${reasons.join(' | ')}` : 'reasons: no classifier reason recorded', 'counter_action: re-submit, re-write, re-test, and escalate through ARIA console until successful proof exists. Do not downgrade this to an advisory warning.'].join('\n'); }
|
|
1
|
+
export * from './skill-autoload-gate-impl.mjs';
|
|
@@ -622,6 +622,7 @@ export function buildRuntimeCognitionDirective(packet, bundle = {}) {
|
|
|
622
622
|
'- For any non-trivial reply, include a readable <cognition> block using everyday labels, not internal lens codenames.',
|
|
623
623
|
'- If you request any non-trivial tool call, place the <cognition> block BEFORE the tool request.',
|
|
624
624
|
'- If the action is deploy, destructive, or state-mutating, include both <verify> and <expected> blocks before the tool request.',
|
|
625
|
+
'- For any non-trivial reply, also include <applied_cognition> so the runtime can verify that cognition changed the response.',
|
|
625
626
|
'- The runtime will canonicalize the readable block into backend JSON automatically, so do not hide it behind private shorthand.',
|
|
626
627
|
'',
|
|
627
628
|
'<cognition>',
|
|
@@ -635,6 +636,13 @@ export function buildRuntimeCognitionDirective(packet, bundle = {}) {
|
|
|
635
636
|
' beauty: <what cleaner, more elegant, more durable path preserves the contract>',
|
|
636
637
|
` first_principle: ${firstPrincipleText}`,
|
|
637
638
|
'</cognition>',
|
|
639
|
+
'<applied_cognition>',
|
|
640
|
+
' decision_delta: <specific change this cognition made to the answer>',
|
|
641
|
+
' dominant_domain: <primary domain pressure shaping the response>',
|
|
642
|
+
' binds_to: <one visible substrate, evidence, axiom, or user constraint>',
|
|
643
|
+
' expected_predicate: <observable predicate that would prove the answer held up>',
|
|
644
|
+
' artifact_change: <what changed in the emitted answer because of cognition>',
|
|
645
|
+
'</applied_cognition>',
|
|
638
646
|
'',
|
|
639
647
|
dominantModules.length ? 'Current module insights:' : 'Current module insights: none yet',
|
|
640
648
|
...dominantModules.map((line) => `- ${line}`),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
|
-
"bundledAt": "2026-05-
|
|
3
|
-
"sdkFiles":
|
|
2
|
+
"bundledAt": "2026-05-04T03:02:47.930Z",
|
|
3
|
+
"sdkFiles": 12,
|
|
4
4
|
"runtimeTemplate": "/home/hamzaibrahim1/rei-ai-brain/packages/aria-connector/runtime-src",
|
|
5
5
|
"gateRuntimeSource": "/home/hamzaibrahim1/rei-ai-brain/packages/aria-gate-runtime/dist",
|
|
6
6
|
"sdkGuideSource": "/home/hamzaibrahim1/rei-ai-brain/harness/packages/harness-http-client/CLAUDE.md",
|
|
@@ -7,6 +7,7 @@ import { join } from 'node:path';
|
|
|
7
7
|
const CONFIG_PATH = join(homedir(), '.aria', 'config.json');
|
|
8
8
|
const DEFAULT_OLLAMA_BASE_URL = process.env.OLLAMA_BASE_URL || 'http://127.0.0.1:11434';
|
|
9
9
|
const DEFAULT_DEEPSEEK_BASE_URL = process.env.DEEPSEEK_API_BASE || 'https://api.deepseek.com/v1/chat/completions';
|
|
10
|
+
const DEFAULT_XAI_BASE_URL = process.env.XAI_API_BASE || 'https://api.x.ai/v1/chat/completions';
|
|
10
11
|
const DEFAULT_OLLAMA_MODEL =
|
|
11
12
|
process.env.ARIA_RUNTIME_MODEL ||
|
|
12
13
|
process.env.ARIA_LOCAL_MODEL ||
|
|
@@ -15,18 +16,32 @@ const DEFAULT_OLLAMA_MODEL =
|
|
|
15
16
|
const DEFAULT_CHAT_MODEL =
|
|
16
17
|
process.env.ARIA_CHAT_MODEL ||
|
|
17
18
|
process.env.ARIA_CASUAL_MODEL ||
|
|
18
|
-
|
|
19
|
+
process.env.ARIA_XAI_MODEL ||
|
|
20
|
+
process.env.GROK_MODEL ||
|
|
21
|
+
'grok-4-3';
|
|
19
22
|
const DEFAULT_DEEP_MODEL =
|
|
20
23
|
process.env.ARIA_DEEP_MODEL ||
|
|
24
|
+
process.env.ARIA_DEEPSEEK_FALLBACK_MODEL ||
|
|
21
25
|
'deepseek-v4-pro';
|
|
22
|
-
const DEFAULT_XAI_BASE_URL = process.env.XAI_API_BASE || 'https://api.x.ai/v1/chat/completions';
|
|
23
26
|
const DEFAULT_XAI_FALLBACK_MODEL =
|
|
24
27
|
process.env.ARIA_XAI_FALLBACK_MODEL ||
|
|
25
|
-
|
|
28
|
+
DEFAULT_CHAT_MODEL;
|
|
26
29
|
const DEFAULT_NIM_BASE_URL = process.env.NIM_BASE_URL || 'https://integrate.api.nvidia.com/v1/chat/completions';
|
|
27
30
|
const DEFAULT_NIM_FALLBACK_MODEL =
|
|
28
31
|
process.env.ARIA_NIM_FALLBACK_MODEL ||
|
|
29
32
|
'qwen/qwen3.5-122b-a10b';
|
|
33
|
+
const LOCAL_VIRTUAL_MAC_PROVIDER = 'aria-local-virtual-mac-lane';
|
|
34
|
+
const DEFAULT_LOCAL_FALLBACK_BASE_URL = normalizeChatCompletionsUrl(
|
|
35
|
+
process.env.ARIA_LOCAL_FALLBACK_BASE_URL ||
|
|
36
|
+
process.env.ARIA_VIRTUAL_MAC_LANE_BASE_URL ||
|
|
37
|
+
process.env.ARIA_LANE_GATEWAY_URL ||
|
|
38
|
+
'http://aria-lane-gateway.aria.svc.cluster.local:8089/v1',
|
|
39
|
+
);
|
|
40
|
+
const DEFAULT_LOCAL_FALLBACK_MODEL =
|
|
41
|
+
process.env.ARIA_LOCAL_FALLBACK_MODEL ||
|
|
42
|
+
process.env.ARIA_VIRTUAL_MAC_LANE_MODEL ||
|
|
43
|
+
process.env.ARIA_LOCAL_MAC_MODEL ||
|
|
44
|
+
'mlx-community/Qwen2.5-7B-Instruct-4bit';
|
|
30
45
|
|
|
31
46
|
function safeJsonParse(raw, fallback = null) {
|
|
32
47
|
try {
|
|
@@ -45,6 +60,36 @@ function coerceString(value) {
|
|
|
45
60
|
return typeof value === 'string' && value.trim() ? value.trim() : '';
|
|
46
61
|
}
|
|
47
62
|
|
|
63
|
+
function secretEnv(...names) {
|
|
64
|
+
for (const name of names) {
|
|
65
|
+
const value = coerceString(process.env[name]);
|
|
66
|
+
if (value) return value;
|
|
67
|
+
}
|
|
68
|
+
return '';
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function normalizeChatCompletionsUrl(value) {
|
|
72
|
+
const trimmed = coerceString(value).replace(/\/+$/, '');
|
|
73
|
+
if (!trimmed) return '';
|
|
74
|
+
return trimmed.endsWith('/chat/completions') ? trimmed : `${trimmed}/chat/completions`;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function isLocalVirtualMacProvider(provider) {
|
|
78
|
+
return provider === LOCAL_VIRTUAL_MAC_PROVIDER || provider === 'local-virtual-mac-lane' || provider === 'qwen-mac-lane';
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function xaiApiModel(model) {
|
|
82
|
+
return model === 'grok-4-3' ? 'grok-4.3' : model;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function isAnthropicClientModel(model) {
|
|
86
|
+
return /^claude(?:-|$)/i.test(coerceString(model)) || /^anthropic\//i.test(coerceString(model));
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function providerRequiresApiKey(provider) {
|
|
90
|
+
return provider !== 'ollama' && !isLocalVirtualMacProvider(provider);
|
|
91
|
+
}
|
|
92
|
+
|
|
48
93
|
function loadRuntimeProfiles(local) {
|
|
49
94
|
const profiles = local?.runtimeProfiles && typeof local.runtimeProfiles === 'object' ? local.runtimeProfiles : {};
|
|
50
95
|
return {
|
|
@@ -53,9 +98,14 @@ function loadRuntimeProfiles(local) {
|
|
|
53
98
|
xaiFallbackModel: coerceString(profiles.xaiFallbackModel || local?.xaiFallbackModel || local?.model?.xaiFallbackModel) || DEFAULT_XAI_FALLBACK_MODEL,
|
|
54
99
|
nimFallbackModel: coerceString(profiles.nimFallbackModel || local?.nimFallbackModel || local?.model?.nimFallbackModel) || DEFAULT_NIM_FALLBACK_MODEL,
|
|
55
100
|
xaiApiKey: coerceString(profiles.xaiApiKey || local?.xaiApiKey),
|
|
101
|
+
deepseekApiKey: coerceString(profiles.deepseekApiKey || local?.deepseekApiKey),
|
|
56
102
|
nimApiKey: coerceString(profiles.nimApiKey || local?.nimApiKey),
|
|
57
103
|
xaiBaseUrl: coerceString(profiles.xaiBaseUrl || local?.xaiBaseUrl) || DEFAULT_XAI_BASE_URL,
|
|
104
|
+
deepseekBaseUrl: coerceString(profiles.deepseekBaseUrl || local?.deepseekBaseUrl) || DEFAULT_DEEPSEEK_BASE_URL,
|
|
58
105
|
nimBaseUrl: coerceString(profiles.nimBaseUrl || local?.nimBaseUrl) || DEFAULT_NIM_BASE_URL,
|
|
106
|
+
localFallbackModel: coerceString(profiles.localFallbackModel || local?.localFallbackModel) || DEFAULT_LOCAL_FALLBACK_MODEL,
|
|
107
|
+
localFallbackBaseUrl: normalizeChatCompletionsUrl(profiles.localFallbackBaseUrl || local?.localFallbackBaseUrl) || DEFAULT_LOCAL_FALLBACK_BASE_URL,
|
|
108
|
+
localFallbackApiKey: coerceString(profiles.localFallbackApiKey || local?.localFallbackApiKey),
|
|
59
109
|
};
|
|
60
110
|
}
|
|
61
111
|
|
|
@@ -104,7 +154,11 @@ function resolveProviderApiKey(provider, overrideApiKey = '', localApiKey = '')
|
|
|
104
154
|
case 'openrouter':
|
|
105
155
|
return process.env.OPENROUTER_API_KEY || '';
|
|
106
156
|
case 'xai':
|
|
107
|
-
return process.env.XAI_API_KEY || '';
|
|
157
|
+
return process.env.XAI_API_KEY || process.env.GROK_API_KEY || process.env.ARIA_XAI_KEY || '';
|
|
158
|
+
case LOCAL_VIRTUAL_MAC_PROVIDER:
|
|
159
|
+
case 'local-virtual-mac-lane':
|
|
160
|
+
case 'qwen-mac-lane':
|
|
161
|
+
return process.env.ARIA_LOCAL_FALLBACK_API_KEY || process.env.ARIA_LANE_GATEWAY_API_KEY || '';
|
|
108
162
|
case 'nim':
|
|
109
163
|
case 'nvidia-nim':
|
|
110
164
|
return process.env.NVIDIA_NIM_API_KEY || process.env.NIM_API_KEY || '';
|
|
@@ -116,16 +170,30 @@ function resolveProviderApiKey(provider, overrideApiKey = '', localApiKey = '')
|
|
|
116
170
|
function resolveDefaultModel(provider, body, localModel, runtimeProfiles) {
|
|
117
171
|
const explicitModel = coerceString(body?.llm?.model || body?.providerConfig?.model || body?.model);
|
|
118
172
|
if (explicitModel) return explicitModel;
|
|
119
|
-
if (provider === 'deepseek')
|
|
120
|
-
|
|
121
|
-
}
|
|
122
|
-
if (provider === 'xai') return runtimeProfiles.xaiFallbackModel;
|
|
173
|
+
if (provider === 'deepseek') return runtimeProfiles.deepModel;
|
|
174
|
+
if (provider === 'xai') return runtimeProfiles.chatModel || runtimeProfiles.xaiFallbackModel;
|
|
123
175
|
if (provider === 'nim' || provider === 'nvidia-nim') return runtimeProfiles.nimFallbackModel;
|
|
124
|
-
if (
|
|
176
|
+
if (isLocalVirtualMacProvider(provider)) return runtimeProfiles.localFallbackModel;
|
|
177
|
+
if (localModel?.provider === provider && coerceString(localModel?.model)) return coerceString(localModel.model);
|
|
125
178
|
if (provider === 'ollama') return DEFAULT_OLLAMA_MODEL;
|
|
126
179
|
return '';
|
|
127
180
|
}
|
|
128
181
|
|
|
182
|
+
function resolveProviderNativeModel(provider, body, localModel, runtimeProfiles, fallbackModel = '') {
|
|
183
|
+
const overrideModel = coerceString(body?.llm?.model || body?.providerConfig?.model);
|
|
184
|
+
const clientModel = coerceString(body?.model);
|
|
185
|
+
if (overrideModel && (!clientModel || overrideModel !== clientModel || !isAnthropicClientModel(overrideModel))) {
|
|
186
|
+
return overrideModel;
|
|
187
|
+
}
|
|
188
|
+
if (localModel?.provider === provider && coerceString(localModel?.model)) return coerceString(localModel.model);
|
|
189
|
+
if (provider === 'deepseek') return runtimeProfiles.deepModel;
|
|
190
|
+
if (provider === 'xai') return runtimeProfiles.chatModel || runtimeProfiles.xaiFallbackModel;
|
|
191
|
+
if (provider === 'nim' || provider === 'nvidia-nim') return runtimeProfiles.nimFallbackModel;
|
|
192
|
+
if (isLocalVirtualMacProvider(provider)) return runtimeProfiles.localFallbackModel;
|
|
193
|
+
if (provider === 'ollama') return DEFAULT_OLLAMA_MODEL;
|
|
194
|
+
return isAnthropicClientModel(fallbackModel) ? '' : coerceString(fallbackModel);
|
|
195
|
+
}
|
|
196
|
+
|
|
129
197
|
function buildFallbackChain(body, runtimeProfiles) {
|
|
130
198
|
if (body.allowProviderFallback === false) return [];
|
|
131
199
|
const explicitFallbacks = Array.isArray(body?.llm?.fallbacks)
|
|
@@ -136,24 +204,24 @@ function buildFallbackChain(body, runtimeProfiles) {
|
|
|
136
204
|
if (explicitFallbacks.length > 0) return explicitFallbacks;
|
|
137
205
|
return [
|
|
138
206
|
{
|
|
139
|
-
provider: '
|
|
140
|
-
model: runtimeProfiles.
|
|
141
|
-
baseUrl: runtimeProfiles.
|
|
142
|
-
apiKey: runtimeProfiles.
|
|
143
|
-
reason: '
|
|
207
|
+
provider: 'deepseek',
|
|
208
|
+
model: runtimeProfiles.deepModel,
|
|
209
|
+
baseUrl: runtimeProfiles.deepseekBaseUrl,
|
|
210
|
+
apiKey: runtimeProfiles.deepseekApiKey || secretEnv('DEEPSEEK_API_KEY', 'ARIA_DEEPSEEK_API_KEY'),
|
|
211
|
+
reason: 'deepseek-v4-pro fallback',
|
|
144
212
|
},
|
|
145
213
|
{
|
|
146
|
-
provider:
|
|
147
|
-
model: runtimeProfiles.
|
|
148
|
-
baseUrl: runtimeProfiles.
|
|
149
|
-
apiKey: runtimeProfiles.
|
|
150
|
-
reason: '
|
|
214
|
+
provider: LOCAL_VIRTUAL_MAC_PROVIDER,
|
|
215
|
+
model: runtimeProfiles.localFallbackModel,
|
|
216
|
+
baseUrl: runtimeProfiles.localFallbackBaseUrl,
|
|
217
|
+
apiKey: runtimeProfiles.localFallbackApiKey || secretEnv('ARIA_LOCAL_FALLBACK_API_KEY', 'ARIA_LANE_GATEWAY_API_KEY'),
|
|
218
|
+
reason: 'aria local virtual mac lane fallback',
|
|
151
219
|
},
|
|
152
|
-
].filter((entry) => entry.
|
|
220
|
+
].filter((entry) => entry.model && (!providerRequiresApiKey(entry.provider) || entry.apiKey));
|
|
153
221
|
}
|
|
154
222
|
|
|
155
223
|
async function callResolvedProvider(config, body, ariaSystemPrompt) {
|
|
156
|
-
const model =
|
|
224
|
+
const model = config.model || body.model || 'gpt-4o';
|
|
157
225
|
const messages = composeOpenAIMessages(Array.isArray(body.messages) ? body.messages : [], ariaSystemPrompt);
|
|
158
226
|
const maxTokens = Number(body.max_tokens || body.max_completion_tokens || 4096);
|
|
159
227
|
|
|
@@ -235,16 +303,28 @@ async function callResolvedProvider(config, body, ariaSystemPrompt) {
|
|
|
235
303
|
xai: config.baseUrl || DEFAULT_XAI_BASE_URL,
|
|
236
304
|
nim: config.baseUrl || DEFAULT_NIM_BASE_URL,
|
|
237
305
|
'nvidia-nim': config.baseUrl || DEFAULT_NIM_BASE_URL,
|
|
306
|
+
[LOCAL_VIRTUAL_MAC_PROVIDER]: config.baseUrl || DEFAULT_LOCAL_FALLBACK_BASE_URL,
|
|
307
|
+
'local-virtual-mac-lane': config.baseUrl || DEFAULT_LOCAL_FALLBACK_BASE_URL,
|
|
308
|
+
'qwen-mac-lane': config.baseUrl || DEFAULT_LOCAL_FALLBACK_BASE_URL,
|
|
238
309
|
};
|
|
239
310
|
const providerUrl = urlByProvider[config.provider] || urlByProvider.openai;
|
|
311
|
+
const providerModel = config.provider === 'xai' ? xaiApiModel(model) : model;
|
|
240
312
|
const extraHeaders = config.provider === 'openrouter'
|
|
241
313
|
? {
|
|
242
314
|
'HTTP-Referer': 'http://127.0.0.1',
|
|
243
315
|
'X-Title': 'Aria Mounted Runtime',
|
|
244
316
|
}
|
|
317
|
+
: isLocalVirtualMacProvider(config.provider)
|
|
318
|
+
? {
|
|
319
|
+
'X-Aria-Surface': body?.aria_surface || body?.metadata?.surface || 'client_chat',
|
|
320
|
+
'X-Aria-Role-Profile': body?.metadata?.roleProfile || 'interactive_chat',
|
|
321
|
+
'X-Aria-Stage': body?.metadata?.stage || 'fallback',
|
|
322
|
+
'X-Aria-Actor': body?.metadata?.actor || 'aria-smart-cli',
|
|
323
|
+
'X-Aria-System': body?.metadata?.system || 'aria-connector',
|
|
324
|
+
}
|
|
245
325
|
: {};
|
|
246
326
|
const data = await callOpenAICompatible(providerUrl, config.apiKey, {
|
|
247
|
-
model,
|
|
327
|
+
model: providerModel,
|
|
248
328
|
messages,
|
|
249
329
|
max_tokens: maxTokens,
|
|
250
330
|
stream: false,
|
|
@@ -274,25 +354,33 @@ export function resolveProviderConfig(body = {}) {
|
|
|
274
354
|
body.provider ||
|
|
275
355
|
localModel?.provider ||
|
|
276
356
|
coerceString(local?.defaultProvider) ||
|
|
277
|
-
(
|
|
357
|
+
(runtimeProfiles.xaiApiKey || secretEnv('XAI_API_KEY', 'GROK_API_KEY', 'ARIA_XAI_KEY')
|
|
358
|
+
? 'xai'
|
|
359
|
+
: runtimeProfiles.deepseekApiKey || secretEnv('DEEPSEEK_API_KEY', 'ARIA_DEEPSEEK_API_KEY')
|
|
360
|
+
? 'deepseek'
|
|
361
|
+
: 'ollama');
|
|
362
|
+
const localApiKey = localModel?.provider === provider ? coerceString(localModel?.apiKey) : '';
|
|
363
|
+
const localBaseUrl = localModel?.provider === provider ? coerceString(localModel?.baseUrl) : '';
|
|
278
364
|
const merged = {
|
|
279
365
|
provider,
|
|
280
366
|
model: resolveDefaultModel(provider, body, localModel, runtimeProfiles),
|
|
281
367
|
apiKey: resolveProviderApiKey(
|
|
282
368
|
provider,
|
|
283
369
|
coerceString(override?.apiKey || body.providerApiKey),
|
|
284
|
-
|
|
370
|
+
localApiKey,
|
|
285
371
|
),
|
|
286
372
|
baseUrl:
|
|
287
373
|
override?.baseUrl ||
|
|
288
374
|
body.providerBaseUrl ||
|
|
289
|
-
|
|
375
|
+
localBaseUrl ||
|
|
290
376
|
(provider === 'ollama'
|
|
291
377
|
? DEFAULT_OLLAMA_BASE_URL
|
|
292
378
|
: provider === 'deepseek'
|
|
293
|
-
?
|
|
379
|
+
? runtimeProfiles.deepseekBaseUrl
|
|
294
380
|
: provider === 'xai'
|
|
295
|
-
?
|
|
381
|
+
? runtimeProfiles.xaiBaseUrl
|
|
382
|
+
: isLocalVirtualMacProvider(provider)
|
|
383
|
+
? runtimeProfiles.localFallbackBaseUrl
|
|
296
384
|
: provider === 'nim' || provider === 'nvidia-nim'
|
|
297
385
|
? DEFAULT_NIM_BASE_URL
|
|
298
386
|
: ''),
|
|
@@ -302,7 +390,7 @@ export function resolveProviderConfig(body = {}) {
|
|
|
302
390
|
throw new Error('No provider configured. Save one in ~/.aria/config.json or pass llm/providerConfig in the request body.');
|
|
303
391
|
}
|
|
304
392
|
|
|
305
|
-
if (merged.provider
|
|
393
|
+
if (providerRequiresApiKey(merged.provider) && merged.provider !== 'google' && !merged.apiKey) {
|
|
306
394
|
throw new Error(`No API key configured for provider ${merged.provider}. Save one in ~/.aria/config.json or pass llm.apiKey.`);
|
|
307
395
|
}
|
|
308
396
|
|
|
@@ -415,7 +503,7 @@ async function callOpenAICompatible(url, apiKey, payload, extraHeaders = {}) {
|
|
|
415
503
|
method: 'POST',
|
|
416
504
|
headers: {
|
|
417
505
|
'Content-Type': 'application/json',
|
|
418
|
-
Authorization: `Bearer ${apiKey}
|
|
506
|
+
...(apiKey ? { Authorization: `Bearer ${apiKey}` } : {}),
|
|
419
507
|
...extraHeaders,
|
|
420
508
|
},
|
|
421
509
|
body: JSON.stringify(payload),
|
|
@@ -537,8 +625,11 @@ export async function callProviderForOpenAI(body, ariaSystemPrompt) {
|
|
|
537
625
|
}
|
|
538
626
|
|
|
539
627
|
export async function callProviderForAnthropic(body, ariaSystemPrompt) {
|
|
628
|
+
const local = loadLocalConfig();
|
|
629
|
+
const localModel = local?.model && typeof local.model === 'object' ? local.model : null;
|
|
630
|
+
const runtimeProfiles = loadRuntimeProfiles(local);
|
|
540
631
|
const config = resolveProviderConfig(body);
|
|
541
|
-
const model = body.model || config.model || 'claude-sonnet-4-20250514';
|
|
632
|
+
const model = coerceString(body.model) || config.model || 'claude-sonnet-4-20250514';
|
|
542
633
|
const req = composeAnthropicRequest(body, ariaSystemPrompt);
|
|
543
634
|
const maxTokens = Number(body.max_tokens || 4096);
|
|
544
635
|
|
|
@@ -569,13 +660,25 @@ export async function callProviderForAnthropic(body, ariaSystemPrompt) {
|
|
|
569
660
|
content: flattenAnthropicContent(message.content),
|
|
570
661
|
})),
|
|
571
662
|
];
|
|
572
|
-
|
|
663
|
+
const providerModel = resolveProviderNativeModel(config.provider, body, localModel, runtimeProfiles, config.model);
|
|
664
|
+
if (!providerModel) {
|
|
665
|
+
throw new Error(`No native model configured for provider ${config.provider}; refusing to send Anthropic client model ${model} upstream.`);
|
|
666
|
+
}
|
|
667
|
+
const providerMeta = await callProviderForOpenAI({
|
|
573
668
|
...body,
|
|
574
669
|
provider: config.provider,
|
|
575
|
-
model,
|
|
670
|
+
model: providerModel,
|
|
576
671
|
messages: openAiMessages,
|
|
577
|
-
llm:
|
|
672
|
+
llm: {
|
|
673
|
+
...config,
|
|
674
|
+
model: providerModel,
|
|
675
|
+
},
|
|
578
676
|
}, req.system);
|
|
677
|
+
return {
|
|
678
|
+
...providerMeta,
|
|
679
|
+
model,
|
|
680
|
+
upstreamModel: providerMeta.model,
|
|
681
|
+
};
|
|
579
682
|
}
|
|
580
683
|
|
|
581
684
|
export function chunkText(text, maxChunkChars = 120) {
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type HarnessAuthTokenSource = 'explicit' | 'env:ARIA_HARNESS_TOKEN' | 'env:ARIA_API_KEY' | 'env:ARIA_MASTER_TOKEN' | 'persisted-client-token' | 'owner-token-file' | 'license:harnessToken' | 'license:token' | 'missing';
|
|
2
|
+
export interface HarnessAuthResolutionOptions {
|
|
3
|
+
explicitToken?: string | null;
|
|
4
|
+
baseUrl?: string;
|
|
5
|
+
clientId?: string;
|
|
6
|
+
tokenScope?: string;
|
|
7
|
+
persistToken?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface HarnessAuthResolution {
|
|
10
|
+
token: string;
|
|
11
|
+
source: HarnessAuthTokenSource;
|
|
12
|
+
scope: string;
|
|
13
|
+
persisted: boolean;
|
|
14
|
+
tokenPresent: boolean;
|
|
15
|
+
}
|
|
16
|
+
export declare function resolveHarnessAuthToken(options?: HarnessAuthResolutionOptions): HarnessAuthResolution;
|
|
17
|
+
export declare function getHarnessAuthStatus(options?: HarnessAuthResolutionOptions): Omit<HarnessAuthResolution, 'token'>;
|