@steerable/agent-shell-web 0.6.55 → 0.6.57

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 (47) hide show
  1. package/README.md +3 -4
  2. package/package.json +4 -4
  3. package/src/AppShell.tsx +3 -3
  4. package/src/components/AgentSidebar.tsx +4 -4
  5. package/src/components/CreateProjectModal.tsx +2 -2
  6. package/src/components/SidebarRelease.tsx +4 -4
  7. package/src/components/TerminalPanel.tsx +3 -3
  8. package/src/components/TerminalView.tsx +4 -4
  9. package/src/components/chat/ApprovalModal.tsx +1 -1
  10. package/src/components/chat/ApprovalPromptProvider.tsx +4 -4
  11. package/src/components/chat/AskUserPromptProvider.tsx +3 -3
  12. package/src/components/chat/ChatProjectBadge.tsx +3 -3
  13. package/src/components/chat/TaskPanelModal.tsx +2 -2
  14. package/src/components/chat/TaskProcessPanel.tsx +2 -2
  15. package/src/components/chat/useChatTasks.ts +3 -3
  16. package/src/components/settings/AgentCapabilityFields.tsx +2 -2
  17. package/src/components/settings/AgentsSettingsPanel.tsx +3 -3
  18. package/src/components/settings/CliInstallSettingsPanel.tsx +67 -0
  19. package/src/components/settings/InsightsSettingsPanel.tsx +15 -15
  20. package/src/components/settings/LlmSettingsPanel.tsx +3 -3
  21. package/src/components/settings/McpSettingsPanel.tsx +12 -12
  22. package/src/components/settings/PythonRunnerSettingsPanel.tsx +4 -4
  23. package/src/components/settings/SecuritySettingsPanel.tsx +3 -3
  24. package/src/components/settings/SkillsSettingsPanel.tsx +7 -7
  25. package/src/components/settings/TelemetrySettingsPanel.tsx +5 -5
  26. package/src/components/settings/UsagePanel.tsx +3 -3
  27. package/src/components/settings/WebSearchSettingsPanel.tsx +5 -5
  28. package/src/hooks/useChatsAndAgents.ts +9 -9
  29. package/src/hooks/useProjects.ts +2 -2
  30. package/src/i18n/index.tsx +1 -1
  31. package/src/layouts/AgentLayout.tsx +14 -6
  32. package/src/lib/app-release.ts +1 -1
  33. package/src/lib/attachments.ts +2 -2
  34. package/src/lib/{browser-dev-electron-mock.ts → browser-dev-host-mock.ts} +10 -10
  35. package/src/lib/chat-transport.ts +10 -10
  36. package/src/lib/host-bridge.ts +376 -4
  37. package/src/lib/host-paste.ts +1 -1
  38. package/src/lib/http-bridge.ts +10 -8
  39. package/src/lib/insights.ts +2 -2
  40. package/src/lib/local-api.ts +13 -5
  41. package/src/lib/portable.ts +3 -3
  42. package/src/lib/slash-sources.ts +3 -3
  43. package/src/lib/tauri-bridge.ts +1 -1
  44. package/src/main.tsx +3 -3
  45. package/src/pages/AgentPage.tsx +23 -23
  46. package/src/pages/SettingsPage.tsx +4 -4
  47. package/src/lib/electron-bridge.ts +0 -389
@@ -1,7 +1,379 @@
1
1
  /**
2
- * Canonical renderer host contract.
2
+ * Host-neutral bridge used by the renderer in desktop and browser modes.
3
3
  *
4
- * The legacy `electron-bridge` module remains available so existing product
5
- * sources can migrate without a synchronized breaking release.
4
+ * Implementations are `tauri-bridge.ts` (desktop) and `http-bridge.ts`
5
+ * (browser server); both must satisfy {@link HostBridge}.
6
+ * Callers use `window.steerableHost` and `getHostBridge()`.
6
7
  */
