@oracle-agent/oracle 0.4.2 → 0.6.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 +76 -18
- package/SETUP.md +13 -0
- package/bin/oracle-data-mcp.mjs +1 -1
- package/bin/oracle.mjs +33 -0
- package/docs/cli.md +47 -0
- package/docs/connectors.md +13 -0
- package/package.json +6 -2
- package/profiles/oracle/SOUL.md +10 -4
- package/profiles/robinhood-agent/SOUL.md +5 -3
- package/protocols/templates/safe-erc20/README.md +9 -0
- package/public/agent-connect/app.js +16 -13
- package/public/oracle-splash/assets/hero/orb.avif +0 -0
- package/public/oracle-splash/assets/hero/orb.webm +0 -0
- package/public/oracle-splash/assets/llms/claude.svg +1 -0
- package/public/oracle-splash/assets/llms/codex.svg +1 -0
- package/public/oracle-splash/assets/llms/cursor.svg +17 -0
- package/public/oracle-splash/assets/llms/deepseek.svg +1 -0
- package/public/oracle-splash/assets/llms/gemini.svg +1 -0
- package/public/oracle-splash/assets/llms/grok.svg +8 -0
- package/public/oracle-splash/assets/llms/hermes.png +0 -0
- package/public/oracle-splash/assets/llms/kimi.svg +1 -0
- package/public/oracle-splash/assets/llms/manus.svg +18 -0
- package/public/oracle-splash/assets/llms/openclaw.svg +22 -0
- package/public/oracle-splash/assets/llms/perplexity.svg +1 -0
- package/public/oracle-splash/assets/llms/qwen.svg +1 -0
- package/public/oracle-splash/assets/llms/windsurf.svg +1 -0
- package/public/oracle-splash/assets/protocols/abcdex.png +0 -0
- package/public/oracle-splash/assets/protocols/across.png +0 -0
- package/public/oracle-splash/assets/protocols/aerodrome.png +0 -0
- package/public/oracle-splash/assets/protocols/balancer.png +0 -0
- package/public/oracle-splash/assets/protocols/cowswap.png +0 -0
- package/public/oracle-splash/assets/protocols/curve.png +0 -0
- package/public/oracle-splash/assets/protocols/dreamcash.png +0 -0
- package/public/oracle-splash/assets/protocols/felix.png +0 -0
- package/public/oracle-splash/assets/protocols/gmx.png +0 -0
- package/public/oracle-splash/assets/protocols/hyena.png +0 -0
- package/public/oracle-splash/assets/protocols/hyperbeat.png +0 -0
- package/public/oracle-splash/assets/protocols/hyperliquid.png +0 -0
- package/public/oracle-splash/assets/protocols/hyperswap.png +0 -0
- package/public/oracle-splash/assets/protocols/jupiter.png +0 -0
- package/public/oracle-splash/assets/protocols/kinetiq.png +0 -0
- package/public/oracle-splash/assets/protocols/lfj.png +0 -0
- package/public/oracle-splash/assets/protocols/lifi.png +0 -0
- package/public/oracle-splash/assets/protocols/magic-eden.png +0 -0
- package/public/oracle-splash/assets/protocols/morpho.png +0 -0
- package/public/oracle-splash/assets/protocols/odos.png +0 -0
- package/public/oracle-splash/assets/protocols/oneinch.png +0 -0
- package/public/oracle-splash/assets/protocols/opensea.png +0 -0
- package/public/oracle-splash/assets/protocols/pancakeswap.png +0 -0
- package/public/oracle-splash/assets/protocols/paragon.png +0 -0
- package/public/oracle-splash/assets/protocols/paraswap.png +0 -0
- package/public/oracle-splash/assets/protocols/pendle.png +0 -0
- package/public/oracle-splash/assets/protocols/polymarket.png +0 -0
- package/public/oracle-splash/assets/protocols/quickswap.png +0 -0
- package/public/oracle-splash/assets/protocols/relay.png +0 -0
- package/public/oracle-splash/assets/protocols/stargate.png +0 -0
- package/public/oracle-splash/assets/protocols/tradexyz.png +0 -0
- package/public/oracle-splash/assets/protocols/uniswap.png +0 -0
- package/public/oracle-splash/assets/protocols/velodrome.png +0 -0
- package/public/oracle-splash/assets/protocols/ventuals.png +0 -0
- package/public/oracle-splash/assets/wordmarks/across.svg +4 -0
- package/public/oracle-splash/assets/wordmarks/aerodrome.svg +23 -0
- package/public/oracle-splash/assets/wordmarks/balancer.svg +3 -0
- package/public/oracle-splash/assets/wordmarks/cowswap.svg +1 -0
- package/public/oracle-splash/assets/wordmarks/gmx.svg +13 -0
- package/public/oracle-splash/assets/wordmarks/hyena.svg +7 -0
- package/public/oracle-splash/assets/wordmarks/hyperliquid.svg +21 -0
- package/public/oracle-splash/assets/wordmarks/hyperswap.svg +13 -0
- package/public/oracle-splash/assets/wordmarks/jupiter.svg +35 -0
- package/public/oracle-splash/assets/wordmarks/lifi.png +0 -0
- package/public/oracle-splash/assets/wordmarks/magic-eden.svg +1 -0
- package/public/oracle-splash/assets/wordmarks/morpho.svg +1 -0
- package/public/oracle-splash/assets/wordmarks/odos.svg +3 -0
- package/public/oracle-splash/assets/wordmarks/oneinch.svg +6 -0
- package/public/oracle-splash/assets/wordmarks/opensea.svg +1 -0
- package/public/oracle-splash/assets/wordmarks/outcome.svg +16 -0
- package/public/oracle-splash/assets/wordmarks/pancakeswap.svg +18 -0
- package/public/oracle-splash/assets/wordmarks/paraswap.svg +16 -0
- package/public/oracle-splash/assets/wordmarks/pendle.png +0 -0
- package/public/oracle-splash/assets/wordmarks/polymarket.png +0 -0
- package/public/oracle-splash/assets/wordmarks/quickswap.png +0 -0
- package/public/oracle-splash/assets/wordmarks/relay.svg +8 -0
- package/public/oracle-splash/assets/wordmarks/stargate.svg +15 -0
- package/public/oracle-splash/assets/wordmarks/uniswap.svg +18 -0
- package/public/oracle-splash/assets/wordmarks/velodrome.svg +84 -0
- package/public/oracle-splash/assets/wordmarks/xyz.svg +12 -0
- package/public/oracle-splash/index.html +784 -498
- package/scripts/check-doc-drift.mjs +111 -0
- package/skills/oracle-chat/SKILL.md +61 -0
- package/skills/oracle-chat/chain.SKILL.md +31 -0
- package/skills/oracle-chat/setup.SKILL.md +37 -0
- package/skins/oracle.yaml +52 -0
- package/src/cli/chain-catalog.mjs +215 -0
- package/src/cli/chain-state.mjs +74 -0
- package/src/cli/commands/chain.mjs +143 -0
- package/src/cli/commands/chat.mjs +268 -0
- package/src/cli/commands/credential.mjs +9 -0
- package/src/cli/commands/data-mcp.mjs +18 -0
- package/src/cli/commands/data.mjs +73 -0
- package/src/cli/commands/doctor.mjs +131 -0
- package/src/cli/commands/help.mjs +7 -0
- package/src/cli/commands/init.mjs +27 -0
- package/src/cli/commands/mcp.mjs +142 -0
- package/src/cli/commands/model.mjs +37 -0
- package/src/cli/commands/prepare.mjs +12 -0
- package/src/cli/commands/public.mjs +20 -0
- package/src/cli/commands/route.mjs +12 -0
- package/src/cli/commands/runner.mjs +9 -0
- package/src/cli/commands/scan.mjs +12 -0
- package/src/cli/commands/setup.mjs +283 -0
- package/src/cli/commands/sign.mjs +21 -0
- package/src/cli/commands/signer.mjs +9 -0
- package/src/cli/commands/upgrade.mjs +12 -0
- package/src/cli/commands/vault.mjs +9 -0
- package/src/cli/commands/version.mjs +22 -0
- package/src/cli/first-run.mjs +23 -0
- package/src/cli/kernel.mjs +237 -0
- package/src/cli/mcp-targets/chatgpt.mjs +51 -0
- package/src/cli/mcp-targets/claude-code.mjs +39 -0
- package/src/cli/mcp-targets/claude-desktop.mjs +24 -0
- package/src/cli/mcp-targets/codex.mjs +41 -0
- package/src/cli/mcp-targets/shared.mjs +61 -0
- package/src/cli/messaging-platforms.mjs +209 -0
- package/src/cli/operator-dispatch.mjs +258 -0
- package/src/cli/oracle-harness.py +148 -0
- package/src/cli/paths.mjs +83 -0
- package/src/cli/setup-state.mjs +168 -0
- package/src/cli/spawn-child.mjs +43 -0
- package/src/public-api/connect-agent.mjs +29 -10
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { pathToFileURL } from "node:url";
|
|
4
|
+
import { PACKAGE_ROOT, paths } from "./paths.mjs";
|
|
5
|
+
import {
|
|
6
|
+
dispatchOperator,
|
|
7
|
+
resolveOperator,
|
|
8
|
+
printOperatorNotInstalled,
|
|
9
|
+
SIGN_NOUNS,
|
|
10
|
+
} from "./operator-dispatch.mjs";
|
|
11
|
+
|
|
12
|
+
const HELP_HEADER = `oracle — self-custody multichain agent control plane`;
|
|
13
|
+
|
|
14
|
+
const STATIC_HELP = `READ / RESEARCH (no keys, this package)
|
|
15
|
+
oracle open the plain oracle chat harness (TTY)
|
|
16
|
+
oracle init install agent lanes + read plane (dry-run by default)
|
|
17
|
+
oracle doctor check read plane; checks signer too when installed
|
|
18
|
+
oracle chat one lowercase oracle chat surface (multi-model)
|
|
19
|
+
oracle model choose the profile's default model/provider
|
|
20
|
+
oracle chain list/select working chains (hyperliquid, base, ...)
|
|
21
|
+
oracle setup telegram/discord/slack + hermes messaging menu
|
|
22
|
+
oracle data serve|call|catalog|health
|
|
23
|
+
oracle data-mcp start the read-only MCP server
|
|
24
|
+
oracle scan chains|head|token|pools|risk|quote|sell
|
|
25
|
+
oracle route swap|bridge|prepare|prepare-bridge
|
|
26
|
+
oracle prepare build an unsigned swap (alias of route prepare)
|
|
27
|
+
oracle public serve secret-free public HTTP surface
|
|
28
|
+
oracle mcp install <t> wire Oracle into claude-code|claude-desktop|codex|chatgpt
|
|
29
|
+
oracle upgrade upgrade installed Hermes lanes
|
|
30
|
+
|
|
31
|
+
SIGNING (dispatches to @oracle-agent/operator on THIS machine; never in this package)
|
|
32
|
+
oracle sign init|doctor provision / check the local signer (opt-in)
|
|
33
|
+
oracle vault ... encrypt local key files at rest
|
|
34
|
+
oracle signer / runner loopback signer daemon / action runner
|
|
35
|
+
oracle credential ... OS credential store glue
|
|
36
|
+
|
|
37
|
+
oracle <noun> --help for details. Keys never leave your machine; this package
|
|
38
|
+
cannot sign — signing commands run the locally installed operator package.
|
|
39
|
+
`;
|
|
40
|
+
|
|
41
|
+
function readPackageVersion() {
|
|
42
|
+
try {
|
|
43
|
+
const pkg = JSON.parse(
|
|
44
|
+
fs.readFileSync(path.join(PACKAGE_ROOT, "package.json"), "utf8"),
|
|
45
|
+
);
|
|
46
|
+
return pkg.version || "0.0.0";
|
|
47
|
+
} catch {
|
|
48
|
+
return "0.0.0";
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function commandsDir() {
|
|
53
|
+
return path.join(PACKAGE_ROOT, "src", "cli", "commands");
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export async function discoverCommands() {
|
|
57
|
+
const dir = commandsDir();
|
|
58
|
+
const out = new Map();
|
|
59
|
+
if (!fs.existsSync(dir)) return out;
|
|
60
|
+
const entries = fs
|
|
61
|
+
.readdirSync(dir)
|
|
62
|
+
.filter((f) => f.endsWith(".mjs"))
|
|
63
|
+
.sort();
|
|
64
|
+
for (const file of entries) {
|
|
65
|
+
const full = path.join(dir, file);
|
|
66
|
+
try {
|
|
67
|
+
const mod = await import(pathToFileURL(full).href + `?t=${Date.now()}`);
|
|
68
|
+
const cmd = mod.default;
|
|
69
|
+
if (!cmd || typeof cmd !== "object" || typeof cmd.run !== "function") {
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
const name = cmd.name || file.replace(/\.mjs$/, "");
|
|
73
|
+
out.set(name, { ...cmd, name, __file: full });
|
|
74
|
+
} catch (err) {
|
|
75
|
+
if (process.env.ORACLE_CLI_DEBUG) {
|
|
76
|
+
console.error(`oracle: failed loading command ${file}: ${err.message}`);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return out;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export function renderHelp(version, commands) {
|
|
84
|
+
const lines = [];
|
|
85
|
+
lines.push(`${HELP_HEADER} (v${version})`);
|
|
86
|
+
lines.push("");
|
|
87
|
+
lines.push(STATIC_HELP.trimEnd());
|
|
88
|
+
|
|
89
|
+
const extras = [];
|
|
90
|
+
for (const cmd of commands.values()) {
|
|
91
|
+
if (["help", "version"].includes(cmd.name)) continue;
|
|
92
|
+
const known = new Set([
|
|
93
|
+
"init","doctor","chat","model","chain","setup","data","data-mcp","scan","route","prepare","public","mcp","upgrade",
|
|
94
|
+
"sign","vault","signer","runner","credential",
|
|
95
|
+
]);
|
|
96
|
+
if (!known.has(cmd.name) && cmd.summary) {
|
|
97
|
+
extras.push(` oracle ${cmd.name.padEnd(20)} ${cmd.summary}`);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
if (extras.length) {
|
|
101
|
+
lines.push("");
|
|
102
|
+
lines.push("ADDITIONAL");
|
|
103
|
+
lines.push(...extras);
|
|
104
|
+
}
|
|
105
|
+
return lines.join("\n") + "\n";
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function unknownNounMessage(noun, commands) {
|
|
109
|
+
const known = [...commands.keys()].sort();
|
|
110
|
+
const list = known.length ? known.join(", ") : "(none loaded yet)";
|
|
111
|
+
return `oracle: unknown command '${noun}'. Known: ${list}\nTry: oracle --help\n`;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function buildCtx(argv) {
|
|
115
|
+
return {
|
|
116
|
+
argv,
|
|
117
|
+
root: PACKAGE_ROOT,
|
|
118
|
+
paths,
|
|
119
|
+
dispatchOperator,
|
|
120
|
+
resolveOperator,
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export async function run(argv = []) {
|
|
125
|
+
const version = readPackageVersion();
|
|
126
|
+
|
|
127
|
+
if (argv.includes("--version") || argv.includes("-V")) {
|
|
128
|
+
return runVersion();
|
|
129
|
+
}
|
|
130
|
+
if (argv[0] === "--help" || argv[0] === "-h") {
|
|
131
|
+
const commands = await discoverCommands();
|
|
132
|
+
process.stdout.write(renderHelp(version, commands));
|
|
133
|
+
return 0;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if (argv.length === 0) {
|
|
137
|
+
const commands = await discoverCommands();
|
|
138
|
+
if (shouldLaunchChat(argv)) {
|
|
139
|
+
const chat = commands.get("chat");
|
|
140
|
+
if (chat) return chat.run(buildCtx([]));
|
|
141
|
+
}
|
|
142
|
+
process.stdout.write(renderHelp(version, commands));
|
|
143
|
+
return 0;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
if (isRootChatFlag(argv[0])) {
|
|
147
|
+
const commands = await discoverCommands();
|
|
148
|
+
const chat = commands.get("chat");
|
|
149
|
+
if (chat) return chat.run(buildCtx(argv));
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
const noun = argv[0];
|
|
153
|
+
const rest = argv.slice(1);
|
|
154
|
+
|
|
155
|
+
if (noun === "version") {
|
|
156
|
+
return runVersion();
|
|
157
|
+
}
|
|
158
|
+
if (noun === "help") {
|
|
159
|
+
const commands = await discoverCommands();
|
|
160
|
+
if (rest[0]) {
|
|
161
|
+
const cmd = commands.get(rest[0]);
|
|
162
|
+
if (cmd) {
|
|
163
|
+
process.stdout.write((cmd.usage || `oracle ${cmd.name}`) + "\n");
|
|
164
|
+
if (cmd.summary) process.stdout.write(cmd.summary + "\n");
|
|
165
|
+
return 0;
|
|
166
|
+
}
|
|
167
|
+
process.stderr.write(unknownNounMessage(rest[0], commands));
|
|
168
|
+
return 1;
|
|
169
|
+
}
|
|
170
|
+
process.stdout.write(renderHelp(version, commands));
|
|
171
|
+
return 0;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
const commands = await discoverCommands();
|
|
175
|
+
const cmd = commands.get(noun);
|
|
176
|
+
|
|
177
|
+
if (cmd) {
|
|
178
|
+
if (rest[0] === "--help" || rest[0] === "-h") {
|
|
179
|
+
process.stdout.write((cmd.usage || `oracle ${cmd.name}`) + "\n");
|
|
180
|
+
if (cmd.summary) process.stdout.write(cmd.summary + "\n");
|
|
181
|
+
return 0;
|
|
182
|
+
}
|
|
183
|
+
try {
|
|
184
|
+
const code = await cmd.run(buildCtx(rest));
|
|
185
|
+
return typeof code === "number" ? code : 0;
|
|
186
|
+
} catch (err) {
|
|
187
|
+
process.stderr.write(`oracle ${noun}: ${err?.message || err}\n`);
|
|
188
|
+
return 1;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
if (SIGN_NOUNS.includes(noun)) {
|
|
193
|
+
const resolved = resolveOperator();
|
|
194
|
+
if (!resolved.ok) {
|
|
195
|
+
printOperatorNotInstalled(process.stderr);
|
|
196
|
+
return 3;
|
|
197
|
+
}
|
|
198
|
+
process.stderr.write(
|
|
199
|
+
`oracle: sign-plane command '${noun}' is not available in this build (operator is installed).\n`,
|
|
200
|
+
);
|
|
201
|
+
return 1;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
process.stderr.write(unknownNounMessage(noun, commands));
|
|
205
|
+
return 1;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
async function runVersion() {
|
|
209
|
+
const version = readPackageVersion();
|
|
210
|
+
let line = `oracle ${version}`;
|
|
211
|
+
const op = resolveOperator();
|
|
212
|
+
if (op.ok) {
|
|
213
|
+
line += ` operator ${op.version}`;
|
|
214
|
+
}
|
|
215
|
+
process.stdout.write(line + "\n");
|
|
216
|
+
return 0;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
export default { run, discoverCommands, renderHelp };
|
|
220
|
+
|
|
221
|
+
export function shouldLaunchChat(
|
|
222
|
+
argv = [],
|
|
223
|
+
io = { stdin: process.stdin, stdout: process.stdout },
|
|
224
|
+
) {
|
|
225
|
+
if (argv.length !== 0) return false;
|
|
226
|
+
if (process.env.ORACLE_FORCE_CHAT === "1") return true;
|
|
227
|
+
return io.stdin?.isTTY === true && io.stdout?.isTTY === true;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
export function isRootChatFlag(value) {
|
|
231
|
+
return [
|
|
232
|
+
"-m", "--model", "--provider", "-q", "--query", "-Q", "--quiet",
|
|
233
|
+
"-c", "--continue", "-r", "--resume", "-s", "--skills", "-t",
|
|
234
|
+
"--toolsets", "--reasoning", "--tui", "--cli", "--yolo",
|
|
235
|
+
"--checkpoints", "--source", "--max-turns",
|
|
236
|
+
].includes(String(value || ""));
|
|
237
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { fakeHome, report } from "./shared.mjs";
|
|
4
|
+
|
|
5
|
+
export const CHATGPT_CANNOT_SIGN =
|
|
6
|
+
"ChatGPT is hosted and can NEVER sign or reach your keys. This connector is read/prepare only; anything it prepares is unsigned until you sign it locally.";
|
|
7
|
+
|
|
8
|
+
function openApiDoc() {
|
|
9
|
+
return {
|
|
10
|
+
openapi: "3.1.0",
|
|
11
|
+
info: {
|
|
12
|
+
title: "Oracle Public (read/prepare)",
|
|
13
|
+
version: "1.0.0",
|
|
14
|
+
description: "Secret-free public surface for hosted clients. " + CHATGPT_CANNOT_SIGN,
|
|
15
|
+
},
|
|
16
|
+
servers: [{ url: "https://REPLACE-WITH-YOUR-TUNNEL" }],
|
|
17
|
+
paths: {
|
|
18
|
+
"/public/health": { get: { operationId: "publicHealth", summary: "Health check", responses: { "200": { description: "ok" } } } },
|
|
19
|
+
"/public/config": { get: { operationId: "publicConfig", summary: "Public config", responses: { "200": { description: "ok" } } } },
|
|
20
|
+
"/public/connect/request": { post: { operationId: "connectRequest", summary: "Build a connect request (unsigned)", responses: { "200": { description: "unsigned request artifact" } } } },
|
|
21
|
+
"/public/connect/assemble": { post: { operationId: "connectAssemble", summary: "Assemble an unsigned grant artifact", responses: { "200": { description: "unsigned grant artifact" } } } },
|
|
22
|
+
"/public/grants/active": { post: { operationId: "grantsActive", summary: "List active grants (read)", responses: { "200": { description: "ok" } } } },
|
|
23
|
+
"/public/grants/get": { post: { operationId: "grantsGet", summary: "Get a grant by id (read)", responses: { "200": { description: "ok" } } } },
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export async function installChatgpt({ printOnly = false } = {}) {
|
|
29
|
+
const doc = openApiDoc();
|
|
30
|
+
const target = path.join(fakeHome(), ".config", "oracle", "connectors", "chatgpt-openapi.json");
|
|
31
|
+
const text = JSON.stringify(doc, null, 2) + "\n";
|
|
32
|
+
if (!printOnly) {
|
|
33
|
+
fs.mkdirSync(path.dirname(target), { recursive: true });
|
|
34
|
+
fs.writeFileSync(target, text);
|
|
35
|
+
}
|
|
36
|
+
const instructions = [
|
|
37
|
+
CHATGPT_CANNOT_SIGN, "",
|
|
38
|
+
"Next steps:",
|
|
39
|
+
" 1. oracle public serve",
|
|
40
|
+
" 2. Expose 127.0.0.1:8799 through YOUR HTTPS tunnel (cloudflared, tailscale funnel, etc.).",
|
|
41
|
+
" Oracle will not create tunnels for you.",
|
|
42
|
+
" 3. Paste the OpenAPI spec into a GPT Action, or add the tunnel URL as a developer-mode MCP connector.",
|
|
43
|
+
printOnly ? "" : ` Spec written to: ${target}`,
|
|
44
|
+
].filter(Boolean).join("\n");
|
|
45
|
+
return {
|
|
46
|
+
ok: true,
|
|
47
|
+
...report(printOnly ? "printed" : "written", {
|
|
48
|
+
path: target, print: doc, instructions, cannotSign: CHATGPT_CANNOT_SIGN,
|
|
49
|
+
}),
|
|
50
|
+
};
|
|
51
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { spawnSync } from "node:child_process";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { fakeHome, buildServerSpecs, mergeMcpServers, report } from "./shared.mjs";
|
|
4
|
+
|
|
5
|
+
function claudeJsonPath() { return path.join(fakeHome(), ".claude.json"); }
|
|
6
|
+
function projectMcpPath(cwd) { return path.join(cwd || process.cwd(), ".mcp.json"); }
|
|
7
|
+
|
|
8
|
+
function tryClaudeCli(name, spec) {
|
|
9
|
+
const probe = spawnSync("claude", ["--version"], { encoding: "utf8", timeout: 10000 });
|
|
10
|
+
if (probe.error || probe.status !== 0) return null;
|
|
11
|
+
const r = spawnSync("claude", ["mcp", "add-json", name, JSON.stringify(spec), "--scope", "user"], {
|
|
12
|
+
encoding: "utf8", timeout: 30000,
|
|
13
|
+
});
|
|
14
|
+
if (r.status !== 0) return { ok: false, stderr: r.stderr || r.stdout || "failed" };
|
|
15
|
+
return { ok: true };
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export async function installClaudeCode({
|
|
19
|
+
oracleRoot, operator, withControl = false, project = false, printOnly = false, cwd = process.cwd(),
|
|
20
|
+
}) {
|
|
21
|
+
const built = buildServerSpecs({ oracleRoot, operator, withControl });
|
|
22
|
+
if (!built.ok) return { ok: false, code: 3, reason: built.reason };
|
|
23
|
+
if (printOnly) return { ok: true, print: { mcpServers: built.specs } };
|
|
24
|
+
if (project) {
|
|
25
|
+
const target = projectMcpPath(cwd);
|
|
26
|
+
const result = mergeMcpServers(target, built.specs);
|
|
27
|
+
return { ok: true, ...report(result.status, { path: target, backup: result.backup }) };
|
|
28
|
+
}
|
|
29
|
+
let usedCli = false;
|
|
30
|
+
for (const [name, spec] of Object.entries(built.specs)) {
|
|
31
|
+
const cli = tryClaudeCli(name, spec);
|
|
32
|
+
if (cli && cli.ok) { usedCli = true; continue; }
|
|
33
|
+
break;
|
|
34
|
+
}
|
|
35
|
+
if (usedCli) return { ok: true, ...report("written", { method: "claude-cli" }) };
|
|
36
|
+
const target = claudeJsonPath();
|
|
37
|
+
const result = mergeMcpServers(target, built.specs);
|
|
38
|
+
return { ok: true, ...report(result.status, { path: target, backup: result.backup }) };
|
|
39
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { fakeHome, buildServerSpecs, mergeMcpServers, report } from "./shared.mjs";
|
|
4
|
+
|
|
5
|
+
function desktopConfigPath() {
|
|
6
|
+
if (process.platform === "darwin") {
|
|
7
|
+
return path.join(fakeHome(), "Library", "Application Support", "Claude", "claude_desktop_config.json");
|
|
8
|
+
}
|
|
9
|
+
return path.join(fakeHome(), ".config", "Claude", "claude_desktop_config.json");
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export async function installClaudeDesktop({ oracleRoot, operator, withControl = false, printOnly = false }) {
|
|
13
|
+
const built = buildServerSpecs({ oracleRoot, operator, withControl });
|
|
14
|
+
if (!built.ok) return { ok: false, code: 3, reason: built.reason };
|
|
15
|
+
const target = desktopConfigPath();
|
|
16
|
+
const payload = { mcpServers: built.specs };
|
|
17
|
+
if (printOnly) return { ok: true, print: payload };
|
|
18
|
+
const parent = path.dirname(target);
|
|
19
|
+
if (!fs.existsSync(parent)) {
|
|
20
|
+
return { ok: true, status: "printed (Claude Desktop not detected)", path: target, print: payload };
|
|
21
|
+
}
|
|
22
|
+
const result = mergeMcpServers(target, built.specs);
|
|
23
|
+
return { ok: true, ...report(result.status, { path: target, backup: result.backup }) };
|
|
24
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { fakeHome, buildServerSpecs, backupFile, report } from "./shared.mjs";
|
|
4
|
+
|
|
5
|
+
const BEGIN = "# oracle-mcp-install begin";
|
|
6
|
+
const END = "# oracle-mcp-install end";
|
|
7
|
+
|
|
8
|
+
function codexPath() { return path.join(fakeHome(), ".codex", "config.toml"); }
|
|
9
|
+
|
|
10
|
+
function renderBlock(specs) {
|
|
11
|
+
const lines = [BEGIN];
|
|
12
|
+
for (const [name, spec] of Object.entries(specs)) {
|
|
13
|
+
lines.push(`[mcp_servers.${name}]`);
|
|
14
|
+
lines.push(`command = ${JSON.stringify(spec.command)}`);
|
|
15
|
+
lines.push(`args = [${spec.args.map((a) => JSON.stringify(a)).join(", ")}]`);
|
|
16
|
+
lines.push("");
|
|
17
|
+
}
|
|
18
|
+
lines.push(END);
|
|
19
|
+
return lines.join("\n") + "\n";
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function stripExistingBlock(text) {
|
|
23
|
+
return text.replace(new RegExp(`${BEGIN}[\\s\\S]*?${END}\\n?`, "g"), "");
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export async function installCodex({ oracleRoot, operator, withControl = false, printOnly = false }) {
|
|
27
|
+
const built = buildServerSpecs({ oracleRoot, operator, withControl });
|
|
28
|
+
if (!built.ok) return { ok: false, code: 3, reason: built.reason };
|
|
29
|
+
const block = renderBlock(built.specs);
|
|
30
|
+
const target = codexPath();
|
|
31
|
+
if (printOnly) return { ok: true, printText: block, path: target };
|
|
32
|
+
fs.mkdirSync(path.dirname(target), { recursive: true });
|
|
33
|
+
const prev = fs.existsSync(target) ? fs.readFileSync(target, "utf8") : "";
|
|
34
|
+
if (prev.includes(block.trim())) return { ok: true, ...report("present", { path: target, backup: null }) };
|
|
35
|
+
const stripped = stripExistingBlock(prev);
|
|
36
|
+
const next = (stripped.trimEnd() + "\n\n" + block).replace(/^\n+/, "");
|
|
37
|
+
if (prev.trim() === next.trim()) return { ok: true, ...report("present", { path: target, backup: null }) };
|
|
38
|
+
const backup = prev ? backupFile(target) : null;
|
|
39
|
+
fs.writeFileSync(target, next.endsWith("\n") ? next : next + "\n");
|
|
40
|
+
return { ok: true, ...report("written", { path: target, backup }) };
|
|
41
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import os from "node:os";
|
|
4
|
+
import { PACKAGE_ROOT } from "../paths.mjs";
|
|
5
|
+
|
|
6
|
+
export function fakeHome() {
|
|
7
|
+
return process.env.ORACLE_FAKE_HOME || os.homedir();
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function buildServerSpecs({ oracleRoot = PACKAGE_ROOT, operator = null, withControl = false } = {}) {
|
|
11
|
+
const specs = {
|
|
12
|
+
"oracle-data": {
|
|
13
|
+
command: "node",
|
|
14
|
+
args: [path.join(oracleRoot, "bin", "oracle-data-mcp.mjs")],
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
if (withControl) {
|
|
18
|
+
if (!operator || !operator.ok) return { ok: false, reason: "operator-missing" };
|
|
19
|
+
const control = operator.bins?.["oracle-control-mcp"] || operator.controlMcp || null;
|
|
20
|
+
if (!control) return { ok: false, reason: "control-bin-missing" };
|
|
21
|
+
specs["oracle-control"] = { command: "node", args: [control] };
|
|
22
|
+
}
|
|
23
|
+
return { ok: true, specs };
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function backupFile(filePath) {
|
|
27
|
+
if (!fs.existsSync(filePath)) return null;
|
|
28
|
+
const bak = `${filePath}.bak-oracle-${Math.floor(Date.now() / 1000)}`;
|
|
29
|
+
fs.copyFileSync(filePath, bak);
|
|
30
|
+
return bak;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function readJson(filePath, fallback = {}) {
|
|
34
|
+
if (!fs.existsSync(filePath)) return structuredClone(fallback);
|
|
35
|
+
return JSON.parse(fs.readFileSync(filePath, "utf8"));
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function writeJson(filePath, obj) {
|
|
39
|
+
fs.mkdirSync(path.dirname(filePath), { recursive: true });
|
|
40
|
+
fs.writeFileSync(filePath, JSON.stringify(obj, null, 2) + "\n");
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function mergeMcpServers(filePath, specs) {
|
|
44
|
+
const existing = readJson(filePath, {});
|
|
45
|
+
if (!existing.mcpServers || typeof existing.mcpServers !== "object") existing.mcpServers = {};
|
|
46
|
+
let changed = false;
|
|
47
|
+
for (const [name, spec] of Object.entries(specs)) {
|
|
48
|
+
const prev = existing.mcpServers[name];
|
|
49
|
+
if (prev && JSON.stringify(prev) === JSON.stringify(spec)) continue;
|
|
50
|
+
existing.mcpServers[name] = spec;
|
|
51
|
+
changed = true;
|
|
52
|
+
}
|
|
53
|
+
if (!changed) return { status: "present", backup: null };
|
|
54
|
+
const backup = backupFile(filePath);
|
|
55
|
+
writeJson(filePath, existing);
|
|
56
|
+
return { status: "written", backup };
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function report(status, detail = {}) {
|
|
60
|
+
return { status, ...detail };
|
|
61
|
+
}
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
// Hermes messaging platforms Oracle can configure.
|
|
2
|
+
// Values stay lowercase. Secrets stay in Hermes profile .env, never printed.
|
|
3
|
+
|
|
4
|
+
export const MESSAGING_PLATFORMS = Object.freeze([
|
|
5
|
+
{
|
|
6
|
+
key: "telegram",
|
|
7
|
+
name: "telegram",
|
|
8
|
+
hermes: ["gateway", "setup"],
|
|
9
|
+
required: ["TELEGRAM_BOT_TOKEN"],
|
|
10
|
+
optional: ["TELEGRAM_ALLOWED_USERS", "TELEGRAM_PROXY"],
|
|
11
|
+
note: "dms · groups · topics",
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
key: "discord",
|
|
15
|
+
name: "discord",
|
|
16
|
+
hermes: ["gateway", "setup"],
|
|
17
|
+
required: ["DISCORD_BOT_TOKEN"],
|
|
18
|
+
optional: ["DISCORD_ALLOWED_USERS"],
|
|
19
|
+
note: "dms · channels · threads",
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
key: "slack",
|
|
23
|
+
name: "slack",
|
|
24
|
+
hermes: ["gateway", "setup"],
|
|
25
|
+
required: ["SLACK_BOT_TOKEN", "SLACK_APP_TOKEN"],
|
|
26
|
+
optional: ["SLACK_ALLOWED_USERS"],
|
|
27
|
+
note: "socket mode",
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
key: "whatsapp",
|
|
31
|
+
name: "whatsapp",
|
|
32
|
+
hermes: ["whatsapp"],
|
|
33
|
+
required: [],
|
|
34
|
+
optional: ["WHATSAPP_ALLOWED_USERS", "WHATSAPP_MODE"],
|
|
35
|
+
note: "qr bridge",
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
key: "whatsapp-cloud",
|
|
39
|
+
name: "whatsapp cloud",
|
|
40
|
+
hermes: ["whatsapp-cloud"],
|
|
41
|
+
required: [],
|
|
42
|
+
optional: [],
|
|
43
|
+
note: "business cloud api",
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
key: "signal",
|
|
47
|
+
name: "signal",
|
|
48
|
+
hermes: ["gateway", "setup"],
|
|
49
|
+
required: ["SIGNAL_HTTP_URL", "SIGNAL_ACCOUNT"],
|
|
50
|
+
optional: ["SIGNAL_ALLOWED_USERS"],
|
|
51
|
+
note: "signal-cli rest bridge",
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
key: "matrix",
|
|
55
|
+
name: "matrix",
|
|
56
|
+
hermes: ["gateway", "setup"],
|
|
57
|
+
required: ["MATRIX_HOMESERVER", "MATRIX_ACCESS_TOKEN", "MATRIX_USER_ID"],
|
|
58
|
+
optional: ["MATRIX_ALLOWED_USERS"],
|
|
59
|
+
note: "rooms · dms",
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
key: "mattermost",
|
|
63
|
+
name: "mattermost",
|
|
64
|
+
hermes: ["gateway", "setup"],
|
|
65
|
+
required: ["MATTERMOST_URL", "MATTERMOST_TOKEN"],
|
|
66
|
+
optional: ["MATTERMOST_ALLOWED_USERS"],
|
|
67
|
+
note: "channels · dms",
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
key: "email",
|
|
71
|
+
name: "email",
|
|
72
|
+
hermes: ["gateway", "setup"],
|
|
73
|
+
required: ["EMAIL_ADDRESS", "EMAIL_PASSWORD", "EMAIL_IMAP_HOST", "EMAIL_SMTP_HOST"],
|
|
74
|
+
optional: [],
|
|
75
|
+
note: "imap/smtp mailbox",
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
key: "bluebubbles",
|
|
79
|
+
name: "bluebubbles",
|
|
80
|
+
hermes: ["gateway", "setup"],
|
|
81
|
+
required: [],
|
|
82
|
+
optional: [],
|
|
83
|
+
note: "imessage via bluebubbles",
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
key: "homeassistant",
|
|
87
|
+
name: "homeassistant",
|
|
88
|
+
hermes: ["gateway", "setup"],
|
|
89
|
+
required: ["HASS_URL", "HASS_TOKEN"],
|
|
90
|
+
optional: [],
|
|
91
|
+
note: "smart home",
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
key: "webhook",
|
|
95
|
+
name: "webhook",
|
|
96
|
+
hermes: ["gateway", "setup"],
|
|
97
|
+
required: [],
|
|
98
|
+
optional: [],
|
|
99
|
+
note: "http ingress",
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
key: "api-server",
|
|
103
|
+
name: "api server",
|
|
104
|
+
hermes: ["gateway", "setup"],
|
|
105
|
+
required: [],
|
|
106
|
+
optional: [],
|
|
107
|
+
note: "local http api",
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
key: "dingtalk",
|
|
111
|
+
name: "dingtalk",
|
|
112
|
+
hermes: ["gateway", "setup"],
|
|
113
|
+
required: [],
|
|
114
|
+
optional: [],
|
|
115
|
+
note: "dingtalk bot",
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
key: "feishu",
|
|
119
|
+
name: "feishu",
|
|
120
|
+
hermes: ["gateway", "setup"],
|
|
121
|
+
required: [],
|
|
122
|
+
optional: [],
|
|
123
|
+
note: "feishu / lark",
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
key: "wecom",
|
|
127
|
+
name: "wecom",
|
|
128
|
+
hermes: ["gateway", "setup"],
|
|
129
|
+
required: [],
|
|
130
|
+
optional: [],
|
|
131
|
+
note: "wecom",
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
key: "weixin",
|
|
135
|
+
name: "weixin",
|
|
136
|
+
hermes: ["gateway", "setup"],
|
|
137
|
+
required: [],
|
|
138
|
+
optional: [],
|
|
139
|
+
note: "weixin",
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
key: "qqbot",
|
|
143
|
+
name: "qqbot",
|
|
144
|
+
hermes: ["gateway", "setup"],
|
|
145
|
+
required: [],
|
|
146
|
+
optional: [],
|
|
147
|
+
note: "qq bot",
|
|
148
|
+
},
|
|
149
|
+
]);
|
|
150
|
+
|
|
151
|
+
function normalize(raw) {
|
|
152
|
+
return String(raw || "")
|
|
153
|
+
.trim()
|
|
154
|
+
.toLowerCase()
|
|
155
|
+
.replace(/^\/+/, "")
|
|
156
|
+
.replace(/\s+/g, "-");
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export function listMessagingPlatforms() {
|
|
160
|
+
return MESSAGING_PLATFORMS.slice();
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export function findMessagingPlatform(query) {
|
|
164
|
+
const q = normalize(query);
|
|
165
|
+
if (!q) return null;
|
|
166
|
+
for (const p of MESSAGING_PLATFORMS) {
|
|
167
|
+
if (p.key === q) return p;
|
|
168
|
+
if (normalize(p.name) === q) return p;
|
|
169
|
+
}
|
|
170
|
+
return null;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
export function renderSetupMenu({ profile = "oracle", statuses = {} } = {}) {
|
|
174
|
+
const lines = [
|
|
175
|
+
"oracle setup",
|
|
176
|
+
"",
|
|
177
|
+
"one oracle. many models. hermes messaging underneath.",
|
|
178
|
+
`profile: ${profile}`,
|
|
179
|
+
"",
|
|
180
|
+
"messaging platforms:",
|
|
181
|
+
"",
|
|
182
|
+
];
|
|
183
|
+
for (const p of MESSAGING_PLATFORMS) {
|
|
184
|
+
const st = statuses[p.key] || "unset";
|
|
185
|
+
lines.push(` ${p.key.padEnd(16)} ${String(st).padEnd(8)} ${p.note}`);
|
|
186
|
+
}
|
|
187
|
+
lines.push("");
|
|
188
|
+
lines.push("commands:");
|
|
189
|
+
lines.push(" oracle setup this menu");
|
|
190
|
+
lines.push(" oracle setup messaging open hermes gateway setup");
|
|
191
|
+
lines.push(" oracle setup telegram configure telegram bot token");
|
|
192
|
+
lines.push(" oracle setup discord configure discord bot token");
|
|
193
|
+
lines.push(" oracle setup status show configured platforms (no secrets)");
|
|
194
|
+
lines.push(" oracle setup gateway start/status hermes gateway");
|
|
195
|
+
lines.push(" /setup same menu inside chat");
|
|
196
|
+
lines.push("");
|
|
197
|
+
lines.push("notes:");
|
|
198
|
+
lines.push(" tokens stay in the hermes profile .env on this machine");
|
|
199
|
+
lines.push(" oracle never prints bot tokens or app secrets");
|
|
200
|
+
lines.push(" after setup: hermes -p oracle gateway restart");
|
|
201
|
+
return lines.join("\n") + "\n";
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
export default {
|
|
205
|
+
MESSAGING_PLATFORMS,
|
|
206
|
+
listMessagingPlatforms,
|
|
207
|
+
findMessagingPlatform,
|
|
208
|
+
renderSetupMenu,
|
|
209
|
+
};
|