@0perator/operator 0.1.263 → 0.1.275
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/dist/auth/store.js +36 -5
- package/dist/cli.js +119 -26
- package/dist/config/persona.js +14 -1
- package/dist/engine/agent.js +4 -4
- package/dist/engine/anthropic.js +48 -0
- package/dist/engine/batch-scheduler.js +68 -21
- package/dist/engine/cli.js +1171 -0
- package/dist/mcp/index.js +2 -1
- package/dist/permissions/index.js +11 -4
- package/dist/remote/host.js +46 -5
- package/dist/remote/pairing.js +70 -0
- package/dist/router/models.js +8 -1
- package/dist/router/models.js.bak +78 -0
- package/dist/router/models.js.bak-1791259923 +78 -0
- package/dist/router/models.js.bak-pre-gateway +78 -0
- package/dist/router/models.js.bak-pre-patch2 +78 -0
- package/dist/router/models.js.bak2 +78 -0
- package/dist/services/model-autodetect.js +240 -0
- package/dist/tools/chauffeur.js +16 -3
- package/dist/tools/deferred.js +2 -1
- package/dist/tools/executor.js +15 -3
- package/dist/tools/native-redirect.js +140 -0
- package/dist/tools/power-tools.js +627 -0
- package/dist/tools/registry.js +252 -5
- package/dist/tools/registry.js.bak-1791259948 +1914 -0
- package/dist/tools/registry.js.bak-pre-plugins +1914 -0
- package/dist/ui/App.js +5 -4
- package/dist/ui/BusTray.js +70 -0
- package/dist/ui/Composer.js +28 -1
- package/dist/ui/ToolStep.js +1 -1
- package/dist/ui/format.js +18 -0
- package/dist/ui/liveTools.js +2 -5
- package/dist/ui/qr.js +10 -0
- package/dist/ui/resize.js +160 -0
- package/dist/ui/slashCommands.js +43 -0
- package/dist/ui/term.js +17 -0
- package/dist/util/slash.js +1 -1
- package/package.json +3 -1
package/dist/mcp/index.js
CHANGED
|
@@ -139,7 +139,7 @@ export function withMcp(local, hub) {
|
|
|
139
139
|
classify: (n) => (hub?.has(n) ? "write" : local.sched ? local.sched.classify(n) : "write"),
|
|
140
140
|
keys: (n, a) => (hub?.has(n) ? ["mcp:" + n.split(":")[0]] : local.sched ? local.sched.keys(n, a) : defaultKeys(n, a)),
|
|
141
141
|
},
|
|
142
|
-
executeParallel: (calls, onSettle) => runBatch(calls, {
|
|
142
|
+
executeParallel: (calls, onSettle, signal) => runBatch(calls, {
|
|
143
143
|
classify: (n) => (hub?.has(n) ? "write" : local.sched ? local.sched.classify(n) : "write"),
|
|
144
144
|
keys: (n, a) => (hub?.has(n) ? ["mcp:" + n.split(":")[0]] : local.sched ? local.sched.keys(n, a) : defaultKeys(n, a)),
|
|
145
145
|
runOne: (c) => {
|
|
@@ -147,6 +147,7 @@ export function withMcp(local, hub) {
|
|
|
147
147
|
return hub?.has(sc.name) ? hub.call(sc.name, sc.args) : local.execute(sc.name, sc.args);
|
|
148
148
|
},
|
|
149
149
|
onSettle,
|
|
150
|
+
signal,
|
|
150
151
|
}),
|
|
151
152
|
};
|
|
152
153
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { digestArgs } from "./audit.js";
|
|
2
2
|
import { EventSink } from "../telemetry/events.js";
|
|
3
|
-
import { runBatch, defaultClassify, defaultKeys } from "../engine/batch-scheduler.js";
|
|
3
|
+
import { runBatch, defaultClassify, defaultKeys, cancelledResult } from "../engine/batch-scheduler.js";
|
|
4
4
|
import { registrySafeTools } from "./tier.js";
|
|
5
5
|
export { PermissionPolicy } from "./policy.js";
|
|
6
6
|
const DENIED = (name) => `Permission denied: "${name}" was refused by the operator permission policy. ` +
|
|
@@ -17,7 +17,7 @@ export function withPermissions(inner, policy, opts = {}) {
|
|
|
17
17
|
// `batch` carries the round identity a PendingToolCall was stamped with (engine/agent.ts's
|
|
18
18
|
// runToolCalls) onto every ToolEvent this call emits — absent for the single-call execute() path,
|
|
19
19
|
// which has no round context.
|
|
20
|
-
async function gate(name, args, exec, batch) {
|
|
20
|
+
async function gate(name, args, exec, batch, signal) {
|
|
21
21
|
const digest = digestArgs(name, args);
|
|
22
22
|
const decision = policy.decide(name, args);
|
|
23
23
|
const t0 = performance.now();
|
|
@@ -44,6 +44,12 @@ export function withPermissions(inner, policy, opts = {}) {
|
|
|
44
44
|
return DENIED(name);
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
+
// An esc during the (human) approval wait: the approval may land AFTER the interrupt, and an approved edit
|
|
48
|
+
// must not then execute. Recorded as an error (the wire outcome enum is frozen; nothing was refused by policy).
|
|
49
|
+
if (signal?.aborted) {
|
|
50
|
+
tool({ name, args: digest, decision, outcome: "error", approved, durationMs: performance.now() - t0, ...batch });
|
|
51
|
+
return cancelledResult(name);
|
|
52
|
+
}
|
|
47
53
|
let result;
|
|
48
54
|
try {
|
|
49
55
|
result = await exec();
|
|
@@ -64,7 +70,7 @@ export function withPermissions(inner, policy, opts = {}) {
|
|
|
64
70
|
// but conflicting resources serialize in input order through the shared DAG scheduler. The old
|
|
65
71
|
// Promise.all-over-execute() dropped the 0.1.225 walk at this layer: a gated batch of
|
|
66
72
|
// [write f, read f] raced, the read deterministically observing pre-write state on slow writes.
|
|
67
|
-
executeParallel: (calls, onSettle) => {
|
|
73
|
+
executeParallel: (calls, onSettle, signal) => {
|
|
68
74
|
const safe = new Set(registrySafeTools());
|
|
69
75
|
return runBatch(calls, {
|
|
70
76
|
// prefer the INNER executor's classification truth (per-session toolset); fall back to the
|
|
@@ -76,9 +82,10 @@ export function withPermissions(inner, policy, opts = {}) {
|
|
|
76
82
|
const batch = sc.batchId !== undefined
|
|
77
83
|
? { batchId: sc.batchId, batchSize: sc.batchSize ?? calls.length, batchIndex: sc.batchIndex ?? calls.findIndex((x) => x.id === sc.id) }
|
|
78
84
|
: undefined;
|
|
79
|
-
return gate(sc.name, sc.args, () => inner.execute(sc.name, sc.args), batch);
|
|
85
|
+
return gate(sc.name, sc.args, () => inner.execute(sc.name, sc.args), batch, signal);
|
|
80
86
|
},
|
|
81
87
|
onSettle,
|
|
88
|
+
signal,
|
|
82
89
|
});
|
|
83
90
|
},
|
|
84
91
|
};
|
package/dist/remote/host.js
CHANGED
|
@@ -1,4 +1,15 @@
|
|
|
1
|
+
import { frameKey as deriveFrameKey, pairingId as derivePairingId, encryptFrame, decryptFrame } from "./pairing.js";
|
|
1
2
|
const V = 1;
|
|
3
|
+
// Paired (QR) mode: only DATA-frame payloads are e2e-encrypted; the header (v/type/sessionId/seq/ts) and
|
|
4
|
+
// control frames stay plaintext so the relay can route blind. These sets mirror the mobile's frozen
|
|
5
|
+
// dataFrameTypes byte-for-byte (kode-mobile RemoteSession.swift). The INNER encrypted bytes are
|
|
6
|
+
// JSON.stringify(payloadDict) — just the payload dict, never {type,payload}.
|
|
7
|
+
const DATA_HOST_TYPES = new Set(["snapshot", "transcript", "tool_step", "activity", "status", "capabilities", "approval_request", "ask_user", "delta"]);
|
|
8
|
+
const DATA_DRIVE_TYPES = new Set(["prompt", "command", "approval_response", "ask_user_response", "interrupt"]);
|
|
9
|
+
// A paired snapshot is encrypted (base64 ≈ 1.37× plaintext), and the relay drops/truncates any frame over
|
|
10
|
+
// its 256 KB cap — which would corrupt ciphertext. Cap the paired snapshot's plaintext so the encrypted
|
|
11
|
+
// frame stays comfortably under 256 KB; token-mode keeps the full 512 KB budget.
|
|
12
|
+
const SNAPSHOT_MAX_BYTES_PAIRED = 170 * 1024;
|
|
2
13
|
// SPEC §8 limits (relay-enforced per spec, but host.ts didn't honor either one — REMOTE_RICH_HEAD_AUDIT.md
|
|
3
14
|
// §1/§4 BLOCKER: this repo's own MCP surface is 600+ tools across a handful of servers, which put
|
|
4
15
|
// `capabilities.mcpServers` alone at 70-100+ KB before this fix, on top of an already-uncapped transcript.
|
|
@@ -45,11 +56,23 @@ export class RemoteHost {
|
|
|
45
56
|
livePending = null;
|
|
46
57
|
turnN = 0;
|
|
47
58
|
capabilities = null;
|
|
48
|
-
|
|
59
|
+
// Paired (QR) mode — set from the one-time code the owner shows as a QR. When paired, the host registers
|
|
60
|
+
// its pairingId with the relay and e2e-encrypts every DATA-frame payload with frameKey; the relay (and
|
|
61
|
+
// anyone but the scanning phone) sees only ciphertext.
|
|
62
|
+
paired = false;
|
|
63
|
+
frameKey = null;
|
|
64
|
+
pairingId = null;
|
|
65
|
+
constructor(url, token, meta, cb, pairing) {
|
|
49
66
|
this.url = url;
|
|
50
67
|
this.token = token;
|
|
51
68
|
this.meta = meta;
|
|
52
69
|
this.cb = cb;
|
|
70
|
+
if (pairing) {
|
|
71
|
+
this.sessionId = pairing.sessionId; // deterministic, so the QR's s=<sessionId> is known before connect
|
|
72
|
+
this.paired = true;
|
|
73
|
+
this.frameKey = deriveFrameKey(pairing.code);
|
|
74
|
+
this.pairingId = derivePairingId(pairing.code);
|
|
75
|
+
}
|
|
53
76
|
}
|
|
54
77
|
connect() {
|
|
55
78
|
this.cb.onState?.("connecting");
|
|
@@ -93,11 +116,24 @@ export class RemoteHost {
|
|
|
93
116
|
}
|
|
94
117
|
if (f.v !== V)
|
|
95
118
|
return;
|
|
119
|
+
// Paired mode: a follower's DATA (drive) frame carries an encrypted payload string — decrypt it back to
|
|
120
|
+
// the payload dict before the switch reads f.payload.text / .id / etc. Control frames (welcome, attach,
|
|
121
|
+
// error) stay plaintext and skip this. An undecryptable frame (wrong key / tamper) is dropped.
|
|
122
|
+
if (this.paired && DATA_DRIVE_TYPES.has(f.type) && typeof f.payload === "string") {
|
|
123
|
+
try {
|
|
124
|
+
f.payload = JSON.parse(decryptFrame(this.frameKey, f.payload).toString("utf8"));
|
|
125
|
+
}
|
|
126
|
+
catch {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
96
130
|
switch (f.type) {
|
|
97
131
|
case "welcome":
|
|
98
132
|
this.sessionId = f.payload?.sessionId ?? this.sessionId;
|
|
99
133
|
this.ownerSub = f.payload?.ownerSub ?? null;
|
|
100
134
|
this.send("register", this.sessionId, { title: this.meta.title, surface: this.meta.surface ?? "cli", cwd: this.meta.cwd, host: this.meta.host });
|
|
135
|
+
if (this.paired && this.pairingId)
|
|
136
|
+
this.send("pair-register", this.sessionId, { pairingId: this.pairingId }); // control frame (plaintext) — binds pairingId -> this session at the relay
|
|
101
137
|
this.cb.onState?.("live");
|
|
102
138
|
break;
|
|
103
139
|
case "attach": // a follower joined — send a full snapshot BEFORE any further delta (§8)
|
|
@@ -152,7 +188,12 @@ export class RemoteHost {
|
|
|
152
188
|
send(type, sessionId, payload, seq = null) {
|
|
153
189
|
if (!this.ws || this.ws.readyState !== 1)
|
|
154
190
|
return;
|
|
155
|
-
|
|
191
|
+
// Paired mode: encrypt the payload of DATA frames (control frames — hello/register/pair-register — stay
|
|
192
|
+
// plaintext so the relay routes them). INNER = JSON.stringify(payloadDict); wire payload = base64(iv||ct||tag).
|
|
193
|
+
const wirePayload = this.paired && this.frameKey && DATA_HOST_TYPES.has(type) && payload != null
|
|
194
|
+
? encryptFrame(this.frameKey, Buffer.from(JSON.stringify(payload)))
|
|
195
|
+
: payload;
|
|
196
|
+
const frame = { v: V, type, sessionId: sessionId ?? this.sessionId, seq, ts: Date.now(), payload: wirePayload };
|
|
156
197
|
try {
|
|
157
198
|
this.ws.send(JSON.stringify(frame));
|
|
158
199
|
}
|
|
@@ -161,7 +202,7 @@ export class RemoteHost {
|
|
|
161
202
|
state(type, payload) { this.send(type, this.sessionId, payload, ++this.seq); }
|
|
162
203
|
sendSnapshot() {
|
|
163
204
|
this.flushLive();
|
|
164
|
-
const { transcript, truncated, omittedBefore } = this.capTranscript(this.entries);
|
|
205
|
+
const { transcript, truncated, omittedBefore } = this.capTranscript(this.entries, this.paired ? SNAPSHOT_MAX_BYTES_PAIRED : SNAPSHOT_MAX_BYTES);
|
|
165
206
|
this.send("snapshot", this.sessionId, {
|
|
166
207
|
transcript, activity: this.activity, status: { ctxPct: this.ctxPct, route: this.route, ...(this.tokens != null ? { tokens: this.tokens } : {}) },
|
|
167
208
|
...(truncated ? { truncated: true, omittedBefore } : {}),
|
|
@@ -174,14 +215,14 @@ export class RemoteHost {
|
|
|
174
215
|
* time (entries carry no seq of their own): enough for a follower to know only scrollback before
|
|
175
216
|
* "now" was cut, not that live driving is affected. Cheap to call on every attach — at most O(200)
|
|
176
217
|
* serializations of a shrinking slice, and attach is not a hot path. */
|
|
177
|
-
capTranscript(entries) {
|
|
218
|
+
capTranscript(entries, maxBytes = SNAPSHOT_MAX_BYTES) {
|
|
178
219
|
let out = entries;
|
|
179
220
|
let truncated = false;
|
|
180
221
|
if (out.length > SNAPSHOT_MAX_ENTRIES) {
|
|
181
222
|
out = out.slice(-SNAPSHOT_MAX_ENTRIES);
|
|
182
223
|
truncated = true;
|
|
183
224
|
}
|
|
184
|
-
while (out.length > 1 && byteLen(out) >
|
|
225
|
+
while (out.length > 1 && byteLen(out) > maxBytes) {
|
|
185
226
|
out = out.slice(1);
|
|
186
227
|
truncated = true;
|
|
187
228
|
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// Operator RC pairing crypto — the DESKTOP (host) half of the mobile "Pair Desktop" flow.
|
|
2
|
+
// Byte-for-byte conformant with the mobile Swift CryptoKit impl (kode-mobile PairingCrypto.swift); the
|
|
3
|
+
// frozen test vectors in test/pairing.test.mts pin it so the two can never drift. The RELAY needs none of
|
|
4
|
+
// this — it routes by the opaque `pairingId` and stays blind; only the host and the phone hold frameKey.
|
|
5
|
+
//
|
|
6
|
+
// Contract (frozen on the mobile side):
|
|
7
|
+
// code = 16 random bytes (crypto.randomBytes(16)). NEVER sent to the relay.
|
|
8
|
+
// QR / link = `operator://pair?c=<base64url(code),no-pad>&s=<sessionId>`
|
|
9
|
+
// pairingId = sha256(code) hex -> sent to the relay (the blind id)
|
|
10
|
+
// frameKey = HKDF-SHA256(ikm=code, salt="operator-pair-v1", info="e2e-frame-key", 32)
|
|
11
|
+
// DATA frame = base64( iv(12) || ciphertext || gcm-tag(16) ), aes-256-gcm, fresh iv, no AAD
|
|
12
|
+
// Only DATA frames are encrypted; control frames (pair-register, pair-join, welcome, sessions,
|
|
13
|
+
// attach, detach, error) stay plaintext so the relay can route them.
|
|
14
|
+
import crypto from "node:crypto";
|
|
15
|
+
export function b64url(buf) {
|
|
16
|
+
return Buffer.from(buf).toString("base64").replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
17
|
+
}
|
|
18
|
+
export function b64urlDecode(s) {
|
|
19
|
+
let t = s.replace(/-/g, "+").replace(/_/g, "/");
|
|
20
|
+
while (t.length % 4)
|
|
21
|
+
t += "=";
|
|
22
|
+
return Buffer.from(t, "base64");
|
|
23
|
+
}
|
|
24
|
+
/** A fresh 128-bit pairing secret. Stays on the desktop + the phone that scans it; never touches the relay. */
|
|
25
|
+
export function newCode() {
|
|
26
|
+
return crypto.randomBytes(16);
|
|
27
|
+
}
|
|
28
|
+
/** pairingId = hex(SHA256(code)) — the blind id the relay routes by. */
|
|
29
|
+
export function pairingId(code) {
|
|
30
|
+
return crypto.createHash("sha256").update(code).digest("hex");
|
|
31
|
+
}
|
|
32
|
+
/** frameKey = HKDF-SHA256(code, "operator-pair-v1", "e2e-frame-key", 32). Node hkdfSync is RFC-5869,
|
|
33
|
+
* which is exactly what CryptoKit's HKDF uses, so host and phone derive the same key. */
|
|
34
|
+
export function frameKey(code) {
|
|
35
|
+
return Buffer.from(crypto.hkdfSync("sha256", code, Buffer.from("operator-pair-v1"), Buffer.from("e2e-frame-key"), 32));
|
|
36
|
+
}
|
|
37
|
+
/** encryptFrame(key, plaintextBytes) -> base64( iv(12) || ciphertext || gcm-tag(16) ). */
|
|
38
|
+
export function encryptFrame(key, plaintext, iv = crypto.randomBytes(12)) {
|
|
39
|
+
const c = crypto.createCipheriv("aes-256-gcm", key, iv);
|
|
40
|
+
const ct = Buffer.concat([c.update(plaintext), c.final()]);
|
|
41
|
+
return Buffer.concat([iv, ct, c.getAuthTag()]).toString("base64");
|
|
42
|
+
}
|
|
43
|
+
/** decryptFrame(key, base64) -> Buffer. Throws on tamper / wrong key (GCM auth). */
|
|
44
|
+
export function decryptFrame(key, b64) {
|
|
45
|
+
const raw = Buffer.from(b64, "base64");
|
|
46
|
+
const iv = raw.subarray(0, 12);
|
|
47
|
+
const tag = raw.subarray(raw.length - 16);
|
|
48
|
+
const ct = raw.subarray(12, raw.length - 16);
|
|
49
|
+
const d = crypto.createDecipheriv("aes-256-gcm", key, iv);
|
|
50
|
+
d.setAuthTag(tag);
|
|
51
|
+
return Buffer.concat([d.update(ct), d.final()]);
|
|
52
|
+
}
|
|
53
|
+
/** The scannable payload: `operator://pair?c=<b64url(code)>&s=<sessionId>` (valid scheme for the QR). */
|
|
54
|
+
export function pairURL(code, sessionId) {
|
|
55
|
+
return `operator://pair?c=${b64url(code)}&s=${encodeURIComponent(sessionId)}`;
|
|
56
|
+
}
|
|
57
|
+
/** Parse a QR/paste payload. Accepts operator://…, 0perator://… (digit-leading), or a bare query string —
|
|
58
|
+
* mirrors the mobile parser. Returns null unless it carries a 16-byte code + a sessionId. */
|
|
59
|
+
export function parsePairURL(raw) {
|
|
60
|
+
const t = (raw || "").trim();
|
|
61
|
+
const q = t.includes("?") ? t.slice(t.indexOf("?") + 1) : t;
|
|
62
|
+
const p = new URLSearchParams(q);
|
|
63
|
+
const c = p.get("c"), s = p.get("s");
|
|
64
|
+
if (!c || !s)
|
|
65
|
+
return null;
|
|
66
|
+
const code = b64urlDecode(c);
|
|
67
|
+
if (code.length !== 16)
|
|
68
|
+
return null;
|
|
69
|
+
return { code, sessionId: s };
|
|
70
|
+
}
|
package/dist/router/models.js
CHANGED
|
@@ -36,7 +36,7 @@ export const BUILTIN_MODELS = [
|
|
|
36
36
|
// truncated a round at token 32767 (finish=length) mid-tool-call, and that cut call poisoned the session (0.1.259).
|
|
37
37
|
// 32000 sits just UNDER the real wall (margin) AND under LEAN_HARNESS_CTX so Cortana drops the heavy memory/handoff
|
|
38
38
|
// (which alone was ~16K = half the window) — persona + unrestricted layer kept. Raise ONLY if the server's --ctx-size does.
|
|
39
|
-
{ id: "cortana", label: "Cortana 35B", kind: "single", desc: "flagship — abliterated Qwen3.6-35B-A3B MoE (~3B active, ~40 tok/s), uncensored + vision (JL1:8112, llama.cpp,
|
|
39
|
+
{ id: "cortana", label: "Cortana 35B", kind: "single", desc: "flagship — abliterated Qwen3.6-35B-A3B MoE (~3B active, ~40 tok/s), uncensored + vision (JL1:8112, llama.cpp, 256K ctx)", endpoint: "http://192.168.1.103:8112/v1", model: "/Volumes/Ai Storage/jl1-local/models/aurorax/Huihui-Qwen3.6-35B-A3B-abliterated.Q4_K_M.gguf", ctx: 262144 },
|
|
40
40
|
// Qwen3-4B — fast LOCAL tier (stock qwen3-4b-mlx-q4, 2.26GB MLX 4-bit, ctx 40960) served via mlx_lm.server
|
|
41
41
|
// on JL1:8110. Qwen3 vocab (151936) — the same family as ghost-32b, so it's the review-recommended quick tier
|
|
42
42
|
// AND the vocab lineage for ghost spec-decode (the actual draft is Qwen3-0.6B, too small to list here). Runs
|
|
@@ -48,6 +48,13 @@ export const BUILTIN_MODELS = [
|
|
|
48
48
|
// JL1:8114 via llama.cpp (--jinja, q8 KV). ctx 32768 ≥ LEAN_HARNESS_CTX → full harness. A quick drop-in to
|
|
49
49
|
// test a smaller/different flavour alongside Spectre without the 35B footprint.
|
|
50
50
|
{ id: "venice-24b", label: "Venice 24B", kind: "single", desc: "lighter uncensored tier — Dolphin-Mistral-24B-Venice + vision (JL1:8114, llama.cpp)", endpoint: "http://192.168.1.103:8114/v1", model: "/Volumes/Ai Storage/exotic-models/dolphin-mistral-24b-venice-gguf/cognitivecomputations_Dolphin-Mistral-24B-Venice-Edition-Q4_K_M.gguf", ctx: 32768 },
|
|
51
|
+
// Code tier for the coding/Replit-clone surface — Qwen2.5-Coder-3B has a real chat template + tool-calling
|
|
52
|
+
// + FIM (ollama reports "completion, tools, insert"), unlike StarCoder2/replit-code (completion-only, can't
|
|
53
|
+
// drive an agent loop). Ollama on JL1, on-demand (loads ~3GB, so SELECT only when JL1 swap has headroom).
|
|
54
|
+
// ctx 32000 stays just under the 32768 train wall (the 0.1.259/260 overrun bug) and below LEAN_HARNESS_CTX
|
|
55
|
+
// so a 3B gets the lean harness. LICENCE: Qwen Research Licence (non-commercial) — fine for owner/eval use;
|
|
56
|
+
// the paid product should use an Apache-2.0 size (qwen2.5-coder 1.5b/7b). transport:"openai" = Ollama /v1.
|
|
57
|
+
{ id: "qwen-coder", label: "Qwen Coder 3B", kind: "single", desc: "code tier — Qwen2.5-Coder-3B Q4_K_M (chat + tool-calling + FIM), Ollama on JL1 (on-demand ~3GB); Qwen Research Licence, non-commercial", endpoint: "http://127.0.0.1:11434/v1", model: "qwen2.5-coder:3b", ctx: 32000, transport: "openai" },
|
|
51
58
|
{ id: "moa", label: "MOA (Mixture of Agents)", kind: "orchestrated", desc: "fan out to proposers, synthesize with an aggregator" },
|
|
52
59
|
];
|
|
53
60
|
/** The runtime registry: the built-ins, with any settings.models entries merged in (overriding a
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
export const DEFAULT_MODEL_ID = "operator-1m";
|
|
2
|
+
// Back-compat aliases: the user-facing ids were renamed aurora-* -> operator-* (the outward name is
|
|
3
|
+
// Operator; "aurora" is the internal model, never shown). The OLD ids still resolve — a persisted
|
|
4
|
+
// settings.activeModel: "aurora-1m", a `/model aurora-1m`, or any muscle memory keeps working — so the
|
|
5
|
+
// rename loses nothing. The served model name ("aurora-code-1") + endpoints stay internal, untouched.
|
|
6
|
+
export const MODEL_ALIASES = {
|
|
7
|
+
"aurora-1m": "operator-1m",
|
|
8
|
+
"aurora-128k": "operator-128k",
|
|
9
|
+
};
|
|
10
|
+
export const BUILTIN_MODELS = [
|
|
11
|
+
{ id: "operator-1m", label: "Operator 300K", kind: "single", desc: "307,200-token (300K) context (:8097)", endpoint: "http://127.0.0.1:8097/v1", model: "aurora-code-1", ctx: 307200 },
|
|
12
|
+
{ id: "operator-128k", label: "Operator 128K", kind: "single", desc: "128K context, lighter RAM (:8096)", endpoint: "http://127.0.0.1:8096/v1", model: "aurora-code-1", ctx: 131072 },
|
|
13
|
+
// QwenCloud Token Plan BYO connectors (SPEC/providers.md §2 "API-key connectors"). Same keychain
|
|
14
|
+
// account ("qwen") serves both; the picker hides them until connected (§1 honest availability), and
|
|
15
|
+
// authHeaders NEVER sends the Operator token to this host. ctx starts conservative and self-clamps
|
|
16
|
+
// to the served truth (observeContext).
|
|
17
|
+
{ id: "qwen3.8-max", label: "Qwen 3.8 Max", kind: "single", desc: "BYO QwenCloud Token Plan — credits from your plan", endpoint: "https://token-plan.maas.qwencloudapi.com/compatible-mode/v1", model: "qwen3.8-max", ctx: 262144, byo: "qwen", transport: "openai" },
|
|
18
|
+
{ id: "qwen3.8-flash", label: "Qwen 3.8 Flash", kind: "single", desc: "BYO QwenCloud Token Plan — fast tier, your credits", endpoint: "https://token-plan.maas.qwencloudapi.com/compatible-mode/v1", model: "qwen3.8-flash", ctx: 262144, byo: "qwen", transport: "openai" },
|
|
19
|
+
// Venice 24B — SELF-HOSTED like Aurora (NOT a third-party connector): the open uncensored weights
|
|
20
|
+
// (Dolphin-Mistral-24B-Venice-Edition Q4_K_M, JL1 Ai Storage) served via llama.cpp on JL1:8110, bound
|
|
21
|
+
// 0.0.0.0 so the engine (on JL2) reaches it over LAN. Uncensored at the weights — answers directly, no
|
|
22
|
+
// retry needed; complements the engine-level unrestricted layer. Runs ALONGSIDE Aurora (:8097); the
|
|
23
|
+
// llama.cpp router health-checks + recovers, and ctx self-clamps to the served truth (observeContext).
|
|
24
|
+
{ id: "venice-24b", label: "Venice 24B (uncensored)", kind: "single", desc: "self-hosted uncensored Dolphin-Mistral-24B-Venice (fleet llama.cpp, JL1:8110)", endpoint: "http://192.168.1.103:8110/v1", model: "dolphin-venice-24b", ctx: 8192 },
|
|
25
|
+
{ id: "moa", label: "MOA (Mixture of Agents)", kind: "orchestrated", desc: "fan out to proposers, synthesize with an aggregator" },
|
|
26
|
+
];
|
|
27
|
+
/** The runtime registry: the built-ins, with any settings.models entries merged in (overriding a
|
|
28
|
+
* built-in by id, or adding a new one) — same shape either way, so /model doesn't care which. */
|
|
29
|
+
export function modelRegistry(overrides) {
|
|
30
|
+
if (!overrides?.length)
|
|
31
|
+
return BUILTIN_MODELS;
|
|
32
|
+
const byId = new Map(BUILTIN_MODELS.map((m) => [m.id, m]));
|
|
33
|
+
for (const m of overrides)
|
|
34
|
+
byId.set(m.id, { ...byId.get(m.id), ...m });
|
|
35
|
+
return [...byId.values()];
|
|
36
|
+
}
|
|
37
|
+
export function findModel(registry, id) {
|
|
38
|
+
const canon = MODEL_ALIASES[id] ?? id; // aurora-1m -> operator-1m (old ids keep resolving)
|
|
39
|
+
return registry.find((m) => m.id === canon);
|
|
40
|
+
}
|
|
41
|
+
/** The configured context window (tokens) for a model id — from BUILTIN_MODELS + settings overrides — or
|
|
42
|
+
* Infinity if unknown. Used to pick a LEAN harness: a small-context model (e.g. a self-hosted 8K Venice)
|
|
43
|
+
* can't take Operator's full memory + handoff injection (sized for Aurora's 300K); it fills the window and
|
|
44
|
+
* the model recites the memory instead of answering. Callers drop the heavy memory/handoff below a
|
|
45
|
+
* threshold while keeping the base persona (incl. the Direct/unrestricted section), so it stays uncensored. */
|
|
46
|
+
export function modelCtxFor(id, overrides) {
|
|
47
|
+
if (!id)
|
|
48
|
+
return Number.POSITIVE_INFINITY;
|
|
49
|
+
return findModel(modelRegistry(overrides), id)?.ctx ?? Number.POSITIVE_INFINITY;
|
|
50
|
+
}
|
|
51
|
+
/** ctx window below which the lean harness (no heavy memory/handoff) kicks in. Aurora/Qwen (128K+) stay
|
|
52
|
+
* full; a self-hosted small model (Venice 8K, or a 16K bump) goes lean. */
|
|
53
|
+
export const LEAN_HARNESS_CTX = 32768;
|
|
54
|
+
/** Pure selection reducer for /model — no I/O (no settings read/write, no router mutation), so it's
|
|
55
|
+
* directly testable. The moa-needs-config check lives in Session.setModel (it needs settings.moa,
|
|
56
|
+
* which this module intentionally doesn't import). `hasByo` (injected by the caller, see auth/byo)
|
|
57
|
+
* gates BYO connector profiles: honest "not connected" beats a request-time 401. */
|
|
58
|
+
export function selectModel(registry, id, hasByo) {
|
|
59
|
+
const profile = findModel(registry, id);
|
|
60
|
+
if (!profile)
|
|
61
|
+
return { error: `unknown model "${id}" — choices: ${registry.map((m) => m.id).join(", ")}` };
|
|
62
|
+
if (profile.kind === "single" && !profile.endpoint)
|
|
63
|
+
return { error: `model "${id}" has no endpoint configured` };
|
|
64
|
+
if (profile.byo && hasByo && !hasByo(profile.byo)) {
|
|
65
|
+
return { error: `"${id}" is not connected — store the ${profile.byo} key first: operator auth byo ${profile.byo}` };
|
|
66
|
+
}
|
|
67
|
+
return { profile };
|
|
68
|
+
}
|
|
69
|
+
/** The picker-truth view of a registry: drops BYO profiles whose key isn't connected (and ALL
|
|
70
|
+
* unresolvable ones when the resolver is absent — a picker must never offer what setModel refuses). */
|
|
71
|
+
export function visibleModels(registry, hasByo) {
|
|
72
|
+
return registry.filter((p) => !p.byo || (hasByo ? hasByo(p.byo) : false));
|
|
73
|
+
}
|
|
74
|
+
/** Strip a trailing /v1 so a ModelProfile/MoaAggregator endpoint can feed the AuroraRouter, whose
|
|
75
|
+
* base is bare (engine/aurora.ts's chat() appends /v1/chat/completions itself). */
|
|
76
|
+
export function endpointBase(endpoint) {
|
|
77
|
+
return endpoint.replace(/\/v1\/?$/, "");
|
|
78
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
export const DEFAULT_MODEL_ID = "operator-1m";
|
|
2
|
+
// Back-compat aliases: the user-facing ids were renamed aurora-* -> operator-* (the outward name is
|
|
3
|
+
// Operator; "aurora" is the internal model, never shown). The OLD ids still resolve — a persisted
|
|
4
|
+
// settings.activeModel: "aurora-1m", a `/model aurora-1m`, or any muscle memory keeps working — so the
|
|
5
|
+
// rename loses nothing. The served model name ("aurora-code-1") + endpoints stay internal, untouched.
|
|
6
|
+
export const MODEL_ALIASES = {
|
|
7
|
+
"aurora-1m": "operator-1m",
|
|
8
|
+
"aurora-128k": "operator-128k",
|
|
9
|
+
};
|
|
10
|
+
export const BUILTIN_MODELS = [
|
|
11
|
+
{ id: "operator-1m", label: "Operator 300K", kind: "single", desc: "307,200-token (300K) context (:8097)", endpoint: "http://127.0.0.1:8097/v1", model: "aurora-code-1", ctx: 307200 },
|
|
12
|
+
{ id: "operator-128k", label: "Operator 128K", kind: "single", desc: "128K context, lighter RAM (:8096)", endpoint: "http://127.0.0.1:8096/v1", model: "aurora-code-1", ctx: 131072 },
|
|
13
|
+
// QwenCloud Token Plan BYO connectors (SPEC/providers.md §2 "API-key connectors"). Same keychain
|
|
14
|
+
// account ("qwen") serves both; the picker hides them until connected (§1 honest availability), and
|
|
15
|
+
// authHeaders NEVER sends the Operator token to this host. ctx starts conservative and self-clamps
|
|
16
|
+
// to the served truth (observeContext).
|
|
17
|
+
{ id: "qwen3.8-max", label: "Qwen 3.8 Max", kind: "single", desc: "BYO QwenCloud Token Plan — credits from your plan", endpoint: "https://token-plan.maas.qwencloudapi.com/compatible-mode/v1", model: "qwen3.8-max", ctx: 262144, byo: "qwen", transport: "openai" },
|
|
18
|
+
{ id: "qwen3.8-flash", label: "Qwen 3.8 Flash", kind: "single", desc: "BYO QwenCloud Token Plan — fast tier, your credits", endpoint: "https://token-plan.maas.qwencloudapi.com/compatible-mode/v1", model: "qwen3.8-flash", ctx: 262144, byo: "qwen", transport: "openai" },
|
|
19
|
+
// Venice 24B — SELF-HOSTED like Aurora (NOT a third-party connector): the open uncensored weights
|
|
20
|
+
// (Dolphin-Mistral-24B-Venice-Edition Q4_K_M, JL1 Ai Storage) served via llama.cpp on JL1:8110, bound
|
|
21
|
+
// 0.0.0.0 so the engine (on JL2) reaches it over LAN. Uncensored at the weights — answers directly, no
|
|
22
|
+
// retry needed; complements the engine-level unrestricted layer. Runs ALONGSIDE Aurora (:8097); the
|
|
23
|
+
// llama.cpp router health-checks + recovers, and ctx self-clamps to the served truth (observeContext).
|
|
24
|
+
{ id: "venice-24b", label: "Venice 24B (uncensored)", kind: "single", desc: "self-hosted uncensored Dolphin-Mistral-24B-Venice (fleet llama.cpp, JL1:8110)", endpoint: "http://192.168.1.103:8110/v1", model: "dolphin-venice-24b", ctx: 8192 },
|
|
25
|
+
{ id: "moa", label: "MOA (Mixture of Agents)", kind: "orchestrated", desc: "fan out to proposers, synthesize with an aggregator" },
|
|
26
|
+
];
|
|
27
|
+
/** The runtime registry: the built-ins, with any settings.models entries merged in (overriding a
|
|
28
|
+
* built-in by id, or adding a new one) — same shape either way, so /model doesn't care which. */
|
|
29
|
+
export function modelRegistry(overrides) {
|
|
30
|
+
if (!overrides?.length)
|
|
31
|
+
return BUILTIN_MODELS;
|
|
32
|
+
const byId = new Map(BUILTIN_MODELS.map((m) => [m.id, m]));
|
|
33
|
+
for (const m of overrides)
|
|
34
|
+
byId.set(m.id, { ...byId.get(m.id), ...m });
|
|
35
|
+
return [...byId.values()];
|
|
36
|
+
}
|
|
37
|
+
export function findModel(registry, id) {
|
|
38
|
+
const canon = MODEL_ALIASES[id] ?? id; // aurora-1m -> operator-1m (old ids keep resolving)
|
|
39
|
+
return registry.find((m) => m.id === canon);
|
|
40
|
+
}
|
|
41
|
+
/** The configured context window (tokens) for a model id — from BUILTIN_MODELS + settings overrides — or
|
|
42
|
+
* Infinity if unknown. Used to pick a LEAN harness: a small-context model (e.g. a self-hosted 8K Venice)
|
|
43
|
+
* can't take Operator's full memory + handoff injection (sized for Aurora's 300K); it fills the window and
|
|
44
|
+
* the model recites the memory instead of answering. Callers drop the heavy memory/handoff below a
|
|
45
|
+
* threshold while keeping the base persona (incl. the Direct/unrestricted section), so it stays uncensored. */
|
|
46
|
+
export function modelCtxFor(id, overrides) {
|
|
47
|
+
if (!id)
|
|
48
|
+
return Number.POSITIVE_INFINITY;
|
|
49
|
+
return findModel(modelRegistry(overrides), id)?.ctx ?? Number.POSITIVE_INFINITY;
|
|
50
|
+
}
|
|
51
|
+
/** ctx window below which the lean harness (no heavy memory/handoff) kicks in. Aurora/Qwen (128K+) stay
|
|
52
|
+
* full; a self-hosted small model (Venice 8K, or a 16K bump) goes lean. */
|
|
53
|
+
export const LEAN_HARNESS_CTX = 32768;
|
|
54
|
+
/** Pure selection reducer for /model — no I/O (no settings read/write, no router mutation), so it's
|
|
55
|
+
* directly testable. The moa-needs-config check lives in Session.setModel (it needs settings.moa,
|
|
56
|
+
* which this module intentionally doesn't import). `hasByo` (injected by the caller, see auth/byo)
|
|
57
|
+
* gates BYO connector profiles: honest "not connected" beats a request-time 401. */
|
|
58
|
+
export function selectModel(registry, id, hasByo) {
|
|
59
|
+
const profile = findModel(registry, id);
|
|
60
|
+
if (!profile)
|
|
61
|
+
return { error: `unknown model "${id}" — choices: ${registry.map((m) => m.id).join(", ")}` };
|
|
62
|
+
if (profile.kind === "single" && !profile.endpoint)
|
|
63
|
+
return { error: `model "${id}" has no endpoint configured` };
|
|
64
|
+
if (profile.byo && hasByo && !hasByo(profile.byo)) {
|
|
65
|
+
return { error: `"${id}" is not connected — store the ${profile.byo} key first: operator auth byo ${profile.byo}` };
|
|
66
|
+
}
|
|
67
|
+
return { profile };
|
|
68
|
+
}
|
|
69
|
+
/** The picker-truth view of a registry: drops BYO profiles whose key isn't connected (and ALL
|
|
70
|
+
* unresolvable ones when the resolver is absent — a picker must never offer what setModel refuses). */
|
|
71
|
+
export function visibleModels(registry, hasByo) {
|
|
72
|
+
return registry.filter((p) => !p.byo || (hasByo ? hasByo(p.byo) : false));
|
|
73
|
+
}
|
|
74
|
+
/** Strip a trailing /v1 so a ModelProfile/MoaAggregator endpoint can feed the AuroraRouter, whose
|
|
75
|
+
* base is bare (engine/aurora.ts's chat() appends /v1/chat/completions itself). */
|
|
76
|
+
export function endpointBase(endpoint) {
|
|
77
|
+
return endpoint.replace(/\/v1\/?$/, "");
|
|
78
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
export const DEFAULT_MODEL_ID = "operator-1m";
|
|
2
|
+
// Back-compat aliases: the user-facing ids were renamed aurora-* -> operator-* (the outward name is
|
|
3
|
+
// Operator; "aurora" is the internal model, never shown). The OLD ids still resolve — a persisted
|
|
4
|
+
// settings.activeModel: "aurora-1m", a `/model aurora-1m`, or any muscle memory keeps working — so the
|
|
5
|
+
// rename loses nothing. The served model name ("aurora-code-1") + endpoints stay internal, untouched.
|
|
6
|
+
export const MODEL_ALIASES = {
|
|
7
|
+
"aurora-1m": "operator-1m",
|
|
8
|
+
"aurora-128k": "operator-128k",
|
|
9
|
+
};
|
|
10
|
+
export const BUILTIN_MODELS = [
|
|
11
|
+
{ id: "operator-1m", label: "Operator 300K", kind: "single", desc: "307,200-token (300K) context (:8097)", endpoint: "http://127.0.0.1:8097/v1", model: "aurora-code-1", ctx: 307200 },
|
|
12
|
+
{ id: "operator-128k", label: "Operator 128K", kind: "single", desc: "128K context, lighter RAM (:8096)", endpoint: "http://127.0.0.1:8096/v1", model: "aurora-code-1", ctx: 131072 },
|
|
13
|
+
// QwenCloud Token Plan BYO connectors (SPEC/providers.md §2 "API-key connectors"). Same keychain
|
|
14
|
+
// account ("qwen") serves both; the picker hides them until connected (§1 honest availability), and
|
|
15
|
+
// authHeaders NEVER sends the Operator token to this host. ctx starts conservative and self-clamps
|
|
16
|
+
// to the served truth (observeContext).
|
|
17
|
+
{ id: "qwen3.8-max", label: "Qwen 3.8 Max", kind: "single", desc: "BYO QwenCloud Token Plan — credits from your plan", endpoint: "https://token-plan.maas.qwencloudapi.com/compatible-mode/v1", model: "qwen3.8-max", ctx: 262144, byo: "qwen", transport: "openai" },
|
|
18
|
+
{ id: "qwen3.8-flash", label: "Qwen 3.8 Flash", kind: "single", desc: "BYO QwenCloud Token Plan — fast tier, your credits", endpoint: "https://token-plan.maas.qwencloudapi.com/compatible-mode/v1", model: "qwen3.8-flash", ctx: 262144, byo: "qwen", transport: "openai" },
|
|
19
|
+
// Venice 24B — SELF-HOSTED like Aurora (NOT a third-party connector): the open uncensored weights
|
|
20
|
+
// (Dolphin-Mistral-24B-Venice-Edition Q4_K_M, JL1 Ai Storage) served via llama.cpp on JL1:8110, bound
|
|
21
|
+
// 0.0.0.0 so the engine (on JL2) reaches it over LAN. Uncensored at the weights — answers directly, no
|
|
22
|
+
// retry needed; complements the engine-level unrestricted layer. Runs ALONGSIDE Aurora (:8097); the
|
|
23
|
+
// llama.cpp router health-checks + recovers, and ctx self-clamps to the served truth (observeContext).
|
|
24
|
+
{ id: "venice-24b", label: "Venice 24B (uncensored)", kind: "single", desc: "self-hosted uncensored Dolphin-Mistral-24B-Venice (fleet llama.cpp, JL1:8110)", endpoint: "http://192.168.1.103:8110/v1", model: "dolphin-venice-24b", ctx: 8192 },
|
|
25
|
+
{ id: "moa", label: "MOA (Mixture of Agents)", kind: "orchestrated", desc: "fan out to proposers, synthesize with an aggregator" },
|
|
26
|
+
];
|
|
27
|
+
/** The runtime registry: the built-ins, with any settings.models entries merged in (overriding a
|
|
28
|
+
* built-in by id, or adding a new one) — same shape either way, so /model doesn't care which. */
|
|
29
|
+
export function modelRegistry(overrides) {
|
|
30
|
+
if (!overrides?.length)
|
|
31
|
+
return BUILTIN_MODELS;
|
|
32
|
+
const byId = new Map(BUILTIN_MODELS.map((m) => [m.id, m]));
|
|
33
|
+
for (const m of overrides)
|
|
34
|
+
byId.set(m.id, { ...byId.get(m.id), ...m });
|
|
35
|
+
return [...byId.values()];
|
|
36
|
+
}
|
|
37
|
+
export function findModel(registry, id) {
|
|
38
|
+
const canon = MODEL_ALIASES[id] ?? id; // aurora-1m -> operator-1m (old ids keep resolving)
|
|
39
|
+
return registry.find((m) => m.id === canon);
|
|
40
|
+
}
|
|
41
|
+
/** The configured context window (tokens) for a model id — from BUILTIN_MODELS + settings overrides — or
|
|
42
|
+
* Infinity if unknown. Used to pick a LEAN harness: a small-context model (e.g. a self-hosted 8K Venice)
|
|
43
|
+
* can't take Operator's full memory + handoff injection (sized for Aurora's 300K); it fills the window and
|
|
44
|
+
* the model recites the memory instead of answering. Callers drop the heavy memory/handoff below a
|
|
45
|
+
* threshold while keeping the base persona (incl. the Direct/unrestricted section), so it stays uncensored. */
|
|
46
|
+
export function modelCtxFor(id, overrides) {
|
|
47
|
+
if (!id)
|
|
48
|
+
return Number.POSITIVE_INFINITY;
|
|
49
|
+
return findModel(modelRegistry(overrides), id)?.ctx ?? Number.POSITIVE_INFINITY;
|
|
50
|
+
}
|
|
51
|
+
/** ctx window below which the lean harness (no heavy memory/handoff) kicks in. Aurora/Qwen (128K+) stay
|
|
52
|
+
* full; a self-hosted small model (Venice 8K, or a 16K bump) goes lean. */
|
|
53
|
+
export const LEAN_HARNESS_CTX = 32768;
|
|
54
|
+
/** Pure selection reducer for /model — no I/O (no settings read/write, no router mutation), so it's
|
|
55
|
+
* directly testable. The moa-needs-config check lives in Session.setModel (it needs settings.moa,
|
|
56
|
+
* which this module intentionally doesn't import). `hasByo` (injected by the caller, see auth/byo)
|
|
57
|
+
* gates BYO connector profiles: honest "not connected" beats a request-time 401. */
|
|
58
|
+
export function selectModel(registry, id, hasByo) {
|
|
59
|
+
const profile = findModel(registry, id);
|
|
60
|
+
if (!profile)
|
|
61
|
+
return { error: `unknown model "${id}" — choices: ${registry.map((m) => m.id).join(", ")}` };
|
|
62
|
+
if (profile.kind === "single" && !profile.endpoint)
|
|
63
|
+
return { error: `model "${id}" has no endpoint configured` };
|
|
64
|
+
if (profile.byo && hasByo && !hasByo(profile.byo)) {
|
|
65
|
+
return { error: `"${id}" is not connected — store the ${profile.byo} key first: operator auth byo ${profile.byo}` };
|
|
66
|
+
}
|
|
67
|
+
return { profile };
|
|
68
|
+
}
|
|
69
|
+
/** The picker-truth view of a registry: drops BYO profiles whose key isn't connected (and ALL
|
|
70
|
+
* unresolvable ones when the resolver is absent — a picker must never offer what setModel refuses). */
|
|
71
|
+
export function visibleModels(registry, hasByo) {
|
|
72
|
+
return registry.filter((p) => !p.byo || (hasByo ? hasByo(p.byo) : false));
|
|
73
|
+
}
|
|
74
|
+
/** Strip a trailing /v1 so a ModelProfile/MoaAggregator endpoint can feed the AuroraRouter, whose
|
|
75
|
+
* base is bare (engine/aurora.ts's chat() appends /v1/chat/completions itself). */
|
|
76
|
+
export function endpointBase(endpoint) {
|
|
77
|
+
return endpoint.replace(/\/v1\/?$/, "");
|
|
78
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
export const DEFAULT_MODEL_ID = "operator-1m";
|
|
2
|
+
// Back-compat aliases: the user-facing ids were renamed aurora-* -> operator-* (the outward name is
|
|
3
|
+
// Operator; "aurora" is the internal model, never shown). The OLD ids still resolve — a persisted
|
|
4
|
+
// settings.activeModel: "aurora-1m", a `/model aurora-1m`, or any muscle memory keeps working — so the
|
|
5
|
+
// rename loses nothing. The served model name ("aurora-code-1") + endpoints stay internal, untouched.
|
|
6
|
+
export const MODEL_ALIASES = {
|
|
7
|
+
"aurora-1m": "operator-1m",
|
|
8
|
+
"aurora-128k": "operator-128k",
|
|
9
|
+
};
|
|
10
|
+
export const BUILTIN_MODELS = [
|
|
11
|
+
{ id: "operator-1m", label: "Operator 300K", kind: "single", desc: "307,200-token (300K) context (:8097)", endpoint: "http://127.0.0.1:8097/v1", model: "aurora-code-1", ctx: 307200 },
|
|
12
|
+
{ id: "operator-128k", label: "Operator 128K", kind: "single", desc: "128K context, lighter RAM (:8096)", endpoint: "http://127.0.0.1:8096/v1", model: "aurora-code-1", ctx: 131072 },
|
|
13
|
+
// QwenCloud Token Plan BYO connectors (SPEC/providers.md §2 "API-key connectors"). Same keychain
|
|
14
|
+
// account ("qwen") serves both; the picker hides them until connected (§1 honest availability), and
|
|
15
|
+
// authHeaders NEVER sends the Operator token to this host. ctx starts conservative and self-clamps
|
|
16
|
+
// to the served truth (observeContext).
|
|
17
|
+
{ id: "qwen3.8-max", label: "Qwen 3.8 Max", kind: "single", desc: "BYO QwenCloud Token Plan — credits from your plan", endpoint: "https://token-plan.maas.qwencloudapi.com/compatible-mode/v1", model: "qwen3.8-max", ctx: 262144, byo: "qwen", transport: "openai" },
|
|
18
|
+
{ id: "qwen3.8-flash", label: "Qwen 3.8 Flash", kind: "single", desc: "BYO QwenCloud Token Plan — fast tier, your credits", endpoint: "https://token-plan.maas.qwencloudapi.com/compatible-mode/v1", model: "qwen3.8-flash", ctx: 262144, byo: "qwen", transport: "openai" },
|
|
19
|
+
// Venice 24B — SELF-HOSTED like Aurora (NOT a third-party connector): the open uncensored weights
|
|
20
|
+
// (Dolphin-Mistral-24B-Venice-Edition Q4_K_M, JL1 Ai Storage) served via llama.cpp on JL1:8110, bound
|
|
21
|
+
// 0.0.0.0 so the engine (on JL2) reaches it over LAN. Uncensored at the weights — answers directly, no
|
|
22
|
+
// retry needed; complements the engine-level unrestricted layer. Runs ALONGSIDE Aurora (:8097); the
|
|
23
|
+
// llama.cpp router health-checks + recovers, and ctx self-clamps to the served truth (observeContext).
|
|
24
|
+
{ id: "venice-24b", label: "Venice 24B (uncensored)", kind: "single", desc: "self-hosted uncensored Dolphin-Mistral-24B-Venice (fleet llama.cpp, JL1:8110)", endpoint: "http://192.168.1.103:8110/v1", model: "dolphin-venice-24b", ctx: 8192 },
|
|
25
|
+
{ id: "moa", label: "MOA (Mixture of Agents)", kind: "orchestrated", desc: "fan out to proposers, synthesize with an aggregator" },
|
|
26
|
+
];
|
|
27
|
+
/** The runtime registry: the built-ins, with any settings.models entries merged in (overriding a
|
|
28
|
+
* built-in by id, or adding a new one) — same shape either way, so /model doesn't care which. */
|
|
29
|
+
export function modelRegistry(overrides) {
|
|
30
|
+
if (!overrides?.length)
|
|
31
|
+
return BUILTIN_MODELS;
|
|
32
|
+
const byId = new Map(BUILTIN_MODELS.map((m) => [m.id, m]));
|
|
33
|
+
for (const m of overrides)
|
|
34
|
+
byId.set(m.id, { ...byId.get(m.id), ...m });
|
|
35
|
+
return [...byId.values()];
|
|
36
|
+
}
|
|
37
|
+
export function findModel(registry, id) {
|
|
38
|
+
const canon = MODEL_ALIASES[id] ?? id; // aurora-1m -> operator-1m (old ids keep resolving)
|
|
39
|
+
return registry.find((m) => m.id === canon);
|
|
40
|
+
}
|
|
41
|
+
/** The configured context window (tokens) for a model id — from BUILTIN_MODELS + settings overrides — or
|
|
42
|
+
* Infinity if unknown. Used to pick a LEAN harness: a small-context model (e.g. a self-hosted 8K Venice)
|
|
43
|
+
* can't take Operator's full memory + handoff injection (sized for Aurora's 300K); it fills the window and
|
|
44
|
+
* the model recites the memory instead of answering. Callers drop the heavy memory/handoff below a
|
|
45
|
+
* threshold while keeping the base persona (incl. the Direct/unrestricted section), so it stays uncensored. */
|
|
46
|
+
export function modelCtxFor(id, overrides) {
|
|
47
|
+
if (!id)
|
|
48
|
+
return Number.POSITIVE_INFINITY;
|
|
49
|
+
return findModel(modelRegistry(overrides), id)?.ctx ?? Number.POSITIVE_INFINITY;
|
|
50
|
+
}
|
|
51
|
+
/** ctx window below which the lean harness (no heavy memory/handoff) kicks in. Aurora/Qwen (128K+) stay
|
|
52
|
+
* full; a self-hosted small model (Venice 8K, or a 16K bump) goes lean. */
|
|
53
|
+
export const LEAN_HARNESS_CTX = 32768;
|
|
54
|
+
/** Pure selection reducer for /model — no I/O (no settings read/write, no router mutation), so it's
|
|
55
|
+
* directly testable. The moa-needs-config check lives in Session.setModel (it needs settings.moa,
|
|
56
|
+
* which this module intentionally doesn't import). `hasByo` (injected by the caller, see auth/byo)
|
|
57
|
+
* gates BYO connector profiles: honest "not connected" beats a request-time 401. */
|
|
58
|
+
export function selectModel(registry, id, hasByo) {
|
|
59
|
+
const profile = findModel(registry, id);
|
|
60
|
+
if (!profile)
|
|
61
|
+
return { error: `unknown model "${id}" — choices: ${registry.map((m) => m.id).join(", ")}` };
|
|
62
|
+
if (profile.kind === "single" && !profile.endpoint)
|
|
63
|
+
return { error: `model "${id}" has no endpoint configured` };
|
|
64
|
+
if (profile.byo && hasByo && !hasByo(profile.byo)) {
|
|
65
|
+
return { error: `"${id}" is not connected — store the ${profile.byo} key first: operator auth byo ${profile.byo}` };
|
|
66
|
+
}
|
|
67
|
+
return { profile };
|
|
68
|
+
}
|
|
69
|
+
/** The picker-truth view of a registry: drops BYO profiles whose key isn't connected (and ALL
|
|
70
|
+
* unresolvable ones when the resolver is absent — a picker must never offer what setModel refuses). */
|
|
71
|
+
export function visibleModels(registry, hasByo) {
|
|
72
|
+
return registry.filter((p) => !p.byo || (hasByo ? hasByo(p.byo) : false));
|
|
73
|
+
}
|
|
74
|
+
/** Strip a trailing /v1 so a ModelProfile/MoaAggregator endpoint can feed the AuroraRouter, whose
|
|
75
|
+
* base is bare (engine/aurora.ts's chat() appends /v1/chat/completions itself). */
|
|
76
|
+
export function endpointBase(endpoint) {
|
|
77
|
+
return endpoint.replace(/\/v1\/?$/, "");
|
|
78
|
+
}
|