@galaxy-stack/blackhole-cli 3.0.20 → 3.0.22
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/package.json +3 -2
- package/web/brand/app-icon-192.png +0 -0
- package/web/brand/app-icon-512.png +0 -0
- package/web/brand/client.template.js +1259 -0
- package/web/brand/dsh-locale-keys.json +8659 -0
- package/web/brand/favicon.png +0 -0
- package/web/brand/favicon.svg +12 -0
- package/web/brand/lib/app-icons.js +3 -0
- package/web/brand/lib/client.js +5161 -0
- package/web/brand/lib/favicon.js +1 -0
- package/web/brand/lib/index.d.ts +3 -0
- package/web/brand/lib/index.js +1068 -0
- package/web/brand/lib/journey-host.js +288 -0
- package/web/brand/lib/journey-run.d.ts +70 -0
- package/web/brand/lib/journey-run.js +344 -0
- package/web/brand/lib/journey-store.d.ts +61 -0
- package/web/brand/lib/journey-store.js +183 -0
- package/web/brand/lib/session-store.d.ts +54 -0
- package/web/brand/lib/session-store.js +288 -0
- package/web/brand/logo.png +0 -0
- package/web/brand/logo.svg +20 -0
- package/web/brand/package.json +35 -0
- package/web/brand/panel/journey-panel.js +1037 -0
- package/web/brand/vi-same-by-design.json +112 -0
- package/web/brand/vi.locales.json +2867 -0
- package/web/brand/zalo.jpg +0 -0
- package/web/patches/gbh-brand.patch.yml +13 -0
- package/web/patches/gbh-ui.patch.yml +7 -0
- package/web/patches/gbh-web.patch.yml +124 -0
|
@@ -0,0 +1,1259 @@
|
|
|
1
|
+
window.__ModuleLoader__.load({
|
|
2
|
+
id: "@galaxy-stack/gbh-brand",
|
|
3
|
+
factory: (require) => {
|
|
4
|
+
var module = { exports: {} };
|
|
5
|
+
var exports = module.exports;
|
|
6
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
7
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
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; }
|
|
12
|
+
const LOGO = __LOGO_DATA_URI__;
|
|
13
|
+
const ZALO = __ZALO_DATA_URI__;
|
|
14
|
+
const CLI_VERSION = __CLI_VERSION__;
|
|
15
|
+
const VI_LOCALES = __VI_LOCALES__;
|
|
16
|
+
const EN_OVERRIDES = {
|
|
17
|
+
"settings.models": {
|
|
18
|
+
"welcomeTitle": "Galaxy Blackhole",
|
|
19
|
+
"welcomeBody": "Galaxy Blackhole is an open, composable AI coding stack for the Galaxy ecosystem, developed by engineer Kevinbui (email: kevinbui210191@gmail.com). It combines a provider-neutral agent runtime, a deterministic CLI, and reusable tools and skills, so developers can build, extend, and share coding agents on open-source infrastructure.\n\nCore plugins and APIs are still evolving quickly, and feedback from the developer community is very welcome.",
|
|
20
|
+
"welcomeContinue": "Continue",
|
|
21
|
+
"welcomeError": "Could not save the acknowledgement. Please try again."
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
function GbhBrandMark({ size, className }) {
|
|
25
|
+
const px = typeof size === "number" ? size : 20;
|
|
26
|
+
return react_jsx_runtime.jsx("img", {
|
|
27
|
+
src: LOGO,
|
|
28
|
+
alt: "Galaxy Blackhole",
|
|
29
|
+
width: px,
|
|
30
|
+
height: px,
|
|
31
|
+
className,
|
|
32
|
+
style: { display: "block", objectFit: "contain" }
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
function GbhBrandName() {
|
|
36
|
+
return react_jsx_runtime.jsx("span", {
|
|
37
|
+
style: { fontWeight: 600, fontSize: "14px", letterSpacing: "0.01em", whiteSpace: "nowrap" },
|
|
38
|
+
children: "Galaxy Blackhole"
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/* The injected-context row prints its producer as a raw plugin id, so the
|
|
43
|
+
reader sees "@deepseek-ai/dsh-system-prompt". Rename the harness
|
|
44
|
+
producers to readable labels: "Chèn ngữ cảnh · System prompt". */
|
|
45
|
+
const CONTEXT_SOURCE_ID = /^@deepseek-ai\/dsh-([a-z0-9-]+)$/i;
|
|
46
|
+
function friendlyContextSource(raw) {
|
|
47
|
+
var match = CONTEXT_SOURCE_ID.exec(raw);
|
|
48
|
+
if (!match) return undefined;
|
|
49
|
+
var words = match[1].split("-");
|
|
50
|
+
for (var i = 0; i < words.length; i += 1) words[i] = words[i].charAt(0).toUpperCase() + words[i].slice(1);
|
|
51
|
+
var label = words.join(" ");
|
|
52
|
+
return label === "System Prompt" ? "System prompt" : label;
|
|
53
|
+
}
|
|
54
|
+
/** Rewrite every visible producer label; React re-renders are re-applied. */
|
|
55
|
+
function relabelContextSources() {
|
|
56
|
+
if (typeof document === "undefined") return;
|
|
57
|
+
var nodes = document.querySelectorAll("[data-context-source]");
|
|
58
|
+
for (var i = 0; i < nodes.length; i += 1) {
|
|
59
|
+
var node = nodes[i];
|
|
60
|
+
var label = friendlyContextSource((node.textContent || "").trim());
|
|
61
|
+
if (label !== undefined && node.textContent !== label) node.textContent = label;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
function watchContextSources() {
|
|
65
|
+
if (typeof document === "undefined" || typeof MutationObserver === "undefined") return;
|
|
66
|
+
relabelContextSources();
|
|
67
|
+
var scheduled = false;
|
|
68
|
+
new MutationObserver(function () {
|
|
69
|
+
if (scheduled) return;
|
|
70
|
+
scheduled = true;
|
|
71
|
+
Promise.resolve().then(function () { scheduled = false; relabelContextSources(); });
|
|
72
|
+
}).observe(document.body, { childList: true, subtree: true, characterData: true });
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const GALAXY_KEY_REF = "GBH_GALAXY_API_KEY";
|
|
76
|
+
/** Show a Galaxy-specific dialog when the Galaxy key is not configured. */
|
|
77
|
+
function ensureGalaxyKey(ctx) {
|
|
78
|
+
try {
|
|
79
|
+
if (globalThis.__GBH_HAS_KEY__ === true) return;
|
|
80
|
+
var credentials = ctx.remote && ctx.remote.credentials;
|
|
81
|
+
if (!credentials || typeof credentials.describe !== "function") return;
|
|
82
|
+
Promise.resolve(credentials.describe([GALAXY_KEY_REF])).then(function (res) {
|
|
83
|
+
var info = res && res.ok ? res.value[GALAXY_KEY_REF] : undefined;
|
|
84
|
+
if (info && info.configured) return;
|
|
85
|
+
renderKeyDialog(ctx);
|
|
86
|
+
}).catch(function () { renderKeyDialog(ctx); });
|
|
87
|
+
} catch (error) { /* best effort */ }
|
|
88
|
+
}
|
|
89
|
+
/** Build the key dialog with plain DOM so it does not need React. */
|
|
90
|
+
function renderKeyDialog(ctx) {
|
|
91
|
+
if (typeof document === "undefined" || document.getElementById("gbh-key-dialog")) return;
|
|
92
|
+
var vi = false;
|
|
93
|
+
try { vi = ctx.locale.getSnapshot().active === "vi"; } catch (error) { /* default en */ }
|
|
94
|
+
var copy = vi ? {
|
|
95
|
+
title: "Galaxy Blackhole",
|
|
96
|
+
body: "Nhập Galaxy API key để dùng model. Key được lưu trong GBH và dùng luôn cho web search.",
|
|
97
|
+
placeholder: "Dán Galaxy API key",
|
|
98
|
+
save: "Lưu", cancel: "Để sau", failed: "Lưu thất bại. Vui lòng thử lại."
|
|
99
|
+
} : {
|
|
100
|
+
title: "Galaxy Blackhole",
|
|
101
|
+
body: "Enter your Galaxy API key to use the model. The key is stored in GBH and reused for web search.",
|
|
102
|
+
placeholder: "Paste your Galaxy API key",
|
|
103
|
+
save: "Save", cancel: "Later", failed: "Save failed. Please try again."
|
|
104
|
+
};
|
|
105
|
+
var overlay = document.createElement("div");
|
|
106
|
+
overlay.id = "gbh-key-dialog";
|
|
107
|
+
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";
|
|
108
|
+
var card = document.createElement("div");
|
|
109
|
+
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)";
|
|
110
|
+
var title = document.createElement("div");
|
|
111
|
+
title.textContent = copy.title;
|
|
112
|
+
title.style.cssText = "font-size:17px;font-weight:600;margin-bottom:8px";
|
|
113
|
+
var body = document.createElement("div");
|
|
114
|
+
body.textContent = copy.body;
|
|
115
|
+
body.style.cssText = "font-size:13px;line-height:20px;opacity:.8;margin-bottom:14px";
|
|
116
|
+
var input = document.createElement("input");
|
|
117
|
+
input.type = "password";
|
|
118
|
+
input.placeholder = copy.placeholder;
|
|
119
|
+
input.style.cssText = "width:100%;box-sizing:border-box;height:38px;border-radius:9px;border:1px solid rgba(127,127,127,.4);background:transparent;color:inherit;padding:0 12px;font-size:14px;outline:none";
|
|
120
|
+
var errorEl = document.createElement("div");
|
|
121
|
+
errorEl.style.cssText = "color:#ff6b6b;font-size:12px;min-height:16px;margin-top:8px";
|
|
122
|
+
var actions = document.createElement("div");
|
|
123
|
+
actions.style.cssText = "display:flex;justify-content:flex-end;gap:10px;margin-top:10px";
|
|
124
|
+
var cancel = document.createElement("button");
|
|
125
|
+
cancel.type = "button"; cancel.textContent = copy.cancel;
|
|
126
|
+
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";
|
|
127
|
+
var save = document.createElement("button");
|
|
128
|
+
save.type = "button"; save.textContent = copy.save;
|
|
129
|
+
save.style.cssText = "height:34px;padding:0 16px;border-radius:9px;border:none;background:#4f7cff;color:#fff;cursor:pointer;font-weight:600";
|
|
130
|
+
cancel.onclick = function () { overlay.remove(); };
|
|
131
|
+
save.onclick = function () {
|
|
132
|
+
var value = input.value.trim();
|
|
133
|
+
if (value.length === 0) return;
|
|
134
|
+
save.disabled = true;
|
|
135
|
+
Promise.resolve(ctx.remote.credentials.set(GALAXY_KEY_REF, value)).then(function (res) {
|
|
136
|
+
if (res && res.ok) { overlay.remove(); globalThis.__GBH_HAS_KEY__ = true; location.reload(); }
|
|
137
|
+
else { errorEl.textContent = res && res.error ? res.error.message : copy.failed; save.disabled = false; }
|
|
138
|
+
}).catch(function () { errorEl.textContent = copy.failed; save.disabled = false; });
|
|
139
|
+
};
|
|
140
|
+
actions.append(cancel, save);
|
|
141
|
+
card.append(title, body, input, errorEl, actions);
|
|
142
|
+
overlay.append(card);
|
|
143
|
+
document.body.append(overlay);
|
|
144
|
+
setTimeout(function () { try { input.focus(); } catch (error) { /* ignore */ } }, 30);
|
|
145
|
+
}
|
|
146
|
+
/** Locale namespace owned by the Galaxy session tools. */
|
|
147
|
+
const GBH_SESSIONS_NS = "gbh.sessions";
|
|
148
|
+
/** English dictionary for the session tools; Vietnamese lives in vi.locales.json. */
|
|
149
|
+
const GBH_SESSIONS_EN = {
|
|
150
|
+
"action.delete": "Delete session",
|
|
151
|
+
"menu.delete": "Delete session",
|
|
152
|
+
"dialog.title": "Delete this session?",
|
|
153
|
+
"dialog.body": "The session log and its projection cache are removed from the DSH home. This cannot be undone.",
|
|
154
|
+
"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.",
|
|
155
|
+
"dialog.cascade": "This session has {count} descendant session(s). Deleting it also deletes them.",
|
|
156
|
+
"dialog.running": "This session is running. Stop it before deleting.",
|
|
157
|
+
"dialog.cancel": "Cancel",
|
|
158
|
+
"dialog.confirm": "Delete session",
|
|
159
|
+
"dialog.confirmCascade": "Delete {count} sessions",
|
|
160
|
+
"dialog.busy": "Deleting…",
|
|
161
|
+
"dialog.failed": "Could not delete the session.",
|
|
162
|
+
"dialog.done": "Session deleted.",
|
|
163
|
+
"dialog.alreadyDeleted": "This session was already deleted. Its row has now been cleaned up.",
|
|
164
|
+
"dialog.unknown": "This session left no trace in the DSH home; the list has been cleaned up."
|
|
165
|
+
};
|
|
166
|
+
/** Success wording that reports what the route actually did. */
|
|
167
|
+
function gbhDeleteOutcomeText(body, t) {
|
|
168
|
+
if (body && body.found === false) return t("dialog.unknown");
|
|
169
|
+
if (body && body.alreadyDeleted === true) return t("dialog.alreadyDeleted");
|
|
170
|
+
return t("dialog.done");
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Put the sidebar back in sync after a delete.
|
|
174
|
+
*
|
|
175
|
+
* A Session this DSH process still holds attached cannot be unlinked out of every
|
|
176
|
+
* list on its own: the Host hides it through the archive set, which arrives as a
|
|
177
|
+
* workspace frame. The list refresh covers the cold case (the row's summary is
|
|
178
|
+
* gone with its projection cache), and only the open Session needs a reload.
|
|
179
|
+
*/
|
|
180
|
+
function gbhAfterDelete(sessionId) {
|
|
181
|
+
try {
|
|
182
|
+
var current = gbhCtx !== undefined && gbhCtx.sessions !== undefined ? gbhCtx.sessions.list.getSnapshot().current : undefined;
|
|
183
|
+
if (current === sessionId) { location.reload(); return; }
|
|
184
|
+
if (gbhCtx !== undefined && gbhCtx.sessions !== undefined) gbhCtx.sessions.refresh();
|
|
185
|
+
} catch (error) { /* the list refresh is best effort */ }
|
|
186
|
+
}
|
|
187
|
+
/** Same-origin Host base with the connection carrier\u0027s null-origin fallback. */
|
|
188
|
+
function gbhHostBase() {
|
|
189
|
+
var origin = globalThis.location && globalThis.location.origin;
|
|
190
|
+
return origin !== undefined && origin !== null && origin !== "null" ? origin : "http://dsh.internal";
|
|
191
|
+
}
|
|
192
|
+
/** Delete one session through the Galaxy host route; resolves to the parsed JSON body. */
|
|
193
|
+
function gbhDeleteSession(sessionId, cascade) {
|
|
194
|
+
return fetch(gbhHostBase() + "/api/galaxy/session.delete", {
|
|
195
|
+
method: "POST",
|
|
196
|
+
headers: { "content-type": "application/json" },
|
|
197
|
+
credentials: "same-origin",
|
|
198
|
+
body: JSON.stringify({ sessionId: sessionId, cascade: cascade === true, trash: true })
|
|
199
|
+
}).then(function (response) {
|
|
200
|
+
return response.json().then(function (body) { return body || {}; }, function () { return {}; });
|
|
201
|
+
}).catch(function (error) { return { ok: false, code: "network", message: String(error) }; });
|
|
202
|
+
}
|
|
203
|
+
/** Modal confirmation built with plain DOM, matching the Galaxy key dialog style. */
|
|
204
|
+
function gbhConfirmDeleteSession(sessionId, t, onFinished, onDeleted) {
|
|
205
|
+
if (typeof document === "undefined") return;
|
|
206
|
+
if (document.getElementById("gbh-delete-session-dialog")) return;
|
|
207
|
+
var overlay = document.createElement("div");
|
|
208
|
+
overlay.id = "gbh-delete-session-dialog";
|
|
209
|
+
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";
|
|
210
|
+
var card = document.createElement("div");
|
|
211
|
+
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)";
|
|
212
|
+
var title = document.createElement("div");
|
|
213
|
+
title.textContent = t("dialog.title");
|
|
214
|
+
title.style.cssText = "font-size:17px;font-weight:600;margin-bottom:8px";
|
|
215
|
+
var body = document.createElement("div");
|
|
216
|
+
body.textContent = t("dialog.body");
|
|
217
|
+
body.style.cssText = "font-size:13px;line-height:20px;opacity:.82;margin-bottom:8px";
|
|
218
|
+
var note = document.createElement("div");
|
|
219
|
+
note.textContent = t("dialog.trash");
|
|
220
|
+
note.style.cssText = "font-size:12px;line-height:18px;opacity:.62;margin-bottom:14px";
|
|
221
|
+
var errorEl = document.createElement("div");
|
|
222
|
+
errorEl.style.cssText = "color:#ff6b6b;font-size:12px;line-height:18px;min-height:16px;margin-bottom:10px";
|
|
223
|
+
var actions = document.createElement("div");
|
|
224
|
+
actions.style.cssText = "display:flex;justify-content:flex-end;gap:10px";
|
|
225
|
+
var cancel = document.createElement("button");
|
|
226
|
+
cancel.type = "button";
|
|
227
|
+
cancel.textContent = t("dialog.cancel");
|
|
228
|
+
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";
|
|
229
|
+
var confirm = document.createElement("button");
|
|
230
|
+
confirm.type = "button";
|
|
231
|
+
confirm.textContent = t("dialog.confirm");
|
|
232
|
+
confirm.style.cssText = "height:34px;padding:0 16px;border-radius:9px;border:none;background:#e5484d;color:#fff;cursor:pointer;font-weight:600";
|
|
233
|
+
cancel.onclick = function () { overlay.remove(); onFinished(); };
|
|
234
|
+
confirm.onclick = function () { run(false); };
|
|
235
|
+
function finish(body) {
|
|
236
|
+
confirm.disabled = true;
|
|
237
|
+
errorEl.style.color = "var(--dsw-alias-label-secondary,#9aa0a6)";
|
|
238
|
+
/* An id whose artifacts are already gone is a success, not a dead end. */
|
|
239
|
+
errorEl.textContent = gbhDeleteOutcomeText(body, t);
|
|
240
|
+
if (typeof onDeleted === "function") {
|
|
241
|
+
onDeleted(body);
|
|
242
|
+
setTimeout(function () { overlay.remove(); onFinished(); }, 500);
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
if (body && body.deleted && body.deleted.length > 0) {
|
|
246
|
+
setTimeout(function () { try { location.reload(); } catch (e) { overlay.remove(); onFinished(); } }, 600);
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
overlay.remove();
|
|
250
|
+
onFinished();
|
|
251
|
+
}
|
|
252
|
+
function run(cascade) {
|
|
253
|
+
confirm.disabled = true;
|
|
254
|
+
cancel.disabled = true;
|
|
255
|
+
errorEl.style.color = "var(--dsw-alias-label-secondary,#9aa0a6)";
|
|
256
|
+
errorEl.textContent = t("dialog.busy");
|
|
257
|
+
gbhDeleteSession(sessionId, cascade).then(function (body) {
|
|
258
|
+
if (body && body.ok === true) { finish(body); return; }
|
|
259
|
+
var code = body && body.code ? body.code : "error";
|
|
260
|
+
confirm.disabled = false;
|
|
261
|
+
cancel.disabled = false;
|
|
262
|
+
errorEl.style.color = "#ff6b6b";
|
|
263
|
+
if (code === "session/has-children") {
|
|
264
|
+
var count = body && body.children ? body.children.length : 0;
|
|
265
|
+
note.textContent = t("dialog.cascade").split("{count}").join(String(count));
|
|
266
|
+
confirm.textContent = t("dialog.confirmCascade").split("{count}").join(String(count));
|
|
267
|
+
confirm.onclick = function () { run(true); };
|
|
268
|
+
errorEl.textContent = "";
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
if (code === "session/running") { errorEl.textContent = t("dialog.running"); return; }
|
|
272
|
+
errorEl.textContent = (body && body.message) || t("dialog.failed");
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
actions.append(cancel, confirm);
|
|
276
|
+
card.append(title, body, note, errorEl, actions);
|
|
277
|
+
overlay.append(card);
|
|
278
|
+
document.body.append(overlay);
|
|
279
|
+
setTimeout(function () { try { confirm.focus(); } catch (e) { /* ignore */ } }, 30);
|
|
280
|
+
}
|
|
281
|
+
/** Trash button seated in the Session header utilities list. */
|
|
282
|
+
function GbhDeleteSessionAction(props) {
|
|
283
|
+
var sessionId = props.sessionId;
|
|
284
|
+
if (typeof sessionId !== "string" || sessionId.length === 0) return null;
|
|
285
|
+
var busyState = react.useState(false);
|
|
286
|
+
var busy = busyState[0];
|
|
287
|
+
var setBusy = busyState[1];
|
|
288
|
+
var t = props.t;
|
|
289
|
+
var label = t("action.delete");
|
|
290
|
+
var icon = react_jsx_runtime.jsx("span", { style: { display: "inline-flex" }, dangerouslySetInnerHTML: { __html: GBH_TRASH_SVG } });
|
|
291
|
+
return react_jsx_runtime.jsx("button", {
|
|
292
|
+
type: "button",
|
|
293
|
+
title: label,
|
|
294
|
+
"aria-label": label,
|
|
295
|
+
disabled: busy,
|
|
296
|
+
onClick: function () {
|
|
297
|
+
if (busy) return;
|
|
298
|
+
setBusy(true);
|
|
299
|
+
/* The header action owns the open Session, so it always re-syncs the list. */
|
|
300
|
+
gbhConfirmDeleteSession(sessionId, t, function () { setBusy(false); }, function () { gbhAfterDelete(sessionId); });
|
|
301
|
+
},
|
|
302
|
+
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" },
|
|
303
|
+
children: icon === null ? label : icon
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
/** Locale namespace owned by the Galaxy journey panel. */
|
|
307
|
+
const GBH_JOURNEY_NS = "gbh.journey";
|
|
308
|
+
/** English dictionary for the journey panel; Vietnamese lives in vi.locales.json. */
|
|
309
|
+
const GBH_JOURNEY_EN = {
|
|
310
|
+
"view.journey": "Journey",
|
|
311
|
+
"toolbar.revision": "Blueprint revision",
|
|
312
|
+
"toolbar.save": "Save",
|
|
313
|
+
"toolbar.reload": "Reload",
|
|
314
|
+
"toolbar.undo": "Undo",
|
|
315
|
+
"toolbar.redo": "Redo",
|
|
316
|
+
"toolbar.zoomIn": "Zoom in",
|
|
317
|
+
"toolbar.zoomOut": "Zoom out",
|
|
318
|
+
"toolbar.fit": "Fit",
|
|
319
|
+
"toolbar.layout": "Auto layout",
|
|
320
|
+
"node.outPort": "Drag to connect",
|
|
321
|
+
"node.inPort": "Drop a connection here",
|
|
322
|
+
"node.step": "Step in the run order",
|
|
323
|
+
"node.noDescription": "No description yet — the agent reads it before running this step.",
|
|
324
|
+
"inspector.empty": "Select a node or an edge to edit it.",
|
|
325
|
+
"inspector.node": "Node",
|
|
326
|
+
"inspector.edge": "Edge",
|
|
327
|
+
"inspector.id": "Id",
|
|
328
|
+
"inspector.label": "Label",
|
|
329
|
+
"inspector.description": "Description",
|
|
330
|
+
"inspector.descriptionHint": "What this step does — for the agent that runs it, and for whoever reads the canvas.",
|
|
331
|
+
"inspector.kind": "Kind",
|
|
332
|
+
"inspector.workflow": "Workflow",
|
|
333
|
+
"inspector.actions": "Actions (JSON)",
|
|
334
|
+
"inspector.deleteNode": "Delete node",
|
|
335
|
+
"inspector.from": "From",
|
|
336
|
+
"inspector.to": "To",
|
|
337
|
+
"inspector.when": "Condition",
|
|
338
|
+
"inspector.deleteEdge": "Delete edge",
|
|
339
|
+
"status.loading": "Loading the blueprint…",
|
|
340
|
+
"status.loadFailed": "Could not load the blueprint.",
|
|
341
|
+
"status.loaded": "Blueprint loaded.",
|
|
342
|
+
"status.newBlueprint": "No journey.json yet — this is the starting template.",
|
|
343
|
+
"status.saving": "Saving…",
|
|
344
|
+
"status.saved": "Saved.",
|
|
345
|
+
"status.saveFailed": "Could not save the blueprint.",
|
|
346
|
+
"status.conflict": "The blueprint changed elsewhere.",
|
|
347
|
+
"conflict.banner": "The agent (or another window) changed this blueprint.",
|
|
348
|
+
"conflict.reload": "Load theirs",
|
|
349
|
+
"toolbar.diagram": "Diagram",
|
|
350
|
+
"toolbar.spec": "Spec",
|
|
351
|
+
"run.start": "Run",
|
|
352
|
+
"run.advance": "Continue",
|
|
353
|
+
"run.cancel": "Stop",
|
|
354
|
+
"run.status": "Run",
|
|
355
|
+
"run.working": "Driving the run…",
|
|
356
|
+
"run.failed": "The run call failed.",
|
|
357
|
+
"run.waiting": "Waiting",
|
|
358
|
+
"run.approve": "Approve",
|
|
359
|
+
"run.reject": "Reject",
|
|
360
|
+
"run.retry": "Retry",
|
|
361
|
+
"spec.hint": "The same document as JSON — edits here are the edits the agent makes.",
|
|
362
|
+
"spec.apply": "Apply",
|
|
363
|
+
"spec.reset": "Reset",
|
|
364
|
+
"spec.notObject": "The spec must be a JSON object.",
|
|
365
|
+
"spec.applied": "Spec applied to the canvas.",
|
|
366
|
+
"status.reloaded": "Blueprint reloaded (changed elsewhere).",
|
|
367
|
+
};
|
|
368
|
+
/** Readable fallback so the panel stays usable before the locale service binds. */
|
|
369
|
+
const GBH_JOURNEY_VI = {
|
|
370
|
+
"view.journey": "Hành trình",
|
|
371
|
+
"toolbar.revision": "Bản sửa đổi blueprint",
|
|
372
|
+
"toolbar.save": "Lưu",
|
|
373
|
+
"toolbar.reload": "Tải lại",
|
|
374
|
+
"toolbar.undo": "Hoàn tác",
|
|
375
|
+
"toolbar.redo": "Làm lại",
|
|
376
|
+
"toolbar.zoomIn": "Phóng to",
|
|
377
|
+
"toolbar.zoomOut": "Thu nhỏ",
|
|
378
|
+
"toolbar.fit": "Vừa khung",
|
|
379
|
+
"toolbar.layout": "Tự xếp",
|
|
380
|
+
"node.outPort": "Kéo để nối",
|
|
381
|
+
"node.inPort": "Thả kết nối vào đây",
|
|
382
|
+
"node.step": "Bước chạy theo thứ tự",
|
|
383
|
+
"node.noDescription": "Chưa có mô tả — agent đọc mô tả này trước khi chạy bước.",
|
|
384
|
+
"inspector.empty": "Chọn một node hoặc edge để sửa.",
|
|
385
|
+
"inspector.node": "Node",
|
|
386
|
+
"inspector.edge": "Edge",
|
|
387
|
+
"inspector.id": "Id",
|
|
388
|
+
"inspector.label": "Nhãn",
|
|
389
|
+
"inspector.description": "Mô tả",
|
|
390
|
+
"inspector.descriptionHint": "Bước này làm gì — cho agent chạy bước, và cho người đọc sơ đồ.",
|
|
391
|
+
"inspector.kind": "Loại",
|
|
392
|
+
"inspector.workflow": "Workflow",
|
|
393
|
+
"inspector.actions": "Hành động (JSON)",
|
|
394
|
+
"inspector.deleteNode": "Xoá node",
|
|
395
|
+
"inspector.from": "Từ",
|
|
396
|
+
"inspector.to": "Đến",
|
|
397
|
+
"inspector.when": "Điều kiện",
|
|
398
|
+
"inspector.deleteEdge": "Xoá edge",
|
|
399
|
+
"status.loading": "Đang tải blueprint…",
|
|
400
|
+
"status.loadFailed": "Không tải được blueprint.",
|
|
401
|
+
"status.loaded": "Đã tải blueprint.",
|
|
402
|
+
"status.newBlueprint": "Chưa có journey.json — đây là mẫu khởi đầu.",
|
|
403
|
+
"status.saving": "Đang lưu…",
|
|
404
|
+
"status.saved": "Đã lưu.",
|
|
405
|
+
"status.saveFailed": "Không lưu được blueprint.",
|
|
406
|
+
"status.conflict": "Blueprint đã bị sửa ở nơi khác.",
|
|
407
|
+
"conflict.banner": "Agent (hoặc cửa sổ khác) vừa sửa blueprint này.",
|
|
408
|
+
"conflict.reload": "Tải bản của họ",
|
|
409
|
+
"toolbar.diagram": "Sơ đồ",
|
|
410
|
+
"toolbar.spec": "Đặc tả",
|
|
411
|
+
"run.start": "Chạy",
|
|
412
|
+
"run.advance": "Chạy tiếp",
|
|
413
|
+
"run.cancel": "Dừng",
|
|
414
|
+
"run.status": "Run",
|
|
415
|
+
"run.working": "Đang chạy hành trình…",
|
|
416
|
+
"run.failed": "Gọi chạy hành trình thất bại.",
|
|
417
|
+
"run.waiting": "Đang chờ",
|
|
418
|
+
"run.approve": "Duyệt",
|
|
419
|
+
"run.reject": "Từ chối",
|
|
420
|
+
"run.retry": "Chạy lại",
|
|
421
|
+
"spec.hint": "Cùng một document ở dạng JSON — sửa ở đây chính là sửa như agent sửa.",
|
|
422
|
+
"spec.apply": "Áp dụng",
|
|
423
|
+
"spec.reset": "Khôi phục",
|
|
424
|
+
"spec.notObject": "Đặc tả phải là một object JSON.",
|
|
425
|
+
"spec.applied": "Đã áp dụng đặc tả vào sơ đồ.",
|
|
426
|
+
"status.reloaded": "Đã tải lại blueprint (bị sửa ở nơi khác).",
|
|
427
|
+
};
|
|
428
|
+
|
|
429
|
+
__JOURNEY_PANEL__
|
|
430
|
+
|
|
431
|
+
/** Locale namespace owned by the Galaxy feedback entry. */
|
|
432
|
+
const GBH_FEEDBACK_NS = "gbh.feedback";
|
|
433
|
+
/** Where the Galaxy feedback entry sends the remark. */
|
|
434
|
+
const GBH_FEEDBACK_EMAIL = "kevinbui210191@gmail.com";
|
|
435
|
+
/** English dictionary for the feedback entry; Vietnamese lives in vi.locales.json. */
|
|
436
|
+
const GBH_FEEDBACK_EN = {
|
|
437
|
+
"action.send": "Send feedback by email",
|
|
438
|
+
"dialog.title": "Send feedback by email",
|
|
439
|
+
"dialog.hint": "The remark opens in your mail app; Galaxy uploads nothing. Attach the conversation log with /export if you want it included.",
|
|
440
|
+
"dialog.category": "Category",
|
|
441
|
+
"dialog.details": "Details",
|
|
442
|
+
"dialog.placeholder": "What happened? What did you expect?",
|
|
443
|
+
"dialog.send": "Open mail app",
|
|
444
|
+
"dialog.save": "Save to session",
|
|
445
|
+
"dialog.cancel": "Cancel",
|
|
446
|
+
"dialog.empty": "Add some details first.",
|
|
447
|
+
"dialog.saving": "Saving…",
|
|
448
|
+
"dialog.saved": "Saved to this session.",
|
|
449
|
+
"dialog.saveFailed": "Could not save to the session.",
|
|
450
|
+
"dialog.mailTo": "Send to {email}",
|
|
451
|
+
"mail.subject": "[Galaxy Blackhole] Feedback — {category}",
|
|
452
|
+
"mail.session": "Session: {id}",
|
|
453
|
+
"mail.title": "Title: {title}",
|
|
454
|
+
"mail.workspace": "Workspace: {cwd}",
|
|
455
|
+
"mail.time": "Time: {time}",
|
|
456
|
+
"mail.note": "Attach the conversation log to this mail if you want it included (/export downloads it as a ZIP).",
|
|
457
|
+
"mail.none": "(none)"
|
|
458
|
+
};
|
|
459
|
+
/** The trash glyph: the header button draws it through React, the row menu injects the same markup. */
|
|
460
|
+
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>';
|
|
461
|
+
|
|
462
|
+
/** Fill a copy template like "Phiên: {id}" without a formatting dependency. */
|
|
463
|
+
function gbhFill(template, values) {
|
|
464
|
+
return String(template).replace(/\{([a-zA-Z][a-zA-Z0-9]*)\}/g, function (match, name) {
|
|
465
|
+
return values[name] === undefined ? match : String(values[name]);
|
|
466
|
+
});
|
|
467
|
+
}
|
|
468
|
+
/** Session facts for the mail body, from the Galaxy session route (best effort). */
|
|
469
|
+
function gbhSessionFacts(sessionId) {
|
|
470
|
+
return fetch(gbhHostBase() + "/api/galaxy/sessions", { credentials: "same-origin" })
|
|
471
|
+
.then(function (response) { return response.json(); })
|
|
472
|
+
.then(function (body) {
|
|
473
|
+
var rows = body && Array.isArray(body.sessions) ? body.sessions : [];
|
|
474
|
+
for (var i = 0; i < rows.length; i += 1) if (rows[i] && rows[i].id === sessionId) return rows[i];
|
|
475
|
+
return {};
|
|
476
|
+
})
|
|
477
|
+
.catch(function () { return {}; });
|
|
478
|
+
}
|
|
479
|
+
/** Build the mailto target and the human-readable body of one remark. */
|
|
480
|
+
function gbhFeedbackMail(input) {
|
|
481
|
+
var t = input.t;
|
|
482
|
+
var facts = input.facts || {};
|
|
483
|
+
var details = String(input.details || "").trim();
|
|
484
|
+
if (details.length > 1800) details = details.slice(0, 1800) + "…";
|
|
485
|
+
var category = input.categoryLabel || "";
|
|
486
|
+
var subject = gbhFill(t("mail.subject"), { category: category.length > 0 ? category : "—" });
|
|
487
|
+
var lines = [];
|
|
488
|
+
if (category.length > 0) lines.push(category);
|
|
489
|
+
if (details.length > 0) lines.push(details);
|
|
490
|
+
lines.push("");
|
|
491
|
+
lines.push("---");
|
|
492
|
+
lines.push(gbhFill(t("mail.session"), { id: input.sessionId }));
|
|
493
|
+
lines.push(gbhFill(t("mail.title"), { title: facts.title || t("mail.none") }));
|
|
494
|
+
lines.push(gbhFill(t("mail.workspace"), { cwd: facts.cwd || t("mail.none") }));
|
|
495
|
+
lines.push(gbhFill(t("mail.time"), { time: new Date().toISOString() }));
|
|
496
|
+
lines.push(t("mail.note"));
|
|
497
|
+
var body = lines.join("\n");
|
|
498
|
+
return {
|
|
499
|
+
subject: subject,
|
|
500
|
+
body: body,
|
|
501
|
+
href: "mailto:" + GBH_FEEDBACK_EMAIL + "?subject=" + encodeURIComponent(subject) + "&body=" + encodeURIComponent(body)
|
|
502
|
+
};
|
|
503
|
+
}
|
|
504
|
+
/** Hand a mailto target to the browser mail client. */
|
|
505
|
+
function gbhOpenMail(href) {
|
|
506
|
+
try {
|
|
507
|
+
var anchor = document.createElement("a");
|
|
508
|
+
anchor.href = href;
|
|
509
|
+
anchor.rel = "noopener";
|
|
510
|
+
document.body.append(anchor);
|
|
511
|
+
anchor.click();
|
|
512
|
+
anchor.remove();
|
|
513
|
+
return true;
|
|
514
|
+
} catch (error) {
|
|
515
|
+
try { globalThis.location.href = href; return true; } catch (inner) { return false; }
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
/**
|
|
519
|
+
* Feedback lives in Settings now: one inline form that either opens the remark in
|
|
520
|
+
* the mail client (nothing leaves the machine before that) or records it in the
|
|
521
|
+
* current Session log through the stock sessionFeedback remote.
|
|
522
|
+
*/
|
|
523
|
+
function GbhFeedbackSection(props) {
|
|
524
|
+
var t = props.t;
|
|
525
|
+
var categoryT = props.categoryT;
|
|
526
|
+
var ctx = props.ctx;
|
|
527
|
+
var CATEGORIES = ["task-result", "instruction-following", "product-interaction", "service-stability", "resource-cost", "security-privacy-permission", "other"];
|
|
528
|
+
var selectedState = react.useState(CATEGORIES[0]);
|
|
529
|
+
var selected = selectedState[0];
|
|
530
|
+
var setSelected = selectedState[1];
|
|
531
|
+
var textState = react.useState("");
|
|
532
|
+
var text = textState[0];
|
|
533
|
+
var setText = textState[1];
|
|
534
|
+
var statusState = react.useState(null);
|
|
535
|
+
var status = statusState[0];
|
|
536
|
+
var setStatus = statusState[1];
|
|
537
|
+
var busyState = react.useState(false);
|
|
538
|
+
var busy = busyState[0];
|
|
539
|
+
var setBusy = busyState[1];
|
|
540
|
+
/* The Settings section is root-scoped, so the Session comes from the live list. */
|
|
541
|
+
var listStore = ctx.sessions && ctx.sessions.list ? ctx.sessions.list : null;
|
|
542
|
+
var current;
|
|
543
|
+
try {
|
|
544
|
+
current = react.useSyncExternalStore(
|
|
545
|
+
function (notify) { return listStore.subscribe(notify); },
|
|
546
|
+
function () { return listStore.getSnapshot(); }
|
|
547
|
+
).current;
|
|
548
|
+
} catch (error) { current = undefined; }
|
|
549
|
+
var chipStyle = function (active) {
|
|
550
|
+
return {
|
|
551
|
+
height: "30px", padding: "0 12px", borderRadius: "15px", fontSize: "12.5px",
|
|
552
|
+
border: "1px solid " + (active ? "#4f7cff" : "rgba(127,127,127,.35)"),
|
|
553
|
+
background: active ? "rgba(79,124,255,.16)" : "transparent", color: "inherit", cursor: "pointer",
|
|
554
|
+
};
|
|
555
|
+
};
|
|
556
|
+
var send = function () {
|
|
557
|
+
var details = text.trim();
|
|
558
|
+
if (details.length === 0) { setStatus({ kind: "error", text: t("dialog.empty") }); return; }
|
|
559
|
+
if (typeof current !== "string" || current.length === 0) { setStatus({ kind: "error", text: t("dialog.noSession") }); return; }
|
|
560
|
+
gbhSessionFacts(current).then(function (facts) {
|
|
561
|
+
var mail = gbhFeedbackMail({ t: t, facts: facts, details: details, categoryLabel: categoryT("category." + selected), sessionId: current });
|
|
562
|
+
if (gbhOpenMail(mail.href)) setStatus({ kind: "ok", text: t("dialog.opened") });
|
|
563
|
+
else setStatus({ kind: "error", text: mail.body });
|
|
564
|
+
});
|
|
565
|
+
};
|
|
566
|
+
var save = function () {
|
|
567
|
+
var details = text.trim();
|
|
568
|
+
if (details.length === 0) { setStatus({ kind: "error", text: t("dialog.empty") }); return; }
|
|
569
|
+
if (typeof current !== "string" || current.length === 0) { setStatus({ kind: "error", text: t("dialog.noSession") }); return; }
|
|
570
|
+
setBusy(true);
|
|
571
|
+
setStatus({ kind: "info", text: t("dialog.saving") });
|
|
572
|
+
Promise.resolve(ctx.remote.sessionFeedback.record({ sessionId: current, text: details, category: selected }))
|
|
573
|
+
.then(function (carried) {
|
|
574
|
+
setBusy(false);
|
|
575
|
+
var ok = carried && carried.ok === true && carried.value && carried.value.ok === true;
|
|
576
|
+
setStatus(ok ? { kind: "ok", text: t("dialog.saved") } : { kind: "error", text: t("dialog.saveFailed") });
|
|
577
|
+
}, function () { setBusy(false); setStatus({ kind: "error", text: t("dialog.saveFailed") }); });
|
|
578
|
+
};
|
|
579
|
+
var statusColor = status === null ? "inherit" : status.kind === "error" ? "#ff8a8a" : status.kind === "ok" ? "#6ddba0" : "var(--dsw-alias-label-secondary, #9aa0a6)";
|
|
580
|
+
return react_jsx_runtime.jsxs("div", {
|
|
581
|
+
"data-gbh-feedback": "settings",
|
|
582
|
+
style: { display: "flex", flexDirection: "column", gap: "10px", maxWidth: "620px" },
|
|
583
|
+
children: [
|
|
584
|
+
react_jsx_runtime.jsx("div", { style: { fontSize: "15px", fontWeight: 600 }, children: t("settings.title") }),
|
|
585
|
+
react_jsx_runtime.jsx("div", { style: { fontSize: "12.5px", lineHeight: "19px", opacity: 0.75 }, children: t("settings.intro") }),
|
|
586
|
+
react_jsx_runtime.jsx("div", {
|
|
587
|
+
style: { display: "flex", flexWrap: "wrap", gap: "8px" },
|
|
588
|
+
children: CATEGORIES.map(function (category) {
|
|
589
|
+
return react_jsx_runtime.jsx("button", {
|
|
590
|
+
type: "button",
|
|
591
|
+
"data-gbh-feedback-category": category,
|
|
592
|
+
onClick: function () { setSelected(category); },
|
|
593
|
+
style: chipStyle(selected === category),
|
|
594
|
+
children: categoryT("category." + category),
|
|
595
|
+
}, category);
|
|
596
|
+
}),
|
|
597
|
+
}),
|
|
598
|
+
react_jsx_runtime.jsx("textarea", {
|
|
599
|
+
"data-gbh-feedback-text": "1",
|
|
600
|
+
value: text,
|
|
601
|
+
placeholder: t("dialog.placeholder"),
|
|
602
|
+
onChange: function (event) { setText(event.target.value); },
|
|
603
|
+
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" },
|
|
604
|
+
}),
|
|
605
|
+
react_jsx_runtime.jsxs("div", { style: { display: "flex", alignItems: "center", gap: "10px", flexWrap: "wrap" }, children: [
|
|
606
|
+
react_jsx_runtime.jsx("button", {
|
|
607
|
+
type: "button", "data-gbh-feedback-send": "1", onClick: send,
|
|
608
|
+
style: { height: "34px", padding: "0 16px", borderRadius: "9px", border: "none", background: "#4f7cff", color: "#fff", cursor: "pointer", fontWeight: 600, fontSize: "13px" },
|
|
609
|
+
children: t("dialog.send"),
|
|
610
|
+
}),
|
|
611
|
+
react_jsx_runtime.jsx("button", {
|
|
612
|
+
type: "button", "data-gbh-feedback-save": "1", onClick: save, disabled: busy,
|
|
613
|
+
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" },
|
|
614
|
+
children: t("dialog.save"),
|
|
615
|
+
}),
|
|
616
|
+
react_jsx_runtime.jsx("span", {
|
|
617
|
+
"data-gbh-feedback-status": status === null ? "idle" : status.kind,
|
|
618
|
+
style: { fontSize: "12px", color: statusColor },
|
|
619
|
+
children: status === null ? t("settings.target") : status.text,
|
|
620
|
+
}),
|
|
621
|
+
] }),
|
|
622
|
+
],
|
|
623
|
+
});
|
|
624
|
+
}
|
|
625
|
+
/**
|
|
626
|
+
* The sidebar row whose more-button was clicked last, and when.
|
|
627
|
+
*
|
|
628
|
+
* The marker is armed only by that button, is consumed by the first menu that appears after it, and
|
|
629
|
+
* expires quickly. It used to be armed by a click anywhere in the row and never cleared, so switching
|
|
630
|
+
* sessions left it set and the permission menu and the model popover inherited the delete entry.
|
|
631
|
+
*/
|
|
632
|
+
var gbhMenuRow;
|
|
633
|
+
var gbhMenuRowAt;
|
|
634
|
+
/** How long an armed marker may wait for its menu. */
|
|
635
|
+
var GBH_MENU_MARKER_MS = 1500;
|
|
636
|
+
/** Client context captured for the injected row-menu entry (session list refresh). */
|
|
637
|
+
var gbhCtx;
|
|
638
|
+
/**
|
|
639
|
+
* Resolve the Session id a sidebar row belongs to.
|
|
640
|
+
*
|
|
641
|
+
* The row markup carries no id, but React keeps its fiber on the DOM node, and the
|
|
642
|
+
* SessionNodeItem fiber holds the Session node as a prop. Walking up a bounded number
|
|
643
|
+
* of fibers keeps this independent of the row markup and of the active language.
|
|
644
|
+
*/
|
|
645
|
+
function gbhRowSessionId(row) {
|
|
646
|
+
var key;
|
|
647
|
+
var keys = Object.keys(row);
|
|
648
|
+
for (var i = 0; i < keys.length; i += 1) if (keys[i].indexOf("__reactFiber$") === 0) { key = keys[i]; break; }
|
|
649
|
+
if (key === undefined) return undefined;
|
|
650
|
+
var fiber = row[key];
|
|
651
|
+
for (var depth = 0; depth < 15 && fiber; depth += 1) {
|
|
652
|
+
var props = fiber.memoizedProps;
|
|
653
|
+
if (props && typeof props.sessionId === "string") return props.sessionId;
|
|
654
|
+
if (props && props.node && typeof props.node.id === "string") return props.node.id;
|
|
655
|
+
fiber = fiber.return;
|
|
656
|
+
}
|
|
657
|
+
return undefined;
|
|
658
|
+
}
|
|
659
|
+
/** True for the sidebar row markup that represents one Session. */
|
|
660
|
+
function gbhIsSessionRow(row) {
|
|
661
|
+
return typeof row.className === "string" && row.className.indexOf("sessionRow") !== -1;
|
|
662
|
+
}
|
|
663
|
+
/** Close a menu the primitives own by asking it to dismiss itself. */
|
|
664
|
+
function gbhDismissMenu(menu) {
|
|
665
|
+
try { menu.dispatchEvent(new KeyboardEvent("keydown", { key: "Escape", bubbles: true })); } catch (error) { /* ignore */ }
|
|
666
|
+
try { document.body.dispatchEvent(new MouseEvent("mousedown", { bubbles: true })); } catch (error) { /* ignore */ }
|
|
667
|
+
}
|
|
668
|
+
/**
|
|
669
|
+
* Add the Galaxy delete entry to an open Session row menu.
|
|
670
|
+
*
|
|
671
|
+
* The stock menu is built inside @deepseek-ai/dsh-client-ui-workspace, which exposes no
|
|
672
|
+
* slot for per-row actions, so the entry is appended next to the last stock item using
|
|
673
|
+
* that item as the styling template. Any uncertainty about which Session the menu owns
|
|
674
|
+
* skips the injection: deleting the wrong Session is far worse than a missing entry.
|
|
675
|
+
*/
|
|
676
|
+
function gbhInjectDeleteMenuItem(sessionsT) {
|
|
677
|
+
var menu = document.querySelector("[role=menu]");
|
|
678
|
+
if (menu === null || menu.querySelector("[data-gbh-menu-delete]") !== null) return;
|
|
679
|
+
/* The first menu after the click consumes the marker, whatever that menu turns out to be. */
|
|
680
|
+
var row = gbhMenuRow;
|
|
681
|
+
var armedAt = gbhMenuRowAt;
|
|
682
|
+
gbhMenuRow = undefined;
|
|
683
|
+
gbhMenuRowAt = undefined;
|
|
684
|
+
if (row === undefined || armedAt === undefined) return;
|
|
685
|
+
if (Date.now() - armedAt > GBH_MENU_MARKER_MS) return;
|
|
686
|
+
if (!document.contains(row) || !gbhIsSessionRow(row)) return;
|
|
687
|
+
var sessionId = gbhRowSessionId(row);
|
|
688
|
+
if (sessionId === undefined) return;
|
|
689
|
+
var items = menu.querySelectorAll("button[role=menuitem]");
|
|
690
|
+
if (items.length === 0) return;
|
|
691
|
+
var template = items[items.length - 1];
|
|
692
|
+
var wrap = template.parentElement;
|
|
693
|
+
var viewport = wrap === null ? null : wrap.parentElement;
|
|
694
|
+
if (wrap === null || viewport === null) return;
|
|
695
|
+
var clone = wrap.cloneNode(true);
|
|
696
|
+
var button = clone.querySelector("button[role=menuitem]");
|
|
697
|
+
if (button === null) return;
|
|
698
|
+
button.setAttribute("data-gbh-menu-delete", "1");
|
|
699
|
+
var label = button.querySelector("[class*=itemLabel]");
|
|
700
|
+
if (label !== null) label.textContent = sessionsT("menu.delete");
|
|
701
|
+
var icon = button.querySelector("[class*=itemIcon]");
|
|
702
|
+
if (icon !== null) icon.innerHTML = GBH_TRASH_SVG;
|
|
703
|
+
button.addEventListener("click", function (event) {
|
|
704
|
+
event.preventDefault();
|
|
705
|
+
event.stopPropagation();
|
|
706
|
+
gbhDismissMenu(menu);
|
|
707
|
+
gbhConfirmDeleteSession(sessionId, sessionsT, function () {}, function () { gbhAfterDelete(sessionId); });
|
|
708
|
+
}, true);
|
|
709
|
+
viewport.append(clone);
|
|
710
|
+
}
|
|
711
|
+
/** Remember the clicked row and watch for row menus the primitives portal into the body. */
|
|
712
|
+
function gbhWatchSessionMenu(ctx, sessionsT) {
|
|
713
|
+
if (typeof document === "undefined" || typeof MutationObserver === "undefined") return;
|
|
714
|
+
document.addEventListener("click", function (event) {
|
|
715
|
+
var target = event.target;
|
|
716
|
+
if (target === null || typeof target.closest !== "function") return;
|
|
717
|
+
var row = target.closest("[role=treeitem]");
|
|
718
|
+
if (row === null || !gbhIsSessionRow(row)) return;
|
|
719
|
+
/* Only the row's own menu button arms the marker: clicking the row switches sessions. */
|
|
720
|
+
var button = target.closest("button");
|
|
721
|
+
if (button === null || button === row) return;
|
|
722
|
+
if (button.getAttribute("aria-haspopup") === null && button.getAttribute("aria-expanded") === null) return;
|
|
723
|
+
gbhMenuRow = row;
|
|
724
|
+
gbhMenuRowAt = Date.now();
|
|
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.
|
|
733
|
+
*/
|
|
734
|
+
var menuProbeScheduled = false;
|
|
735
|
+
function scheduleMenuProbe() {
|
|
736
|
+
if (menuProbeScheduled) return;
|
|
737
|
+
menuProbeScheduled = true;
|
|
738
|
+
setTimeout(function () {
|
|
739
|
+
menuProbeScheduled = false;
|
|
740
|
+
gbhInjectDeleteMenuItem(sessionsT);
|
|
741
|
+
}, 150);
|
|
742
|
+
}
|
|
743
|
+
new MutationObserver(function (mutations) {
|
|
744
|
+
scheduleTidySurfaces();
|
|
745
|
+
for (var i = 0; i < mutations.length; i += 1) {
|
|
746
|
+
var added = mutations[i].addedNodes;
|
|
747
|
+
for (var j = 0; j < added.length; j += 1) {
|
|
748
|
+
var node = added[j];
|
|
749
|
+
if (node === null || node.nodeType !== 1) continue;
|
|
750
|
+
scheduleMenuProbe();
|
|
751
|
+
return;
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
}).observe(document.body, { childList: true, subtree: true });
|
|
755
|
+
}
|
|
756
|
+
/* Tab "Thông tin" trong Cài đặt: tác giả, liên hệ, ảnh Zalo và dòng phiên bản; nút ⤓ chỉ hiện
|
|
757
|
+
khi npm có bản mới và in % ngay trên nút trong lúc cập nhật, xong thì tải lại trang. */
|
|
758
|
+
/*
|
|
759
|
+
* Tab Tinh nang trong Cai dat: hai tinh nang thu nghiem cua DSH. Chung khong nam trong ban dung mac dinh.
|
|
760
|
+
* Bat hay tat o day ghi vao profile, dung cho ma trinh quan ly plugin cua DSH ghi, nen khong can trang do.
|
|
761
|
+
*/
|
|
762
|
+
var GBH_FEATURE_ROWS = [
|
|
763
|
+
{ id: "agentTeams", title: "Agent Teams",
|
|
764
|
+
body: "Nhóm agent cùng làm một việc: danh sách thành viên, hộp thư giữa các agent, và bảng việc chung. " +
|
|
765
|
+
"Bật lên sẽ thay bốn công cụ Subagent hiện có bằng công cụ của nhóm." },
|
|
766
|
+
{ id: "automationTasks", title: "Tác vụ tự động",
|
|
767
|
+
body: "Chạy tác vụ trong phiên của bạn theo giờ đặt trước hoặc theo lịch lặp lại, kèm một trang lịch ở sidebar." },
|
|
768
|
+
];
|
|
769
|
+
|
|
770
|
+
function GbhSwitch(props) {
|
|
771
|
+
return react_jsx_runtime.jsx("button", {
|
|
772
|
+
type: "button",
|
|
773
|
+
role: "switch",
|
|
774
|
+
"aria-checked": props.on === true,
|
|
775
|
+
"aria-label": props.label,
|
|
776
|
+
disabled: props.disabled === true,
|
|
777
|
+
onClick: props.onToggle,
|
|
778
|
+
style: {
|
|
779
|
+
width: "40px", height: "22px", borderRadius: "11px", border: "none", padding: "2px",
|
|
780
|
+
cursor: props.disabled === true ? "default" : "pointer",
|
|
781
|
+
display: "inline-flex", alignItems: "center", flex: "0 0 auto",
|
|
782
|
+
justifyContent: props.on === true ? "flex-end" : "flex-start",
|
|
783
|
+
background: props.on === true ? "var(--dsw-alias-state-business-primary, #4c8dff)" : "rgba(255,255,255,.18)",
|
|
784
|
+
},
|
|
785
|
+
children: react_jsx_runtime.jsx("span", { style: { width: "18px", height: "18px", borderRadius: "50%", background: "#fff", display: "block" } }),
|
|
786
|
+
});
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
function GbhFeaturesSection() {
|
|
790
|
+
const state = react.useState({ loading: true, features: {}, busy: null, error: "" });
|
|
791
|
+
const view = state[0];
|
|
792
|
+
const setView = state[1];
|
|
793
|
+
react.useEffect(function () {
|
|
794
|
+
var alive = true;
|
|
795
|
+
fetch("/api/galaxy/features").then(function (r) { return r.json(); }).then(function (data) {
|
|
796
|
+
if (!alive) return;
|
|
797
|
+
setView(function (p) { return Object.assign({}, p, { loading: false, features: (data && data.features) || {} }); });
|
|
798
|
+
}, function () {
|
|
799
|
+
if (alive) setView(function (p) { return Object.assign({}, p, { loading: false, failed: true, error: "Không đọc được trạng thái tính năng. Nếu bạn vừa cập nhật, hãy khởi động lại blackhole web." }); });
|
|
800
|
+
});
|
|
801
|
+
return function () { alive = false; };
|
|
802
|
+
}, []);
|
|
803
|
+
var toggle = function (row) {
|
|
804
|
+
if (view.busy !== null) return;
|
|
805
|
+
var body = { features: {} };
|
|
806
|
+
body.features[row.id] = !(view.features[row.id] === true);
|
|
807
|
+
setView(function (p) { return Object.assign({}, p, { busy: row.id, error: "" }); });
|
|
808
|
+
fetch("/api/galaxy/features", { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify(body) })
|
|
809
|
+
.then(function (r) { return r.json(); })
|
|
810
|
+
.then(function (data) {
|
|
811
|
+
setView(function (p) { return Object.assign({}, p, { busy: null, features: (data && data.features) || p.features }); });
|
|
812
|
+
}, function () {
|
|
813
|
+
setView(function (p) { return Object.assign({}, p, { busy: null, error: "Không lưu được. Hãy thử lại." }); });
|
|
814
|
+
});
|
|
815
|
+
};
|
|
816
|
+
var rows = GBH_FEATURE_ROWS.map(function (row) {
|
|
817
|
+
return react_jsx_runtime.jsxs("div", {
|
|
818
|
+
key: row.id,
|
|
819
|
+
style: {
|
|
820
|
+
display: "flex", alignItems: "flex-start", gap: "16px", padding: "16px",
|
|
821
|
+
border: "0.5px solid var(--dsw-alias-border-l2, rgba(255,255,255,.12))", borderRadius: "12px",
|
|
822
|
+
},
|
|
823
|
+
children: [react_jsx_runtime.jsxs("div", { style: { flex: "1 1 auto", minWidth: "0" }, children: [
|
|
824
|
+
react_jsx_runtime.jsxs("div", { style: { display: "flex", alignItems: "center", gap: "8px", flexWrap: "wrap" }, children: [
|
|
825
|
+
react_jsx_runtime.jsx("strong", { style: { fontSize: "15px" }, children: row.title }),
|
|
826
|
+
react_jsx_runtime.jsx("span", { style: {
|
|
827
|
+
fontSize: "11px", padding: "2px 8px", borderRadius: "999px",
|
|
828
|
+
background: "rgba(76,141,255,.16)", color: "var(--dsw-alias-label-secondary, #c9d4e6)",
|
|
829
|
+
}, children: "Thử nghiệm" }),
|
|
830
|
+
]}),
|
|
831
|
+
react_jsx_runtime.jsx("p", { style: { margin: "6px 0 0", fontSize: "13px", lineHeight: "20px", color: "var(--dsw-alias-label-secondary, #a9b4c4)" }, children: row.body }),
|
|
832
|
+
]}),
|
|
833
|
+
react_jsx_runtime.jsx(GbhSwitch, { on: view.features[row.id] === true, disabled: view.busy !== null || view.failed === true, label: row.title, onToggle: function () { toggle(row); } }),
|
|
834
|
+
],
|
|
835
|
+
});
|
|
836
|
+
});
|
|
837
|
+
return react_jsx_runtime.jsxs("div", { style: { display: "flex", flexDirection: "column", gap: "12px", maxWidth: "620px" }, children: [
|
|
838
|
+
react_jsx_runtime.jsx("p", { style: { margin: "0 0 4px", fontSize: "13px", color: "var(--dsw-alias-label-secondary, #a9b4c4)" },
|
|
839
|
+
children: view.loading ? "Đang đọc trạng thái…" : "Bật hoặc tắt các tính năng đang thử nghiệm. Thay đổi có hiệu lực từ lần khởi động sau." }),
|
|
840
|
+
rows,
|
|
841
|
+
view.error === "" ? null : react_jsx_runtime.jsx("p", { style: { margin: "0", fontSize: "13px", color: "var(--dsw-alias-state-error-primary, #ff7a7a)" }, children: view.error }),
|
|
842
|
+
]});
|
|
843
|
+
}
|
|
844
|
+
|
|
845
|
+
function GbhInfoSection(props) {
|
|
846
|
+
const version = props.version;
|
|
847
|
+
const zalo = props.zalo;
|
|
848
|
+
const state = react.useState({ latest: null, pct: null, line: "", failed: false });
|
|
849
|
+
const view = state[0];
|
|
850
|
+
const setView = state[1];
|
|
851
|
+
react.useEffect(function () {
|
|
852
|
+
var alive = true;
|
|
853
|
+
fetch("/api/galaxy/version?current=" + encodeURIComponent(version))
|
|
854
|
+
.then(function (response) { return response.json(); })
|
|
855
|
+
.then(function (data) {
|
|
856
|
+
if (!alive || !data || data.hasUpdate !== true || typeof data.latest !== "string") return;
|
|
857
|
+
setView(function (previous) { return Object.assign({}, previous, { latest: data.latest }); });
|
|
858
|
+
}, function () {});
|
|
859
|
+
return function () { alive = false; };
|
|
860
|
+
}, [version]);
|
|
861
|
+
var start = function () {
|
|
862
|
+
if (view.pct !== null) return;
|
|
863
|
+
if (!window.confirm("Cập nhật blackhole lên v" + view.latest + "? Trang sẽ tải lại khi xong.")) return;
|
|
864
|
+
setView(function (previous) { return Object.assign({}, previous, { pct: 0, line: "đang bắt đầu", failed: false }); });
|
|
865
|
+
fetch("/api/galaxy/update", { method: "POST" }).catch(function () {});
|
|
866
|
+
var poll = setInterval(function () {
|
|
867
|
+
fetch("/api/galaxy/update.progress").then(function (response) { return response.json(); }).then(function (data) {
|
|
868
|
+
if (!data) return;
|
|
869
|
+
if (data.done === true) {
|
|
870
|
+
clearInterval(poll);
|
|
871
|
+
if (data.ok === true) window.location.reload();
|
|
872
|
+
else setView(function (previous) { return Object.assign({}, previous, { pct: null, failed: true, line: data.line || "npm lỗi" }); });
|
|
873
|
+
return;
|
|
874
|
+
}
|
|
875
|
+
setView(function (previous) { return Object.assign({}, previous, { pct: data.pct, line: data.line || "" }); });
|
|
876
|
+
}).catch(function () {});
|
|
877
|
+
}, 700);
|
|
878
|
+
};
|
|
879
|
+
var labelStyle = { fontSize: "12.5px", opacity: 0.85 };
|
|
880
|
+
return react_jsx_runtime.jsxs("div", {
|
|
881
|
+
"data-gbh-info": "1",
|
|
882
|
+
style: { display: "flex", flexDirection: "column", gap: "10px", maxWidth: "620px" },
|
|
883
|
+
children: [
|
|
884
|
+
react_jsx_runtime.jsxs("div", { style: { display: "flex", alignItems: "center", gap: "10px" }, children: [
|
|
885
|
+
react_jsx_runtime.jsx("div", { style: { fontSize: "15px", fontWeight: 600 }, children: "Thông tin" }),
|
|
886
|
+
view.latest === null ? null : react_jsx_runtime.jsx("button", {
|
|
887
|
+
type: "button",
|
|
888
|
+
"data-gbh-update": "1",
|
|
889
|
+
onClick: start,
|
|
890
|
+
style: { cursor: "pointer" },
|
|
891
|
+
children: view.pct === null ? "⤓ Tải v" + view.latest : view.pct + "%"
|
|
892
|
+
})
|
|
893
|
+
] }),
|
|
894
|
+
react_jsx_runtime.jsx("div", { style: labelStyle, children: "Tác giả: Bùi Trọng Hiếu" }),
|
|
895
|
+
react_jsx_runtime.jsx("div", { style: labelStyle, children: "Email: kevinbui210191@gmail.com" }),
|
|
896
|
+
react_jsx_runtime.jsxs("div", { style: labelStyle, children: ["Website: ", react_jsx_runtime.jsx("a", { href: "https://galaxy-blackhole.vercel.app/", target: "_blank", rel: "noreferrer", style: { color: "#8ab4ff" }, children: "https://galaxy-blackhole.vercel.app/" })] }),
|
|
897
|
+
react_jsx_runtime.jsx("img", { src: zalo, alt: "Zalo", style: { width: "200px", borderRadius: "10px" } }),
|
|
898
|
+
react_jsx_runtime.jsx("div", { style: { fontSize: "12.5px", opacity: 0.9 }, children: "Phiên bản: v" + version + " (phiên bản hiện tại)" + (view.latest === null ? "" : " → v" + view.latest + " (phiên bản trên npm)") }),
|
|
899
|
+
view.pct === null ? null : react_jsx_runtime.jsx("div", { style: { fontSize: "12px", opacity: 0.75 }, children: "Đang cập nhật: " + view.pct + "%" + (view.line ? " · " + view.line : "") }),
|
|
900
|
+
view.failed ? react_jsx_runtime.jsx("div", { style: { fontSize: "12px", color: "#ff8a8a" }, children: "Cập nhật thất bại: " + view.line }) : null
|
|
901
|
+
]
|
|
902
|
+
});
|
|
903
|
+
}
|
|
904
|
+
|
|
905
|
+
const inject = ["slots", "locale", "remote", "remote.credentials", "remote.sessionFeedback", "sessions"];
|
|
906
|
+
/*
|
|
907
|
+
* DSH draws its own animated whale for the running Chat status. The slots it exposes cover the sidebar and
|
|
908
|
+
* the hero mark, not that indicator, so the only honest way to stop showing another product's mascot next
|
|
909
|
+
* to our copy is a rule. The class hash changes between builds, so match the stable part of the name.
|
|
910
|
+
*/
|
|
911
|
+
function hideDshMascot() {
|
|
912
|
+
try {
|
|
913
|
+
if (document.getElementById("gbh-hide-dsh-mascot") !== null) return;
|
|
914
|
+
var style = document.createElement("style");
|
|
915
|
+
style.id = "gbh-hide-dsh-mascot";
|
|
916
|
+
style.textContent = [
|
|
917
|
+
'[class*="runningWhale"]{display:none !important}',
|
|
918
|
+
/* The preset card's view affordance is an icon carrying its label in data-tip/aria-label rather than in
|
|
919
|
+
text, so a rule on those attributes survives the re-renders an inline style does not. */
|
|
920
|
+
'[data-tip="Xem"],[data-tip="View"],[aria-label^="Xem:"],[aria-label^="View:"]{display:none !important}',
|
|
921
|
+
/* Rows the brand marks for removal; the attribute survives a re-render better than an inline style. */
|
|
922
|
+
"[data-gbh-hidden]{display:none !important}",
|
|
923
|
+
/* DSH marks the rows a plugin page is built from, so these need no scripting and cannot flicker. */
|
|
924
|
+
'[class*="_versionTag"]{display:none !important}',
|
|
925
|
+
'code[data-plugin-name="true"]{display:none !important}',
|
|
926
|
+
'section[data-plugin-rows="true"]{display:none !important}',
|
|
927
|
+
/*
|
|
928
|
+
* The stock provider editor offers a 'Customized settings' disclosure, and DSH opens it for a frame while a
|
|
929
|
+
* route loads. A stylesheet applies from the first paint, which no script-driven hide can promise, so this
|
|
930
|
+
* is a rule rather than a marker. The add-provider surfaces keep the disclosure.
|
|
931
|
+
*/
|
|
932
|
+
'[class*="_customized"]{display:none !important}',
|
|
933
|
+
'[class*="_addCard"] [class*="_customized"],[class*="_addPanel"] [class*="_customized"],' +
|
|
934
|
+
'[class*="_addBlock"] [class*="_customized"],[class*="_setupCard"] [class*="_customized"]{display:revert !important}',
|
|
935
|
+
].join("\n");
|
|
936
|
+
document.head.appendChild(style);
|
|
937
|
+
} catch (error) { /* A page without a head must not break the rest of the brand. */ }
|
|
938
|
+
}
|
|
939
|
+
|
|
940
|
+
/*
|
|
941
|
+
* Two small corrections to the stock settings surfaces.
|
|
942
|
+
*
|
|
943
|
+
* 1. The General page prints DSH's own version. This product is Galaxy Blackhole, so the line shows the
|
|
944
|
+
* version of the client the user actually installed.
|
|
945
|
+
* 2. A preset card carries a 'Xem' button that opens the same guide the card already links to; the card and
|
|
946
|
+
* the guide are one surface here, so the extra button is noise.
|
|
947
|
+
*
|
|
948
|
+
* Both run on a debounced observer because the settings panel mounts long after the brand is applied.
|
|
949
|
+
*/
|
|
950
|
+
|
|
951
|
+
|
|
952
|
+
function tidySettingsSurfaces() {
|
|
953
|
+
try {
|
|
954
|
+
var nodes = document.querySelectorAll("div, span, p, li");
|
|
955
|
+
for (var i = 0; i < nodes.length; i += 1) {
|
|
956
|
+
var node = nodes[i];
|
|
957
|
+
if (node.children.length !== 0) continue;
|
|
958
|
+
var text = node.textContent || "";
|
|
959
|
+
if (text.indexOf("Phiên bản hiện tại:") === 0 || text.indexOf("Current version:") === 0) {
|
|
960
|
+
var label = text.indexOf("Current version:") === 0 ? "Current version: " : "Phiên bản hiện tại: ";
|
|
961
|
+
node.textContent = label + CLI_VERSION;
|
|
962
|
+
continue;
|
|
963
|
+
}
|
|
964
|
+
/*
|
|
965
|
+
* The session-log upload setting writes its own copy straight into the bundle instead of going through the
|
|
966
|
+
* dictionary, so it needs a rewrite here. The product is Galaxy, so its wording names Galaxy too.
|
|
967
|
+
*/
|
|
968
|
+
if (text === "Upload Session Log when using the official model API") {
|
|
969
|
+
node.textContent = "Tải log phiên lên khi dùng API model chính thức";
|
|
970
|
+
continue;
|
|
971
|
+
}
|
|
972
|
+
if (text === "Help improve DeepSeek models and products.") {
|
|
973
|
+
node.textContent = "Giúp cải thiện model và sản phẩm Galaxy.";
|
|
974
|
+
continue;
|
|
975
|
+
}
|
|
976
|
+
/* The module row names an internal npm package; it is the one line there a user cannot act on. */
|
|
977
|
+
if (text === "Mô-đun" || text === "Module") {
|
|
978
|
+
var row = node.parentElement;
|
|
979
|
+
if (row !== null) row.setAttribute("data-gbh-hidden", "");
|
|
980
|
+
}
|
|
981
|
+
}
|
|
982
|
+
|
|
983
|
+
} catch (error) { /* A DOM we do not recognise must not break the brand. */ }
|
|
984
|
+
}
|
|
985
|
+
|
|
986
|
+
/* The disclosure is hidden by a stylesheet rule; no marker pass exists any more. */
|
|
987
|
+
|
|
988
|
+
/*
|
|
989
|
+
* The row-menu probe already observes the document, so this rides on it: a second observer would be one
|
|
990
|
+
* more thing watching every mutation, and the brand is supposed to stay the only two it has.
|
|
991
|
+
*/
|
|
992
|
+
var tidyScheduled = false;
|
|
993
|
+
function scheduleTidySurfaces() {
|
|
994
|
+
if (tidyScheduled) return;
|
|
995
|
+
tidyScheduled = true;
|
|
996
|
+
setTimeout(function () {
|
|
997
|
+
tidyScheduled = false;
|
|
998
|
+
tidySettingsSurfaces();
|
|
999
|
+
}, 250);
|
|
1000
|
+
}
|
|
1001
|
+
|
|
1002
|
+
function apply(ctx) {
|
|
1003
|
+
hideDshMascot();
|
|
1004
|
+
tidySettingsSurfaces();
|
|
1005
|
+
ctx.slots.inject("sidebar.brand.mark", () => ctx.slots.inject("sidebar.brand.name", function* () {
|
|
1006
|
+
yield ctx.slots.register({ name: "sidebar.brand.mark" }, GbhBrandMark);
|
|
1007
|
+
yield ctx.slots.register({ name: "sidebar.brand.name" }, GbhBrandName);
|
|
1008
|
+
}));
|
|
1009
|
+
ctx.slots.inject("conversation.hero.brand.mark", () => ctx.slots.register({ name: "conversation.hero.brand.mark" }, GbhBrandMark));
|
|
1010
|
+
/* Session tools: delete the open session through the Galaxy Host route. */
|
|
1011
|
+
ctx.slots.inject("conversation.session.header.utilities", function () {
|
|
1012
|
+
return ctx.slots.register({
|
|
1013
|
+
name: "conversation.session.header.utilities",
|
|
1014
|
+
id: "gbh-session-delete",
|
|
1015
|
+
order: 50,
|
|
1016
|
+
locale: GBH_SESSIONS_NS,
|
|
1017
|
+
inject: function () { return {}; }
|
|
1018
|
+
}, GbhDeleteSessionAction);
|
|
1019
|
+
});
|
|
1020
|
+
/* Tab Thong tin trong Cai dat, cung khuon voi tab Model/Chung cua DSH. */
|
|
1021
|
+
ctx.slots.inject("settings.section", function () {
|
|
1022
|
+
return ctx.slots.register({
|
|
1023
|
+
name: "settings.section",
|
|
1024
|
+
id: "gbh-info",
|
|
1025
|
+
order: 70,
|
|
1026
|
+
locale: GBH_FEEDBACK_NS,
|
|
1027
|
+
label: function () { return "Thông tin"; },
|
|
1028
|
+
inject: function () { return { version: CLI_VERSION, zalo: ZALO }; }
|
|
1029
|
+
}, GbhInfoSection);
|
|
1030
|
+
});
|
|
1031
|
+
/* Tab Tinh nang: bat/tat hai tinh nang thu nghiem cua DSH ngay trong Cai dat. */
|
|
1032
|
+
ctx.slots.inject("settings.section", function () {
|
|
1033
|
+
return ctx.slots.register({
|
|
1034
|
+
name: "settings.section",
|
|
1035
|
+
id: "gbh-features",
|
|
1036
|
+
order: 65,
|
|
1037
|
+
label: function () { return "Tính năng"; },
|
|
1038
|
+
inject: function () { return {}; }
|
|
1039
|
+
}, GbhFeaturesSection);
|
|
1040
|
+
});
|
|
1041
|
+
/* Row menus: the stock Session menu exposes no slot, so the entry is injected on open. */
|
|
1042
|
+
var sessionsT = function (key) { return key; };
|
|
1043
|
+
try { sessionsT = ctx.locale.bind(GBH_SESSIONS_NS); } catch (error) { /* the namespace registers just above */ }
|
|
1044
|
+
gbhCtx = ctx;
|
|
1045
|
+
gbhWatchSessionMenu(ctx, sessionsT);
|
|
1046
|
+
/* Journey: the n8n-style blueprint canvas, seated next to Trajectory. */
|
|
1047
|
+
var journeyTranslator = function (key) { return key; };
|
|
1048
|
+
try { journeyTranslator = ctx.locale.bind(GBH_JOURNEY_NS); } catch (error) { /* the namespace registers just above */ }
|
|
1049
|
+
var journeyT = function (key) {
|
|
1050
|
+
try {
|
|
1051
|
+
var value = journeyTranslator(key);
|
|
1052
|
+
if (typeof value === "string" && value !== key) return value;
|
|
1053
|
+
} catch (error) { /* fall through to the built-in copy */ }
|
|
1054
|
+
return GBH_JOURNEY_VI[key] !== undefined ? GBH_JOURNEY_VI[key] : key;
|
|
1055
|
+
};
|
|
1056
|
+
var journeyApi = {
|
|
1057
|
+
load: function (sessionId) {
|
|
1058
|
+
return fetch(gbhHostBase() + "/api/galaxy/journey?sessionId=" + encodeURIComponent(sessionId), { credentials: "same-origin" })
|
|
1059
|
+
.then(function (response) { return response.json().catch(function () { return { ok: false, message: "HTTP " + response.status }; }); })
|
|
1060
|
+
.catch(function (error) { return { ok: false, message: String(error) }; });
|
|
1061
|
+
},
|
|
1062
|
+
run: function (sessionId, payload) {
|
|
1063
|
+
return fetch(gbhHostBase() + "/api/galaxy/journey.run", {
|
|
1064
|
+
method: "POST",
|
|
1065
|
+
headers: { "content-type": "application/json" },
|
|
1066
|
+
credentials: "same-origin",
|
|
1067
|
+
body: JSON.stringify({ sessionId: sessionId, updatedBy: "human", ...(payload || {}) })
|
|
1068
|
+
})
|
|
1069
|
+
.then(function (response) { return response.json().catch(function () { return { ok: false, message: "HTTP " + response.status }; }); })
|
|
1070
|
+
.catch(function (error) { return { ok: false, message: String(error) }; });
|
|
1071
|
+
},
|
|
1072
|
+
save: function (sessionId, document, expectedRevision) {
|
|
1073
|
+
return fetch(gbhHostBase() + "/api/galaxy/journey", {
|
|
1074
|
+
method: "POST",
|
|
1075
|
+
headers: { "content-type": "application/json" },
|
|
1076
|
+
credentials: "same-origin",
|
|
1077
|
+
body: JSON.stringify({ sessionId: sessionId, document: document, expectedRevision: expectedRevision, updatedBy: "human" })
|
|
1078
|
+
})
|
|
1079
|
+
.then(function (response) { return response.json().catch(function () { return { ok: false, message: "HTTP " + response.status }; }); })
|
|
1080
|
+
.catch(function (error) { return { ok: false, message: String(error) }; });
|
|
1081
|
+
}
|
|
1082
|
+
};
|
|
1083
|
+
var journeyPanel = createJourneyPanel({
|
|
1084
|
+
react: react,
|
|
1085
|
+
jsx: react_jsx_runtime.jsx,
|
|
1086
|
+
jsxs: react_jsx_runtime.jsxs,
|
|
1087
|
+
primitives: primitives,
|
|
1088
|
+
t: journeyT,
|
|
1089
|
+
api: journeyApi
|
|
1090
|
+
});
|
|
1091
|
+
/*
|
|
1092
|
+
* The journey panel is still being built, and a release should not carry a surface that is not finished. The
|
|
1093
|
+
* code below stays whole; flip this to true to seat it back on the conversation view.
|
|
1094
|
+
*/
|
|
1095
|
+
var GBH_JOURNEY_ENABLED = false;
|
|
1096
|
+
if (GBH_JOURNEY_ENABLED) ctx.slots.inject("conversation.view", function () {
|
|
1097
|
+
return ctx.slots.register({
|
|
1098
|
+
name: "conversation.view",
|
|
1099
|
+
id: "journey",
|
|
1100
|
+
order: 20,
|
|
1101
|
+
locale: GBH_JOURNEY_NS,
|
|
1102
|
+
label: function () { return journeyT("view.journey"); },
|
|
1103
|
+
inject: function (sessionId) { return { sessionId: sessionId, api: journeyApi, t: journeyT }; }
|
|
1104
|
+
}, journeyPanel.JourneyPanel);
|
|
1105
|
+
});
|
|
1106
|
+
/*
|
|
1107
|
+
* Nothing seats in the session header for feedback. Feedback is a Settings section now, and the header
|
|
1108
|
+
* action this call site used to pass was renamed out from under it: the name was never defined, so the
|
|
1109
|
+
* throw landed inside the entry's activation and the GUI booted into "Failed to load plugins".
|
|
1110
|
+
* GbhFeedbackSection is the live surface; it has no header face.
|
|
1111
|
+
*/
|
|
1112
|
+
try {
|
|
1113
|
+
ctx.locale.addLanguage({ id: "vi", label: "Tiếng Việt", fallback: "en" });
|
|
1114
|
+
} catch (error) {
|
|
1115
|
+
/* the language may already be registered on a plugin reload */
|
|
1116
|
+
}
|
|
1117
|
+
/* Galaxy-owned namespaces ship both dictionaries: English here, Vietnamese in vi.locales.json. */
|
|
1118
|
+
const ownDictionaries = {};
|
|
1119
|
+
ownDictionaries[GBH_SESSIONS_NS] = GBH_SESSIONS_EN;
|
|
1120
|
+
ownDictionaries[GBH_FEEDBACK_NS] = GBH_FEEDBACK_EN;
|
|
1121
|
+
ownDictionaries[GBH_JOURNEY_NS] = GBH_JOURNEY_EN;
|
|
1122
|
+
const namespaces = Object.keys(VI_LOCALES);
|
|
1123
|
+
for (let i = 0; i < namespaces.length; i += 1) {
|
|
1124
|
+
const ns = namespaces[i];
|
|
1125
|
+
/* A Galaxy-owned namespace registers both dictionaries in one call below. */
|
|
1126
|
+
if (ownDictionaries[ns] !== undefined) continue;
|
|
1127
|
+
try {
|
|
1128
|
+
ctx.locale.register(ns, "vi", VI_LOCALES[ns]);
|
|
1129
|
+
} catch (error) {
|
|
1130
|
+
/* a namespace may already carry vi on a reload */
|
|
1131
|
+
}
|
|
1132
|
+
}
|
|
1133
|
+
const ownNames = Object.keys(ownDictionaries);
|
|
1134
|
+
for (let i = 0; i < ownNames.length; i += 1) {
|
|
1135
|
+
const ns = ownNames[i];
|
|
1136
|
+
try {
|
|
1137
|
+
ctx.locale.register(ns, { en: ownDictionaries[ns], vi: VI_LOCALES[ns] });
|
|
1138
|
+
} catch (error) {
|
|
1139
|
+
/* the namespace may already be registered on a plugin reload */
|
|
1140
|
+
}
|
|
1141
|
+
}
|
|
1142
|
+
/* Replace the shipped internal-testing notice with the Galaxy description,
|
|
1143
|
+
including the English copy, by editing the registered dictionaries. */
|
|
1144
|
+
try {
|
|
1145
|
+
const dicts = ctx.locale.dicts;
|
|
1146
|
+
if (dicts && typeof dicts.get === "function") {
|
|
1147
|
+
const overridden = Object.keys(EN_OVERRIDES);
|
|
1148
|
+
for (let i = 0; i < overridden.length; i += 1) {
|
|
1149
|
+
const ns = overridden[i];
|
|
1150
|
+
const localeMap = dicts.get(ns);
|
|
1151
|
+
if (!localeMap || typeof localeMap.get !== "function") continue;
|
|
1152
|
+
const current = localeMap.get("en");
|
|
1153
|
+
if (current) localeMap.set("en", Object.assign({}, current, EN_OVERRIDES[ns]));
|
|
1154
|
+
}
|
|
1155
|
+
}
|
|
1156
|
+
} catch (error) {
|
|
1157
|
+
/* dictionary override is best-effort */
|
|
1158
|
+
}
|
|
1159
|
+
/* The composer keeps the stock model/effort chip; Galaxy no longer seats a
|
|
1160
|
+
second effort control there (it duplicated the chip and rendered empty
|
|
1161
|
+
for a provider that declares its efforts as a map). */
|
|
1162
|
+
ensureGalaxyKey(ctx);
|
|
1163
|
+
watchContextSources();
|
|
1164
|
+
}
|
|
1165
|
+
/* "Thông tin" cạnh khối Cài đặt: tác giả, email, website, ảnh Zalo và dòng phiên bản; nút ⤓
|
|
1166
|
+
chỉ hiện khi npm có bản mới và in % ngay trên nút trong lúc npm chạy, xong thì tải lại trang.
|
|
1167
|
+
Thuần DOM trên khối settings có sẵn, nên không đụng vào cây React của bảng điều khiển. */
|
|
1168
|
+
function installGalaxyInfoPanel() {
|
|
1169
|
+
if (typeof document === "undefined") return;
|
|
1170
|
+
var attempts = 0;
|
|
1171
|
+
var timer = setInterval(function () {
|
|
1172
|
+
attempts += 1;
|
|
1173
|
+
/* The panel belongs in the Settings dialog the user opens, which the dashboard renders as a
|
|
1174
|
+
dialog; the Galaxy feedback block stays as a fallback for builds without it. */
|
|
1175
|
+
var host = document.querySelector('[data-gbh-feedback="settings"]');
|
|
1176
|
+
if (host === null) {
|
|
1177
|
+
var dialogs = document.querySelectorAll('[role="dialog"], dialog');
|
|
1178
|
+
for (var i = 0; i < dialogs.length; i += 1) {
|
|
1179
|
+
var text = dialogs[i].textContent || "";
|
|
1180
|
+
if (text.indexOf("Cài đặt") !== -1 || text.indexOf("Settings") !== -1) { host = dialogs[i]; break; }
|
|
1181
|
+
}
|
|
1182
|
+
}
|
|
1183
|
+
if (host === null) { if (attempts > 240) clearInterval(timer); return; }
|
|
1184
|
+
if (host.querySelector('[data-gbh-info="1"]') !== null) { clearInterval(timer); return; }
|
|
1185
|
+
clearInterval(timer);
|
|
1186
|
+
var box = document.createElement("div");
|
|
1187
|
+
box.setAttribute("data-gbh-info", "1");
|
|
1188
|
+
box.style.cssText = "display:flex;flex-direction:column;gap:6px;padding:10px;border:1px solid rgba(255,255,255,0.14);border-radius:10px;max-width:620px";
|
|
1189
|
+
var row = document.createElement("div");
|
|
1190
|
+
row.style.cssText = "display:flex;align-items:center;gap:10px";
|
|
1191
|
+
var title = document.createElement("div");
|
|
1192
|
+
title.textContent = "Thông tin";
|
|
1193
|
+
title.style.cssText = "font-size:14px;font-weight:600";
|
|
1194
|
+
row.appendChild(title);
|
|
1195
|
+
var button = document.createElement("button");
|
|
1196
|
+
button.type = "button";
|
|
1197
|
+
button.setAttribute("data-gbh-update", "1");
|
|
1198
|
+
button.style.cssText = "display:none;align-items:center;gap:6px;cursor:pointer";
|
|
1199
|
+
row.appendChild(button);
|
|
1200
|
+
box.appendChild(row);
|
|
1201
|
+
["Tác giả: Bùi Trọng Hiếu", "Email: kevinbui210191@gmail.com", "Website: https://galaxy-blackhole.vercel.app/"].forEach(function (text) {
|
|
1202
|
+
var line = document.createElement("div");
|
|
1203
|
+
line.textContent = text;
|
|
1204
|
+
line.style.cssText = "font-size:12.5px;opacity:0.8";
|
|
1205
|
+
box.appendChild(line);
|
|
1206
|
+
});
|
|
1207
|
+
var zalo = document.createElement("img");
|
|
1208
|
+
zalo.src = __ZALO_DATA_URI__;
|
|
1209
|
+
zalo.alt = "Zalo";
|
|
1210
|
+
zalo.style.cssText = "width:180px;border-radius:10px";
|
|
1211
|
+
box.appendChild(zalo);
|
|
1212
|
+
var version = document.createElement("div");
|
|
1213
|
+
version.style.cssText = "font-size:12.5px;opacity:0.9";
|
|
1214
|
+
version.textContent = "Phiên bản: v" + __CLI_VERSION__ + " (phiên bản hiện tại)";
|
|
1215
|
+
box.appendChild(version);
|
|
1216
|
+
var progress = document.createElement("div");
|
|
1217
|
+
progress.style.cssText = "font-size:12px;opacity:0.75;display:none";
|
|
1218
|
+
box.appendChild(progress);
|
|
1219
|
+
host.appendChild(box);
|
|
1220
|
+
fetch("/api/galaxy/version?current=" + encodeURIComponent(__CLI_VERSION__))
|
|
1221
|
+
.then(function (response) { return response.json(); })
|
|
1222
|
+
.then(function (data) {
|
|
1223
|
+
if (!data || data.hasUpdate !== true || typeof data.latest !== "string") return;
|
|
1224
|
+
var latest = data.latest;
|
|
1225
|
+
version.textContent = "Phiên bản: v" + __CLI_VERSION__ + " (phiên bản hiện tại) → v" + latest + " (phiên bản trên npm)";
|
|
1226
|
+
button.style.display = "flex";
|
|
1227
|
+
button.textContent = "⤓ Tải v" + latest;
|
|
1228
|
+
button.addEventListener("click", function () {
|
|
1229
|
+
if (button.disabled) return;
|
|
1230
|
+
if (!window.confirm("Cập nhật blackhole lên v" + latest + "? Trang sẽ tải lại khi xong.")) return;
|
|
1231
|
+
button.disabled = true;
|
|
1232
|
+
button.textContent = "0%";
|
|
1233
|
+
progress.style.display = "block";
|
|
1234
|
+
progress.textContent = "Đang cập nhật…";
|
|
1235
|
+
fetch("/api/galaxy/update", { method: "POST" }).catch(function () {});
|
|
1236
|
+
var poll = setInterval(function () {
|
|
1237
|
+
fetch("/api/galaxy/update.progress").then(function (response) { return response.json(); }).then(function (data) {
|
|
1238
|
+
if (!data) return;
|
|
1239
|
+
var pct = typeof data.pct === "number" ? data.pct : 0;
|
|
1240
|
+
button.textContent = pct + "%";
|
|
1241
|
+
progress.textContent = "Đang cập nhật: " + pct + "%" + (data.line ? " · " + data.line : "");
|
|
1242
|
+
if (data.done === true) {
|
|
1243
|
+
clearInterval(poll);
|
|
1244
|
+
button.textContent = data.ok === true ? "✓ xong" : "✗ lỗi";
|
|
1245
|
+
if (data.ok === true) window.location.reload();
|
|
1246
|
+
else { button.disabled = false; button.textContent = "⤓ thử lại"; progress.textContent = "Cập nhật thất bại: " + (data.line || "npm lỗi"); }
|
|
1247
|
+
}
|
|
1248
|
+
}).catch(function () {});
|
|
1249
|
+
}, 700);
|
|
1250
|
+
});
|
|
1251
|
+
})
|
|
1252
|
+
.catch(function () {});
|
|
1253
|
+
}, 500);
|
|
1254
|
+
}
|
|
1255
|
+
exports.apply = apply;
|
|
1256
|
+
exports.inject = inject;
|
|
1257
|
+
return module.exports;
|
|
1258
|
+
}
|
|
1259
|
+
});
|