@galaxy-stack/blackhole-cli 2.0.0-alpha.9 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/README.md +74 -3
  2. package/dist/application.d.ts +42 -0
  3. package/dist/application.d.ts.map +1 -1
  4. package/dist/application.js +113 -8
  5. package/dist/application.js.map +1 -1
  6. package/dist/cli-meta.d.ts +15 -0
  7. package/dist/cli-meta.d.ts.map +1 -0
  8. package/dist/cli-meta.js +37 -0
  9. package/dist/cli-meta.js.map +1 -0
  10. package/dist/cli.js +14 -2
  11. package/dist/cli.js.map +1 -1
  12. package/dist/commands.d.ts +13 -0
  13. package/dist/commands.d.ts.map +1 -0
  14. package/dist/commands.js +40 -0
  15. package/dist/commands.js.map +1 -0
  16. package/dist/composer.d.ts +3 -1
  17. package/dist/composer.d.ts.map +1 -1
  18. package/dist/composer.js +15 -3
  19. package/dist/composer.js.map +1 -1
  20. package/dist/file-index.d.ts +20 -0
  21. package/dist/file-index.d.ts.map +1 -0
  22. package/dist/file-index.js +60 -0
  23. package/dist/file-index.js.map +1 -0
  24. package/dist/flow.d.ts +30 -0
  25. package/dist/flow.d.ts.map +1 -1
  26. package/dist/flow.js +172 -28
  27. package/dist/flow.js.map +1 -1
  28. package/dist/manual-config.d.ts +28 -0
  29. package/dist/manual-config.d.ts.map +1 -0
  30. package/dist/manual-config.js +67 -0
  31. package/dist/manual-config.js.map +1 -0
  32. package/dist/options.d.ts +10 -2
  33. package/dist/options.d.ts.map +1 -1
  34. package/dist/options.js +46 -7
  35. package/dist/options.js.map +1 -1
  36. package/dist/provider-display.d.ts +20 -0
  37. package/dist/provider-display.d.ts.map +1 -0
  38. package/dist/provider-display.js +26 -0
  39. package/dist/provider-display.js.map +1 -0
  40. package/dist/thinking-policy.d.ts +53 -0
  41. package/dist/thinking-policy.d.ts.map +1 -0
  42. package/dist/thinking-policy.js +135 -0
  43. package/dist/thinking-policy.js.map +1 -0
  44. package/dist/timeline.d.ts +52 -5
  45. package/dist/timeline.d.ts.map +1 -1
  46. package/dist/timeline.js +362 -32
  47. package/dist/timeline.js.map +1 -1
  48. package/dist/tui.d.ts +3 -1
  49. package/dist/tui.d.ts.map +1 -1
  50. package/dist/tui.js +353 -13
  51. package/dist/tui.js.map +1 -1
  52. package/dist/web/options.js +2 -2
  53. package/dist/web/options.js.map +1 -1
  54. package/package.json +2 -2
  55. package/skills/galaxy-ui/SKILL.md +13 -0
  56. package/skills/orbit-framework/SKILL.md +398 -4
  57. package/web/brand/client.template.js +184 -0
  58. package/web/brand/lib/client.js +212 -2
  59. package/web/brand/lib/index.d.ts +3 -0
  60. package/web/brand/lib/index.js +202 -0
  61. package/web/brand/lib/session-store.d.ts +54 -0
  62. package/web/brand/lib/session-store.js +288 -0
  63. package/web/brand/vi.locales.json +28 -2
  64. package/web/patches/gbh-brand.patch.yml +1 -1
