@oracle-agent/oracle 0.9.8 → 0.10.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/README.md +9 -13
- package/package.json +3 -2
- package/public/oracle-splash/index.html +130 -57
- package/src/auth/oauth.mjs +672 -0
- package/src/cli/commands/auth.mjs +193 -0
- package/src/cli/commands/bootstrap.mjs +2 -2
- package/src/cli/commands/chat.mjs +97 -75
- package/src/cli/commands/model.mjs +79 -23
- package/src/cli/kernel.mjs +4 -3
- package/src/cli/model-config.mjs +70 -0
- package/src/tui/app.mjs +18 -7
- package/src/tui/backend.mjs +145 -0
- package/src/tui/standalone-client.mjs +666 -0
- package/src/cards.mjs +0 -369
- package/src/cli/__pycache__/oracle-harness.cpython-311.pyc +0 -0
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
const PROVIDERS = Object.freeze({
|
|
2
|
+
openrouter: {
|
|
3
|
+
key: "OPENROUTER_API_KEY",
|
|
4
|
+
baseUrl: "https://openrouter.ai/api/v1",
|
|
5
|
+
model: "openrouter/auto",
|
|
6
|
+
},
|
|
7
|
+
openai: {
|
|
8
|
+
key: "OPENAI_API_KEY",
|
|
9
|
+
baseUrl: "https://api.openai.com/v1",
|
|
10
|
+
model: "gpt-4.1-mini",
|
|
11
|
+
},
|
|
12
|
+
xai: {
|
|
13
|
+
key: "XAI_API_KEY",
|
|
14
|
+
baseUrl: "https://api.x.ai/v1",
|
|
15
|
+
model: "grok-4-latest",
|
|
16
|
+
},
|
|
17
|
+
deepseek: {
|
|
18
|
+
key: "DEEPSEEK_API_KEY",
|
|
19
|
+
baseUrl: "https://api.deepseek.com/v1",
|
|
20
|
+
model: "deepseek-chat",
|
|
21
|
+
},
|
|
22
|
+
gemini: {
|
|
23
|
+
key: "GEMINI_API_KEY",
|
|
24
|
+
alternateKey: "GOOGLE_API_KEY",
|
|
25
|
+
baseUrl: "https://generativelanguage.googleapis.com/v1beta/openai",
|
|
26
|
+
model: "gemini-2.5-flash",
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
const OAUTH_PROVIDERS = Object.freeze({
|
|
31
|
+
"anthropic-oauth": {
|
|
32
|
+
baseUrl: "https://api.anthropic.com/v1",
|
|
33
|
+
model: "claude-sonnet-4-6",
|
|
34
|
+
protocol: "anthropic-messages",
|
|
35
|
+
},
|
|
36
|
+
"openai-codex": {
|
|
37
|
+
baseUrl: "https://chatgpt.com/backend-api/codex",
|
|
38
|
+
model: "gpt-5.6-sol",
|
|
39
|
+
protocol: "responses",
|
|
40
|
+
},
|
|
41
|
+
"xai-oauth": {
|
|
42
|
+
baseUrl: "https://api.x.ai/v1",
|
|
43
|
+
model: "grok-4.5",
|
|
44
|
+
protocol: "responses",
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
function positiveInteger(value, fallback) {
|
|
49
|
+
const parsed = Number.parseInt(String(value || ""), 10);
|
|
50
|
+
return Number.isFinite(parsed) && parsed > 0 ? parsed : fallback;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function providerFromEnv(env, stored = {}) {
|
|
54
|
+
const explicit = String(env.ORACLE_PROVIDER || stored.provider || "").trim().toLowerCase();
|
|
55
|
+
if (explicit) return explicit;
|
|
56
|
+
if (env.ORACLE_BASE_URL) return "custom";
|
|
57
|
+
for (const [name, preset] of Object.entries(PROVIDERS)) {
|
|
58
|
+
if (env[preset.key] || (preset.alternateKey && env[preset.alternateKey])) return name;
|
|
59
|
+
}
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function standaloneConfigFromEnv(
|
|
64
|
+
env = process.env,
|
|
65
|
+
stored = {},
|
|
66
|
+
oauthAvailable = () => false,
|
|
67
|
+
apiKeyResolver = () => "",
|
|
68
|
+
) {
|
|
69
|
+
const provider = providerFromEnv(env, stored);
|
|
70
|
+
if (!provider) return null;
|
|
71
|
+
|
|
72
|
+
const oauthPreset = OAUTH_PROVIDERS[provider];
|
|
73
|
+
const preset = PROVIDERS[provider] || oauthPreset;
|
|
74
|
+
const apiKeyEnv = String(env.ORACLE_API_KEY_ENV || stored.apiKeyEnv || "");
|
|
75
|
+
const apiKey = String(
|
|
76
|
+
env.ORACLE_API_KEY ||
|
|
77
|
+
(apiKeyEnv && env[apiKeyEnv]) ||
|
|
78
|
+
(preset && (env[preset.key] || (preset.alternateKey && env[preset.alternateKey]))) ||
|
|
79
|
+
apiKeyResolver(provider) ||
|
|
80
|
+
"",
|
|
81
|
+
);
|
|
82
|
+
const baseUrl = String(
|
|
83
|
+
oauthPreset
|
|
84
|
+
? oauthPreset.baseUrl
|
|
85
|
+
: provider === "custom"
|
|
86
|
+
? (env.ORACLE_BASE_URL || stored.baseUrl || "")
|
|
87
|
+
: (preset?.baseUrl || ""),
|
|
88
|
+
).replace(/\/+$/, "");
|
|
89
|
+
const model = String(env.ORACLE_MODEL || stored.model || preset?.model || "");
|
|
90
|
+
if (!baseUrl || !model) return null;
|
|
91
|
+
const hasOAuth = Boolean(oauthPreset && oauthAvailable(provider));
|
|
92
|
+
if (oauthPreset && !hasOAuth) return null;
|
|
93
|
+
if (!oauthPreset && provider !== "custom" && !apiKey) return null;
|
|
94
|
+
|
|
95
|
+
return {
|
|
96
|
+
kind: "standalone",
|
|
97
|
+
provider,
|
|
98
|
+
model,
|
|
99
|
+
baseUrl,
|
|
100
|
+
...(hasOAuth ? { authType: "oauth", protocol: oauthPreset.protocol } : { apiKey }),
|
|
101
|
+
contextLength: positiveInteger(env.ORACLE_CONTEXT_LENGTH || stored.contextLength, 128000),
|
|
102
|
+
reasoningEffort: String(env.ORACLE_REASONING_EFFORT || stored.reasoningEffort || "high"),
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function setupReason(extra = "") {
|
|
107
|
+
return [
|
|
108
|
+
"Oracle standalone chat does not require Hermes.",
|
|
109
|
+
"Set OPENROUTER_API_KEY, run `oracle auth login claude|codex|grok`, or configure a custom OpenAI-compatible endpoint.",
|
|
110
|
+
"If Hermes is installed, Oracle will reuse it automatically.",
|
|
111
|
+
extra,
|
|
112
|
+
].filter(Boolean).join("\n");
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export function resolveChatBackend({
|
|
116
|
+
env = process.env,
|
|
117
|
+
hermes = { ok: false },
|
|
118
|
+
storedConfig = null,
|
|
119
|
+
oauthAvailable = () => false,
|
|
120
|
+
apiKeyResolver = () => "",
|
|
121
|
+
} = {}) {
|
|
122
|
+
const requested = String(env.ORACLE_CHAT_BACKEND || storedConfig?.backend || "auto").trim().toLowerCase();
|
|
123
|
+
const standalone = standaloneConfigFromEnv(env, storedConfig || {}, oauthAvailable, apiKeyResolver);
|
|
124
|
+
|
|
125
|
+
if (requested === "standalone") {
|
|
126
|
+
return standalone
|
|
127
|
+
? { kind: "standalone", config: standalone }
|
|
128
|
+
: { kind: "unconfigured", reason: setupReason("ORACLE_CHAT_BACKEND=standalone was requested, but no standalone model is configured.") };
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if (requested === "hermes") {
|
|
132
|
+
return hermes?.ok
|
|
133
|
+
? { kind: "hermes", bin: hermes.bin }
|
|
134
|
+
: { kind: "unconfigured", reason: setupReason("ORACLE_CHAT_BACKEND=hermes was requested, but Hermes was not found.") };
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
if (requested !== "auto") {
|
|
138
|
+
return { kind: "unconfigured", reason: setupReason(`Unknown ORACLE_CHAT_BACKEND value: ${requested}`) };
|
|
139
|
+
}
|
|
140
|
+
if (hermes?.ok) return { kind: "hermes", bin: hermes.bin };
|
|
141
|
+
if (standalone) return { kind: "standalone", config: standalone };
|
|
142
|
+
return { kind: "unconfigured", reason: setupReason() };
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export default { resolveChatBackend, standaloneConfigFromEnv };
|