7
- export * from './electron-bridge';
8
+
9
+ import type { SSEEvent } from '@steerable/agent-protocol';
10
+ import { getHttpBridge } from './http-bridge';
11
+ import { getTauriBridge } from './tauri-bridge';
12
+
13
+ export type LocalBackendRequestInput = {
14
+ method: string;
15
+ path: string;
16
+ body?: unknown;
17
+ };
18
+
19
+ export type LocalBackendStreamEvent =
20
+ | { type: 'data'; chunk: string; parsed?: SSEEvent }
21
+ | { type: 'end'; status: number }
22
+ | { type: 'error'; error: string };
23
+
24
+ /**
25
+ * W4-1: mirror of the approval algebra's decision variants
26
+ * (`steerable_agent_runtime.approval.APPROVAL_KINDS` minus `timed_out`,
27
+ * which the sidecar synthesizes itself on timeout).
28
+ */
29
+ export type ApprovalDecisionKind =
30
+ | 'allow_once'
31
+ | 'allow_for_session'
32
+ | 'allow_always'
33
+ | 'deny_once'
34
+ | 'deny_for_session'
35
+ | 'deny_always'
36
+ | 'abort';
37
+
38
+ export interface ApprovalPromptRequest {
39
+ requestId: string;
40
+ toolName: string;
41
+ arguments: Record<string, unknown>;
42
+ mode: string;
43
+ category: string;
44
+ round: number;
45
+ /** 发起审批的对话。缺省时卡片不绑定会话(旧请求)。 */
46
+ chatId?: string;
47
+ }
48
+
49
+ /**
50
+ * W8: mirror of the sidecar's `ask_user.request` reverse-call payload
51
+ * (`HostAskUserHandler` in steerable_sidecar.host_tools). `questions`
52
+ * entries match `AskUserQuestionsPayload['questions'][number]` from
53
+ * `@steerable/agent-protocol`; kept structurally typed here so the
54
+ * renderer's compile graph stays free of main-process imports.
55
+ */
56
+ export interface AskUserPromptRequest {
57
+ requestId: string;
58
+ intro: string;
59
+ questions: Array<Record<string, unknown>>;
60
+ /** 发起提问的对话。缺省时卡片不绑定会话(旧请求)。 */
61
+ chatId?: string;
62
+ }
63
+
64
+ /**
65
+ * Mirror of `TerminalSession` / `TerminalSpawnOptions` in
66
+ * `src/terminal-manager.ts`. Kept inline (rather than cross-imported)
67
+ * for the same reason as the rest of this file — we don't want the
68
+ * renderer's compile graph to pull in main-process modules.
69
+ */
70
+ export interface TerminalSession {
71
+ id: string;
72
+ shell: string;
73
+ pid: number;
74
+ cwd: string;
75
+ cols: number;
76
+ rows: number;
77
+ }
78
+
79
+ export interface TerminalSpawnOptions {
80
+ shell?: string;
81
+ cwd?: string;
82
+ env?: Record<string, string>;
83
+ cols?: number;
84
+ rows?: number;
85
+ }
86
+
87
+ export type AppReleasePhase =
88
+ | 'disabled'
89
+ | 'idle'
90
+ | 'checking'
91
+ | 'downloading'
92
+ | 'ready'
93
+ | 'installing'
94
+ | 'error';
95
+
96
+ /**
97
+ * 桌面版本与更新。`version` 是当前安装版本,`availableVersion` 是待安装版本。
98
+ * 与主进程 `AppReleaseSnapshot` 对齐。
99
+ */
100
+ export interface AppReleaseSnapshot {
101
+ version: string;
102
+ enabled: boolean;
103
+ phase: AppReleasePhase;
104
+ availableVersion?: string;
105
+ percent?: number;
106
+ message?: string;
107
+ }
108
+
109
+ export type PythonRunnerPhase =
110
+ | 'idle'
111
+ | 'downloading'
112
+ | 'verifying'
113
+ | 'extracting'
114
+ | 'ready'
115
+ | 'error';
116
+
117
+ export interface PythonRunnerSnapshot {
118
+ supported: boolean;
119
+ source: 'default' | 'url' | 'local';
120
+ phase: PythonRunnerPhase;
121
+ percent?: number;
122
+ downloadedBytes?: number;
123
+ totalBytes?: number;
124
+ message?: string;
125
+ defaultUrl?: string;
126
+ configuredUrl?: string;
127
+ activeRunner?: string;
128
+ configuredRunner?: string;
129
+ restartRequired: boolean;
130
+ }
131
+
132
+ export interface HostBridge {
133
+ runtime: 'local';
134
+ platform: NodeJS.Platform;
135
+ local?: {
136
+ selectDirectory: (options?: {
137
+ title?: string;
138
+ }) => Promise<{ canceled: boolean; filePaths: string[] }>;
139
+ saveTextFile?: (options: {
140
+ title?: string;
141
+ defaultPath?: string;
142
+ content: string;
143
+ }) => Promise<{ canceled: boolean; filePath?: string }>;
144
+ /** 截取窗口(或指定 DIP 区域)并写入系统剪贴板。 */
145
+ captureScreenshot: (rect?: {
146
+ x: number;
147
+ y: number;
148
+ width: number;
149
+ height: number;
150
+ }) => Promise<
151
+ | { success: true; width: number; height: number }
152
+ | { success: false; error: string }
153
+ >;
154
+ };
155
+ localBackend: {
156
+ request: <T>(input: LocalBackendRequestInput) => Promise<T>;
157
+ startStream: (
158
+ input: LocalBackendRequestInput,
159
+ onEvent: (payload: LocalBackendStreamEvent) => void,
160
+ ) => Promise<string | null>;
161
+ cancelStream: (streamId: string) => void;
162
+ /** 轮中转向:注入一条用户消息到运行中的 CoreLoop 回合;false = 无可转向回合。 */
163
+ steerChat?: (chatId: string, content: string) => Promise<boolean>;
164
+ };
165
+ /** 会话附件:把源文件路径 / base64 字节拷贝进会话空间(`attachments:save`)。 */
166
+ attachments?: {
167
+ save: (input: {
168
+ chatId: string;
169
+ files: Array<{ path?: string; name?: string; data?: string }>;
170
+ }) => Promise<{
171
+ files: Array<{ name: string; path: string; size: number; error?: string }>;
172
+ }>;
173
+ };
174
+ /**
175
+ * Desktop menu — `Cmd+N` fires `menu:new-chat`. Renderer subscribes via
176
+ * `onMenuNewChat(cb)` and must call `offMenuNewChat()` on unmount
177
+ * so a remounted AgentSidebar does not keep the previous callback.
178
+ */
179
+ /** 把当前界面语言告诉桌面壳,以便重建应用菜单。浏览器预览里没有。 */
180
+ setLocale?: (locale: string) => void;
181
+ onMenuNewChat?: (callback: () => void) => void;
182
+ offMenuNewChat?: () => void;
183
+ /**
184
+ * App menu IPC — `Cmd+T` / 视图 → 打开终端 fires `menu:open-terminal`.
185
+ * The terminal is a toggleable panel inside AgentLayout (not a separate
186
+ * window, not a route), so the renderer just flips layout state. Same
187
+ * subscribe/off pairing as `onMenuNewChat`.
188
+ */
189
+ onMenuOpenTerminal?: (callback: () => void) => void;
190
+ offMenuOpenTerminal?: () => void;
191
+ /**
192
+ * App menu IPC — `Cmd+V` / 编辑 → 粘贴 fires `menu:paste`.
193
+ * WKWebView does not expose that pasteboard to the page, so the renderer
194
+ * reads it through `readClipboard`.
195
+ */
196
+ onMenuPaste?: (callback: () => void) => void;
197
+ offMenuPaste?: () => void;
198
+ /**
199
+ * OS pasteboard. `files` are copied paths or a screenshot PNG.
200
+ * Text is empty when the pasteboard holds files, so the path is not
201
+ * inserted into the composer as well.
202
+ */
203
+ readClipboard?: () => Promise<{
204
+ text: string;
205
+ files: Array<{
206
+ name: string;
207
+ path?: string;
208
+ dataBase64?: string;
209
+ mime?: string;
210
+ }>;
211
+ }>;
212
+ /** Plain text from the OS pasteboard. Empty when the clipboard has no text. */
213
+ readClipboardText?: () => Promise<string>;
214
+ /**
215
+ * 异步 AI 标题就绪通知。Backend 在每条 chat 首条助手回复完成后 fire-and-forget
216
+ * 跑 LLM 生成标题;完成时通过这个通道把 `{chatId, title}` 推过来。返回的函数
217
+ * 解除订阅(preload 用 add/remove 配对,不是 removeAllListeners——可以多处订阅)。
218
+ */
219
+ onChatTitleUpdated?: (
220
+ callback: (payload: { chatId: string; title: string }) => void,
221
+ ) => () => void;
222
+ /**
223
+ * 回合追问建议就绪。Backend 在助手回复完成后推 `{chatId, messageId, suggestions}`
224
+ * (先启发式、后 LLM 替换)。返回解除订阅函数。
225
+ */
226
+ onSuggestedReplies?: (
227
+ callback: (payload: {
228
+ chatId: string;
229
+ messageId: string;
230
+ suggestions: string[];
231
+ }) => void,
232
+ ) => () => void;
233
+ /**
234
+ * 会话补建通知。Backend 在「向一个本地不存在的 chatId 首次发送」时按 URL
235
+ * 里的 id 现场补建会话(见 router.handleStream),随后广播 `chat-created`
236
+ * ({chatId, agentId});渲染端据此 refresh 一次侧栏,避免"URL 能聊、列表
237
+ * 里却找不到这条会话"。返回解除订阅函数。
238
+ */
239
+ onChatCreated?: (
240
+ callback: (payload: { chatId: string; agentId?: string | null }) => void,
241
+ ) => () => void;
242
+ /**
243
+ * 另一个进程提交了宿主库。侧栏据此重新拉会话列表。
244
+ * 载荷为空;渲染端不依赖里面的字段。
245
+ */
246
+ onStoreChanged?: (callback: () => void) => () => void;
247
+ /**
248
+ * 4.6a 后台任务状态推送。任务到达终态或 worktree 合并/丢弃完成时主进程
249
+ * 广播;载荷只有 chatId/taskId,面板收到后重新拉列表。
250
+ */
251
+ onTaskUpdated?: (
252
+ callback: (payload: { chatId: string; taskId: string }) => void,
253
+ ) => () => void;
254
+ /**
255
+ * 场景包广播事件订阅(3.1 通用化):按通道名订阅主进程/BS 后端的
256
+ * 广播事件,载荷由订阅方(包)自行收窄校验。shell 不知道包的事件
257
+ * 语义——包的通道名约定带包前缀(如 `<pack>:updated`)。返回解除
258
+ * 订阅函数。
259
+ */
260
+ onPackEvent?: (
261
+ channel: string,
262
+ callback: (payload: unknown) => void,
263
+ ) => () => void;
264
+ /**
265
+ * 后台任务推理时间线推送。任务流的 reasoning / 工具 / 文本增量经主进程
266
+ * 广播;右侧过程栏订阅后不用轮询。
267
+ */
268
+ onTaskProcess?: (
269
+ callback: (payload: {
270
+ chatId: string;
271
+ taskId: string;
272
+ timeline: unknown;
273
+ live: boolean;
274
+ }) => void,
275
+ ) => () => void;
276
+ /**
277
+ * W4-1 审批代数:sidecar ApprovalExecutor 的请示经主进程广播到 renderer。
278
+ * onRequest 订阅返回 unsubscribe;decide 把用户的 7 变体决定送回主进程。
279
+ */
280
+ approval?: {
281
+ onRequest: (callback: (request: ApprovalPromptRequest) => void) => () => void;
282
+ decide: (decision: {
283
+ requestId: string;
284
+ kind: ApprovalDecisionKind;
285
+ reason?: string;
286
+ }) => Promise<void>;
287
+ pending: () => Promise<ApprovalPromptRequest[]>;
288
+ };
289
+ /**
290
+ * W8 结构化提问:sidecar ask_user 工具的请示经主进程/BS 服务器广播到
291
+ * renderer。onRequest 订阅返回 unsubscribe;answer 把答案映射送回
292
+ * (空映射 = 用户未作答,模型自行推进)。
293
+ */
294
+ askUser?: {
295
+ onRequest: (callback: (request: AskUserPromptRequest) => void) => () => void;
296
+ answer: (reply: {
297
+ requestId: string;
298
+ answers: Record<string, string | string[]>;
299
+ }) => Promise<void>;
300
+ pending: () => Promise<AskUserPromptRequest[]>;
301
+ };
302
+ terminal?: {
303
+ /** Ensures a session exists (reuses last one if alive). */
304
+ ensure: (options?: TerminalSpawnOptions) => Promise<TerminalSession>;
305
+ write: (id: string, data: string) => Promise<boolean>;
306
+ resize: (id: string, cols: number, rows: number) => Promise<boolean>;
307
+ onData: (
308
+ callback: (payload: { sessionId: string; chunk: string }) => void,
309
+ ) => () => void;
310
+ onExit: (
311
+ callback: (payload: {
312
+ sessionId: string;
313
+ code: number;
314
+ signal: string | null;
315
+ }) => void,
316
+ ) => () => void;
317
+ };
318
+ /**
319
+ * 桌面版本与更新。Tauri 提供;浏览器预览没有这一段。
320
+ */
321
+ app?: {
322
+ snapshot: () => Promise<AppReleaseSnapshot>;
323
+ check: () => Promise<AppReleaseSnapshot>;
324
+ install: () => Promise<AppReleaseSnapshot>;
325
+ onState: (callback: (snapshot: AppReleaseSnapshot) => void) => () => void;
326
+ };
327
+ /** Desktop-only Python child interpreter management for run_code. */
328
+ pythonRunner?: {
329
+ snapshot: () => Promise<PythonRunnerSnapshot>;
330
+ download: (url?: string) => Promise<PythonRunnerSnapshot>;
331
+ cancel: () => Promise<PythonRunnerSnapshot>;
332
+ pickLocal: () => Promise<string | null>;
333
+ useLocal: (path: string) => Promise<PythonRunnerSnapshot>;
334
+ useDefault: () => Promise<PythonRunnerSnapshot>;
335
+ restart: () => Promise<void>;
336
+ onState: (callback: (snapshot: PythonRunnerSnapshot) => void) => () => void;
337
+ };
338
+ // 场景包的 invoke 命名空间(如包 preload 贡献的 `<pack>` / `<pack>Mock`)
339
+ // 不进本接口——包用自己的结构化收窄访问器(见各包 web/bridge.ts),
340
+ // shell 桥接口保持产品中立(3.1)。
341
+ }
342
+
343
+ declare global {
344
+ interface Window {
345
+ steerableHost?: HostBridge;
346
+ __TAURI_INTERNALS__?: object;
347
+ /**
348
+ * BS server 托管 index.html 时注入的引导信息。存在且没有 Tauri
349
+ * 内部对象时,`getHostBridge()` 返回 HTTP 实现。
350
+ */
351
+ __DEEPPATH_BS__?: {
352
+ platform: NodeJS.Platform;
353
+ flavor: string;
354
+ brandName: string;
355
+ };
356
+ }
357
+ }
358
+
359
+ export function getHostBridge(): HostBridge | null {
360
+ if (typeof window === 'undefined') return null;
361
+ if (window.steerableHost) return window.steerableHost;
362
+ if (window.__TAURI_INTERNALS__ && window.__DEEPPATH_BS__) {
363
+ return getTauriBridge();
364
+ }
365
+ if (window.__DEEPPATH_BS__) return getHttpBridge();
366
+ return null;
367
+ }
368
+
369
+ /** True when the page can call the Node host, including browser mode. */
370
+ export function hasHostBridge(): boolean {
371
+ return getHostBridge() !== null;
372
+ }
373
+
374
+ export function isDesktopHost(): boolean {
375
+ if (typeof window === 'undefined') return false;
376
+ return Boolean(
377
+ window.steerableHost || (window.__TAURI_INTERNALS__ && window.__DEEPPATH_BS__),
378
+ );
379
+ }
@@ -15,7 +15,7 @@ export interface HostClipboard {
15
15
  text: string;
16
16
  files: HostClipboardFile[];
17
17
  }
