@0perator/operator 0.1.274 → 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/client.js +0 -8
- package/dist/auth/store.js +36 -5
- package/dist/autonomy/delegate.js +2 -21
- package/dist/autonomy/session-factory.js +0 -4
- package/dist/cli.js +69 -127
- package/dist/config/persona.js +18 -31
- package/dist/config/settings.js +6 -47
- package/dist/engine/agent.js +3 -32
- package/dist/engine/cli.js +1171 -0
- package/dist/router/models.js +1 -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/preflight.js +2 -46
- package/dist/session.js +2 -19
- package/dist/tools/chauffeur.js +16 -3
- package/dist/tools/registry.js +45 -132
- package/dist/tools/registry.js.bak-1791259948 +1914 -0
- package/dist/tools/registry.js.bak-pre-plugins +1914 -0
- package/dist/tools/searxng.js +1 -8
- package/dist/ui/BgPanel.js +1 -13
- package/dist/ui/BusTray.js +70 -0
- package/dist/ui/term.js +6 -11
- package/package.json +1 -1
package/dist/router/models.js
CHANGED
|
@@ -54,7 +54,7 @@ export const BUILTIN_MODELS = [
|
|
|
54
54
|
// ctx 32000 stays just under the 32768 train wall (the 0.1.259/260 overrun bug) and below LEAN_HARNESS_CTX
|
|
55
55
|
// so a 3B gets the lean harness. LICENCE: Qwen Research Licence (non-commercial) — fine for owner/eval use;
|
|
56
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"
|
|
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" },
|
|
58
58
|
{ id: "moa", label: "MOA (Mixture of Agents)", kind: "orchestrated", desc: "fan out to proposers, synthesize with an aggregator" },
|
|
59
59
|
];
|
|
60
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
|
+
}
|
|
@@ -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
|
+
}
|
|
@@ -39,41 +39,6 @@ async function launchctl(args, timeoutMs = 15_000) {
|
|
|
39
39
|
child.on?.("error", () => resolve({ code: 127, out: "launchctl not available" }));
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
|
-
/** Pull the model file a launchd plist serves: an explicit `-m`/`--model` argument, or any string that is a
|
|
43
|
-
* .gguf path (a ProgramArguments element, or inside a `bash -c` command, quoted or not). Undefined when the
|
|
44
|
-
* plist names no gguf (an MLX directory, a wrapper script) — an unknown model is never grounds to refuse a
|
|
45
|
-
* launch, only a KNOWN-missing one is. PURE. */
|
|
46
|
-
export function parseModelPathFromPlist(xml) {
|
|
47
|
-
const unesc = (v) => v.replace(/</g, "<").replace(/>/g, ">").replace(/"/g, '"').replace(/'/g, "'").replace(/&/g, "&");
|
|
48
|
-
const strings = [...xml.matchAll(/<string>([\s\S]*?)<\/string>/g)].map((m) => unesc(m[1]).trim());
|
|
49
|
-
for (let i = 0; i < strings.length - 1; i++) {
|
|
50
|
-
if ((strings[i] === "-m" || strings[i] === "--model") && /\.gguf$/i.test(strings[i + 1]))
|
|
51
|
-
return strings[i + 1];
|
|
52
|
-
}
|
|
53
|
-
for (const v of strings) {
|
|
54
|
-
if (/^(\/|~\/).*\.gguf$/i.test(v))
|
|
55
|
-
return v;
|
|
56
|
-
const m = /(?:^|\s)(?:-m|--model)\s+(?:"([^"]+\.gguf)"|'([^']+\.gguf)'|(\S+\.gguf))/i.exec(v);
|
|
57
|
-
if (m)
|
|
58
|
-
return m[1] ?? m[2] ?? m[3];
|
|
59
|
-
}
|
|
60
|
-
return undefined;
|
|
61
|
-
}
|
|
62
|
-
/** The model file a launchd service needs, if knowable: explicit config first, else read from its plist. */
|
|
63
|
-
async function resolveModelPath(cfg) {
|
|
64
|
-
if (cfg.modelPath)
|
|
65
|
-
return expandHome(cfg.modelPath);
|
|
66
|
-
if (!cfg.plistPath)
|
|
67
|
-
return undefined;
|
|
68
|
-
try {
|
|
69
|
-
const { readFile } = await nodeImport("node:fs/promises");
|
|
70
|
-
const found = parseModelPathFromPlist(await readFile(expandHome(cfg.plistPath), "utf8"));
|
|
71
|
-
return found ? expandHome(found) : undefined;
|
|
72
|
-
}
|
|
73
|
-
catch {
|
|
74
|
-
return undefined;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
42
|
/** Probe a health URL. `ready` = 2xx. `loading` = the port answered but not 2xx (llama.cpp serves 503
|
|
78
43
|
* while it mmaps the model — the service is coming up on its own and must NOT be restarted). `refused`
|
|
79
44
|
* = nothing is listening. When okOnly is false any answer counts as `ready` (autopilot has no /health). */
|
|
@@ -134,13 +99,6 @@ async function ensureLaunchd(name, healthUrl, okOnly, cfg, onProgress) {
|
|
|
134
99
|
}
|
|
135
100
|
return { name, state: "skipped", detail: `not installed (${expandHome(cfg.plistPath)} missing) — run: operator setup-services` };
|
|
136
101
|
}
|
|
137
|
-
// A job whose model file is GONE can never come up — kickstarting it just crash-loops while we poll a dead
|
|
138
|
-
// port for waitSec (the 2026-10-10 Aurora incident: gguf vanished, boot hard-waited 90s, then quit). Refuse
|
|
139
|
-
// INSTANTLY with the real reason. Unknown model path = proceed; only a known-missing file blocks.
|
|
140
|
-
const modelPath = await resolveModelPath(cfg);
|
|
141
|
-
if (modelPath && !(await fileExists(modelPath))) {
|
|
142
|
-
return { name, state: "down", detail: `model file missing: ${modelPath} — not launching ${label}` };
|
|
143
|
-
}
|
|
144
102
|
onProgress?.(`starting ${name} via launchd…`);
|
|
145
103
|
const target = `gui/${uid}/${label}`;
|
|
146
104
|
// 1) fast path: the job is loaded but its port died — kick it.
|
|
@@ -162,13 +120,11 @@ async function ensureLaunchd(name, healthUrl, okOnly, cfg, onProgress) {
|
|
|
162
120
|
? { name, state: "started" }
|
|
163
121
|
: { name, state: "down", detail: `started the launchd job but ${name} did not report ready at ${healthUrl} within ${waitSec}s` };
|
|
164
122
|
}
|
|
165
|
-
/** Ensure the services Operator depends on are up.
|
|
166
|
-
* the boot passes it ONLY as the last resort after model auto-detect found nothing healthy; autopilot is
|
|
123
|
+
/** Ensure the services Operator depends on are up. Aurora first (required, health-gated); autopilot is
|
|
167
124
|
* optional and never blocks. Returns one report per service for the boot UI. */
|
|
168
125
|
export async function ensureServices(cfg) {
|
|
169
126
|
const reports = [];
|
|
170
|
-
|
|
171
|
-
reports.push(await ensureLaunchd("aurora", `${cfg.aurora.base.replace(/\/$/, "")}/health`, true, cfg.aurora, cfg.onProgress));
|
|
127
|
+
reports.push(await ensureLaunchd("aurora", `${cfg.aurora.base.replace(/\/$/, "")}/health`, true, cfg.aurora, cfg.onProgress));
|
|
172
128
|
if (cfg.autopilot) {
|
|
173
129
|
const url = (cfg.autopilot.url ?? "http://127.0.0.1:9333").replace(/\/$/, "");
|
|
174
130
|
// Optional service: cap the readiness wait hard so a present-but-unhealthy autopilot can never hold
|
package/dist/session.js
CHANGED
|
@@ -272,9 +272,9 @@ export class Session {
|
|
|
272
272
|
// Per-session tool registry: the base set, plus `spawn_agent` when the shell provides a delegate
|
|
273
273
|
// handler (foreground only). Both the executor (dispatch) and localSchemas (what the model sees)
|
|
274
274
|
// are built from the same map, so the tool is advertised iff it's runnable.
|
|
275
|
-
let reg =
|
|
275
|
+
let reg = registry;
|
|
276
276
|
if (cfg.spawnAgent || cfg.askUser || cfg.messageAgent || cfg.agentStatus || cfg.stopAgent) {
|
|
277
|
-
reg = new Map(
|
|
277
|
+
reg = new Map(registry);
|
|
278
278
|
if (cfg.spawnAgent)
|
|
279
279
|
reg.set("spawn_agent", makeSpawnTool(cfg.spawnAgent));
|
|
280
280
|
if (cfg.messageAgent)
|
|
@@ -568,16 +568,6 @@ export class Session {
|
|
|
568
568
|
this.modelId = profile.id;
|
|
569
569
|
return { ok: true };
|
|
570
570
|
}
|
|
571
|
-
/** Re-point THIS session at an explicit endpoint chain without changing the active /model id. The boot auto-detect
|
|
572
|
-
* (services/model-autodetect.ts) uses it when the configured endpoint is down and a same-model standby — the
|
|
573
|
-
* failover or another fleet node — is the one that is alive. Same router rebuild as setModel; session-only, never
|
|
574
|
-
* persisted, so the owner's preferred model is still the one named next launch. */
|
|
575
|
-
adoptEndpoints(eps) {
|
|
576
|
-
if (!eps.length)
|
|
577
|
-
return;
|
|
578
|
-
this.inner = new AuroraRouter(eps);
|
|
579
|
-
this.router = engineRouter(this.inner);
|
|
580
|
-
}
|
|
581
571
|
/** The full conversation, for persistence (auto-save / --resume). */
|
|
582
572
|
snapshot() {
|
|
583
573
|
return this.convo.all.map((m) => ({ ...m }));
|
|
@@ -910,13 +900,6 @@ export class Session {
|
|
|
910
900
|
catch (e) {
|
|
911
901
|
if (e instanceof TurnAbortedError) {
|
|
912
902
|
this.telemetry.record({ type: "turn", rounds: 0, toolCalls: 0, interrupted: true, durationMs: Math.round(performance.now() - _t0), ctxPct: this.ctxPct() });
|
|
913
|
-
// A user esc throws with no reason → the host shows its own "interrupted" note. An ENGINE stop (loop
|
|
914
|
-
// guard) throws WITH a message — surface it as the turn's content so a mission-critical user is never
|
|
915
|
-
// left with a bare "interrupted": they see WHY it stopped and that nothing was lost. interrupted:false
|
|
916
|
-
// so the host finalizes it as a normal assistant message, not the esc banner.
|
|
917
|
-
const engineStop = typeof e.message === "string" && e.message.length > 0 && e.message !== "turn aborted";
|
|
918
|
-
if (engineStop)
|
|
919
|
-
return { content: `[${e.message}]`, rounds: 0, toolCalls: 0, interrupted: false, stopReason: "repetition" };
|
|
920
903
|
return { content: "", rounds: 0, toolCalls: 0, interrupted: true };
|
|
921
904
|
}
|
|
922
905
|
this.telemetry.record({ type: "error", where: "send", errorClass: Telemetry.errorClass(e) });
|
package/dist/tools/chauffeur.js
CHANGED
|
@@ -35,7 +35,18 @@ export const CHAUFFEUR_ACTION_NAMES = CHAUFFEUR_ACTION_TOOLS.map((t) => `chauffe
|
|
|
35
35
|
export const CHAUFFEUR_TOOL_NAMES = CHAUFFEUR_TOOLS.map((t) => `chauffeur:${t}`);
|
|
36
36
|
// Resolve the chauffeur binary: explicit override, then the fleet install path, else bare `chauffeur` on
|
|
37
37
|
// PATH. Returns null only when nothing is found, so cli.tsx can skip wiring a dead hub.
|
|
38
|
+
// SINGLE-FLIGHT + ASYNC (the boot-stall class): this runs on cli.tsx module scope when computer control
|
|
39
|
+
// is enabled. The old form was `execFileSync("command", ["-v", …])` — a SYNCHRONOUS child process that
|
|
40
|
+
// blocks the event loop, and it re-spawned for every buildChauffeurServer()/buildChauffeurHub() call
|
|
41
|
+
// (chauffeur + each stdio MCP server that needs it). `command -v` is normally sub-ms, but a slow/network
|
|
42
|
+
// PATH entry or a wedged /bin/sh turns it into the same unbounded boot stall as the keychain read. Cached
|
|
43
|
+
// into one promise so the process resolves the binary at most ONCE, and awaited (never sync) so a hung
|
|
44
|
+
// lookup can never freeze the first frame.
|
|
45
|
+
let chauffeurBin = null;
|
|
38
46
|
async function resolveBinary() {
|
|
47
|
+
return (chauffeurBin ??= resolveBinaryFresh());
|
|
48
|
+
}
|
|
49
|
+
async function resolveBinaryFresh() {
|
|
39
50
|
const override = process.env.KODE_CHAUFFEUR_BIN;
|
|
40
51
|
if (override)
|
|
41
52
|
return override;
|
|
@@ -46,9 +57,11 @@ async function resolveBinary() {
|
|
|
46
57
|
return local;
|
|
47
58
|
// Fall back to PATH resolution; if `chauffeur` isn't there either, give up (no dead hub, no failed spawn).
|
|
48
59
|
try {
|
|
49
|
-
const {
|
|
50
|
-
const p =
|
|
51
|
-
|
|
60
|
+
const { execFile } = await import("node:child_process");
|
|
61
|
+
const p = await new Promise((resolve, reject) => {
|
|
62
|
+
execFile("/bin/sh", ["-c", "command -v chauffeur"], { timeout: 3000, encoding: "utf8" }, (err, stdout) => (err ? reject(err) : resolve(stdout)));
|
|
63
|
+
});
|
|
64
|
+
return p.trim() || null;
|
|
52
65
|
}
|
|
53
66
|
catch {
|
|
54
67
|
return null;
|