@galaxy-stack/blackhole-cli 2.0.2 → 2.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.
Files changed (58) hide show
  1. package/dist/cli.js +24 -0
  2. package/dist/cli.js.map +1 -1
  3. package/dist/commands.d.ts.map +1 -1
  4. package/dist/commands.js +2 -0
  5. package/dist/commands.js.map +1 -1
  6. package/dist/config-command.d.ts +35 -0
  7. package/dist/config-command.d.ts.map +1 -0
  8. package/dist/config-command.js +273 -0
  9. package/dist/config-command.js.map +1 -0
  10. package/dist/info.d.ts +21 -0
  11. package/dist/info.d.ts.map +1 -0
  12. package/dist/info.js +33 -0
  13. package/dist/info.js.map +1 -0
  14. package/dist/logs.d.ts.map +1 -1
  15. package/dist/logs.js +10 -2
  16. package/dist/logs.js.map +1 -1
  17. package/dist/manual-config.d.ts +17 -0
  18. package/dist/manual-config.d.ts.map +1 -1
  19. package/dist/manual-config.js +35 -0
  20. package/dist/manual-config.js.map +1 -1
  21. package/dist/options.d.ts +2 -2
  22. package/dist/options.d.ts.map +1 -1
  23. package/dist/options.js +5 -1
  24. package/dist/options.js.map +1 -1
  25. package/dist/tui.d.ts.map +1 -1
  26. package/dist/tui.js +39 -1
  27. package/dist/tui.js.map +1 -1
  28. package/dist/update.d.ts +45 -0
  29. package/dist/update.d.ts.map +1 -0
  30. package/dist/update.js +158 -0
  31. package/dist/update.js.map +1 -0
  32. package/dist/web/web.d.ts.map +1 -1
  33. package/dist/web/web.js +16 -5
  34. package/dist/web/web.js.map +1 -1
  35. package/package.json +3 -2
  36. package/skills/galaxy-ui/SKILL.md +18 -0
  37. package/skills/orbit-framework/SKILL.md +18 -0
  38. package/web/brand/app-icon-192.png +0 -0
  39. package/web/brand/app-icon-512.png +0 -0
  40. package/web/brand/client.template.js +581 -79
  41. package/web/brand/dsh-locale-keys.json +2020 -0
  42. package/web/brand/favicon.png +0 -0
  43. package/web/brand/favicon.svg +12 -0
  44. package/web/brand/lib/app-icons.js +3 -0
  45. package/web/brand/lib/client.js +2303 -88
  46. package/web/brand/lib/favicon.js +1 -1
  47. package/web/brand/lib/index.js +618 -18
  48. package/web/brand/lib/journey-host.js +282 -0
  49. package/web/brand/lib/journey-run.d.ts +66 -0
  50. package/web/brand/lib/journey-run.js +315 -0
  51. package/web/brand/lib/journey-store.d.ts +61 -0
  52. package/web/brand/lib/journey-store.js +177 -0
  53. package/web/brand/logo.png +0 -0
  54. package/web/brand/logo.svg +20 -0
  55. package/web/brand/panel/journey-panel.js +884 -0
  56. package/web/brand/vi.locales.json +838 -8
  57. package/web/brand/zalo.jpg +0 -0
  58. package/web/patches/gbh-web.patch.yml +51 -2