18
- import { getHostBridge } from './electron-bridge';
18
+ import { getHostBridge } from './host-bridge';
19
19
 
20
20
  let pending = false;
21
21
  let lastEditable: HTMLElement | null = null;
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * BS 模式的宿主 bridge:与 Electron preload(src/preload.ts)暴露的
3
- * `window.electron` 同一接口(ElectronBridge),但传输换成 HTTP + SSE:
3
+ * `window.steerableHost` 同一接口(HostBridge),但传输换成 HTTP + SSE:
4
4
  *
5
5
  * localBackend.request → fetch /api/v2/*
6
6
  * localBackend.startStream → fetch(ReadableStream 逐 chunk 喂 onEvent)
@@ -12,17 +12,17 @@
12
12
  * onPackEvent(= subscribeChannel)订阅。
13
13
  *
14
14
  * server 在 index.html 里注入 `window.__DEEPPATH_BS__`(platform/brand),
15
- * getElectronBridge() 据此在浏览器里选中本实现。
15
+ * getHostBridge() 据此在浏览器里选中本实现。
16
16
  */
17
17
  import type {
18
18
  ApprovalPromptRequest,
19
19
  AskUserPromptRequest,
20
- ElectronBridge,
20
+ HostBridge,
21
21
  LocalBackendRequestInput,
22
22
  LocalBackendStreamEvent,
23
23
  TerminalSession,
24
24
  TerminalSpawnOptions,
25
- } from './electron-bridge';
25
+ } from './host-bridge';
26
26
  import { t } from '@/i18n';
