aegiscode 6.7.8 → 6.8.1

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/src/commands.js CHANGED
@@ -74,10 +74,6 @@ const {
74
74
  const {
75
75
  aggregateSessionUsage, pruneSessionHistory, readResumeList,
76
76
  } = require('./history.js');
77
- // The custom-endpoint catalog behind the `custom` class and /model add|key|remove.
78
- const customModelsCatalog = require('./custommodels.js');
79
- const { VALID_WIRES } = customModelsCatalog;
80
-
81
77
  // Guarded: a concurrent workstream owns ./markdown.js.
82
78
  let markdownModule = null;
83
79
  try {
@@ -115,45 +111,6 @@ const EFFORT_LEVELS = overlays.EFFORT_VALUES;
115
111
 
116
112
  // ── Small handler helpers ─────────────────────────────────────────────────────
117
113
 
118
- /**
119
- * Split a command's raw tail into tokens, honouring double quotes so a model
120
- * name or id with a space stays one token
121
- * (`/model add local "Llama 3 70B" http://…`). Backslash escapes a quote or a
122
- * backslash inside a quoted run. Never throws — an unclosed quote simply ends
123
- * at the end of the line.
124
- */
125
- function splitArgs(raw) {
126
- const text = String(raw == null ? '' : raw);
127
- const out = [];
128
- let cur = '';
129
- let quoted = false;
130
- let started = false;
131
- for (let i = 0; i < text.length; i++) {
132
- const ch = text[i];
133
- if (ch === '\\' && quoted && i + 1 < text.length && (text[i + 1] === '"' || text[i + 1] === '\\')) {
134
- cur += text[++i];
135
- started = true;
136
- continue;
137
- }
138
- if (ch === '"') {
139
- quoted = !quoted;
140
- // A quoted empty string ("") is a real, intentional token.
141
- started = true;
142
- continue;
143
- }
144
- if (!quoted && /\s/.test(ch)) {
145
- if (started) out.push(cur);
146
- cur = '';
147
- started = false;
148
- continue;
149
- }
150
- cur += ch;
151
- started = true;
152
- }
153
- if (started) out.push(cur);
154
- return out;
155
- }
156
-
157
114
  const note = (c, text) => c.push({ role: 'note', text });const panel = (c, lines) => c.push({ role: 'panel', lines });
158
115
  const tip = (c, text) => c.push({ role: 'tip', text });
159
116
  const done = (c, text) => c.push({ role: 'done', text });
@@ -163,17 +120,13 @@ const shortCwd = () => process.cwd().split('/').filter(Boolean).pop() || '~';
163
120
  * The pinnable-model list for the class the session is on, fetched fresh.
164
121
  *
165
122
  * `c.loadModels()` on the command context is `() => listModelsFor(cls)` — it
166
- * already returns the class-scoped rows (pooled catalog on aegis, the
167
- * `provider:model` ids this machine can relay on byok, the /model add catalog
168
- * on custom). This helper must RETURN that value.
123
+ * already returns the class-scoped rows (the pooled catalog on aegis, the
124
+ * `provider:model` ids this machine can relay on byok). This helper must
125
+ * RETURN that value.
169
126
  *
170
127
  * It used to `await` it and discard the result, leaving every caller to read
171
- * `c.state().models` instead — and that field was a two-way ternary over a
172
- * three-class world, so on `custom` it fell through to the pooled catalog,
173
- * which is never populated on that class. The picker therefore reported "Could
174
- * not read the model catalog" on a class whose models are local and always
175
- * readable, while `/models` (which reads listModelsFor directly) listed them
176
- * correctly. Best-effort on failure: offline, the caller falls through to the
128
+ * `c.state().models` instead, which went stale the moment the live class
129
+ * changed. Best-effort on failure: offline, the caller falls through to the
177
130
  * honest empty note rather than opening an empty picker.
178
131
  * @returns {Promise<Array<{id:string,label:string,note:string}>>}
179
132
  */
@@ -864,18 +817,12 @@ const COMMANDS = [
864
817
  // will actually take (app.js's buildState().models is class-scoped too).
865
818
  const cls = (c.ctx && c.ctx.modelClass) || 'aegis';
866
819
  const byok = cls === 'byok';
867
- const custom = cls === 'custom';
868
- // The sub-command token, lower-cased: `add` / `key` / `remove` are the
869
- // custom-endpoint catalog's verbs. A model id is never one of these in
870
- // practice, and `list` already shadows a real id the same way.
871
- const sub = id.toLowerCase();
872
820
  if (!id) {
873
821
  note(c, `model: ${c.ctx.model || 'server default'}`);
874
822
  // Populate the picker for the LIVE class first. The list is the return
875
823
  // value, not `c.state().models`: that field is rebuilt from a cache the
876
- // current class may not populate (and the custom class never asks the
877
- // pool at all), so reading it rendered an empty picker on a class whose
878
- // models are local and always readable.
824
+ // current class may not populate, so reading it rendered an empty
825
+ // picker on a class whose models are local and always readable.
879
826
  //
880
827
  // `pickerEntries` is the same filter app.js's buildState() applies to
881
828
  // that field, and it has to be applied here for the same reason it is
@@ -887,21 +834,16 @@ const COMMANDS = [
887
834
  // Say why, and what unblocks it: an unreachable catalog is almost
888
835
  // always a missing key or no network, and "no models advertised"
889
836
  // read as "the platform has none" rather than "this client could not
890
- // ask". On byok "no models" has a third cause — the relay is fine and
891
- // the account is fine, this machine simply holds no provider key yet,
892
- // which is exactly what /byok-key fixes. On custom an empty list is
893
- // never a network problem: the catalog is local, so the only cause is
894
- // that it has not been filled in yet.
895
- note(c, custom
896
- ? 'No custom endpoints yet — /model add <id> <name> <model> <baseURL> registers a LOCAL endpoint (its key is prompted, or pass it last).'
897
- : byok
898
- ? 'No relayable models — this machine holds no provider key yet. Save one with /byok-key <provider>, then retry /model.'
899
- : c.state().online
900
- ? 'Could not read the model catalog (offline, or the server refused it) — /models retries.'
901
- : // The key travels in the environment only (client/aegis.js reads
902
- // AEGIS_API_KEY); /login is an unavailable command here, so
903
- // pointing at it would send the user to a refusal.
904
- 'No API key set, so the model catalog cannot be read — export AEGIS_API_KEY (free at https://aegiscloud.org), then retry /model.');
837
+ // ask". On byok "no models" means this machine simply holds no
838
+ // provider key yet, which is exactly what /byok-key fixes.
839
+ note(c, byok
840
+ ? 'No relayable models — this machine holds no provider key yet. Save one with /byok-key <provider>, then retry /model.'
841
+ : c.state().online
842
+ ? 'Could not read the model catalog (offline, or the server refused it) — /models retries.'
843
+ : // The key travels in the environment only (client/aegis.js reads
844
+ // AEGIS_API_KEY); /login is an unavailable command here, so
845
+ // pointing at it would send the user to a refusal.
846
+ 'No API key set, so the model catalog cannot be read — export AEGIS_API_KEY (free at https://aegiscloud.org), then retry /model.');
905
847
  c.render();
906
848
  return true;
907
849
  }
@@ -909,24 +851,15 @@ const COMMANDS = [
909
851
  // from its own default with no error. Say so where the pin is visible
910
852
  // rather than letting the reply look like the pinned model. On byok the
911
853
  // failure mode is different and louder (the relay 400s on a provider it
912
- // has no key for), so the sentence names the right one; on custom the
913
- // entry was simply removed or renamed after it was pinned.
854
+ // has no key for).
914
855
  if (c.ctx.model && !models.some((m) => m.id === c.ctx.model)) {
915
- note(c, custom
916
- ? `pinned model "${c.ctx.model}" is not in your custom catalog — pick one below, or re-add it with /model add.`
917
- : byok
918
- ? `pinned model "${c.ctx.model}" is not one this machine can relay — pick from the list below.`
919
- : `pinned model "${c.ctx.model}" is not in the catalog — the pool will answer with its own default; pick one below.`);
856
+ note(c, byok
857
+ ? `pinned model "${c.ctx.model}" is not one this machine can relay — pick from the list below.`
858
+ : `pinned model "${c.ctx.model}" is not in the catalog — the pool will answer with its own default; pick one below.`);
920
859
  }
921
- // The overlay's subtitle promises /model add|remove, and that promise is
922
- // now kept: the custom class owns this catalog, so the verbs are real
923
- // there. Say which surface applies to the live class instead of the
924
- // blanket "this build refuses both" that used to sit here.
925
- note(c, custom
926
- ? '/model <id> pins one for this session; /model add|key|remove manage the catalog; /models lists it.'
927
- : byok
928
- ? '/model <id> pins one for this session; /models lists what this machine can relay.'
929
- : '/model <id> pins one for this session; /models lists what the server advertises.');
860
+ note(c, byok
861
+ ? '/model <id> pins one for this session; /models lists what this machine can relay.'
862
+ : '/model <id> pins one for this session; /models lists what the server advertises.');
930
863
  // `cls` rides on the overlay so the picker's title and subtitle render
931
864
  // for the class that opened it, even if /class moves while it is open.
932
865
  c.openOverlay({ type: 'model', items: models, sel: 0, current: c.ctx.model, cls });
@@ -941,104 +874,6 @@ const COMMANDS = [
941
874
  c.render();
942
875
  return true;
943
876
  }
944
- // The /model add catalog — the aegiscodex-dev concept ported in, LOCAL
945
- // endpoints only. A user registers an endpoint on their own machine (own
946
- // base URL, own model string, own key) and the CLI calls it DIRECTLY
947
- // through the desktop transport, the full tool loop and all: no pooled
948
- // route, no BYOK relay, no fee or margin — because the request never
949
- // touches aegiscloud.org and there is no vendor to pay.
950
- //
951
- // That is only defensible for an address on this machine. A REMOTE base
952
- // URL is refused (custommodels.js isLocalEndpoint, fail-closed): nothing
953
- // on this lane is metered, so remote usage on it would be unpaid, and the
954
- // relay cannot bill an arbitrary URL either (it accepts a fixed catalog
955
- // of provider ids). The refusal points at /class byok — whose providers
956
- // ARE billed, a handling fee per 1k tokens — or at a local address.
957
- // There is deliberately no flag that re-opens the remote direct lane.
958
- // The classic entry form is the positional one
959
- // /model add <id> <name> <model> <baseURL> [wire]
960
- // with the key prompted for (masked) right after, or supplied inline
961
- // /model add <id> <name> <model> <baseURL> [wire] <key>
962
- // (the scriptable spelling, like /byok-key's second token).
963
- if (sub === 'add') {
964
- const parts = splitArgs(args._rest);
965
- // `sub` itself is the first token of _rest, so drop its own copy.
966
- const rest = parts[0] === 'add' ? parts.slice(1) : parts;
967
- // The wire name is optional and only recognised when it is one of the
968
- // two transports — otherwise that token is the key (so
969
- // `/model add id name model url sk-…` needs no placeholder).
970
- let at = 4;
971
- let wire;
972
- if (VALID_WIRES.includes(String(rest[at] || '').toLowerCase())) {
973
- wire = String(rest[at]).toLowerCase();
974
- at += 1;
975
- }
976
- const fields = { id: rest[0], name: rest[1], model: rest[2], baseURL: rest[3], wire };
977
- if (!fields.id || !fields.model || !fields.baseURL) {
978
- note(c, 'Usage: /model add <id> <name> <model> <baseURL> [openai|anthropic] [key]');
979
- note(c, ' e.g. /model add local Llama-3 "meta-llama/Llama-3-70b" http://localhost:8080/v1');
980
- note(c, ' the base URL must be LOCAL (localhost, 127.0.0.1, a LAN address, *.local, or a dotless host like "ollama").');
981
- note(c, ' remote providers are billed, so they are not offered here — /class byok with /byok-key <provider> relays them and charges the AEGIS handling fee.');
982
- note(c, ' the key is prompted for and stored 0600 on this machine — never in config.json.');
983
- c.render();
984
- return true;
985
- }
986
- const inlineKey = rest[at] || '';
987
- const store = c.settings && c.settings();
988
- const res = customModelsCatalog.addCustom({ ...fields, key: null }, store);
989
- if (res.error) {
990
- c.push({ role: 'error', text: `couldn't add "${fields.id}": ${res.error}` });
991
- return true;
992
- }
993
- const entry = res.entry;
994
- let key = inlineKey || '';
995
- if (!key) {
996
- note(c, `storing a key for "${entry.id}" — leave it blank to add it later with /model key ${entry.id}.`);
997
- c.render();
998
- key = String((await c.readSecret(`${entry.id} key: `)) || '').trim();
999
- }
1000
- if (key) {
1001
- customModelsCatalog.setCustomKey(entry.id, key, store);
1002
- }
1003
- note(c, `added "${entry.id}" → ${entry.model} at ${entry.baseURL} (${entry.wire} wire)${key ? '' : ' — no key yet'} — local endpoint, direct and free.`);
1004
- note(c, key
1005
- ? `run it with /class custom (then /model ${entry.id}), or /model ${entry.id} while on the custom class.`
1006
- : `add its key with /model key ${entry.id}, then /class custom runs it.`);
1007
- c.render();
1008
- return true;
1009
- }
1010
- if (sub === 'key') {
1011
- const target = splitArgs(args._rest)[1];
1012
- if (!target) { note(c, 'Usage: /model key <id> — /models lists your custom endpoints.'); c.render(); return true; }
1013
- const entry = customModelsCatalog.getCustom(target);
1014
- if (!entry) { note(c, `no custom endpoint "${target}" — /model add registers one.`); c.render(); return true; }
1015
- const store = c.settings && c.settings();
1016
- note(c, `storing a key for "${entry.id}" — blank clears it.`);
1017
- c.render();
1018
- const key = String((await c.readSecret(`${entry.id} key: `)) || '').trim();
1019
- if (!key) { note(c, 'nothing saved.'); c.render(); return true; }
1020
- customModelsCatalog.setCustomKey(entry.id, key, store);
1021
- note(c, `saved a key for "${entry.id}" on this machine — /class custom runs it.`);
1022
- c.render();
1023
- return true;
1024
- }
1025
- if (sub === 'remove' || sub === 'rm') {
1026
- const target = splitArgs(args._rest)[1];
1027
- if (!target) { note(c, 'Usage: /model remove <id>'); c.render(); return true; }
1028
- const store = c.settings && c.settings();
1029
- const { removed } = customModelsCatalog.removeCustom(target, store);
1030
- if (!removed) { note(c, `no custom endpoint "${target}" — /models lists your endpoints.`); c.render(); return true; }
1031
- // A pin on the row we just deleted would otherwise outlive its entry and
1032
- // fail at the next send with "no model … in the catalog".
1033
- if (String(c.ctx.model || '') === String(target)) {
1034
- c.ctx.model = null;
1035
- c.saveConfig({ model: null, currentModelId: null });
1036
- note(c, `unpinned "${target}" (its catalog entry is gone).`);
1037
- }
1038
- note(c, `removed "${target}" and forgot its key.`);
1039
- c.render();
1040
- return true;
1041
- }
1042
877
  if (id === '-') {
1043
878
  c.ctx.model = null;
1044
879
  c.saveConfig({ model: null, currentModelId: null });
package/src/config.js CHANGED
@@ -73,20 +73,6 @@ const DEFAULT_CONFIG = {
73
73
  // aegiscode- name so /model add/remove/switch stay compatible both ways.
74
74
  models: null,
75
75
  currentModelId: null,
76
- // The named custom-model catalog behind the `custom` class — the
77
- // aegiscodex-dev `/model add` concept: each entry names a LOCAL endpoint the
78
- // user brings themselves (own base URL + own key — llama.cpp, Ollama, a LAN
79
- // box), called DIRECTLY through the desktop transport
80
- // (providers.openaiCompatible / anthropicMessages), tools and all, never
81
- // through the pooled route or the BYOK relay. Free of AEGIS fee and margin
82
- // for exactly that reason, which is why the add path and the dispatch gate
83
- // both refuse a remote base URL: nothing on this lane is metered, so remote
84
- // usage here would be unpaid. Remote providers are billed on /class byok.
85
- // Only the non-secret metadata lives here; the key is in the 0600 settings
86
- // store under `custom:<id>` (engine.js), never in this file (config.json is
87
- // not 0600 and participates in cloud sync). Shape: [{ id, name, model,
88
- // baseURL, wire }], wire ∈ {'openai','anthropic'}.
89
- customModels: [],
90
76
  // `null` = no effort pinned, i.e. "auto": each turn is sized by the server
91
77
  // from the ask itself (aegis1 services/pool_brain.py estimate_effort). The
92
78
  // old 'high' was a *pin* on the top rung of the budget ladder — the most the
package/src/deps.js CHANGED
@@ -21,11 +21,8 @@
21
21
  const path = require('node:path');
22
22
 
23
23
  // Where the shared modules live, WITHOUT loading any of them. Kept in its own
24
- // module because this file eagerly requires everything it resolves, which makes
25
- // it unusable from inside the engine's own dependency graph (engine.js ->
26
- // custommodels.js -> deps.js -> engine.js is a cycle, and the cycle resolves to
27
- // `createLocalEngine === undefined`). src/custommodels.js needs to locate one
28
- // shared file and nothing more, so it goes through sharedpaths.js instead.
24
+ // module because this file eagerly requires everything it resolves, which
25
+ // makes it unusable from inside the engine's own dependency graph.
29
26
  const { roots, resolveShared } = require('./sharedpaths.js');
30
27
 
31
28
  const clientPath = resolveShared(path.join('client', 'aegis.js'));
@@ -66,20 +63,11 @@ const updatePath = resolveShared(path.join('client', 'update.js'));
66
63
  // must work the SAME queue with the SAME rules (scoped commits included).
67
64
  const queuePath = resolveShared(path.join('desktop', 'lib', 'local', 'queue.js'));
68
65
  const autonomousPath = resolveShared(path.join('desktop', 'lib', 'local', 'autonomous.js'));
69
- // The direct-provider transport (openaiCompatible + anthropicMessages). The
70
- // desktop injects it into createLocalEngine for its custom-endpoint classes;
71
- // the CLI injects the same real module for its `custom` class (the /model add
72
- // catalog) rather than the throwing stub it shipped before. That catalog is
73
- // LOCAL-ONLY (see custommodels.js isLocalEndpoint): the free direct lane may
74
- // only carry an endpoint on this machine, and the engine's gate refuses a
75
- // remote base URL before this module is ever called.
76
- const providersPath = resolveShared(path.join('desktop', 'lib', 'local', 'providers.js'));
77
66
 
78
67
  const { createClient } = require(clientPath);
79
68
  const { createTools } = require(toolsPath);
80
69
  const { usageTokens } = require(usagePath);
81
70
  const { createLocalEngine } = require(enginePath);
82
- const providers = require(providersPath);
83
71
  const { createSettingsStore, isReservedNamespace } = require(settingsPath);
84
72
  const { agentRoles, agentRoleLabel } = require(agentsPath);
85
73
  const { buildSystemPrompt } = require(promptPath);
@@ -93,7 +81,6 @@ module.exports = {
93
81
  createTools,
94
82
  usageTokens,
95
83
  createLocalEngine,
96
- providers,
97
84
  createSettingsStore,
98
85
  isReservedNamespace,
99
86
  agentRoles,
@@ -102,6 +89,6 @@ module.exports = {
102
89
  updater,
103
90
  queue,
104
91
  autonomous,
105
- paths: { client: clientPath, tools: toolsPath, usage: usagePath, engine: enginePath, providers: providersPath, settings: settingsPath, agents: agentsPath, prompt: promptPath, update: updatePath, queue: queuePath, autonomous: autonomousPath },
92
+ paths: { client: clientPath, tools: toolsPath, usage: usagePath, engine: enginePath, settings: settingsPath, agents: agentsPath, prompt: promptPath, update: updatePath, queue: queuePath, autonomous: autonomousPath },
106
93
  roots,
107
94
  };
package/src/engine.js CHANGED
@@ -18,14 +18,6 @@
18
18
  * free ride — and why the key must never be handed to a direct provider
19
19
  * call from here.
20
20
  *
21
- * custom LOCAL endpoints only. The `custom` class (the /model add catalog)
22
- * reaches the direct provider transport — the free lane — and the
23
- * catalog refuses every base URL that is not on this machine, so the
24
- * only usage that never touches aegiscloud.org is usage with no vendor
25
- * behind it (see custommodels.js isLocalEndpoint). A remote entry is
26
- * refused in-process before any network call and pointed at /class
27
- * byok, which bills the AEGIS handling fee.
28
- *
29
21
  * Ollama stays a stub that throws if the engine ever calls it: it needs an
30
22
  * endpoint surface this host does not offer, and a stub is proof that a code
31
23
  * path meant for another host never silently runs here.
@@ -43,25 +35,19 @@
43
35
  */
44
36
 
45
37
  const os = require('node:os');
46
- const { createLocalEngine, createSettingsStore, providers } = require('./deps.js');
38
+ const { createLocalEngine, createSettingsStore } = require('./deps.js');
47
39
  const { credentials } = require('./shared.js');
48
- const custom = require('./custommodels.js');
49
40
  const VERSION = require('../package.json').version;
50
41
 
51
42
  /**
52
43
  * The classes this host can actually run (see the docstring above).
53
44
  * aegis — the pooled route (account key pays, pool picks the provider; bills).
54
45
  * byok — the BYOK relay (your provider key, AEGIS bills a handling fee).
55
- * custom — the /model add catalog, LOCAL endpoints only: your own base URL +
56
- * key on this machine (llama.cpp, Ollama, a LAN box), called DIRECTLY
57
- * through the desktop transport with the full tool loop, never
58
- * touching aegiscloud.org. Free of AEGIS fee and margin for exactly
59
- * that reason, which is why a remote base URL is refused here: no
60
- * other class may reach the direct transport, and nothing on this
61
- * lane is metered, so remote usage on it would be unpaid. Remote
62
- * providers go through /class byok instead, where the relay bills.
46
+ * local — a model on hardware you own, over loopback. Bills nobody because
47
+ * there is no vendor; refused outright if the base URL is not local
48
+ * (desktop/lib/local/local.js remoteRefusal, fail-closed).
63
49
  */
64
- const HOST_CLASSES = Object.freeze(['aegis', 'byok', 'custom']);
50
+ const HOST_CLASSES = Object.freeze(['aegis', 'byok', 'local']);
65
51
 
66
52
  /** The class a turn runs on when nothing else is said. */
67
53
  const DEFAULT_CLASS = 'aegis';
@@ -70,15 +56,9 @@ const DEFAULT_CLASS = 'aegis';
70
56
  const CLASS_LABELS = Object.freeze({
71
57
  aegis: 'AEGIS Cloud (pooled)',
72
58
  byok: 'Bring your own key (relayed, billed)',
73
- custom: 'Custom endpoint (local only — free, direct)',
59
+ local: 'Local model (your own machine, free)',
74
60
  });
75
61
 
76
- function unsupported(label) {
77
- return async () => {
78
- throw new Error(`aegiscode: ${label} is not available — this client only runs the aegis and byok classes`);
79
- };
80
- }
81
-
82
62
  /**
83
63
  * @param {object} client A client from client/aegis.js (createClient()).
84
64
  * @param {() => boolean} getConfirmMode Whether mutating tools (exec,
@@ -100,22 +80,12 @@ function createEngine({ client, getConfirmMode, getClass, settings: injectedSett
100
80
  const local = createLocalEngine({
101
81
  aegis: client,
102
82
  settings,
103
- ollama: {
104
- probe: async () => ({ running: false }),
105
- listTags: async () => [],
106
- chat: unsupported('Ollama'),
107
- },
108
- // The real direct-provider transport — no longer a throwing stub. The
109
- // `custom` class (the /model add catalog, LOCAL endpoints only) rewrites a
110
- // turn to the 'openai-compat' / 'anthropic' class the desktop engine
111
- // already drives through exactly these two functions, so a local endpoint
112
- // gets the same tool loop the pooled class does. Nothing else in this host
113
- // reaches them: prepareCustom's local-only gate is the only door, and it
114
- // throws for a remote base URL before the call.
115
- providers: {
116
- anthropicMessages: providers.anthropicMessages,
117
- openaiCompatible: providers.openaiCompatible,
118
- },
83
+ // No `ollama` or `providers` injection: both were stubs for a transport
84
+ // this host never runs. The local class is served by the engine's own
85
+ // `localTransport`, which defaults to ./local.js — vendored alongside this
86
+ // engine by cli/scripts/predist.mjs — so a local model on the user's own
87
+ // machine works here with no extra wiring. `byok` never touches a local
88
+ // transport at all: it is relayed through AEGIS.
119
89
  env: {
120
90
  platform: process.platform,
121
91
  arch: process.arch,
@@ -132,57 +102,8 @@ function createEngine({ client, getConfirmMode, getClass, settings: injectedSett
132
102
  return HOST_CLASSES.includes(asked) ? asked : DEFAULT_CLASS;
133
103
  }
134
104
 
135
- /**
136
- * Rewrite a `custom`-class turn to the concrete transport class the desktop
137
- * engine already drives. The catalog entry is the source of truth for the
138
- * endpoint; its base URL + key are written just-in-time into the wire-class
139
- * settings row (settings.get(cls).baseURL / rawKey(cls) is what the engine's
140
- * dispatch reads), and the payload's class + model are set to that wire class
141
- * and the entry's real model string. Throws a clear, in-process error rather
142
- * than shipping `model: undefined` or an empty base URL upstream.
143
- *
144
- * The local-only gate is the first thing after the catalog lookup, and it
145
- * runs BEFORE any network call, before the key check and before the
146
- * just-in-time settings write: a remote entry throws here, so the direct
147
- * provider transport below is never reached with one and there is no
148
- * fall-through path to it. Remote providers are billed, and nothing on this
149
- * lane is metered, so the refusal points at /class byok (billed) and at a
150
- * local address (free).
151
- */
152
- function prepareCustom(payload) {
153
- const modelId = payload && payload.model;
154
- const resolved = modelId ? custom.resolveCustom(modelId, settings) : null;
155
- if (!resolved) {
156
- const err = new Error(
157
- modelId
158
- ? `custom: no model "${modelId}" in the catalog — /model add <id> <name> <model> <baseURL>, or /models to list.`
159
- : 'custom: no model pinned — pin one with /model <id> (/models lists your custom endpoints).'
160
- );
161
- err.status = 400;
162
- throw err;
163
- }
164
- if (!resolved.local) {
165
- const err = new Error(custom.customRefusal(resolved.baseURL));
166
- err.status = 400;
167
- throw err;
168
- }
169
- if (resolved.wire === 'anthropic' && !resolved.key) {
170
- const err = new Error(
171
- `custom: "${resolved.id}" is an Anthropic-style endpoint and needs a key — /model key ${resolved.id}.`
172
- );
173
- err.status = 400;
174
- throw err;
175
- }
176
- // Just-in-time scratch write: the wire-class row is only ever this session's
177
- // active custom endpoint, re-set on every custom turn, so two custom models
178
- // sharing a wire never collide.
179
- settings.set(resolved.wireClass, { baseURL: resolved.baseURL, key: resolved.key || null });
180
- return { ...payload, class: resolved.wireClass, model: resolved.model };
181
- }
182
-
183
105
  function chat(payload, onDelta) {
184
106
  const cls = currentClass();
185
- if (cls === 'custom') return local.chat(prepareCustom(payload), onDelta);
186
107
  // `class` is stamped here rather than sent by every caller, so the class a
187
108
  // turn runs on has exactly one source of truth (the live session state) and
188
109
  // a caller cannot accidentally pin a stale one.
@@ -196,23 +117,11 @@ function createEngine({ client, getConfirmMode, getClass, settings: injectedSett
196
117
  clearSessionApprovals: local.clearSessionApprovals,
197
118
  // The engine's own class table, narrowed to the ones this host runs — so a
198
119
  // UI built from listClasses() can never offer a class that would throw.
199
- // `custom` is not in the desktop engine's own CLASSES (it is a CLI concept
200
- // that rewrites to openai-compat/anthropic), so it is appended here.
201
120
  // Async, like the local engine's: listClasses() probes Ollama (a live
202
121
  // HTTP round-trip) before it can answer, so returning the raw promise made
203
122
  // `/class` throw "filter is not a function". The caller awaits it.
204
- listClasses: async () => {
205
- const base = (await local.listClasses()).filter((c) => HOST_CLASSES.includes(c.class));
206
- const configured = custom.listCustomModels(settings).length > 0;
207
- return [...base, { class: 'custom', label: CLASS_LABELS.custom, kind: 'custom', configured }];
208
- },
209
- // The `custom` class enumerates the catalog (the desktop engine has no such
210
- // class, so delegating would throw); every other class delegates.
211
- listModels: (cls) => {
212
- const want = cls || currentClass();
213
- if (want === 'custom') return { class: 'custom', models: custom.listCustomModels(settings) };
214
- return local.listModels(want);
215
- },
123
+ listClasses: async () => (await local.listClasses()).filter((c) => HOST_CLASSES.includes(c.class)),
124
+ listModels: (cls) => local.listModels(cls || currentClass()),
216
125
  classLabel: (cls) => CLASS_LABELS[cls] || CLASS_LABELS[DEFAULT_CLASS],
217
126
  getClass: currentClass,
218
127
  settings,
package/src/screens.js CHANGED
@@ -79,6 +79,28 @@ const WHATS_NEW = [
79
79
  ' /release-notes for more',
80
80
  ];
81
81
 
82
+ /**
83
+ * The connect block — the two ways to power this client, plus the one-line
84
+ * answer to "why would I want the app". Shown under the boxes on the welcome
85
+ * screen, in place of the desktop host's welcome panel (BYOK + AEGIS Cloud).
86
+ *
87
+ * It is two plain rows and not a third box, and the reason is the same row
88
+ * budget `WHATS_NEW` is held to: at 80×24 the rule, mark, title, tagline and
89
+ * the Tips/What's-new pair already come to 21 of the 23 usable rows, so a
90
+ * boxed third panel (three rows minimum, two of them rules) would push the
91
+ * footer hint off the bottom of the commonest terminal there is. Two rows fit
92
+ * exactly, one route each, and the desktop line shares the second.
93
+ *
94
+ * Both commands named here are real registry entries — `/byok-key` saves a
95
+ * provider key, `/key` saves the AEGIS account key — and the URL is the same
96
+ * `aegiscloud.org` the key screen and `/cloud` panels already point at. Nothing
97
+ * here is a URL or a command that only exists in this comment.
98
+ */
99
+ const CONNECT = [
100
+ 'Your key, your bill: /byok-key <provider> — or AEGIS Cloud, /key',
101
+ 'AEGIS Desktop: same engine in a window, on your machine — aegiscloud.org',
102
+ ];
103
+
82
104
  /** Centre a plain string, returning one span line. Clip first, or a string
83
105
  * wider than the terminal produces a row that wraps and shears the frame. */
84
106
  function centered(text, cols, style) {
@@ -312,6 +334,13 @@ function welcomeLines(ctx, cols, rows, firstRun = true) {
312
334
 
313
335
  lines.push(...boxes(t, cols, rows - lines.length - 4));
314
336
  lines.push([span('', '')]);
337
+ // The connect block, before the footer hint and only while the machine
338
+ // holds no account key. `wrapped` splits rather than clips, so a narrow
339
+ // terminal gets four short rows instead of two sheared ones; the height
340
+ // budget is unaffected at 80×24, where each line still fits on one row.
341
+ if (connectNeeded()) {
342
+ for (const text of CONNECT) lines.push(...wrapped(text, cols, t.white, 1));
343
+ }
315
344
  lines.push([span(t.gray, GLYPH.hint), span(t.white, ' Try "write a test for <filepath>"')]);
316
345
  while (lines.length < rows - 1) lines.push([span('', '')]);
317
346
  return lines;
@@ -413,6 +442,26 @@ function make(style, text) {
413
442
  return sp;
414
443
  }
415
444
 
445
+ /**
446
+ * Whether the welcome screen should still pitch the two connect routes.
447
+ *
448
+ * Once an AEGIS account key is on this machine the user has already taken one
449
+ * of them, and two rows repeating what they just did is nagging, not
450
+ * onboarding — the same rule the desktop host applies to its welcome panel.
451
+ *
452
+ * A read that fails (no credentials file, an unreadable one) resolves to
453
+ * "show it": the block is exactly what a user with no key needs, and a
454
+ * failed status read must never be the reason a new install is told nothing
455
+ * about how to start.
456
+ */
457
+ function connectNeeded() {
458
+ try {
459
+ return !credentials.keyStatus().configured;
460
+ } catch {
461
+ return true;
462
+ }
463
+ }
464
+
416
465
  /**
417
466
  * The welcome screen. Enter or Esc continues into the session; ctrl+c/d is the
418
467
  * user asking to leave, which is returned to the caller as `{ exit: true }`
@@ -637,6 +686,8 @@ module.exports = {
637
686
  PRODUCT,
638
687
  TIPS,
639
688
  WHATS_NEW,
689
+ CONNECT,
690
+ connectNeeded,
640
691
  trustLines,
641
692
  themePickerLines,
642
693
  keyLines,
@@ -6,14 +6,11 @@
6
6
  * This is `deps.js`'s path resolution split into its own module, and the split
7
7
  * is load-bearing rather than cosmetic. `deps.js` eagerly requires everything
8
8
  * it resolves — the engine, the tool registry, the client — so a module that
9
- * only needs to *locate* one shared file cannot require deps.js: the CLI's
10
- * engine requires `src/custommodels.js`, so `custommodels.js -> deps.js ->
11
- * engine.js` would be a require cycle, and the cycle would hand one of them a
12
- * half-built exports object (`createLocalEngine === undefined`) at load time.
9
+ * only needs to *locate* one shared file cannot require deps.js: doing so
10
+ * from inside something deps.js itself requires would be a require cycle,
11
+ * handing one side a half-built exports object at load time.
13
12
  *
14
- * So: paths here, code in deps.js. `custommodels.js` resolves the shared
15
- * endpoint policy (desktop/lib/local/endpoints.js) through this module and
16
- * requires just that file, which needs nothing but node builtins.
13
+ * So: paths here, code in deps.js.
17
14
  *
18
15
  * Two layouts must work, exactly as deps.js documents:
19
16
  *