@aria_asi/cli 0.2.35 → 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 +312 -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 +310 -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
|
@@ -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}`),
|
|
@@ -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) {
|