@galaxy-stack/blackhole-cli 2.4.0 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (164) hide show
  1. package/README.md +82 -47
  2. package/dist/application.d.ts.map +1 -1
  3. package/dist/application.js +13 -2
  4. package/dist/application.js.map +1 -1
  5. package/dist/cli-meta.d.ts +8 -0
  6. package/dist/cli-meta.d.ts.map +1 -1
  7. package/dist/cli-meta.js +11 -0
  8. package/dist/cli-meta.js.map +1 -1
  9. package/dist/cli.js +26 -9
  10. package/dist/cli.js.map +1 -1
  11. package/dist/config-command.d.ts +11 -14
  12. package/dist/config-command.d.ts.map +1 -1
  13. package/dist/config-command.js +41 -118
  14. package/dist/config-command.js.map +1 -1
  15. package/dist/doctor.d.ts +8 -2
  16. package/dist/doctor.d.ts.map +1 -1
  17. package/dist/doctor.js +11 -15
  18. package/dist/doctor.js.map +1 -1
  19. package/dist/file-index.d.ts +50 -0
  20. package/dist/file-index.d.ts.map +1 -1
  21. package/dist/file-index.js +124 -0
  22. package/dist/file-index.js.map +1 -1
  23. package/dist/harness/boot.d.ts +87 -0
  24. package/dist/harness/boot.d.ts.map +1 -0
  25. package/dist/harness/boot.js +111 -0
  26. package/dist/harness/boot.js.map +1 -0
  27. package/dist/harness/catalogs.d.ts +50 -0
  28. package/dist/harness/catalogs.d.ts.map +1 -0
  29. package/dist/harness/catalogs.js +34 -0
  30. package/dist/harness/catalogs.js.map +1 -0
  31. package/dist/harness/chat.d.ts +90 -0
  32. package/dist/harness/chat.d.ts.map +1 -0
  33. package/dist/harness/chat.js +260 -0
  34. package/dist/harness/chat.js.map +1 -0
  35. package/dist/harness/client.d.ts +72 -0
  36. package/dist/harness/client.d.ts.map +1 -0
  37. package/dist/harness/client.js +173 -0
  38. package/dist/harness/client.js.map +1 -0
  39. package/dist/harness/command.d.ts +22 -0
  40. package/dist/harness/command.d.ts.map +1 -0
  41. package/dist/harness/command.js +142 -0
  42. package/dist/harness/command.js.map +1 -0
  43. package/dist/harness/composer.d.ts +46 -0
  44. package/dist/harness/composer.d.ts.map +1 -0
  45. package/dist/harness/composer.js +127 -0
  46. package/dist/harness/composer.js.map +1 -0
  47. package/dist/harness/conversation.d.ts +75 -0
  48. package/dist/harness/conversation.d.ts.map +1 -0
  49. package/dist/harness/conversation.js +196 -0
  50. package/dist/harness/conversation.js.map +1 -0
  51. package/dist/harness/help.d.ts +56 -0
  52. package/dist/harness/help.d.ts.map +1 -0
  53. package/dist/harness/help.js +85 -0
  54. package/dist/harness/help.js.map +1 -0
  55. package/dist/harness/history.d.ts +108 -0
  56. package/dist/harness/history.d.ts.map +1 -0
  57. package/dist/harness/history.js +268 -0
  58. package/dist/harness/history.js.map +1 -0
  59. package/dist/harness/labels.d.ts +164 -0
  60. package/dist/harness/labels.d.ts.map +1 -0
  61. package/dist/harness/labels.js +271 -0
  62. package/dist/harness/labels.js.map +1 -0
  63. package/dist/harness/locate.d.ts +28 -0
  64. package/dist/harness/locate.d.ts.map +1 -0
  65. package/dist/harness/locate.js +73 -0
  66. package/dist/harness/locate.js.map +1 -0
  67. package/dist/harness/menus.d.ts +74 -0
  68. package/dist/harness/menus.d.ts.map +1 -0
  69. package/dist/harness/menus.js +140 -0
  70. package/dist/harness/menus.js.map +1 -0
  71. package/dist/harness/model-name.d.ts +73 -0
  72. package/dist/harness/model-name.d.ts.map +1 -0
  73. package/dist/harness/model-name.js +101 -0
  74. package/dist/harness/model-name.js.map +1 -0
  75. package/dist/harness/node-runtime.d.ts +64 -0
  76. package/dist/harness/node-runtime.d.ts.map +1 -0
  77. package/dist/harness/node-runtime.js +109 -0
  78. package/dist/harness/node-runtime.js.map +1 -0
  79. package/dist/harness/parts.d.ts +239 -0
  80. package/dist/harness/parts.d.ts.map +1 -0
  81. package/dist/harness/parts.js +266 -0
  82. package/dist/harness/parts.js.map +1 -0
  83. package/dist/harness/preset.d.ts +124 -0
  84. package/dist/harness/preset.d.ts.map +1 -0
  85. package/dist/harness/preset.js +197 -0
  86. package/dist/harness/preset.js.map +1 -0
  87. package/dist/harness/process.d.ts +55 -0
  88. package/dist/harness/process.d.ts.map +1 -0
  89. package/dist/harness/process.js +124 -0
  90. package/dist/harness/process.js.map +1 -0
  91. package/dist/harness/screen.d.ts +33 -0
  92. package/dist/harness/screen.d.ts.map +1 -0
  93. package/dist/harness/screen.js +1070 -0
  94. package/dist/harness/screen.js.map +1 -0
  95. package/dist/harness/sessions.d.ts +55 -0
  96. package/dist/harness/sessions.d.ts.map +1 -0
  97. package/dist/harness/sessions.js +92 -0
  98. package/dist/harness/sessions.js.map +1 -0
  99. package/dist/harness/skills.d.ts +90 -0
  100. package/dist/harness/skills.d.ts.map +1 -0
  101. package/dist/harness/skills.js +133 -0
  102. package/dist/harness/skills.js.map +1 -0
  103. package/dist/harness/slash-palette.d.ts +32 -0
  104. package/dist/harness/slash-palette.d.ts.map +1 -0
  105. package/dist/harness/slash-palette.js +48 -0
  106. package/dist/harness/slash-palette.js.map +1 -0
  107. package/dist/harness/slash.d.ts +113 -0
  108. package/dist/harness/slash.d.ts.map +1 -0
  109. package/dist/harness/slash.js +187 -0
  110. package/dist/harness/slash.js.map +1 -0
  111. package/dist/harness/trajectory.d.ts +74 -0
  112. package/dist/harness/trajectory.d.ts.map +1 -0
  113. package/dist/harness/trajectory.js +270 -0
  114. package/dist/harness/trajectory.js.map +1 -0
  115. package/dist/harness/tui.d.ts +28 -0
  116. package/dist/harness/tui.d.ts.map +1 -0
  117. package/dist/harness/tui.js +143 -0
  118. package/dist/harness/tui.js.map +1 -0
  119. package/dist/manual-config.d.ts +23 -10
  120. package/dist/manual-config.d.ts.map +1 -1
  121. package/dist/manual-config.js +45 -37
  122. package/dist/manual-config.js.map +1 -1
  123. package/dist/migrate.d.ts +32 -0
  124. package/dist/migrate.d.ts.map +1 -0
  125. package/dist/migrate.js +155 -0
  126. package/dist/migrate.js.map +1 -0
  127. package/dist/options.d.ts +5 -1
  128. package/dist/options.d.ts.map +1 -1
  129. package/dist/options.js +23 -4
  130. package/dist/options.js.map +1 -1
  131. package/dist/setup.d.ts +14 -10
  132. package/dist/setup.d.ts.map +1 -1
  133. package/dist/setup.js +25 -92
  134. package/dist/setup.js.map +1 -1
  135. package/dist/timeline.d.ts.map +1 -1
  136. package/dist/timeline.js +11 -0
  137. package/dist/timeline.js.map +1 -1
  138. package/dist/web/command.d.ts +5 -1
  139. package/dist/web/command.d.ts.map +1 -1
  140. package/dist/web/command.js +34 -6
  141. package/dist/web/command.js.map +1 -1
  142. package/dist/web/credentials.d.ts +7 -5
  143. package/dist/web/credentials.d.ts.map +1 -1
  144. package/dist/web/credentials.js +13 -48
  145. package/dist/web/credentials.js.map +1 -1
  146. package/dist/web/doctor.d.ts +1 -1
  147. package/dist/web/doctor.d.ts.map +1 -1
  148. package/dist/web/doctor.js +49 -61
  149. package/dist/web/doctor.js.map +1 -1
  150. package/dist/web/options.d.ts +26 -2
  151. package/dist/web/options.d.ts.map +1 -1
  152. package/dist/web/options.js +54 -18
  153. package/dist/web/options.js.map +1 -1
  154. package/dist/web/paths.d.ts +1 -1
  155. package/dist/web/paths.d.ts.map +1 -1
  156. package/dist/web/paths.js +2 -2
  157. package/dist/web/paths.js.map +1 -1
  158. package/dist/web/web.d.ts +56 -16
  159. package/dist/web/web.d.ts.map +1 -1
  160. package/dist/web/web.js +184 -168
  161. package/dist/web/web.js.map +1 -1
  162. package/package.json +4 -3
  163. package/web/brand/lib/client.js +4 -4
  164. package/web/patches/gbh-ui.patch.yml +6 -24
