@bendyline/gezel-cli 1.0.1 → 1.0.3

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/tui/index.js CHANGED
@@ -22,11 +22,13 @@ import {
22
22
  GezelApiError,
23
23
  GezelClient,
24
24
  createTrustingFetch,
25
+ discoverOrSpawn,
25
26
  electronNativeBinCandidates,
26
27
  isProcessAlive,
27
28
  readRuntime,
28
29
  readSystemServiceEndpoint,
29
30
  resolveDaemonEntry,
31
+ stopOwnedDaemon,
30
32
  systemSharedAssetsDir
31
33
  } from "@bendyline/gezel-client/node";
32
34
  import { gezelPaths } from "@bendyline/gezel/paths";
@@ -107,14 +109,35 @@ var CLI_ENGAGEMENT_MODE_USAGE = CLI_ENGAGEMENT_MODES.map((option) => option.name
107
109
  );
108
110
 
109
111
  // src/tui/active-access.ts
110
- import {
111
- resolveGezelWorkspaceAccess
112
- } from "@bendyline/gezel";
112
+ import * as GezelCore from "@bendyline/gezel";
113
113
  function activeAccessMode(opts) {
114
- const access = resolveGezelWorkspaceAccess(opts);
115
- if (access.nativeAccess === "reviewed") return "reviewed edits";
116
- if (access.nativeAccess === "full") return "full access";
117
- return access.effectiveWritable ? "editable" : "read-only";
114
+ const resolveAccess = Reflect.get(GezelCore, "resolveGezelWorkspaceAccess");
115
+ if (resolveAccess) {
116
+ const access = resolveAccess(opts);
117
+ if (access.nativeAccess === "reviewed") return "reviewed edits";
118
+ if (access.nativeAccess === "full") return "full access";
119
+ return access.effectiveWritable ? "editable" : "read-only";
120
+ }
121
+ const { provider, project, gezel, config } = opts;
122
+ if (provider === "codex-cli") {
123
+ const mode = GezelCore.normalizeCodexPermissionMode(
124
+ project?.codexPermissionMode ?? gezel?.codexPermissionMode ?? gezel?.claudePermissionMode ?? config?.codexCli?.defaultPermissionMode
125
+ );
126
+ if (mode === "plan") return "read-only";
127
+ if (mode === "reviewed") return "reviewed edits";
128
+ if (mode === "full") return "full access";
129
+ return "editable";
130
+ }
131
+ if (provider === "anthropic-cli") {
132
+ const mode = project?.claudePermissionMode ?? gezel?.claudePermissionMode ?? config?.anthropicCli?.defaultPermissionMode ?? "acceptEdits";
133
+ if (mode === "plan") return "read-only";
134
+ if (mode === "bypassPermissions") return "full access";
135
+ return "editable";
136
+ }
137
+ if (provider === "copilot" && !GezelCore.resolveSandboxCopilot(config?.sandboxCopilot, gezel?.sandboxCopilot)) {
138
+ return "editable";
139
+ }
140
+ return GezelCore.projectWorkspaceWritable(project) ? "editable" : "read-only";
118
141
  }
119
142
 
120
143
  // src/tui/commands.ts
@@ -123,11 +146,13 @@ var SLASH_COMMANDS = [
123
146
  { name: "help", description: "show the command reference" },
124
147
  { name: "project", description: "switch active project" },
125
148
  { name: "gezel", description: "switch active gezel" },
149
+ { name: "allow", description: "allow a project permission" },
150
+ { name: "disallow", description: "disallow a project permission" },
126
151
  { name: "mode", description: "set AI activity: read-only through full play" },
127
152
  { name: "model", description: "switch engine and model" },
128
153
  { name: "thread", description: "switch the active chat thread" },
129
154
  { name: "task", description: "list and manage project tasks" },
130
- { name: "start", description: "start a task from a craftbook" },
155
+ { name: "do", description: "do a task from a craftbook" },
131
156
  { name: "continue", description: "process due and active project tasks" },
132
157
  { name: "nightshift", description: "start, stop, or list night-shift work" },
133
158
  { name: "focus", description: "send into another active chat" },
@@ -146,7 +171,59 @@ var NIGHT_SHIFT_SUBCOMMANDS = [
146
171
  { name: "stop", description: "stop the current night shift" },
147
172
  { name: "list", description: "show current and upcoming night-shift work" }
148
173
  ];
174
+ var MODEL_SUBCOMMANDS = [
175
+ { name: "download", description: "choose and download a new on-device model" }
176
+ ];
177
+ var PROJECT_PERMISSIONS = [
178
+ {
179
+ name: "edits",
180
+ allowDescription: "let built-in tools and background work edit this project",
181
+ disallowDescription: "make built-in tools and background work read-only"
182
+ },
183
+ {
184
+ name: "codexedits",
185
+ allowDescription: "let Codex sessions edit this project",
186
+ disallowDescription: "put Codex sessions in read-only plan mode"
187
+ },
188
+ {
189
+ name: "claudeedits",
190
+ allowDescription: "let Claude sessions edit this project",
191
+ disallowDescription: "put Claude sessions in read-only plan mode"
192
+ }
193
+ ];
194
+ var PROJECT_PERMISSION_USAGE = PROJECT_PERMISSIONS.map(
195
+ (permission) => permission.name
196
+ ).join("|");
197
+ function parseProjectPermissionName(input) {
198
+ const normalized = input.trim().toLowerCase();
199
+ return PROJECT_PERMISSIONS.find((permission) => permission.name === normalized)?.name;
200
+ }
149
201
  function suggestSlashWordwheel(input, craftbooks) {
202
+ const modelMatch = input.match(/^\/model\s+(.*)$/i);
203
+ if (modelMatch) {
204
+ const query = (modelMatch[1] ?? "").trim().toLowerCase();
205
+ return MODEL_SUBCOMMANDS.filter((command) => command.name.startsWith(query)).map((command) => ({
206
+ key: `model:${command.name}`,
207
+ label: `/model ${command.name}`,
208
+ description: command.description,
209
+ submit: `/model ${command.name}`,
210
+ completion: `/model ${command.name}`
211
+ }));
212
+ }
213
+ const permissionMatch = input.match(/^\/(allow|disallow)\s+(.*)$/i);
214
+ if (permissionMatch) {
215
+ const command = (permissionMatch[1] ?? "").toLowerCase();
216
+ const query = (permissionMatch[2] ?? "").trim().toLowerCase();
217
+ return PROJECT_PERMISSIONS.filter((permission) => permission.name.startsWith(query)).map(
218
+ (permission) => ({
219
+ key: `${command}:${permission.name}`,
220
+ label: `/${command} ${permission.name}`,
221
+ description: command === "allow" ? permission.allowDescription : permission.disallowDescription,
222
+ submit: `/${command} ${permission.name}`,
223
+ completion: `/${command} ${permission.name}`
224
+ })
225
+ );
226
+ }
150
227
  const modeMatch = input.match(/^\/mode\s+(.*)$/i);
151
228
  if (modeMatch) {
152
229
  const query = (modeMatch[1] ?? "").trim().toLowerCase();
@@ -171,9 +248,9 @@ function suggestSlashWordwheel(input, craftbooks) {
171
248
  })
172
249
  );
173
250
  }