@@ -6,6 +6,9 @@ window.__ModuleLoader__.load({
6
6
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
7
7
  let react_jsx_runtime = require("react/jsx-runtime");
8
8
  let react = require("react");
9
+ /* UI primitives come from the renderer bundle; a missing module only costs the icon. */
10
+ let primitives = null;
11
+ try { primitives = require("@deepseek-ai/dsh-client-ui-primitives"); } catch (error) { primitives = null; }
9
12
  const LOGO = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAMAAACahl6sAAAAS1BMVEVHcEwABwsQ8/wMz9sMyNQJrr4N1N8Q7vcLv80Q8foQ8PkQ7fYFiZ0P6vMO2+UO3ecP6PEP5u8N2OIQ6/QP5O4P4uwO4OkR9v8R9f8lLy6cAAAAF3RSTlMAAfspHQo54xL069gEwFhos6VKzJeGd46TGgUAAAvESURBVHja7V3ZgqMqEA0CAoobivj/X3op0ESNSUwH7UlffJiZnixyqP1QZV8kOvg6/Ab+Lhd0+RMXikAikAgkAolAIpAIJAKJQCKQCCQCiUAikAgkAolA/k9ALlEiEUgE8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TS6zl7MK0KHSHjekXjSo+jvMykJjxHoCrs8P/yRsKZvnb+y+WOtK2VTFwKj0/CwgTbzg9VQ/76qx1VbH8CikJHxzNqmL+3a3JWqsu8a/xgBX4W4cW4JSaIz93GcnbGcsZm4wAnsoBX4IbTjWKQO17XZpQkx0yXo0e7KyUuR6jqbb5aPGFg+X+A3LgJPXzCbT8kY4FEOi7IBIXhawurJIPDEB/14PPxT5/pG0gFrE6u1ZXnR9QrTTQeVlr3umhrG2ZquH5/ncPl1IBcpp7U1tV2ZXVppTZm++pAbMERP7sVTci6Qm+JYSPBBeUEByECpRYCG0n/ggVK8NQFOeP4BIJgZof4CEGCW+z8AxE0+fc4p/j6QMhuyz4Z9RyC/CgWRPjNZZa1EY/m9QHjV2KxMVK5Xh9UafyuQyj88C41dYB8NbP2qYpWuOGmVb9hKhEZfKhEJp0L+CXCGdZ+x1b9r7NL3o1hD+biK+v3HrW/1InwlEFkmIai4f+AB+JiFaC79B4DwNsQgyj8BxDDyF4CgPg8wcfgv/JIIGaKWj7+2IwKJQCKQCCQCiUAikAgkAolAIpAIJAL5Y0Di7wyNQCKQCCQCiUAikAgkAolAIpAIJAKJhVUEEoGcYe7oyfX0xeubLnv/e7rj2I5+bUp/Yx2XuzvYP/8DsY316XTA+ZQAAAAASUVORK5CYII=";
10
13
  const VI_LOCALES = {
11
14
  "common": {
@@ -93,7 +96,8 @@ window.__ModuleLoader__.load({
93
96
  "connection.connecting": "Đang kết nối lại",
94
97
  "connection.connected": "Đã kết nối",
95
98
  "connection.reconnect": "Mất kết nối, kết nối lại ngay",
96
- "connection.restart": "Đang kết nối lại, kết nối lại ngay"
99
+ "connection.restart": "Đang kết nối lại, kết nối lại ngay",
100
+ "connection.retry": "Kết nối lại ngay"
97
101
  },
98
102
  "command": {
99
103
  "section.add": "Thêm",
@@ -142,6 +146,7 @@ window.__ModuleLoader__.load({
142
146
  "menu.effort": "Mức suy luận",
143
147
  "effort.providerDefault": "Mặc định",
144
148
  "status.loading": "Đang làm mới danh sách model…",
149
+ "blocked.composer": "Model này không khả dụng — hãy chọn một model để tiếp tục",
145
150
  "error.action": "Thao tác model thất bại: {message}",
146
151
  "error.sessionInUse": "Phiên này đang được dùng, có thể bởi DSH khác (dsh web hoặc desktop). Hãy thoát các DSH khác rồi thử lại.",
147
152
  "action.reload": "Tải lại",
@@ -150,7 +155,11 @@ window.__ModuleLoader__.load({
150
155
  "empty.efforts": "Model này không cung cấp mức suy luận nào."
151
156
  },
152
157
  "approval": {
153
- "detail.aria": "Chi tiết phê duyệt"
158
+ "detail.aria": "Chi tiết phê duyệt",
159
+ "waiting": "Đang chờ phê duyệt",
160
+ "escalation": "Công cụ {toolName} yêu cầu quyền thực thi đặc biệt",
161
+ "reject": "Từ chối",
162
+ "allowOnce": "Cho phép một lần"
154
163
  },
155
164
  "conversation": {
156
165
  "access.preset.readOnly": "Chỉ đọc",
@@ -603,6 +612,8 @@ window.__ModuleLoader__.load({
603
612
  "advancedHint": "Các trường khác nằm trong cordis.patch.yml; hãy sửa trực tiếp mục đó.",
604
613
  "modelCapacityInvalid": "Dung lượng phải là số, có thể có hậu tố K hoặc M.",
605
614
  "modelDuplicate": "Mỗi ID model chỉ được xuất hiện một lần.",
615
+ "modelContextWindow": "Cửa sổ ngữ cảnh",
616
+ "modelMaxTokens": "Token đầu ra tối đa",
606
617
  "fetchModels": "Tải model khả dụng",
607
618
  "fetching": "Đang hỏi nhà cung cấp…",
608
619
  "fetchNeedsBaseUrl": "Nhập base URL trước, rồi tải.",
@@ -614,6 +625,8 @@ window.__ModuleLoader__.load({
614
625
  "fetchSelectAll": "Chọn tất cả",
615
626
  "fetchDeselectAll": "Bỏ chọn tất cả",
616
627
  "fetchAdopt": "Thêm mục đã chọn",
628
+ "customAdd": "Thêm nhà cung cấp tuỳ chỉnh",
629
+ "customTitle": "Nhà cung cấp tuỳ chỉnh",
617
630
  "customTag": "Tuỳ chỉnh",
618
631
  "customRoute": "ID nhà cung cấp",
619
632
  "customRouteHint": "Định danh chữ thường, bắt đầu bằng chữ cái, đặt tên duy nhất cho nhà cung cấp này trong yêu cầu và làm tên thông tin xác thực.",
@@ -725,6 +738,7 @@ window.__ModuleLoader__.load({
725
738
  "search.pending": "Đang tìm trong lịch sử phiên…",
726
739
  "search.noMatches": "Không có phiên khớp",
727
740
  "search.hasMore": "Đang hiện {n} kết quả đầu. Hãy thu hẹp tìm kiếm.",
741
+ "search.unavailable": "Tìm kiếm nội dung tạm thời không khả dụng. Đang hiển thị kết quả theo tên.",
728
742
  "menu.addWorkspace": "Thêm workspace…",
729
743
  "picker.loading": "Đang tải workspace…",
730
744
  "conflict.named": "Đã tồn tại workspace tên “{name}”.",
@@ -790,6 +804,7 @@ window.__ModuleLoader__.load({
790
804
  "status.compact.planReview": "Duyệt kế hoạch",
791
805
  "status.compact.answer": "Trả lời",
792
806
  "status.completed": "Hoàn thành",
807
+ "schedule.active": "Có nhắc hẹn theo lịch đang hoạt động",
793
808
  "hover.created": "Tạo lúc {time}",
794
809
  "hover.copied": "Đã sao chép",
795
810
  "date.ymd": "{y}-{m}-{d}",
@@ -994,6 +1009,20 @@ window.__ModuleLoader__.load({
994
1009
  "message.turnTime.duration": "Tổng thời gian chạy",
995
1010
  "message.turnTime.speed": "Token mỗi giây (TPS)",
996
1011
  "message.turnTime.ttft": "Thời gian tới token đầu (TTFT)"
1012
+ },
1013
+ "gbh.sessions": {
1014
+ "action.delete": "Xoá phiên",
1015
+ "dialog.title": "Xoá phiên này?",
1016
+ "dialog.body": "Log của phiên và cache projection sẽ bị xoá khỏi DSH home. Không thể hoàn tác.",
1017
+ "dialog.trash": "Tệp được chuyển vào .trash/sessions trước, nên vẫn có thể khôi phục thủ công.",
1018
+ "dialog.cascade": "Phiên này có {count} phiên con. Xoá nó sẽ xoá luôn chúng.",
1019
+ "dialog.running": "Phiên đang chạy. Hãy dừng phiên trước khi xoá.",
1020
+ "dialog.cancel": "Huỷ",
1021
+ "dialog.confirm": "Xoá phiên",
1022
+ "dialog.confirmCascade": "Xoá {count} phiên",
1023
+ "dialog.busy": "Đang xoá…",
1024
+ "dialog.failed": "Không xoá được phiên.",
1025
+ "dialog.done": "Đã xoá phiên. Đang tải lại…"
997
1026
  }
998
1027
  };
999
1028
  const EN_OVERRIDES = {
@@ -1022,6 +1051,39 @@ window.__ModuleLoader__.load({
1022
1051
  });
1023
1052
  }
1024
1053
 
1054
+ /* The injected-context row prints its producer as a raw plugin id, so the
1055
+ reader sees "@deepseek-ai/dsh-system-prompt". Rename the harness
1056
+ producers to readable labels: "Chèn ngữ cảnh · System prompt". */
1057
+ const CONTEXT_SOURCE_ID = /^@deepseek-ai\/dsh-([a-z0-9-]+)$/i;
1058
+ function friendlyContextSource(raw) {
1059
+ var match = CONTEXT_SOURCE_ID.exec(raw);
1060
+ if (!match) return undefined;
1061
+ var words = match[1].split("-");
1062
+ for (var i = 0; i < words.length; i += 1) words[i] = words[i].charAt(0).toUpperCase() + words[i].slice(1);
1063
+ var label = words.join(" ");
1064
+ return label === "System Prompt" ? "System prompt" : label;
1065
+ }
1066
+ /** Rewrite every visible producer label; React re-renders are re-applied. */
1067
+ function relabelContextSources() {
1068
+ if (typeof document === "undefined") return;
1069
+ var nodes = document.querySelectorAll("[data-context-source]");
1070
+ for (var i = 0; i < nodes.length; i += 1) {
1071
+ var node = nodes[i];
1072
+ var label = friendlyContextSource((node.textContent || "").trim());
1073
+ if (label !== undefined && node.textContent !== label) node.textContent = label;
1074
+ }
1075
+ }
1076
+ function watchContextSources() {
1077
+ if (typeof document === "undefined" || typeof MutationObserver === "undefined") return;
1078
+ relabelContextSources();
1079
+ var scheduled = false;
1080
+ new MutationObserver(function () {
1081
+ if (scheduled) return;
1082
+ scheduled = true;
1083
+ Promise.resolve().then(function () { scheduled = false; relabelContextSources(); });
1084
+ }).observe(document.body, { childList: true, subtree: true, characterData: true });
1085
+ }
1086
+
1025
1087
  const GALAXY_KEY_REF = "GBH_GALAXY_API_KEY";
1026
1088
  /** Show a Galaxy-specific dialog when the Galaxy key is not configured. */
1027
1089
  function ensureGalaxyKey(ctx) {
@@ -1135,6 +1197,136 @@ window.__ModuleLoader__.load({
1135
1197
  style: { height: "28px", borderRadius: "14px", border: "1px solid var(--dsw-alias-border-l2, rgba(127,127,127,.35))", background: "transparent", color: "var(--dsw-alias-label-tertiary, inherit)", font: "inherit", fontSize: "12px", padding: "0 8px", cursor: "pointer" }
1136
1198
  }, options);
1137
1199
  }
1200
+ /** Locale namespace owned by the Galaxy session tools. */
1201
+ const GBH_SESSIONS_NS = "gbh.sessions";
1202
+ /** English dictionary for the session tools; Vietnamese lives in vi.locales.json. */
1203
+ const GBH_SESSIONS_EN = {
1204
+ "action.delete": "Delete session",
1205
+ "dialog.title": "Delete this session?",
1206
+ "dialog.body": "The session log and its projection cache are removed from the DSH home. This cannot be undone.",
1207
+ "dialog.trash": "Artifacts are moved to .trash/sessions first, so they can still be recovered by hand.",
1208
+ "dialog.cascade": "This session has {count} descendant session(s). Deleting it also deletes them.",
1209
+ "dialog.running": "This session is running. Stop it before deleting.",
1210
+ "dialog.cancel": "Cancel",
1211
+ "dialog.confirm": "Delete session",
1212
+ "dialog.confirmCascade": "Delete {count} sessions",
1213
+ "dialog.busy": "Deleting…",
1214
+ "dialog.failed": "Could not delete the session.",
1215
+ "dialog.done": "Session deleted. Reloading…"
1216
+ };
1217
+ /** Same-origin Host base with the connection carrier\u0027s null-origin fallback. */
1218
+ function gbhHostBase() {
1219
+ var origin = globalThis.location && globalThis.location.origin;
1220
+ return origin !== undefined && origin !== null && origin !== "null" ? origin : "http://dsh.internal";
1221
+ }
1222
+ /** Delete one session through the Galaxy host route; resolves to the parsed JSON body. */
1223
+ function gbhDeleteSession(sessionId, cascade) {
1224
+ return fetch(gbhHostBase() + "/api/galaxy/session.delete", {
1225
+ method: "POST",
1226
+ headers: { "content-type": "application/json" },
1227
+ credentials: "same-origin",
1228
+ body: JSON.stringify({ sessionId: sessionId, cascade: cascade === true, trash: true })
1229
+ }).then(function (response) {
1230
+ return response.json().then(function (body) { return body || {}; }, function () { return {}; });
1231
+ }).catch(function (error) { return { ok: false, code: "network", message: String(error) }; });
1232
+ }
1233
+ /** Modal confirmation built with plain DOM, matching the Galaxy key dialog style. */
1234
+ function gbhConfirmDeleteSession(sessionId, t, onFinished) {
1235
+ if (typeof document === "undefined") return;
1236
+ if (document.getElementById("gbh-delete-session-dialog")) return;
1237
+ var overlay = document.createElement("div");
1238
+ overlay.id = "gbh-delete-session-dialog";
1239
+ overlay.style.cssText = "position:fixed;inset:0;z-index:2147483647;background:rgba(0,0,0,.55);display:flex;align-items:center;justify-content:center;font-family:system-ui,-apple-system,Segoe UI,sans-serif";
1240
+ var card = document.createElement("div");
1241
+ card.style.cssText = "background:var(--dsw-alias-bg-module-platform,#1f1f24);color:var(--dsw-alias-label-primary,#f2f2f2);padding:22px;border-radius:14px;width:min(460px,92vw);box-shadow:0 18px 50px rgba(0,0,0,.45)";
1242
+ var title = document.createElement("div");
1243
+ title.textContent = t("dialog.title");
1244
+ title.style.cssText = "font-size:17px;font-weight:600;margin-bottom:8px";
1245
+ var body = document.createElement("div");
1246
+ body.textContent = t("dialog.body");
1247
+ body.style.cssText = "font-size:13px;line-height:20px;opacity:.82;margin-bottom:8px";
1248
+ var note = document.createElement("div");
1249
+ note.textContent = t("dialog.trash");
1250
+ note.style.cssText = "font-size:12px;line-height:18px;opacity:.62;margin-bottom:14px";
1251
+ var errorEl = document.createElement("div");
1252
+ errorEl.style.cssText = "color:#ff6b6b;font-size:12px;line-height:18px;min-height:16px;margin-bottom:10px";
1253
+ var actions = document.createElement("div");
1254
+ actions.style.cssText = "display:flex;justify-content:flex-end;gap:10px";
1255
+ var cancel = document.createElement("button");
1256
+ cancel.type = "button";
1257
+ cancel.textContent = t("dialog.cancel");
1258
+ cancel.style.cssText = "height:34px;padding:0 14px;border-radius:9px;border:1px solid rgba(127,127,127,.4);background:transparent;color:inherit;cursor:pointer";
1259
+ var confirm = document.createElement("button");
1260
+ confirm.type = "button";
1261
+ confirm.textContent = t("dialog.confirm");
1262
+ confirm.style.cssText = "height:34px;padding:0 16px;border-radius:9px;border:none;background:#e5484d;color:#fff;cursor:pointer;font-weight:600";
1263
+ cancel.onclick = function () { overlay.remove(); onFinished(); };
1264
+ confirm.onclick = function () { run(false); };
1265
+ function finish(body) {
1266
+ confirm.disabled = true;
1267
+ errorEl.style.color = "var(--dsw-alias-label-secondary,#9aa0a6)";
1268
+ errorEl.textContent = t("dialog.done");
1269
+ if (body && body.deleted && body.deleted.length > 0) {
1270
+ setTimeout(function () { try { location.reload(); } catch (e) { overlay.remove(); onFinished(); } }, 600);
1271
+ return;
1272
+ }
1273
+ overlay.remove();
1274
+ onFinished();
1275
+ }
1276
+ function run(cascade) {
1277
+ confirm.disabled = true;
1278
+ cancel.disabled = true;
1279
+ errorEl.style.color = "var(--dsw-alias-label-secondary,#9aa0a6)";
1280
+ errorEl.textContent = t("dialog.busy");
1281
+ gbhDeleteSession(sessionId, cascade).then(function (body) {
1282
+ if (body && body.ok === true) { finish(body); return; }
1283
+ var code = body && body.code ? body.code : "error";
1284
+ confirm.disabled = false;
1285
+ cancel.disabled = false;
1286
+ errorEl.style.color = "#ff6b6b";
1287
+ if (code === "session/has-children") {
1288
+ var count = body && body.children ? body.children.length : 0;
1289
+ note.textContent = t("dialog.cascade").split("{count}").join(String(count));
1290
+ confirm.textContent = t("dialog.confirmCascade").split("{count}").join(String(count));
1291
+ confirm.onclick = function () { run(true); };
1292
+ errorEl.textContent = "";
1293
+ return;
1294
+ }
1295
+ if (code === "session/running") { errorEl.textContent = t("dialog.running"); return; }
1296
+ errorEl.textContent = (body && body.message) || t("dialog.failed");
1297
+ });
1298
+ }
1299
+ actions.append(cancel, confirm);
1300
+ card.append(title, body, note, errorEl, actions);
1301
+ overlay.append(card);
1302
+ document.body.append(overlay);
1303
+ setTimeout(function () { try { confirm.focus(); } catch (e) { /* ignore */ } }, 30);
1304
+ }
1305
+ /** Trash button seated in the Session header utilities list. */
1306
+ function GbhDeleteSessionAction(props) {
1307
+ var sessionId = props.sessionId;
1308
+ if (typeof sessionId !== "string" || sessionId.length === 0) return null;
1309
+ var busyState = react.useState(false);
1310
+ var busy = busyState[0];
1311
+ var setBusy = busyState[1];
1312
+ var t = props.t;
1313
+ var label = t("action.delete");
1314
+ var icon = null;
1315
+ try { icon = primitives && primitives.IconTrashOutline16 ? react_jsx_runtime.jsx(primitives.IconTrashOutline16, {}) : null; } catch (e) { icon = null; }
1316
+ return react_jsx_runtime.jsx("button", {
1317
+ type: "button",
1318
+ title: label,
1319
+ "aria-label": label,
1320
+ disabled: busy,
1321
+ onClick: function () {
1322
+ if (busy) return;
1323
+ setBusy(true);
1324
+ gbhConfirmDeleteSession(sessionId, t, function () { setBusy(false); });
1325
+ },
1326
+ style: { display: "inline-flex", alignItems: "center", justifyContent: "center", width: "28px", height: "28px", borderRadius: "8px", border: "1px solid var(--dsw-alias-border-l2, rgba(127,127,127,.35))", background: "transparent", color: "var(--dsw-alias-label-tertiary, inherit)", cursor: busy ? "default" : "pointer", padding: "0" },
1327
+ children: icon === null ? label : icon
1328
+ });
1329
+ }
1138
1330
  const inject = ["slots", "locale", "remote", "remote.credentials", "modelDirectories", "sessions"];
1139
1331
  function apply(ctx) {
1140
1332
  ctx.slots.inject("sidebar.brand.mark", () => ctx.slots.inject("sidebar.brand.name", function* () {
@@ -1142,6 +1334,16 @@ window.__ModuleLoader__.load({
1142
1334
  yield ctx.slots.register({ name: "sidebar.brand.name" }, GbhBrandName);
1143
1335
  }));
1144
1336
  ctx.slots.inject("conversation.hero.brand.mark", () => ctx.slots.register({ name: "conversation.hero.brand.mark" }, GbhBrandMark));
1337
+ /* Session tools: delete the open session through the Galaxy Host route. */
1338
+ ctx.slots.inject("conversation.session.header.utilities", function () {
1339
+ return ctx.slots.register({
1340
+ name: "conversation.session.header.utilities",
1341
+ id: "gbh-session-delete",
1342
+ order: 50,
1343
+ locale: GBH_SESSIONS_NS,
1344
+ inject: function () { return {}; }
1345
+ }, GbhDeleteSessionAction);
1346
+ });
1145
1347
  try {
1146
1348
  ctx.locale.addLanguage({ id: "vi", label: "Tiếng Việt", fallback: "en" });
1147
1349
  } catch (error) {
@@ -1150,12 +1352,19 @@ window.__ModuleLoader__.load({
1150
1352
  const namespaces = Object.keys(VI_LOCALES);
1151
1353
  for (let i = 0; i < namespaces.length; i += 1) {
1152
1354
  const ns = namespaces[i];
1355
+ /* The session tools namespace registers both dictionaries in one call below. */
1356
+ if (ns === GBH_SESSIONS_NS) continue;
1153
1357
  try {
1154
1358
  ctx.locale.register(ns, "vi", VI_LOCALES[ns]);
1155
1359
  } catch (error) {
1156
1360
  /* a namespace may already carry vi on a reload */
1157
1361
  }
1158
1362
  }
1363
+ try {
1364
+ ctx.locale.register(GBH_SESSIONS_NS, { en: GBH_SESSIONS_EN, vi: VI_LOCALES[GBH_SESSIONS_NS] });
1365
+ } catch (error) {
1366
+ /* the namespace may already be registered on a plugin reload */
1367
+ }
1159
1368
  /* Replace the shipped internal-testing notice with the Galaxy description,
1160
1369
  including the English copy, by editing the registered dictionaries. */
1161
1370
  try {
@@ -1197,6 +1406,7 @@ window.__ModuleLoader__.load({
1197
1406
  });
1198
1407
  });
1199
1408
  ensureGalaxyKey(ctx);
1409
+ watchContextSources();
1200
1410
  }
1201
1411
  exports.apply = apply;
1202
1412
  exports.inject = inject;
@@ -0,0 +1,3 @@
1
+ /** Types for the gbh brand plugin host half (see index.js). */
2
+ export declare const inject: string[];
3
+ export declare function apply(ctx: unknown): void;
@@ -1,5 +1,16 @@
1
1
  //#region node half
2
+ import { readFileSync } from "node:fs";
2
3
  import { FAVICON_DATA_URI } from "./favicon.js";
4
+ import {
5
+ deleteSession,
6
+ findSessionDirectories,
7
+ formatBytes,
8
+ isSessionId,
9
+ listStoredSessions,
10
+ projectionCachePath,
11
+ resolveHome,
12
+ sweepTombstones,
13
+ } from "./session-store.js";
3
14
 
4
15
  /**
5
16
  * Host half of the gbh brand plugin: rewords the fixed harness:identity
@@ -114,6 +125,196 @@ function createGalaxySearchProvider() {
114
125
  };
115
126
  }
116
127
 
128
+ //#region session maintenance
129
+ /** Browser routes owned by the Galaxy session tools. */
130
+ const SESSIONS_PATH = "/api/galaxy/sessions";
131
+ const SESSION_DELETE_PATH = "/api/galaxy/session.delete";
132
+
133
+ function jsonResponse(body, status = 200) {
134
+ return new Response(JSON.stringify(body), {
135
+ status,
136
+ headers: { "content-type": "application/json; charset=utf-8", "cache-control": "no-store" },
137
+ });
138
+ }
139
+
140
+ /** Read the durable title the sidebar projects for one session, when it exists. */
141
+ function sessionTitleFromCache(home, sessionId) {
142
+ try {
143
+ const raw = readFileSync(projectionCachePath(home, sessionId), "utf8");
144
+ const parsed = JSON.parse(raw);
145
+ const title = parsed?.record?.rows?.title?.val;
146
+ return typeof title === "string" && title.length > 0 ? title : undefined;
147
+ } catch {
148
+ return undefined;
149
+ }
150
+ }
151
+
152
+ /** The Host's own running predicate, shared with the Session list projection. */
153
+ function sessionIsRunning(ctx, sessionId) {
154
+ try {
155
+ const agents = ctx.get("agents");
156
+ return agents?.get?.(sessionId)?.status === "running";
157
+ } catch {
158
+ return false;
159
+ }
160
+ }
161
+
162
+ /** Whether this DSH process currently holds the Session attached. */
163
+ function sessionIsAttached(ctx, sessionId) {
164
+ try {
165
+ const sessions = ctx.get("sessions");
166
+ return sessions?.get?.(sessionId) !== undefined;
167
+ } catch {
168
+ return false;
169
+ }
170
+ }
171
+
172
+ /** Cached persistence listing; a provider fault degrades to an empty listing. */
173
+ async function storedSnapshots(ctx) {
174
+ try {
175
+ const persistence = ctx.get("sessionPersistence");
176
+ if (persistence === undefined) return [];
177
+ const snapshots = await persistence.list();
178
+ return Array.isArray(snapshots) ? snapshots : [];
179
+ } catch {
180
+ return [];
181
+ }
182
+ }
183
+
184
+ function headerOf(snapshot) {
185
+ return snapshot && typeof snapshot === "object" ? snapshot.header : undefined;
186
+ }
187
+
188
+ /** Join the artifact inventory with the Host's session facts. */
189
+ async function sessionInventory(ctx, home) {
190
+ const snapshots = await storedSnapshots(ctx);
191
+ const known = new Map();
192
+ for (const snapshot of snapshots) {
193
+ const header = headerOf(snapshot);
194
+ if (header === undefined || typeof header.id !== "string") continue;
195
+ known.set(header.id, {
196
+ cwd: typeof header.cwd === "string" ? header.cwd : undefined,
197
+ parentId: typeof header.parentSession === "string" ? header.parentSession : undefined,
198
+ });
199
+ }
200
+ const rows = [];
201
+ for (const stored of listStoredSessions(home)) {
202
+ const facts = known.get(stored.id);
203
+ rows.push({
204
+ id: stored.id,
205
+ bytes: stored.bytes,
206
+ size: formatBytes(stored.bytes),
207
+ updatedAt: stored.updatedAt,
208
+ title: sessionTitleFromCache(home, stored.id),
209
+ cwd: facts?.cwd,
210
+ parentId: facts?.parentId,
211
+ running: sessionIsRunning(ctx, stored.id),
212
+ attached: sessionIsAttached(ctx, stored.id),
213
+ });
214
+ }
215
+ return { home, sessions: rows };
216
+ }
217
+
218
+ /** Delete one stored session after the guards the UI relies on. */
219
+ async function removeStoredSession(ctx, home, sessionId, options = {}) {
220
+ if (!isSessionId(sessionId)) {
221
+ return { status: 400, body: { ok: false, code: "invalid-request", message: "Invalid session id." } };
222
+ }
223
+ const snapshots = await storedSnapshots(ctx);
224
+ const known = new Set();
225
+ const children = [];
226
+ for (const snapshot of snapshots) {
227
+ const header = headerOf(snapshot);
228
+ if (header === undefined || typeof header.id !== "string") continue;
229
+ known.add(header.id);
230
+ if (header.parentSession === sessionId) children.push(header.id);
231
+ }
232
+ if (!known.has(sessionId) && findSessionDirectories(home, sessionId).length === 0) {
233
+ return { status: 404, body: { ok: false, code: "session/not-found", message: "Session " + sessionId + " does not exist." } };
234
+ }
235
+ if (sessionIsRunning(ctx, sessionId)) {
236
+ return {
237
+ status: 409,
238
+ body: { ok: false, code: "session/running", message: "Session " + sessionId + " is running; stop it before deleting." },
239
+ };
240
+ }
241
+ if (children.length > 0 && options.cascade !== true) {
242
+ return {
243
+ status: 409,
244
+ body: {
245
+ ok: false,
246
+ code: "session/has-children",
247
+ message: "Session " + sessionId + " has " + children.length + " descendant session(s).",
248
+ children,
249
+ },
250
+ };
251
+ }
252
+ const removed = [];
253
+ try {
254
+ const targets = options.cascade === true && children.length > 0 ? [...children, sessionId] : [sessionId];
255
+ for (const target of targets) {
256
+ const result = deleteSession(home, target, { trash: options.trash !== false });
257
+ removed.push({ id: target, bytes: result.bytes, trashedTo: result.trashedTo, projectionCache: result.projectionCache });
258
+ }
259
+ } catch (error) {
260
+ return {
261
+ status: 500,
262
+ body: { ok: false, code: "session/delete-failed", message: error instanceof Error ? error.message : String(error) },
263
+ };
264
+ }
265
+ return { status: 200, body: { ok: true, deleted: removed, cascaded: options.cascade === true ? children : [] } };
266
+ }
267
+
268
+ /**
269
+ * Register the Galaxy session routes on the Host connection carrier.
270
+ *
271
+ * @param ctx - plugin context, used to reach the Session services lazily per request.
272
+ * @param connectionCtx - the injected connection scope that owns route registration.
273
+ */
274
+ function registerSessionRoutes(ctx, connectionCtx) {
275
+ const home = resolveHome();
276
+ try {
277
+ const swept = sweepTombstones(home);
278
+ if (swept.resurrected.length > 0) {
279
+ console.log("gbh: removed " + swept.resurrected.length + " session artifact(s) a live runtime re-created: " + swept.resurrected.join(", "));
280
+ }
281
+ } catch (error) {
282
+ console.warn("gbh: session tombstone sweep failed: " + (error instanceof Error ? error.message : String(error)));
283
+ }
284
+ connectionCtx.connection.fetch.register({
285
+ path: SESSIONS_PATH,
286
+ methods: ["GET", "HEAD"],
287
+ requestBody: "buffered",
288
+ fetch: async (request) => {
289
+ const inventory = await sessionInventory(ctx, home);
290
+ const response = jsonResponse(inventory);
291
+ if (request.method === "GET") return response;
292
+ await response.body?.cancel();
293
+ return new Response(null, { status: response.status, headers: response.headers });
294
+ },
295
+ });
296
+ connectionCtx.connection.fetch.register({
297
+ path: SESSION_DELETE_PATH,
298
+ methods: ["POST"],
299
+ requestBody: "buffered",
300
+ fetch: async (request) => {
301
+ let payload;
302
+ try {
303
+ payload = await request.json();
304
+ } catch {
305
+ return jsonResponse({ ok: false, code: "invalid-request", message: "Expected a JSON body." }, 400);
306
+ }
307
+ const sessionId = payload && typeof payload.sessionId === "string" ? payload.sessionId : "";
308
+ const result = await removeStoredSession(ctx, home, sessionId, {
309
+ cascade: payload?.cascade === true,
310
+ trash: payload?.trash !== false,
311
+ });
312
+ return jsonResponse(result.body, result.status);
313
+ },
314
+ });
315
+ }
316
+ //#endregion
317
+
117
318
  /** The system-prompt registry owns the section this plugin rewrites. */
118
319
  export const inject = ["systemPrompt"];
119
320
 
@@ -129,6 +330,7 @@ function apply(ctx) {
129
330
  return next();
130
331
  });
131
332
  ctx.inject(["web"], (webCtx) => webCtx.web.registerSearchProvider(createGalaxySearchProvider()));
333
+ ctx.inject(["connection"], (connectionCtx) => registerSessionRoutes(ctx, connectionCtx));
132
334
  ctx.inject(["webServer"], (hostCtx) => {
133
335
  hostCtx.on("webserver/index-inject", (table) => {
134
336
  table.push({ kind: "script", placement: "body", text: FAVICON_SCRIPT });
@@ -0,0 +1,54 @@
1
+ /** Types for the gbh session-store maintenance module (see session-store.js). */
2
+
3
+ /** One stored session artifact found under `<home>/sessions`. */
4
+ export interface StoredSessionRow {
5
+ id: string;
6
+ directory: string;
7
+ cwdSlug: string;
8
+ bytes: number;
9
+ updatedAt: number;
10
+ }
11
+
12
+ /** Outcome of one delete. */
13
+ export interface SessionDeleteResult {
14
+ id: string;
15
+ bytes: number;
16
+ directories: string[];
17
+ projectionCache: boolean;
18
+ trashedTo?: string;
19
+ }
20
+
21
+ /** One deleted-session tombstone. */
22
+ export interface SessionTombstone {
23
+ id: string;
24
+ deletedAt: string;
25
+ }
26
+
27
+ /** Outcome of a tombstone sweep. */
28
+ export interface TombstoneSweepReport {
29
+ resurrected: string[];
30
+ pruned: string[];
31
+ kept: number;
32
+ }
33
+
34
+ export declare const DELETED_INDEX_NAME: string;
35
+ export declare function resolveHome(explicit?: string): string;
36
+ export declare function sessionsRoot(home: string): string;
37
+ export declare function projectionCachePath(home: string, sessionId: string): string;
38
+ export declare function deletedIndexPath(home: string): string;
39
+ export declare function trashRoot(home: string): string;
40
+ export declare function isSessionId(value: unknown): value is string;
41
+ export declare function findSessionDirectories(home: string, sessionId: string): string[];
42
+ export declare function listStoredSessions(home: string): StoredSessionRow[];
43
+ export declare function readTombstones(home: string): SessionTombstone[];
44
+ export declare function recordTombstone(home: string, sessionId: string, deletedAt?: string): number;
45
+ export declare function deleteSession(
46
+ home: string,
47
+ sessionId: string,
48
+ options?: { trash?: boolean; now?: Date },
49
+ ): SessionDeleteResult;
50
+ export declare function sweepTombstones(
51
+ home: string,
52
+ options?: { maxAgeDays?: number; now?: Date },
53
+ ): TombstoneSweepReport;
54
+ export declare function formatBytes(bytes: number): string;