@galaxy-stack/blackhole-cli 2.3.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 +23 -2
- package/dist/application.js.map +1 -1
- package/dist/authorization.d.ts +22 -0
- package/dist/authorization.d.ts.map +1 -0
- package/dist/authorization.js +42 -0
- package/dist/authorization.js.map +1 -0
- 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 +51 -27
- 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 +10 -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 +5 -4
- package/web/brand/lib/client.js +4 -4
- package/web/patches/gbh-ui.patch.yml +6 -24
package/dist/file-index.d.ts
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
/** Directories never offered as @ references. */
|
|
2
2
|
export declare const INDEX_IGNORED: readonly string[];
|
|
3
|
+
/** How the index is bounded; every field has a default that suits one workspace. */
|
|
3
4
|
export interface FileIndexOptions {
|
|
5
|
+
/** Hard cap on the number of files kept. */
|
|
4
6
|
readonly limit?: number;
|
|
7
|
+
/** How many directory levels below the root are walked. */
|
|
5
8
|
readonly maxDepth?: number;
|
|
9
|
+
/** Directory names never walked into. */
|
|
6
10
|
readonly ignored?: readonly string[];
|
|
7
11
|
}
|
|
8
12
|
/**
|
|
@@ -17,4 +21,50 @@ export declare function fileQuery(text: string): {
|
|
|
17
21
|
} | undefined;
|
|
18
22
|
/** Replace the trailing @token with the chosen path. */
|
|
19
23
|
export declare function insertFilePath(text: string, path: string): string;
|
|
24
|
+
/**
|
|
25
|
+
* Score one path against a typed query; an empty query matches everything.
|
|
26
|
+
*
|
|
27
|
+
* A subsequence match is the whole rule (every query character appears in order),
|
|
28
|
+
* and the score rewards what a person aims at: a character on a word boundary
|
|
29
|
+
* (start of the path, after "/", "-", "_" or "."), a character continuing an
|
|
30
|
+
* unbroken run, and a match near the basename rather than spread over folders.
|
|
31
|
+
* @param query - what the user typed after @.
|
|
32
|
+
* @param candidate - the relative path to score.
|
|
33
|
+
* @returns a positive score, or undefined when the path does not match.
|
|
34
|
+
*/
|
|
35
|
+
export declare function fuzzyScore(query: string, candidate: string): number | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* Filter and rank paths for the picker.
|
|
38
|
+
* @param files - the workspace index.
|
|
39
|
+
* @param query - what the user typed after @.
|
|
40
|
+
* @param limit - rows to keep; the picker shows far fewer.
|
|
41
|
+
* @returns the best matches, best first, at most limit of them.
|
|
42
|
+
*/
|
|
43
|
+
export declare function filterFiles(files: readonly string[], query: string, limit?: number): readonly string[];
|
|
44
|
+
/** A workspace index that survives keystrokes, and a way to force it fresh. */
|
|
45
|
+
export interface FileIndexCache {
|
|
46
|
+
/** The cached list, read at most once per TTL. */
|
|
47
|
+
files(): Promise<readonly string[]>;
|
|
48
|
+
/** Drop the cached list; the next read walks the tree again. */
|
|
49
|
+
invalidate(): void;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Build a TTL-cached index for one workspace root.
|
|
53
|
+
* @param root - absolute workspace directory.
|
|
54
|
+
* @param options - count/depth bounds plus the cache TTL.
|
|
55
|
+
* @returns the cache the picker reads.
|
|
56
|
+
*/
|
|
57
|
+
export declare function workspaceFileIndex(root: string, options?: FileIndexOptions & {
|
|
58
|
+
readonly ttlMs?: number;
|
|
59
|
+
}): FileIndexCache;
|
|
60
|
+
/**
|
|
61
|
+
* Immediate subdirectories under a root, for the workspace chooser.
|
|
62
|
+
* @param root - absolute directory to scan.
|
|
63
|
+
* @param options - cap and ignore list; hidden folders are always skipped.
|
|
64
|
+
* @returns relative folder names, sorted.
|
|
65
|
+
*/
|
|
66
|
+
export declare function listWorkspaceDirs(root: string, options?: {
|
|
67
|
+
readonly limit?: number;
|
|
68
|
+
readonly ignored?: readonly string[];
|
|
69
|
+
}): Promise<readonly string[]>;
|
|
20
70
|
//# sourceMappingURL=file-index.d.ts.map
|
package/dist/file-index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-index.d.ts","sourceRoot":"","sources":["../src/file-index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"file-index.d.ts","sourceRoot":"","sources":["../src/file-index.ts"],"names":[],"mappings":"AAaA,iDAAiD;AACjD,eAAO,MAAM,aAAa,EAAE,SAAS,MAAM,EAGzC,CAAC;AAEH,oFAAoF;AACpF,MAAM,WAAW,gBAAgB;IAC/B,4CAA4C;IAC5C,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,2DAA2D;IAC3D,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,yCAAyC;IACzC,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACtC;AAED;;;GAGG;AACH,wBAAsB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,gBAAqB,GAAG,OAAO,CAAC,SAAS,MAAM,EAAE,CAAC,CA2BjH;AAED,+CAA+C;AAC/C,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CAKpF;AAED,wDAAwD;AACxD,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAIjE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAqB/E;AAOD;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,SAAM,GAAG,SAAS,MAAM,EAAE,CASnG;AAED,+EAA+E;AAC/E,MAAM,WAAW,cAAc;IAC7B,kDAAkD;IAClD,KAAK,IAAI,OAAO,CAAC,SAAS,MAAM,EAAE,CAAC,CAAC;IACpC,gEAAgE;IAChE,UAAU,IAAI,IAAI,CAAC;CACpB;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,gBAAgB,GAAG;IAAE,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAO,GAAG,cAAc,CA0B7H;AAED;;;;;GAKG;AACH,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE;IAAE,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;CAAO,GAAG,OAAO,CAAC,SAAS,MAAM,EAAE,CAAC,CAajK"}
|
package/dist/file-index.js
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The workspace file index behind the composer @ picker.
|
|
3
|
+
*
|
|
4
|
+
* The picker answers from disk, not from the harness: a recursive readdir bounded
|
|
5
|
+
* by count and depth is enough to list a workspace, and a short-lived cache keeps
|
|
6
|
+
* every keystroke from walking the tree again. Filtering is a subsequence match
|
|
7
|
+
* scored so that a match on the basename outranks a match spread across folders.
|
|
8
|
+
*
|
|
9
|
+
* Everything here is pure or filesystem-only, which is what the tests drive.
|
|
10
|
+
*/
|
|
1
11
|
import { readdir } from "node:fs/promises";
|
|
2
12
|
import { join } from "node:path";
|
|
3
13
|
/** Directories never offered as @ references. */
|
|
@@ -57,4 +67,118 @@ export function insertFilePath(text, path) {
|
|
|
57
67
|
return text;
|
|
58
68
|
return text.slice(0, found.start) + "@" + path + " ";
|
|
59
69
|
}
|
|
70
|
+
/**
|
|
71
|
+
* Score one path against a typed query; an empty query matches everything.
|
|
72
|
+
*
|
|
73
|
+
* A subsequence match is the whole rule (every query character appears in order),
|
|
74
|
+
* and the score rewards what a person aims at: a character on a word boundary
|
|
75
|
+
* (start of the path, after "/", "-", "_" or "."), a character continuing an
|
|
76
|
+
* unbroken run, and a match near the basename rather than spread over folders.
|
|
77
|
+
* @param query - what the user typed after @.
|
|
78
|
+
* @param candidate - the relative path to score.
|
|
79
|
+
* @returns a positive score, or undefined when the path does not match.
|
|
80
|
+
*/
|
|
81
|
+
export function fuzzyScore(query, candidate) {
|
|
82
|
+
const needle = query.toLowerCase();
|
|
83
|
+
const haystack = candidate.toLowerCase();
|
|
84
|
+
if (needle.length === 0)
|
|
85
|
+
return 1;
|
|
86
|
+
let score = 0;
|
|
87
|
+
let from = 0;
|
|
88
|
+
let run = 0;
|
|
89
|
+
for (const character of needle) {
|
|
90
|
+
const at = haystack.indexOf(character, from);
|
|
91
|
+
if (at < 0)
|
|
92
|
+
return undefined;
|
|
93
|
+
const previous = at === 0 ? "" : haystack[at - 1] ?? "";
|
|
94
|
+
const boundary = at === 0 || previous === "/" || previous === "-" || previous === "_" || previous === ".";
|
|
95
|
+
score += boundary ? 3 : 1;
|
|
96
|
+
run = at === from ? run + 1 : 0;
|
|
97
|
+
score += run;
|
|
98
|
+
from = at + 1;
|
|
99
|
+
}
|
|
100
|
+
// A match in the file name beats the same match spread through folder names.
|
|
101
|
+
const base = haystack.lastIndexOf("/") + 1;
|
|
102
|
+
if (base > 0 && atOrAfter(haystack, needle[0] ?? "", base))
|
|
103
|
+
score += 2;
|
|
104
|
+
return score;
|
|
105
|
+
}
|
|
106
|
+
/** Whether the first query character also appears at or after the basename offset. */
|
|
107
|
+
function atOrAfter(haystack, character, offset) {
|
|
108
|
+
return character.length > 0 && haystack.indexOf(character, offset) >= 0;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Filter and rank paths for the picker.
|
|
112
|
+
* @param files - the workspace index.
|
|
113
|
+
* @param query - what the user typed after @.
|
|
114
|
+
* @param limit - rows to keep; the picker shows far fewer.
|
|
115
|
+
* @returns the best matches, best first, at most limit of them.
|
|
116
|
+
*/
|
|
117
|
+
export function filterFiles(files, query, limit = 200) {
|
|
118
|
+
const scored = [];
|
|
119
|
+
for (const path of files) {
|
|
120
|
+
const score = fuzzyScore(query, path);
|
|
121
|
+
if (score === undefined)
|
|
122
|
+
continue;
|
|
123
|
+
scored.push({ path, score });
|
|
124
|
+
}
|
|
125
|
+
scored.sort((left, right) => right.score - left.score || left.path.length - right.path.length || left.path.localeCompare(right.path));
|
|
126
|
+
return scored.slice(0, Math.max(1, limit)).map(entry => entry.path);
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Build a TTL-cached index for one workspace root.
|
|
130
|
+
* @param root - absolute workspace directory.
|
|
131
|
+
* @param options - count/depth bounds plus the cache TTL.
|
|
132
|
+
* @returns the cache the picker reads.
|
|
133
|
+
*/
|
|
134
|
+
export function workspaceFileIndex(root, options = {}) {
|
|
135
|
+
const ttlMs = Math.max(0, options.ttlMs ?? 30_000);
|
|
136
|
+
let cached;
|
|
137
|
+
let readAt = 0;
|
|
138
|
+
let inflight;
|
|
139
|
+
return {
|
|
140
|
+
async files() {
|
|
141
|
+
const now = Date.now();
|
|
142
|
+
if (cached !== undefined && now - readAt < ttlMs)
|
|
143
|
+
return cached;
|
|
144
|
+
if (inflight !== undefined)
|
|
145
|
+
return inflight;
|
|
146
|
+
inflight = listWorkspaceFiles(root, options).then(files => {
|
|
147
|
+
cached = files;
|
|
148
|
+
readAt = Date.now();
|
|
149
|
+
inflight = undefined;
|
|
150
|
+
return files;
|
|
151
|
+
}, error => {
|
|
152
|
+
inflight = undefined;
|
|
153
|
+
throw error;
|
|
154
|
+
});
|
|
155
|
+
return inflight;
|
|
156
|
+
},
|
|
157
|
+
invalidate() {
|
|
158
|
+
cached = undefined;
|
|
159
|
+
readAt = 0;
|
|
160
|
+
},
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Immediate subdirectories under a root, for the workspace chooser.
|
|
165
|
+
* @param root - absolute directory to scan.
|
|
166
|
+
* @param options - cap and ignore list; hidden folders are always skipped.
|
|
167
|
+
* @returns relative folder names, sorted.
|
|
168
|
+
*/
|
|
169
|
+
export async function listWorkspaceDirs(root, options = {}) {
|
|
170
|
+
const limit = Math.max(1, options.limit ?? 200);
|
|
171
|
+
const ignored = new Set(options.ignored ?? INDEX_IGNORED);
|
|
172
|
+
try {
|
|
173
|
+
const entries = await readdir(root, { withFileTypes: true });
|
|
174
|
+
return entries
|
|
175
|
+
.filter(entry => entry.isDirectory() && !entry.name.startsWith(".") && !ignored.has(entry.name))
|
|
176
|
+
.map(entry => entry.name)
|
|
177
|
+
.sort((left, right) => left.localeCompare(right))
|
|
178
|
+
.slice(0, limit);
|
|
179
|
+
}
|
|
180
|
+
catch {
|
|
181
|
+
return [];
|
|
182
|
+
}
|
|
183
|
+
}
|
|
60
184
|
//# sourceMappingURL=file-index.js.map
|
package/dist/file-index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-index.js","sourceRoot":"","sources":["../src/file-index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,iDAAiD;AACjD,MAAM,CAAC,MAAM,aAAa,GAAsB,MAAM,CAAC,MAAM,CAAC;IAC5D,cAAc,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM;IAC7E,aAAa,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ;CACxE,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"file-index.js","sourceRoot":"","sources":["../src/file-index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO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BACrB,MAAM,KAAK,CAAC;YACd,CAAC,CAAC,CAAC;YACH,OAAO,QAAQ,CAAC;QAClB,CAAC;QACD,UAAU;YACR,MAAM,GAAG,SAAS,CAAC;YACnB,MAAM,GAAG,CAAC,CAAC;QACb,CAAC;KACF,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,IAAY,EAAE,UAA6E,EAAE;IACnI,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,KAAK,IAAI,GAAG,CAAC,CAAC;IAChD,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,OAAO,IAAI,aAAa,CAAC,CAAC;IAC1D,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,IAAI,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;QAC7D,OAAO,OAAO;aACX,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,WAAW,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;aAC/F,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC;aACxB,IAAI,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;aAChD,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;IACrB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Boot progress for every surface that waits on the harness (~20-40 s on this machine).
|
|
3
|
+
*
|
|
4
|
+
* Booting is three real phases and one spinner: the launcher mounts plugins, writes
|
|
5
|
+
* the composed config, then the host serves and prints its URL. The launcher already
|
|
6
|
+
* says which of those it reached in its own log, so the milestones are derived from
|
|
7
|
+
* that log rather than invented by a timer.
|
|
8
|
+
*
|
|
9
|
+
* ONE line, ONE wording, ONE erase for both surfaces: `blackhole web` and
|
|
10
|
+
* `blackhole chat` paint the same spinner and brand here, and both clear it the same
|
|
11
|
+
* way. A terminal gets one line rewritten in place; `chat` paints it on the last row,
|
|
12
|
+
* which is where the TUI's own status row sits, so the screen does not jump when the
|
|
13
|
+
* terminal takes over. A pipe gets nothing at all, because a progress spinner in a log
|
|
14
|
+
* file is noise.
|
|
15
|
+
*/
|
|
16
|
+
/** One named milestone of a harness boot. */
|
|
17
|
+
export interface BootPhase {
|
|
18
|
+
/** Stable id, used by tests and by the phase table. */
|
|
19
|
+
readonly id: "plugins" | "config" | "host";
|
|
20
|
+
/** The Vietnamese line the user reads. */
|
|
21
|
+
readonly label: string;
|
|
22
|
+
}
|
|
23
|
+
/** The milestones in the order a boot reaches them. */
|
|
24
|
+
export declare const BOOT_PHASES: readonly BootPhase[];
|
|
25
|
+
/** The brand both surfaces print beside the milestone. */
|
|
26
|
+
export declare const BOOT_BRAND = "Galaxy Blackhole";
|
|
27
|
+
/** The spinner frames, shared by every surface. */
|
|
28
|
+
export declare const SPINNER_FRAMES: readonly string[];
|
|
29
|
+
/**
|
|
30
|
+
* The frame for one tick.
|
|
31
|
+
* @param tick - a counter that only ever grows.
|
|
32
|
+
* @returns one spinner glyph.
|
|
33
|
+
*/
|
|
34
|
+
export declare function spinnerFrame(tick: number): string;
|
|
35
|
+
/**
|
|
36
|
+
* The one boot line every surface paints: spinner, brand, milestone.
|
|
37
|
+
* @param tick - the spinner counter.
|
|
38
|
+
* @param label - the milestone the launcher proved.
|
|
39
|
+
* @returns the text of the line, without any cursor control.
|
|
40
|
+
*/
|
|
41
|
+
export declare function bootLine(tick: number, label: string): string;
|
|
42
|
+
/** Erase the whole current line, the sequence both surfaces end a boot with. */
|
|
43
|
+
export declare const ERASE_LINE = "\r\u001B[2K";
|
|
44
|
+
/**
|
|
45
|
+
* Which milestone one launcher log line has reached, if it names one.
|
|
46
|
+
*
|
|
47
|
+
* The launcher prints its banner before it mounts plugins ("[bh] node", "[bh] harness",
|
|
48
|
+
* "[bh] argv"), the preset probes while plugins load ("agent-preset[...]"), and the
|
|
49
|
+
* web app last ("dsh web:" / "gbh web:"). Anything else keeps the current milestone.
|
|
50
|
+
* @param line - one line of launcher output, without its newline.
|
|
51
|
+
* @returns the phase the line proves, or undefined when it proves none.
|
|
52
|
+
*/
|
|
53
|
+
export declare function bootPhaseFor(line: string): BootPhase | undefined;
|
|
54
|
+
/** What a boot reporter offers its caller. */
|
|
55
|
+
export interface BootReporter {
|
|
56
|
+
/** The milestone currently shown. */
|
|
57
|
+
readonly label: string;
|
|
58
|
+
/** Move to another milestone (never backwards); repeats are ignored. */
|
|
59
|
+
step(label: string): void;
|
|
60
|
+
/** Stop the spinner and erase the line. */
|
|
61
|
+
clear(): void;
|
|
62
|
+
}
|
|
63
|
+
/** Where a reporter writes, and how often it redraws. */
|
|
64
|
+
export interface BootReporterOptions {
|
|
65
|
+
/** Milliseconds between frames; 100 reads as motion without flicker. */
|
|
66
|
+
readonly intervalMs?: number;
|
|
67
|
+
/** Force the carriage-return surface on or off; defaults to the stream TTY flag. */
|
|
68
|
+
readonly tty?: boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Paint on the terminal's last row instead of the current one. The TUI's status row
|
|
71
|
+
* lives there, so the boot line and the screen that replaces it occupy one row.
|
|
72
|
+
*/
|
|
73
|
+
readonly bottom?: boolean;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* The one boot reporter, used by `blackhole web` and `blackhole chat` alike.
|
|
77
|
+
*
|
|
78
|
+
* The line is rewritten in place with a carriage return, so a 25-second boot costs one
|
|
79
|
+
* row instead of a wall of log. On a terminal with rows, `bottom` parks that row at the
|
|
80
|
+
* bottom of the screen, where the TUI's status row will be.
|
|
81
|
+
* @param stream - the stream the line belongs to.
|
|
82
|
+
* @param initial - the first milestone label.
|
|
83
|
+
* @param options - interval, an explicit TTY override, and the bottom-row choice.
|
|
84
|
+
* @returns the reporter the caller advances.
|
|
85
|
+
*/
|
|
86
|
+
export declare function createBootReporter(stream: NodeJS.WriteStream, initial: string, options?: BootReporterOptions): BootReporter;
|
|
87
|
+
//# sourceMappingURL=boot.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"boot.d.ts","sourceRoot":"","sources":["../../src/harness/boot.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,6CAA6C;AAC7C,MAAM,WAAW,SAAS;IACxB,uDAAuD;IACvD,QAAQ,CAAC,EAAE,EAAE,SAAS,GAAG,QAAQ,GAAG,MAAM,CAAC;IAC3C,0CAA0C;IAC1C,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED,uDAAuD;AACvD,eAAO,MAAM,WAAW,EAAE,SAAS,SAAS,EAI1C,CAAC;AAEH,0DAA0D;AAC1D,eAAO,MAAM,UAAU,qBAAqB,CAAC;AAE7C,mDAAmD;AACnD,eAAO,MAAM,cAAc,EAAE,SAAS,MAAM,EAAsE,CAAC;AAEnH;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEjD;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAE5D;AAED,gFAAgF;AAChF,eAAO,MAAM,UAAU,gBAAgB,CAAC;AAExC;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CAKhE;AAED,8CAA8C;AAC9C,MAAM,WAAW,YAAY;IAC3B,qCAAqC;IACrC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,wEAAwE;IACxE,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,2CAA2C;IAC3C,KAAK,IAAI,IAAI,CAAC;CACf;AAED,yDAAyD;AACzD,MAAM,WAAW,mBAAmB;IAClC,wEAAwE;IACxE,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,oFAAoF;IACpF,QAAQ,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC;IACvB;;;OAGG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,MAAM,CAAC,WAAW,EAC1B,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,mBAAwB,GAChC,YAAY,CA8Bd"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Boot progress for every surface that waits on the harness (~20-40 s on this machine).
|
|
3
|
+
*
|
|
4
|
+
* Booting is three real phases and one spinner: the launcher mounts plugins, writes
|
|
5
|
+
* the composed config, then the host serves and prints its URL. The launcher already
|
|
6
|
+
* says which of those it reached in its own log, so the milestones are derived from
|
|
7
|
+
* that log rather than invented by a timer.
|
|
8
|
+
*
|
|
9
|
+
* ONE line, ONE wording, ONE erase for both surfaces: `blackhole web` and
|
|
10
|
+
* `blackhole chat` paint the same spinner and brand here, and both clear it the same
|
|
11
|
+
* way. A terminal gets one line rewritten in place; `chat` paints it on the last row,
|
|
12
|
+
* which is where the TUI's own status row sits, so the screen does not jump when the
|
|
13
|
+
* terminal takes over. A pipe gets nothing at all, because a progress spinner in a log
|
|
14
|
+
* file is noise.
|
|
15
|
+
*/
|
|
16
|
+
/** The milestones in the order a boot reaches them. */
|
|
17
|
+
export const BOOT_PHASES = Object.freeze([
|
|
18
|
+
Object.freeze({ id: "plugins", label: "Đang nạp plugin…" }),
|
|
19
|
+
Object.freeze({ id: "config", label: "Đang dựng cấu hình…" }),
|
|
20
|
+
Object.freeze({ id: "host", label: "Đang chờ host…" }),
|
|
21
|
+
]);
|
|
22
|
+
/** The brand both surfaces print beside the milestone. */
|
|
23
|
+
export const BOOT_BRAND = "Galaxy Blackhole";
|
|
24
|
+
/** The spinner frames, shared by every surface. */
|
|
25
|
+
export const SPINNER_FRAMES = Object.freeze(["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"]);
|
|
26
|
+
/**
|
|
27
|
+
* The frame for one tick.
|
|
28
|
+
* @param tick - a counter that only ever grows.
|
|
29
|
+
* @returns one spinner glyph.
|
|
30
|
+
*/
|
|
31
|
+
export function spinnerFrame(tick) {
|
|
32
|
+
return SPINNER_FRAMES[Math.abs(tick) % SPINNER_FRAMES.length] ?? SPINNER_FRAMES[0];
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* The one boot line every surface paints: spinner, brand, milestone.
|
|
36
|
+
* @param tick - the spinner counter.
|
|
37
|
+
* @param label - the milestone the launcher proved.
|
|
38
|
+
* @returns the text of the line, without any cursor control.
|
|
39
|
+
*/
|
|
40
|
+
export function bootLine(tick, label) {
|
|
41
|
+
return spinnerFrame(tick) + " " + BOOT_BRAND + " · " + label;
|
|
42
|
+
}
|
|
43
|
+
/** Erase the whole current line, the sequence both surfaces end a boot with. */
|
|
44
|
+
export const ERASE_LINE = "\r\u001b[2K";
|
|
45
|
+
/**
|
|
46
|
+
* Which milestone one launcher log line has reached, if it names one.
|
|
47
|
+
*
|
|
48
|
+
* The launcher prints its banner before it mounts plugins ("[bh] node", "[bh] harness",
|
|
49
|
+
* "[bh] argv"), the preset probes while plugins load ("agent-preset[...]"), and the
|
|
50
|
+
* web app last ("dsh web:" / "gbh web:"). Anything else keeps the current milestone.
|
|
51
|
+
* @param line - one line of launcher output, without its newline.
|
|
52
|
+
* @returns the phase the line proves, or undefined when it proves none.
|
|
53
|
+
*/
|
|
54
|
+
export function bootPhaseFor(line) {
|
|
55
|
+
if (/^(?:dsh|gbh) web: |devtools:/.test(line))
|
|
56
|
+
return BOOT_PHASES[2];
|
|
57
|
+
if (/^agent-preset\[/.test(line) || /mount|plugin|alias/.test(line))
|
|
58
|
+
return BOOT_PHASES[0];
|
|
59
|
+
if (/^\[bh\] (?:node|harness|DSH_HOME|profile|patch|rewrite|argv)\b/.test(line) || /^\[bh\] (?:doi id|chep icon)/.test(line))
|
|
60
|
+
return BOOT_PHASES[1];
|
|
61
|
+
return undefined;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* The one boot reporter, used by `blackhole web` and `blackhole chat` alike.
|
|
65
|
+
*
|
|
66
|
+
* The line is rewritten in place with a carriage return, so a 25-second boot costs one
|
|
67
|
+
* row instead of a wall of log. On a terminal with rows, `bottom` parks that row at the
|
|
68
|
+
* bottom of the screen, where the TUI's status row will be.
|
|
69
|
+
* @param stream - the stream the line belongs to.
|
|
70
|
+
* @param initial - the first milestone label.
|
|
71
|
+
* @param options - interval, an explicit TTY override, and the bottom-row choice.
|
|
72
|
+
* @returns the reporter the caller advances.
|
|
73
|
+
*/
|
|
74
|
+
export function createBootReporter(stream, initial, options = {}) {
|
|
75
|
+
const intervalMs = Math.max(16, options.intervalMs ?? 100);
|
|
76
|
+
const tty = options.tty ?? stream.isTTY === true;
|
|
77
|
+
const rows = options.bottom === true ? (stream.rows ?? 0) : 0;
|
|
78
|
+
// Moving to the bottom row costs one escape; erasing still happens in place.
|
|
79
|
+
const place = rows > 0 ? "\u001b[" + String(rows) + ";1H" : "";
|
|
80
|
+
let label = initial;
|
|
81
|
+
let tick = 0;
|
|
82
|
+
let stopped = false;
|
|
83
|
+
const paint = () => {
|
|
84
|
+
if (!tty || stopped)
|
|
85
|
+
return;
|
|
86
|
+
stream.write(place + ERASE_LINE + bootLine(tick, label));
|
|
87
|
+
};
|
|
88
|
+
const timer = tty ? setInterval(() => { tick += 1; paint(); }, intervalMs) : undefined;
|
|
89
|
+
if (timer !== undefined)
|
|
90
|
+
timer.unref?.();
|
|
91
|
+
paint();
|
|
92
|
+
return {
|
|
93
|
+
get label() { return label; },
|
|
94
|
+
step(next) {
|
|
95
|
+
if (stopped || next === label)
|
|
96
|
+
return;
|
|
97
|
+
label = next;
|
|
98
|
+
paint();
|
|
99
|
+
},
|
|
100
|
+
clear() {
|
|
101
|
+
if (stopped)
|
|
102
|
+
return;
|
|
103
|
+
stopped = true;
|
|
104
|
+
if (timer !== undefined)
|
|
105
|
+
clearInterval(timer);
|
|
106
|
+
if (tty)
|
|
107
|
+
stream.write(place + ERASE_LINE);
|
|
108
|
+
},
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=boot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"boot.js","sourceRoot":"","sources":["../../src/harness/boot.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAUH,uDAAuD;AACvD,MAAM,CAAC,MAAM,WAAW,GAAyB,MAAM,CAAC,MAAM,CAAC;IAC7D,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,kBAAkB,EAAE,CAAC;IAC3D,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,qBAAqB,EAAE,CAAC;IAC7D,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,gBAAgB,EAAE,CAAC;CACvD,CAAC,CAAC;AAEH,0DAA0D;AAC1D,MAAM,CAAC,MAAM,UAAU,GAAG,kBAAkB,CAAC;AAE7C,mDAAmD;AACnD,MAAM,CAAC,MAAM,cAAc,GAAsB,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;AAEnH;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,IAAY;IACvC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
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The two host catalogs the composer reads: permission presets and models.
|
|
3
|
+
*
|
|
4
|
+
* Both answers are additive across host versions — every field is optional — so the
|
|
5
|
+
* shapes here mirror the wire loosely and the screen only ever sees the folded result.
|
|
6
|
+
* `flattenModels` is the one interesting fold: the catalog groups models by provider,
|
|
7
|
+
* and the menu wants one flat list with each route's default effort and every effort
|
|
8
|
+
* that route accepts, because the reasoning submenu is opened from a model row.
|
|
9
|
+
*/
|
|
10
|
+
import type { ModelOption } from "./parts.js";
|
|
11
|
+
/** The permission catalog, as far as this terminal reads it. */
|
|
12
|
+
export interface PermissionCatalogLike {
|
|
13
|
+
readonly options?: readonly {
|
|
14
|
+
readonly value?: string;
|
|
15
|
+
readonly name?: string;
|
|
16
|
+
}[];
|
|
17
|
+
readonly defaultPreset?: string;
|
|
18
|
+
}
|
|
19
|
+
/** The model catalog, as far as this terminal reads it. */
|
|
20
|
+
export interface ModelCatalogLike {
|
|
21
|
+
readonly default?: {
|
|
22
|
+
readonly provider?: string;
|
|
23
|
+
readonly model?: string;
|
|
24
|
+
readonly reasoningEffort?: string;
|
|
25
|
+
};
|
|
26
|
+
readonly groups?: readonly {
|
|
27
|
+
readonly id?: string;
|
|
28
|
+
readonly name?: string;
|
|
29
|
+
readonly models?: readonly {
|
|
30
|
+
readonly id?: string;
|
|
31
|
+
readonly name?: string;
|
|
32
|
+
readonly description?: string;
|
|
33
|
+
readonly reasoning?: {
|
|
34
|
+
readonly defaultEffort?: string;
|
|
35
|
+
readonly efforts?: readonly {
|
|
36
|
+
readonly id?: string;
|
|
37
|
+
readonly name?: string;
|
|
38
|
+
readonly description?: string;
|
|
39
|
+
}[];
|
|
40
|
+
};
|
|
41
|
+
}[];
|
|
42
|
+
}[];
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Flatten the provider groups into one menu list, keeping each route's default effort.
|
|
46
|
+
* @param catalog - the host's `session.modelCatalog` answer.
|
|
47
|
+
* @returns one row per provider/model route, in catalog order.
|
|
48
|
+
*/
|
|
49
|
+
export declare function flattenModels(catalog: ModelCatalogLike): readonly ModelOption[];
|
|
50
|
+
//# sourceMappingURL=catalogs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catalogs.d.ts","sourceRoot":"","sources":["../../src/harness/catalogs.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,gEAAgE;AAChE,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS;QAAE,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAClF,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;CACjC;AAED,2DAA2D;AAC3D,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,OAAO,CAAC,EAAE;QAAE,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC9G,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS;QACzB,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC;QACrB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QACvB,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS;YACzB,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC;YACrB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;YACvB,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;YAC9B,QAAQ,CAAC,SAAS,CAAC,EAAE;gBACnB,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;gBAChC,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS;oBAAE,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC;oBAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;oBAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAA;iBAAE,EAAE,CAAC;aAC/G,CAAC;SACH,EAAE,CAAC;KACL,EAAE,CAAC;CACL;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,gBAAgB,GAAG,SAAS,WAAW,EAAE,CAyB/E"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flatten the provider groups into one menu list, keeping each route's default effort.
|
|
3
|
+
* @param catalog - the host's `session.modelCatalog` answer.
|
|
4
|
+
* @returns one row per provider/model route, in catalog order.
|
|
5
|
+
*/
|
|
6
|
+
export function flattenModels(catalog) {
|
|
7
|
+
const options = [];
|
|
8
|
+
for (const group of catalog.groups ?? []) {
|
|
9
|
+
const provider = group.id;
|
|
10
|
+
if (provider === undefined)
|
|
11
|
+
continue;
|
|
12
|
+
for (const model of group.models ?? []) {
|
|
13
|
+
if (model.id === undefined)
|
|
14
|
+
continue;
|
|
15
|
+
const effort = model.reasoning?.defaultEffort;
|
|
16
|
+
const effortName = effort === undefined ? undefined : model.reasoning?.efforts?.find(entry => entry.id === effort)?.name;
|
|
17
|
+
const efforts = (model.reasoning?.efforts ?? []).flatMap(entry => (entry.id === undefined
|
|
18
|
+
? []
|
|
19
|
+
: [{ id: entry.id, name: entry.name ?? entry.id, ...(entry.description === undefined ? {} : { description: entry.description }) }]));
|
|
20
|
+
options.push({
|
|
21
|
+
provider,
|
|
22
|
+
model: model.id,
|
|
23
|
+
name: model.name ?? model.id,
|
|
24
|
+
...(model.description === undefined ? {} : { description: model.description }),
|
|
25
|
+
...(effort === undefined ? {} : { effort }),
|
|
26
|
+
...(effortName === undefined ? {} : { effortName }),
|
|
27
|
+
...(efforts.length === 0 ? {} : { efforts }),
|
|
28
|
+
...(group.name === undefined ? {} : { hint: group.name }),
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return options;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=catalogs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catalogs.js","sourceRoot":"","sources":["../../src/harness/catalogs.ts"],"names":[],"mappings":"AAmCA;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,OAAyB;IACrD,MAAM,OAAO,GAAkB,EAAE,CAAC;IAClC,KAAK,MAAM,KAAK,IAAI,OAAO,CAAC,MAAM,IAAI,EAAE,EAAE,CAAC;QACzC,MAAM,QAAQ,GAAG,KAAK,CAAC,EAAE,CAAC;QAC1B,IAAI,QAAQ,KAAK,SAAS;YAAE,SAAS;QACrC,KAAK,MAAM,KAAK,IAAI,KAAK,CAAC,MAAM,IAAI,EAAE,EAAE,CAAC;YACvC,IAAI,KAAK,CAAC,EAAE,KAAK,SAAS;gBAAE,SAAS;YACrC,MAAM,MAAM,GAAG,KAAK,CAAC,SAAS,EAAE,aAAa,CAAC;YAC9C,MAAM,UAAU,GAAG,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,SAAS,EAAE,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,MAAM,CAAC,EAAE,IAAI,CAAC;YACzH,MAAM,OAAO,GAAG,CAAC,KAAK,CAAC,SAAS,EAAE,OAAO,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,EAAE,KAAK,SAAS;gBACvF,CAAC,CAAC,EAAE;gBACJ,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,KAAK,CAAC,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,EAAE,EAAE,GAAG,CAAC,KAAK,CAAC,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,KAAK,CAAC,WAAW,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;YACvI,OAAO,CAAC,IAAI,CAAC;gBACX,QAAQ;gBACR,KAAK,EAAE,KAAK,CAAC,EAAE;gBACf,IAAI,EAAE,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,EAAE;gBAC5B,GAAG,CAAC,KAAK,CAAC,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,KAAK,CAAC,WAAW,EAAE,CAAC;gBAC9E,GAAG,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC;gBAC3C,GAAG,CAAC,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC;gBACnD,GAAG,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC;gBAC5C,GAAG,CAAC,KAAK,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC;aAC1D,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One conversation on the Galaxy Blackhole harness.
|
|
3
|
+
*
|
|
4
|
+
* A turn is: open the session's follow stream, send the prompt, translate the
|
|
5
|
+
* harness's durable events (and its live assistant chunks) into terminal-sized
|
|
6
|
+
* facts, and stop at `turn/end`. Nothing here reaches for the old ai-coder-core
|
|
7
|
+
* runtime: the model, the tools and the transcript all live in the harness.
|
|
8
|
+
*/
|
|
9
|
+
import type { HarnessClient } from "./client.js";
|
|
10
|
+
import { type TodoItem } from "./history.js";
|
|
11
|
+
/** The model call this turn used, when the harness reported one. */
|
|
12
|
+
export interface ChatModelFact {
|
|
13
|
+
readonly provider?: string;
|
|
14
|
+
readonly model?: string;
|
|
15
|
+
}
|
|
16
|
+
/** One fact the terminal can render. */
|
|
17
|
+
export type ChatChunk = {
|
|
18
|
+
readonly kind: "status";
|
|
19
|
+
readonly label: string;
|
|
20
|
+
} | {
|
|
21
|
+
readonly kind: "text";
|
|
22
|
+
readonly text: string;
|
|
23
|
+
} | {
|
|
24
|
+
readonly kind: "reasoning";
|
|
25
|
+
readonly text: string;
|
|
26
|
+
} | {
|
|
27
|
+
readonly kind: "tool-start";
|
|
28
|
+
readonly id: string;
|
|
29
|
+
readonly name: string;
|
|
30
|
+
readonly args: Readonly<Record<string, unknown>>;
|
|
31
|
+
} | {
|
|
32
|
+
readonly kind: "tool-end";
|
|
33
|
+
readonly id: string;
|
|
34
|
+
readonly ok: boolean;
|
|
35
|
+
readonly summary: string;
|
|
36
|
+
} | {
|
|
37
|
+
readonly kind: "todo";
|
|
38
|
+
readonly todos: readonly TodoItem[];
|
|
39
|
+
} | {
|
|
40
|
+
readonly kind: "meta";
|
|
41
|
+
readonly sessionId: string;
|
|
42
|
+
readonly durationMs: number;
|
|
43
|
+
readonly model?: ChatModelFact;
|
|
44
|
+
readonly tokens?: number;
|
|
45
|
+
} | {
|
|
46
|
+
readonly kind: "error";
|
|
47
|
+
readonly message: string;
|
|
48
|
+
};
|
|
49
|
+
/** How one turn ended. */
|
|
50
|
+
export interface ChatTurnResult {
|
|
51
|
+
readonly state: "completed" | "aborted" | "error";
|
|
52
|
+
/** Everything the assistant said, joined. */
|
|
53
|
+
readonly text: string;
|
|
54
|
+
readonly error?: string;
|
|
55
|
+
readonly sessionId: string;
|
|
56
|
+
readonly turn?: number;
|
|
57
|
+
}
|
|
58
|
+
/** One followable session and its next turn. */
|
|
59
|
+
export declare class HarnessChat {
|
|
60
|
+
private readonly client;
|
|
61
|
+
private readonly options;
|
|
62
|
+
private sessionId;
|
|
63
|
+
private baselineTurn;
|
|
64
|
+
private model;
|
|
65
|
+
constructor(client: HarnessClient, options: Readonly<{
|
|
66
|
+
cwd: string;
|
|
67
|
+
model?: string;
|
|
68
|
+
sessionId?: string;
|
|
69
|
+
preset?: string;
|
|
70
|
+
}>);
|
|
71
|
+
/**
|
|
72
|
+
* The harness session behind this conversation.
|
|
73
|
+
* @returns the session named at construction, or the draft created on first use.
|
|
74
|
+
*/
|
|
75
|
+
ensureSession(): Promise<string>;
|
|
76
|
+
/** Facts for the /session panel. */
|
|
77
|
+
info(): Readonly<{
|
|
78
|
+
sessionId?: string;
|
|
79
|
+
base: string;
|
|
80
|
+
}>;
|
|
81
|
+
/**
|
|
82
|
+
* Send one prompt and translate the turn.
|
|
83
|
+
* @param goal - the text the user typed.
|
|
84
|
+
* @param onChunk - called for every renderable fact, in order.
|
|
85
|
+
* @param signal - cancellation; the turn is cancelled on the host too.
|
|
86
|
+
* @returns the settled turn.
|
|
87
|
+
*/
|
|
88
|
+
send(goal: string, onChunk: (chunk: ChatChunk) => void, signal: AbortSignal): Promise<ChatTurnResult>;
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=chat.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat.d.ts","sourceRoot":"","sources":["../../src/harness/chat.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAA4B,aAAa,EAAE,MAAM,aAAa,CAAC;AAC3E,OAAO,EAAa,KAAK,QAAQ,EAAE,MAAM,cAAc,CAAC;AAGxD,oEAAoE;AACpE,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,KAAK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