27
27
 
28
28
  interface BsBootstrap {
@@ -198,9 +198,9 @@ async function terminalEnsure(options?: TerminalSpawnOptions): Promise<TerminalS
198
198
  return session;
199
199
  }
200
200
 
201
- export function createHttpBridge(): ElectronBridge {
201
+ export function createHttpBridge(): HostBridge {
202
202
  const boot = bootstrap();
203
- const bridge: ElectronBridge = {
203
+ const bridge: HostBridge = {
204
204
  runtime: 'local',
205
205
  platform: boot.platform,
206
206
 
@@ -266,6 +266,8 @@ export function createHttpBridge(): ElectronBridge {
266
266
  onChatCreated: (callback) =>
267
267
  subscribeChannel<{ chatId: string; agentId?: string | null }>('chat-created', callback),
268
268
 
269
+ onStoreChanged: (callback) => subscribeChannel('store:changed', () => callback()),
270
+
269
271
  onTaskUpdated: (callback) =>
270
272
  subscribeChannel<{ chatId: string; taskId: string }>(
271
273
  'task-updated',
@@ -321,9 +323,9 @@ export function createHttpBridge(): ElectronBridge {
321
323
  return bridge;
322
324
  }
323
325
 
324
- let singleton: ElectronBridge | null = null;
326
+ let singleton: HostBridge | null = null;
325
327
 
326
- export function getHttpBridge(): ElectronBridge {
328
+ export function getHttpBridge(): HostBridge {
327
329
  if (!singleton) singleton = createHttpBridge();
328
330
  return singleton;
329
331
  }
@@ -1,11 +1,11 @@
1
- import { getElectronBridge } from './electron-bridge';
1
+ import { getHostBridge } from './host-bridge';
2
2
 
3
3
  /** Fire-and-forget local enqueue. Never throws into UI. */
4
4
  export function trackBehavior(
5
5
  eventName: string,
6
6
  properties: Record<string, unknown> = {},
7
7
  ): void {
8
- const bridge = getElectronBridge();
8
+ const bridge = getHostBridge();
9
9
  if (!bridge) return;
10
10
  void bridge.localBackend
11
11
  .request({
@@ -1,18 +1,18 @@
1
1
  /**
2
- * Typed wrappers around `window.electron.localBackend.request` for the
2
+ * Typed wrappers around `window.steerableHost.localBackend.request` for the
3
3
  * endpoints that apps/web actually consumes today. Shapes follow what
4
4
  * `src/local-backend/router.ts` returns — see the corresponding route
5
5
  * handlers there if you need to add fields.
6
6
  *
7
7
  * Conventions:
8
- * - Every helper throws if the bridge is missing (caller should `isElectron()`
8
+ * - Every helper throws if the bridge is missing (caller should `hasHostBridge()`
9
9
  * check first if a graceful degradation is needed).
10
10
  * - We deliberately keep the local return shapes (not Pydantic / protocol
11
11
  * types) — they're the contract between local-backend and renderer, and
12
12
  * may drift from any public cloud API. Aligning the two is out of scope.
13
13
  */
14
14
 
15
- import { getElectronBridge } from './electron-bridge';
15
+ import { getHostBridge } from './host-bridge';
16
16
 
17
17
  export interface LocalChat {
18
18
  id: string;
@@ -100,10 +100,10 @@ interface CreateChatResponse {
100
100
  }
101
101
 
102
102
  function bridge() {
103
- const b = getElectronBridge();
103
+ const b = getHostBridge();
104
104
  if (!b) {
105
105
  throw new Error(
106
- 'Electron bridge unavailable — local API can only be used inside the desktop shell.',
106
+ 'Host bridge unavailable — local API can only be used inside the desktop shell.',
107
107
  );
108
108
  }
109
109
  return b;
@@ -767,6 +767,14 @@ export interface DiagnoseResult {
767
767
  hint: string | null;
768
768
  }
769
769
 
770
+ export async function installCommandLineTool(name: string) {
771
+ return bridge().localBackend.request<{ path: string; onPath: boolean }>({
772
+ method: 'POST',
773
+ path: '/api/v2/cli/install',
774
+ body: { name },
775
+ });
776
+ }
777
+
770
778
  export async function diagnoseLlmConnection(input: {
771
779
  baseUrl?: string;
772
780
  apiKey?: string;
@@ -4,7 +4,7 @@
4
4
  */
5
5
 
6
6
  import { t } from '@/i18n';
7
- import { getElectronBridge } from '@/lib/electron-bridge';
7
+ import { getHostBridge } from '@/lib/host-bridge';
8
8
  import { listChats } from '@/lib/local-api';
9
9
  import { persistExecPolicy, readStoredExecPolicy, type ExecPolicy } from '@/lib/exec-policy';
10
10
  import {
@@ -139,7 +139,7 @@ export function isClientSection(id: string): boolean {
139
139
  }
140
140
 
141
141
  async function request<T>(method: string, path: string, body?: unknown): Promise<T> {
142
- const bridge = getElectronBridge();
142
+ const bridge = getHostBridge();
143
143
  if (!bridge) throw new Error(t('No local backend in this environment'));
144
144
  return bridge.localBackend.request<T>(body === undefined ? { method, path } : { method, path, body });
145
145
  }
@@ -189,7 +189,7 @@ export async function importChatDocument(document: unknown): Promise<PortableCha
189
189
 
190
190
  export async function saveJsonFile(filename: string, data: unknown): Promise<string | null> {
191
191
  const content = `${JSON.stringify(data, null, 2)}\n`;
192
- const save = getElectronBridge()?.local?.saveTextFile;
192
+ const save = getHostBridge()?.local?.saveTextFile;
193
193
  if (save) {
194
194
  const saved = await save({ title: t('Export'), defaultPath: filename, content });
195
195
  if (saved.canceled || !saved.filePath) return null;
@@ -14,7 +14,7 @@
14
14
 
15
15
  import { useCallback, useEffect, useState } from 'react';
16
16
  import { getPackHiddenSlashSkills } from '../packs/registry';
17
- import { getElectronBridge, isElectron } from './electron-bridge';
17
+ import { getHostBridge, hasHostBridge } from './host-bridge';
18
18
 
19
19
  export type SkillItem = {
20
20
  /** Skill directory name (e.g. `70-plan-mode`); absent on hand-built items. */
@@ -125,7 +125,7 @@ let inflight: Promise<SlashSources> | null = null;
125
125
  const listeners = new Set<(sources: SlashSources) => void>();
126
126
 
127
127
  async function load(): Promise<SlashSources> {
128
- const bridge = getElectronBridge();
128
+ const bridge = getHostBridge();
129
129
  if (!bridge) return cached;
130
130
 
131
131
  let skills = cached.skills;
@@ -159,7 +159,7 @@ async function load(): Promise<SlashSources> {
159
159
 
160
160
  /** Re-read the catalog. Concurrent callers share one in-flight request. */
161
161
  export function refreshSlashSources(): Promise<SlashSources> {
162
- if (!isElectron()) return Promise.resolve(cached);
162
+ if (!hasHostBridge()) return Promise.resolve(cached);
163
163
  if (!inflight) {
164
164
  inflight = load().finally(() => {
165
165
  inflight = null;
@@ -12,7 +12,7 @@ import type {
12
12
  AppReleaseSnapshot,
13
13
  HostBridge,
14
14
  PythonRunnerSnapshot,
15
- } from './electron-bridge';
15
+ } from './host-bridge';
16
16
  import { createHttpBridge } from './http-bridge';
17
17
 
18
18
  type VoidCallback = () => void;
package/src/main.tsx CHANGED
@@ -94,8 +94,8 @@ export async function bootstrap(): Promise<void> {
94
94
  if (import.meta.env.DEV) {
95
95
  // 动态 import:prod 构建里 Rollup 把 DEV 分支连同 mock(含其 fixtures)
96
96
  // 整体树摇掉,浏览器 dev mock 数据不进产物。
97
- const { installBrowserDevElectronMock } = await import('./lib/browser-dev-electron-mock');
98
- installBrowserDevElectronMock();
97
+ const { installBrowserDevHostMock } = await import('./lib/browser-dev-host-mock');
98
+ installBrowserDevHostMock();
99
99
  }
100
100
 
101
101
  // 标题与 favicon 在 bootstrap 时设置——此刻产品入口已完成包注册
@@ -105,7 +105,7 @@ export async function bootstrap(): Promise<void> {
105
105
  defaultLocale: import.meta.env.VITE_DEFAULT_LOCALE || 'en',
106
106
  });
107
107
  document.documentElement.lang = getLocale() === 'zh' ? 'zh-CN' : getLocale();
108
- window.electron?.setLocale?.(getLocale());
108
+ window.steerableHost?.setLocale?.(getLocale());
109
109
  document.title = BRAND_NAME;
110
110
  document.querySelector<HTMLLinkElement>('link[rel="icon"]')?.setAttribute('href', getBrandLogoUrl());
111
111
  installHostPaste();