@bendyline/gezel-cli 1.0.2 → 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/README.md +23 -8
- package/dist/bin/gezel.js +847 -223
- package/dist/tui/index.js +884 -364
- package/package.json +6 -6
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";
|
|
@@ -144,11 +146,13 @@ var SLASH_COMMANDS = [
|
|
|
144
146
|
{ name: "help", description: "show the command reference" },
|
|
145
147
|
{ name: "project", description: "switch active project" },
|
|
146
148
|
{ name: "gezel", description: "switch active gezel" },
|
|
149
|
+
{ name: "allow", description: "allow a project permission" },
|
|
150
|
+
{ name: "disallow", description: "disallow a project permission" },
|
|
147
151
|
{ name: "mode", description: "set AI activity: read-only through full play" },
|
|
148
152
|
{ name: "model", description: "switch engine and model" },
|
|
149
153
|
{ name: "thread", description: "switch the active chat thread" },
|
|
150
154
|
{ name: "task", description: "list and manage project tasks" },
|
|
151
|
-
{ name: "
|
|
155
|
+
{ name: "do", description: "do a task from a craftbook" },
|
|
152
156
|
{ name: "continue", description: "process due and active project tasks" },
|
|
153
157
|
{ name: "nightshift", description: "start, stop, or list night-shift work" },
|
|
154
158
|
{ name: "focus", description: "send into another active chat" },
|
|
@@ -167,7 +171,59 @@ var NIGHT_SHIFT_SUBCOMMANDS = [
|
|
|
167
171
|
{ name: "stop", description: "stop the current night shift" },
|
|
168
172
|
{ name: "list", description: "show current and upcoming night-shift work" }
|
|
169
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
|
+
}
|
|
170
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
|
+
}
|
|
171
227
|
const modeMatch = input.match(/^\/mode\s+(.*)$/i);
|
|
172
228
|
if (modeMatch) {
|
|
173
229
|
const query = (modeMatch[1] ?? "").trim().toLowerCase();
|
|
@@ -192,9 +248,9 @@ function suggestSlashWordwheel(input, craftbooks) {
|
|
|
192
248
|
})
|
|
193
249
|
);
|
|
194
250
|
}
|
|
195
|
-
const
|
|
196
|
-
if (
|
|
197
|
-
const query = (
|
|
251
|
+
const doMatch = input.match(/^\/do\s+(.*)$/i);
|
|
252
|
+
if (doMatch) {
|
|
253
|
+
const query = (doMatch[1] ?? "").trim().toLowerCase();
|
|
198
254
|
const terms = query.split(/\s+/).filter(Boolean);
|
|
199
255
|
return craftbooks.filter((book) => {
|
|
200
256
|
const haystack = `${book.id} ${book.name} ${book.description ?? ""}`.toLowerCase();
|
|
@@ -205,10 +261,10 @@ function suggestSlashWordwheel(input, craftbooks) {
|
|
|
205
261
|
return leftRank - rightRank || left.name.localeCompare(right.name);
|
|
206
262
|
}).map((book) => ({
|
|
207
263
|
key: `craftbook:${book.id}`,
|
|
208
|
-
label: `/
|
|
264
|
+
label: `/do ${book.id}`,
|
|
209
265
|
description: `${book.name} \xB7 ${book.stepCount} ${book.stepCount === 1 ? "step" : "steps"} \xB7 ${book.source}`,
|
|
210
|
-
submit: `/
|
|
211
|
-
completion: `/
|
|
266
|
+
submit: `/do ${book.id}`,
|
|
267
|
+
completion: `/do ${book.id}`
|
|
212
268
|
}));
|
|
213
269
|
}
|
|
214
270
|
return suggestSlashCommands(input).map((command) => ({
|
|
@@ -273,6 +329,24 @@ function reduceFeed(rows, env) {
|
|
|
273
329
|
open: false
|
|
274
330
|
}
|
|
275
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}`);
|
|
276
350
|
case "delta": {
|
|
277
351
|
const idx = findOpenAssistant(rows, sessionId);
|
|
278
352
|
const open = idx === -1 ? void 0 : rows[idx];
|
|
@@ -340,7 +414,11 @@ function reduceFeed(rows, env) {
|
|
|
340
414
|
gezelId: "",
|
|
341
415
|
kind: "note",
|
|
342
416
|
text: `task \xB7 ${event.summary}`,
|
|
343
|
-
open: false
|
|
417
|
+
open: false,
|
|
418
|
+
taskEvent: {
|
|
419
|
+
kind: event.kind,
|
|
420
|
+
...event.gezelId ? { gezelId: event.gezelId } : {}
|
|
421
|
+
}
|
|
344
422
|
}
|
|
345
423
|
]);
|
|
346
424
|
case "error":
|
|
@@ -523,7 +601,7 @@ function toolRowText(call) {
|
|
|
523
601
|
}
|
|
524
602
|
function gezelLabel(gezelId, gezels, boring) {
|
|
525
603
|
const g = gezels.find((x) => x.id === gezelId);
|
|
526
|
-
if (!g) return gezelId;
|
|
604
|
+
if (!g) return boring ? "gezel" : gezelId;
|
|
527
605
|
if (boring) return g.roleBasedName ?? g.role ?? g.id;
|
|
528
606
|
return g.role ? `${g.name} \xB7 ${g.role}` : g.name;
|
|
529
607
|
}
|
|
@@ -655,6 +733,7 @@ var TABLE_LOGO = [
|
|
|
655
733
|
].join("\n");
|
|
656
734
|
var KIND_COLOR = {
|
|
657
735
|
user: "white",
|
|
736
|
+
pending: "yellow",
|
|
658
737
|
assistant: "cyan",
|
|
659
738
|
tool: "yellow",
|
|
660
739
|
note: "magenta",
|
|
@@ -664,7 +743,7 @@ var KIND_COLOR = {
|
|
|
664
743
|
function ChatFeed(props) {
|
|
665
744
|
const { rows, gezels, boring, focusedSessionId, visible = 16 } = props;
|
|
666
745
|
const shown = rows.slice(Math.max(0, rows.length - visible));
|
|
667
|
-
return /* @__PURE__ */ jsx(Box, { flexDirection: "column", flexGrow: 1, children: shown.length === 0 ? /* @__PURE__ */ jsxs(Box, { flexDirection: "row",
|
|
746
|
+
return /* @__PURE__ */ jsx(Box, { flexDirection: "column", flexGrow: 1, marginBottom: 1, children: shown.length === 0 ? /* @__PURE__ */ jsxs(Box, { flexDirection: "row", children: [
|
|
668
747
|
/* @__PURE__ */ jsx(Text, { color: "yellow", children: TABLE_LOGO }),
|
|
669
748
|
/* @__PURE__ */ jsxs(Box, { flexDirection: "column", marginLeft: 3, children: [
|
|
670
749
|
/* @__PURE__ */ jsxs(Text, { children: [
|
|
@@ -678,7 +757,7 @@ function ChatFeed(props) {
|
|
|
678
757
|
if (row.kind === "shell" && row.sessionId.startsWith("term-")) {
|
|
679
758
|
return /* @__PURE__ */ jsx(Text, { wrap: "wrap", children: clip(row.text) }, row.key);
|
|
680
759
|
}
|
|
681
|
-
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";
|
|
682
761
|
const isFocused = focusedSessionId && row.sessionId === focusedSessionId;
|
|
683
762
|
return /* @__PURE__ */ jsxs(Box, { flexDirection: "row", children: [
|
|
684
763
|
/* @__PURE__ */ jsx(Text, { dimColor: !isFocused, color: isFocused ? "green" : void 0, children: isFocused ? "\u258E" : " " }),
|
|
@@ -687,11 +766,33 @@ function ChatFeed(props) {
|
|
|
687
766
|
who,
|
|
688
767
|
": "
|
|
689
768
|
] }),
|
|
690
|
-
/* @__PURE__ */ jsx(Text, { color: KIND_COLOR[row.kind],
|
|
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
|
+
) })
|
|
691
772
|
] })
|
|
692
773
|
] }, row.key);
|
|
693
774
|
}) });
|
|
694
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
|
+
}
|
|
695
796
|
var MAX_CHARS = 8e3;
|
|
696
797
|
function clip(text) {
|
|
697
798
|
const t = text.replace(/\s+$/, "");
|
|
@@ -769,19 +870,29 @@ import { useEffect, useState as useState2 } from "react";
|
|
|
769
870
|
|
|
770
871
|
// src/tui/components/EnginePill.tsx
|
|
771
872
|
import { Box as Box3, Text as Text3 } from "ink";
|
|
772
|
-
import {
|
|
873
|
+
import { jsxs as jsxs3 } from "react/jsx-runtime";
|
|
773
874
|
function EnginePill(props) {
|
|
774
875
|
const { provider, model, accessMode, busy, label } = props;
|
|
775
|
-
const
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
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
|
+
] });
|
|
890
|
+
}
|
|
891
|
+
function formatEngineMetadata(provider, model, accessMode) {
|
|
892
|
+
return [accessMode, formatEngineIdentity(provider, model)].filter(Boolean).join(" \xB7 ");
|
|
781
893
|
}
|
|
782
|
-
function
|
|
783
|
-
|
|
784
|
-
return [activity, accessMode, formatEngineIdentity(provider, model)].filter(Boolean).join(" \xB7 ");
|
|
894
|
+
function formatEngineActivity(busy, label) {
|
|
895
|
+
return busy ? `\u25CF ${label ?? "working"}` : "\u25CB idle";
|
|
785
896
|
}
|
|
786
897
|
function formatEngineIdentity(provider, model) {
|
|
787
898
|
const engine = provider === "llama-cpp" ? "llama" : provider ?? "on-device";
|
|
@@ -789,7 +900,7 @@ function formatEngineIdentity(provider, model) {
|
|
|
789
900
|
}
|
|
790
901
|
|
|
791
902
|
// src/tui/components/PromptLine.tsx
|
|
792
|
-
import { Fragment as Fragment2, jsx as
|
|
903
|
+
import { Fragment as Fragment2, jsx as jsx3, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
793
904
|
function PromptLine(props) {
|
|
794
905
|
const {
|
|
795
906
|
projectName,
|
|
@@ -867,18 +978,18 @@ function PromptLine(props) {
|
|
|
867
978
|
const placeholder = pendingPrompt ? pendingPrompt : mode === "cli" ? "shell / @tool \u2026 (/chat to exit)" : "message, or /command, !shell, @tool";
|
|
868
979
|
return /* @__PURE__ */ jsxs4(Box4, { flexDirection: "column", children: [
|
|
869
980
|
/* @__PURE__ */ jsxs4(Box4, { children: [
|
|
870
|
-
/* @__PURE__ */
|
|
871
|
-
/* @__PURE__ */
|
|
872
|
-
/* @__PURE__ */
|
|
981
|
+
/* @__PURE__ */ jsx3(Text4, { color: "blue", children: projectName }),
|
|
982
|
+
/* @__PURE__ */ jsx3(Text4, { dimColor: true, children: " \xB7 " }),
|
|
983
|
+
/* @__PURE__ */ jsx3(Text4, { color: "magenta", children: gezelLabel2 }),
|
|
873
984
|
threadTitle ? /* @__PURE__ */ jsxs4(Fragment2, { children: [
|
|
874
|
-
/* @__PURE__ */
|
|
985
|
+
/* @__PURE__ */ jsx3(Text4, { dimColor: true, children: " \xB7 " }),
|
|
875
986
|
/* @__PURE__ */ jsxs4(Text4, { color: "cyan", children: [
|
|
876
987
|
"\u21B3 ",
|
|
877
988
|
compactThreadTitle(threadTitle)
|
|
878
989
|
] })
|
|
879
990
|
] }) : null,
|
|
880
|
-
/* @__PURE__ */
|
|
881
|
-
/* @__PURE__ */
|
|
991
|
+
/* @__PURE__ */ jsx3(Text4, { children: " " }),
|
|
992
|
+
/* @__PURE__ */ jsx3(
|
|
882
993
|
EnginePill,
|
|
883
994
|
{
|
|
884
995
|
provider,
|
|
@@ -908,8 +1019,8 @@ function PromptLine(props) {
|
|
|
908
1019
|
] })
|
|
909
1020
|
] }) : null,
|
|
910
1021
|
/* @__PURE__ */ jsxs4(Box4, { children: [
|
|
911
|
-
/* @__PURE__ */
|
|
912
|
-
/* @__PURE__ */
|
|
1022
|
+
/* @__PURE__ */ jsx3(Text4, { color: pendingPrompt ? "yellow" : mode === "cli" ? "green" : "cyan", children: prefix }),
|
|
1023
|
+
/* @__PURE__ */ jsx3(
|
|
913
1024
|
TextInput,
|
|
914
1025
|
{
|
|
915
1026
|
value,
|
|
@@ -932,7 +1043,7 @@ function compactThreadTitle(title) {
|
|
|
932
1043
|
import { Box as Box5, Text as Text5, useInput as useInput3 } from "ink";
|
|
933
1044
|
import TextInput2 from "ink-text-input";
|
|
934
1045
|
import { useState as useState3 } from "react";
|
|
935
|
-
import { Fragment as Fragment3, jsx as
|
|
1046
|
+
import { Fragment as Fragment3, jsx as jsx4, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
936
1047
|
var QUESTION_OPTION_WINDOW_SIZE = 4;
|
|
937
1048
|
function questionOptionCount(question) {
|
|
938
1049
|
const choices = question.choices?.length ?? 0;
|
|
@@ -1033,11 +1144,11 @@ function QuestionPrompt(props) {
|
|
|
1033
1144
|
askerLabel,
|
|
1034
1145
|
" asks"
|
|
1035
1146
|
] }),
|
|
1036
|
-
/* @__PURE__ */
|
|
1147
|
+
/* @__PURE__ */ jsx4(Text5, { wrap: "wrap", children: question.prompt }),
|
|
1037
1148
|
writing ? /* @__PURE__ */ jsxs5(Fragment3, { children: [
|
|
1038
1149
|
/* @__PURE__ */ jsxs5(Box5, { children: [
|
|
1039
|
-
/* @__PURE__ */
|
|
1040
|
-
/* @__PURE__ */
|
|
1150
|
+
/* @__PURE__ */ jsx4(Text5, { color: "cyan", children: "\u203A " }),
|
|
1151
|
+
/* @__PURE__ */ jsx4(
|
|
1041
1152
|
TextInput2,
|
|
1042
1153
|
{
|
|
1043
1154
|
value: writeIn,
|
|
@@ -1070,8 +1181,8 @@ function QuestionPrompt(props) {
|
|
|
1070
1181
|
options.length > QUESTION_OPTION_WINDOW_SIZE ? ` \xB7 ${activeOptionIndex + 1}/${options.length}` : ""
|
|
1071
1182
|
] })
|
|
1072
1183
|
] }),
|
|
1073
|
-
submitting ? /* @__PURE__ */
|
|
1074
|
-
error ? /* @__PURE__ */
|
|
1184
|
+
submitting ? /* @__PURE__ */ jsx4(Text5, { color: "yellow", children: "Submitting\u2026" }) : null,
|
|
1185
|
+
error ? /* @__PURE__ */ jsx4(Text5, { color: "red", children: error }) : null
|
|
1075
1186
|
] });
|
|
1076
1187
|
}
|
|
1077
1188
|
function toggleSet(current, value) {
|
|
@@ -1083,11 +1194,12 @@ function toggleSet(current, value) {
|
|
|
1083
1194
|
|
|
1084
1195
|
// src/tui/craftbook-start.ts
|
|
1085
1196
|
import {
|
|
1086
|
-
CRAFTBOOK_ROLE_META
|
|
1197
|
+
CRAFTBOOK_ROLE_META,
|
|
1198
|
+
visibleCatalogItems
|
|
1087
1199
|
} from "@bendyline/gezel";
|
|
1088
|
-
function normalizeCraftbooks(items) {
|
|
1200
|
+
function normalizeCraftbooks(items, showWorkInProgressFeatures = false) {
|
|
1089
1201
|
const byId = /* @__PURE__ */ new Map();
|
|
1090
|
-
for (const item of items) {
|
|
1202
|
+
for (const item of visibleCatalogItems(items, showWorkInProgressFeatures)) {
|
|
1091
1203
|
if (item.manifest.kind !== "craftbook-template") continue;
|
|
1092
1204
|
const manifest = item.manifest;
|
|
1093
1205
|
if (byId.has(manifest.id)) continue;
|
|
@@ -1166,6 +1278,179 @@ function craftbookStartRequest(book) {
|
|
|
1166
1278
|
};
|
|
1167
1279
|
}
|
|
1168
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
|
+
|
|
1169
1454
|
// src/tui/model-picker.ts
|
|
1170
1455
|
var PROVIDER_ORDER = [
|
|
1171
1456
|
"mlx",
|
|
@@ -1218,9 +1503,10 @@ function configuredModelProviders(config, opts) {
|
|
|
1218
1503
|
return providers.sort((a, b) => PROVIDER_ORDER.indexOf(a) - PROVIDER_ORDER.indexOf(b));
|
|
1219
1504
|
}
|
|
1220
1505
|
async function loadModelChoices(client, config, platform = process.platform, arch = process.arch) {
|
|
1221
|
-
const [copilot, memory] = await Promise.all([
|
|
1506
|
+
const [copilot, memory, catalog] = await Promise.all([
|
|
1222
1507
|
client.getCopilotStatus().catch(() => null),
|
|
1223
|
-
client.getMemoryProfile().catch(() => null)
|
|
1508
|
+
client.getMemoryProfile().catch(() => null),
|
|
1509
|
+
client.listCatalogItems ? client.listCatalogItems("chat-model").catch(() => null) : Promise.resolve(null)
|
|
1224
1510
|
]);
|
|
1225
1511
|
const providers = configuredModelProviders(config, {
|
|
1226
1512
|
platform,
|
|
@@ -1239,13 +1525,70 @@ async function loadModelChoices(client, config, platform = process.platform, arc
|
|
|
1239
1525
|
})
|
|
1240
1526
|
);
|
|
1241
1527
|
return inventories.flatMap(
|
|
1242
|
-
({ provider, models }) => models.map((model) =>
|
|
1243
|
-
provider,
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
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
|
+
})
|
|
1538
|
+
);
|
|
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
|
|
1248
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
|
+
}
|
|
1249
1592
|
}
|
|
1250
1593
|
|
|
1251
1594
|
// src/tui/question-queue.ts
|
|
@@ -1332,7 +1675,7 @@ function abortableDelay(ms, signal) {
|
|
|
1332
1675
|
}
|
|
1333
1676
|
|
|
1334
1677
|
// src/tui/App.tsx
|
|
1335
|
-
import { jsx as
|
|
1678
|
+
import { jsx as jsx5, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
1336
1679
|
function useTerminalSize() {
|
|
1337
1680
|
const { stdout } = useStdout();
|
|
1338
1681
|
const [size, setSize] = useState4({ rows: stdout?.rows ?? 24, columns: stdout?.columns ?? 80 });
|
|
@@ -1348,10 +1691,14 @@ function useTerminalSize() {
|
|
|
1348
1691
|
}
|
|
1349
1692
|
var HELP = [
|
|
1350
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",
|
|
1351
1698
|
"/mode \u2014 choose read-only, reactive, reactive+tasks, or full-play AI activity",
|
|
1352
1699
|
"/thread \u2014 switch or start a chat thread",
|
|
1353
1700
|
"/task \u2014 list, inspect, create, edit, assign, or change task status",
|
|
1354
|
-
"/
|
|
1701
|
+
"/do \u2014 choose a craftbook and start it as a task",
|
|
1355
1702
|
"/continue \u2014 process due schedules and active tasks in this project",
|
|
1356
1703
|
"/nightshift start|stop|list \u2014 manage Night Shift",
|
|
1357
1704
|
"/focus \u2014 send into another active chat /cli \u2014 CLI mode /chat \u2014 chat mode",
|
|
@@ -1359,6 +1706,7 @@ var HELP = [
|
|
|
1359
1706
|
"/clear \u2014 clear feed /quit \u2014 exit",
|
|
1360
1707
|
"\u2191/\u2193 \u2014 input history Esc \u2014 interrupt turn Ctrl+C \u2014 interrupt, then again to exit"
|
|
1361
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.";
|
|
1362
1710
|
function App(props) {
|
|
1363
1711
|
const { client } = props;
|
|
1364
1712
|
const { exit } = useApp();
|
|
@@ -1375,6 +1723,11 @@ function App(props) {
|
|
|
1375
1723
|
);
|
|
1376
1724
|
const [startCategoryId, setStartCategoryId] = useState4(null);
|
|
1377
1725
|
const [modelChoices, setModelChoices] = useState4([]);
|
|
1726
|
+
const [modelDownloadChoices, setModelDownloadChoices] = useState4([]);
|
|
1727
|
+
const [modelDownloadProgress, setModelDownloadProgress] = useState4(
|
|
1728
|
+
null
|
|
1729
|
+
);
|
|
1730
|
+
const [modelDownloadReturn, setModelDownloadReturn] = useState4(null);
|
|
1378
1731
|
const [modelChoicesLoading, setModelChoicesLoading] = useState4(false);
|
|
1379
1732
|
const [threadsLoading, setThreadsLoading] = useState4(false);
|
|
1380
1733
|
const [pendingQuestions, setPendingQuestions] = useState4([]);
|
|
@@ -1403,7 +1756,7 @@ function App(props) {
|
|
|
1403
1756
|
const wordwheelRows = wordwheelCount > 0 ? Math.min(SLASH_COMMAND_WORDWHEEL_SIZE, wordwheelCount) + 1 : 0;
|
|
1404
1757
|
const questionRows = pendingQuestion ? Math.min(QUESTION_OPTION_WINDOW_SIZE, Math.max(1, questionOptionCount(pendingQuestion))) + 4 : 0;
|
|
1405
1758
|
const modelPickerWindowSize = Math.max(4, Math.min(10, termRows - 12));
|
|
1406
|
-
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;
|
|
1407
1760
|
const visibleRows = Math.max(
|
|
1408
1761
|
4,
|
|
1409
1762
|
termRows - 7 - wordwheelRows - questionRows - inventoryPickerRows
|
|
@@ -1424,6 +1777,23 @@ function App(props) {
|
|
|
1424
1777
|
(text, kind = "note") => setRows((r) => appendNote(r, text, kind)),
|
|
1425
1778
|
[]
|
|
1426
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]);
|
|
1427
1797
|
const taskLoadSequence = useRef2(0);
|
|
1428
1798
|
const refreshTasks = useCallback(async () => {
|
|
1429
1799
|
const sequence = ++taskLoadSequence.current;
|
|
@@ -1439,13 +1809,13 @@ function App(props) {
|
|
|
1439
1809
|
const sequence = ++craftbookLoadSequence.current;
|
|
1440
1810
|
const result = await client.listProjectCraftbooks(projectId);
|
|
1441
1811
|
if (sequence !== craftbookLoadSequence.current) return [];
|
|
1442
|
-
const next = normalizeCraftbooks(result.items);
|
|
1812
|
+
const next = normalizeCraftbooks(result.items, config?.showWorkInProgressFeatures === true);
|
|
1443
1813
|
setCraftbooks(next);
|
|
1444
1814
|
setCraftbookProjectType(result.projectType ?? null);
|
|
1445
1815
|
setSuggestedCraftbookIds(new Set(result.suggestedIds ?? []));
|
|
1446
1816
|
setCraftbooksNeedingSetup(new Set(Object.keys(result.missingToolsets)));
|
|
1447
1817
|
return next;
|
|
1448
|
-
}, [client, projectId]);
|
|
1818
|
+
}, [client, config?.showWorkInProgressFeatures, projectId]);
|
|
1449
1819
|
useProjectEvents(
|
|
1450
1820
|
client,
|
|
1451
1821
|
projectId,
|
|
@@ -1453,6 +1823,8 @@ function App(props) {
|
|
|
1453
1823
|
(env) => {
|
|
1454
1824
|
setRows((r) => reduceFeed(r, env));
|
|
1455
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();
|
|
1456
1828
|
if (env.event.type === "task_event") void refreshTasks();
|
|
1457
1829
|
if (env.event.type === "user_message" && env.sessionId === ownSessionId) {
|
|
1458
1830
|
const nextTitle = env.event.message.content.slice(0, 60).trim() || "Untitled";
|
|
@@ -1468,7 +1840,7 @@ function App(props) {
|
|
|
1468
1840
|
setPendingQuestions((questions) => updatePendingQuestion(questions, question));
|
|
1469
1841
|
}
|
|
1470
1842
|
},
|
|
1471
|
-
[ownSessionId, refreshTasks]
|
|
1843
|
+
[ownSessionId, refreshGezels, refreshTasks]
|
|
1472
1844
|
)
|
|
1473
1845
|
);
|
|
1474
1846
|
useTerminalEvents(
|
|
@@ -1507,7 +1879,11 @@ function App(props) {
|
|
|
1507
1879
|
const ensureSession = useCallback(
|
|
1508
1880
|
async (gezelId, pid) => {
|
|
1509
1881
|
try {
|
|
1510
|
-
const session = await client.createChatSession({
|
|
1882
|
+
const session = await client.createChatSession({
|
|
1883
|
+
gezelId,
|
|
1884
|
+
projectId: pid,
|
|
1885
|
+
roleBasedNameOnlyMode: boring
|
|
1886
|
+
});
|
|
1511
1887
|
setOwnSessionId(session.id);
|
|
1512
1888
|
setFocusedSessionId(session.id);
|
|
1513
1889
|
setActiveThreadTitle(displayThreadTitle(session.title));
|
|
@@ -1517,7 +1893,7 @@ function App(props) {
|
|
|
1517
1893
|
return false;
|
|
1518
1894
|
}
|
|
1519
1895
|
},
|
|
1520
|
-
[client, note]
|
|
1896
|
+
[client, note, boring]
|
|
1521
1897
|
);
|
|
1522
1898
|
const switchProject = useCallback(
|
|
1523
1899
|
async (id) => {
|
|
@@ -1551,6 +1927,56 @@ function App(props) {
|
|
|
1551
1927
|
},
|
|
1552
1928
|
[client, ensureSession, note, projectId, projects]
|
|
1553
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
|
+
);
|
|
1554
1980
|
const openThreadPicker = useCallback(async () => {
|
|
1555
1981
|
if (!activeGezelId) return note("no active gezel yet.", "error");
|
|
1556
1982
|
if (threadsLoading) return;
|
|
@@ -1587,7 +2013,11 @@ function App(props) {
|
|
|
1587
2013
|
setOverlay(null);
|
|
1588
2014
|
if (!activeGezelId) return note("no active gezel yet.", "error");
|
|
1589
2015
|
try {
|
|
1590
|
-
const session = await client.createChatSession({
|
|
2016
|
+
const session = await client.createChatSession({
|
|
2017
|
+
gezelId: activeGezelId,
|
|
2018
|
+
projectId,
|
|
2019
|
+
roleBasedNameOnlyMode: boring
|
|
2020
|
+
});
|
|
1591
2021
|
setOwnSessionId(session.id);
|
|
1592
2022
|
setFocusedSessionId(session.id);
|
|
1593
2023
|
setActiveThreadTitle(displayThreadTitle(session.title));
|
|
@@ -1596,7 +2026,7 @@ function App(props) {
|
|
|
1596
2026
|
} catch (err) {
|
|
1597
2027
|
note(`could not start a thread: ${errMsg(err)}`, "error");
|
|
1598
2028
|
}
|
|
1599
|
-
}, [activeGezelId, client, note, projectId]);
|
|
2029
|
+
}, [activeGezelId, client, note, projectId, boring]);
|
|
1600
2030
|
useEffect3(() => {
|
|
1601
2031
|
let cancelled = false;
|
|
1602
2032
|
(async () => {
|
|
@@ -1608,22 +2038,31 @@ function App(props) {
|
|
|
1608
2038
|
]);
|
|
1609
2039
|
if (cancelled) return;
|
|
1610
2040
|
setConfig(cfg);
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
);
|
|
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);
|
|
1624
2053
|
const gezelId = props.initialGezelId;
|
|
2054
|
+
const initialGezel = gz.gezels.find((gezel) => gezel.id === gezelId);
|
|
2055
|
+
const initialProject = projectRows.find((project) => project.id === projectId);
|
|
1625
2056
|
setActiveGezelId(gezelId);
|
|
1626
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
|
+
}
|
|
1627
2066
|
await ensureSession(gezelId, projectId);
|
|
1628
2067
|
} catch (err) {
|
|
1629
2068
|
if (!cancelled) setStatus(`Failed to connect: ${errMsg(err)}`);
|
|
@@ -1695,7 +2134,8 @@ function App(props) {
|
|
|
1695
2134
|
for (const r of rows) {
|
|
1696
2135
|
if (r.sessionId === "local" || r.sessionId.startsWith("term-")) continue;
|
|
1697
2136
|
if (!seen.has(r.sessionId)) {
|
|
1698
|
-
const
|
|
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);
|
|
1699
2139
|
seen.set(r.sessionId, label);
|
|
1700
2140
|
}
|
|
1701
2141
|
}
|
|
@@ -1706,7 +2146,7 @@ function App(props) {
|
|
|
1706
2146
|
items.push({ label, value: sid });
|
|
1707
2147
|
}
|
|
1708
2148
|
return items;
|
|
1709
|
-
}, [rows, gezels, ownSessionId, gezelLine]);
|
|
2149
|
+
}, [rows, gezels, ownSessionId, gezelLine, boring]);
|
|
1710
2150
|
const cancelActive = useCallback(async () => {
|
|
1711
2151
|
const sessions = [...turns.keys()];
|
|
1712
2152
|
const runs = [...activeRuns];
|
|
@@ -1739,10 +2179,41 @@ function App(props) {
|
|
|
1739
2179
|
},
|
|
1740
2180
|
[client, note]
|
|
1741
2181
|
);
|
|
1742
|
-
const
|
|
1743
|
-
async (
|
|
1744
|
-
|
|
1745
|
-
|
|
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
|
+
);
|
|
2213
|
+
const startCraftbook = useCallback(
|
|
2214
|
+
async (book) => {
|
|
2215
|
+
setOverlay(null);
|
|
2216
|
+
note(`starting ${book.name}\u2026`);
|
|
1746
2217
|
try {
|
|
1747
2218
|
const created = await client.createTask(projectId, craftbookStartRequest(book));
|
|
1748
2219
|
rememberTask(created);
|
|
@@ -1855,7 +2326,10 @@ function App(props) {
|
|
|
1855
2326
|
const target = focusedSessionId ?? ownSessionId;
|
|
1856
2327
|
if (!target) return note("no active session yet.", "error");
|
|
1857
2328
|
try {
|
|
1858
|
-
await client.sendToChatSession(
|
|
2329
|
+
await client.sendToChatSession(
|
|
2330
|
+
target,
|
|
2331
|
+
turns.has(target) ? { message: parsed.text, nudge: true } : parsed.text
|
|
2332
|
+
);
|
|
1859
2333
|
} catch (err) {
|
|
1860
2334
|
note(`send failed: ${errMsg(err)}`, "error");
|
|
1861
2335
|
}
|
|
@@ -1918,7 +2392,8 @@ function App(props) {
|
|
|
1918
2392
|
note,
|
|
1919
2393
|
pendingInput,
|
|
1920
2394
|
submitTaskPrompt,
|
|
1921
|
-
taskPrompt
|
|
2395
|
+
taskPrompt,
|
|
2396
|
+
turns
|
|
1922
2397
|
]
|
|
1923
2398
|
);
|
|
1924
2399
|
const runCommand = useCallback(
|
|
@@ -1932,31 +2407,21 @@ function App(props) {
|
|
|
1932
2407
|
return setOverlay("project");
|
|
1933
2408
|
case "gezel":
|
|
1934
2409
|
return setOverlay("gezel");
|
|
2410
|
+
case "allow":
|
|
2411
|
+
await applyProjectPermission(rest, true);
|
|
2412
|
+
return;
|
|
2413
|
+
case "disallow":
|
|
2414
|
+
await applyProjectPermission(rest, false);
|
|
2415
|
+
return;
|
|
1935
2416
|
case "mode":
|
|
1936
2417
|
if (!rest.trim()) return setOverlay("engagement-mode");
|
|
1937
2418
|
await applyEngagementMode(rest);
|
|
1938
2419
|
return;
|
|
1939
2420
|
case "model": {
|
|
1940
|
-
|
|
1941
|
-
if (
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
if (modelChoicesLoading) return note("model choices are already loading.");
|
|
1945
|
-
setModelChoicesLoading(true);
|
|
1946
|
-
note("loading available engines and models\u2026");
|
|
1947
|
-
try {
|
|
1948
|
-
const choices = await loadModelChoices(client, config ?? await client.getConfig());
|
|
1949
|
-
if (choices.length === 0) {
|
|
1950
|
-
return note("no engines with available chat models were found.", "error");
|
|
1951
|
-
}
|
|
1952
|
-
setModelChoices(choices);
|
|
1953
|
-
setOverlay("model");
|
|
1954
|
-
} catch (err) {
|
|
1955
|
-
note(`could not load models: ${errMsg(err)}`, "error");
|
|
1956
|
-
} finally {
|
|
1957
|
-
setModelChoicesLoading(false);
|
|
1958
|
-
}
|
|
1959
|
-
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");
|
|
1960
2425
|
}
|
|
1961
2426
|
case "thread":
|
|
1962
2427
|
await openThreadPicker();
|
|
@@ -2007,7 +2472,7 @@ function App(props) {
|
|
|
2007
2472
|
}
|
|
2008
2473
|
return;
|
|
2009
2474
|
}
|
|
2010
|
-
case "
|
|
2475
|
+
case "do": {
|
|
2011
2476
|
let available = craftbooks;
|
|
2012
2477
|
if (available.length === 0) {
|
|
2013
2478
|
try {
|
|
@@ -2025,7 +2490,7 @@ function App(props) {
|
|
|
2025
2490
|
}
|
|
2026
2491
|
const book = findCraftbook(available, rest);
|
|
2027
2492
|
if (!book) {
|
|
2028
|
-
return note(`craftbook not found: ${rest.trim()} (try /
|
|
2493
|
+
return note(`craftbook not found: ${rest.trim()} (try /do)`, "error");
|
|
2029
2494
|
}
|
|
2030
2495
|
await startCraftbook(book);
|
|
2031
2496
|
return;
|
|
@@ -2083,15 +2548,14 @@ function App(props) {
|
|
|
2083
2548
|
}
|
|
2084
2549
|
},
|
|
2085
2550
|
[
|
|
2086
|
-
activeGezel,
|
|
2087
|
-
activeGezelId,
|
|
2088
2551
|
applyEngagementMode,
|
|
2552
|
+
applyProjectPermission,
|
|
2089
2553
|
client,
|
|
2090
|
-
config,
|
|
2091
2554
|
craftbooks,
|
|
2092
|
-
modelChoicesLoading,
|
|
2093
2555
|
note,
|
|
2094
2556
|
exit,
|
|
2557
|
+
openModelDownloadPicker,
|
|
2558
|
+
openModelPicker,
|
|
2095
2559
|
openThreadPicker,
|
|
2096
2560
|
projectId,
|
|
2097
2561
|
projectName,
|
|
@@ -2100,11 +2564,10 @@ function App(props) {
|
|
|
2100
2564
|
startCraftbook
|
|
2101
2565
|
]
|
|
2102
2566
|
);
|
|
2103
|
-
const
|
|
2104
|
-
async (
|
|
2567
|
+
const applyModelSelection = useCallback(
|
|
2568
|
+
async (choice) => {
|
|
2105
2569
|
setOverlay(null);
|
|
2106
2570
|
if (!activeGezelId || !activeGezel || !config) return;
|
|
2107
|
-
const choice = modelChoices.find((item) => item.value === value2);
|
|
2108
2571
|
const nextProvider = choice?.provider ?? null;
|
|
2109
2572
|
const nextModel = choice?.model.id;
|
|
2110
2573
|
const providerChanged = (activeGezel.provider ?? null) !== nextProvider;
|
|
@@ -2129,8 +2592,80 @@ function App(props) {
|
|
|
2129
2592
|
note(`could not switch model: ${errMsg(err)}`, "error");
|
|
2130
2593
|
}
|
|
2131
2594
|
},
|
|
2132
|
-
[activeGezel, activeGezelId, client, config, ensureSession,
|
|
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]
|
|
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]
|
|
2133
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]);
|
|
2134
2669
|
const onSubmit = useCallback(
|
|
2135
2670
|
(raw) => {
|
|
2136
2671
|
setValue("");
|
|
@@ -2176,10 +2711,10 @@ function App(props) {
|
|
|
2176
2711
|
}
|
|
2177
2712
|
);
|
|
2178
2713
|
if (status) {
|
|
2179
|
-
return /* @__PURE__ */
|
|
2714
|
+
return /* @__PURE__ */ jsx5(Box6, { flexDirection: "column", padding: 1, children: /* @__PURE__ */ jsx5(Text6, { color: status.startsWith("Failed") ? "red" : "cyan", children: status }) });
|
|
2180
2715
|
}
|
|
2181
2716
|
return /* @__PURE__ */ jsxs6(Box6, { flexDirection: "column", padding: 1, children: [
|
|
2182
|
-
/* @__PURE__ */
|
|
2717
|
+
/* @__PURE__ */ jsx5(
|
|
2183
2718
|
ChatFeed,
|
|
2184
2719
|
{
|
|
2185
2720
|
rows,
|
|
@@ -2189,7 +2724,7 @@ function App(props) {
|
|
|
2189
2724
|
visible: visibleRows
|
|
2190
2725
|
}
|
|
2191
2726
|
),
|
|
2192
|
-
overlay === "project" ? /* @__PURE__ */
|
|
2727
|
+
overlay === "project" ? /* @__PURE__ */ jsx5(
|
|
2193
2728
|
Picker,
|
|
2194
2729
|
{
|
|
2195
2730
|
title: "Switch project",
|
|
@@ -2198,7 +2733,7 @@ function App(props) {
|
|
|
2198
2733
|
onSelect: (id) => void switchProject(id)
|
|
2199
2734
|
}
|
|
2200
2735
|
) : null,
|
|
2201
|
-
overlay === "gezel" ? /* @__PURE__ */
|
|
2736
|
+
overlay === "gezel" ? /* @__PURE__ */ jsx5(
|
|
2202
2737
|
Picker,
|
|
2203
2738
|
{
|
|
2204
2739
|
title: "Switch gezel",
|
|
@@ -2218,7 +2753,7 @@ function App(props) {
|
|
|
2218
2753
|
}
|
|
2219
2754
|
}
|
|
2220
2755
|
) : null,
|
|
2221
|
-
overlay === "engagement-mode" ? /* @__PURE__ */
|
|
2756
|
+
overlay === "engagement-mode" ? /* @__PURE__ */ jsx5(
|
|
2222
2757
|
Picker,
|
|
2223
2758
|
{
|
|
2224
2759
|
title: "Choose AI engagement mode",
|
|
@@ -2232,16 +2767,21 @@ function App(props) {
|
|
|
2232
2767
|
onSelect: (selected) => void applyEngagementMode(selected)
|
|
2233
2768
|
}
|
|
2234
2769
|
) : null,
|
|
2235
|
-
overlay === "model" ? /* @__PURE__ */
|
|
2770
|
+
overlay === "model" ? /* @__PURE__ */ jsx5(
|
|
2236
2771
|
Picker,
|
|
2237
2772
|
{
|
|
2238
|
-
title: "Choose engine + model",
|
|
2773
|
+
title: "Choose engine + model - models are downloaded from Hugging Face (huggingface.co)",
|
|
2239
2774
|
items: [
|
|
2240
2775
|
{
|
|
2241
2776
|
label: "Use default",
|
|
2242
2777
|
value: "__default__",
|
|
2243
2778
|
hint: `${modelProviderLabel(config?.provider ?? "llama-cpp")}${config?.defaultModel?.[config.provider] ? ` \xB7 ${config.defaultModel[config.provider]}` : ""}`
|
|
2244
2779
|
},
|
|
2780
|
+
{
|
|
2781
|
+
label: "Download a new model\u2026",
|
|
2782
|
+
value: "__download__",
|
|
2783
|
+
hint: "browse on-device models ranked for this machine"
|
|
2784
|
+
},
|
|
2245
2785
|
...modelChoices.map((choice) => ({
|
|
2246
2786
|
label: choice.label,
|
|
2247
2787
|
value: choice.value,
|
|
@@ -2251,10 +2791,36 @@ function App(props) {
|
|
|
2251
2791
|
initialValue: activeGezel?.provider && activeGezel.model ? `${activeGezel.provider}:${activeGezel.model}` : "__default__",
|
|
2252
2792
|
windowSize: modelPickerWindowSize,
|
|
2253
2793
|
onCancel: () => setOverlay(null),
|
|
2254
|
-
onSelect: (value2) =>
|
|
2794
|
+
onSelect: (value2) => {
|
|
2795
|
+
if (value2 === "__download__") void openModelDownloadPicker("model");
|
|
2796
|
+
else void applyModelChoice(value2);
|
|
2797
|
+
}
|
|
2798
|
+
}
|
|
2799
|
+
) : null,
|
|
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)
|
|
2255
2821
|
}
|
|
2256
2822
|
) : null,
|
|
2257
|
-
overlay === "start-category" ? /* @__PURE__ */
|
|
2823
|
+
overlay === "start-category" ? /* @__PURE__ */ jsx5(
|
|
2258
2824
|
Picker,
|
|
2259
2825
|
{
|
|
2260
2826
|
title: "Choose a craftbook category",
|
|
@@ -2271,7 +2837,7 @@ function App(props) {
|
|
|
2271
2837
|
}
|
|
2272
2838
|
}
|
|
2273
2839
|
) : null,
|
|
2274
|
-
overlay === "start-craftbook" ? /* @__PURE__ */
|
|
2840
|
+
overlay === "start-craftbook" ? /* @__PURE__ */ jsx5(
|
|
2275
2841
|
Picker,
|
|
2276
2842
|
{
|
|
2277
2843
|
title: startCategory?.label ?? "Start a craftbook",
|
|
@@ -2288,7 +2854,7 @@ function App(props) {
|
|
|
2288
2854
|
}
|
|
2289
2855
|
}
|
|
2290
2856
|
) : null,
|
|
2291
|
-
overlay === "thread" ? /* @__PURE__ */
|
|
2857
|
+
overlay === "thread" ? /* @__PURE__ */ jsx5(
|
|
2292
2858
|
Picker,
|
|
2293
2859
|
{
|
|
2294
2860
|
title: `Threads with ${gezelLine}`,
|
|
@@ -2309,7 +2875,7 @@ function App(props) {
|
|
|
2309
2875
|
}
|
|
2310
2876
|
}
|
|
2311
2877
|
) : null,
|
|
2312
|
-
overlay === "task" ? /* @__PURE__ */
|
|
2878
|
+
overlay === "task" ? /* @__PURE__ */ jsx5(
|
|
2313
2879
|
Picker,
|
|
2314
2880
|
{
|
|
2315
2881
|
title: `Tasks \xB7 ${tasks.filter((task) => task.status === "active").length} active`,
|
|
@@ -2334,7 +2900,7 @@ function App(props) {
|
|
|
2334
2900
|
}
|
|
2335
2901
|
}
|
|
2336
2902
|
) : null,
|
|
2337
|
-
overlay === "task-actions" && managedTask ? /* @__PURE__ */
|
|
2903
|
+
overlay === "task-actions" && managedTask ? /* @__PURE__ */ jsx5(
|
|
2338
2904
|
Picker,
|
|
2339
2905
|
{
|
|
2340
2906
|
title: `${managedTask.ref} \xB7 ${managedTask.status}`,
|
|
@@ -2369,7 +2935,7 @@ function App(props) {
|
|
|
2369
2935
|
}
|
|
2370
2936
|
}
|
|
2371
2937
|
) : null,
|
|
2372
|
-
overlay === "task-status" && managedTask ? /* @__PURE__ */
|
|
2938
|
+
overlay === "task-status" && managedTask ? /* @__PURE__ */ jsx5(
|
|
2373
2939
|
Picker,
|
|
2374
2940
|
{
|
|
2375
2941
|
title: `Set ${managedTask.ref} status`,
|
|
@@ -2378,7 +2944,7 @@ function App(props) {
|
|
|
2378
2944
|
onSelect: (status2) => void applyTaskStatus(status2)
|
|
2379
2945
|
}
|
|
2380
2946
|
) : null,
|
|
2381
|
-
overlay === "task-assignee" && managedTask ? /* @__PURE__ */
|
|
2947
|
+
overlay === "task-assignee" && managedTask ? /* @__PURE__ */ jsx5(
|
|
2382
2948
|
Picker,
|
|
2383
2949
|
{
|
|
2384
2950
|
title: `Assign ${managedTask.ref}`,
|
|
@@ -2398,7 +2964,7 @@ function App(props) {
|
|
|
2398
2964
|
onSelect: (assignee) => void applyTaskAssignee(assignee)
|
|
2399
2965
|
}
|
|
2400
2966
|
) : null,
|
|
2401
|
-
overlay === "focus" ? /* @__PURE__ */
|
|
2967
|
+
overlay === "focus" ? /* @__PURE__ */ jsx5(
|
|
2402
2968
|
Picker,
|
|
2403
2969
|
{
|
|
2404
2970
|
title: "Send into which chat?",
|
|
@@ -2410,7 +2976,7 @@ function App(props) {
|
|
|
2410
2976
|
}
|
|
2411
2977
|
}
|
|
2412
2978
|
) : null,
|
|
2413
|
-
overlay === null && pendingQuestion ? /* @__PURE__ */
|
|
2979
|
+
overlay === null && pendingQuestion ? /* @__PURE__ */ jsx5(
|
|
2414
2980
|
QuestionPrompt,
|
|
2415
2981
|
{
|
|
2416
2982
|
client,
|
|
@@ -2424,7 +2990,7 @@ function App(props) {
|
|
|
2424
2990
|
},
|
|
2425
2991
|
pendingQuestion.id
|
|
2426
2992
|
) : null,
|
|
2427
|
-
/* @__PURE__ */
|
|
2993
|
+
/* @__PURE__ */ jsx5(
|
|
2428
2994
|
PromptLine,
|
|
2429
2995
|
{
|
|
2430
2996
|
projectName,
|
|
@@ -2448,6 +3014,52 @@ function App(props) {
|
|
|
2448
3014
|
)
|
|
2449
3015
|
] });
|
|
2450
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
|
+
}
|
|
2451
3063
|
function errMsg(err) {
|
|
2452
3064
|
return err instanceof Error ? err.message : String(err);
|
|
2453
3065
|
}
|
|
@@ -2522,7 +3134,7 @@ function taskAssigneeLabel(task, gezels, boring) {
|
|
|
2522
3134
|
if (task.assignee.kind === "user") return "you";
|
|
2523
3135
|
const gezelId = task.assignee.gezelId;
|
|
2524
3136
|
const gezel = gezels.find((item) => item.id === gezelId);
|
|
2525
|
-
if (!gezel) return gezelId;
|
|
3137
|
+
if (!gezel) return boring ? "gezel" : gezelId;
|
|
2526
3138
|
return boring ? gezel.roleBasedName ?? gezel.role ?? gezel.id : gezel.name;
|
|
2527
3139
|
}
|
|
2528
3140
|
function taskStatusChoices(task) {
|
|
@@ -2550,174 +3162,10 @@ function formatTaskDetails(task, gezels, boring) {
|
|
|
2550
3162
|
}
|
|
2551
3163
|
|
|
2552
3164
|
// src/tui/components/BootstrapGate.tsx
|
|
3165
|
+
import { formatModelAttribution as formatModelAttribution3 } from "@bendyline/gezel";
|
|
2553
3166
|
import { Box as Box7, Text as Text7, useApp as useApp2, useInput as useInput5 } from "ink";
|
|
2554
3167
|
import { useCallback as useCallback2, useEffect as useEffect4, useState as useState5 } from "react";
|
|
2555
|
-
|
|
2556
|
-
// src/tui/bootstrap.ts
|
|
2557
|
-
import {
|
|
2558
|
-
computeModelFit,
|
|
2559
|
-
isMoEFromTags,
|
|
2560
|
-
isRecommendedModel,
|
|
2561
|
-
mediaModelFits,
|
|
2562
|
-
pickRecommendedModel
|
|
2563
|
-
} from "@bendyline/gezel";
|
|
2564
|
-
var CHAT_MEMORY_OVERHEAD = {
|
|
2565
|
-
"llama-cpp": 1.2,
|
|
2566
|
-
mlx: 1.3
|
|
2567
|
-
};
|
|
2568
|
-
var NATIVE_TOOLKIT = [
|
|
2569
|
-
"uv",
|
|
2570
|
-
"sd-server",
|
|
2571
|
-
"whisper-server",
|
|
2572
|
-
"llama-server"
|
|
2573
|
-
];
|
|
2574
|
-
function rankChatModels(items, device, provider) {
|
|
2575
|
-
const candidates = [];
|
|
2576
|
-
for (const item of items) {
|
|
2577
|
-
if (item.manifest.kind !== "chat-model") continue;
|
|
2578
|
-
const manifest = item.manifest;
|
|
2579
|
-
if (manifest.licenseClass !== "open") continue;
|
|
2580
|
-
const source = provider === "mlx" ? manifest.mlx : manifest.llamaCpp;
|
|
2581
|
-
if (!source || provider === "mlx" && manifest.mlx?.disabledReason) continue;
|
|
2582
|
-
const residentBytes = source.residentBytes ?? Math.round(source.approxSizeBytes * CHAT_MEMORY_OVERHEAD[provider]);
|
|
2583
|
-
const fit = computeModelFit({
|
|
2584
|
-
residentBytes,
|
|
2585
|
-
isMoE: isMoEFromTags(manifest.tags),
|
|
2586
|
-
usableBytes: device.usableBytes,
|
|
2587
|
-
totalRamBytes: device.totalRamBytes,
|
|
2588
|
-
gpuVramBytes: device.gpuVramBytes,
|
|
2589
|
-
...device.budgetBytes !== void 0 ? { admissibleBytes: device.budgetBytes } : {}
|
|
2590
|
-
}).tier;
|
|
2591
|
-
candidates.push({
|
|
2592
|
-
id: manifest.id,
|
|
2593
|
-
name: manifest.name,
|
|
2594
|
-
provider,
|
|
2595
|
-
approxSizeBytes: source.approxSizeBytes,
|
|
2596
|
-
residentBytes,
|
|
2597
|
-
// Effective score: a model the shared gate rejects (restricted license,
|
|
2598
|
-
// no tool support) sorts as unscored rather than leading the list.
|
|
2599
|
-
recoScore: isRecommendedModel(manifest) ? manifest.recoScore ?? 0 : 0,
|
|
2600
|
-
fit
|
|
2601
|
-
});
|
|
2602
|
-
}
|
|
2603
|
-
if (candidates.length === 0) return [];
|
|
2604
|
-
const picked = pickRecommendedModel(
|
|
2605
|
-
candidates.map((model) => ({
|
|
2606
|
-
id: model.id,
|
|
2607
|
-
...model.recoScore > 0 ? { recoScore: model.recoScore } : {},
|
|
2608
|
-
licenseClass: "open",
|
|
2609
|
-
tags: items.find((item) => item.manifest.kind === "chat-model" && item.manifest.id === model.id)?.manifest?.tags ?? [],
|
|
2610
|
-
residentBytes: model.residentBytes
|
|
2611
|
-
})),
|
|
2612
|
-
device
|
|
2613
|
-
);
|
|
2614
|
-
const comfortable = candidates.filter(
|
|
2615
|
-
(model) => model.fit === "fits" || model.fit === "fits-offload"
|
|
2616
|
-
);
|
|
2617
|
-
const pool = comfortable.length > 0 ? comfortable : candidates;
|
|
2618
|
-
pool.sort(
|
|
2619
|
-
(a, b) => b.recoScore - a.recoScore || fitOrder(a.fit) - fitOrder(b.fit) || b.residentBytes - a.residentBytes || a.name.localeCompare(b.name)
|
|
2620
|
-
);
|
|
2621
|
-
if (!picked) return pool;
|
|
2622
|
-
const bestIndex = pool.findIndex((model) => model.id === picked.id);
|
|
2623
|
-
if (bestIndex < 0) {
|
|
2624
|
-
const best = candidates.find((model) => model.id === picked.id);
|
|
2625
|
-
if (best) pool.unshift(best);
|
|
2626
|
-
return pool;
|
|
2627
|
-
}
|
|
2628
|
-
if (bestIndex > 0) {
|
|
2629
|
-
const [best] = pool.splice(bestIndex, 1);
|
|
2630
|
-
if (best) pool.unshift(best);
|
|
2631
|
-
}
|
|
2632
|
-
return pool;
|
|
2633
|
-
}
|
|
2634
|
-
function pickAccessoryModels(input, device) {
|
|
2635
|
-
const output = [];
|
|
2636
|
-
const image = pickCatalogMedia(input.imageItems, device, "image");
|
|
2637
|
-
if (image && !input.installed.image?.has(image.id)) {
|
|
2638
|
-
output.push({
|
|
2639
|
-
kind: "image",
|
|
2640
|
-
id: image.id,
|
|
2641
|
-
name: image.name,
|
|
2642
|
-
approxSizeBytes: image.approxSizeBytes + (image.auxiliaryFiles ?? []).reduce((sum, file) => sum + (file.sizeBytes ?? 0), 0),
|
|
2643
|
-
requiredEngine: "sd-server"
|
|
2644
|
-
});
|
|
2645
|
-
}
|
|
2646
|
-
const recognition = pickScoredOpen(input.recognition, false);
|
|
2647
|
-
if (recognition && !input.installed.recognition?.has(recognition.id)) {
|
|
2648
|
-
output.push({
|
|
2649
|
-
kind: "recognition",
|
|
2650
|
-
id: recognition.id,
|
|
2651
|
-
name: recognition.name,
|
|
2652
|
-
approxSizeBytes: recognition.approxSizeBytes,
|
|
2653
|
-
requiredEngine: "llama-server"
|
|
2654
|
-
});
|
|
2655
|
-
}
|
|
2656
|
-
const stt = pickScoredOpen(input.audio.stt);
|
|
2657
|
-
if (stt && !input.installed.stt?.has(stt.id)) {
|
|
2658
|
-
output.push({
|
|
2659
|
-
kind: "stt",
|
|
2660
|
-
id: stt.id,
|
|
2661
|
-
name: stt.name,
|
|
2662
|
-
approxSizeBytes: stt.approxSizeBytes,
|
|
2663
|
-
requiredEngine: "whisper-server"
|
|
2664
|
-
});
|
|
2665
|
-
}
|
|
2666
|
-
const tts = pickScoredOpen(input.audio.tts);
|
|
2667
|
-
if (tts && !input.installed.tts?.has(tts.id)) {
|
|
2668
|
-
output.push({
|
|
2669
|
-
kind: "tts",
|
|
2670
|
-
id: tts.id,
|
|
2671
|
-
name: tts.name,
|
|
2672
|
-
approxSizeBytes: tts.approxSizeBytes
|
|
2673
|
-
});
|
|
2674
|
-
}
|
|
2675
|
-
const video = pickCatalogMedia(input.videoItems, device, "video");
|
|
2676
|
-
if (video && !input.installed.video?.has(video.id)) {
|
|
2677
|
-
output.push({
|
|
2678
|
-
kind: "video",
|
|
2679
|
-
id: video.id,
|
|
2680
|
-
name: video.name,
|
|
2681
|
-
approxSizeBytes: video.approxSizeBytes,
|
|
2682
|
-
requiredEngine: "uv"
|
|
2683
|
-
});
|
|
2684
|
-
}
|
|
2685
|
-
return output;
|
|
2686
|
-
}
|
|
2687
|
-
function formatDownloadSize(bytes) {
|
|
2688
|
-
if (bytes >= 1e9) return `${(bytes / 1e9).toFixed(1)} GB`;
|
|
2689
|
-
return `${Math.max(1, Math.round(bytes / 1e6))} MB`;
|
|
2690
|
-
}
|
|
2691
|
-
function fitOrder(fit) {
|
|
2692
|
-
switch (fit) {
|
|
2693
|
-
case "fits":
|
|
2694
|
-
return 0;
|
|
2695
|
-
case "fits-offload":
|
|
2696
|
-
return 1;
|
|
2697
|
-
case "tight":
|
|
2698
|
-
return 2;
|
|
2699
|
-
case "too-big":
|
|
2700
|
-
return 3;
|
|
2701
|
-
}
|
|
2702
|
-
}
|
|
2703
|
-
function pickCatalogMedia(items, device, kind) {
|
|
2704
|
-
const models = items.map((item) => item.manifest).filter((model) => {
|
|
2705
|
-
if (model.licenseClass !== "open" || !model.recoScore) return false;
|
|
2706
|
-
return mediaModelFits(
|
|
2707
|
-
device,
|
|
2708
|
-
kind === "image" ? { minRamGB: model.minRamGB } : { minVramGB: model.minVramGB }
|
|
2709
|
-
);
|
|
2710
|
-
});
|
|
2711
|
-
return pickScoredOpen(models);
|
|
2712
|
-
}
|
|
2713
|
-
function pickScoredOpen(models, requireLicense = true) {
|
|
2714
|
-
return [...models].filter(
|
|
2715
|
-
(model) => typeof model.recoScore === "number" && model.recoScore > 0 && (!requireLicense || model.licenseClass === "open")
|
|
2716
|
-
).sort((a, b) => (b.recoScore ?? 0) - (a.recoScore ?? 0))[0] ?? null;
|
|
2717
|
-
}
|
|
2718
|
-
|
|
2719
|
-
// src/tui/components/BootstrapGate.tsx
|
|
2720
|
-
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";
|
|
2721
3169
|
var MAX_ALTERNATIVE_MODELS = 6;
|
|
2722
3170
|
function BootstrapGate(props) {
|
|
2723
3171
|
const { client, children } = props;
|
|
@@ -2740,7 +3188,8 @@ function BootstrapGate(props) {
|
|
|
2740
3188
|
async (context) => {
|
|
2741
3189
|
setScreen({ kind: "loading", message: "Finding the best models for this device\u2026" });
|
|
2742
3190
|
const installedChat = context.provider === "mlx" ? await client.listMlxModels() : await client.listLlamaCppModels();
|
|
2743
|
-
|
|
3191
|
+
const pinnedModel = context.config.defaultModel?.[context.provider];
|
|
3192
|
+
if (pinnedModel && installedChat.models.some((model) => model.id === pinnedModel)) {
|
|
2744
3193
|
setScreen({ kind: "ready" });
|
|
2745
3194
|
return;
|
|
2746
3195
|
}
|
|
@@ -2765,8 +3214,20 @@ function BootstrapGate(props) {
|
|
|
2765
3214
|
client.listInstalledTtsModels().catch(() => ({ models: [] })),
|
|
2766
3215
|
client.listInstalledRecognitionModels().catch(() => ({ models: [] }))
|
|
2767
3216
|
]);
|
|
2768
|
-
const
|
|
2769
|
-
|
|
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) {
|
|
2770
3231
|
setScreen({
|
|
2771
3232
|
kind: "error",
|
|
2772
3233
|
title: "No compatible local models found",
|
|
@@ -2790,7 +3251,19 @@ function BootstrapGate(props) {
|
|
|
2790
3251
|
},
|
|
2791
3252
|
context.device
|
|
2792
3253
|
);
|
|
2793
|
-
setScreen({
|
|
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
|
+
});
|
|
2794
3267
|
},
|
|
2795
3268
|
[client]
|
|
2796
3269
|
);
|
|
@@ -2818,14 +3291,7 @@ function BootstrapGate(props) {
|
|
|
2818
3291
|
const context = {
|
|
2819
3292
|
config,
|
|
2820
3293
|
provider: config.provider,
|
|
2821
|
-
device:
|
|
2822
|
-
platform: memory.platform,
|
|
2823
|
-
gpuVramBytes: memory.gpuVramBytes,
|
|
2824
|
-
...memory.gpuMemoryKind ? { gpuMemoryKind: memory.gpuMemoryKind } : {},
|
|
2825
|
-
totalRamBytes: memory.totalRamBytes,
|
|
2826
|
-
usableBytes: memory.usableBytes,
|
|
2827
|
-
...memory.budgetBytes !== void 0 ? { budgetBytes: memory.budgetBytes } : {}
|
|
2828
|
-
},
|
|
3294
|
+
device: recoDevice(memory),
|
|
2829
3295
|
chatCatalog: chatCatalog.items,
|
|
2830
3296
|
nativeStatus
|
|
2831
3297
|
};
|
|
@@ -2860,12 +3326,19 @@ function BootstrapGate(props) {
|
|
|
2860
3326
|
}
|
|
2861
3327
|
try {
|
|
2862
3328
|
await installNativeToolkit(client, context.nativeStatus, missing, setScreen);
|
|
2863
|
-
const nativeStatus = await
|
|
2864
|
-
|
|
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
|
+
});
|
|
2865
3338
|
} catch (error) {
|
|
2866
3339
|
setScreen({
|
|
2867
3340
|
kind: "error",
|
|
2868
|
-
title: "
|
|
3341
|
+
title: "Gezel native toolkit install failed",
|
|
2869
3342
|
message: errorMessage(error),
|
|
2870
3343
|
retry
|
|
2871
3344
|
});
|
|
@@ -2881,24 +3354,40 @@ function BootstrapGate(props) {
|
|
|
2881
3354
|
}
|
|
2882
3355
|
const retry = () => void installModels(plan, choice);
|
|
2883
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
|
+
}
|
|
2884
3370
|
if (choice.kind === "bundle") {
|
|
2885
3371
|
const missing = missingToolkit(await client.getNativeEngineStatus());
|
|
2886
3372
|
if (missing.length > 0) {
|
|
2887
3373
|
await installNativeToolkit(client, plan.context.nativeStatus, missing, setScreen);
|
|
2888
3374
|
}
|
|
2889
3375
|
}
|
|
3376
|
+
const chatAlreadyInstalled = choice.kind === "bundle" && plan.installedChatModels.some((model) => model.id === choice.model.id);
|
|
2890
3377
|
const jobs = [
|
|
2891
|
-
{ label: choice.model.name, sizeBytes: choice.model.approxSizeBytes },
|
|
3378
|
+
...!chatAlreadyInstalled ? [{ label: choice.model.name, sizeBytes: choice.model.approxSizeBytes }] : [],
|
|
2892
3379
|
...choice.kind === "bundle" ? plan.accessories.map((model) => ({
|
|
2893
3380
|
label: model.name,
|
|
2894
3381
|
sizeBytes: model.approxSizeBytes
|
|
2895
3382
|
})) : []
|
|
2896
3383
|
];
|
|
2897
3384
|
let jobIndex = 0;
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
|
|
3385
|
+
if (!chatAlreadyInstalled) {
|
|
3386
|
+
await installChatModel(client, choice.model, (event) => {
|
|
3387
|
+
updateDownloadProgress(setScreen, jobs[jobIndex], jobIndex, jobs.length, event);
|
|
3388
|
+
});
|
|
3389
|
+
jobIndex += 1;
|
|
3390
|
+
}
|
|
2902
3391
|
const updated = await client.updateConfig({
|
|
2903
3392
|
provider: choice.model.provider,
|
|
2904
3393
|
defaultModel: {
|
|
@@ -2929,9 +3418,9 @@ function BootstrapGate(props) {
|
|
|
2929
3418
|
},
|
|
2930
3419
|
[client]
|
|
2931
3420
|
);
|
|
2932
|
-
if (screen.kind === "ready") return /* @__PURE__ */
|
|
3421
|
+
if (screen.kind === "ready") return /* @__PURE__ */ jsx6(Fragment4, { children });
|
|
2933
3422
|
if (screen.kind === "loading") {
|
|
2934
|
-
return /* @__PURE__ */
|
|
3423
|
+
return /* @__PURE__ */ jsx6(BootstrapFrame, { title: "Preparing the workshop", children: /* @__PURE__ */ jsxs7(Text7, { color: "yellow", children: [
|
|
2935
3424
|
"\u25CF ",
|
|
2936
3425
|
screen.message
|
|
2937
3426
|
] }) });
|
|
@@ -2945,28 +3434,29 @@ function BootstrapGate(props) {
|
|
|
2945
3434
|
" ",
|
|
2946
3435
|
screen.progress.detail
|
|
2947
3436
|
] }),
|
|
2948
|
-
/* @__PURE__ */
|
|
2949
|
-
/* @__PURE__ */
|
|
3437
|
+
/* @__PURE__ */ jsx6(ProgressBar, { pct: screen.progress.pct }),
|
|
3438
|
+
/* @__PURE__ */ jsx6(Text7, { dimColor: true, children: screen.progress.pct == null ? "Working\u2026" : `${screen.progress.pct}%` })
|
|
2950
3439
|
] });
|
|
2951
3440
|
}
|
|
2952
3441
|
if (screen.kind === "native-choice") {
|
|
2953
3442
|
const labels = screen.missing.map(nativeLabel).join(", ");
|
|
2954
|
-
return /* @__PURE__ */ jsxs7(BootstrapFrame, { title: "
|
|
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.` }),
|
|
2955
3445
|
/* @__PURE__ */ jsxs7(Text7, { children: [
|
|
2956
|
-
"
|
|
2957
|
-
|
|
2958
|
-
|
|
3446
|
+
"Downloaded from",
|
|
3447
|
+
" ",
|
|
3448
|
+
/* @__PURE__ */ jsx6(Text7, { bold: true, color: "cyan", children: "https://github.com/bendyline/gezel/releases/" })
|
|
2959
3449
|
] }),
|
|
2960
3450
|
/* @__PURE__ */ jsxs7(Text7, { dimColor: true, children: [
|
|
2961
3451
|
"Missing: ",
|
|
2962
3452
|
labels
|
|
2963
3453
|
] }),
|
|
2964
|
-
/* @__PURE__ */
|
|
3454
|
+
/* @__PURE__ */ jsx6(
|
|
2965
3455
|
BootstrapChoiceList,
|
|
2966
3456
|
{
|
|
2967
3457
|
options: [
|
|
2968
3458
|
{
|
|
2969
|
-
label: "Install the native toolkit",
|
|
3459
|
+
label: "Install the Gezel native toolkit",
|
|
2970
3460
|
hint: "recommended \xB7 engines for chat, images, speech, and local model helpers",
|
|
2971
3461
|
value: "install"
|
|
2972
3462
|
},
|
|
@@ -2984,53 +3474,73 @@ function BootstrapGate(props) {
|
|
|
2984
3474
|
] });
|
|
2985
3475
|
}
|
|
2986
3476
|
if (screen.kind === "model-choice") {
|
|
2987
|
-
const best = screen.plan.
|
|
3477
|
+
const best = screen.plan.recommendedChatModel;
|
|
3478
|
+
const bestInstalled = best ? screen.plan.installedChatModels.some((model) => model.id === best.id) : false;
|
|
2988
3479
|
const accessoryBytes = screen.plan.accessories.reduce(
|
|
2989
3480
|
(sum, model) => sum + model.approxSizeBytes,
|
|
2990
3481
|
0
|
|
2991
3482
|
);
|
|
3483
|
+
const workshopDownloadBytes = accessoryBytes + (best && !bestInstalled ? best.approxSizeBytes : 0);
|
|
2992
3484
|
const options = [
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
|
|
3004
|
-
|
|
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`,
|
|
3005
3504
|
hint: `${formatDownloadSize(model.approxSizeBytes)} \xB7 ${fitLabel(model.fit)}`,
|
|
3006
3505
|
value: `chat:${model.id}`
|
|
3007
3506
|
})),
|
|
3008
3507
|
{ label: "Not now", hint: "open the TUI without a local model", value: "skip" }
|
|
3009
3508
|
];
|
|
3010
|
-
return /* @__PURE__ */ jsxs7(
|
|
3011
|
-
|
|
3012
|
-
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
|
|
3016
|
-
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
|
|
3020
|
-
|
|
3021
|
-
|
|
3022
|
-
|
|
3023
|
-
|
|
3024
|
-
|
|
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
|
+
}
|
|
3025
3535
|
}
|
|
3026
|
-
|
|
3027
|
-
|
|
3028
|
-
|
|
3029
|
-
|
|
3536
|
+
)
|
|
3537
|
+
]
|
|
3538
|
+
}
|
|
3539
|
+
);
|
|
3030
3540
|
}
|
|
3031
3541
|
return /* @__PURE__ */ jsxs7(BootstrapFrame, { title: screen.title, children: [
|
|
3032
|
-
/* @__PURE__ */
|
|
3033
|
-
/* @__PURE__ */
|
|
3542
|
+
/* @__PURE__ */ jsx6(Text7, { color: "red", children: screen.message }),
|
|
3543
|
+
/* @__PURE__ */ jsx6(
|
|
3034
3544
|
BootstrapChoiceList,
|
|
3035
3545
|
{
|
|
3036
3546
|
options: [
|
|
@@ -3047,7 +3557,7 @@ function BootstrapGate(props) {
|
|
|
3047
3557
|
}
|
|
3048
3558
|
function BootstrapFrame(props) {
|
|
3049
3559
|
return /* @__PURE__ */ jsxs7(Box7, { flexDirection: "column", paddingX: 1, paddingY: 1, children: [
|
|
3050
|
-
/* @__PURE__ */
|
|
3560
|
+
/* @__PURE__ */ jsx6(Text7, { bold: true, color: "cyan", children: "gezel \xB7 first-time setup" }),
|
|
3051
3561
|
/* @__PURE__ */ jsxs7(
|
|
3052
3562
|
Box7,
|
|
3053
3563
|
{
|
|
@@ -3057,14 +3567,24 @@ function BootstrapFrame(props) {
|
|
|
3057
3567
|
paddingX: 1,
|
|
3058
3568
|
marginTop: 1,
|
|
3059
3569
|
children: [
|
|
3060
|
-
/* @__PURE__ */
|
|
3570
|
+
/* @__PURE__ */ jsx6(Text7, { bold: true, color: "yellow", children: props.title }),
|
|
3061
3571
|
props.children
|
|
3062
3572
|
]
|
|
3063
3573
|
}
|
|
3064
3574
|
),
|
|
3065
|
-
/* @__PURE__ */
|
|
3575
|
+
/* @__PURE__ */ jsx6(Text7, { dimColor: true, children: "Ctrl+C exit" })
|
|
3066
3576
|
] });
|
|
3067
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
|
+
}
|
|
3068
3588
|
function BootstrapChoiceList(props) {
|
|
3069
3589
|
const [index, setIndex] = useState5(0);
|
|
3070
3590
|
const options = props.options;
|
|
@@ -3137,7 +3657,7 @@ async function installNativeToolkit(client, status, missing, setScreen) {
|
|
|
3137
3657
|
index,
|
|
3138
3658
|
missing.length,
|
|
3139
3659
|
event,
|
|
3140
|
-
`Installing native-v${status.release}`
|
|
3660
|
+
`Installing the Gezel native toolkit (native-v${status.release})`
|
|
3141
3661
|
);
|
|
3142
3662
|
},
|
|
3143
3663
|
engine === "llama-server" ? status.llamaBackend : void 0
|
|
@@ -3241,10 +3761,10 @@ function delay(ms) {
|
|
|
3241
3761
|
}
|
|
3242
3762
|
|
|
3243
3763
|
// src/tui/index.tsx
|
|
3244
|
-
import { jsx as
|
|
3764
|
+
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
3245
3765
|
async function launchTui(opts) {
|
|
3246
3766
|
const instance = render(
|
|
3247
|
-
/* @__PURE__ */
|
|
3767
|
+
/* @__PURE__ */ jsx7(BootstrapGate, { client: opts.client, children: /* @__PURE__ */ jsx7(
|
|
3248
3768
|
App,
|
|
3249
3769
|
{
|
|
3250
3770
|
client: opts.client,
|