@0perator/operator 0.1.284 → 0.1.313

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.
Files changed (99) hide show
  1. package/README.md +24 -2
  2. package/dist/acp/agent.js +3 -2
  3. package/dist/acp/config-options.js +15 -1
  4. package/dist/acp/tool-map.js +2 -1
  5. package/dist/auth/commands.js +69 -13
  6. package/dist/autonomy/agent-cli.js +304 -0
  7. package/dist/autonomy/cloud-agent.js +439 -0
  8. package/dist/autonomy/cron-lifecycle.js +78 -0
  9. package/dist/autonomy/cron-lock.js +121 -0
  10. package/dist/autonomy/cron.js +216 -43
  11. package/dist/autonomy/delegate.js +5 -1
  12. package/dist/autonomy/incidents.js +135 -0
  13. package/dist/autonomy/session-factory.js +25 -16
  14. package/dist/background/index.js +40 -0
  15. package/dist/bus/inbox.js +20 -0
  16. package/dist/classifier/config.js +47 -0
  17. package/dist/classifier/modes.js +41 -0
  18. package/dist/classifier/types.js +1 -0
  19. package/dist/cli.js +529 -53
  20. package/dist/config/features.js +69 -0
  21. package/dist/config/persona.js +118 -99
  22. package/dist/config/scaffold.js +15 -0
  23. package/dist/config/settings.js +96 -6
  24. package/dist/consolidation/sleep.js +73 -11
  25. package/dist/engine/agent.js +275 -18
  26. package/dist/engine/anthropic-chat.js +343 -0
  27. package/dist/engine/aurora.js +101 -13
  28. package/dist/engine/batch-scheduler.js +41 -9
  29. package/dist/engine/classifier.js +85 -0
  30. package/dist/engine/compaction.js +24 -5
  31. package/dist/engine/fast-start.js +25 -0
  32. package/dist/engine/loop-guard.js +448 -0
  33. package/dist/engine/moa.js +5 -1
  34. package/dist/engine/net-error.js +24 -0
  35. package/dist/engine/repetition-guard.js +180 -0
  36. package/dist/engine/selfheal.js +8 -0
  37. package/dist/engine/toolcalls.js +51 -1
  38. package/dist/engine/verify-gate.js +2 -0
  39. package/dist/flywheel/processor.js +78 -31
  40. package/dist/flywheel/srft.js +13 -0
  41. package/dist/hooks/index.js +196 -0
  42. package/dist/mcp/config.js +21 -1
  43. package/dist/memory/index.js +0 -0
  44. package/dist/memory/providers.js +210 -0
  45. package/dist/memory/session-catalog.js +422 -0
  46. package/dist/memory/session-providers.js +121 -0
  47. package/dist/memory/session-sources.js +335 -0
  48. package/dist/memory/skylark.js +131 -0
  49. package/dist/models/bench.js +103 -0
  50. package/dist/models/registry.js +144 -0
  51. package/dist/models/switch.js +69 -0
  52. package/dist/observability/blackbox.js +37 -0
  53. package/dist/permissions/policy.js +31 -6
  54. package/dist/router/discovery.js +127 -0
  55. package/dist/router/models.js +117 -24
  56. package/dist/router/portal.js +100 -0
  57. package/dist/router/router.js +1 -1
  58. package/dist/services/preflight.js +55 -7
  59. package/dist/session.js +316 -46
  60. package/dist/tools/chauffeur.js +12 -0
  61. package/dist/tools/executor.js +19 -9
  62. package/dist/tools/find-files.js +483 -0
  63. package/dist/tools/git-pr.js +94 -0
  64. package/dist/tools/incident-tools.js +82 -0
  65. package/dist/tools/memory.js +12 -2
  66. package/dist/tools/registry.js +281 -85
  67. package/dist/tools/semantic-compress.js +124 -0
  68. package/dist/tools/shell-context.js +1 -0
  69. package/dist/tools/shell-jobs.js +160 -0
  70. package/dist/tools/shell-session.js +170 -4
  71. package/dist/tools/wave-tools.js +609 -0
  72. package/dist/tools/wave2-tools.js +411 -0
  73. package/dist/ui/App.js +15 -4
  74. package/dist/ui/BgPanel.js +30 -6
  75. package/dist/ui/Composer.js +11 -1
  76. package/dist/ui/QuestionPrompt.js +31 -11
  77. package/dist/ui/SessionPicker.js +86 -0
  78. package/dist/ui/StatusRule.js +5 -5
  79. package/dist/ui/ToolStep.js +2 -1
  80. package/dist/ui/Transcript.js +17 -1
  81. package/dist/ui/index.js +1 -1
  82. package/dist/ui/liveTools.js +21 -3
  83. package/dist/ui/slashCommands.js +2 -0
  84. package/dist/util/screenshots.js +74 -8
  85. package/dist/util/slash.js +2 -2
  86. package/package.json +8 -2
  87. package/dist/engine/cli.js +0 -1171
  88. package/dist/router/models.js.bak +0 -78
  89. package/dist/router/models.js.bak-1791259923 +0 -78
  90. package/dist/router/models.js.bak-pre-gateway +0 -78
  91. package/dist/router/models.js.bak-pre-patch2 +0 -78
  92. package/dist/router/models.js.bak2 +0 -78
  93. package/dist/services/model-autodetect.js +0 -240
  94. package/dist/tools/native-redirect.js +0 -140
  95. package/dist/tools/power-tools.js +0 -627
  96. package/dist/tools/registry.js.bak-1791259948 +0 -1914
  97. package/dist/tools/registry.js.bak-pre-plugins +0 -1914
  98. package/dist/ui/BusTray.js +0 -70
  99. package/dist/ui/resize.js +0 -160