@@ -0,0 +1 @@
1
+ {"version":3,"file":"menus.d.ts","sourceRoot":"","sources":["../../src/harness/menus.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAmC,KAAK,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEtF,8BAA8B;AAC9B,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,OAAO,GAAG,QAAQ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,iBAAiB,EAAO,EAC1C,aAAa,CAAC,EAAE,MAAM,GACrB,SAAS,UAAU,EAAE,CAmBvB;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,QAAQ,GAAG,MAAM,CAMhD;AAED;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,GAAG,SAAS,EAAE,YAAY,EAAE,MAAM,GAAG,SAAS,EAAE,MAAM,EAAE,MAAM,GAAG,SAAS,EAAE,aAAa,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAMvL"}
@@ -0,0 +1,140 @@
1
+ /**
2
+ * The dropdowns the composer opens: agent mode, access, model, reasoning effort, and "Thêm".
3
+ *
4
+ * The screen owns the state machine (which menu is open and which row is on); this
5
+ * module owns the wording and the option lists, so the rows are pure data a test can
6
+ * assert on without mounting Ink. Effort ids come from the harness catalog
7
+ * (session.modelCatalog -> groups[].models[].reasoning.efforts[].id); the labels are
8
+ * the app's four words, with the host's own name as the fallback for an id we have
9
+ * never seen.
10
+ */
11
+ import { UI } from "./labels.js";
12
+ import { MODE_MENU_TITLE, presetMenuRows } from "./preset.js";
13
+ /** The value the effort submenu uses for "no explicit effort". */
14
+ export const DEFAULT_EFFORT_VALUE = "";
15
+ /** Vietnamese names for the effort ids the harness catalogs today. */
16
+ const EFFORT_LABELS = Object.freeze({
17
+ off: "Tắt",
18
+ none: "Tắt",
19
+ minimal: "Thấp",
20
+ low: "Thấp",
21
+ medium: "Trung bình",
22
+ high: "Cao",
23
+ xhigh: "Tối đa",
24
+ max: "Tối đa",
25
+ });
26
+ /**
27
+ * The Vietnamese name of one effort id.
28
+ * @param id - the host's effort id, e.g. "high".
29
+ * @param fallback - the host's own name for ids this table does not know.
30
+ * @returns the label the chip and the menu show.
31
+ */
32
+ export function effortLabel(id, fallback) {
33
+ if (id === undefined || id.length === 0)
34
+ return UI.defaultEffort;
35
+ return EFFORT_LABELS[id] ?? fallback ?? id;
36
+ }
37
+ /**
38
+ * The rows of the reasoning submenu for one model: "Mặc định" then the host's efforts.
39
+ * @param model - the model the catalog described, when one is selected.
40
+ * @returns the rows, "Mặc định" first.
41
+ */
42
+ export function effortOptions(model) {
43
+ const rows = [{
44
+ value: DEFAULT_EFFORT_VALUE,
45
+ label: UI.defaultEffort,
46
+ description: "Để harness tự chọn mức suy luận cho model này.",
47
+ hint: "mặc định",
48
+ }];
49
+ for (const effort of model?.efforts ?? []) {
50
+ rows.push({
51
+ value: effort.id,
52
+ label: effortLabel(effort.id, effort.name),
53
+ hint: effort.id,
54
+ ...(effort.description === undefined ? {} : { description: effort.description }),
55
+ });
56
+ }
57
+ return rows;
58
+ }
59
+ /**
60
+ * The rows of the "Thêm" menu: both entries really act.
61
+ * @returns the rows, in the order the composer shows them.
62
+ */
63
+ export function plusOptions() {
64
+ return [
65
+ { value: "attach", label: UI.attach, description: "Chọn một tệp trong workspace và chèn @đường-dẫn vào ô soạn." },
66
+ { value: "workspace", label: UI.chooseWorkspace, description: "Mở phiên mới ở một workspace khác." },
67
+ ];
68
+ }
69
+ /**
70
+ * The rows of any menu, as the panel renders them.
71
+ * @param state - the open menu.
72
+ * @param accessOptions - preset rows from the permission catalog.
73
+ * @param models - model rows from the model catalog.
74
+ * @param currentAccess - preset in force, marked as in use.
75
+ * @param currentModel - provider/model in force, marked as in use.
76
+ * @param presets - agent-mode rows from `agentPresets/list`, the mode menu's list.
77
+ * @param currentPreset - agent mode the session records, marked as in use.
78
+ * @returns the rows for the open menu; empty when no menu is open.
79
+ */
80
+ export function menuRows(state, accessOptions, models, currentAccess, currentModel, presets = [], currentPreset) {
81
+ if (state === undefined)
82
+ return [];
83
+ if (state.kind === "mode")
84
+ return presetMenuRows(presets, currentPreset);
85
+ if (state.kind === "access") {
86
+ return accessOptions.map(option => ({
87
+ value: option.value,
88
+ label: option.label,
89
+ ...(option.description === undefined ? {} : { description: option.description }),
90
+ ...(option.value === currentAccess ? { hint: "đang dùng" } : {}),
91
+ }));
92
+ }
93
+ if (state.kind === "plus")
94
+ return plusOptions();
95
+ if (state.kind === "effort")
96
+ return effortOptions(models[state.modelIndex ?? state.index]);
97
+ return models.map(option => ({
98
+ value: option.provider + "/" + option.model,
99
+ label: option.name,
100
+ ...(option.description === undefined ? {} : { description: option.description }),
101
+ hint: option.hint ?? option.model,
102
+ }));
103
+ }
104
+ /**
105
+ * The heading of one menu.
106
+ * @param kind - the open menu.
107
+ * @returns the title line.
108
+ */
109
+ export function menuTitle(kind) {
110
+ if (kind === "access")
111
+ return UI.accessMenu;
112
+ if (kind === "effort")
113
+ return UI.effortMenu;
114
+ if (kind === "plus")
115
+ return UI.plusMenu;
116
+ if (kind === "mode")
117
+ return MODE_MENU_TITLE;
118
+ return UI.modelMenu;
119
+ }
120
+ /**
121
+ * The value the panel marks with a check for the open menu.
122
+ * @param kind - the open menu.
123
+ * @param currentAccess - preset in force.
124
+ * @param currentModel - provider/model in force.
125
+ * @param effort - effort in force, empty for "Mặc định".
126
+ * @param currentPreset - agent mode the session records.
127
+ * @returns the checked row value, or undefined when nothing is in force yet.
128
+ */
129
+ export function menuCurrent(kind, currentAccess, currentModel, effort, currentPreset) {
130
+ if (kind === "access")
131
+ return currentAccess;
132
+ if (kind === "effort")
133
+ return effort ?? DEFAULT_EFFORT_VALUE;
134
+ if (kind === "mode")
135
+ return currentPreset;
136
+ if (kind === "plus")
137
+ return undefined;
138
+ return currentModel;
139
+ }
140
+ //# sourceMappingURL=menus.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"menus.js","sourceRoot":"","sources":["../../src/harness/menus.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AAEjC,OAAO,EAAE,eAAe,EAAE,cAAc,EAA0B,MAAM,aAAa,CAAC;AAwBtF,kEAAkE;AAClE,MAAM,CAAC,MAAM,oBAAoB,GAAG,EAAE,CAAC;AAEvC,sEAAs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
5
+ * provider's display name and every model carries its own. The wire ids behind them
6
+ * (`auto`, `deepseek-v4.1-flash`) are plumbing, so every surface that prints a route
7
+ * — the ledger's "Model ·" row, the session panel, the composer chip, the status row —
8
+ * goes through this module. A route the host does not describe keeps its ids: naming
9
+ * someone else's model is not this terminal's call.
10
+ */
11
+ import type { ModelCatalogLike } from "./catalogs.js";
12
+ /** The provider id every Galaxy-managed route resolves to. */
13
+ export declare const MANAGED_PROVIDER_ID = "auto";
14
+ /** The one model id behind the managed route today. */
15
+ export declare const MANAGED_MODEL_ID = "deepseek-v4.1-flash";
16
+ /** The brand the managed route reads as. */
17
+ export declare const MANAGED_PROVIDER_NAME = "Galaxy Blackhole";
18
+ /** The managed model's own word: it is the router's automatic choice, not a model name. */
19
+ export declare const MANAGED_MODEL_NAME = "Auto";
20
+ /** Everything this module knows about naming routes. */
21
+ export interface ModelNames {
22
+ /** provider id → the provider's display name. */
23
+ readonly providers: Readonly<Record<string, string>>;
24
+ /** `provider/model` → the model's display name. */
25
+ readonly models: Readonly<Record<string, string>>;
26
+ }
27
+ /** One route a catalog or the composer's flattened list carries. */
28
+ export interface NamedRoute {
29
+ readonly provider: string;
30
+ readonly model: string;
31
+ /** The model's display name. */
32
+ readonly name?: string;
33
+ /** The provider group's display name, as `flattenModels` carries it. */
34
+ readonly hint?: string;
35
+ }
36
+ /**
37
+ * Build the name table from the host's catalog.
38
+ * @param catalog - `session.modelCatalog` as the host answered it.
39
+ * @returns provider and model display names, with the managed route always named.
40
+ */
41
+ export declare function modelNames(catalog?: ModelCatalogLike): ModelNames;
42
+ /**
43
+ * The same table from the composer's flattened rows.
44
+ * @param routes - `flattenModels` output, or nothing while the catalog loads.
45
+ * @returns provider and model display names.
46
+ */
47
+ export declare function modelNamesOf(routes?: readonly NamedRoute[]): ModelNames;
48
+ /** The table this module falls back to: the managed route, nothing else. */
49
+ export declare const DEFAULT_MODEL_NAMES: ModelNames;
50
+ /**
51
+ * The provider's own name.
52
+ * @param provider - the provider id the harness reported.
53
+ * @param names - the catalog's table.
54
+ * @returns the display name, or the id when nothing names it.
55
+ */
56
+ export declare function providerName(provider: string | undefined, names?: ModelNames): string | undefined;
57
+ /**
58
+ * The model's own name inside its provider.
59
+ * @param provider - the provider id the harness reported, when it reported one.
60
+ * @param model - the model id the harness reported.
61
+ * @param names - the catalog's table.
62
+ * @returns the display name, or the id when nothing names it.
63
+ */
64
+ export declare function modelName(provider: string | undefined, model: string | undefined, names?: ModelNames): string | undefined;
65
+ /**
66
+ * One route as a person reads it: "Galaxy Blackhole/Auto".
67
+ * @param provider - the provider id the harness reported.
68
+ * @param model - the model id the harness reported.
69
+ * @param names - the catalog's table; the managed route is named without one.
70
+ * @returns "provider/model" display names, or the ids when nothing names them.
71
+ */
72
+ export declare function modelRouteName(provider: string | undefined, model: string | undefined, names?: ModelNames): string;
73
+ //# sourceMappingURL=model-name.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model-name.d.ts","sourceRoot":"","sources":["../../src/harness/model-name.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEtD,8DAA8D;AAC9D,eAAO,MAAM,mBAAmB,SAAS,CAAC;AAE1C,uDAAuD;AACvD,eAAO,MAAM,gBAAgB,wBAAwB,CAAC;AAEtD,4CAA4C;AAC5C,eAAO,MAAM,qBAAqB,qBAAqB,CAAC;AAExD,2FAA2F;AAC3F,eAAO,MAAM,kBAAkB,SAAS,CAAC;AAEzC,wDAAwD;AACxD,MAAM,WAAW,UAAU;IACzB,iDAAiD;IACjD,QAAQ,CAAC,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACrD,mDAAmD;IACnD,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CACnD;AAED,oEAAoE;AACpE,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,gCAAgC;IAChC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,wEAAwE;IACxE,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;CACxB;AAaD;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,OAAO,CAAC,EAAE,gBAAgB,GAAG,UAAU,CAWjE;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,MAAM,CAAC,EAAE,SAAS,UAAU,EAAE,GAAG,UAAU,CAOvE;AAED,4EAA4E;AAC5E,eAAO,MAAM,mBAAmB,EAAE,UAAyB,CAAC;AAE5D;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,EAAE,KAAK,GAAE,UAAgC,GAAG,MAAM,GAAG,SAAS,CAGtH;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS,EAAE,KAAK,GAAE,UAAgC,GAAG,MAAM,GAAG,SAAS,CAO9I;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS,EAAE,KAAK,GAAE,UAAgC,GAAG,MAAM,CAMvI"}
@@ -0,0 +1,101 @@
1
+ /** The provider id every Galaxy-managed route resolves to. */
2
+ export const MANAGED_PROVIDER_ID = "auto";
3
+ /** The one model id behind the managed route today. */
4
+ export const MANAGED_MODEL_ID = "deepseek-v4.1-flash";
5
+ /** The brand the managed route reads as. */
6
+ export const MANAGED_PROVIDER_NAME = "Galaxy Blackhole";
7
+ /** The managed model's own word: it is the router's automatic choice, not a model name. */
8
+ export const MANAGED_MODEL_NAME = "Auto";
9
+ /**
10
+ * Start a table from the managed route, so a line is right before the catalog answers.
11
+ * @returns mutable maps seeded with the managed names.
12
+ */
13
+ function managedTables() {
14
+ return {
15
+ providers: { [MANAGED_PROVIDER_ID]: MANAGED_PROVIDER_NAME },
16
+ models: { [MANAGED_PROVIDER_ID + "/" + MANAGED_MODEL_ID]: MANAGED_MODEL_NAME },
17
+ };
18
+ }
19
+ /**
20
+ * Build the name table from the host's catalog.
21
+ * @param catalog - `session.modelCatalog` as the host answered it.
22
+ * @returns provider and model display names, with the managed route always named.
23
+ */
24
+ export function modelNames(catalog) {
25
+ const tables = managedTables();
26
+ for (const group of catalog?.groups ?? []) {
27
+ if (group.id === undefined)
28
+ continue;
29
+ if (group.name !== undefined)
30
+ tables.providers[group.id] = group.name;
31
+ for (const model of group.models ?? []) {
32
+ if (model.id === undefined || model.name === undefined)
33
+ continue;
34
+ tables.models[group.id + "/" + model.id] = model.name;
35
+ }
36
+ }
37
+ return Object.freeze({ providers: Object.freeze(tables.providers), models: Object.freeze(tables.models) });
38
+ }
39
+ /**
40
+ * The same table from the composer's flattened rows.
41
+ * @param routes - `flattenModels` output, or nothing while the catalog loads.
42
+ * @returns provider and model display names.
43
+ */
44
+ export function modelNamesOf(routes) {
45
+ const tables = managedTables();
46
+ for (const route of routes ?? []) {
47
+ if (route.hint !== undefined)
48
+ tables.providers[route.provider] = route.hint;
49
+ if (route.name !== undefined)
50
+ tables.models[route.provider + "/" + route.model] = route.name;
51
+ }
52
+ return Object.freeze({ providers: Object.freeze(tables.providers), models: Object.freeze(tables.models) });
53
+ }
54
+ /** The table this module falls back to: the managed route, nothing else. */
55
+ export const DEFAULT_MODEL_NAMES = modelNames();
56
+ /**
57
+ * The provider's own name.
58
+ * @param provider - the provider id the harness reported.
59
+ * @param names - the catalog's table.
60
+ * @returns the display name, or the id when nothing names it.
61
+ */
62
+ export function providerName(provider, names = DEFAULT_MODEL_NAMES) {
63
+ if (provider === undefined || provider.length === 0)
64
+ return undefined;
65
+ return names.providers[provider] ?? provider;
66
+ }
67
+ /**
68
+ * The model's own name inside its provider.
69
+ * @param provider - the provider id the harness reported, when it reported one.
70
+ * @param model - the model id the harness reported.
71
+ * @param names - the catalog's table.
72
+ * @returns the display name, or the id when nothing names it.
73
+ */
74
+ export function modelName(provider, model, names = DEFAULT_MODEL_NAMES) {
75
+ if (model === undefined || model.length === 0)
76
+ return undefined;
77
+ const named = provider === undefined ? undefined : names.models[provider + "/" + model];
78
+ if (named !== undefined)
79
+ return named;
80
+ // The managed model keeps its own word even when only its id is in hand.
81
+ if (model === MANAGED_MODEL_ID && (provider === undefined || provider === MANAGED_PROVIDER_ID))
82
+ return MANAGED_MODEL_NAME;
83
+ return model;
84
+ }
85
+ /**
86
+ * One route as a person reads it: "Galaxy Blackhole/Auto".
87
+ * @param provider - the provider id the harness reported.
88
+ * @param model - the model id the harness reported.
89
+ * @param names - the catalog's table; the managed route is named without one.
90
+ * @returns "provider/model" display names, or the ids when nothing names them.
91
+ */
92
+ export function modelRouteName(provider, model, names = DEFAULT_MODEL_NAMES) {
93
+ const namedProvider = providerName(provider, names);
94
+ const namedModel = modelName(provider, model, names);
95
+ if (namedProvider === undefined)
96
+ return namedModel ?? "";
97
+ if (namedModel === undefined)
98
+ return namedProvider;
99
+ return namedProvider + "/" + namedModel;
100
+ }
101
+ //# sourceMappingURL=model-name.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model-name.js","sourceRoot":"","sources":["../../src/harness/model-name.ts"],"names":[],"mappings":"AAYA,8DAA8D;AAC9D,MAAM,CAAC,MAAM,mBAAmB,GAAG,MAAM,CAAC;AAE1C,uDAAuD;AACvD,MAAM,CAAC,MAAM,gBAAgB,GAAG,qBAAqB,CAAC;AAEtD,4CAA4C;AAC5C,MAAM,CAAC,MAAM,qBAAqB,GAAG,kBAAkB,CAAC;AAExD,2FAA2F;AAC3F,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC;AAoBzC;;;GAGG;AACH,SAAS,aAAa;IACpB,OAAO;QACL,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K,SAAS,IAAI,QAAQ,KAAK,mBAAmB,CAAC;QAAE,OAAO,kBAAkB,CAAC;IAC1H,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAAC,QAA4B,EAAE,KAAyB,EAAE,QAAoB,mBAAmB;IAC7H,MAAM,aAAa,GAAG,YAAY,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IACpD,MAAM,UAAU,GAAG,SAAS,CAAC,QAAQ,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;IACrD,IAAI,aAAa,KAAK,SAAS;QAAE,OAAO,UAAU,IAAI,EAAE,CAAC;IACzD,IAAI,UAAU,KAAK,SAAS;QAAE,OAAO,aAAa,CAAC;IACnD,OAAO,aAAa,GAAG,GAAG,GAAG,UAAU,CAAC;AAC1C,CAAC"}
@@ -0,0 +1,64 @@
1
+ /** Lowest Node major the harness launcher and its kernel accept. */
2
+ export declare const MIN_NODE_MAJOR = 26;
3
+ /** The one sentence every failure shares: what to install and how to point at it. */
4
+ export declare const NODE_INSTALL_HINT: string;
5
+ /** A Node binary this CLI is willing to boot the harness with. */
6
+ export interface NodeRuntime {
7
+ /** Absolute path, or the PATH name that resolved. */
8
+ readonly bin: string;
9
+ /** Version as printed by `node --version`, e.g. `v26.9.0`. */
10
+ readonly version: string;
11
+ /** Major version, already checked against {@link MIN_NODE_MAJOR}. */
12
+ readonly major: number;
13
+ /** Where the candidate came from: `GBH_NODE`, `nvm vX`, `PATH` or a system path. */
14
+ readonly source: string;
15
+ }
16
+ /** One candidate that was refused, kept so a failure names what it found instead. */
17
+ export interface RejectedNode {
18
+ /** Path or PATH name that was probed. */
19
+ readonly bin: string;
20
+ /** Version it reported, when it reported one. */
21
+ readonly version?: string;
22
+ /** Why it was refused. */
23
+ readonly reason: string;
24
+ }
25
+ /** Every fact the ladder reads, so a test can drive it without a real install. */
26
+ export interface NodeLookup {
27
+ /** Process environment; `GBH_NODE` is the explicit pin. */
28
+ readonly env: NodeJS.ProcessEnv;
29
+ /** Home directory that may hold `~/.nvm/versions/node`. */
30
+ readonly home: string;
31
+ /** Whether a path exists. */
32
+ readonly exists: (path: string) => boolean;
33
+ /** Directory listing; throws for a missing directory. */
34
+ readonly readdir: (dir: string) => string[];
35
+ /** `node --version` for one binary, or undefined when it is missing or stays silent. */
36
+ readonly probe: (bin: string) => string | undefined;
37
+ }
38
+ /** Parses `v26.9.0` / `26.9.0` into major and minor. */
39
+ export declare function parseNodeVersion(text: string): {
40
+ major: number;
41
+ minor: number;
42
+ version: string;
43
+ } | undefined;
44
+ /** The real filesystem, PATH probe and environment. */
45
+ export declare function systemNodeLookup(): NodeLookup;
46
+ /**
47
+ * Candidate binaries in preference order: the explicit pin, then the newest nvm install, then
48
+ * whatever PATH and the usual system locations offer.
49
+ * @param lookup - filesystem, environment and version-probe facts.
50
+ * @returns one entry per candidate, unresolved and unprobed.
51
+ */
52
+ export declare function nodeCandidates(lookup: NodeLookup): {
53
+ bin: string;
54
+ source: string;
55
+ }[];
56
+ /**
57
+ * Resolves the Node runtime that boots the harness: explicit pin, newest nvm install, PATH, then
58
+ * the system paths, refusing anything below {@link MIN_NODE_MAJOR}.
59
+ * @param lookup - filesystem, environment and version-probe facts.
60
+ * @returns the first acceptable runtime.
61
+ * @throws with a Vietnamese message naming the requirement, the fix and every binary it tried.
62
+ */
63
+ export declare function resolveNodeRuntime(lookup?: NodeLookup): NodeRuntime;
64
+ //# sourceMappingURL=node-runtime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node-runtime.d.ts","sourceRoot":"","sources":["../../src/harness/node-runtime.ts"],"names":[],"mappings":"AAcA,oEAAoE;AACpE,eAAO,MAAM,cAAc,KAAK,CAAC;AAEjC,qFAAqF;AACrF,eAAO,MAAM,iBAAiB,QAEgD,CAAC;AAE/E,kEAAkE;AAClE,MAAM,WAAW,WAAW;IAC1B,qDAAqD;IACrD,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,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,CAsBpF;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,GAAE,UAA+B,GAAG,WAAW,CA6BvF"}
@@ -0,0 +1,109 @@
1
+ /**
2
+ * Which Node binary runs the blackhole-tauri launcher (`bh host`).
3
+ *
4
+ * The launcher and the kernel it boots are Node programs — the desktop repo pins Node >= 26 for
5
+ * both — so `blackhole web` looks for that runtime instead of asking for Bun. The ladder is the
6
+ * desktop's own (blackhole-tauri `apps/cli/src/runtime.ts`): an explicit pin, the newest nvm
7
+ * install, PATH, then the usual system locations. Every fact is injectable, so the ladder is
8
+ * testable without a real install.
9
+ */
10
+ import { spawnSync } from "node:child_process";
11
+ import { existsSync, readdirSync } from "node:fs";
12
+ import { homedir } from "node:os";
13
+ import { join } from "node:path";
14
+ /** Lowest Node major the harness launcher and its kernel accept. */
15
+ export const MIN_NODE_MAJOR = 26;
16
+ /** The one sentence every failure shares: what to install and how to point at it. */
17
+ export const NODE_INSTALL_HINT = "Cài Node " + String(MIN_NODE_MAJOR) + " (nvm install " + String(MIN_NODE_MAJOR) + " · brew install node@" + String(MIN_NODE_MAJOR) +
18
+ ") hoặc đặt GBH_NODE tới một binary node >= " + String(MIN_NODE_MAJOR) + ".";
19
+ /** Parses `v26.9.0` / `26.9.0` into major and minor. */
20
+ export function parseNodeVersion(text) {
21
+ const match = /v?(\d+)\.(\d+)\.(\d+)/u.exec(text);
22
+ if (match === null)
23
+ return undefined;
24
+ return { major: Number(match[1]), minor: Number(match[2]), version: "v" + String(match[1]) + "." + String(match[2]) + "." + String(match[3]) };
25
+ }
26
+ /** The real filesystem, PATH probe and environment. */
27
+ export function systemNodeLookup() {
28
+ return {
29
+ env: process.env,
30
+ home: homedir(),
31
+ exists: existsSync,
32
+ readdir: dir => readdirSync(dir),
33
+ probe: bin => {
34
+ const result = spawnSync(bin, ["--version"], { encoding: "utf8", timeout: 8000, stdio: ["ignore", "pipe", "ignore"] });
35
+ if (result.error !== undefined || result.status !== 0)
36
+ return undefined;
37
+ const out = (result.stdout ?? "").trim();
38
+ return out.length === 0 ? undefined : out;
39
+ },
40
+ };
41
+ }
42
+ /**
43
+ * Candidate binaries in preference order: the explicit pin, then the newest nvm install, then
44
+ * whatever PATH and the usual system locations offer.
45
+ * @param lookup - filesystem, environment and version-probe facts.
46
+ * @returns one entry per candidate, unresolved and unprobed.
47
+ */
48
+ export function nodeCandidates(lookup) {
49
+ const candidates = [];
50
+ const explicit = (lookup.env.GBH_NODE ?? "").trim();
51
+ if (explicit.length > 0)
52
+ candidates.push({ bin: explicit, source: "GBH_NODE" });
53
+ const nvmRoot = join(lookup.home, ".nvm", "versions", "node");
54
+ try {
55
+ const versions = lookup
56
+ .readdir(nvmRoot)
57
+ .filter(name => /^v\d+\.\d+\.\d+$/u.test(name))
58
+ .sort((left, right) => {
59
+ const a = parseNodeVersion(left);
60
+ const b = parseNodeVersion(right);
61
+ return (b?.major ?? 0) - (a?.major ?? 0) || (b?.minor ?? 0) - (a?.minor ?? 0);
62
+ });
63
+ for (const version of versions)
64
+ candidates.push({ bin: join(nvmRoot, version, "bin", "node"), source: "nvm " + version });
65
+ }
66
+ catch {
67
+ /* nvm is optional: fall through to PATH and the system locations */
68
+ }
69
+ candidates.push({ bin: "node", source: "PATH" });
70
+ candidates.push({ bin: join("/usr/local/bin", "node"), source: "system /usr/local/bin" });
71
+ candidates.push({ bin: join("/opt/homebrew/bin", "node"), source: "homebrew /opt/homebrew/bin" });
72
+ return candidates;
73
+ }
74
+ /**
75
+ * Resolves the Node runtime that boots the harness: explicit pin, newest nvm install, PATH, then
76
+ * the system paths, refusing anything below {@link MIN_NODE_MAJOR}.
77
+ * @param lookup - filesystem, environment and version-probe facts.
78
+ * @returns the first acceptable runtime.
79
+ * @throws with a Vietnamese message naming the requirement, the fix and every binary it tried.
80
+ */
81
+ export function resolveNodeRuntime(lookup = systemNodeLookup()) {
82
+ const rejected = [];
83
+ for (const candidate of nodeCandidates(lookup)) {
84
+ // "node" is a PATH name, not a path: only a real path can be checked before probing.
85
+ if (candidate.bin !== "node" && !lookup.exists(candidate.bin)) {
86
+ rejected.push({ bin: candidate.bin, reason: "không có tệp" });
87
+ continue;
88
+ }
89
+ const printed = lookup.probe(candidate.bin);
90
+ if (printed === undefined) {
91
+ rejected.push({ bin: candidate.bin, reason: "không trả lời --version" });
92
+ continue;
93
+ }
94
+ const parsed = parseNodeVersion(printed);
95
+ if (parsed === undefined) {
96
+ rejected.push({ bin: candidate.bin, version: printed, reason: "không đọc được phiên bản" });
97
+ continue;
98
+ }
99
+ if (parsed.major < MIN_NODE_MAJOR) {
100
+ rejected.push({ bin: candidate.bin, version: parsed.version, reason: "dưới mức v" + String(MIN_NODE_MAJOR) });
101
+ continue;
102
+ }
103
+ return { bin: candidate.bin, version: parsed.version, major: parsed.major, source: candidate.source };
104
+ }
105
+ const tried = rejected.map(entry => entry.bin + " (" + (entry.version ?? "?") + ": " + entry.reason + ")").join(" · ");
106
+ throw new Error("Không tìm thấy Node >= " + String(MIN_NODE_MAJOR) + " để chạy harness blackhole-tauri. " + NODE_INSTALL_HINT +
107
+ (tried.length === 0 ? "" : " Đã thử: " + tried + "."));
108
+ }
109
+ //# sourceMappingURL=node-runtime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node-runtime.js","sourceRoot":"","sources":["../../src/harness/node-runtime.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,oEAAoE;AACpE,MAAM,CAAC,MAAM,cAAc,GAAG,EAAE,CAAC;AAEjC,qFAAqF;AACrF,MAAM,CAAC,MAAM,iBAAiB,GAC5B,WAAW,GAAG,MAAM,CAAC,cAAc,CAAC,GAAG,g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