oomi-ai 0.12.2 → 0.14.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 +2 -0
- package/bin/oomi-ai.js +101 -75
- package/lib/agentChannels.js +42 -3
- package/lib/agentIdentity.js +3 -1
- package/lib/chatModels.js +93 -0
- package/lib/gatewayProbe.js +29 -5
- package/lib/gatewayRuns.js +29 -0
- package/lib/hermesAcp.js +53 -76
- package/lib/hermesGateway.js +213 -8
- package/lib/localAgent.js +461 -43
- package/lib/openclawModels.js +71 -0
- package/lib/runtimeFailure.js +2 -0
- package/lib/updateWatcher.js +56 -0
- package/package.json +6 -2
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// `/model` in Talk for OpenClaw personas (docs/specs/chat-models-v1.md). The bridge asks
|
|
2
|
+
// OpenClaw's own gateway methods and answers in oomi's shape: models.list (view "configured":
|
|
3
|
+
// configured models and providers with usable auth) for the choices, chat.history's
|
|
4
|
+
// sessionInfo for the conversation's model, and sessions.patch to switch that session.
|
|
5
|
+
import { ChatModelsError, matchModel, modelChoice, modelsAnswer, openclawEntries } from './chatModels.js';
|
|
6
|
+
|
|
7
|
+
const MODELS = '::oomi-models';
|
|
8
|
+
const SESSION = '::oomi-session';
|
|
9
|
+
const SET = '::oomi-set';
|
|
10
|
+
const STALE_MS = 60 * 1000;
|
|
11
|
+
|
|
12
|
+
function parse(text) { try { const value = JSON.parse(text); return value && typeof value === 'object' ? value : null; } catch { return null; } }
|
|
13
|
+
function request(id, method, params) { return JSON.stringify({ type: 'req', id, method, params }); }
|
|
14
|
+
function answer(id, payload) { return JSON.stringify({ type: 'res', id, ok: true, payload }); }
|
|
15
|
+
function failure(id, code) { const error = new ChatModelsError(code); return JSON.stringify({ type: 'res', id, ok: false, error: { code: error.code, message: error.message } }); }
|
|
16
|
+
|
|
17
|
+
export class OpenclawModelRequests {
|
|
18
|
+
constructor({ now = () => Date.now() } = {}) { this.now = now; this.pending = new Map(); this.entries = []; }
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* For an oomi.models.* request: `{ frames }` to send OpenClaw instead, or `{ reply }` to answer
|
|
22
|
+
* the app straight away. Null for every other frame.
|
|
23
|
+
*/
|
|
24
|
+
plan(frameText) {
|
|
25
|
+
const frame = parse(frameText);
|
|
26
|
+
if (frame?.type !== 'req' || (frame.method !== 'oomi.models.list' && frame.method !== 'oomi.models.set')) return null;
|
|
27
|
+
for (const [id, entry] of this.pending) if (this.now() - entry.at > STALE_MS) this.pending.delete(id);
|
|
28
|
+
const id = typeof frame.id === 'string' || typeof frame.id === 'number' ? String(frame.id) : '';
|
|
29
|
+
const sessionKey = typeof frame.params?.sessionKey === 'string' ? frame.params.sessionKey.trim() : '';
|
|
30
|
+
if (!id || !sessionKey) return { reply: failure(id, 'unavailable') };
|
|
31
|
+
if (frame.method === 'oomi.models.list') {
|
|
32
|
+
this.pending.set(id, { kind: 'list', at: this.now() });
|
|
33
|
+
return { frames: [request(id + MODELS, 'models.list', { view: 'configured' }), request(id + SESSION, 'chat.history', { sessionKey, limit: 1 })] };
|
|
34
|
+
}
|
|
35
|
+
const typed = typeof frame.params?.model === 'string' ? frame.params.model.trim() : '';
|
|
36
|
+
if (!typed || typed.length > 300) return { reply: failure(id, 'unknown_model') };
|
|
37
|
+
this.pending.set(id, { kind: 'set', at: this.now() });
|
|
38
|
+
return { frames: [request(id + SET, 'sessions.patch', { key: sessionKey, model: matchModel(typed, this.entries) })] };
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* For OpenClaw's answer to one of those frames: `{ reply }` once oomi's answer is complete, or
|
|
43
|
+
* `{}` while it waits for the other half. Either way the frame itself goes no further. Null for
|
|
44
|
+
* every other frame.
|
|
45
|
+
*/
|
|
46
|
+
take(frameText) {
|
|
47
|
+
const frame = parse(frameText);
|
|
48
|
+
if (frame?.type !== 'res' || typeof frame.id !== 'string') return null;
|
|
49
|
+
const suffix = [MODELS, SESSION, SET].find((end) => frame.id.endsWith(end));
|
|
50
|
+
const id = suffix ? frame.id.slice(0, -suffix.length) : '';
|
|
51
|
+
const entry = suffix && this.pending.get(id);
|
|
52
|
+
if (!entry) return null;
|
|
53
|
+
if (suffix === SET) {
|
|
54
|
+
this.pending.delete(id);
|
|
55
|
+
if (!frame.ok) return { reply: failure(id, frame.error?.code === 'INVALID_REQUEST' ? 'unknown_model' : 'unavailable') };
|
|
56
|
+
const resolved = frame.payload?.resolved;
|
|
57
|
+
const current = resolved?.modelProvider && resolved?.model ? `${resolved.modelProvider}/${resolved.model}` : '';
|
|
58
|
+
return { reply: answer(id, { scope: 'conversation', current: modelChoice(current, this.entries) }) };
|
|
59
|
+
}
|
|
60
|
+
if (suffix === MODELS) entry.models = frame.ok && Array.isArray(frame.payload?.models) ? openclawEntries(frame.payload.models) : null;
|
|
61
|
+
else {
|
|
62
|
+
const info = frame.ok ? frame.payload?.sessionInfo : null;
|
|
63
|
+
entry.current = info?.modelProvider && info?.model ? `${info.modelProvider}/${info.model}` : '';
|
|
64
|
+
}
|
|
65
|
+
if (entry.models === undefined || entry.current === undefined) return {};
|
|
66
|
+
this.pending.delete(id);
|
|
67
|
+
if (!entry.models) return { reply: failure(id, 'unavailable') };
|
|
68
|
+
this.entries = entry.models;
|
|
69
|
+
return { reply: answer(id, modelsAnswer({ current: entry.current, entries: entry.models })) };
|
|
70
|
+
}
|
|
71
|
+
}
|
package/lib/runtimeFailure.js
CHANGED
|
@@ -15,6 +15,7 @@ export const FAILURE_SUMMARIES = {
|
|
|
15
15
|
model_unavailable: "its AI provider couldn't be reached",
|
|
16
16
|
runtime_timeout: 'it took too long to answer',
|
|
17
17
|
runtime_failed: 'its agent runtime stopped with an error',
|
|
18
|
+
guest_sandbox_unavailable: "its agent runtime can't answer guests with its tools turned off",
|
|
18
19
|
};
|
|
19
20
|
|
|
20
21
|
export const FAILURE_HINTS = {
|
|
@@ -23,6 +24,7 @@ export const FAILURE_HINTS = {
|
|
|
23
24
|
model_unavailable: 'Check this computer is online and the provider is up, then try again.',
|
|
24
25
|
runtime_timeout: 'Try again with a shorter request, or check the agent runtime is responsive.',
|
|
25
26
|
runtime_failed: 'Check the agent runtime logs on this computer, then try again.',
|
|
27
|
+
guest_sandbox_unavailable: 'Chat links and agent channels need a Hermes or OpenClaw persona, which can answer guests without running commands or touching files.',
|
|
26
28
|
};
|
|
27
29
|
|
|
28
30
|
export function redactDetail(text, limit = 300) {
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// Keeps the persona's oomi-ai current (Justin, 2026-10-25: "make sure the package always requests
|
|
2
|
+
// the agent to stay up to date to avoid security risks"). The running bridge checks npm and, once
|
|
3
|
+
// per new version, asks its agent to update through the agent's own approval flow, or to tell its
|
|
4
|
+
// owner. It never installs anything itself. OOMI_UPDATE_NOTICES=0 turns it off.
|
|
5
|
+
import { readJson, writePrivateJson } from './localAgent.js';
|
|
6
|
+
|
|
7
|
+
export const UPDATE_CHECK_EVERY_MS = 6 * 60 * 60 * 1000;
|
|
8
|
+
const VERSION = /^\d+\.\d+\.\d+$/;
|
|
9
|
+
|
|
10
|
+
export function newerVersion(current, latest) {
|
|
11
|
+
if (!VERSION.test(String(current)) || !VERSION.test(String(latest))) return false;
|
|
12
|
+
const a = current.split('.').map(Number);
|
|
13
|
+
const b = latest.split('.').map(Number);
|
|
14
|
+
const difference = b.map((value, index) => value - a[index]).find((value) => value !== 0) || 0;
|
|
15
|
+
return difference > 0;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function updateNotice({ current, latest, connection = '' }) {
|
|
19
|
+
const name = connection ? ` --name ${connection}` : '';
|
|
20
|
+
const conn = connection ? ` --connection ${connection}` : '';
|
|
21
|
+
return `Oomi maintenance notice from the oomi-ai bridge on this computer (not from a person): oomi-ai ${latest} is out; this computer has ${current}. ` +
|
|
22
|
+
'New versions carry security fixes, so keep it current.\n' +
|
|
23
|
+
`1. Run oomi update${conn} for the exact install command, and run that command alone through your normal approval flow.\n` +
|
|
24
|
+
`2. After it succeeds, check the installed version, then run oomi bridge repair${name}.\n` +
|
|
25
|
+
`If you can't (it needs approval you don't have, or you have no terminal here), tell your owner: oomi notify "oomi-ai on this computer needs an update to ${latest}: npm install -g oomi-ai@${latest}"${conn}\n` +
|
|
26
|
+
'Never change security settings or approvals to do this. Reply with one line saying what you did.';
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Checks after `firstDelayMs`, then every `intervalMs`. `deliver` runs one agent turn (the same
|
|
31
|
+
* path as identity and routine notices); `onStatus` records what's available for oomi status.
|
|
32
|
+
*/
|
|
33
|
+
export function startUpdateWatcher({ current, fetchLatest, deliver, sessionKey, receiptPath, connection = '', onStatus = () => {}, intervalMs = UPDATE_CHECK_EVERY_MS, firstDelayMs = 60 * 1000, env = process.env }) {
|
|
34
|
+
if (String(env.OOMI_UPDATE_NOTICES || '').trim() === '0' || !VERSION.test(String(current))) return () => {};
|
|
35
|
+
let stopped = false;
|
|
36
|
+
let timer;
|
|
37
|
+
const check = async () => {
|
|
38
|
+
try {
|
|
39
|
+
const latest = String(await fetchLatest() || '').trim();
|
|
40
|
+
if (stopped || !VERSION.test(latest)) return;
|
|
41
|
+
if (!newerVersion(current, latest)) { onStatus({ updateAvailable: '' }); return; }
|
|
42
|
+
onStatus({ updateAvailable: latest });
|
|
43
|
+
const receipt = readJson(receiptPath, {});
|
|
44
|
+
if (receipt.notifiedVersion === latest) return;
|
|
45
|
+
await deliver({ sessionKey, idempotencyKey: `oomi-update:${latest}`, message: updateNotice({ current, latest, connection }) });
|
|
46
|
+
writePrivateJson(receiptPath, { notifiedVersion: latest, notifiedAt: new Date().toISOString() });
|
|
47
|
+
} catch {
|
|
48
|
+
// A missed check or notice is tried again at the next interval.
|
|
49
|
+
} finally {
|
|
50
|
+
if (!stopped) { timer = setTimeout(check, intervalMs); timer.unref?.(); }
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
timer = setTimeout(check, firstDelayMs);
|
|
54
|
+
timer.unref?.();
|
|
55
|
+
return () => { stopped = true; clearTimeout(timer); };
|
|
56
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oomi-ai",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"description": "Connect OpenClaw, Hermes, Grok Bot, and other agents to Oomi with verified runtime adapters",
|
|
5
5
|
"bin": {
|
|
6
6
|
"oomi": "bin/oomi-ai.js"
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"url": "https://github.com/crispcode-io/oomi/issues"
|
|
50
50
|
},
|
|
51
51
|
"scripts": {
|
|
52
|
-
"check": "node --check bin/oomi-ai.js && node --check lib/bridgeService.js && node --check lib/bridgeMaintenance.js && node --check lib/processTable.js && node --check lib/localAgent.js && node --check lib/hermesGateway.js && node --check lib/hermesAcp.js && node --check lib/grokbotRuntime.js && node --check lib/connectionSetup.js && node --check lib/processSupervisor.js && node --check lib/agentChannels.js && node --check lib/runtimeFailure.js",
|
|
52
|
+
"check": "node --check bin/oomi-ai.js && node --check lib/bridgeService.js && node --check lib/bridgeMaintenance.js && node --check lib/gatewayRuns.js && node --check lib/processTable.js && node --check lib/localAgent.js && node --check lib/chatModels.js && node --check lib/openclawModels.js && node --check lib/updateWatcher.js && node --check lib/hermesGateway.js && node --check lib/hermesAcp.js && node --check lib/grokbotRuntime.js && node --check lib/connectionSetup.js && node --check lib/processSupervisor.js && node --check lib/agentChannels.js && node --check lib/runtimeFailure.js",
|
|
53
53
|
"test": "node --test test/*.test.mjs",
|
|
54
54
|
"prepublishOnly": "npm run check && node --test test/packageFiles.test.mjs"
|
|
55
55
|
},
|
|
@@ -60,6 +60,7 @@
|
|
|
60
60
|
"files": [
|
|
61
61
|
"bin/oomi-ai.js",
|
|
62
62
|
"bin/sessionBridgeState.js",
|
|
63
|
+
"lib/gatewayRuns.js",
|
|
63
64
|
"lib/modelRelayClient.js",
|
|
64
65
|
"lib/openclawPaths.js",
|
|
65
66
|
"lib/openclawProfile.js",
|
|
@@ -74,6 +75,9 @@
|
|
|
74
75
|
"skills/oomi/agent_instructions.md",
|
|
75
76
|
"lib/gatewayProbe.js",
|
|
76
77
|
"lib/localAgent.js",
|
|
78
|
+
"lib/chatModels.js",
|
|
79
|
+
"lib/openclawModels.js",
|
|
80
|
+
"lib/updateWatcher.js",
|
|
77
81
|
"lib/agentIdentity.js",
|
|
78
82
|
"lib/routines.js",
|
|
79
83
|
"lib/spaces.js",
|