@@ -1,3 +1,5 @@
1
+ /** Fallback walk order, strongest → cheapest. */
2
+ export const TIER_LADDER = ["power_turbo", "power", "economy", "lite", "free"];
1
3
  export const DEFAULT_MODEL_ID = "operator-1m";
2
4
  // Back-compat aliases: the user-facing ids were renamed aurora-* -> operator-* (the outward name is
3
5
  // Operator; "aurora" is the internal model, never shown). The OLD ids still resolve — a persisted
@@ -8,23 +10,32 @@ export const MODEL_ALIASES = {
8
10
  "aurora-128k": "operator-128k",
9
11
  "spectre": "cortana", // flagship renamed Spectre -> Cortana 35B (2026-10-07); old id keeps resolving
10
12
  };
13
+ /** AXE's one shared model gateway (Caddy + AuthGate op_ verify + LiteLLM with server-side fallbacks, JL2).
14
+ * Fleet entries list it FIRST so one public name keeps answering when a box is down; the portal client
15
+ * (router/portal.ts) derives its host from this too, so the address lives in exactly one place. */
16
+ export const GATEWAY_BASE = "https://api.axe.onl/v1";
11
17
  export const BUILTIN_MODELS = [
12
- { id: "operator-1m", label: "Operator 128K", kind: "single", desc: "131,072-token (128K) context (:8097) — matched to the server's --ctx-size so the engine compacts BEFORE the wall (no overflow/interruption on long autonomous turns)", endpoint: "http://127.0.0.1:8097/v1", model: "aurora-code-1", ctx: 128000 },
13
- { 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 },
18
+ { id: "operator-1m", tier: "power", label: "Operator 1M (local)", kind: "single", desc: "RECOMMENDED DEFAULT — local Aurora code model on this box's GPU (:8097, 24-47 tok/s measured, warm prefix-cache, no shared-slot contention); ctx 300K matched under the served 307,200 wall so compaction lands BEFORE the edge", endpoint: "http://127.0.0.1:8097/v1", model: "aurora-code-1", ctx: 1000000 },
19
+ { id: "operator-128k", tier: "economy", label: "Operator 128K", kind: "single", desc: "128K context, lighter RAM (:8096) — slot not served on this fleet today; hidden from the picker, resolves by id when the slot comes up", endpoint: "http://127.0.0.1:8096/v1", model: "aurora-code-1", ctx: 131072, hidden: true },
14
20
  // QwenCloud Token Plan BYO connectors (SPEC/providers.md §2 "API-key connectors"). Same keychain
15
21
  // account ("qwen") serves both; the picker hides them until connected (§1 honest availability), and
16
22
  // authHeaders NEVER sends the Operator token to this host. ctx starts conservative and self-clamps
17
23
  // to the served truth (observeContext).
18
- { 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" },
19
- { 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" },
20
- // AXE Token Plan connector — the INVERSE of the QwenCloud entries: here AXE is the vendor
21
- // (_ai-docs/architecture/axe-model-vendor.md, phase V1). api.axe.onl is AXE's own gateway
22
- // (nginx + LiteLLM); third-party users paste an `sk-axe-…` virtual key (`operator auth byo axe`),
23
- // stored under keychain account "axe" — a separate account from the operator token, so the two
24
- // can never be confused (auth/byo.ts separation guard). Gateway-side sk-axe acceptance is the V0
25
- // deployment step; until then the connector stays hidden (honest availability). A ghost-32b API
26
- // SKU joins once the gateway routes JL1:8101 (reverse tunnel owed — api/README "524" note).
27
- { id: "axe-aurora-300k", label: "AXE Aurora 300K (API)", kind: "single", desc: "BYO AXE Token Plan — agent-tuned 300K reasoner via api.axe.onl", endpoint: "https://api.axe.onl/v1", model: "aurora-code-1", ctx: 307200, byo: "axe", transport: "openai" },
24
+ { id: "qwen3.8-max", tier: "power_turbo", 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" },
25
+ { id: "qwen3.8-flash", tier: "economy", 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" },
26
+ // Claude — a BYO Anthropic connector, so "delegate to Claude" and `/model claude-sonnet` work. Unlike the
27
+ // qwen/OpenAI connectors (OpenAI dialect), Claude speaks the NATIVE Anthropic Messages wire — transport
28
+ // "anthropic" routes it through engine/anthropic-chat.ts (x-api-key auth from the BYO "anthropic" key; the
29
+ // Operator token is NEVER sent here — authHeaders scoping + anthropic-chat's own key resolution). Hidden
30
+ // from the picker until the key is stored; ctx is Anthropic's documented 200K, self-clamps to served truth.
31
+ { id: "claude-sonnet", tier: "power_turbo", label: "Claude Sonnet 4.5", kind: "single", desc: "BYO Anthropic — full tool-using delegate/chat target (native Messages wire), your Anthropic key", endpoint: "https://api.anthropic.com/v1", model: "claude-sonnet-4-5", ctx: 200000, byo: "anthropic", transport: "anthropic" },
32
+ // AXE Token Plan: api.axe.onl is AXE's OWN gateway (nginx + LiteLLM) and the Operator token is its
33
+ // native auth (authHeaders scoping sends it to *.axe.onl — aurora.ts). Third-party `sk-axe-…` virtual
34
+ // keys are the V1 vendor plan (_ai-docs/architecture/axe-model-vendor.md); until the gateway actually
35
+ // issues them, gating this profile behind an unconnectable BYO account hid our OWN flagship remote
36
+ // lane from our own picker (2026-10-12 picker-truth audit) — so it is a plain profile today. When V1
37
+ // ships, reintroduce the byo:"axe" SKU as a SEPARATE connector id, never by re-gating this one.
38
+ { id: "axe-aurora-300k", tier: "power", label: "Aurora 300K (AXE cloud)", kind: "single", desc: "remote shared slot via api.axe.onl — big-context fallback, NOT default: contended decode measured 1-4.6 tok/s vs local 24-47 (JL1 serves everyone); cold >~100K prefills can also hit the Cloudflare ~125s edge cutoff", endpoint: GATEWAY_BASE, model: "aurora-code-1", ctx: 307200, transport: "openai" },
28
39
  // Spectre — the flagship, replacing Ghost (2026-10-07). Ghost 32B was the prior self-hosted abliterated
29
40
  // Qwen3-VL-32B on this slot; retired when Spectre proved 4× faster at equal capability (its weights + restore
30
41
  // command are kept at ~/.axe/logs/ghost-restore-cmd.txt — reversible). Spectre = Huihui-Qwen3.6-35B-A3B-
@@ -36,27 +47,63 @@ export const BUILTIN_MODELS = [
36
47
  // truncated a round at token 32767 (finish=length) mid-tool-call, and that cut call poisoned the session (0.1.259).
37
48
  // 32000 sits just UNDER the real wall (margin) AND under LEAN_HARNESS_CTX so Cortana drops the heavy memory/handoff
38
49
  // (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, 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 },
50
+ { id: "cortana", tier: "power", label: "Cortana 35B (JL1)", kind: "single", desc: "flagship MoE — abliterated Qwen3.6-35B-A3B (~3B active; ~40 tok/s ONLY when JL1 is quiet — shares the box with the 300K cloud slots and fell to 1-4 tok/s under fleet load; pick for vision/uncensored jobs, prefer Operator 1M local otherwise). GATEWAY-FIRST: the shared gateway answers by its own fallback (Aurora) when JL1 is down, then the LAN box direct; cold huge prefills can hit the Cloudflare ~125s edge cutoff)", endpoint: "http://192.168.1.103:8112/v1", endpoints: [GATEWAY_BASE, "http://192.168.1.103:8112/v1"], endpointModels: ["cortana", "/Volumes/Ai Storage/jl1-local/models/aurorax/Huihui-Qwen3.6-35B-A3B-abliterated.Q4_K_M.gguf"], model: "/Volumes/Ai Storage/jl1-local/models/aurorax/Huihui-Qwen3.6-35B-A3B-abliterated.Q4_K_M.gguf", ctx: 262144 },
40
51
  // Qwen3-4B — fast LOCAL tier (stock qwen3-4b-mlx-q4, 2.26GB MLX 4-bit, ctx 40960) served via mlx_lm.server
41
52
  // on JL1:8110. Qwen3 vocab (151936) — the same family as ghost-32b, so it's the review-recommended quick tier
42
53
  // AND the vocab lineage for ghost spec-decode (the actual draft is Qwen3-0.6B, too small to list here). Runs
43
54
  // /no_think for speed. Picked (2026-10-07) from a fleet-wide 3B-class review; no 3B had been execution-graded,
44
55
  // so this is the evidence-led default pending a dyno/coding-eval bench. 40960 ≥ LEAN_HARNESS_CTX → full harness.
45
- { id: "scout", label: "Scout 4B", kind: "single", desc: "fast local tier — Qwen3-4B /no_think, Qwen3 vocab (JL1:8110, MLX 4-bit)", endpoint: "http://192.168.1.103:8110/v1", model: "/Volumes/Ai Storage/axe-models/qwen3-4b-mlx-q4", ctx: 32000 },
56
+ { id: "scout", tier: "lite", label: "Scout 4B", kind: "single", desc: "fast local tier — Qwen3-4B /no_think, Qwen3 vocab (JL1:8110, MLX 4-bit; gateway-first, LAN direct as failover)", endpoint: "http://192.168.1.103:8110/v1", endpoints: [GATEWAY_BASE, "http://192.168.1.103:8110/v1"], endpointModels: ["scout", "/Volumes/Ai Storage/axe-models/qwen3-4b-mlx-q4"], model: "/Volumes/Ai Storage/axe-models/qwen3-4b-mlx-q4", ctx: 32000 },
46
57
  // Venice 24B — a LIGHTER uncensored alternative to the 35B Spectre: Dolphin-Mistral-24B-Venice-Edition
47
58
  // (Q4_K_M, ~14GB) with a bolted-on Mistral-Small-3.1 mmproj for vision. Dense 24B (not MoE), served on
48
59
  // JL1:8114 via llama.cpp (--jinja, q8 KV). ctx 32768 ≥ LEAN_HARNESS_CTX → full harness. A quick drop-in to
49
60
  // test a smaller/different flavour alongside Spectre without the 35B footprint.
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 },
61
+ { id: "venice-24b", tier: "economy", label: "Venice 24B", kind: "single", desc: "lighter uncensored tier — Dolphin-Mistral-24B-Venice + vision (JL1:8114) — slot stopped today; hidden from the picker, resolves by id once launched", 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, hidden: true },
62
+ // Falcon-H1-34B — a NOVEL architecture nobody else on the fleet runs: hybrid SSM+attention, trained with a
63
+ // genuinely long native context (no YaRN stretch needed — 262144 is baked into the GGUF's own metadata,
64
+ // confirmed via gguf-py header read, rope.freq_base ≈1e11). Served JL1:8101, q8_0 KV, parallel=1. Not one
65
+ // of our own fine-tunes — picked specifically to try something outside the Qwen/Aurora lineage.
66
+ { id: "falcon-h1-34b", tier: "power", label: "Falcon-H1 34B (JL1)", kind: "single", desc: "novel hybrid SSM+attention architecture, native 256K context (no rope extension) — not ours, picked to try something different from the Qwen/Aurora lineage", endpoint: "http://192.168.1.103:8101/v1", model: "/Volumes/Ai Storage/axe-models/falcon-h1-34b/Falcon-H1-34B-Instruct-Q4_K_M.gguf", ctx: 262144 },
67
+ // Casanova (axe/newton-base-32b) — OUR OWN fine-tune, Qwen2-architecture, 32B. Source was MLX 4-bit
68
+ // quantized (group_size 64, affine) — dequantized via mlx_lm --dequantize, reconverted+requantized to
69
+ // Q4_K_M via convert_hf_to_gguf.py + llama-quantize (2026-10-22). Native ctx is only 32768, so 128K here is
70
+ // a 4x YaRN stretch (--rope-scaling yarn --yarn-orig-ctx 32768 --rope-scale 4) — untested at the edge,
71
+ // verify with a real long-context probe before trusting it near the ceiling.
72
+ { id: "casanova", tier: "power", label: "Casanova 32B (JL1)", kind: "single", desc: "our own fine-tune (axe/newton-base-32b) — 128K via 4x YaRN stretch from a 32K native window", endpoint: "http://192.168.1.103:8102/v1", model: "/Users/home/.axe/gguf-converted/casanova-current/casanova-current-Q4_K_M.gguf", ctx: 131072 },
51
73
  // Code tier for the coding/Replit-clone surface — Qwen2.5-Coder-3B has a real chat template + tool-calling
52
74
  // + FIM (ollama reports "completion, tools, insert"), unlike StarCoder2/replit-code (completion-only, can't
53
75
  // drive an agent loop). Ollama on JL1, on-demand (loads ~3GB, so SELECT only when JL1 swap has headroom).
54
76
  // ctx 32000 stays just under the 32768 train wall (the 0.1.259/260 overrun bug) and below LEAN_HARNESS_CTX
55
77
  // 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" },
58
- { id: "moa", label: "MOA (Mixture of Agents)", kind: "orchestrated", desc: "fan out to proposers, synthesize with an aggregator" },
78
+ // the paid product should use an Apache-2.0 size (qwen2.5-coder 1.5b/7b).
79
+ // transport:"openai" = Ollama /v1. ENDPOINT FIX 2026-10-12: was 127.0.0.1:11434, which only resolves
80
+ // ON JL1 — every laptop picker entry pointed at its own dead loopback. LAN address like the other
81
+ // JL1 slots.
82
+ { id: "qwen-coder", tier: "lite", label: "Qwen Coder 3B (JL1)", kind: "single", desc: "code tier — Qwen2.5-Coder-3B Q4_K_M (chat + tool-calling + FIM), Ollama on JL1:11434 (on-demand ~3GB); Qwen Research Licence, non-commercial", endpoint: "http://192.168.1.103:11434/v1", model: "qwen2.5-coder:3b", ctx: 32000, transport: "openai" },
83
+ // Belmont 30b — an OWNER-ONLY trial of muse (muse0P abliterated, Q4_K_M ~16.9GB), served under the alias
84
+ // `muse-op` on llama.cpp :8113. FAILOVER pair: JL2 primary (192.168.1.146:8113), JL1 standby
85
+ // (192.168.1.103:8113) — same model/alias on both, so the router can hop JL2->JL1 on a busy/5xx. JL1 runs
86
+ // overnight training, so muse is served on JL2 and only falls back to JL1 when that box is free (it must be
87
+ // running on at least one box to answer — nothing here starts a server). ctx 131072 matches the served
88
+ // n_ctx on :8113 (JL1 /props: muse0P, n_ctx 131072); the earlier 16384 understated it 8x and instantly
89
+ // stalled the full headless harness at ctxPct=99 (it sits ABOVE LEAN_HARNESS_CTX, so Belmont gets the
90
+ // full harness). Keep this equal to the serve scripts' --ctx-size on both boxes.
91
+ // ownerOnly: enterprise-grade private trial — hidden from every picker and refused for any non-owner seat.
92
+ { id: "belmont-30b", tier: "economy", label: "Belmont 30b", kind: "single", desc: "OWNER-ONLY trial — muse (muse-op, abliterated 30B Q4_K_M) on llama.cpp :8113, JL2 primary + JL1 failover; must be served on a box to answer", endpoints: ["http://192.168.1.146:8113/v1", "http://192.168.1.103:8113/v1"], model: "muse-op", ctx: 131072, ownerOnly: true, leanPersona: true },
93
+ { id: "moa", tier: "power_turbo", label: "MOA (Mixture of Agents)", kind: "orchestrated", desc: "the team slot — fans each turn to aurora-local + Cortana 35B + Qwen-Coder 3B proposers (settings.moa, 60s fan-out, graceful per-draft failure) and synthesizes with local Aurora as agent-loop aggregator; roster + benchmark in _ai-docs" },
59
94
  ];
95
+ export const BYO_PRESETS = {
96
+ openai: { label: "OpenAI", endpoint: "https://api.openai.com/v1", model: "gpt-5", ctx: 272000, account: "openai" },
97
+ anthropic: { label: "Anthropic", endpoint: "https://api.anthropic.com/v1", model: "claude-sonnet-4-5", ctx: 200000, account: "anthropic", transport: "anthropic" },
98
+ gemini: { label: "Gemini", endpoint: "https://generativelanguage.googleapis.com/v1beta/openai", model: "gemini-2.5-pro", ctx: 1000000, account: "gemini" },
99
+ groq: { label: "Groq", endpoint: "https://api.groq.com/openai/v1", model: "llama-3.3-70b-versatile", ctx: 131072, account: "groq" },
100
+ deepseek: { label: "DeepSeek", endpoint: "https://api.deepseek.com/v1", model: "deepseek-chat", ctx: 131072, account: "deepseek" },
101
+ mistral: { label: "Mistral", endpoint: "https://api.mistral.ai/v1", model: "mistral-large-latest", ctx: 131072, account: "mistral" },
102
+ openrouter: { label: "OpenRouter", endpoint: "https://openrouter.ai/api/v1", model: "openai/gpt-5", ctx: 200000, account: "openrouter" },
103
+ together: { label: "Together", endpoint: "https://api.together.xyz/v1", model: "meta-llama/Llama-3.3-70B-Instruct-Turbo", ctx: 131072, account: "together" },
104
+ xai: { label: "xAI Grok", endpoint: "https://api.x.ai/v1", model: "grok-4", ctx: 256000, account: "xai" },
105
+ qwen: { label: "QwenCloud", endpoint: "https://token-plan.maas.qwencloudapi.com/compatible-mode/v1", model: "qwen3.8-max", ctx: 262144, account: "qwen" },
106
+ };
60
107
  /** The runtime registry: the built-ins, with any settings.models entries merged in (overriding a
61
108
  * built-in by id, or adding a new one) — same shape either way, so /model doesn't care which. */
62
109
  export function modelRegistry(overrides) {
@@ -71,6 +118,41 @@ export function findModel(registry, id) {
71
118
  const canon = MODEL_ALIASES[id] ?? id; // aurora-1m -> operator-1m (old ids keep resolving)
72
119
  return registry.find((m) => m.id === canon);
73
120
  }
121
+ /** The tier of a model id (alias-aware), or undefined when the profile has none. */
122
+ export function tierOf(registry, id) {
123
+ return findModel(registry, id)?.tier;
124
+ }
125
+ /** Every profile at exactly `tier`, in registry order. Picker-truth semantics by default:
126
+ * hidden and ownerOnly profiles are not OFFERED by tier (they still resolve by id elsewhere). */
127
+ export function profilesByTier(registry, tier, opts) {
128
+ return registry.filter((m) => m.tier === tier && (opts?.includeHidden || (!m.hidden && !m.ownerOnly)));
129
+ }
130
+ /**
131
+ * Resolve a tier to a concrete profile. Exact tier first (registry order decides within a tier —
132
+ * builtins lead with the recommended default). When the tier is empty, `fallback` walks the
133
+ * ladder: "down" (default) degrades toward cheaper tiers — a routing request never silently
134
+ * UPGRADES to a pricier class — while "up" climbs toward stronger ones (use when a floor matters
135
+ * more than cost); "none" is exact-only.
136
+ */
137
+ export function resolveByTier(registry, tier, opts) {
138
+ const fallback = opts?.fallback ?? "down";
139
+ const start = TIER_LADDER.indexOf(tier);
140
+ if (start === -1)
141
+ return undefined;
142
+ const order = fallback === "none" ? [tier]
143
+ : fallback === "down" ? TIER_LADDER.slice(start)
144
+ : [...TIER_LADDER.slice(0, start + 1)].reverse();
145
+ for (const t of order) {
146
+ const hit = profilesByTier(registry, t, opts)[0];
147
+ if (hit)
148
+ return hit;
149
+ }
150
+ return undefined;
151
+ }
152
+ /** The tier a grandmaster spawn lane wants (string-literal lanes — engine types never import here). */
153
+ export function laneTier(lane) {
154
+ return lane === "reasoning" ? "power" : "lite";
155
+ }
74
156
  /** The configured context window (tokens) for a model id — from BUILTIN_MODELS + settings overrides — or
75
157
  * Infinity if unknown. Used to pick a LEAN harness: a small-context model (e.g. a self-hosted 8K Venice)
76
158
  * can't take Operator's full memory + handoff injection (sized for Aurora's 300K); it fills the window and
@@ -84,25 +166,36 @@ export function modelCtxFor(id, overrides) {
84
166
  /** ctx window below which the lean harness (no heavy memory/handoff) kicks in. Aurora/Qwen (128K+) stay
85
167
  * full; a self-hosted small model (Venice 8K, or a 16K bump) goes lean. */
86
168
  export const LEAN_HARNESS_CTX = 32768;
169
+ /** Whether a model runs the lean harness: small context (< LEAN_HARNESS_CTX) OR a profile that forces it via
170
+ * `leanPersona` (a weak but big-context model). The ONE place both surfaces (cli.tsx, session-factory) decide. */
171
+ export function leanHarnessFor(id, overrides) {
172
+ if (modelCtxFor(id, overrides) < LEAN_HARNESS_CTX)
173
+ return true;
174
+ return !!findModel(modelRegistry(overrides), id ?? "")?.leanPersona;
175
+ }
87
176
  /** Pure selection reducer for /model — no I/O (no settings read/write, no router mutation), so it's
88
177
  * directly testable. The moa-needs-config check lives in Session.setModel (it needs settings.moa,
89
178
  * which this module intentionally doesn't import). `hasByo` (injected by the caller, see auth/byo)
90
179
  * gates BYO connector profiles: honest "not connected" beats a request-time 401. */
91
- export function selectModel(registry, id, hasByo) {
180
+ export function selectModel(registry, id, hasByo, isOwner = true) {
92
181
  const profile = findModel(registry, id);
93
182
  if (!profile)
94
183
  return { error: `unknown model "${id}" — choices: ${registry.map((m) => m.id).join(", ")}` };
95
- if (profile.kind === "single" && !profile.endpoint)
184
+ if (profile.kind === "single" && !profile.endpoint && !profile.endpoints?.length)
96
185
  return { error: `model "${id}" has no endpoint configured` };
186
+ if (profile.ownerOnly && !isOwner)
187
+ return { error: `"${id}" is owner-only` };
97
188
  if (profile.byo && hasByo && !hasByo(profile.byo)) {
98
- return { error: `"${id}" is not connected — store the ${profile.byo} key first: operator auth byo ${profile.byo}` };
189
+ return { error: `"${id}" is not connected — store the ${profile.byo} key first: operator auth byo-key ${profile.byo}` };
99
190
  }
100
191
  return { profile };
101
192
  }
102
193
  /** The picker-truth view of a registry: drops BYO profiles whose key isn't connected (and ALL
103
- * unresolvable ones when the resolver is absent — a picker must never offer what setModel refuses). */
104
- export function visibleModels(registry, hasByo) {
105
- return registry.filter((p) => !p.byo || (hasByo ? hasByo(p.byo) : false));
194
+ * unresolvable ones when the resolver is absent — a picker must never offer what setModel refuses),
195
+ * and owner-only profiles for any non-owner seat. `isOwner` defaults true (the implicit local owner);
196
+ * a narrowed-tier surface MUST pass isOwner=false so an owner-only lane never leaks into its picker. */
197
+ export function visibleModels(registry, hasByo, isOwner = true) {
198
+ return registry.filter((p) => !p.hidden && (!p.ownerOnly || isOwner) && (!p.byo || (hasByo ? hasByo(p.byo) : false)));
106
199
  }
107
200
  /** Strip a trailing /v1 so a ModelProfile/MoaAggregator endpoint can feed the AuroraRouter, whose
108
201
  * base is bare (engine/aurora.ts's chat() appends /v1/chat/completions itself). */
@@ -0,0 +1,100 @@
1
+ // Portal client — live per-model state from the AXE portal control plane, read through the gateway
2
+ // (GET /api/v1/models, AuthGate-gated). Read path only: it annotates the /model picker and powers an honest
3
+ // "this model is offline" note. It NEVER decides which models are offered or routed (the registry does), and
4
+ // ANY failure — signed out, 401, 502, junk JSON, timeout, network — yields `undefined`, so the picker renders
5
+ // exactly as it did before the portal existed. Absent-from-the-list means UNKNOWN, never offline.
6
+ import { GATEWAY_BASE } from "./models.js";
7
+ import { authHeaders } from "../engine/aurora.js";
8
+ const STATES = new Set(["loaded", "available", "loading", "parked", "offline", "failed"]);
9
+ /** The portal catalog URL, derived from the one gateway address (models.ts GATEWAY_BASE). */
10
+ export function portalModelsUrl(gatewayBase = GATEWAY_BASE) {
11
+ return `${new URL(gatewayBase).origin}/api/v1/models`;
12
+ }
13
+ /** Pure: OpenAI-shaped `{object:"list", data:[{id,state,node|owned_by,stale?}]}` → catalog. Entries without a
14
+ * string id or a known state are skipped (unknown stays unknown); a non-list body yields undefined. */
15
+ export function parsePortalModels(body) {
16
+ if (typeof body !== "object" || body === null)
17
+ return undefined;
18
+ const data = body.data;
19
+ if (!Array.isArray(data))
20
+ return undefined;
21
+ const out = new Map();
22
+ for (const raw of data) {
23
+ if (typeof raw !== "object" || raw === null)
24
+ continue;
25
+ const m = raw;
26
+ if (typeof m.id !== "string" || typeof m.state !== "string" || !STATES.has(m.state))
27
+ continue;
28
+ const node = typeof m.node === "string" ? m.node : typeof m.owned_by === "string" ? m.owned_by : undefined;
29
+ out.set(m.id, { state: m.state, node, stale: m.stale === true });
30
+ }
31
+ return out;
32
+ }
33
+ /** Pure: the id the PORTAL knows a registry profile by — its gateway alias (endpointModels[0]) or its served
34
+ * model name. A profile whose served name is a filesystem path (a direct-only llama-server) simply never matches,
35
+ * which is the point: absent from the portal catalog means unknown. */
36
+ export function portalIdFor(p) {
37
+ return p.endpointModels?.[0] ?? p.model ?? p.id;
38
+ }
39
+ /** Pure: the picker marker for one model, "" when the portal doesn't know it. ● loaded, ○ available/parked/
40
+ * loading, ✕ offline/failed, ? stale (the control plane is serving a last-known value for that node). */
41
+ export function stateMarker(m) {
42
+ if (!m)
43
+ return "";
44
+ if (m.stale)
45
+ return "? ";
46
+ if (m.state === "loaded")
47
+ return "● ";
48
+ if (m.state === "offline" || m.state === "failed")
49
+ return "✕ ";
50
+ return "○ ";
51
+ }
52
+ /** Pure: the picker rows with portal markers applied — same count, same order, same text; a row only changes
53
+ * (gains a leading marker) where the portal knows its id. `cat` undefined (portal unreachable) returns the rows as-is. */
54
+ export function markPickerOptions(plain, portalIds, cat) {
55
+ return plain.map((t, i) => `${stateMarker(cat?.get(portalIds[i]))}${t}`);
56
+ }
57
+ /** Pure: one honest line for a selection the portal reports down; undefined (no note) otherwise. */
58
+ export function offlineNote(label, m) {
59
+ if (!m || m.stale || (m.state !== "offline" && m.state !== "failed"))
60
+ return undefined;
61
+ return `${label} is ${m.state}${m.node ? ` on ${m.node}` : ""} — the gateway will try its fallback, or pick another with /model`;
62
+ }
63
+ const DEFAULTS = { timeoutMs: 3000, ttlMs: 30_000, failTtlMs: 5000 };
64
+ let cache;
65
+ let inflight;
66
+ export function resetPortalCache() {
67
+ cache = undefined;
68
+ inflight = undefined;
69
+ }
70
+ /** Live catalog or undefined. Never throws. Successes cache 30s, failures 5s (so a picker opened repeatedly while
71
+ * the gateway is down doesn't stall on a fresh 3s timeout each time); concurrent callers share one request. */
72
+ export function fetchPortalModels(opts = {}) {
73
+ const now = (opts.now ?? Date.now)();
74
+ const url = portalModelsUrl(opts.gatewayBase);
75
+ if (cache && cache.key === url && now - cache.at < cache.ttl)
76
+ return Promise.resolve(cache.value);
77
+ if (inflight)
78
+ return inflight;
79
+ const f = opts.fetchImpl ?? fetch;
80
+ const timeoutMs = opts.timeoutMs ?? DEFAULTS.timeoutMs;
81
+ const ttlMs = opts.ttlMs ?? DEFAULTS.ttlMs;
82
+ inflight = (async () => {
83
+ const ac = new AbortController();
84
+ const timer = setTimeout(() => ac.abort(), timeoutMs);
85
+ let value;
86
+ try {
87
+ const res = await f(url, { headers: { Accept: "application/json", ...authHeaders({ base: url, model: "" }) }, signal: ac.signal });
88
+ value = res.ok ? parsePortalModels(await res.json()) : undefined;
89
+ }
90
+ catch {
91
+ value = undefined;
92
+ }
93
+ finally {
94
+ clearTimeout(timer);
95
+ }
96
+ cache = { at: (opts.now ?? Date.now)(), ttl: value ? ttlMs : DEFAULTS.failTtlMs, value, key: url };
97
+ return value;
98
+ })().finally(() => { inflight = undefined; });
99
+ return inflight;
100
+ }
@@ -1,7 +1,7 @@
1
1
  // ONE model: Aurora at its native 1M context on :8097 (the air/1m/saddle roster collapsed here once 1M
2
2
  // served at full speed). The router still handles N endpoints generically; this default just has one.
3
3
  const DEFAULT_ENDPOINTS = [
4
- { name: "aurora", base: "http://127.0.0.1:8097", model: "aurora", ctxLimit: 307200 },
4
+ { name: "aurora", base: "http://127.0.0.1:8097", model: "aurora", ctxLimit: 1000000 },
5
5
  ];
6
6
  // Leave headroom under the hard ctx limit — mirrors SPEC §5's 0.85 compaction threshold, so
7
7
  // routing and compaction agree on what "fits."
@@ -11,6 +11,12 @@
11
11
  // because that would break every other client. launchd's KeepAlive is the real supervisor — the
12
12
  // lever just makes sure the job is loaded and the port is live before the REPL opens.
13
13
  // • autopilot (:9333) is optional and handled the same start-only way (non-fatal if it won't come up).
14
+ // • vision (:7788, axe.vision-bot) is OFF BY DEFAULT — the media-pipeline ADR (2026-10-19) keeps the
15
+ // GPU with Aurora, so boot only PROBES + reports it (settings DEFAULTS ship autostart:false). The
16
+ // start happens at POINT OF NEED: ensureVisionUp() below, called by the image_analyze vision chain
17
+ // when a local vision target is down. A launchd-disabled job makes bootstrap fail I/O-error(5)
18
+ // until `enable` runs first — ensureLaunchd's kick-failure path (bootout→enable→bootstrap→kickstart)
19
+ // is exactly that repair.
14
20
  // • SearXNG is session-scoped and owned by tools/searxng.ts (lazy start + idle/exit stop) — the only
15
21
  // service Operator tears down, via stopSessionServices() below.
16
22
  const nodeImport = (m) => import(/* @vite-ignore */ m);
@@ -120,20 +126,62 @@ async function ensureLaunchd(name, healthUrl, okOnly, cfg, onProgress) {
120
126
  ? { name, state: "started" }
121
127
  : { name, state: "down", detail: `started the launchd job but ${name} did not report ready at ${healthUrl} within ${waitSec}s` };
122
128
  }
123
- /** Ensure the services Operator depends on are up. Aurora first (required, health-gated); autopilot is
124
- * optional and never blocks. Returns one report per service for the boot UI. */
129
+ /** Ensure the services Operator depends on are up. Aurora first (required, health-gated); autopilot and
130
+ * vision are optional and never block. Returns one report per service for the boot UI. */
125
131
  export async function ensureServices(cfg) {
126
132
  const reports = [];
127
133
  reports.push(await ensureLaunchd("aurora", `${cfg.aurora.base.replace(/\/$/, "")}/health`, true, cfg.aurora, cfg.onProgress));
128
134
  if (cfg.autopilot) {
129
- const url = (cfg.autopilot.url ?? "http://127.0.0.1:9333").replace(/\/$/, "");
130
- // Optional service: cap the readiness wait hard so a present-but-unhealthy autopilot can never hold
131
- // the REPL for the required-service budget (Aurora's 90s). A real `node serve` answers in <2s.
132
- const apCfg = { ...cfg.autopilot, waitSec: Math.min(cfg.autopilot.waitSec ?? 8, 8) };
133
- reports.push(await ensureLaunchd("autopilot", `${url}/`, false, apCfg, cfg.onProgress));
135
+ reports.push(await ensureOptional("autopilot", cfg.autopilot, cfg.onProgress));
136
+ }
137
+ if (cfg.vision) {
138
+ reports.push(await ensureOptional("vision", cfg.vision, cfg.onProgress, "/health"));
134
139
  }
135
140
  return reports;
136
141
  }
142
+ /** One optional companion: cap the readiness wait hard so a present-but-unhealthy service can never hold
143
+ * the REPL for the required-service budget (Aurora's 90s). A real node server answers in <2s. `healthPath`
144
+ * is "" for services with no /health route (any answer counts) or "/health" for ones that do. */
145
+ async function ensureOptional(name, cfg, onProgress, healthPath = "/") {
146
+ const url = (cfg.url ?? (name === "vision" ? "http://127.0.0.1:7788" : "http://127.0.0.1:9333")).replace(/\/$/, "");
147
+ const optCfg = { ...cfg, waitSec: Math.min(cfg.waitSec ?? 8, 8) };
148
+ return ensureLaunchd(name, `${url}${healthPath}`, healthPath !== "/", optCfg, onProgress);
149
+ }
150
+ /** Point-of-need vision start — the ADR's deferred auto-on, done client-side. image_analyze calls this
151
+ * when a LOCAL vision target fails /health, so the media pipeline comes up for the turn that needs it
152
+ * while boot never touches it (GPU stays with Aurora by default). Reuses the full ensureLaunchd repair
153
+ * (kickstart → bootout/enable/bootstrap/kickstart), so a job left launchd-disabled — by `media-pipeline
154
+ * off` or a stale eval pause — self-heals here instead of dying with bootstrap I/O-error(5). Single-flight:
155
+ * concurrent callers share one start attempt; a short negative TTL so a genuinely broken worker doesn't
156
+ * re-kick launchd on every retry. Returns true iff vision answered /health. */
157
+ let visionStart = null;
158
+ let visionStartFailedAt = 0;
159
+ const VISION_START_TTL_MS = 60_000;
160
+ export function ensureVisionUp(url = "http://127.0.0.1:7788") {
161
+ if (visionStart)
162
+ return visionStart;
163
+ if (Date.now() - visionStartFailedAt < VISION_START_TTL_MS)
164
+ return Promise.resolve(false);
165
+ visionStart = (async () => {
166
+ const uid = typeof process.getuid === "function" ? process.getuid() : NaN;
167
+ if (Number.isNaN(uid)) {
168
+ visionStartFailedAt = Date.now();
169
+ return false;
170
+ }
171
+ const r = await ensureLaunchd("vision", `${url.replace(/\/$/, "")}/health`, true, {
172
+ autostart: true,
173
+ launchdLabel: "axe.vision-bot",
174
+ plistPath: "~/Library/LaunchAgents/axe.vision-bot.plist",
175
+ waitSec: 12, // qwen2.5vl:7b is an ollama-backed worker — a cold load is seconds, not minutes
176
+ });
177
+ const ok = r.state === "up" || r.state === "started";
178
+ if (!ok)
179
+ visionStartFailedAt = Date.now();
180
+ visionStart = null;
181
+ return ok;
182
+ })();
183
+ return visionStart;
184
+ }
137
185
  /** Best-effort install of an optional companion (autopilot / chauffeur) via the packaged setup script,
138
186
  * DETACHED so it never blocks boot. Sourcing (fleet rsync / clone) lives in scripts/setup-services.sh —
139
187
  * kept out of the JS so the mobile bundle carries no installer. No-ops if the script or spawn is absent. */