@@ -141,56 +141,15 @@ window.__ModuleLoader__.load({
141
141
  document.body.append(overlay);
142
142
  setTimeout(function () { try { input.focus(); } catch (error) { /* ignore */ } }, 30);
143
143
  }
144
- /**
145
- * A reasoning-effort control seated before the composer submit action. The
146
- * effort list comes from the current model route, so it differs per system.
147
- */
148
- function GbhThinkingControl(props) {
149
- var store = props.directory;
150
- var state = react.useSyncExternalStore(function (fn) { return store.subscribe(fn); }, function () { return store.getSnapshot(); });
151
- react.useEffect(function () { try { props.load(); } catch (error) { /* ignore */ } }, []);
152
- var current = state.current;
153
- if (!current) return null;
154
- var choice = null;
155
- for (var i = 0; i < state.groups.length && choice === null; i += 1) {
156
- var group = state.groups[i];
157
- for (var j = 0; j < group.models.length; j += 1) {
158
- if (group.id === current.provider && group.models[j].id === current.model) { choice = { group: group, model: group.models[j] }; break; }
159
- }
160
- }
161
- var reasoning = choice === null ? undefined : choice.model.reasoning;
162
- if (!reasoning || !reasoning.efforts || reasoning.efforts.length === 0) return null;
163
- var vi = false;
164
- try { vi = props.localeActive === "vi"; } catch (error) { /* default en */ }
165
- var label = vi ? "Suy nghĩ" : "Thinking";
166
- var effective = current.reasoningEffort !== undefined ? current.reasoningEffort : reasoning.defaultEffort;
167
- var options = [];
168
- if (reasoning.defaultEffort === undefined) options.push(react_jsx_runtime.jsx("option", { value: "", key: "default" }, vi ? "Mặc định" : "Default"));
169
- for (var k = 0; k < reasoning.efforts.length; k += 1) {
170
- options.push(react_jsx_runtime.jsx("option", { value: reasoning.efforts[k].id, key: reasoning.efforts[k].id }, reasoning.efforts[k].name));
171
- }
172
- return react_jsx_runtime.jsx("select", {
173
- value: effective === undefined ? "" : effective,
174
- title: label,
175
- "aria-label": label,
176
- disabled: props.available === false,
177
- onChange: function (event) {
178
- var value = event.target.value;
179
- var selection = { provider: current.provider, model: current.model };
180
- if (value !== "") selection.reasoningEffort = value;
181
- props.select(selection);
182
- },
183
- 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" }
184
- }, options);
185
- }
186
144
  /** Locale namespace owned by the Galaxy session tools. */
187
145
  const GBH_SESSIONS_NS = "gbh.sessions";
188
146
  /** English dictionary for the session tools; Vietnamese lives in vi.locales.json. */
189
147
  const GBH_SESSIONS_EN = {
190
148
  "action.delete": "Delete session",
149
+ "menu.delete": "Delete session",
191
150
  "dialog.title": "Delete this session?",
192
151
  "dialog.body": "The session log and its projection cache are removed from the DSH home. This cannot be undone.",
193
- "dialog.trash": "Artifacts are moved to .trash/sessions first, so they can still be recovered by hand.",
152
+ "dialog.trash": "Artifacts are moved to .trash/sessions first, so they can still be recovered by hand. A session the GUI still holds open is also archived, which removes its row.",
194
153
  "dialog.cascade": "This session has {count} descendant session(s). Deleting it also deletes them.",
195
154
  "dialog.running": "This session is running. Stop it before deleting.",
196
155
  "dialog.cancel": "Cancel",
@@ -198,8 +157,62 @@ window.__ModuleLoader__.load({
198
157
  "dialog.confirmCascade": "Delete {count} sessions",
199
158
  "dialog.busy": "Deleting…",
200
159
  "dialog.failed": "Could not delete the session.",
201
- "dialog.done": "Session deleted. Reloading…"
160
+ "dialog.done": "Session deleted.",
161
+ "dialog.alreadyDeleted": "This session was already deleted. Its row has now been cleaned up.",
162
+ "dialog.unknown": "This session left no trace in the DSH home; the list has been cleaned up.",
163
+ "turnError.hint": "This conversation outgrew what the route really serves (~655k prompt tokens with tools and images), so the provider refuses every request that carries it — including /compact. Fork an earlier turn (branch icon) or open a new session to get back under the limit."
202
164
  };
165
+ /** Provider failure codes whose only way out is changing the request itself. */
166
+ const GBH_STUCK_CODES = { SERVER: 1, TRANSPORT: 1, TIMEOUT: 1, RATE_LIMIT: 1, EMPTY_RESPONSE: 1 };
167
+ /**
168
+ * Point at the way out when the provider refuses a turn.
169
+ *
170
+ * DSH renders a terminal turn failure with no next step, and re-sending the exact
171
+ * prompt is what keeps failing (measured 2026-09-29: the same conversation was
172
+ * still refused 2 and 20 minutes later, while every other conversation worked, and
173
+ * the route itself served 1M-token prompts). Both escapes change the request: a
174
+ * compaction replaces the history with a summary, and a fork from an earlier turn
175
+ * starts from a smaller prefix.
176
+ */
177
+ function gbhAnnotateTurnErrors(sessionsT) {
178
+ var rows = document.querySelectorAll("[class*=turnErrorRow]");
179
+ var limit = Math.min(rows.length, 20);
180
+ for (var i = 0; i < limit; i += 1) {
181
+ var row = rows[i];
182
+ /* React may re-render the row and drop the node, so probe the hint, not a flag. */
183
+ if (row.querySelector("[data-gbh-turn-hint]") !== null) continue;
184
+ var code = row.querySelector("[class*=turnErrorCode]");
185
+ var label = code === null ? "" : (code.textContent || "").trim();
186
+ if (GBH_STUCK_CODES[label] !== 1) continue;
187
+ var hint = document.createElement("div");
188
+ hint.setAttribute("data-gbh-turn-hint", "1");
189
+ hint.textContent = sessionsT("turnError.hint");
190
+ /* The row is a 10px | copy | code grid, so the hint spans the copy column below. */
191
+ hint.style.cssText = "grid-column:2/-1;margin-top:2px;color:var(--dsw-alias-label-tertiary,inherit);font-size:12px;line-height:18px";
192
+ row.append(hint);
193
+ }
194
+ }
195
+ /** Success wording that reports what the route actually did. */
196
+ function gbhDeleteOutcomeText(body, t) {
197
+ if (body && body.found === false) return t("dialog.unknown");
198
+ if (body && body.alreadyDeleted === true) return t("dialog.alreadyDeleted");
199
+ return t("dialog.done");
200
+ }
201
+ /**
202
+ * Put the sidebar back in sync after a delete.
203
+ *
204
+ * A Session this DSH process still holds attached cannot be unlinked out of every
205
+ * list on its own: the Host hides it through the archive set, which arrives as a
206
+ * workspace frame. The list refresh covers the cold case (the row's summary is
207
+ * gone with its projection cache), and only the open Session needs a reload.
208
+ */
209
+ function gbhAfterDelete(sessionId) {
210
+ try {
211
+ var current = gbhCtx !== undefined && gbhCtx.sessions !== undefined ? gbhCtx.sessions.list.getSnapshot().current : undefined;
212
+ if (current === sessionId) { location.reload(); return; }
213
+ if (gbhCtx !== undefined && gbhCtx.sessions !== undefined) gbhCtx.sessions.refresh();
214
+ } catch (error) { /* the list refresh is best effort */ }
215
+ }
203
216
  /** Same-origin Host base with the connection carrier\u0027s null-origin fallback. */
204
217
  function gbhHostBase() {
205
218
  var origin = globalThis.location && globalThis.location.origin;
@@ -217,7 +230,7 @@ window.__ModuleLoader__.load({
217
230
  }).catch(function (error) { return { ok: false, code: "network", message: String(error) }; });
218
231
  }
219
232
  /** Modal confirmation built with plain DOM, matching the Galaxy key dialog style. */
220
- function gbhConfirmDeleteSession(sessionId, t, onFinished) {
233
+ function gbhConfirmDeleteSession(sessionId, t, onFinished, onDeleted) {
221
234
  if (typeof document === "undefined") return;
222
235
  if (document.getElementById("gbh-delete-session-dialog")) return;
223
236
  var overlay = document.createElement("div");
@@ -251,7 +264,13 @@ window.__ModuleLoader__.load({
251
264
  function finish(body) {
252
265
  confirm.disabled = true;
253
266
  errorEl.style.color = "var(--dsw-alias-label-secondary,#9aa0a6)";
254
- errorEl.textContent = t("dialog.done");
267
+ /* An id whose artifacts are already gone is a success, not a dead end. */
268
+ errorEl.textContent = gbhDeleteOutcomeText(body, t);
269
+ if (typeof onDeleted === "function") {
270
+ onDeleted(body);
271
+ setTimeout(function () { overlay.remove(); onFinished(); }, 500);
272
+ return;
273
+ }
255
274
  if (body && body.deleted && body.deleted.length > 0) {
256
275
  setTimeout(function () { try { location.reload(); } catch (e) { overlay.remove(); onFinished(); } }, 600);
257
276
  return;
@@ -297,8 +316,7 @@ window.__ModuleLoader__.load({
297
316
  var setBusy = busyState[1];
298
317
  var t = props.t;
299
318
  var label = t("action.delete");
300
- var icon = null;
301
- try { icon = primitives && primitives.IconTrashOutline16 ? react_jsx_runtime.jsx(primitives.IconTrashOutline16, {}) : null; } catch (e) { icon = null; }
319
+ var icon = react_jsx_runtime.jsx("span", { style: { display: "inline-flex" }, dangerouslySetInnerHTML: { __html: GBH_TRASH_SVG } });
302
320
  return react_jsx_runtime.jsx("button", {
303
321
  type: "button",
304
322
  title: label,
@@ -307,13 +325,436 @@ window.__ModuleLoader__.load({
307
325
  onClick: function () {
308
326
  if (busy) return;
309
327
  setBusy(true);
310
- gbhConfirmDeleteSession(sessionId, t, function () { setBusy(false); });
328
+ /* The header action owns the open Session, so it always re-syncs the list. */
329
+ gbhConfirmDeleteSession(sessionId, t, function () { setBusy(false); }, function () { gbhAfterDelete(sessionId); });
311
330
  },
312
331
  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" },
313
332
  children: icon === null ? label : icon
314
333
  });
315
334
  }
316
- const inject = ["slots", "locale", "remote", "remote.credentials", "modelDirectories", "sessions"];
335
+ /** Locale namespace owned by the Galaxy journey panel. */
336
+ const GBH_JOURNEY_NS = "gbh.journey";
337
+ /** English dictionary for the journey panel; Vietnamese lives in vi.locales.json. */
338
+ const GBH_JOURNEY_EN = {
339
+ "view.journey": "Journey",
340
+ "toolbar.path": "no blueprint yet",
341
+ "toolbar.save": "Save",
342
+ "toolbar.reload": "Reload",
343
+ "toolbar.undo": "Undo",
344
+ "toolbar.redo": "Redo",
345
+ "toolbar.zoomIn": "Zoom in",
346
+ "toolbar.zoomOut": "Zoom out",
347
+ "toolbar.fit": "Fit",
348
+ "toolbar.layout": "Auto layout",
349
+ "node.outPort": "Drag to connect",
350
+ "node.inPort": "Drop a connection here",
351
+ "inspector.empty": "Select a node or an edge to edit it.",
352
+ "inspector.node": "Node",
353
+ "inspector.edge": "Edge",
354
+ "inspector.id": "Id",
355
+ "inspector.label": "Label",
356
+ "inspector.kind": "Kind",
357
+ "inspector.workflow": "Workflow",
358
+ "inspector.actions": "Actions (JSON)",
359
+ "inspector.deleteNode": "Delete node",
360
+ "inspector.from": "From",
361
+ "inspector.to": "To",
362
+ "inspector.when": "Condition",
363
+ "inspector.deleteEdge": "Delete edge",
364
+ "status.loading": "Loading the blueprint…",
365
+ "status.loadFailed": "Could not load the blueprint.",
366
+ "status.loaded": "Blueprint loaded.",
367
+ "status.newBlueprint": "No journey.json yet — this is the starting template.",
368
+ "status.saving": "Saving…",
369
+ "status.saved": "Saved.",
370
+ "status.saveFailed": "Could not save the blueprint.",
371
+ "status.conflict": "The blueprint changed elsewhere.",
372
+ "conflict.banner": "The agent (or another window) changed this blueprint.",
373
+ "conflict.reload": "Load theirs",
374
+ "toolbar.diagram": "Diagram",
375
+ "toolbar.spec": "Spec",
376
+ "run.start": "Run",
377
+ "run.advance": "Continue",
378
+ "run.cancel": "Stop",
379
+ "run.status": "Run",
380
+ "run.working": "Driving the run…",
381
+ "run.failed": "The run call failed.",
382
+ "run.waiting": "Waiting",
383
+ "run.approve": "Approve",
384
+ "run.reject": "Reject",
385
+ "run.retry": "Retry",
386
+ "spec.hint": "The same document as JSON — edits here are the edits the agent makes.",
387
+ "spec.apply": "Apply",
388
+ "spec.reset": "Reset",
389
+ "spec.notObject": "The spec must be a JSON object.",
390
+ "spec.applied": "Spec applied to the canvas.",
391
+ "status.reloaded": "Blueprint reloaded (changed elsewhere).",
392
+ };
393
+ /** Readable fallback so the panel stays usable before the locale service binds. */
394
+ const GBH_JOURNEY_VI = {
395
+ "view.journey": "Hành trình",
396
+ "toolbar.path": "chưa có blueprint",
397
+ "toolbar.save": "Lưu",
398
+ "toolbar.reload": "Tải lại",
399
+ "toolbar.undo": "Hoàn tác",
400
+ "toolbar.redo": "Làm lại",
401
+ "toolbar.zoomIn": "Phóng to",
402
+ "toolbar.zoomOut": "Thu nhỏ",
403
+ "toolbar.fit": "Vừa khung",
404
+ "toolbar.layout": "Tự xếp",
405
+ "node.outPort": "Kéo để nối",
406
+ "node.inPort": "Thả kết nối vào đây",
407
+ "inspector.empty": "Chọn một node hoặc edge để sửa.",
408
+ "inspector.node": "Node",
409
+ "inspector.edge": "Edge",
410
+ "inspector.id": "Id",
411
+ "inspector.label": "Nhãn",
412
+ "inspector.kind": "Loại",
413
+ "inspector.workflow": "Workflow",
414
+ "inspector.actions": "Hành động (JSON)",
415
+ "inspector.deleteNode": "Xoá node",
416
+ "inspector.from": "Từ",
417
+ "inspector.to": "Đến",
418
+ "inspector.when": "Điều kiện",
419
+ "inspector.deleteEdge": "Xoá edge",
420
+ "status.loading": "Đang tải blueprint…",
421
+ "status.loadFailed": "Không tải được blueprint.",
422
+ "status.loaded": "Đã tải blueprint.",
423
+ "status.newBlueprint": "Chưa có journey.json — đây là mẫu khởi đầu.",
424
+ "status.saving": "Đang lưu…",
425
+ "status.saved": "Đã lưu.",
426
+ "status.saveFailed": "Không lưu được blueprint.",
427
+ "status.conflict": "Blueprint đã bị sửa ở nơi khác.",
428
+ "conflict.banner": "Agent (hoặc cửa sổ khác) vừa sửa blueprint này.",
429
+ "conflict.reload": "Tải bản của họ",
430
+ "toolbar.diagram": "Sơ đồ",
431
+ "toolbar.spec": "Đặc tả",
432
+ "run.start": "Chạy",
433
+ "run.advance": "Chạy tiếp",
434
+ "run.cancel": "Dừng",
435
+ "run.status": "Run",
436
+ "run.working": "Đang chạy hành trình…",
437
+ "run.failed": "Gọi chạy hành trình thất bại.",
438
+ "run.waiting": "Đang chờ",
439
+ "run.approve": "Duyệt",
440
+ "run.reject": "Từ chối",
441
+ "run.retry": "Chạy lại",
442
+ "spec.hint": "Cùng một document ở dạng JSON — sửa ở đây chính là sửa như agent sửa.",
443
+ "spec.apply": "Áp dụng",
444
+ "spec.reset": "Khôi phục",
445
+ "spec.notObject": "Đặc tả phải là một object JSON.",
446
+ "spec.applied": "Đã áp dụng đặc tả vào sơ đồ.",
447
+ "status.reloaded": "Đã tải lại blueprint (bị sửa ở nơi khác).",
448
+ };
449
+
450
+ __JOURNEY_PANEL__
451
+
452
+ /** Locale namespace owned by the Galaxy feedback entry. */
453
+ const GBH_FEEDBACK_NS = "gbh.feedback";
454
+ /** Where the Galaxy feedback entry sends the remark. */
455
+ const GBH_FEEDBACK_EMAIL = "kevinbui210191@gmail.com";
456
+ /** English dictionary for the feedback entry; Vietnamese lives in vi.locales.json. */
457
+ const GBH_FEEDBACK_EN = {
458
+ "action.send": "Send feedback by email",
459
+ "dialog.title": "Send feedback by email",
460
+ "dialog.hint": "The remark opens in your mail app; Galaxy uploads nothing. Attach the conversation log with /export if you want it included.",
461
+ "dialog.category": "Category",
462
+ "dialog.details": "Details",
463
+ "dialog.placeholder": "What happened? What did you expect?",
464
+ "dialog.send": "Open mail app",
465
+ "dialog.save": "Save to session",
466
+ "dialog.cancel": "Cancel",
467
+ "dialog.empty": "Add some details first.",
468
+ "dialog.saving": "Saving…",
469
+ "dialog.saved": "Saved to this session.",
470
+ "dialog.saveFailed": "Could not save to the session.",
471
+ "dialog.mailTo": "Send to {email}",
472
+ "mail.subject": "[Galaxy Blackhole] Feedback — {category}",
473
+ "mail.session": "Session: {id}",
474
+ "mail.title": "Title: {title}",
475
+ "mail.workspace": "Workspace: {cwd}",
476
+ "mail.time": "Time: {time}",
477
+ "mail.note": "Attach the conversation log to this mail if you want it included (/export downloads it as a ZIP).",
478
+ "mail.none": "(none)"
479
+ };
480
+ /** The trash glyph: the header button draws it through React, the row menu injects the same markup. */
481
+ const GBH_TRASH_SVG = '<svg width="16" height="16" viewBox="0 0 16 16" aria-hidden="true" fill="none"><rect x="2" y="3.5" width="12" height="9" rx="1.5" stroke="currentColor" stroke-width="1.2"></rect><path d="M3 3.5h10M6.5 3.5V2.4h3v1.1M6.6 6.4v3.6M9.4 6.4v3.6" stroke="currentColor" stroke-width="1.2" stroke-linecap="round"></path></svg>';
482
+
483
+ /** Fill a copy template like "Phiên: {id}" without a formatting dependency. */
484
+ function gbhFill(template, values) {
485
+ return String(template).replace(/\{([a-zA-Z][a-zA-Z0-9]*)\}/g, function (match, name) {
486
+ return values[name] === undefined ? match : String(values[name]);
487
+ });
488
+ }
489
+ /** Session facts for the mail body, from the Galaxy session route (best effort). */
490
+ function gbhSessionFacts(sessionId) {
491
+ return fetch(gbhHostBase() + "/api/galaxy/sessions", { credentials: "same-origin" })
492
+ .then(function (response) { return response.json(); })
493
+ .then(function (body) {
494
+ var rows = body && Array.isArray(body.sessions) ? body.sessions : [];
495
+ for (var i = 0; i < rows.length; i += 1) if (rows[i] && rows[i].id === sessionId) return rows[i];
496
+ return {};
497
+ })
498
+ .catch(function () { return {}; });
499
+ }
500
+ /** Build the mailto target and the human-readable body of one remark. */
501
+ function gbhFeedbackMail(input) {
502
+ var t = input.t;
503
+ var facts = input.facts || {};
504
+ var details = String(input.details || "").trim();
505
+ if (details.length > 1800) details = details.slice(0, 1800) + "…";
506
+ var category = input.categoryLabel || "";
507
+ var subject = gbhFill(t("mail.subject"), { category: category.length > 0 ? category : "—" });
508
+ var lines = [];
509
+ if (category.length > 0) lines.push(category);
510
+ if (details.length > 0) lines.push(details);
511
+ lines.push("");
512
+ lines.push("---");
513
+ lines.push(gbhFill(t("mail.session"), { id: input.sessionId }));
514
+ lines.push(gbhFill(t("mail.title"), { title: facts.title || t("mail.none") }));
515
+ lines.push(gbhFill(t("mail.workspace"), { cwd: facts.cwd || t("mail.none") }));
516
+ lines.push(gbhFill(t("mail.time"), { time: new Date().toISOString() }));
517
+ lines.push(t("mail.note"));
518
+ var body = lines.join("\n");
519
+ return {
520
+ subject: subject,
521
+ body: body,
522
+ href: "mailto:" + GBH_FEEDBACK_EMAIL + "?subject=" + encodeURIComponent(subject) + "&body=" + encodeURIComponent(body)
523
+ };
524
+ }
525
+ /** Hand a mailto target to the browser mail client. */
526
+ function gbhOpenMail(href) {
527
+ try {
528
+ var anchor = document.createElement("a");
529
+ anchor.href = href;
530
+ anchor.rel = "noopener";
531
+ document.body.append(anchor);
532
+ anchor.click();
533
+ anchor.remove();
534
+ return true;
535
+ } catch (error) {
536
+ try { globalThis.location.href = href; return true; } catch (inner) { return false; }
537
+ }
538
+ }
539
+ /**
540
+ * Feedback lives in Settings now: one inline form that either opens the remark in
541
+ * the mail client (nothing leaves the machine before that) or records it in the
542
+ * current Session log through the stock sessionFeedback remote.
543
+ */
544
+ function GbhFeedbackSection(props) {
545
+ var t = props.t;
546
+ var categoryT = props.categoryT;
547
+ var ctx = props.ctx;
548
+ var CATEGORIES = ["task-result", "instruction-following", "product-interaction", "service-stability", "resource-cost", "security-privacy-permission", "other"];
549
+ var selectedState = react.useState(CATEGORIES[0]);
550
+ var selected = selectedState[0];
551
+ var setSelected = selectedState[1];
552
+ var textState = react.useState("");
553
+ var text = textState[0];
554
+ var setText = textState[1];
555
+ var statusState = react.useState(null);
556
+ var status = statusState[0];
557
+ var setStatus = statusState[1];
558
+ var busyState = react.useState(false);
559
+ var busy = busyState[0];
560
+ var setBusy = busyState[1];
561
+ /* The Settings section is root-scoped, so the Session comes from the live list. */
562
+ var listStore = ctx.sessions && ctx.sessions.list ? ctx.sessions.list : null;
563
+ var current;
564
+ try {
565
+ current = react.useSyncExternalStore(
566
+ function (notify) { return listStore.subscribe(notify); },
567
+ function () { return listStore.getSnapshot(); }
568
+ ).current;
569
+ } catch (error) { current = undefined; }
570
+ var chipStyle = function (active) {
571
+ return {
572
+ height: "30px", padding: "0 12px", borderRadius: "15px", fontSize: "12.5px",
573
+ border: "1px solid " + (active ? "#4f7cff" : "rgba(127,127,127,.35)"),
574
+ background: active ? "rgba(79,124,255,.16)" : "transparent", color: "inherit", cursor: "pointer",
575
+ };
576
+ };
577
+ var send = function () {
578
+ var details = text.trim();
579
+ if (details.length === 0) { setStatus({ kind: "error", text: t("dialog.empty") }); return; }
580
+ if (typeof current !== "string" || current.length === 0) { setStatus({ kind: "error", text: t("dialog.noSession") }); return; }
581
+ gbhSessionFacts(current).then(function (facts) {
582
+ var mail = gbhFeedbackMail({ t: t, facts: facts, details: details, categoryLabel: categoryT("category." + selected), sessionId: current });
583
+ if (gbhOpenMail(mail.href)) setStatus({ kind: "ok", text: t("dialog.opened") });
584
+ else setStatus({ kind: "error", text: mail.body });
585
+ });
586
+ };
587
+ var save = function () {
588
+ var details = text.trim();
589
+ if (details.length === 0) { setStatus({ kind: "error", text: t("dialog.empty") }); return; }
590
+ if (typeof current !== "string" || current.length === 0) { setStatus({ kind: "error", text: t("dialog.noSession") }); return; }
591
+ setBusy(true);
592
+ setStatus({ kind: "info", text: t("dialog.saving") });
593
+ Promise.resolve(ctx.remote.sessionFeedback.record({ sessionId: current, text: details, category: selected }))
594
+ .then(function (carried) {
595
+ setBusy(false);
596
+ var ok = carried && carried.ok === true && carried.value && carried.value.ok === true;
597
+ setStatus(ok ? { kind: "ok", text: t("dialog.saved") } : { kind: "error", text: t("dialog.saveFailed") });
598
+ }, function () { setBusy(false); setStatus({ kind: "error", text: t("dialog.saveFailed") }); });
599
+ };
600
+ var statusColor = status === null ? "inherit" : status.kind === "error" ? "#ff8a8a" : status.kind === "ok" ? "#6ddba0" : "var(--dsw-alias-label-secondary, #9aa0a6)";
601
+ return react_jsx_runtime.jsxs("div", {
602
+ "data-gbh-feedback": "settings",
603
+ style: { display: "flex", flexDirection: "column", gap: "10px", maxWidth: "620px" },
604
+ children: [
605
+ react_jsx_runtime.jsx("div", { style: { fontSize: "15px", fontWeight: 600 }, children: t("settings.title") }),
606
+ react_jsx_runtime.jsx("div", { style: { fontSize: "12.5px", lineHeight: "19px", opacity: 0.75 }, children: t("settings.intro") }),
607
+ react_jsx_runtime.jsx("div", {
608
+ style: { display: "flex", flexWrap: "wrap", gap: "8px" },
609
+ children: CATEGORIES.map(function (category) {
610
+ return react_jsx_runtime.jsx("button", {
611
+ type: "button",
612
+ "data-gbh-feedback-category": category,
613
+ onClick: function () { setSelected(category); },
614
+ style: chipStyle(selected === category),
615
+ children: categoryT("category." + category),
616
+ }, category);
617
+ }),
618
+ }),
619
+ react_jsx_runtime.jsx("textarea", {
620
+ "data-gbh-feedback-text": "1",
621
+ value: text,
622
+ placeholder: t("dialog.placeholder"),
623
+ onChange: function (event) { setText(event.target.value); },
624
+ style: { width: "100%", boxSizing: "border-box", minHeight: "120px", resize: "vertical", borderRadius: "10px", border: "1px solid rgba(127,127,127,.4)", background: "transparent", color: "inherit", padding: "10px 12px", fontSize: "13.5px", fontFamily: "inherit", outline: "none" },
625
+ }),
626
+ react_jsx_runtime.jsxs("div", { style: { display: "flex", alignItems: "center", gap: "10px", flexWrap: "wrap" }, children: [
627
+ react_jsx_runtime.jsx("button", {
628
+ type: "button", "data-gbh-feedback-send": "1", onClick: send,
629
+ style: { height: "34px", padding: "0 16px", borderRadius: "9px", border: "none", background: "#4f7cff", color: "#fff", cursor: "pointer", fontWeight: 600, fontSize: "13px" },
630
+ children: t("dialog.send"),
631
+ }),
632
+ react_jsx_runtime.jsx("button", {
633
+ type: "button", "data-gbh-feedback-save": "1", onClick: save, disabled: busy,
634
+ style: { height: "34px", padding: "0 14px", borderRadius: "9px", border: "1px solid rgba(127,127,127,.4)", background: "transparent", color: "inherit", cursor: busy ? "default" : "pointer", fontSize: "13px" },
635
+ children: t("dialog.save"),
636
+ }),
637
+ react_jsx_runtime.jsx("span", {
638
+ "data-gbh-feedback-status": status === null ? "idle" : status.kind,
639
+ style: { fontSize: "12px", color: statusColor },
640
+ children: status === null ? t("settings.target") : status.text,
641
+ }),
642
+ ] }),
643
+ ],
644
+ });
645
+ }
646
+ /** The sidebar row whose more-button was clicked last; the open menu belongs to it. */
647
+ var gbhMenuRow;
648
+ /** Client context captured for the injected row-menu entry (session list refresh). */
649
+ var gbhCtx;
650
+ /**
651
+ * Resolve the Session id a sidebar row belongs to.
652
+ *
653
+ * The row markup carries no id, but React keeps its fiber on the DOM node, and the
654
+ * SessionNodeItem fiber holds the Session node as a prop. Walking up a bounded number
655
+ * of fibers keeps this independent of the row markup and of the active language.
656
+ */
657
+ function gbhRowSessionId(row) {
658
+ var key;
659
+ var keys = Object.keys(row);
660
+ for (var i = 0; i < keys.length; i += 1) if (keys[i].indexOf("__reactFiber$") === 0) { key = keys[i]; break; }
661
+ if (key === undefined) return undefined;
662
+ var fiber = row[key];
663
+ for (var depth = 0; depth < 15 && fiber; depth += 1) {
664
+ var props = fiber.memoizedProps;
665
+ if (props && typeof props.sessionId === "string") return props.sessionId;
666
+ if (props && props.node && typeof props.node.id === "string") return props.node.id;
667
+ fiber = fiber.return;
668
+ }
669
+ return undefined;
670
+ }
671
+ /** True for the sidebar row markup that represents one Session. */
672
+ function gbhIsSessionRow(row) {
673
+ return typeof row.className === "string" && row.className.indexOf("sessionRow") !== -1;
674
+ }
675
+ /** Close a menu the primitives own by asking it to dismiss itself. */
676
+ function gbhDismissMenu(menu) {
677
+ try { menu.dispatchEvent(new KeyboardEvent("keydown", { key: "Escape", bubbles: true })); } catch (error) { /* ignore */ }
678
+ try { document.body.dispatchEvent(new MouseEvent("mousedown", { bubbles: true })); } catch (error) { /* ignore */ }
679
+ }
680
+ /**
681
+ * Add the Galaxy delete entry to an open Session row menu.
682
+ *
683
+ * The stock menu is built inside @deepseek-ai/dsh-client-ui-workspace, which exposes no
684
+ * slot for per-row actions, so the entry is appended next to the last stock item using
685
+ * that item as the styling template. Any uncertainty about which Session the menu owns
686
+ * skips the injection: deleting the wrong Session is far worse than a missing entry.
687
+ */
688
+ function gbhInjectDeleteMenuItem(sessionsT) {
689
+ var menu = document.querySelector("[role=menu]");
690
+ if (menu === null || menu.querySelector("[data-gbh-menu-delete]") !== null) return;
691
+ var row = gbhMenuRow;
692
+ if (row === undefined || !document.contains(row) || !gbhIsSessionRow(row)) return;
693
+ var sessionId = gbhRowSessionId(row);
694
+ if (sessionId === undefined) return;
695
+ var items = menu.querySelectorAll("button[role=menuitem]");
696
+ if (items.length === 0) return;
697
+ var template = items[items.length - 1];
698
+ var wrap = template.parentElement;
699
+ var viewport = wrap === null ? null : wrap.parentElement;
700
+ if (wrap === null || viewport === null) return;
701
+ var clone = wrap.cloneNode(true);
702
+ var button = clone.querySelector("button[role=menuitem]");
703
+ if (button === null) return;
704
+ button.setAttribute("data-gbh-menu-delete", "1");
705
+ var label = button.querySelector("[class*=itemLabel]");
706
+ if (label !== null) label.textContent = sessionsT("menu.delete");
707
+ var icon = button.querySelector("[class*=itemIcon]");
708
+ if (icon !== null) icon.innerHTML = GBH_TRASH_SVG;
709
+ button.addEventListener("click", function (event) {
710
+ event.preventDefault();
711
+ event.stopPropagation();
712
+ gbhDismissMenu(menu);
713
+ gbhConfirmDeleteSession(sessionId, sessionsT, function () {}, function () { gbhAfterDelete(sessionId); });
714
+ }, true);
715
+ viewport.append(clone);
716
+ }
717
+ /** Remember the clicked row and watch for row menus the primitives portal into the body. */
718
+ function gbhWatchSessionMenu(ctx, sessionsT) {
719
+ if (typeof document === "undefined" || typeof MutationObserver === "undefined") return;
720
+ document.addEventListener("click", function (event) {
721
+ var target = event.target;
722
+ if (target === null || typeof target.closest !== "function") return;
723
+ var row = target.closest("[role=treeitem]");
724
+ if (row !== null && gbhIsSessionRow(row)) gbhMenuRow = row;
725
+ }, true);
726
+ /**
727
+ * One menu probe per mutation burst.
728
+ *
729
+ * A session switch re-renders the transcript thousands of times, and probing the
730
+ * document for an open menu on every record froze the renderer; a burst now costs
731
+ * a single probe after the DOM settles, and a burst without element insertions is
732
+ * ignored entirely. The same probe seats the terminal-failure hint, which costs
733
+ * two bounded row queries per burst.
734
+ */
735
+ var menuProbeScheduled = false;
736
+ function scheduleMenuProbe() {
737
+ if (menuProbeScheduled) return;
738
+ menuProbeScheduled = true;
739
+ setTimeout(function () {
740
+ menuProbeScheduled = false;
741
+ gbhInjectDeleteMenuItem(sessionsT);
742
+ gbhAnnotateTurnErrors(sessionsT);
743
+ }, 150);
744
+ }
745
+ new MutationObserver(function (mutations) {
746
+ for (var i = 0; i < mutations.length; i += 1) {
747
+ var added = mutations[i].addedNodes;
748
+ for (var j = 0; j < added.length; j += 1) {
749
+ var node = added[j];
750
+ if (node === null || node.nodeType !== 1) continue;
751
+ scheduleMenuProbe();
752
+ return;
753
+ }
754
+ }
755
+ }).observe(document.body, { childList: true, subtree: true });
756
+ }
757
+ const inject = ["slots", "locale", "remote", "remote.credentials", "remote.sessionFeedback", "sessions"];
317
758
  function apply(ctx) {
318
759
  ctx.slots.inject("sidebar.brand.mark", () => ctx.slots.inject("sidebar.brand.name", function* () {
319
760
  yield ctx.slots.register({ name: "sidebar.brand.mark" }, GbhBrandMark);
@@ -330,26 +771,107 @@ window.__ModuleLoader__.load({
330
771
  inject: function () { return {}; }
331
772
  }, GbhDeleteSessionAction);
332
773
  });
774
+ /* Row menus: the stock Session menu exposes no slot, so the entry is injected on open. */
775
+ var sessionsT = function (key) { return key; };
776
+ try { sessionsT = ctx.locale.bind(GBH_SESSIONS_NS); } catch (error) { /* the namespace registers just above */ }
777
+ gbhCtx = ctx;
778
+ gbhWatchSessionMenu(ctx, sessionsT);
779
+ /* Journey: the n8n-style blueprint canvas, seated next to Trajectory. */
780
+ var journeyTranslator = function (key) { return key; };
781
+ try { journeyTranslator = ctx.locale.bind(GBH_JOURNEY_NS); } catch (error) { /* the namespace registers just above */ }
782
+ var journeyT = function (key) {
783
+ try {
784
+ var value = journeyTranslator(key);
785
+ if (typeof value === "string" && value !== key) return value;
786
+ } catch (error) { /* fall through to the built-in copy */ }
787
+ return GBH_JOURNEY_VI[key] !== undefined ? GBH_JOURNEY_VI[key] : key;
788
+ };
789
+ var journeyApi = {
790
+ load: function (sessionId) {
791
+ return fetch(gbhHostBase() + "/api/galaxy/journey?sessionId=" + encodeURIComponent(sessionId), { credentials: "same-origin" })
792
+ .then(function (response) { return response.json().catch(function () { return { ok: false, message: "HTTP " + response.status }; }); })
793
+ .catch(function (error) { return { ok: false, message: String(error) }; });
794
+ },
795
+ run: function (sessionId, payload) {
796
+ return fetch(gbhHostBase() + "/api/galaxy/journey.run", {
797
+ method: "POST",
798
+ headers: { "content-type": "application/json" },
799
+ credentials: "same-origin",
800
+ body: JSON.stringify({ sessionId: sessionId, updatedBy: "human", ...(payload || {}) })
801
+ })
802
+ .then(function (response) { return response.json().catch(function () { return { ok: false, message: "HTTP " + response.status }; }); })
803
+ .catch(function (error) { return { ok: false, message: String(error) }; });
804
+ },
805
+ save: function (sessionId, document, expectedRevision) {
806
+ return fetch(gbhHostBase() + "/api/galaxy/journey", {
807
+ method: "POST",
808
+ headers: { "content-type": "application/json" },
809
+ credentials: "same-origin",
810
+ body: JSON.stringify({ sessionId: sessionId, document: document, expectedRevision: expectedRevision, updatedBy: "human" })
811
+ })
812
+ .then(function (response) { return response.json().catch(function () { return { ok: false, message: "HTTP " + response.status }; }); })
813
+ .catch(function (error) { return { ok: false, message: String(error) }; });
814
+ }
815
+ };
816
+ var journeyPanel = createJourneyPanel({
817
+ react: react,
818
+ jsx: react_jsx_runtime.jsx,
819
+ jsxs: react_jsx_runtime.jsxs,
820
+ primitives: primitives,
821
+ t: journeyT,
822
+ api: journeyApi
823
+ });
824
+ ctx.slots.inject("conversation.view", function () {
825
+ return ctx.slots.register({
826
+ name: "conversation.view",
827
+ id: "journey",
828
+ order: 20,
829
+ locale: GBH_JOURNEY_NS,
830
+ label: function () { return journeyT("view.journey"); },
831
+ inject: function (sessionId) { return { sessionId: sessionId, api: journeyApi, t: journeyT }; }
832
+ }, journeyPanel.JourneyPanel);
833
+ });
834
+ /* Feedback: send the remark by email, or keep it in the local Session log. */
835
+ var feedbackT = function (key) { return key; };
836
+ try { feedbackT = ctx.locale.bind("feedback"); } catch (error) { /* the stock namespace may be absent */ }
837
+ ctx.slots.inject("conversation.session.header.utilities", function () {
838
+ return ctx.slots.register({
839
+ name: "conversation.session.header.utilities",
840
+ id: "gbh-feedback",
841
+ order: 60,
842
+ locale: GBH_FEEDBACK_NS,
843
+ inject: function () { return { ctx: ctx, feedbackT: feedbackT }; }
844
+ }, GbhFeedbackAction);
845
+ });
333
846
  try {
334
847
  ctx.locale.addLanguage({ id: "vi", label: "Tiếng Việt", fallback: "en" });
335
848
  } catch (error) {
336
849
  /* the language may already be registered on a plugin reload */
337
850
  }
851
+ /* Galaxy-owned namespaces ship both dictionaries: English here, Vietnamese in vi.locales.json. */
852
+ const ownDictionaries = {};
853
+ ownDictionaries[GBH_SESSIONS_NS] = GBH_SESSIONS_EN;
854
+ ownDictionaries[GBH_FEEDBACK_NS] = GBH_FEEDBACK_EN;
855
+ ownDictionaries[GBH_JOURNEY_NS] = GBH_JOURNEY_EN;
338
856
  const namespaces = Object.keys(VI_LOCALES);
339
857
  for (let i = 0; i < namespaces.length; i += 1) {
340
858
  const ns = namespaces[i];
341
- /* The session tools namespace registers both dictionaries in one call below. */
342
- if (ns === GBH_SESSIONS_NS) continue;
859
+ /* A Galaxy-owned namespace registers both dictionaries in one call below. */
860
+ if (ownDictionaries[ns] !== undefined) continue;
343
861
  try {
344
862
  ctx.locale.register(ns, "vi", VI_LOCALES[ns]);
345
863
  } catch (error) {
346
864
  /* a namespace may already carry vi on a reload */
347
865
  }
348
866
  }
349
- try {
350
- ctx.locale.register(GBH_SESSIONS_NS, { en: GBH_SESSIONS_EN, vi: VI_LOCALES[GBH_SESSIONS_NS] });
351
- } catch (error) {
352
- /* the namespace may already be registered on a plugin reload */
867
+ const ownNames = Object.keys(ownDictionaries);
868
+ for (let i = 0; i < ownNames.length; i += 1) {
869
+ const ns = ownNames[i];
870
+ try {
871
+ ctx.locale.register(ns, { en: ownDictionaries[ns], vi: VI_LOCALES[ns] });
872
+ } catch (error) {
873
+ /* the namespace may already be registered on a plugin reload */
874
+ }
353
875
  }
354
876
  /* Replace the shipped internal-testing notice with the Galaxy description,
355
877
  including the English copy, by editing the registered dictionaries. */
@@ -368,29 +890,9 @@ window.__ModuleLoader__.load({
368
890
  } catch (error) {
369
891
  /* dictionary override is best-effort */
370
892
  }
371
- /* Separate thinking control before the composer submit action. */
372
- var localeActive = "en";
373
- try { localeActive = ctx.locale.getSnapshot().active; } catch (error) { /* default en */ }
374
- ctx.inject(["slots", "modelDirectories", "sessions"], function (scope) {
375
- var models = scope.modelDirectories;
376
- var sessions = scope.sessions;
377
- scope.slots.inject("conversation.input.right", function () {
378
- return scope.slots.register({
379
- name: "conversation.input.right",
380
- inject: function (sessionId) {
381
- var directory = models.directoryFor(sessionId);
382
- var available = sessions.subagentAddress(sessionId) === undefined;
383
- return {
384
- available: available,
385
- directory: directory.store,
386
- localeActive: localeActive,
387
- load: function () { if (available) directory.load().catch(function () { return undefined; }); },
388
- select: function (selection) { return available ? directory.select(selection).then(function () { return true; }, function () { return false; }) : Promise.resolve(false); }
389
- };
390
- }
391
- }, GbhThinkingControl);
392
- });
393
- });
893
+ /* The composer keeps the stock model/effort chip; Galaxy no longer seats a
894
+ second effort control there (it duplicated the chip and rendered empty
895
+ for a provider that declares its efforts as a map). */
394
896
  ensureGalaxyKey(ctx);
395
897
  watchContextSources();
396
898
  }