@galaxy-stack/blackhole-cli 2.4.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +78 -47
- package/dist/application.d.ts.map +1 -1
- package/dist/application.js +13 -2
- package/dist/application.js.map +1 -1
- package/dist/cli-meta.d.ts +8 -0
- package/dist/cli-meta.d.ts.map +1 -1
- package/dist/cli-meta.js +11 -0
- package/dist/cli-meta.js.map +1 -1
- package/dist/cli.js +26 -9
- package/dist/cli.js.map +1 -1
- package/dist/config-command.d.ts +11 -14
- package/dist/config-command.d.ts.map +1 -1
- package/dist/config-command.js +41 -118
- package/dist/config-command.js.map +1 -1
- package/dist/doctor.d.ts +8 -2
- package/dist/doctor.d.ts.map +1 -1
- package/dist/doctor.js +11 -15
- package/dist/doctor.js.map +1 -1
- package/dist/file-index.d.ts +50 -0
- package/dist/file-index.d.ts.map +1 -1
- package/dist/file-index.js +124 -0
- package/dist/file-index.js.map +1 -1
- package/dist/harness/boot.d.ts +87 -0
- package/dist/harness/boot.d.ts.map +1 -0
- package/dist/harness/boot.js +111 -0
- package/dist/harness/boot.js.map +1 -0
- package/dist/harness/catalogs.d.ts +50 -0
- package/dist/harness/catalogs.d.ts.map +1 -0
- package/dist/harness/catalogs.js +34 -0
- package/dist/harness/catalogs.js.map +1 -0
- package/dist/harness/chat.d.ts +90 -0
- package/dist/harness/chat.d.ts.map +1 -0
- package/dist/harness/chat.js +260 -0
- package/dist/harness/chat.js.map +1 -0
- package/dist/harness/client.d.ts +72 -0
- package/dist/harness/client.d.ts.map +1 -0
- package/dist/harness/client.js +173 -0
- package/dist/harness/client.js.map +1 -0
- package/dist/harness/command.d.ts +22 -0
- package/dist/harness/command.d.ts.map +1 -0
- package/dist/harness/command.js +142 -0
- package/dist/harness/command.js.map +1 -0
- package/dist/harness/composer.d.ts +46 -0
- package/dist/harness/composer.d.ts.map +1 -0
- package/dist/harness/composer.js +127 -0
- package/dist/harness/composer.js.map +1 -0
- package/dist/harness/conversation.d.ts +75 -0
- package/dist/harness/conversation.d.ts.map +1 -0
- package/dist/harness/conversation.js +196 -0
- package/dist/harness/conversation.js.map +1 -0
- package/dist/harness/help.d.ts +56 -0
- package/dist/harness/help.d.ts.map +1 -0
- package/dist/harness/help.js +85 -0
- package/dist/harness/help.js.map +1 -0
- package/dist/harness/history.d.ts +108 -0
- package/dist/harness/history.d.ts.map +1 -0
- package/dist/harness/history.js +268 -0
- package/dist/harness/history.js.map +1 -0
- package/dist/harness/labels.d.ts +164 -0
- package/dist/harness/labels.d.ts.map +1 -0
- package/dist/harness/labels.js +271 -0
- package/dist/harness/labels.js.map +1 -0
- package/dist/harness/locate.d.ts +24 -0
- package/dist/harness/locate.d.ts.map +1 -0
- package/dist/harness/locate.js +69 -0
- package/dist/harness/locate.js.map +1 -0
- package/dist/harness/menus.d.ts +74 -0
- package/dist/harness/menus.d.ts.map +1 -0
- package/dist/harness/menus.js +140 -0
- package/dist/harness/menus.js.map +1 -0
- package/dist/harness/model-name.d.ts +73 -0
- package/dist/harness/model-name.d.ts.map +1 -0
- package/dist/harness/model-name.js +101 -0
- package/dist/harness/model-name.js.map +1 -0
- package/dist/harness/parts.d.ts +239 -0
- package/dist/harness/parts.d.ts.map +1 -0
- package/dist/harness/parts.js +266 -0
- package/dist/harness/parts.js.map +1 -0
- package/dist/harness/preset.d.ts +124 -0
- package/dist/harness/preset.d.ts.map +1 -0
- package/dist/harness/preset.js +197 -0
- package/dist/harness/preset.js.map +1 -0
- package/dist/harness/process.d.ts +55 -0
- package/dist/harness/process.d.ts.map +1 -0
- package/dist/harness/process.js +119 -0
- package/dist/harness/process.js.map +1 -0
- package/dist/harness/screen.d.ts +33 -0
- package/dist/harness/screen.d.ts.map +1 -0
- package/dist/harness/screen.js +1070 -0
- package/dist/harness/screen.js.map +1 -0
- package/dist/harness/sessions.d.ts +55 -0
- package/dist/harness/sessions.d.ts.map +1 -0
- package/dist/harness/sessions.js +92 -0
- package/dist/harness/sessions.js.map +1 -0
- package/dist/harness/skills.d.ts +90 -0
- package/dist/harness/skills.d.ts.map +1 -0
- package/dist/harness/skills.js +133 -0
- package/dist/harness/skills.js.map +1 -0
- package/dist/harness/slash-palette.d.ts +32 -0
- package/dist/harness/slash-palette.d.ts.map +1 -0
- package/dist/harness/slash-palette.js +48 -0
- package/dist/harness/slash-palette.js.map +1 -0
- package/dist/harness/slash.d.ts +113 -0
- package/dist/harness/slash.d.ts.map +1 -0
- package/dist/harness/slash.js +187 -0
- package/dist/harness/slash.js.map +1 -0
- package/dist/harness/trajectory.d.ts +74 -0
- package/dist/harness/trajectory.d.ts.map +1 -0
- package/dist/harness/trajectory.js +270 -0
- package/dist/harness/trajectory.js.map +1 -0
- package/dist/harness/tui.d.ts +28 -0
- package/dist/harness/tui.d.ts.map +1 -0
- package/dist/harness/tui.js +143 -0
- package/dist/harness/tui.js.map +1 -0
- package/dist/manual-config.d.ts +23 -10
- package/dist/manual-config.d.ts.map +1 -1
- package/dist/manual-config.js +45 -37
- package/dist/manual-config.js.map +1 -1
- package/dist/migrate.d.ts +32 -0
- package/dist/migrate.d.ts.map +1 -0
- package/dist/migrate.js +155 -0
- package/dist/migrate.js.map +1 -0
- package/dist/options.d.ts +5 -1
- package/dist/options.d.ts.map +1 -1
- package/dist/options.js +23 -4
- package/dist/options.js.map +1 -1
- package/dist/setup.d.ts +14 -10
- package/dist/setup.d.ts.map +1 -1
- package/dist/setup.js +25 -92
- package/dist/setup.js.map +1 -1
- package/dist/timeline.d.ts.map +1 -1
- package/dist/timeline.js +11 -0
- package/dist/timeline.js.map +1 -1
- package/dist/web/command.d.ts +5 -1
- package/dist/web/command.d.ts.map +1 -1
- package/dist/web/command.js +22 -6
- package/dist/web/command.js.map +1 -1
- package/dist/web/credentials.d.ts +7 -5
- package/dist/web/credentials.d.ts.map +1 -1
- package/dist/web/credentials.js +13 -48
- package/dist/web/credentials.js.map +1 -1
- package/dist/web/doctor.d.ts +1 -1
- package/dist/web/doctor.d.ts.map +1 -1
- package/dist/web/doctor.js +42 -64
- package/dist/web/doctor.js.map +1 -1
- package/dist/web/options.d.ts +26 -2
- package/dist/web/options.d.ts.map +1 -1
- package/dist/web/options.js +54 -18
- package/dist/web/options.js.map +1 -1
- package/dist/web/paths.d.ts +1 -1
- package/dist/web/paths.d.ts.map +1 -1
- package/dist/web/paths.js +2 -2
- package/dist/web/paths.js.map +1 -1
- package/dist/web/web.d.ts +38 -16
- package/dist/web/web.d.ts.map +1 -1
- package/dist/web/web.js +166 -168
- package/dist/web/web.js.map +1 -1
- package/package.json +4 -3
- package/web/brand/lib/client.js +4 -4
- package/web/patches/gbh-ui.patch.yml +6 -24
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The mode picker's book: the agent presets this harness can run.
|
|
3
|
+
*
|
|
4
|
+
* A session is born on one preset. The host takes `agentPreset` in
|
|
5
|
+
* `session.create` (and `agentPresets/select` while the session is still blank),
|
|
6
|
+
* records it in the session header and folds it back through the `agentPreset`
|
|
7
|
+
* projection — so the header line, the sidebar row and the Agent's own plugin
|
|
8
|
+
* tree all read one fact. The host publishes ids only (a shipped preset owns no
|
|
9
|
+
* `name`), so the four shipped modes carry their Vietnamese copy here, word for
|
|
10
|
+
* word from the desktop app's dictionary
|
|
11
|
+
* (`blackhole-tauri/packages/client/ui-agent-preset/src/locales-vi.ts`).
|
|
12
|
+
*
|
|
13
|
+
* The one behaviour the terminal must never lose: a preset that is only recorded
|
|
14
|
+
* on the host is a preset the user never chose. Every new session is created
|
|
15
|
+
* through {@link sessionCreateRequest}, which carries the mode the composer shows.
|
|
16
|
+
*/
|
|
17
|
+
import { HarnessRpcError } from "./client.js";
|
|
18
|
+
/** The heading the mode menu and the `/mode` notice share. */
|
|
19
|
+
export const MODE_MENU_TITLE = "Chế độ";
|
|
20
|
+
/**
|
|
21
|
+
* The four modes this harness ships, in roster order, with the app's own copy.
|
|
22
|
+
* Used as the roster before `agentPresets/list` answers, and for the copy of a
|
|
23
|
+
* row the host publishes without a name of its own.
|
|
24
|
+
*/
|
|
25
|
+
export const BUILT_IN_PRESETS = Object.freeze([
|
|
26
|
+
Object.freeze({
|
|
27
|
+
value: "standard",
|
|
28
|
+
label: "Chế độ Standard",
|
|
29
|
+
description: "Agent lập trình đầy đủ với chỉnh sửa tệp, shell, tìm kiếm tệp và web, skill, lập kế hoạch, mục tiêu, subagent và workflow.",
|
|
30
|
+
isDefault: true,
|
|
31
|
+
}),
|
|
32
|
+
Object.freeze({
|
|
33
|
+
value: "ptc",
|
|
34
|
+
label: "Chế độ PTC",
|
|
35
|
+
description: "Agent lập trình đầy đủ nhưng không có công cụ workflow; các công cụ khác được mở qua SDK của chế độ PTC để model gộp nhiều bước vào một chương trình TypeScript.",
|
|
36
|
+
}),
|
|
37
|
+
Object.freeze({
|
|
38
|
+
value: "minimal",
|
|
39
|
+
label: "Chế độ tối giản",
|
|
40
|
+
description: "Agent lập trình một công cụ với shell duy trì liên tục.",
|
|
41
|
+
}),
|
|
42
|
+
Object.freeze({
|
|
43
|
+
value: "cordis",
|
|
44
|
+
label: "Chế độ Creator",
|
|
45
|
+
description: "Dành cho việc tạo preset agent tuỳ chỉnh, gồm mọi năng lực của chế độ Standard cùng khả năng soi runtime, thử nghiệm plugin và hướng dẫn soạn preset.",
|
|
46
|
+
}),
|
|
47
|
+
]);
|
|
48
|
+
/** A preset the host named the default for, in the profile's own configuration. */
|
|
49
|
+
const PROFILE_DEFAULT = "standard";
|
|
50
|
+
/** The copy of one shipped preset, or undefined when the id is not ours. */
|
|
51
|
+
function builtIn(id) {
|
|
52
|
+
return BUILT_IN_PRESETS.find(option => option.value === id);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* The bare name of a mode, without the "Chế độ " prefix the chips and menus print.
|
|
56
|
+
* @param value - wire id the session records.
|
|
57
|
+
* @returns "Standard", "PTC", "Creator", a user-authored name, or the id itself.
|
|
58
|
+
*/
|
|
59
|
+
export function presetName(value) {
|
|
60
|
+
return (builtIn(value)?.label ?? value).replace(/^Chế độ /u, "");
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* The full name of a mode, as the composer chip prints it ("Chế độ PTC").
|
|
64
|
+
* @param value - wire id the session records.
|
|
65
|
+
* @returns the label the app uses for that mode.
|
|
66
|
+
*/
|
|
67
|
+
export function presetLabel(value) {
|
|
68
|
+
return builtIn(value)?.label ?? value;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Turn the host's roster into menu rows, filling in the shipped copy.
|
|
72
|
+
* @param rows - `agentPresets.list` presets; undefined or empty before the answer.
|
|
73
|
+
* @returns frozen rows in roster order; the shipped four when the host is silent.
|
|
74
|
+
*/
|
|
75
|
+
export function presetOptions(rows) {
|
|
76
|
+
if (rows === undefined || rows.length === 0)
|
|
77
|
+
return BUILT_IN_PRESETS;
|
|
78
|
+
const options = [...rows]
|
|
79
|
+
.sort((left, right) => (left.order ?? Number.POSITIVE_INFINITY) - (right.order ?? Number.POSITIVE_INFINITY) || left.id.localeCompare(right.id))
|
|
80
|
+
.map(optionOf);
|
|
81
|
+
return Object.freeze(options);
|
|
82
|
+
}
|
|
83
|
+
/** Fold one host row into a menu row, keeping the user's own wording when present. */
|
|
84
|
+
function optionOf(row) {
|
|
85
|
+
const shipped = builtIn(row.id);
|
|
86
|
+
return Object.freeze({
|
|
87
|
+
value: row.id,
|
|
88
|
+
label: row.name ?? shipped?.label ?? "Chế độ " + row.id,
|
|
89
|
+
description: row.description ?? shipped?.description ?? "",
|
|
90
|
+
...(row.isDefault === undefined ? {} : { isDefault: row.isDefault }),
|
|
91
|
+
...(row.broken === undefined ? {} : { broken: row.broken }),
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Mark the row in force, so the menu shows what the session already runs.
|
|
96
|
+
* @param options - rows from {@link presetOptions}.
|
|
97
|
+
* @param current - preset the session records, when it records one.
|
|
98
|
+
* @returns the same rows, with "đang dùng" on the one in force.
|
|
99
|
+
*/
|
|
100
|
+
export function presetMenuRows(options, current) {
|
|
101
|
+
return options.map(option => Object.freeze({
|
|
102
|
+
...option,
|
|
103
|
+
...(current !== undefined && option.value === current ? { hint: "đang dùng" } : {}),
|
|
104
|
+
}));
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* The body every new session is created with.
|
|
108
|
+
* @param cwd - workspace the session owns.
|
|
109
|
+
* @param preset - mode the composer shows; omitted means "the host's default".
|
|
110
|
+
* @returns the `request` object `session.create` expects, preset included.
|
|
111
|
+
*/
|
|
112
|
+
export function sessionCreateRequest(cwd, preset) {
|
|
113
|
+
return Object.freeze({
|
|
114
|
+
request: Object.freeze({
|
|
115
|
+
cwd,
|
|
116
|
+
...(preset === undefined || preset.length === 0 ? {} : { agentPreset: preset }),
|
|
117
|
+
}),
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
/** Fold one `agentPresets/list` entry defensively: the roster is additive across host versions. */
|
|
121
|
+
function rowOf(value) {
|
|
122
|
+
if (typeof value !== "object" || value === null || Array.isArray(value))
|
|
123
|
+
return undefined;
|
|
124
|
+
const item = value;
|
|
125
|
+
const id = typeof item["id"] === "string" && item["id"].length > 0 ? item["id"] : undefined;
|
|
126
|
+
if (id === undefined)
|
|
127
|
+
return undefined;
|
|
128
|
+
const optional = (key) => {
|
|
129
|
+
const field = item[key];
|
|
130
|
+
return typeof field === "string" && field.length > 0 ? field : undefined;
|
|
131
|
+
};
|
|
132
|
+
const order = typeof item["order"] === "number" && Number.isFinite(item["order"]) ? item["order"] : undefined;
|
|
133
|
+
return Object.freeze({
|
|
134
|
+
id,
|
|
135
|
+
...(optional("name") === undefined ? {} : { name: optional("name") }),
|
|
136
|
+
...(optional("description") === undefined ? {} : { description: optional("description") }),
|
|
137
|
+
...(order === undefined ? {} : { order }),
|
|
138
|
+
...(item["isDefault"] === true ? { isDefault: true } : {}),
|
|
139
|
+
...(optional("broken") === undefined ? {} : { broken: optional("broken") }),
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Read the roster the host publishes.
|
|
144
|
+
* @param client - the authenticated harness connection.
|
|
145
|
+
* @param signal - caller cancellation.
|
|
146
|
+
* @returns every preset the host knows; empty when the deployment composes none.
|
|
147
|
+
*/
|
|
148
|
+
export async function loadPresets(client, signal) {
|
|
149
|
+
const value = await client.call("agentPresets.list", {}, signal);
|
|
150
|
+
const rows = [];
|
|
151
|
+
for (const item of value.presets ?? []) {
|
|
152
|
+
const row = rowOf(item);
|
|
153
|
+
if (row !== undefined)
|
|
154
|
+
rows.push(row);
|
|
155
|
+
}
|
|
156
|
+
return Object.freeze(rows);
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Point a still-blank session at another mode.
|
|
160
|
+
*
|
|
161
|
+
* The host locks the mode once the first turn starts (`agent-preset/locked`), so
|
|
162
|
+
* this is the in-place switch for a draft; a started conversation gets a new
|
|
163
|
+
* session through {@link sessionCreateRequest} instead.
|
|
164
|
+
* @param client - the authenticated harness connection.
|
|
165
|
+
* @param sessionId - the blank session to re-point.
|
|
166
|
+
* @param preset - mode it should run from now on.
|
|
167
|
+
* @param signal - caller cancellation.
|
|
168
|
+
* @returns the mode the host recorded.
|
|
169
|
+
*/
|
|
170
|
+
export async function selectPreset(client, sessionId, preset, signal) {
|
|
171
|
+
// The endpoint takes FLAT arguments ({agentId, agentPreset}); a {request} wrapper is rejected
|
|
172
|
+
// by the gateway as an unexpected field.
|
|
173
|
+
const value = await client.call("agentPresets.select", { agentId: sessionId, agentPreset: preset }, signal);
|
|
174
|
+
return typeof value === "string" && value.length > 0 ? value : preset;
|
|
175
|
+
}
|
|
176
|
+
/** The mode a session lands on when nothing names one: the profile's own default. */
|
|
177
|
+
export function defaultPresetId(rows) {
|
|
178
|
+
return rows.find(row => row.isDefault === true)?.id ?? PROFILE_DEFAULT;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* The sentence a failed mode change shows.
|
|
182
|
+
* @param error - whatever the RPC threw.
|
|
183
|
+
* @returns one Vietnamese sentence the composer can print as a notice.
|
|
184
|
+
*/
|
|
185
|
+
export function presetFailure(error) {
|
|
186
|
+
const code = error instanceof HarnessRpcError ? error.code : "";
|
|
187
|
+
if (code === "agent-preset/locked")
|
|
188
|
+
return "Phiên đã bắt đầu nên chế độ đã chốt — chọn chế độ ở phiên mới.";
|
|
189
|
+
if (code === "agent-preset/not-found")
|
|
190
|
+
return "Harness không có chế độ này.";
|
|
191
|
+
if (code === "agent-preset/invalid")
|
|
192
|
+
return "Chế độ này không nạp được trên máy.";
|
|
193
|
+
if (code === "agent-preset/conflict")
|
|
194
|
+
return "Phiên đang chạy một chế độ khác.";
|
|
195
|
+
return "Không đổi được chế độ: " + (error instanceof Error ? error.message : String(error));
|
|
196
|
+
}
|
|
197
|
+
//# sourceMappingURL=preset.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preset.js","sourceRoot":"","sources":["../../src/harness/preset.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,eAAe,EAAsB,MAAM,aAAa,CAAC;AAkClE,8DAA8D;AAC9D,MAAM,CAAC,MAAM,eAAe,GAAG,QAAQ,CAAC;AAExC;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAiC,MAAM,CAAC,MAAM,CAAC;IAC1E,MAAM,CAAC,MAAM,CAAC;QACZ,KAAK,EAAE,UAAU;QACjB,KAAK,EAAE,iBAAiB;QACxB,WAAW,EAAE,4HAA4H;QACzI,SAAS,EAAE,IAAI;KAChB,CAAC;IACF,MAAM,CAAC,MAAM,CAAC;QACZ,KAAK,EAAE,KAAK;QACZ,KAAK,EAAE,YAAY;QACnB,WAAW,EAAE,kKAAkK;KAChL,CAAC;IACF,MAAM,CAAC,MAAM,CAAC;QACZ,KAAK,EAAE,SAAS;QAChB,KAAK,EAAE,iBAAiB;QACxB,WAAW,EAAE,yDAAyD;KAC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AAM,MAAM,CAAC,IAAI,CAAS,qBAAqB,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,EAAE,EAAE,MAAM,CAAC,CAAC;IACpH,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC;AACxE,CAAC;AAED,qFAAqF;AACrF,MAAM,UAAU,eAAe,CAAC,IAA+B;IAC7D,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,SAAS,KAAK,IAAI,CAAC,EAAE,EAAE,IAAI,eAAe,CAAC;AACzE,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,KAAc;IAC1C,MAAM,IAAI,GAAG,KAAK,YAAY,eAAe,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;IAChE,IAAI,IAAI,KAAK,qBAAqB;QAAE,OAAO,gEAAgE,CAAC;IAC5G,IAAI,IAAI,KAAK,wBAAwB;QAAE,OAAO,8BAA8B,CAAC;IAC7E,IAAI,IAAI,KAAK,sBAAsB;QAAE,OAAO,qCAAqC,CAAC;IAClF,IAAI,IAAI,KAAK,uBAAuB;QAAE,OAAO,kCAAkC,CAAC;IAChF,OAAO,yBAAyB,GAAG,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;AAC9F,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Boot (and stop) the Galaxy Blackhole harness host that backs `blackhole chat`.
|
|
3
|
+
*
|
|
4
|
+
* The harness prints one authenticated URL once it is ready
|
|
5
|
+
* (`[bh] ready http://127.0.0.1:<port>/?token=…`); this module captures that line,
|
|
6
|
+
* keeps the child's own output in a log file instead of the terminal (Ink owns
|
|
7
|
+
* the screen), and stops the child when the terminal exits.
|
|
8
|
+
*/
|
|
9
|
+
import { type ChildProcess } from "node:child_process";
|
|
10
|
+
import { type LocateEnvironment } from "./locate.js";
|
|
11
|
+
/** One running host. */
|
|
12
|
+
export interface HarnessHost {
|
|
13
|
+
/** Authenticated loopback URL; exchange its token for a cookie before any RPC. */
|
|
14
|
+
readonly url: string;
|
|
15
|
+
/** The launcher process. */
|
|
16
|
+
readonly child: ChildProcess;
|
|
17
|
+
/** File holding every line the launcher printed. */
|
|
18
|
+
readonly logFile: string;
|
|
19
|
+
/** Ask the child to stop and wait for it. Idempotent. */
|
|
20
|
+
stop(): Promise<void>;
|
|
21
|
+
}
|
|
22
|
+
/** Everything a boot takes. */
|
|
23
|
+
export interface HarnessHostOptions {
|
|
24
|
+
/** Port to bind; 0 (the default) asks the OS for a free one. */
|
|
25
|
+
readonly port?: number;
|
|
26
|
+
/** Harness profile to boot; the app's own default when omitted. */
|
|
27
|
+
readonly profile?: string;
|
|
28
|
+
/** `GBH_HOME` for the child; the app default when omitted. */
|
|
29
|
+
readonly home?: string;
|
|
30
|
+
/** Directory for the host log; the current directory when omitted. */
|
|
31
|
+
readonly logDir?: string;
|
|
32
|
+
/** How long to wait for the ready line, in milliseconds. */
|
|
33
|
+
readonly timeoutMs?: number;
|
|
34
|
+
/** Locate overrides, for tests. */
|
|
35
|
+
readonly environment?: LocateEnvironment;
|
|
36
|
+
/** Pre-resolved bun and checkout root, for tests. */
|
|
37
|
+
readonly bun?: string;
|
|
38
|
+
readonly root?: string;
|
|
39
|
+
/** Called with every complete line the launcher prints, for boot progress. */
|
|
40
|
+
readonly onLine?: (line: string) => void;
|
|
41
|
+
}
|
|
42
|
+
/** A boot failure that carries the launcher's own last words. */
|
|
43
|
+
export declare class HarnessBootError extends Error {
|
|
44
|
+
readonly logFile: string | undefined;
|
|
45
|
+
readonly tail: string;
|
|
46
|
+
constructor(message: string, logFile: string | undefined, tail: string);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Spawn `bh host` and wait for its authenticated URL.
|
|
50
|
+
* @param options - port, profile, home, log directory and timeout.
|
|
51
|
+
* @returns the running host, already serving.
|
|
52
|
+
* @throws HarnessBootError when Bun, the checkout, or the ready line is missing.
|
|
53
|
+
*/
|
|
54
|
+
export declare function spawnHarnessHost(options?: HarnessHostOptions): Promise<HarnessHost>;
|
|
55
|
+
//# sourceMappingURL=process.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"process.d.ts","sourceRoot":"","sources":["../../src/harness/process.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAS,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAG9D,OAAO,EAAmD,KAAK,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAKtG,wBAAwB;AACxB,MAAM,WAAW,WAAW;IAC1B,kFAAkF;IAClF,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,4BAA4B;IAC5B,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC;IAC7B,oDAAoD;IACpD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,yDAAyD;IACzD,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACvB;AAED,+BAA+B;AAC/B,MAAM,WAAW,kBAAkB;IACjC,gEAAgE;IAChE,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,mEAAmE;IACnE,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,8DAA8D;IAC9D,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,sEAAsE;IACtE,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,4DAA4D;IAC5D,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,mCAAmC;IACnC,QAAQ,CAAC,WAAW,CAAC,EAAE,iBAAiB,CAAC;IACzC,qDAAqD;IACrD,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,8EAA8E;IAC9E,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CAC1C;AAED,iEAAiE;AACjE,qBAAa,gBAAiB,SAAQ,KAAK;IACZ,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM;gBAA5E,OAAO,EAAE,MAAM,EAAW,OAAO,EAAE,MAAM,GAAG,SAAS,EAAW,IAAI,EAAE,MAAM;CAIzF;AAMD;;;;;GAKG;AACH,wBAAsB,gBAAgB,CAAC,OAAO,GAAE,kBAAuB,GAAG,OAAO,CAAC,WAAW,CAAC,CAgF7F"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Boot (and stop) the Galaxy Blackhole harness host that backs `blackhole chat`.
|
|
3
|
+
*
|
|
4
|
+
* The harness prints one authenticated URL once it is ready
|
|
5
|
+
* (`[bh] ready http://127.0.0.1:<port>/?token=…`); this module captures that line,
|
|
6
|
+
* keeps the child's own output in a log file instead of the terminal (Ink owns
|
|
7
|
+
* the screen), and stops the child when the terminal exits.
|
|
8
|
+
*/
|
|
9
|
+
import { spawn } from "node:child_process";
|
|
10
|
+
import { createWriteStream, mkdirSync } from "node:fs";
|
|
11
|
+
import { join } from "node:path";
|
|
12
|
+
import { findBun, findTauriRoot, systemLocateEnvironment } from "./locate.js";
|
|
13
|
+
/** The authenticated URL the harness prints when the web surface is serving. */
|
|
14
|
+
const READY_URL = /https?:\/\/127\.0\.0\.1:\d+\/\?token=[A-Za-z0-9._~+/=-]+/u;
|
|
15
|
+
/** A boot failure that carries the launcher's own last words. */
|
|
16
|
+
export class HarnessBootError extends Error {
|
|
17
|
+
logFile;
|
|
18
|
+
tail;
|
|
19
|
+
constructor(message, logFile, tail) {
|
|
20
|
+
super(message);
|
|
21
|
+
this.logFile = logFile;
|
|
22
|
+
this.tail = tail;
|
|
23
|
+
this.name = "HarnessBootError";
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function stamp() {
|
|
27
|
+
return new Date().toISOString().replace(/[:.]/g, "-");
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Spawn `bh host` and wait for its authenticated URL.
|
|
31
|
+
* @param options - port, profile, home, log directory and timeout.
|
|
32
|
+
* @returns the running host, already serving.
|
|
33
|
+
* @throws HarnessBootError when Bun, the checkout, or the ready line is missing.
|
|
34
|
+
*/
|
|
35
|
+
export async function spawnHarnessHost(options = {}) {
|
|
36
|
+
const environment = options.environment ?? systemLocateEnvironment();
|
|
37
|
+
const root = options.root ?? findTauriRoot(environment);
|
|
38
|
+
if (root === undefined) {
|
|
39
|
+
throw new HarnessBootError("Không tìm thấy blackhole-tauri. Đặt GBH_TAURI_ROOT tới bản checkout của nó.", undefined, "");
|
|
40
|
+
}
|
|
41
|
+
const bun = options.bun ?? findBun(environment);
|
|
42
|
+
if (bun === undefined) {
|
|
43
|
+
throw new HarnessBootError("Không tìm thấy bun. Cài bun (https://bun.sh) hoặc đặt GBH_BUN.", undefined, "");
|
|
44
|
+
}
|
|
45
|
+
const port = options.port ?? 0;
|
|
46
|
+
const args = [join(root, "apps", "cli", "src", "main.ts"), "host", "--port", String(port)];
|
|
47
|
+
if (options.profile !== undefined)
|
|
48
|
+
args.push("--profile", options.profile);
|
|
49
|
+
const logDir = options.logDir ?? process.cwd();
|
|
50
|
+
mkdirSync(logDir, { recursive: true, mode: 0o700 });
|
|
51
|
+
const logFile = join(logDir, "harness-" + stamp() + ".log");
|
|
52
|
+
const log = createWriteStream(logFile, { flags: "a", mode: 0o600 });
|
|
53
|
+
let tail = "";
|
|
54
|
+
const timeoutMs = options.timeoutMs ?? 240_000;
|
|
55
|
+
const child = spawn(bun, args, {
|
|
56
|
+
cwd: root,
|
|
57
|
+
env: { ...process.env, ...(options.home === undefined ? {} : { GBH_HOME: options.home, DSH_HOME: options.home }) },
|
|
58
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
59
|
+
});
|
|
60
|
+
const stop = async () => {
|
|
61
|
+
if (child.exitCode !== null || child.signalCode !== null) {
|
|
62
|
+
log.end();
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
child.kill("SIGTERM");
|
|
66
|
+
const exited = await new Promise(resolvePromise => {
|
|
67
|
+
const timer = setTimeout(() => resolvePromise(false), 5000);
|
|
68
|
+
child.once("exit", () => { clearTimeout(timer); resolvePromise(true); });
|
|
69
|
+
});
|
|
70
|
+
if (!exited)
|
|
71
|
+
child.kill("SIGKILL");
|
|
72
|
+
log.end();
|
|
73
|
+
};
|
|
74
|
+
const url = await new Promise((resolvePromise, rejectPromise) => {
|
|
75
|
+
let settled = false;
|
|
76
|
+
const fail = (error) => {
|
|
77
|
+
if (settled)
|
|
78
|
+
return;
|
|
79
|
+
settled = true;
|
|
80
|
+
clearTimeout(timer);
|
|
81
|
+
void stop().finally(() => rejectPromise(new HarnessBootError(error.message, logFile, tail.slice(-2000))));
|
|
82
|
+
};
|
|
83
|
+
const timer = setTimeout(() => fail(new Error(`Harness không in URL sau ${Math.round(timeoutMs / 1000)}s.`)), timeoutMs);
|
|
84
|
+
let pending = "";
|
|
85
|
+
const report = (chunk, complete) => {
|
|
86
|
+
if (options.onLine === undefined)
|
|
87
|
+
return;
|
|
88
|
+
pending += chunk;
|
|
89
|
+
const lines = pending.split(/\r?\n/u);
|
|
90
|
+
pending = complete ? "" : (lines.pop() ?? "");
|
|
91
|
+
for (const line of lines) {
|
|
92
|
+
if (line.length === 0)
|
|
93
|
+
continue;
|
|
94
|
+
options.onLine(line);
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
const scan = (chunk) => {
|
|
98
|
+
log.write(chunk);
|
|
99
|
+
report(chunk, false);
|
|
100
|
+
tail = (tail + chunk).slice(-8192);
|
|
101
|
+
if (settled)
|
|
102
|
+
return;
|
|
103
|
+
const match = READY_URL.exec(tail);
|
|
104
|
+
if (match === null)
|
|
105
|
+
return;
|
|
106
|
+
settled = true;
|
|
107
|
+
clearTimeout(timer);
|
|
108
|
+
resolvePromise(match[0]);
|
|
109
|
+
};
|
|
110
|
+
child.stdout?.setEncoding("utf8");
|
|
111
|
+
child.stdout?.on("data", scan);
|
|
112
|
+
child.stderr?.setEncoding("utf8");
|
|
113
|
+
child.stderr?.on("data", chunk => { log.write(chunk); report(chunk, false); tail = (tail + chunk).slice(-8192); });
|
|
114
|
+
child.once("error", error => fail(new Error("Không chạy được " + bun + ": " + error.message)));
|
|
115
|
+
child.once("exit", (code, signal) => fail(new Error("Harness thoát trước khi sẵn sàng (code " + String(code) + ", signal " + String(signal) + ").")));
|
|
116
|
+
});
|
|
117
|
+
return Object.freeze({ url, child, logFile, stop });
|
|
118
|
+
}
|
|
119
|
+
//# sourceMappingURL=process.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"process.js","sourceRoot":"","sources":["../../src/harness/process.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,KAAK,EAAqB,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAoB,MAAM,SAAS,CAAC;AACzE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,uBAAuB,EAA0B,MAAM,aAAa,CAAC;AAEtG,gFAAgF;AAChF,MAAM,SAAS,GAAG,2DAA2D,CAAC;AAmC9E,iEAAiE;AACjE,MAAM,OAAO,gBAAiB,SAAQ,KAAK;IACH;IAAsC;IAA5E,YAAY,OAAe,EAAW,OAA2B,EAAW,IAAY;QACtF,KAAK,CAAC,OAAO,CAAC,CAAC;QADqB,YAAO,GAAP,OAAO,CAAoB;QAAW,SAAI,GAA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C,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,kBAAkB,GAAG,GAAG,GAAG,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QAC/F,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,yCAAyC,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;IACxJ,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;AACtD,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* author Bùi Trọng Hiếu
|
|
3
|
+
* email kevinbui210191@gmail.com
|
|
4
|
+
* create date 15/10/2026
|
|
5
|
+
* modify date 11/11/2026
|
|
6
|
+
* desc Doc row.effort cua session/list o ca ba cho set effort, de chip va panel hien dung muc suy luan
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* The desktop-shaped `blackhole chat` screen.
|
|
10
|
+
*
|
|
11
|
+
* Layout, top to bottom: a body row (workspace/session sidebar, then the main
|
|
12
|
+
* column with its "Hội thoại" / "Luồng chạy" tabs), an optional dropdown menu,
|
|
13
|
+
* the composer, and one status row. State is the conversation reducer plus the
|
|
14
|
+
* screen's own bookkeeping; the harness engine stays behind `HarnessChat` and
|
|
15
|
+
* `HarnessClient`.
|
|
16
|
+
*/
|
|
17
|
+
import { type ReactElement } from "react";
|
|
18
|
+
import { HarnessChat } from "./chat.js";
|
|
19
|
+
import type { HarnessClient } from "./client.js";
|
|
20
|
+
import type { HarnessHost } from "./process.js";
|
|
21
|
+
/** What the screen needs from the command that booted the harness. */
|
|
22
|
+
export interface HarnessScreenProps {
|
|
23
|
+
readonly chat: HarnessChat;
|
|
24
|
+
readonly client: HarnessClient;
|
|
25
|
+
readonly host: HarnessHost;
|
|
26
|
+
/** Workspace the terminal was started in; new conversations stay here. */
|
|
27
|
+
readonly cwd: string;
|
|
28
|
+
/** A model named on the command line, shown until the catalog answers. */
|
|
29
|
+
readonly model?: string;
|
|
30
|
+
}
|
|
31
|
+
/** The full screen: sidebar, conversation, dropdown, composer and status. */
|
|
32
|
+
export declare function HarnessScreen(props: HarnessScreenProps): ReactElement;
|
|
33
|
+
//# sourceMappingURL=screen.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"screen.d.ts","sourceRoot":"","sources":["../../src/harness/screen.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;;;;GAQG;AACH,OAAO,EAAiE,KAAK,YAAY,EAAE,MAAM,OAAO,CAAC;AAGzG,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAoBhD,sEAAsE;AACtE,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;IAC/B,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAC3B,0EAA0E;IAC1E,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,0EAA0E;IAC1E,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB;AAgED,6EAA6E;AAC7E,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,GAAG,YAAY,CAo2BrE"}
|