174
- const startMatch = input.match(/^\/start\s+(.*)$/i);
175
- if (startMatch) {
176
- const query = (startMatch[1] ?? "").trim().toLowerCase();
251
+ const doMatch = input.match(/^\/do\s+(.*)$/i);
252
+ if (doMatch) {
253
+ const query = (doMatch[1] ?? "").trim().toLowerCase();
177
254
  const terms = query.split(/\s+/).filter(Boolean);
178
255
  return craftbooks.filter((book) => {
179
256
  const haystack = `${book.id} ${book.name} ${book.description ?? ""}`.toLowerCase();
@@ -184,10 +261,10 @@ function suggestSlashWordwheel(input, craftbooks) {
184
261
  return leftRank - rightRank || left.name.localeCompare(right.name);
185
262
  }).map((book) => ({
186
263
  key: `craftbook:${book.id}`,
187
- label: `/start ${book.id}`,
264
+ label: `/do ${book.id}`,
188
265
  description: `${book.name} \xB7 ${book.stepCount} ${book.stepCount === 1 ? "step" : "steps"} \xB7 ${book.source}`,
189
- submit: `/start ${book.id}`,
190
- completion: `/start ${book.id}`
266
+ submit: `/do ${book.id}`,
267
+ completion: `/do ${book.id}`
191
268
  }));
192
269
  }
193
270
  return suggestSlashCommands(input).map((command) => ({
@@ -252,6 +329,24 @@ function reduceFeed(rows, env) {
252
329
  open: false
253
330
  }
254
331
  ]);
332
+ case "queue_enqueued": {
333
+ const key = `queue-${event.queueId}`;
334
+ const pending = {
335
+ key,
336
+ sessionId,
337
+ gezelId,
338
+ kind: "pending",
339
+ text: event.preview,
340
+ open: false
341
+ };
342
+ const idx = rows.findIndex((row) => row.key === key);
343
+ if (idx === -1) return cap([...rows, pending]);
344
+ const next = rows.slice();
345
+ next[idx] = pending;
346
+ return next;
347
+ }
348
+ case "queue_removed":
349
+ return rows.filter((row) => row.key !== `queue-${event.queueId}`);
255
350
  case "delta": {
256
351
  const idx = findOpenAssistant(rows, sessionId);
257
352
  const open = idx === -1 ? void 0 : rows[idx];
@@ -319,7 +414,11 @@ function reduceFeed(rows, env) {
319
414
  gezelId: "",
320
415
  kind: "note",
321
416
  text: `task \xB7 ${event.summary}`,
322
- open: false
417
+ open: false,
418
+ taskEvent: {
419
+ kind: event.kind,
420
+ ...event.gezelId ? { gezelId: event.gezelId } : {}
421
+ }
323
422
  }
324
423
  ]);
325
424
  case "error":
@@ -502,7 +601,7 @@ function toolRowText(call) {
502
601
  }
503
602
  function gezelLabel(gezelId, gezels, boring) {
504
603
  const g = gezels.find((x) => x.id === gezelId);
505
- if (!g) return gezelId;
604
+ if (!g) return boring ? "gezel" : gezelId;
506
605
  if (boring) return g.roleBasedName ?? g.role ?? g.id;
507
606
  return g.role ? `${g.name} \xB7 ${g.role}` : g.name;
508
607
  }
@@ -634,6 +733,7 @@ var TABLE_LOGO = [
634
733
  ].join("\n");
635
734
  var KIND_COLOR = {
636
735
  user: "white",
736
+ pending: "yellow",
637
737
  assistant: "cyan",
638
738
  tool: "yellow",
639
739
  note: "magenta",
@@ -643,7 +743,7 @@ var KIND_COLOR = {
643
743
  function ChatFeed(props) {
644
744
  const { rows, gezels, boring, focusedSessionId, visible = 16 } = props;
645
745
  const shown = rows.slice(Math.max(0, rows.length - visible));
646
- return /* @__PURE__ */ jsx(Box, { flexDirection: "column", flexGrow: 1, children: shown.length === 0 ? /* @__PURE__ */ jsxs(Box, { flexDirection: "row", marginBottom: 1, children: [
746
+ return /* @__PURE__ */ jsx(Box, { flexDirection: "column", flexGrow: 1, marginBottom: 1, children: shown.length === 0 ? /* @__PURE__ */ jsxs(Box, { flexDirection: "row", children: [
647
747
  /* @__PURE__ */ jsx(Text, { color: "yellow", children: TABLE_LOGO }),
648
748
  /* @__PURE__ */ jsxs(Box, { flexDirection: "column", marginLeft: 3, children: [
649
749
  /* @__PURE__ */ jsxs(Text, { children: [
@@ -657,7 +757,7 @@ function ChatFeed(props) {
657
757
  if (row.kind === "shell" && row.sessionId.startsWith("term-")) {
658
758
  return /* @__PURE__ */ jsx(Text, { wrap: "wrap", children: clip(row.text) }, row.key);
659
759
  }
660
- const who = row.kind === "user" ? "you" : row.gezelId ? gezelLabel(row.gezelId, gezels, boring) : row.kind === "tool" ? "tool" : row.kind === "shell" ? "shell" : row.kind === "error" ? "error" : "system";
760
+ const who = row.kind === "user" ? "you" : row.kind === "pending" ? "pending" : row.gezelId ? gezelLabel(row.gezelId, gezels, boring) : row.kind === "tool" ? "tool" : row.kind === "shell" ? "shell" : row.kind === "error" ? "error" : "system";
661
761
  const isFocused = focusedSessionId && row.sessionId === focusedSessionId;
662
762
  return /* @__PURE__ */ jsxs(Box, { flexDirection: "row", children: [
663
763
  /* @__PURE__ */ jsx(Text, { dimColor: !isFocused, color: isFocused ? "green" : void 0, children: isFocused ? "\u258E" : " " }),
@@ -666,11 +766,33 @@ function ChatFeed(props) {
666
766
  who,
667
767
  ": "
668
768
  ] }),
669
- /* @__PURE__ */ jsx(Text, { color: KIND_COLOR[row.kind], children: clip(row.kind === "assistant" ? humanizeToolMarkup(row.text) : row.text) })
769
+ /* @__PURE__ */ jsx(Text, { color: KIND_COLOR[row.kind], dimColor: row.kind === "pending", children: clip(
770
+ row.taskEvent ? taskEventText(row, gezels, boring) : row.kind === "assistant" ? humanizeToolMarkup(row.text) : row.text
771
+ ) })
670
772
  ] })
671
773
  ] }, row.key);
672
774
  }) });
673
775
  }
776
+ function taskEventText(row, gezels, boring) {
777
+ const event = row.taskEvent;
778
+ if (!boring || !event?.gezelId) return row.text;
779
+ const actor = gezelLabel(event.gezelId, gezels, true);
780
+ switch (event.kind) {
781
+ case "task.entry.dispatched":
782
+ return row.text.replace(/ handed to .*$/, ` handed to ${actor}`);
783
+ case "tasknote.appended":
784
+ return row.text.replace(/^task · .*? noted on /, `task \xB7 ${actor} noted on `);
785
+ case "tasknote.deleted":
786
+ return row.text.replace(
787
+ /^task · .*? removed a note from /,
788
+ `task \xB7 ${actor} removed a note from `
789
+ );
790
+ case "tasknote.updated":
791
+ return row.text.replace(/^task · .*? edited a note on /, `task \xB7 ${actor} edited a note on `);
792
+ default:
793
+ return row.text;
794
+ }
795
+ }
674
796
  var MAX_CHARS = 8e3;
675
797
  function clip(text) {
676
798
  const t = text.replace(/\s+$/, "");
@@ -748,19 +870,29 @@ import { useEffect, useState as useState2 } from "react";
748
870
 
749
871
  // src/tui/components/EnginePill.tsx
750
872
  import { Box as Box3, Text as Text3 } from "ink";
751
- import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
873
+ import { jsxs as jsxs3 } from "react/jsx-runtime";
752
874
  function EnginePill(props) {
753
875
  const { provider, model, accessMode, busy, label } = props;
754
- const text = formatEngineStatus(provider, model, busy, label, accessMode);
755
- return /* @__PURE__ */ jsx3(Box3, { children: /* @__PURE__ */ jsxs3(Text3, { backgroundColor: busy ? "yellow" : "blackBright", color: busy ? "black" : "white", children: [
756
- " ",
757
- text,
758
- " "
759
- ] }) });
876
+ const metadata = formatEngineMetadata(provider, model, accessMode);
877
+ const activity = formatEngineActivity(busy, label);
878
+ return /* @__PURE__ */ jsxs3(Box3, { children: [
879
+ /* @__PURE__ */ jsxs3(Text3, { children: [
880
+ " ",
881
+ metadata,
882
+ " \xB7"
883
+ ] }),
884
+ /* @__PURE__ */ jsxs3(Text3, { backgroundColor: busy ? "yellow" : "blackBright", color: busy ? "black" : "white", children: [
885
+ " ",
886
+ activity,
887
+ " "
888
+ ] })
889
+ ] });
760
890
  }
761
- function formatEngineStatus(provider, model, busy, label, accessMode) {
762
- const activity = busy ? `\u25CF ${label ?? "working"}` : "\u25CB idle";
763
- return [activity, accessMode, formatEngineIdentity(provider, model)].filter(Boolean).join(" \xB7 ");
891
+ function formatEngineMetadata(provider, model, accessMode) {
892
+ return [accessMode, formatEngineIdentity(provider, model)].filter(Boolean).join(" \xB7 ");
893
+ }
894
+ function formatEngineActivity(busy, label) {
895
+ return busy ? `\u25CF ${label ?? "working"}` : "\u25CB idle";
764
896
  }
765
897
  function formatEngineIdentity(provider, model) {
766
898
  const engine = provider === "llama-cpp" ? "llama" : provider ?? "on-device";
@@ -768,7 +900,7 @@ function formatEngineIdentity(provider, model) {
768
900
  }
769
901
 
770
902
  // src/tui/components/PromptLine.tsx
771
- import { Fragment as Fragment2, jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
903
+ import { Fragment as Fragment2, jsx as jsx3, jsxs as jsxs4 } from "react/jsx-runtime";
772
904
  function PromptLine(props) {
773
905
  const {
774
906
  projectName,
@@ -846,18 +978,18 @@ function PromptLine(props) {
846
978
  const placeholder = pendingPrompt ? pendingPrompt : mode === "cli" ? "shell / @tool \u2026 (/chat to exit)" : "message, or /command, !shell, @tool";
847
979
  return /* @__PURE__ */ jsxs4(Box4, { flexDirection: "column", children: [
848
980
  /* @__PURE__ */ jsxs4(Box4, { children: [
849
- /* @__PURE__ */ jsx4(Text4, { color: "blue", children: projectName }),
850
- /* @__PURE__ */ jsx4(Text4, { dimColor: true, children: " \xB7 " }),
851
- /* @__PURE__ */ jsx4(Text4, { color: "magenta", children: gezelLabel2 }),
981
+ /* @__PURE__ */ jsx3(Text4, { color: "blue", children: projectName }),
982
+ /* @__PURE__ */ jsx3(Text4, { dimColor: true, children: " \xB7 " }),
983
+ /* @__PURE__ */ jsx3(Text4, { color: "magenta", children: gezelLabel2 }),
852
984
  threadTitle ? /* @__PURE__ */ jsxs4(Fragment2, { children: [
853
- /* @__PURE__ */ jsx4(Text4, { dimColor: true, children: " \xB7 " }),
985
+ /* @__PURE__ */ jsx3(Text4, { dimColor: true, children: " \xB7 " }),
854
986
  /* @__PURE__ */ jsxs4(Text4, { color: "cyan", children: [
855
987
  "\u21B3 ",
856
988
  compactThreadTitle(threadTitle)
857
989
  ] })
858
990
  ] }) : null,
859
- /* @__PURE__ */ jsx4(Text4, { children: " " }),
860
- /* @__PURE__ */ jsx4(
991
+ /* @__PURE__ */ jsx3(Text4, { children: " " }),
992
+ /* @__PURE__ */ jsx3(
861
993
  EnginePill,
862
994
  {
863
995
  provider,
@@ -887,8 +1019,8 @@ function PromptLine(props) {
887
1019
  ] })
888
1020
  ] }) : null,
889
1021
  /* @__PURE__ */ jsxs4(Box4, { children: [
890
- /* @__PURE__ */ jsx4(Text4, { color: pendingPrompt ? "yellow" : mode === "cli" ? "green" : "cyan", children: prefix }),
891
- /* @__PURE__ */ jsx4(
1022
+ /* @__PURE__ */ jsx3(Text4, { color: pendingPrompt ? "yellow" : mode === "cli" ? "green" : "cyan", children: prefix }),
1023
+ /* @__PURE__ */ jsx3(
892
1024
  TextInput,
893
1025
  {
894
1026
  value,
@@ -911,7 +1043,7 @@ function compactThreadTitle(title) {
911
1043
  import { Box as Box5, Text as Text5, useInput as useInput3 } from "ink";
912
1044
  import TextInput2 from "ink-text-input";
913
1045
  import { useState as useState3 } from "react";
914
- import { Fragment as Fragment3, jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
1046
+ import { Fragment as Fragment3, jsx as jsx4, jsxs as jsxs5 } from "react/jsx-runtime";
915
1047
  var QUESTION_OPTION_WINDOW_SIZE = 4;
916
1048
  function questionOptionCount(question) {
917
1049
  const choices = question.choices?.length ?? 0;
@@ -1012,11 +1144,11 @@ function QuestionPrompt(props) {
1012
1144
  askerLabel,
1013
1145
  " asks"
1014
1146
  ] }),
1015
- /* @__PURE__ */ jsx5(Text5, { wrap: "wrap", children: question.prompt }),
1147
+ /* @__PURE__ */ jsx4(Text5, { wrap: "wrap", children: question.prompt }),
1016
1148
  writing ? /* @__PURE__ */ jsxs5(Fragment3, { children: [
1017
1149
  /* @__PURE__ */ jsxs5(Box5, { children: [
1018
- /* @__PURE__ */ jsx5(Text5, { color: "cyan", children: "\u203A " }),
1019
- /* @__PURE__ */ jsx5(
1150
+ /* @__PURE__ */ jsx4(Text5, { color: "cyan", children: "\u203A " }),
1151
+ /* @__PURE__ */ jsx4(
1020
1152
  TextInput2,
1021
1153
  {
1022
1154
  value: writeIn,
@@ -1049,8 +1181,8 @@ function QuestionPrompt(props) {
1049
1181
  options.length > QUESTION_OPTION_WINDOW_SIZE ? ` \xB7 ${activeOptionIndex + 1}/${options.length}` : ""
1050
1182
  ] })
1051
1183
  ] }),
1052
- submitting ? /* @__PURE__ */ jsx5(Text5, { color: "yellow", children: "Submitting\u2026" }) : null,
1053
- error ? /* @__PURE__ */ jsx5(Text5, { color: "red", children: error }) : null
1184
+ submitting ? /* @__PURE__ */ jsx4(Text5, { color: "yellow", children: "Submitting\u2026" }) : null,
1185
+ error ? /* @__PURE__ */ jsx4(Text5, { color: "red", children: error }) : null
1054
1186
  ] });
1055
1187
  }
1056
1188
  function toggleSet(current, value) {
@@ -1062,11 +1194,12 @@ function toggleSet(current, value) {
1062
1194
 
1063
1195
  // src/tui/craftbook-start.ts
1064
1196
  import {
1065
- CRAFTBOOK_ROLE_META
1197
+ CRAFTBOOK_ROLE_META,
1198
+ visibleCatalogItems
1066
1199
  } from "@bendyline/gezel";
1067
- function normalizeCraftbooks(items) {
1200
+ function normalizeCraftbooks(items, showWorkInProgressFeatures = false) {
1068
1201
  const byId = /* @__PURE__ */ new Map();
1069
- for (const item of items) {
1202
+ for (const item of visibleCatalogItems(items, showWorkInProgressFeatures)) {
1070
1203
  if (item.manifest.kind !== "craftbook-template") continue;
1071
1204
  const manifest = item.manifest;
1072
1205
  if (byId.has(manifest.id)) continue;
@@ -1145,6 +1278,179 @@ function craftbookStartRequest(book) {
1145
1278
  };
1146
1279
  }
1147
1280
 
1281
+ // src/tui/model-picker.ts
1282
+ import {
1283
+ formatModelAttribution as formatModelAttribution2
1284
+ } from "@bendyline/gezel";
1285
+
1286
+ // src/tui/bootstrap.ts
1287
+ import {
1288
+ computeModelFit,
1289
+ formatModelAttribution,
1290
+ isMoEFromTags,
1291
+ isRecommendedModel,
1292
+ mediaModelFits,
1293
+ pickRecommendedModel
1294
+ } from "@bendyline/gezel";
1295
+ var CHAT_MEMORY_OVERHEAD = {
1296
+ "llama-cpp": 1.2,
1297
+ mlx: 1.3
1298
+ };
1299
+ var NATIVE_TOOLKIT = [
1300
+ "uv",
1301
+ "sd-server",
1302
+ "whisper-server",
1303
+ "llama-server"
1304
+ ];
1305
+ function rankChatModels(items, device, provider) {
1306
+ const candidates = [];
1307
+ for (const item of items) {
1308
+ if (item.manifest.kind !== "chat-model") continue;
1309
+ const manifest = item.manifest;
1310
+ if (manifest.licenseClass !== "open") continue;
1311
+ const source = provider === "mlx" ? manifest.mlx : manifest.llamaCpp;
1312
+ if (!source || provider === "mlx" && manifest.mlx?.disabledReason) continue;
1313
+ const residentBytes = source.residentBytes ?? Math.round(source.approxSizeBytes * CHAT_MEMORY_OVERHEAD[provider]);
1314
+ const fit = computeModelFit({
1315
+ residentBytes,
1316
+ isMoE: isMoEFromTags(manifest.tags),
1317
+ usableBytes: device.usableBytes,
1318
+ totalRamBytes: device.totalRamBytes,
1319
+ gpuVramBytes: device.gpuVramBytes,
1320
+ ...device.budgetBytes !== void 0 ? { admissibleBytes: device.budgetBytes } : {}
1321
+ }).tier;
1322
+ candidates.push({
1323
+ id: manifest.id,
1324
+ name: manifest.name,
1325
+ provider,
1326
+ approxSizeBytes: source.approxSizeBytes,
1327
+ residentBytes,
1328
+ // Effective score: a model the shared gate rejects (restricted license,
1329
+ // no tool support) sorts as unscored rather than leading the list.
1330
+ recoScore: isRecommendedModel(manifest) ? manifest.recoScore ?? 0 : 0,
1331
+ fit,
1332
+ attribution: formatModelAttribution(manifest)
1333
+ });
1334
+ }
1335
+ if (candidates.length === 0) return [];
1336
+ const picked = pickRecommendedModel(
1337
+ candidates.map((model) => ({
1338
+ id: model.id,
1339
+ ...model.recoScore > 0 ? { recoScore: model.recoScore } : {},
1340
+ licenseClass: "open",
1341
+ tags: items.find((item) => item.manifest.kind === "chat-model" && item.manifest.id === model.id)?.manifest?.tags ?? [],
1342
+ residentBytes: model.residentBytes
1343
+ })),
1344
+ device
1345
+ );
1346
+ const comfortable = candidates.filter(
1347
+ (model) => model.fit === "fits" || model.fit === "fits-offload"
1348
+ );
1349
+ const pool = comfortable.length > 0 ? comfortable : candidates;
1350
+ pool.sort(
1351
+ (a, b) => b.recoScore - a.recoScore || fitOrder(a.fit) - fitOrder(b.fit) || b.residentBytes - a.residentBytes || a.name.localeCompare(b.name)
1352
+ );
1353
+ if (!picked) return pool;
1354
+ const bestIndex = pool.findIndex((model) => model.id === picked.id);
1355
+ if (bestIndex < 0) {
1356
+ const best = candidates.find((model) => model.id === picked.id);
1357
+ if (best) pool.unshift(best);
1358
+ return pool;
1359
+ }
1360
+ if (bestIndex > 0) {
1361
+ const [best] = pool.splice(bestIndex, 1);
1362
+ if (best) pool.unshift(best);
1363
+ }
1364
+ return pool;
1365
+ }
1366
+ function bootstrapChatModelLabel(model) {
1367
+ return `${model.name} (${model.attribution})`;
1368
+ }
1369
+ function pickAccessoryModels(input, device) {
1370
+ const output = [];
1371
+ const image = pickCatalogMedia(input.imageItems, device, "image");
1372
+ if (image && !input.installed.image?.has(image.id)) {
1373
+ output.push({
1374
+ kind: "image",
1375
+ id: image.id,
1376
+ name: image.name,
1377
+ approxSizeBytes: image.approxSizeBytes + (image.auxiliaryFiles ?? []).reduce((sum, file) => sum + (file.sizeBytes ?? 0), 0),
1378
+ requiredEngine: "sd-server"
1379
+ });
1380
+ }
1381
+ const recognition = pickScoredOpen(input.recognition, false);
1382
+ if (recognition && !input.installed.recognition?.has(recognition.id)) {
1383
+ output.push({
1384
+ kind: "recognition",
1385
+ id: recognition.id,
1386
+ name: recognition.name,
1387
+ approxSizeBytes: recognition.approxSizeBytes,
1388
+ requiredEngine: "llama-server"
1389
+ });
1390
+ }
1391
+ const stt = pickScoredOpen(input.audio.stt);
1392
+ if (stt && !input.installed.stt?.has(stt.id)) {
1393
+ output.push({
1394
+ kind: "stt",
1395
+ id: stt.id,
1396
+ name: stt.name,
1397
+ approxSizeBytes: stt.approxSizeBytes,
1398
+ requiredEngine: "whisper-server"
1399
+ });
1400
+ }
1401
+ const tts = pickScoredOpen(input.audio.tts);
1402
+ if (tts && !input.installed.tts?.has(tts.id)) {
1403
+ output.push({
1404
+ kind: "tts",
1405
+ id: tts.id,
1406
+ name: tts.name,
1407
+ approxSizeBytes: tts.approxSizeBytes
1408
+ });
1409
+ }
1410
+ const video = pickCatalogMedia(input.videoItems, device, "video");
1411
+ if (video && !input.installed.video?.has(video.id)) {
1412
+ output.push({
1413
+ kind: "video",
1414
+ id: video.id,
1415
+ name: video.name,
1416
+ approxSizeBytes: video.approxSizeBytes,
1417
+ requiredEngine: "uv"
1418
+ });
1419
+ }
1420
+ return output;
1421
+ }
1422
+ function formatDownloadSize(bytes) {
1423
+ if (bytes >= 1e9) return `${(bytes / 1e9).toFixed(1)} GB`;
1424
+ return `${Math.max(1, Math.round(bytes / 1e6))} MB`;
1425
+ }
1426
+ function fitOrder(fit) {
1427
+ switch (fit) {
1428
+ case "fits":
1429
+ return 0;
1430
+ case "fits-offload":
1431
+ return 1;
1432
+ case "tight":
1433
+ return 2;
1434
+ case "too-big":
1435
+ return 3;
1436
+ }
1437
+ }
1438
+ function pickCatalogMedia(items, device, kind) {
1439
+ const models = items.map((item) => item.manifest).filter((model) => {
1440
+ if (model.licenseClass !== "open" || !model.recoScore) return false;
1441
+ return mediaModelFits(
1442
+ device,
1443
+ kind === "image" ? { minRamGB: model.minRamGB } : { minVramGB: model.minVramGB }
1444
+ );
1445
+ });
1446
+ return pickScoredOpen(models);
1447
+ }
1448
+ function pickScoredOpen(models, requireLicense = true) {
1449
+ return [...models].filter(
1450
+ (model) => typeof model.recoScore === "number" && model.recoScore > 0 && (!requireLicense || model.licenseClass === "open")
1451
+ ).sort((a, b) => (b.recoScore ?? 0) - (a.recoScore ?? 0))[0] ?? null;
1452
+ }
1453
+
1148
1454
  // src/tui/model-picker.ts
1149
1455
  var PROVIDER_ORDER = [
1150
1456
  "mlx",
@@ -1197,9 +1503,10 @@ function configuredModelProviders(config, opts) {
1197
1503
  return providers.sort((a, b) => PROVIDER_ORDER.indexOf(a) - PROVIDER_ORDER.indexOf(b));
1198
1504
  }
1199
1505
  async function loadModelChoices(client, config, platform = process.platform, arch = process.arch) {
1200
- const [copilot, memory] = await Promise.all([
1506
+ const [copilot, memory, catalog] = await Promise.all([
1201
1507
  client.getCopilotStatus().catch(() => null),
1202
- client.getMemoryProfile().catch(() => null)
1508
+ client.getMemoryProfile().catch(() => null),
1509
+ client.listCatalogItems ? client.listCatalogItems("chat-model").catch(() => null) : Promise.resolve(null)
1203
1510
  ]);
1204
1511
  const providers = configuredModelProviders(config, {
1205
1512
  platform,
@@ -1218,14 +1525,71 @@ async function loadModelChoices(client, config, platform = process.platform, arc
1218
1525
  })
1219
1526
  );
1220
1527
  return inventories.flatMap(
1221
- ({ provider, models }) => models.map((model) => ({
1222
- provider,
1223
- model,
1224
- value: `${provider}:${model.id}`,
1225
- label: `${modelProviderLabel(provider)} \xB7 ${model.name}`
1226
- }))
1528
+ ({ provider, models }) => models.map((model) => {
1529
+ const manifest = catalogManifestForModel(catalog?.items ?? [], provider, model.id);
1530
+ const attribution = manifest ? ` (${formatModelAttribution2(manifest)})` : "";
1531
+ return {
1532
+ provider,
1533
+ model,
1534
+ value: `${provider}:${model.id}`,
1535
+ label: `${modelProviderLabel(provider)} \xB7 ${model.name}${attribution}`
1536
+ };
1537
+ })
1227
1538
  );
1228
1539
  }
1540
+ async function loadModelDownloadChoices(client, config, platform = process.platform, arch = process.arch) {
1541
+ const [memory, catalog] = await Promise.all([
1542
+ client.getMemoryProfile(),
1543
+ client.listCatalogItems("chat-model")
1544
+ ]);
1545
+ const provider = config.provider === "mlx" || config.provider === "llama-cpp" ? config.provider : memory.platform === "darwin" && platform === "darwin" && arch === "arm64" ? "mlx" : "llama-cpp";
1546
+ const installed = await client.listProviderModels(provider).catch(() => ({ models: [] }));
1547
+ const installedIds = new Set(installed.models.map((model) => model.id));
1548
+ const ranked = rankChatModels(
1549
+ catalog.items,
1550
+ {
1551
+ platform: memory.platform,
1552
+ gpuVramBytes: memory.gpuVramBytes,
1553
+ ...memory.gpuMemoryKind ? { gpuMemoryKind: memory.gpuMemoryKind } : {},
1554
+ totalRamBytes: memory.totalRamBytes,
1555
+ usableBytes: memory.usableBytes,
1556
+ ...memory.budgetBytes !== void 0 ? { budgetBytes: memory.budgetBytes } : {}
1557
+ },
1558
+ provider
1559
+ );
1560
+ return ranked.filter((model) => !installedIds.has(model.id)).map((model, index) => ({
1561
+ provider,
1562
+ model,
1563
+ value: `${provider}:${model.id}`,
1564
+ label: bootstrapChatModelLabel(model),
1565
+ hint: [
1566
+ index === 0 ? "recommended" : null,
1567
+ formatDownloadSize(model.approxSizeBytes),
1568
+ modelFitLabel(model.fit)
1569
+ ].filter(Boolean).join(" \xB7 ")
1570
+ }));
1571
+ }
1572
+ function catalogManifestForModel(items, provider, modelId) {
1573
+ for (const item of items) {
1574
+ if (item.manifest.kind !== "chat-model") continue;
1575
+ const manifest = item.manifest;
1576
+ if (manifest.id === modelId) return manifest;
1577
+ if (provider === "ollama" && manifest.ollama?.tag === modelId) return manifest;
1578
+ }
1579
+ return null;
1580
+ }
1581
+ function modelFitLabel(fit) {
1582
+ switch (fit) {
1583
+ case "fits":
1584
+ return "fits this device";
1585
+ case "fits-offload":
1586
+ return "fits with offload";
1587
+ case "tight":
1588
+ return "tight fit";
1589
+ case "too-big":
1590
+ return "larger than recommended";
1591
+ }
1592
+ }
1229
1593
 
1230
1594
  // src/tui/question-queue.ts
1231
1595
  function plainPendingQuestions(questions) {
@@ -1311,7 +1675,7 @@ function abortableDelay(ms, signal) {
1311
1675
  }
1312
1676
 
1313
1677
  // src/tui/App.tsx
1314
- import { jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
1678
+ import { jsx as jsx5, jsxs as jsxs6 } from "react/jsx-runtime";
1315
1679
  function useTerminalSize() {
1316
1680
  const { stdout } = useStdout();
1317
1681
  const [size, setSize] = useState4({ rows: stdout?.rows ?? 24, columns: stdout?.columns ?? 80 });
@@ -1327,10 +1691,14 @@ function useTerminalSize() {
1327
1691
  }
1328
1692
  var HELP = [
1329
1693
  "/project \u2014 switch project /gezel \u2014 switch gezel /model \u2014 switch engine + model",
1694
+ "/model download \u2014 choose and download a new on-device model",
1695
+ "/allow edits \u2014 allow tool edits /disallow edits \u2014 make tool edits read-only",
1696
+ "/allow codexedits|claudeedits \u2014 allow provider-native project edits",
1697
+ "/disallow codexedits|claudeedits \u2014 put that provider in read-only plan mode",
1330
1698
  "/mode \u2014 choose read-only, reactive, reactive+tasks, or full-play AI activity",
1331
1699
  "/thread \u2014 switch or start a chat thread",
1332
1700
  "/task \u2014 list, inspect, create, edit, assign, or change task status",
1333
- "/start \u2014 choose a craftbook and start it as a task",
1701
+ "/do \u2014 choose a craftbook and start it as a task",
1334
1702
  "/continue \u2014 process due schedules and active tasks in this project",
1335
1703
  "/nightshift start|stop|list \u2014 manage Night Shift",
1336
1704
  "/focus \u2014 send into another active chat /cli \u2014 CLI mode /chat \u2014 chat mode",
@@ -1338,6 +1706,7 @@ var HELP = [
1338
1706
  "/clear \u2014 clear feed /quit \u2014 exit",
1339
1707
  "\u2191/\u2193 \u2014 input history Esc \u2014 interrupt turn Ctrl+C \u2014 interrupt, then again to exit"
1340
1708
  ];
1709
+ var READ_ONLY_BOOT_NOTE = "Note: this folder is read-only to gezel, and can be used for doing analysis and writing reports. Use the /allow edits command to permit gezel to edit this folder's contents.";
1341
1710
  function App(props) {
1342
1711
  const { client } = props;
1343
1712
  const { exit } = useApp();
@@ -1354,6 +1723,11 @@ function App(props) {
1354
1723
  );
1355
1724
  const [startCategoryId, setStartCategoryId] = useState4(null);
1356
1725
  const [modelChoices, setModelChoices] = useState4([]);
1726
+ const [modelDownloadChoices, setModelDownloadChoices] = useState4([]);
1727
+ const [modelDownloadProgress, setModelDownloadProgress] = useState4(
1728
+ null
1729
+ );
1730
+ const [modelDownloadReturn, setModelDownloadReturn] = useState4(null);
1357
1731
  const [modelChoicesLoading, setModelChoicesLoading] = useState4(false);
1358
1732
  const [threadsLoading, setThreadsLoading] = useState4(false);
1359
1733
  const [pendingQuestions, setPendingQuestions] = useState4([]);
@@ -1382,7 +1756,7 @@ function App(props) {
1382
1756
  const wordwheelRows = wordwheelCount > 0 ? Math.min(SLASH_COMMAND_WORDWHEEL_SIZE, wordwheelCount) + 1 : 0;
1383
1757
  const questionRows = pendingQuestion ? Math.min(QUESTION_OPTION_WINDOW_SIZE, Math.max(1, questionOptionCount(pendingQuestion))) + 4 : 0;
1384
1758
  const modelPickerWindowSize = Math.max(4, Math.min(10, termRows - 12));
1385
- const inventoryPickerRows = overlay === "model" || overlay === "start-category" || overlay === "start-craftbook" ? modelPickerWindowSize + 5 : 0;
1759
+ const inventoryPickerRows = overlay === "model" || overlay === "model-download" || overlay === "start-category" || overlay === "start-craftbook" ? modelPickerWindowSize + 5 : 0;
1386
1760
  const visibleRows = Math.max(
1387
1761
  4,
1388
1762
  termRows - 7 - wordwheelRows - questionRows - inventoryPickerRows
@@ -1403,6 +1777,23 @@ function App(props) {
1403
1777
  (text, kind = "note") => setRows((r) => appendNote(r, text, kind)),
1404
1778
  []
1405
1779
  );
1780
+ const gezelIds = useRef2(/* @__PURE__ */ new Set());
1781
+ const gezelRefreshInFlight = useRef2(false);
1782
+ const applyGezelSnapshot = useCallback((next) => {
1783
+ gezelIds.current = new Set(next.map((gezel) => gezel.id));
1784
+ setGezels(next);
1785
+ }, []);
1786
+ const refreshGezels = useCallback(async () => {
1787
+ if (gezelRefreshInFlight.current) return;
1788
+ gezelRefreshInFlight.current = true;
1789
+ try {
1790
+ const result = await client.listGezels();
1791
+ applyGezelSnapshot(result.gezels);
1792
+ } catch {
1793
+ } finally {
1794
+ gezelRefreshInFlight.current = false;
1795
+ }
1796
+ }, [applyGezelSnapshot, client]);
1406
1797
  const taskLoadSequence = useRef2(0);
1407
1798
  const refreshTasks = useCallback(async () => {
1408
1799
  const sequence = ++taskLoadSequence.current;
@@ -1418,13 +1809,13 @@ function App(props) {
1418
1809
  const sequence = ++craftbookLoadSequence.current;
1419
1810
  const result = await client.listProjectCraftbooks(projectId);
1420
1811
  if (sequence !== craftbookLoadSequence.current) return [];
1421
- const next = normalizeCraftbooks(result.items);
1812
+ const next = normalizeCraftbooks(result.items, config?.showWorkInProgressFeatures === true);
1422
1813
  setCraftbooks(next);
1423
1814
  setCraftbookProjectType(result.projectType ?? null);
1424
1815
  setSuggestedCraftbookIds(new Set(result.suggestedIds ?? []));
1425
1816
  setCraftbooksNeedingSetup(new Set(Object.keys(result.missingToolsets)));
1426
1817
  return next;
1427
- }, [client, projectId]);
1818
+ }, [client, config?.showWorkInProgressFeatures, projectId]);
1428
1819
  useProjectEvents(
1429
1820
  client,
1430
1821
  projectId,
@@ -1432,6 +1823,8 @@ function App(props) {
1432
1823
  (env) => {
1433
1824
  setRows((r) => reduceFeed(r, env));
1434
1825
  setTurns((t) => reduceTurns(t, env));
1826
+ const eventGezelId = env.gezelId || (env.event.type === "task_event" ? env.event.gezelId : void 0);
1827
+ if (eventGezelId && !gezelIds.current.has(eventGezelId)) void refreshGezels();
1435
1828
  if (env.event.type === "task_event") void refreshTasks();
1436
1829
  if (env.event.type === "user_message" && env.sessionId === ownSessionId) {
1437
1830
  const nextTitle = env.event.message.content.slice(0, 60).trim() || "Untitled";
@@ -1447,7 +1840,7 @@ function App(props) {
1447
1840
  setPendingQuestions((questions) => updatePendingQuestion(questions, question));
1448
1841
  }
1449
1842
  },
1450
- [ownSessionId, refreshTasks]
1843
+ [ownSessionId, refreshGezels, refreshTasks]
1451
1844
  )
1452
1845
  );
1453
1846
  useTerminalEvents(
@@ -1486,7 +1879,11 @@ function App(props) {
1486
1879
  const ensureSession = useCallback(
1487
1880
  async (gezelId, pid) => {
1488
1881
  try {
1489
- const session = await client.createChatSession({ gezelId, projectId: pid });
1882
+ const session = await client.createChatSession({
1883
+ gezelId,
1884
+ projectId: pid,
1885
+ roleBasedNameOnlyMode: boring
1886
+ });
1490
1887
  setOwnSessionId(session.id);
1491
1888
  setFocusedSessionId(session.id);
1492
1889
  setActiveThreadTitle(displayThreadTitle(session.title));
@@ -1496,7 +1893,7 @@ function App(props) {
1496
1893
  return false;
1497
1894
  }
1498
1895
  },
1499
- [client, note]
1896
+ [client, note, boring]
1500
1897
  );
1501
1898
  const switchProject = useCallback(
1502
1899
  async (id) => {
@@ -1530,6 +1927,56 @@ function App(props) {
1530
1927
  },
1531
1928
  [client, ensureSession, note, projectId, projects]
1532
1929
  );
1930
+ const openModelPicker = useCallback(async () => {
1931
+ if (!activeGezelId || !activeGezel) return note("no active gezel yet.", "error");
1932
+ if (activeGezel.fixedFunction) {
1933
+ return note("this gezel runs a fixed tool and does not use a chat model.", "error");
1934
+ }
1935
+ if (modelChoicesLoading) return note("model choices are already loading.");
1936
+ setModelChoicesLoading(true);
1937
+ note("loading available engines and models\u2026");
1938
+ try {
1939
+ const choices = await loadModelChoices(client, config ?? await client.getConfig());
1940
+ setModelChoices(choices);
1941
+ setOverlay("model");
1942
+ } catch (err) {
1943
+ note(`could not load models: ${errMsg(err)}`, "error");
1944
+ } finally {
1945
+ setModelChoicesLoading(false);
1946
+ }
1947
+ }, [activeGezel, activeGezelId, client, config, modelChoicesLoading, note]);
1948
+ const openModelDownloadPicker = useCallback(
1949
+ async (returnTo = null) => {
1950
+ if (!activeGezelId || !activeGezel) return note("no active gezel yet.", "error");
1951
+ if (activeGezel.fixedFunction) {
1952
+ return note("this gezel runs a fixed tool and does not use a chat model.", "error");
1953
+ }
1954
+ if (modelChoicesLoading) return note("model choices are already loading.");
1955
+ setOverlay(null);
1956
+ setModelChoicesLoading(true);
1957
+ note("finding on-device models that fit this machine\u2026");
1958
+ try {
1959
+ const choices = await loadModelDownloadChoices(
1960
+ client,
1961
+ config ?? await client.getConfig()
1962
+ );
1963
+ if (choices.length === 0) {
1964
+ note("no additional compatible on-device models are available to download.");
1965
+ if (returnTo === "model") await openModelPicker();
1966
+ return;
1967
+ }
1968
+ setModelDownloadChoices(choices);
1969
+ setModelDownloadProgress(null);
1970
+ setModelDownloadReturn(returnTo);
1971
+ setOverlay("model-download");
1972
+ } catch (err) {
1973
+ note(`could not load downloadable models: ${errMsg(err)}`, "error");
1974
+ } finally {
1975
+ setModelChoicesLoading(false);
1976
+ }
1977
+ },
1978
+ [activeGezel, activeGezelId, client, config, modelChoicesLoading, note, openModelPicker]
1979
+ );
1533
1980
  const openThreadPicker = useCallback(async () => {
1534
1981
  if (!activeGezelId) return note("no active gezel yet.", "error");
1535
1982
  if (threadsLoading) return;
@@ -1566,7 +2013,11 @@ function App(props) {
1566
2013
  setOverlay(null);
1567
2014
  if (!activeGezelId) return note("no active gezel yet.", "error");
1568
2015
  try {
1569
- const session = await client.createChatSession({ gezelId: activeGezelId, projectId });
2016
+ const session = await client.createChatSession({
2017
+ gezelId: activeGezelId,
2018
+ projectId,
2019
+ roleBasedNameOnlyMode: boring
2020
+ });
1570
2021
  setOwnSessionId(session.id);
1571
2022
  setFocusedSessionId(session.id);
1572
2023
  setActiveThreadTitle(displayThreadTitle(session.title));
@@ -1575,7 +2026,7 @@ function App(props) {
1575
2026
  } catch (err) {
1576
2027
  note(`could not start a thread: ${errMsg(err)}`, "error");
1577
2028
  }
1578
- }, [activeGezelId, client, note, projectId]);
2029
+ }, [activeGezelId, client, note, projectId, boring]);
1579
2030
  useEffect3(() => {
1580
2031
  let cancelled = false;
1581
2032
  (async () => {
@@ -1587,22 +2038,31 @@ function App(props) {
1587
2038
  ]);
1588
2039
  if (cancelled) return;
1589
2040
  setConfig(cfg);
1590
- setGezels(gz.gezels);
1591
- setProjects(
1592
- pj.projects.map((p) => ({
1593
- id: p.id,
1594
- name: p.name,
1595
- workingDir: p.workingDir,
1596
- voormanGezelId: p.voormanGezelId,
1597
- managedWorkspaceWritePolicy: p.managedWorkspaceWritePolicy,
1598
- allowGezelWrites: p.allowGezelWrites,
1599
- codexPermissionMode: p.codexPermissionMode,
1600
- claudePermissionMode: p.claudePermissionMode
1601
- }))
1602
- );
2041
+ applyGezelSnapshot(gz.gezels);
2042
+ const projectRows = pj.projects.map((p) => ({
2043
+ id: p.id,
2044
+ name: p.name,
2045
+ workingDir: p.workingDir,
2046
+ voormanGezelId: p.voormanGezelId,
2047
+ managedWorkspaceWritePolicy: p.managedWorkspaceWritePolicy,
2048
+ allowGezelWrites: p.allowGezelWrites,
2049
+ codexPermissionMode: p.codexPermissionMode,
2050
+ claudePermissionMode: p.claudePermissionMode
2051
+ }));
2052
+ setProjects(projectRows);
1603
2053
  const gezelId = props.initialGezelId;
2054
+ const initialGezel = gz.gezels.find((gezel) => gezel.id === gezelId);
2055
+ const initialProject = projectRows.find((project) => project.id === projectId);
1604
2056
  setActiveGezelId(gezelId);
1605
2057
  setStatus(null);
2058
+ if (activeAccessMode({
2059
+ provider: initialGezel?.provider ?? cfg.provider,
2060
+ project: initialProject,
2061
+ gezel: initialGezel,
2062
+ config: cfg
2063
+ }) === "read-only") {
2064
+ note(READ_ONLY_BOOT_NOTE);
2065
+ }
1606
2066
  await ensureSession(gezelId, projectId);
1607
2067
  } catch (err) {
1608
2068
  if (!cancelled) setStatus(`Failed to connect: ${errMsg(err)}`);
@@ -1674,7 +2134,8 @@ function App(props) {
1674
2134
  for (const r of rows) {
1675
2135
  if (r.sessionId === "local" || r.sessionId.startsWith("term-")) continue;
1676
2136
  if (!seen.has(r.sessionId)) {
1677
- const label = gezels.find((g) => g.id === r.gezelId)?.name ?? (r.gezelId || r.sessionId);
2137
+ const gezel = gezels.find((candidate) => candidate.id === r.gezelId);
2138
+ const label = boring ? gezelLabel(r.gezelId, gezels, true) : gezel?.name ?? (r.gezelId || r.sessionId);
1678
2139
  seen.set(r.sessionId, label);
1679
2140
  }
1680
2141
  }
@@ -1685,7 +2146,7 @@ function App(props) {
1685
2146
  items.push({ label, value: sid });
1686
2147
  }
1687
2148
  return items;
1688
- }, [rows, gezels, ownSessionId, gezelLine]);
2149
+ }, [rows, gezels, ownSessionId, gezelLine, boring]);
1689
2150
  const cancelActive = useCallback(async () => {
1690
2151
  const sessions = [...turns.keys()];
1691
2152
  const runs = [...activeRuns];
@@ -1718,6 +2179,37 @@ function App(props) {
1718
2179
  },
1719
2180
  [client, note]
1720
2181
  );
2182
+ const applyProjectPermission = useCallback(
2183
+ async (permission, allowed) => {
2184
+ const permissionName = parseProjectPermissionName(permission);
2185
+ if (!permissionName) {
2186
+ note(`usage: /${allowed ? "allow" : "disallow"} ${PROJECT_PERMISSION_USAGE}`, "error");
2187
+ return;
2188
+ }
2189
+ try {
2190
+ const patch = permissionName === "edits" ? { managedWorkspaceWritePolicy: allowed ? "allow" : "deny" } : permissionName === "codexedits" ? { codexPermissionMode: allowed ? "edit" : "plan" } : { claudePermissionMode: allowed ? "acceptEdits" : "plan" };
2191
+ const updated = await client.updateProject(projectId, patch);
2192
+ setProjects(
2193
+ (current) => current.map(
2194
+ (project) => project.id === projectId ? { ...project, ...updated } : project
2195
+ )
2196
+ );
2197
+ if (permissionName === "edits") {
2198
+ note(
2199
+ allowed ? `Project edits allowed. Built-in tools and background work can now modify ${projectName}.` : `Project edits disallowed. Built-in tools and background work are now read-only in ${projectName}.`
2200
+ );
2201
+ } else {
2202
+ const provider = permissionName === "codexedits" ? "Codex" : "Claude";
2203
+ note(
2204
+ allowed ? `${provider} edits allowed. ${provider} sessions can now modify ${projectName}.` : `${provider} edits disallowed. ${provider} sessions are now read-only in ${projectName}.`
2205
+ );
2206
+ }
2207
+ } catch (err) {
2208
+ note(`could not change project permission: ${errMsg(err)}`, "error");
2209
+ }
2210
+ },
2211
+ [client, note, projectId, projectName]
2212
+ );
1721
2213
  const startCraftbook = useCallback(
1722
2214
  async (book) => {
1723
2215
  setOverlay(null);
@@ -1834,7 +2326,10 @@ function App(props) {
1834
2326
  const target = focusedSessionId ?? ownSessionId;
1835
2327
  if (!target) return note("no active session yet.", "error");
1836
2328
  try {
1837
- await client.sendToChatSession(target, parsed.text);
2329
+ await client.sendToChatSession(
2330
+ target,
2331
+ turns.has(target) ? { message: parsed.text, nudge: true } : parsed.text
2332
+ );
1838
2333
  } catch (err) {
1839
2334
  note(`send failed: ${errMsg(err)}`, "error");
1840
2335
  }
@@ -1897,7 +2392,8 @@ function App(props) {
1897
2392
  note,
1898
2393
  pendingInput,
1899
2394
  submitTaskPrompt,
1900
- taskPrompt
2395
+ taskPrompt,
2396
+ turns
1901
2397
  ]
1902
2398
  );
1903
2399
  const runCommand = useCallback(
@@ -1911,31 +2407,21 @@ function App(props) {
1911
2407
  return setOverlay("project");
1912
2408
  case "gezel":
1913
2409
  return setOverlay("gezel");
2410
+ case "allow":
2411
+ await applyProjectPermission(rest, true);
2412
+ return;
2413
+ case "disallow":
2414
+ await applyProjectPermission(rest, false);
2415
+ return;
1914
2416
  case "mode":
1915
2417
  if (!rest.trim()) return setOverlay("engagement-mode");
1916
2418
  await applyEngagementMode(rest);
1917
2419
  return;
1918
2420
  case "model": {
1919
- if (!activeGezelId || !activeGezel) return note("no active gezel yet.", "error");
1920
- if (activeGezel.fixedFunction) {
1921
- return note("this gezel runs a fixed tool and does not use a chat model.", "error");
1922
- }
1923
- if (modelChoicesLoading) return note("model choices are already loading.");
1924
- setModelChoicesLoading(true);
1925
- note("loading available engines and models\u2026");
1926
- try {
1927
- const choices = await loadModelChoices(client, config ?? await client.getConfig());
1928
- if (choices.length === 0) {
1929
- return note("no engines with available chat models were found.", "error");
1930
- }
1931
- setModelChoices(choices);
1932
- setOverlay("model");
1933
- } catch (err) {
1934
- note(`could not load models: ${errMsg(err)}`, "error");
1935
- } finally {
1936
- setModelChoicesLoading(false);
1937
- }
1938
- return;
2421
+ const subcommand = rest.trim().toLowerCase();
2422
+ if (!subcommand) return openModelPicker();
2423
+ if (subcommand === "download") return openModelDownloadPicker();
2424
+ return note("usage: /model [download]", "error");
1939
2425
  }
1940
2426
  case "thread":
1941
2427
  await openThreadPicker();
@@ -1986,7 +2472,7 @@ function App(props) {
1986
2472
  }
1987
2473
  return;
1988
2474
  }
1989
- case "start": {
2475
+ case "do": {
1990
2476
  let available = craftbooks;
1991
2477
  if (available.length === 0) {
1992
2478
  try {
@@ -2004,7 +2490,7 @@ function App(props) {
2004
2490
  }
2005
2491
  const book = findCraftbook(available, rest);
2006
2492
  if (!book) {
2007
- return note(`craftbook not found: ${rest.trim()} (try /start)`, "error");
2493
+ return note(`craftbook not found: ${rest.trim()} (try /do)`, "error");
2008
2494
  }
2009
2495
  await startCraftbook(book);
2010
2496
  return;
@@ -2062,15 +2548,14 @@ function App(props) {
2062
2548
  }
2063
2549
  },
2064
2550
  [
2065
- activeGezel,
2066
- activeGezelId,
2067
2551
  applyEngagementMode,
2552
+ applyProjectPermission,
2068
2553
  client,
2069
- config,
2070
2554
  craftbooks,
2071
- modelChoicesLoading,
2072
2555
  note,
2073
2556
  exit,
2557
+ openModelDownloadPicker,
2558
+ openModelPicker,
2074
2559
  openThreadPicker,
2075
2560
  projectId,
2076
2561
  projectName,
@@ -2079,11 +2564,10 @@ function App(props) {
2079
2564
  startCraftbook
2080
2565
  ]
2081
2566
  );
2082
- const applyModelChoice = useCallback(
2083
- async (value2) => {
2567
+ const applyModelSelection = useCallback(
2568
+ async (choice) => {
2084
2569
  setOverlay(null);
2085
2570
  if (!activeGezelId || !activeGezel || !config) return;
2086
- const choice = modelChoices.find((item) => item.value === value2);
2087
2571
  const nextProvider = choice?.provider ?? null;
2088
2572
  const nextModel = choice?.model.id;
2089
2573
  const providerChanged = (activeGezel.provider ?? null) !== nextProvider;
@@ -2108,8 +2592,80 @@ function App(props) {
2108
2592
  note(`could not switch model: ${errMsg(err)}`, "error");
2109
2593
  }
2110
2594
  },
2111
- [activeGezel, activeGezelId, client, config, ensureSession, modelChoices, note, projectId]
2595
+ [activeGezel, activeGezelId, client, config, ensureSession, note, projectId]
2596
+ );
2597
+ const applyModelChoice = useCallback(
2598
+ async (value2) => {
2599
+ await applyModelSelection(modelChoices.find((item) => item.value === value2));
2600
+ },
2601
+ [applyModelSelection, modelChoices]
2112
2602
  );
2603
+ const installModelDownload = useCallback(
2604
+ async (value2) => {
2605
+ const choice = modelDownloadChoices.find((candidate) => candidate.value === value2);
2606
+ if (!choice) return;
2607
+ let terminalError = null;
2608
+ setModelDownloadProgress({
2609
+ choice,
2610
+ bytesWritten: 0,
2611
+ totalBytes: choice.model.approxSizeBytes,
2612
+ pct: 0,
2613
+ phase: "starting"
2614
+ });
2615
+ const onEvent = (event) => {
2616
+ if (event.type === "error") terminalError = event.error;
2617
+ const progress = readModelDownloadProgress(choice, event);
2618
+ if (progress) setModelDownloadProgress(progress);
2619
+ };
2620
+ try {
2621
+ if (choice.provider === "mlx") {
2622
+ await client.installMlxModel(choice.model.id, onEvent);
2623
+ } else {
2624
+ await client.installLlamaCppModel(choice.model.id, onEvent);
2625
+ }
2626
+ if (terminalError) throw new Error(terminalError);
2627
+ const installedChoice = {
2628
+ provider: choice.provider,
2629
+ model: {
2630
+ id: choice.model.id,
2631
+ name: choice.model.name
2632
+ },
2633
+ value: choice.value,
2634
+ label: `${modelProviderLabel(choice.provider)} \xB7 ${choice.model.name}`
2635
+ };
2636
+ setModelChoices((current) => [
2637
+ ...current.filter((candidate) => candidate.value !== installedChoice.value),
2638
+ installedChoice
2639
+ ]);
2640
+ setModelDownloadProgress(null);
2641
+ note(`downloaded ${choice.model.name}; switching this gezel to it\u2026`);
2642
+ await applyModelSelection(installedChoice);
2643
+ } catch (err) {
2644
+ setModelDownloadProgress(null);
2645
+ setOverlay("model-download");
2646
+ note(`model download failed: ${errMsg(err)}`, "error");
2647
+ }
2648
+ },
2649
+ [applyModelSelection, client, modelDownloadChoices, note]
2650
+ );
2651
+ const cancelModelDownload = useCallback(async () => {
2652
+ const progress = modelDownloadProgress;
2653
+ if (!progress) return;
2654
+ try {
2655
+ if (progress.choice.provider === "mlx") {
2656
+ await client.cancelMlxModelInstall(progress.choice.model.id);
2657
+ } else {
2658
+ await client.cancelLlamaCppModelInstall(progress.choice.model.id);
2659
+ }
2660
+ note(`canceled the ${progress.choice.model.name} download.`);
2661
+ } catch (err) {
2662
+ note(`could not cancel model download: ${errMsg(err)}`, "error");
2663
+ } finally {
2664
+ setModelDownloadProgress(null);
2665
+ if (modelDownloadReturn === "model") await openModelPicker();
2666
+ else setOverlay(null);
2667
+ }
2668
+ }, [client, modelDownloadProgress, modelDownloadReturn, note, openModelPicker]);
2113
2669
  const onSubmit = useCallback(
2114
2670
  (raw) => {
2115
2671
  setValue("");
@@ -2155,10 +2711,10 @@ function App(props) {
2155
2711
  }
2156
2712
  );
2157
2713
  if (status) {
2158
- return /* @__PURE__ */ jsx6(Box6, { flexDirection: "column", padding: 1, children: /* @__PURE__ */ jsx6(Text6, { color: status.startsWith("Failed") ? "red" : "cyan", children: status }) });
2714
+ return /* @__PURE__ */ jsx5(Box6, { flexDirection: "column", padding: 1, children: /* @__PURE__ */ jsx5(Text6, { color: status.startsWith("Failed") ? "red" : "cyan", children: status }) });
2159
2715
  }
2160
2716
  return /* @__PURE__ */ jsxs6(Box6, { flexDirection: "column", padding: 1, children: [
2161
- /* @__PURE__ */ jsx6(
2717
+ /* @__PURE__ */ jsx5(
2162
2718
  ChatFeed,
2163
2719
  {
2164
2720
  rows,
@@ -2168,7 +2724,7 @@ function App(props) {
2168
2724
  visible: visibleRows
2169
2725
  }
2170
2726
  ),
2171
- overlay === "project" ? /* @__PURE__ */ jsx6(
2727
+ overlay === "project" ? /* @__PURE__ */ jsx5(
2172
2728
  Picker,
2173
2729
  {
2174
2730
  title: "Switch project",
@@ -2177,7 +2733,7 @@ function App(props) {
2177
2733
  onSelect: (id) => void switchProject(id)
2178
2734
  }
2179
2735
  ) : null,
2180
- overlay === "gezel" ? /* @__PURE__ */ jsx6(
2736
+ overlay === "gezel" ? /* @__PURE__ */ jsx5(
2181
2737
  Picker,
2182
2738
  {
2183
2739
  title: "Switch gezel",
@@ -2197,7 +2753,7 @@ function App(props) {
2197
2753
  }
2198
2754
  }
2199
2755
  ) : null,
2200
- overlay === "engagement-mode" ? /* @__PURE__ */ jsx6(
2756
+ overlay === "engagement-mode" ? /* @__PURE__ */ jsx5(
2201
2757
  Picker,
2202
2758
  {
2203
2759
  title: "Choose AI engagement mode",
@@ -2211,16 +2767,21 @@ function App(props) {
2211
2767
  onSelect: (selected) => void applyEngagementMode(selected)
2212
2768
  }
2213
2769
  ) : null,
2214
- overlay === "model" ? /* @__PURE__ */ jsx6(
2770
+ overlay === "model" ? /* @__PURE__ */ jsx5(
2215
2771
  Picker,
2216
2772
  {
2217
- title: "Choose engine + model",
2773
+ title: "Choose engine + model - models are downloaded from Hugging Face (huggingface.co)",
2218
2774
  items: [
2219
2775
  {
2220
2776
  label: "Use default",
2221
2777
  value: "__default__",
2222
2778
  hint: `${modelProviderLabel(config?.provider ?? "llama-cpp")}${config?.defaultModel?.[config.provider] ? ` \xB7 ${config.defaultModel[config.provider]}` : ""}`
2223
2779
  },
2780
+ {
2781
+ label: "Download a new model\u2026",
2782
+ value: "__download__",
2783
+ hint: "browse on-device models ranked for this machine"
2784
+ },
2224
2785
  ...modelChoices.map((choice) => ({
2225
2786
  label: choice.label,
2226
2787
  value: choice.value,
@@ -2230,10 +2791,36 @@ function App(props) {
2230
2791
  initialValue: activeGezel?.provider && activeGezel.model ? `${activeGezel.provider}:${activeGezel.model}` : "__default__",
2231
2792
  windowSize: modelPickerWindowSize,
2232
2793
  onCancel: () => setOverlay(null),
2233
- onSelect: (value2) => void applyModelChoice(value2)
2794
+ onSelect: (value2) => {
2795
+ if (value2 === "__download__") void openModelDownloadPicker("model");
2796
+ else void applyModelChoice(value2);
2797
+ }
2234
2798
  }
2235
2799
  ) : null,
2236
- overlay === "start-category" ? /* @__PURE__ */ jsx6(
2800
+ overlay === "model-download" ? modelDownloadProgress ? /* @__PURE__ */ jsx5(
2801
+ ModelDownloadProgressPanel,
2802
+ {
2803
+ progress: modelDownloadProgress,
2804
+ onCancel: () => void cancelModelDownload()
2805
+ }
2806
+ ) : /* @__PURE__ */ jsx5(
2807
+ Picker,
2808
+ {
2809
+ title: "Download and use an on-device model",
2810
+ items: modelDownloadChoices.map((choice) => ({
2811
+ label: choice.label,
2812
+ value: choice.value,
2813
+ hint: choice.hint
2814
+ })),
2815
+ windowSize: modelPickerWindowSize,
2816
+ onCancel: () => {
2817
+ if (modelDownloadReturn === "model") setOverlay("model");
2818
+ else setOverlay(null);
2819
+ },
2820
+ onSelect: (value2) => void installModelDownload(value2)
2821
+ }
2822
+ ) : null,
2823
+ overlay === "start-category" ? /* @__PURE__ */ jsx5(
2237
2824
  Picker,
2238
2825
  {
2239
2826
  title: "Choose a craftbook category",
@@ -2250,7 +2837,7 @@ function App(props) {
2250
2837
  }
2251
2838
  }
2252
2839
  ) : null,
2253
- overlay === "start-craftbook" ? /* @__PURE__ */ jsx6(
2840
+ overlay === "start-craftbook" ? /* @__PURE__ */ jsx5(
2254
2841
  Picker,
2255
2842
  {
2256
2843
  title: startCategory?.label ?? "Start a craftbook",
@@ -2267,7 +2854,7 @@ function App(props) {
2267
2854
  }
2268
2855
  }
2269
2856
  ) : null,
2270
- overlay === "thread" ? /* @__PURE__ */ jsx6(
2857
+ overlay === "thread" ? /* @__PURE__ */ jsx5(
2271
2858
  Picker,
2272
2859
  {
2273
2860
  title: `Threads with ${gezelLine}`,
@@ -2288,7 +2875,7 @@ function App(props) {
2288
2875
  }
2289
2876
  }
2290
2877
  ) : null,
2291
- overlay === "task" ? /* @__PURE__ */ jsx6(
2878
+ overlay === "task" ? /* @__PURE__ */ jsx5(
2292
2879
  Picker,
2293
2880
  {
2294
2881
  title: `Tasks \xB7 ${tasks.filter((task) => task.status === "active").length} active`,
@@ -2313,7 +2900,7 @@ function App(props) {
2313
2900
  }
2314
2901
  }
2315
2902
  ) : null,
2316
- overlay === "task-actions" && managedTask ? /* @__PURE__ */ jsx6(
2903
+ overlay === "task-actions" && managedTask ? /* @__PURE__ */ jsx5(
2317
2904
  Picker,
2318
2905
  {
2319
2906
  title: `${managedTask.ref} \xB7 ${managedTask.status}`,
@@ -2348,7 +2935,7 @@ function App(props) {
2348
2935
  }
2349
2936
  }
2350
2937
  ) : null,
2351
- overlay === "task-status" && managedTask ? /* @__PURE__ */ jsx6(
2938
+ overlay === "task-status" && managedTask ? /* @__PURE__ */ jsx5(
2352
2939
  Picker,
2353
2940
  {
2354
2941
  title: `Set ${managedTask.ref} status`,
@@ -2357,7 +2944,7 @@ function App(props) {
2357
2944
  onSelect: (status2) => void applyTaskStatus(status2)
2358
2945
  }
2359
2946
  ) : null,
2360
- overlay === "task-assignee" && managedTask ? /* @__PURE__ */ jsx6(
2947
+ overlay === "task-assignee" && managedTask ? /* @__PURE__ */ jsx5(
2361
2948
  Picker,
2362
2949
  {
2363
2950
  title: `Assign ${managedTask.ref}`,
@@ -2377,7 +2964,7 @@ function App(props) {
2377
2964
  onSelect: (assignee) => void applyTaskAssignee(assignee)
2378
2965
  }
2379
2966
  ) : null,
2380
- overlay === "focus" ? /* @__PURE__ */ jsx6(
2967
+ overlay === "focus" ? /* @__PURE__ */ jsx5(
2381
2968
  Picker,
2382
2969
  {
2383
2970
  title: "Send into which chat?",
@@ -2389,7 +2976,7 @@ function App(props) {
2389
2976
  }
2390
2977
  }
2391
2978
  ) : null,
2392
- overlay === null && pendingQuestion ? /* @__PURE__ */ jsx6(
2979
+ overlay === null && pendingQuestion ? /* @__PURE__ */ jsx5(
2393
2980
  QuestionPrompt,
2394
2981
  {
2395
2982
  client,
@@ -2403,7 +2990,7 @@ function App(props) {
2403
2990
  },
2404
2991
  pendingQuestion.id
2405
2992
  ) : null,
2406
- /* @__PURE__ */ jsx6(
2993
+ /* @__PURE__ */ jsx5(
2407
2994
  PromptLine,
2408
2995
  {
2409
2996
  projectName,
@@ -2427,6 +3014,52 @@ function App(props) {
2427
3014
  )
2428
3015
  ] });
2429
3016
  }
3017
+ function ModelDownloadProgressPanel(props) {
3018
+ const { progress, onCancel } = props;
3019
+ useInput4((input, key) => {
3020
+ if (key.escape || key.ctrl && input === "c") onCancel();
3021
+ });
3022
+ const transferred = progress.totalBytes ? `${formatModelBytes(progress.bytesWritten)} / ${formatModelBytes(progress.totalBytes)}` : formatModelBytes(progress.bytesWritten);
3023
+ return /* @__PURE__ */ jsxs6(Box6, { flexDirection: "column", borderStyle: "round", borderColor: "yellow", paddingX: 1, children: [
3024
+ /* @__PURE__ */ jsxs6(Text6, { bold: true, color: "yellow", children: [
3025
+ "Downloading ",
3026
+ progress.choice.model.name
3027
+ ] }),
3028
+ /* @__PURE__ */ jsxs6(Text6, { children: [
3029
+ progress.pct == null ? "Working\u2026" : `${progress.pct}%`,
3030
+ " \xB7 ",
3031
+ transferred
3032
+ ] }),
3033
+ progress.phase ? /* @__PURE__ */ jsx5(Text6, { dimColor: true, children: progress.phase }) : null,
3034
+ /* @__PURE__ */ jsx5(Text6, { dimColor: true, children: "Esc / Ctrl+C cancel" })
3035
+ ] });
3036
+ }
3037
+ function readModelDownloadProgress(choice, event) {
3038
+ if (event.type === "progress") {
3039
+ const bytesWritten = "bytesWrittenAll" in event ? event.bytesWrittenAll : event.bytesWritten;
3040
+ const totalBytes = "totalBytesAll" in event ? event.totalBytesAll : event.totalBytes;
3041
+ return {
3042
+ choice,
3043
+ bytesWritten,
3044
+ totalBytes,
3045
+ pct: totalBytes > 0 ? Math.min(100, Math.floor(bytesWritten / totalBytes * 100)) : null,
3046
+ phase: "downloading and verifying model files"
3047
+ };
3048
+ }
3049
+ if (event.type === "companion") {
3050
+ return {
3051
+ choice,
3052
+ bytesWritten: event.bytesWritten,
3053
+ totalBytes: event.totalBytes,
3054
+ pct: event.totalBytes > 0 ? Math.min(100, Math.floor(event.bytesWritten / event.totalBytes * 100)) : null,
3055
+ phase: `downloading ${event.name}`
3056
+ };
3057
+ }
3058
+ return null;
3059
+ }
3060
+ function formatModelBytes(bytes) {
3061
+ return bytes >= 1e9 ? `${(bytes / 1e9).toFixed(1)} GB` : `${Math.max(0, Math.round(bytes / 1e6))} MB`;
3062
+ }
2430
3063
  function errMsg(err) {
2431
3064
  return err instanceof Error ? err.message : String(err);
2432
3065
  }
@@ -2501,7 +3134,7 @@ function taskAssigneeLabel(task, gezels, boring) {
2501
3134
  if (task.assignee.kind === "user") return "you";
2502
3135
  const gezelId = task.assignee.gezelId;
2503
3136
  const gezel = gezels.find((item) => item.id === gezelId);
2504
- if (!gezel) return gezelId;
3137
+ if (!gezel) return boring ? "gezel" : gezelId;
2505
3138
  return boring ? gezel.roleBasedName ?? gezel.role ?? gezel.id : gezel.name;
2506
3139
  }
2507
3140
  function taskStatusChoices(task) {
@@ -2529,174 +3162,10 @@ function formatTaskDetails(task, gezels, boring) {
2529
3162
  }
2530
3163
 
2531
3164
  // src/tui/components/BootstrapGate.tsx
3165
+ import { formatModelAttribution as formatModelAttribution3 } from "@bendyline/gezel";
2532
3166
  import { Box as Box7, Text as Text7, useApp as useApp2, useInput as useInput5 } from "ink";
2533
3167
  import { useCallback as useCallback2, useEffect as useEffect4, useState as useState5 } from "react";
2534
-
2535
- // src/tui/bootstrap.ts
2536
- import {
2537
- computeModelFit,
2538
- isMoEFromTags,
2539
- isRecommendedModel,
2540
- mediaModelFits,
2541
- pickRecommendedModel
2542
- } from "@bendyline/gezel";
2543
- var CHAT_MEMORY_OVERHEAD = {
2544
- "llama-cpp": 1.2,
2545
- mlx: 1.3
2546
- };
2547
- var NATIVE_TOOLKIT = [
2548
- "uv",
2549
- "sd-server",
2550
- "whisper-server",
2551
- "llama-server"
2552
- ];
2553
- function rankChatModels(items, device, provider) {
2554
- const candidates = [];
2555
- for (const item of items) {
2556
- if (item.manifest.kind !== "chat-model") continue;
2557
- const manifest = item.manifest;
2558
- if (manifest.licenseClass !== "open") continue;
2559
- const source = provider === "mlx" ? manifest.mlx : manifest.llamaCpp;
2560
- if (!source || provider === "mlx" && manifest.mlx?.disabledReason) continue;
2561
- const residentBytes = source.residentBytes ?? Math.round(source.approxSizeBytes * CHAT_MEMORY_OVERHEAD[provider]);
2562
- const fit = computeModelFit({
2563
- residentBytes,
2564
- isMoE: isMoEFromTags(manifest.tags),
2565
- usableBytes: device.usableBytes,
2566
- totalRamBytes: device.totalRamBytes,
2567
- gpuVramBytes: device.gpuVramBytes,
2568
- ...device.budgetBytes !== void 0 ? { admissibleBytes: device.budgetBytes } : {}
2569
- }).tier;
2570
- candidates.push({
2571
- id: manifest.id,
2572
- name: manifest.name,
2573
- provider,
2574
- approxSizeBytes: source.approxSizeBytes,
2575
- residentBytes,
2576
- // Effective score: a model the shared gate rejects (restricted license,
2577
- // no tool support) sorts as unscored rather than leading the list.
2578
- recoScore: isRecommendedModel(manifest) ? manifest.recoScore ?? 0 : 0,
2579
- fit
2580
- });
2581
- }
2582
- if (candidates.length === 0) return [];
2583
- const picked = pickRecommendedModel(
2584
- candidates.map((model) => ({
2585
- id: model.id,
2586
- ...model.recoScore > 0 ? { recoScore: model.recoScore } : {},
2587
- licenseClass: "open",
2588
- tags: items.find((item) => item.manifest.kind === "chat-model" && item.manifest.id === model.id)?.manifest?.tags ?? [],
2589
- residentBytes: model.residentBytes
2590
- })),
2591
- device
2592
- );
2593
- const comfortable = candidates.filter(
2594
- (model) => model.fit === "fits" || model.fit === "fits-offload"
2595
- );
2596
- const pool = comfortable.length > 0 ? comfortable : candidates;
2597
- pool.sort(
2598
- (a, b) => b.recoScore - a.recoScore || fitOrder(a.fit) - fitOrder(b.fit) || b.residentBytes - a.residentBytes || a.name.localeCompare(b.name)
2599
- );
2600
- if (!picked) return pool;
2601
- const bestIndex = pool.findIndex((model) => model.id === picked.id);
2602
- if (bestIndex < 0) {
2603
- const best = candidates.find((model) => model.id === picked.id);
2604
- if (best) pool.unshift(best);
2605
- return pool;
2606
- }
2607
- if (bestIndex > 0) {
2608
- const [best] = pool.splice(bestIndex, 1);
2609
- if (best) pool.unshift(best);
2610
- }
2611
- return pool;
2612
- }
2613
- function pickAccessoryModels(input, device) {
2614
- const output = [];
2615
- const image = pickCatalogMedia(input.imageItems, device, "image");
2616
- if (image && !input.installed.image?.has(image.id)) {
2617
- output.push({
2618
- kind: "image",
2619
- id: image.id,
2620
- name: image.name,
2621
- approxSizeBytes: image.approxSizeBytes + (image.auxiliaryFiles ?? []).reduce((sum, file) => sum + (file.sizeBytes ?? 0), 0),
2622
- requiredEngine: "sd-server"
2623
- });
2624
- }
2625
- const recognition = pickScoredOpen(input.recognition, false);
2626
- if (recognition && !input.installed.recognition?.has(recognition.id)) {
2627
- output.push({
2628
- kind: "recognition",
2629
- id: recognition.id,
2630
- name: recognition.name,
2631
- approxSizeBytes: recognition.approxSizeBytes,
2632
- requiredEngine: "llama-server"
2633
- });
2634
- }
2635
- const stt = pickScoredOpen(input.audio.stt);
2636
- if (stt && !input.installed.stt?.has(stt.id)) {
2637
- output.push({
2638
- kind: "stt",
2639
- id: stt.id,
2640
- name: stt.name,
2641
- approxSizeBytes: stt.approxSizeBytes,
2642
- requiredEngine: "whisper-server"
2643
- });
2644
- }
2645
- const tts = pickScoredOpen(input.audio.tts);
2646
- if (tts && !input.installed.tts?.has(tts.id)) {
2647
- output.push({
2648
- kind: "tts",
2649
- id: tts.id,
2650
- name: tts.name,
2651
- approxSizeBytes: tts.approxSizeBytes
2652
- });
2653
- }
2654
- const video = pickCatalogMedia(input.videoItems, device, "video");
2655
- if (video && !input.installed.video?.has(video.id)) {
2656
- output.push({
2657
- kind: "video",
2658
- id: video.id,
2659
- name: video.name,
2660
- approxSizeBytes: video.approxSizeBytes,
2661
- requiredEngine: "uv"
2662
- });
2663
- }
2664
- return output;
2665
- }
2666
- function formatDownloadSize(bytes) {
2667
- if (bytes >= 1e9) return `${(bytes / 1e9).toFixed(1)} GB`;
2668
- return `${Math.max(1, Math.round(bytes / 1e6))} MB`;
2669
- }
2670
- function fitOrder(fit) {
2671
- switch (fit) {
2672
- case "fits":
2673
- return 0;
2674
- case "fits-offload":
2675
- return 1;
2676
- case "tight":
2677
- return 2;
2678
- case "too-big":
2679
- return 3;
2680
- }
2681
- }
2682
- function pickCatalogMedia(items, device, kind) {
2683
- const models = items.map((item) => item.manifest).filter((model) => {
2684
- if (model.licenseClass !== "open" || !model.recoScore) return false;
2685
- return mediaModelFits(
2686
- device,
2687
- kind === "image" ? { minRamGB: model.minRamGB } : { minVramGB: model.minVramGB }
2688
- );
2689
- });
2690
- return pickScoredOpen(models);
2691
- }
2692
- function pickScoredOpen(models, requireLicense = true) {
2693
- return [...models].filter(
2694
- (model) => typeof model.recoScore === "number" && model.recoScore > 0 && (!requireLicense || model.licenseClass === "open")
2695
- ).sort((a, b) => (b.recoScore ?? 0) - (a.recoScore ?? 0))[0] ?? null;
2696
- }
2697
-
2698
- // src/tui/components/BootstrapGate.tsx
2699
- import { Fragment as Fragment4, jsx as jsx7, jsxs as jsxs7 } from "react/jsx-runtime";
3168
+ import { Fragment as Fragment4, jsx as jsx6, jsxs as jsxs7 } from "react/jsx-runtime";
2700
3169
  var MAX_ALTERNATIVE_MODELS = 6;
2701
3170
  function BootstrapGate(props) {
2702
3171
  const { client, children } = props;
@@ -2719,7 +3188,8 @@ function BootstrapGate(props) {
2719
3188
  async (context) => {
2720
3189
  setScreen({ kind: "loading", message: "Finding the best models for this device\u2026" });
2721
3190
  const installedChat = context.provider === "mlx" ? await client.listMlxModels() : await client.listLlamaCppModels();
2722
- if (installedChat.models.length > 0) {
3191
+ const pinnedModel = context.config.defaultModel?.[context.provider];
3192
+ if (pinnedModel && installedChat.models.some((model) => model.id === pinnedModel)) {
2723
3193
  setScreen({ kind: "ready" });
2724
3194
  return;
2725
3195
  }
@@ -2744,8 +3214,20 @@ function BootstrapGate(props) {
2744
3214
  client.listInstalledTtsModels().catch(() => ({ models: [] })),
2745
3215
  client.listInstalledRecognitionModels().catch(() => ({ models: [] }))
2746
3216
  ]);
2747
- const chatModels = rankChatModels(context.chatCatalog, context.device, context.provider);
2748
- if (chatModels.length === 0) {
3217
+ const installedIds = new Set(installedChat.models.map((model) => model.id));
3218
+ const rankedChatModels = rankChatModels(
3219
+ context.chatCatalog,
3220
+ context.device,
3221
+ context.provider
3222
+ );
3223
+ const recommendedChatModel = rankedChatModels[0];
3224
+ const chatModels = rankedChatModels.filter((model) => !installedIds.has(model.id));
3225
+ const catalogAttributions = new Map(
3226
+ context.chatCatalog.flatMap(
3227
+ (item) => item.manifest.kind === "chat-model" ? [[item.manifest.id, formatModelAttribution3(item.manifest)]] : []
3228
+ )
3229
+ );
3230
+ if (chatModels.length === 0 && installedChat.models.length === 0) {
2749
3231
  setScreen({
2750
3232
  kind: "error",
2751
3233
  title: "No compatible local models found",
@@ -2769,7 +3251,19 @@ function BootstrapGate(props) {
2769
3251
  },
2770
3252
  context.device
2771
3253
  );
2772
- setScreen({ kind: "model-choice", plan: { context, chatModels, accessories } });
3254
+ setScreen({
3255
+ kind: "model-choice",
3256
+ plan: {
3257
+ context,
3258
+ installedChatModels: installedChat.models.map((model) => {
3259
+ const attribution = catalogAttributions.get(model.id);
3260
+ return { ...model, ...attribution ? { attribution } : {} };
3261
+ }),
3262
+ ...recommendedChatModel ? { recommendedChatModel } : {},
3263
+ chatModels,
3264
+ accessories
3265
+ }
3266
+ });
2773
3267
  },
2774
3268
  [client]
2775
3269
  );
@@ -2797,14 +3291,7 @@ function BootstrapGate(props) {
2797
3291
  const context = {
2798
3292
  config,
2799
3293
  provider: config.provider,
2800
- device: {
2801
- platform: memory.platform,
2802
- gpuVramBytes: memory.gpuVramBytes,
2803
- ...memory.gpuMemoryKind ? { gpuMemoryKind: memory.gpuMemoryKind } : {},
2804
- totalRamBytes: memory.totalRamBytes,
2805
- usableBytes: memory.usableBytes,
2806
- ...memory.budgetBytes !== void 0 ? { budgetBytes: memory.budgetBytes } : {}
2807
- },
3294
+ device: recoDevice(memory),
2808
3295
  chatCatalog: chatCatalog.items,
2809
3296
  nativeStatus
2810
3297
  };
@@ -2839,12 +3326,19 @@ function BootstrapGate(props) {
2839
3326
  }
2840
3327
  try {
2841
3328
  await installNativeToolkit(client, context.nativeStatus, missing, setScreen);
2842
- const nativeStatus = await client.getNativeEngineStatus();
2843
- await prepareModels({ ...context, nativeStatus });
3329
+ const [nativeStatus, memory] = await Promise.all([
3330
+ client.getNativeEngineStatus(),
3331
+ client.getMemoryProfile()
3332
+ ]);
3333
+ await prepareModels({
3334
+ ...context,
3335
+ nativeStatus,
3336
+ device: recoDevice(memory)
3337
+ });
2844
3338
  } catch (error) {
2845
3339
  setScreen({
2846
3340
  kind: "error",
2847
- title: "Native toolkit install failed",
3341
+ title: "Gezel native toolkit install failed",
2848
3342
  message: errorMessage(error),
2849
3343
  retry
2850
3344
  });
@@ -2860,24 +3354,40 @@ function BootstrapGate(props) {
2860
3354
  }
2861
3355
  const retry = () => void installModels(plan, choice);
2862
3356
  try {
3357
+ if (choice.kind === "installed") {
3358
+ const updated2 = await client.updateConfig({
3359
+ provider: plan.context.provider,
3360
+ defaultModel: {
3361
+ ...plan.context.config.defaultModel,
3362
+ [plan.context.provider]: choice.modelId
3363
+ },
3364
+ firstRunInstallError: null
3365
+ });
3366
+ plan.context.config = updated2;
3367
+ setScreen({ kind: "ready" });
3368
+ return;
3369
+ }
2863
3370
  if (choice.kind === "bundle") {
2864
3371
  const missing = missingToolkit(await client.getNativeEngineStatus());
2865
3372
  if (missing.length > 0) {
2866
3373
  await installNativeToolkit(client, plan.context.nativeStatus, missing, setScreen);
2867
3374
  }
2868
3375
  }
3376
+ const chatAlreadyInstalled = choice.kind === "bundle" && plan.installedChatModels.some((model) => model.id === choice.model.id);
2869
3377
  const jobs = [
2870
- { label: choice.model.name, sizeBytes: choice.model.approxSizeBytes },
3378
+ ...!chatAlreadyInstalled ? [{ label: choice.model.name, sizeBytes: choice.model.approxSizeBytes }] : [],
2871
3379
  ...choice.kind === "bundle" ? plan.accessories.map((model) => ({
2872
3380
  label: model.name,
2873
3381
  sizeBytes: model.approxSizeBytes
2874
3382
  })) : []
2875
3383
  ];
2876
3384
  let jobIndex = 0;
2877
- await installChatModel(client, choice.model, (event) => {
2878
- updateDownloadProgress(setScreen, jobs[jobIndex], jobIndex, jobs.length, event);
2879
- });
2880
- jobIndex += 1;
3385
+ if (!chatAlreadyInstalled) {
3386
+ await installChatModel(client, choice.model, (event) => {
3387
+ updateDownloadProgress(setScreen, jobs[jobIndex], jobIndex, jobs.length, event);
3388
+ });
3389
+ jobIndex += 1;
3390
+ }
2881
3391
  const updated = await client.updateConfig({
2882
3392
  provider: choice.model.provider,
2883
3393
  defaultModel: {
@@ -2908,9 +3418,9 @@ function BootstrapGate(props) {
2908
3418
  },
2909
3419
  [client]
2910
3420
  );
2911
- if (screen.kind === "ready") return /* @__PURE__ */ jsx7(Fragment4, { children });
3421
+ if (screen.kind === "ready") return /* @__PURE__ */ jsx6(Fragment4, { children });
2912
3422
  if (screen.kind === "loading") {
2913
- return /* @__PURE__ */ jsx7(BootstrapFrame, { title: "Preparing the workshop", children: /* @__PURE__ */ jsxs7(Text7, { color: "yellow", children: [
3423
+ return /* @__PURE__ */ jsx6(BootstrapFrame, { title: "Preparing the workshop", children: /* @__PURE__ */ jsxs7(Text7, { color: "yellow", children: [
2914
3424
  "\u25CF ",
2915
3425
  screen.message
2916
3426
  ] }) });
@@ -2924,28 +3434,29 @@ function BootstrapGate(props) {
2924
3434
  " ",
2925
3435
  screen.progress.detail
2926
3436
  ] }),
2927
- /* @__PURE__ */ jsx7(ProgressBar, { pct: screen.progress.pct }),
2928
- /* @__PURE__ */ jsx7(Text7, { dimColor: true, children: screen.progress.pct == null ? "Working\u2026" : `${screen.progress.pct}%` })
3437
+ /* @__PURE__ */ jsx6(ProgressBar, { pct: screen.progress.pct }),
3438
+ /* @__PURE__ */ jsx6(Text7, { dimColor: true, children: screen.progress.pct == null ? "Working\u2026" : `${screen.progress.pct}%` })
2929
3439
  ] });
2930
3440
  }
2931
3441
  if (screen.kind === "native-choice") {
2932
3442
  const labels = screen.missing.map(nativeLabel).join(", ");
2933
- return /* @__PURE__ */ jsxs7(BootstrapFrame, { title: "Local tools are not installed yet", children: [
3443
+ return /* @__PURE__ */ jsxs7(BootstrapFrame, { title: "The Gezel native toolkit -- needed to run AI models locally -- is not installed yet", children: [
3444
+ /* @__PURE__ */ jsx6(Text7, { children: `Gezel can install the verified Gezel native toolkit (native-v${screen.context.nativeStatus.release}) for this device.` }),
2934
3445
  /* @__PURE__ */ jsxs7(Text7, { children: [
2935
- "Gezel can install the verified native-v",
2936
- screen.context.nativeStatus.release,
2937
- " toolkit for this device."
3446
+ "Downloaded from",
3447
+ " ",
3448
+ /* @__PURE__ */ jsx6(Text7, { bold: true, color: "cyan", children: "https://github.com/bendyline/gezel/releases/" })
2938
3449
  ] }),
2939
3450
  /* @__PURE__ */ jsxs7(Text7, { dimColor: true, children: [
2940
3451
  "Missing: ",
2941
3452
  labels
2942
3453
  ] }),
2943
- /* @__PURE__ */ jsx7(
3454
+ /* @__PURE__ */ jsx6(
2944
3455
  BootstrapChoiceList,
2945
3456
  {
2946
3457
  options: [
2947
3458
  {
2948
- label: "Install the native toolkit",
3459
+ label: "Install the Gezel native toolkit",
2949
3460
  hint: "recommended \xB7 engines for chat, images, speech, and local model helpers",
2950
3461
  value: "install"
2951
3462
  },
@@ -2963,53 +3474,73 @@ function BootstrapGate(props) {
2963
3474
  ] });
2964
3475
  }
2965
3476
  if (screen.kind === "model-choice") {
2966
- const best = screen.plan.chatModels[0];
3477
+ const best = screen.plan.recommendedChatModel;
3478
+ const bestInstalled = best ? screen.plan.installedChatModels.some((model) => model.id === best.id) : false;
2967
3479
  const accessoryBytes = screen.plan.accessories.reduce(
2968
3480
  (sum, model) => sum + model.approxSizeBytes,
2969
3481
  0
2970
3482
  );
3483
+ const workshopDownloadBytes = accessoryBytes + (best && !bestInstalled ? best.approxSizeBytes : 0);
2971
3484
  const options = [
2972
- {
2973
- label: `Recommended workshop set \u2014 ${best.name} + ${screen.plan.accessories.length} helpers`,
2974
- hint: formatDownloadSize(best.approxSizeBytes + accessoryBytes),
2975
- value: "bundle"
2976
- },
2977
- {
2978
- label: `${best.name} only`,
2979
- hint: `best chat model \xB7 ${formatDownloadSize(best.approxSizeBytes)}`,
2980
- value: `chat:${best.id}`
2981
- },
2982
- ...screen.plan.chatModels.slice(1, MAX_ALTERNATIVE_MODELS + 1).map((model) => ({
2983
- label: `${model.name} only`,
3485
+ ...best ? [
3486
+ {
3487
+ label: `Recommended workshop set \u2014 ${bootstrapChatModelLabel(best)} + ${screen.plan.accessories.length} helpers`,
3488
+ hint: `${bestInstalled ? "chat model already available \xB7 " : ""}${workshopDownloadBytes > 0 ? formatDownloadSize(workshopDownloadBytes) : "already available"}`,
3489
+ value: "bundle"
3490
+ },
3491
+ {
3492
+ label: `${bestInstalled ? "Use" : "Download"} ${bootstrapChatModelLabel(best)} only`,
3493
+ hint: `recommended for this device \xB7 ${bestInstalled ? "already available" : formatDownloadSize(best.approxSizeBytes)}`,
3494
+ value: bestInstalled ? `installed:${best.id}` : `chat:${best.id}`
3495
+ }
3496
+ ] : [],
3497
+ ...screen.plan.installedChatModels.filter((model) => model.id !== best?.id).map((model) => ({
3498
+ label: `Use ${model.name ?? model.id}${model.attribution ? ` (${model.attribution})` : ""}`,
3499
+ hint: `already available on this machine${model.approxSizeBytes ? ` \xB7 ${formatDownloadSize(model.approxSizeBytes)}` : ""}`,
3500
+ value: `installed:${model.id}`
3501
+ })),
3502
+ ...screen.plan.chatModels.filter((model) => model.id !== best?.id).slice(0, MAX_ALTERNATIVE_MODELS).map((model) => ({
3503
+ label: `Download ${bootstrapChatModelLabel(model)} only`,
2984
3504
  hint: `${formatDownloadSize(model.approxSizeBytes)} \xB7 ${fitLabel(model.fit)}`,
2985
3505
  value: `chat:${model.id}`
2986
3506
  })),
2987
3507
  { label: "Not now", hint: "open the TUI without a local model", value: "skip" }
2988
3508
  ];
2989
- return /* @__PURE__ */ jsxs7(BootstrapFrame, { title: "No local chat model is installed", children: [
2990
- /* @__PURE__ */ jsx7(Text7, { children: "Pick a setup for this device. Downloads stay under your Gezel home folder." }),
2991
- /* @__PURE__ */ jsx7(
2992
- BootstrapChoiceList,
2993
- {
2994
- options,
2995
- onSelect: (value) => {
2996
- if (value === "skip") {
2997
- void installModels(screen.plan, { kind: "skip" });
2998
- } else if (value === "bundle") {
2999
- void installModels(screen.plan, { kind: "bundle", model: best });
3000
- } else {
3001
- const id = value.slice("chat:".length);
3002
- const model = screen.plan.chatModels.find((candidate) => candidate.id === id);
3003
- if (model) void installModels(screen.plan, { kind: "chat", model });
3509
+ return /* @__PURE__ */ jsxs7(
3510
+ BootstrapFrame,
3511
+ {
3512
+ title: screen.plan.installedChatModels.length > 0 ? "Choose a local chat model" : "No local chat model is installed",
3513
+ children: [
3514
+ /* @__PURE__ */ jsx6(Text7, { children: screen.plan.installedChatModels.length > 0 ? "These models are already available in your Gezel or shared machine store. You can use one now or download another." : "Pick a setup for this device. Downloads stay under Gezel model storage." }),
3515
+ /* @__PURE__ */ jsx6(
3516
+ BootstrapChoiceList,
3517
+ {
3518
+ options,
3519
+ onSelect: (value) => {
3520
+ if (value === "skip") {
3521
+ void installModels(screen.plan, { kind: "skip" });
3522
+ } else if (value === "bundle") {
3523
+ if (best) void installModels(screen.plan, { kind: "bundle", model: best });
3524
+ } else if (value.startsWith("installed:")) {
3525
+ void installModels(screen.plan, {
3526
+ kind: "installed",
3527
+ modelId: value.slice("installed:".length)
3528
+ });
3529
+ } else {
3530
+ const id = value.slice("chat:".length);
3531
+ const model = screen.plan.chatModels.find((candidate) => candidate.id === id);
3532
+ if (model) void installModels(screen.plan, { kind: "chat", model });
3533
+ }
3534
+ }
3004
3535
  }
3005
- }
3006
- }
3007
- )
3008
- ] });
3536
+ )
3537
+ ]
3538
+ }
3539
+ );
3009
3540
  }
3010
3541
  return /* @__PURE__ */ jsxs7(BootstrapFrame, { title: screen.title, children: [
3011
- /* @__PURE__ */ jsx7(Text7, { color: "red", children: screen.message }),
3012
- /* @__PURE__ */ jsx7(
3542
+ /* @__PURE__ */ jsx6(Text7, { color: "red", children: screen.message }),
3543
+ /* @__PURE__ */ jsx6(
3013
3544
  BootstrapChoiceList,
3014
3545
  {
3015
3546
  options: [
@@ -3026,7 +3557,7 @@ function BootstrapGate(props) {
3026
3557
  }
3027
3558
  function BootstrapFrame(props) {
3028
3559
  return /* @__PURE__ */ jsxs7(Box7, { flexDirection: "column", paddingX: 1, paddingY: 1, children: [
3029
- /* @__PURE__ */ jsx7(Text7, { bold: true, color: "cyan", children: "gezel \xB7 first-time setup" }),
3560
+ /* @__PURE__ */ jsx6(Text7, { bold: true, color: "cyan", children: "gezel \xB7 first-time setup" }),
3030
3561
  /* @__PURE__ */ jsxs7(
3031
3562
  Box7,
3032
3563
  {
@@ -3036,14 +3567,24 @@ function BootstrapFrame(props) {
3036
3567
  paddingX: 1,
3037
3568
  marginTop: 1,
3038
3569
  children: [
3039
- /* @__PURE__ */ jsx7(Text7, { bold: true, color: "yellow", children: props.title }),
3570
+ /* @__PURE__ */ jsx6(Text7, { bold: true, color: "yellow", children: props.title }),
3040
3571
  props.children
3041
3572
  ]
3042
3573
  }
3043
3574
  ),
3044
- /* @__PURE__ */ jsx7(Text7, { dimColor: true, children: "Ctrl+C exit" })
3575
+ /* @__PURE__ */ jsx6(Text7, { dimColor: true, children: "Ctrl+C exit" })
3045
3576
  ] });
3046
3577
  }
3578
+ function recoDevice(memory) {
3579
+ return {
3580
+ platform: memory.platform,
3581
+ gpuVramBytes: memory.gpuVramBytes,
3582
+ ...memory.gpuMemoryKind ? { gpuMemoryKind: memory.gpuMemoryKind } : {},
3583
+ totalRamBytes: memory.totalRamBytes,
3584
+ usableBytes: memory.usableBytes,
3585
+ ...memory.budgetBytes !== void 0 ? { budgetBytes: memory.budgetBytes } : {}
3586
+ };
3587
+ }
3047
3588
  function BootstrapChoiceList(props) {
3048
3589
  const [index, setIndex] = useState5(0);
3049
3590
  const options = props.options;
@@ -3116,7 +3657,7 @@ async function installNativeToolkit(client, status, missing, setScreen) {
3116
3657
  index,
3117
3658
  missing.length,
3118
3659
  event,
3119
- `Installing native-v${status.release}`
3660
+ `Installing the Gezel native toolkit (native-v${status.release})`
3120
3661
  );
3121
3662
  },
3122
3663
  engine === "llama-server" ? status.llamaBackend : void 0
@@ -3220,10 +3761,10 @@ function delay(ms) {
3220
3761
  }
3221
3762
 
3222
3763
  // src/tui/index.tsx
3223
- import { jsx as jsx8 } from "react/jsx-runtime";
3764
+ import { jsx as jsx7 } from "react/jsx-runtime";
3224
3765
  async function launchTui(opts) {
3225
3766
  const instance = render(
3226
- /* @__PURE__ */ jsx8(BootstrapGate, { client: opts.client, children: /* @__PURE__ */ jsx8(
3767
+ /* @__PURE__ */ jsx7(BootstrapGate, { client: opts.client, children: /* @__PURE__ */ jsx7(
3227
3768
  App,
3228
3769
  {
3229
3770
  client: opts.client,