@steerable/agent-shell-web 0.6.53 → 0.6.56
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 +3 -4
- package/package.json +4 -4
- package/src/AppShell.tsx +3 -3
- package/src/brand.ts +1 -1
- package/src/components/AgentSidebar.tsx +64 -56
- package/src/components/ChatHeader.tsx +41 -25
- package/src/components/ConfirmDialog.tsx +4 -3
- package/src/components/CreateProjectModal.tsx +31 -21
- package/src/components/LocalLlmSettingsModal.tsx +4 -3
- package/src/components/SidebarRelease.tsx +6 -5
- package/src/components/TerminalPanel.tsx +6 -5
- package/src/components/TerminalView.tsx +15 -10
- package/src/components/chat/ApprovalModal.tsx +40 -26
- package/src/components/chat/ApprovalPromptProvider.tsx +5 -5
- package/src/components/chat/AskUserPromptProvider.tsx +4 -4
- package/src/components/chat/AskUserQuestionMenu.tsx +19 -14
- package/src/components/chat/AssistantMessage.tsx +18 -13
- package/src/components/chat/ChatInput.tsx +56 -40
- package/src/components/chat/ChatProjectBadge.tsx +27 -22
- package/src/components/chat/EmptyChatHero.tsx +2 -1
- package/src/components/chat/ExecPolicyPicker.tsx +12 -11
- package/src/components/chat/ExecutedActionsCard.tsx +45 -33
- package/src/components/chat/FilePathCode.tsx +8 -3
- package/src/components/chat/InterruptedTurnCard.tsx +4 -3
- package/src/components/chat/LocalChatPanel.tsx +2 -1
- package/src/components/chat/Markdown.tsx +2 -1
- package/src/components/chat/MessageList.tsx +3 -2
- package/src/components/chat/ModelPicker.tsx +25 -16
- package/src/components/chat/OrchestrationChildrenCard.tsx +2 -1
- package/src/components/chat/OrchestrationFlowCard.tsx +23 -22
- package/src/components/chat/PlanTodoList.tsx +2 -1
- package/src/components/chat/ProjectTrustBanner.tsx +19 -5
- package/src/components/chat/SessionOrchestrationFlow.tsx +27 -26
- package/src/components/chat/SessionTodoList.tsx +8 -7
- package/src/components/chat/SessionTreeModal.tsx +10 -9
- package/src/components/chat/StreamingStatus.tsx +4 -3
- package/src/components/chat/SuggestedReplies.tsx +3 -2
- package/src/components/chat/TaskOutcomeCards.tsx +8 -5
- package/src/components/chat/TaskPanelModal.tsx +33 -23
- package/src/components/chat/TaskProcessPanel.tsx +16 -15
- package/src/components/chat/TurnFilesCard.tsx +14 -13
- package/src/components/chat/UserMessage.tsx +12 -11
- package/src/components/chat/executed-actions-model.ts +47 -35
- package/src/components/chat/orchestration-flow-model.ts +16 -5
- package/src/components/chat/process-status.ts +8 -7
- package/src/components/chat/todo-list-model.ts +5 -4
- package/src/components/chat/turn-files.ts +8 -8
- package/src/components/chat/useChatTasks.ts +3 -3
- package/src/components/settings/AgentCapabilityFields.tsx +26 -23
- package/src/components/settings/AgentsSettingsPanel.tsx +33 -28
- package/src/components/settings/AppUpdateSettingsPanel.tsx +3 -2
- package/src/components/settings/AppearanceSettingsPanel.tsx +81 -37
- package/src/components/settings/DiagnoseSettingsPanel.tsx +11 -8
- package/src/components/settings/InsightsSettingsPanel.tsx +58 -43
- package/src/components/settings/LlmSettingsPanel.tsx +107 -86
- package/src/components/settings/McpSettingsPanel.tsx +72 -46
- package/src/components/settings/ModelIdCombobox.tsx +2 -1
- package/src/components/settings/OrchestrationSettingsPanel.tsx +8 -5
- package/src/components/settings/PortableSettingsPanel.tsx +83 -55
- package/src/components/settings/PythonRunnerSettingsPanel.tsx +26 -23
- package/src/components/settings/SecuritySettingsPanel.tsx +58 -34
- package/src/components/settings/SettingsNavMenu.tsx +3 -2
- package/src/components/settings/SettingsSaveButton.tsx +2 -1
- package/src/components/settings/SkillsSettingsPanel.tsx +43 -38
- package/src/components/settings/TelemetrySettingsPanel.tsx +20 -17
- package/src/components/settings/UsagePanel.tsx +22 -23
- package/src/components/settings/WebSearchSettingsPanel.tsx +28 -19
- package/src/components/settings/llm-vendors.ts +12 -7
- package/src/components/settings/model-capabilities.ts +16 -15
- package/src/components/settings/preset-choice-model.ts +6 -3
- package/src/fixtures/browser-dev-data.json +24 -24
- package/src/hooks/useChatsAndAgents.ts +9 -9
- package/src/hooks/useProjects.ts +3 -3
- package/src/i18n/agent-label.ts +15 -0
- package/src/i18n/index.tsx +68 -0
- package/src/i18n/runtime.ts +117 -0
- package/src/i18n/translate.ts +65 -0
- package/src/layouts/AgentLayout.tsx +13 -12
- package/src/lib/app-release.ts +16 -11
- package/src/lib/attachments.ts +18 -9
- package/src/lib/{browser-dev-electron-mock.ts → browser-dev-host-mock.ts} +42 -42
- package/src/lib/chat-title.ts +3 -2
- package/src/lib/chat-transport.ts +16 -12
- package/src/lib/date-groups.ts +23 -15
- package/src/lib/host-bridge.ts +371 -4
- package/src/lib/host-paste.ts +1 -1
- package/src/lib/http-bridge.ts +12 -9
- package/src/lib/insights.ts +2 -2
- package/src/lib/local-api.ts +5 -5
- package/src/lib/portable.ts +11 -10
- package/src/lib/show-thinking-content.ts +15 -3
- package/src/lib/slash-sources.ts +3 -3
- package/src/lib/tauri-bridge.ts +1 -1
- package/src/main.tsx +27 -4
- package/src/pages/AgentPage.tsx +39 -34
- package/src/pages/ChatPanelPreviewPage.tsx +46 -44
- package/src/pages/SettingsPage.tsx +51 -45
- package/src/vite-env.d.ts +3 -0
- package/vite.base.js +6 -2
- package/src/lib/electron-bridge.ts +0 -390
|
@@ -1,390 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Host-neutral bridge used by the renderer in desktop and browser modes.
|
|
3
|
-
*
|
|
4
|
-
* This file MUST stay a subset / aligned shape with `ElectronAPI` in
|
|
5
|
-
* `../../../src/preload.ts`. We intentionally don't TypeScript-reference that
|
|
6
|
-
* file across workspaces — it would drag the whole main-process source tree
|
|
7
|
-
* into the renderer's compile graph. Treat this as a contract surface and
|
|
8
|
-
* extend it lazily as apps/web starts using new bridge methods.
|
|
9
|
-
*
|
|
10
|
-
* `window.electron` and `getElectronBridge()` remain compatibility aliases for
|
|
11
|
-
* existing products. New integrations should use `window.steerableHost` and
|
|
12
|
-
* `getHostBridge()`.
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
import type { SSEEvent } from '@steerable/agent-protocol';
|
|
16
|
-
import { getHttpBridge } from './http-bridge';
|
|
17
|
-
import { getTauriBridge } from './tauri-bridge';
|
|
18
|
-
|
|
19
|
-
export type LocalBackendRequestInput = {
|
|
20
|
-
method: string;
|
|
21
|
-
path: string;
|
|
22
|
-
body?: unknown;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
export type LocalBackendStreamEvent =
|
|
26
|
-
| { type: 'data'; chunk: string; parsed?: SSEEvent }
|
|
27
|
-
| { type: 'end'; status: number }
|
|
28
|
-
| { type: 'error'; error: string };
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* W4-1: mirror of the approval algebra's decision variants
|
|
32
|
-
* (`steerable_agent_runtime.approval.APPROVAL_KINDS` minus `timed_out`,
|
|
33
|
-
* which the sidecar synthesizes itself on timeout).
|
|
34
|
-
*/
|
|
35
|
-
export type ApprovalDecisionKind =
|
|
36
|
-
| 'allow_once'
|
|
37
|
-
| 'allow_for_session'
|
|
38
|
-
| 'allow_always'
|
|
39
|
-
| 'deny_once'
|
|
40
|
-
| 'deny_for_session'
|
|
41
|
-
| 'deny_always'
|
|
42
|
-
| 'abort';
|
|
43
|
-
|
|
44
|
-
export interface ApprovalPromptRequest {
|
|
45
|
-
requestId: string;
|
|
46
|
-
toolName: string;
|
|
47
|
-
arguments: Record<string, unknown>;
|
|
48
|
-
mode: string;
|
|
49
|
-
category: string;
|
|
50
|
-
round: number;
|
|
51
|
-
/** 发起审批的对话。缺省时卡片不绑定会话(旧请求)。 */
|
|
52
|
-
chatId?: string;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* W8: mirror of the sidecar's `ask_user.request` reverse-call payload
|
|
57
|
-
* (`HostAskUserHandler` in steerable_sidecar.host_tools). `questions`
|
|
58
|
-
* entries match `AskUserQuestionsPayload['questions'][number]` from
|
|
59
|
-
* `@steerable/agent-protocol`; kept structurally typed here so the
|
|
60
|
-
* renderer's compile graph stays free of main-process imports.
|
|
61
|
-
*/
|
|
62
|
-
export interface AskUserPromptRequest {
|
|
63
|
-
requestId: string;
|
|
64
|
-
intro: string;
|
|
65
|
-
questions: Array<Record<string, unknown>>;
|
|
66
|
-
/** 发起提问的对话。缺省时卡片不绑定会话(旧请求)。 */
|
|
67
|
-
chatId?: string;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Mirror of `TerminalSession` / `TerminalSpawnOptions` in
|
|
72
|
-
* `src/terminal-manager.ts`. Kept inline (rather than cross-imported)
|
|
73
|
-
* for the same reason as the rest of this file — we don't want the
|
|
74
|
-
* renderer's compile graph to pull in main-process modules.
|
|
75
|
-
*/
|
|
76
|
-
export interface TerminalSession {
|
|
77
|
-
id: string;
|
|
78
|
-
shell: string;
|
|
79
|
-
pid: number;
|
|
80
|
-
cwd: string;
|
|
81
|
-
cols: number;
|
|
82
|
-
rows: number;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
export interface TerminalSpawnOptions {
|
|
86
|
-
shell?: string;
|
|
87
|
-
cwd?: string;
|
|
88
|
-
env?: Record<string, string>;
|
|
89
|
-
cols?: number;
|
|
90
|
-
rows?: number;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
export type AppReleasePhase =
|
|
94
|
-
| 'disabled'
|
|
95
|
-
| 'idle'
|
|
96
|
-
| 'checking'
|
|
97
|
-
| 'downloading'
|
|
98
|
-
| 'ready'
|
|
99
|
-
| 'installing'
|
|
100
|
-
| 'error';
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* 桌面版本与更新。`version` 是当前安装版本,`availableVersion` 是待安装版本。
|
|
104
|
-
* 与主进程 `AppReleaseSnapshot` 对齐。
|
|
105
|
-
*/
|
|
106
|
-
export interface AppReleaseSnapshot {
|
|
107
|
-
version: string;
|
|
108
|
-
enabled: boolean;
|
|
109
|
-
phase: AppReleasePhase;
|
|
110
|
-
availableVersion?: string;
|
|
111
|
-
percent?: number;
|
|
112
|
-
message?: string;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
export type PythonRunnerPhase =
|
|
116
|
-
| 'idle'
|
|
117
|
-
| 'downloading'
|
|
118
|
-
| 'verifying'
|
|
119
|
-
| 'extracting'
|
|
120
|
-
| 'ready'
|
|
121
|
-
| 'error';
|
|
122
|
-
|
|
123
|
-
export interface PythonRunnerSnapshot {
|
|
124
|
-
supported: boolean;
|
|
125
|
-
source: 'default' | 'url' | 'local';
|
|
126
|
-
phase: PythonRunnerPhase;
|
|
127
|
-
percent?: number;
|
|
128
|
-
downloadedBytes?: number;
|
|
129
|
-
totalBytes?: number;
|
|
130
|
-
message?: string;
|
|
131
|
-
defaultUrl?: string;
|
|
132
|
-
configuredUrl?: string;
|
|
133
|
-
activeRunner?: string;
|
|
134
|
-
configuredRunner?: string;
|
|
135
|
-
restartRequired: boolean;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
export interface HostBridge {
|
|
139
|
-
runtime: 'local';
|
|
140
|
-
platform: NodeJS.Platform;
|
|
141
|
-
local?: {
|
|
142
|
-
selectDirectory: (options?: {
|
|
143
|
-
title?: string;
|
|
144
|
-
}) => Promise<{ canceled: boolean; filePaths: string[] }>;
|
|
145
|
-
saveTextFile?: (options: {
|
|
146
|
-
title?: string;
|
|
147
|
-
defaultPath?: string;
|
|
148
|
-
content: string;
|
|
149
|
-
}) => Promise<{ canceled: boolean; filePath?: string }>;
|
|
150
|
-
/** 截取窗口(或指定 DIP 区域)并写入系统剪贴板。 */
|
|
151
|
-
captureScreenshot: (rect?: {
|
|
152
|
-
x: number;
|
|
153
|
-
y: number;
|
|
154
|
-
width: number;
|
|
155
|
-
height: number;
|
|
156
|
-
}) => Promise<
|
|
157
|
-
| { success: true; width: number; height: number }
|
|
158
|
-
| { success: false; error: string }
|
|
159
|
-
>;
|
|
160
|
-
};
|
|
161
|
-
localBackend: {
|
|
162
|
-
request: <T>(input: LocalBackendRequestInput) => Promise<T>;
|
|
163
|
-
startStream: (
|
|
164
|
-
input: LocalBackendRequestInput,
|
|
165
|
-
onEvent: (payload: LocalBackendStreamEvent) => void,
|
|
166
|
-
) => Promise<string | null>;
|
|
167
|
-
cancelStream: (streamId: string) => void;
|
|
168
|
-
/** 轮中转向:注入一条用户消息到运行中的 CoreLoop 回合;false = 无可转向回合。 */
|
|
169
|
-
steerChat?: (chatId: string, content: string) => Promise<boolean>;
|
|
170
|
-
};
|
|
171
|
-
/** 会话附件:把源文件路径 / base64 字节拷贝进会话空间(`attachments:save`)。 */
|
|
172
|
-
attachments?: {
|
|
173
|
-
save: (input: {
|
|
174
|
-
chatId: string;
|
|
175
|
-
files: Array<{ path?: string; name?: string; data?: string }>;
|
|
176
|
-
}) => Promise<{
|
|
177
|
-
files: Array<{ name: string; path: string; size: number; error?: string }>;
|
|
178
|
-
}>;
|
|
179
|
-
};
|
|
180
|
-
/**
|
|
181
|
-
* App menu IPC — `Cmd+N` / 文件 → 新建对话 fires `menu:new-chat`
|
|
182
|
-
* (see src/main.ts:createMenu). Renderer subscribes via
|
|
183
|
-
* `onMenuNewChat(cb)` and *must* call `offMenuNewChat()` on unmount
|
|
184
|
-
* to clear the listener (otherwise multiple AgentSidebar mounts
|
|
185
|
-
* during HMR would queue up duplicate callbacks).
|
|
186
|
-
*/
|
|
187
|
-
onMenuNewChat?: (callback: () => void) => void;
|
|
188
|
-
offMenuNewChat?: () => void;
|
|
189
|
-
/**
|
|
190
|
-
* App menu IPC — `Cmd+T` / 视图 → 打开终端 fires `menu:open-terminal`.
|
|
191
|
-
* The terminal is a toggleable panel inside AgentLayout (not a separate
|
|
192
|
-
* window, not a route), so the renderer just flips layout state. Same
|
|
193
|
-
* subscribe/off pairing as `onMenuNewChat`.
|
|
194
|
-
*/
|
|
195
|
-
onMenuOpenTerminal?: (callback: () => void) => void;
|
|
196
|
-
offMenuOpenTerminal?: () => void;
|
|
197
|
-
/**
|
|
198
|
-
* App menu IPC — `Cmd+V` / 编辑 → 粘贴 fires `menu:paste`.
|
|
199
|
-
* WKWebView does not expose that pasteboard to the page, so the renderer
|
|
200
|
-
* reads it through `readClipboard`.
|
|
201
|
-
*/
|
|
202
|
-
onMenuPaste?: (callback: () => void) => void;
|
|
203
|
-
offMenuPaste?: () => void;
|
|
204
|
-
/**
|
|
205
|
-
* OS pasteboard. `files` are copied paths or a screenshot PNG.
|
|
206
|
-
* Text is empty when the pasteboard holds files, so the path is not
|
|
207
|
-
* inserted into the composer as well.
|
|
208
|
-
*/
|
|
209
|
-
readClipboard?: () => Promise<{
|
|
210
|
-
text: string;
|
|
211
|
-
files: Array<{
|
|
212
|
-
name: string;
|
|
213
|
-
path?: string;
|
|
214
|
-
dataBase64?: string;
|
|
215
|
-
mime?: string;
|
|
216
|
-
}>;
|
|
217
|
-
}>;
|
|
218
|
-
/** Plain text from the OS pasteboard. Empty when the clipboard has no text. */
|
|
219
|
-
readClipboardText?: () => Promise<string>;
|
|
220
|
-
/**
|
|
221
|
-
* 异步 AI 标题就绪通知。Backend 在每条 chat 首条助手回复完成后 fire-and-forget
|
|
222
|
-
* 跑 LLM 生成标题;完成时通过这个通道把 `{chatId, title}` 推过来。返回的函数
|
|
223
|
-
* 解除订阅(preload 用 add/remove 配对,不是 removeAllListeners——可以多处订阅)。
|
|
224
|
-
*/
|
|
225
|
-
onChatTitleUpdated?: (
|
|
226
|
-
callback: (payload: { chatId: string; title: string }) => void,
|
|
227
|
-
) => () => void;
|
|
228
|
-
/**
|
|
229
|
-
* 回合追问建议就绪。Backend 在助手回复完成后推 `{chatId, messageId, suggestions}`
|
|
230
|
-
* (先启发式、后 LLM 替换)。返回解除订阅函数。
|
|
231
|
-
*/
|
|
232
|
-
onSuggestedReplies?: (
|
|
233
|
-
callback: (payload: {
|
|
234
|
-
chatId: string;
|
|
235
|
-
messageId: string;
|
|
236
|
-
suggestions: string[];
|
|
237
|
-
}) => void,
|
|
238
|
-
) => () => void;
|
|
239
|
-
/**
|
|
240
|
-
* 会话补建通知。Backend 在「向一个本地不存在的 chatId 首次发送」时按 URL
|
|
241
|
-
* 里的 id 现场补建会话(见 router.handleStream),随后广播 `chat-created`
|
|
242
|
-
* ({chatId, agentId});渲染端据此 refresh 一次侧栏,避免"URL 能聊、列表
|
|
243
|
-
* 里却找不到这条会话"。返回解除订阅函数。
|
|
244
|
-
*/
|
|
245
|
-
onChatCreated?: (
|
|
246
|
-
callback: (payload: { chatId: string; agentId?: string | null }) => void,
|
|
247
|
-
) => () => void;
|
|
248
|
-
/**
|
|
249
|
-
* 4.6a 后台任务状态推送。任务到达终态或 worktree 合并/丢弃完成时主进程
|
|
250
|
-
* 广播;载荷只有 chatId/taskId,面板收到后重新拉列表。
|
|
251
|
-
*/
|
|
252
|
-
onTaskUpdated?: (
|
|
253
|
-
callback: (payload: { chatId: string; taskId: string }) => void,
|
|
254
|
-
) => () => void;
|
|
255
|
-
/**
|
|
256
|
-
* 场景包广播事件订阅(3.1 通用化):按通道名订阅主进程/BS 后端的
|
|
257
|
-
* 广播事件,载荷由订阅方(包)自行收窄校验。shell 不知道包的事件
|
|
258
|
-
* 语义——包的通道名约定带包前缀(如 `<pack>:updated`)。返回解除
|
|
259
|
-
* 订阅函数。
|
|
260
|
-
*/
|
|
261
|
-
onPackEvent?: (
|
|
262
|
-
channel: string,
|
|
263
|
-
callback: (payload: unknown) => void,
|
|
264
|
-
) => () => void;
|
|
265
|
-
/**
|
|
266
|
-
* 后台任务推理时间线推送。任务流的 reasoning / 工具 / 文本增量经主进程
|
|
267
|
-
* 广播;右侧过程栏订阅后不用轮询。
|
|
268
|
-
*/
|
|
269
|
-
onTaskProcess?: (
|
|
270
|
-
callback: (payload: {
|
|
271
|
-
chatId: string;
|
|
272
|
-
taskId: string;
|
|
273
|
-
timeline: unknown;
|
|
274
|
-
live: boolean;
|
|
275
|
-
}) => void,
|
|
276
|
-
) => () => void;
|
|
277
|
-
/**
|
|
278
|
-
* W4-1 审批代数:sidecar ApprovalExecutor 的请示经主进程广播到 renderer。
|
|
279
|
-
* onRequest 订阅返回 unsubscribe;decide 把用户的 7 变体决定送回主进程。
|
|
280
|
-
*/
|
|
281
|
-
approval?: {
|
|
282
|
-
onRequest: (callback: (request: ApprovalPromptRequest) => void) => () => void;
|
|
283
|
-
decide: (decision: {
|
|
284
|
-
requestId: string;
|
|
285
|
-
kind: ApprovalDecisionKind;
|
|
286
|
-
reason?: string;
|
|
287
|
-
}) => Promise<void>;
|
|
288
|
-
pending: () => Promise<ApprovalPromptRequest[]>;
|
|
289
|
-
};
|
|
290
|
-
/**
|
|
291
|
-
* W8 结构化提问:sidecar ask_user 工具的请示经主进程/BS 服务器广播到
|
|
292
|
-
* renderer。onRequest 订阅返回 unsubscribe;answer 把答案映射送回
|
|
293
|
-
* (空映射 = 用户未作答,模型自行推进)。
|
|
294
|
-
*/
|
|
295
|
-
askUser?: {
|
|
296
|
-
onRequest: (callback: (request: AskUserPromptRequest) => void) => () => void;
|
|
297
|
-
answer: (reply: {
|
|
298
|
-
requestId: string;
|
|
299
|
-
answers: Record<string, string | string[]>;
|
|
300
|
-
}) => Promise<void>;
|
|
301
|
-
pending: () => Promise<AskUserPromptRequest[]>;
|
|
302
|
-
};
|
|
303
|
-
terminal?: {
|
|
304
|
-
/** Ensures a session exists (reuses last one if alive). */
|
|
305
|
-
ensure: (options?: TerminalSpawnOptions) => Promise<TerminalSession>;
|
|
306
|
-
write: (id: string, data: string) => Promise<boolean>;
|
|
307
|
-
resize: (id: string, cols: number, rows: number) => Promise<boolean>;
|
|
308
|
-
onData: (
|
|
309
|
-
callback: (payload: { sessionId: string; chunk: string }) => void,
|
|
310
|
-
) => () => void;
|
|
311
|
-
onExit: (
|
|
312
|
-
callback: (payload: {
|
|
313
|
-
sessionId: string;
|
|
314
|
-
code: number;
|
|
315
|
-
signal: string | null;
|
|
316
|
-
}) => void,
|
|
317
|
-
) => () => void;
|
|
318
|
-
};
|
|
319
|
-
/**
|
|
320
|
-
* 桌面版本与更新。Electron / Tauri 提供;浏览器预览没有这一段。
|
|
321
|
-
*/
|
|
322
|
-
app?: {
|
|
323
|
-
snapshot: () => Promise<AppReleaseSnapshot>;
|
|
324
|
-
check: () => Promise<AppReleaseSnapshot>;
|
|
325
|
-
install: () => Promise<AppReleaseSnapshot>;
|
|
326
|
-
onState: (callback: (snapshot: AppReleaseSnapshot) => void) => () => void;
|
|
327
|
-
};
|
|
328
|
-
/** Desktop-only Python child interpreter management for run_code. */
|
|
329
|
-
pythonRunner?: {
|
|
330
|
-
snapshot: () => Promise<PythonRunnerSnapshot>;
|
|
331
|
-
download: (url?: string) => Promise<PythonRunnerSnapshot>;
|
|
332
|
-
cancel: () => Promise<PythonRunnerSnapshot>;
|
|
333
|
-
pickLocal: () => Promise<string | null>;
|
|
334
|
-
useLocal: (path: string) => Promise<PythonRunnerSnapshot>;
|
|
335
|
-
useDefault: () => Promise<PythonRunnerSnapshot>;
|
|
336
|
-
restart: () => Promise<void>;
|
|
337
|
-
onState: (callback: (snapshot: PythonRunnerSnapshot) => void) => () => void;
|
|
338
|
-
};
|
|
339
|
-
// 场景包的 invoke 命名空间(如包 preload 贡献的 `<pack>` / `<pack>Mock`)
|
|
340
|
-
// 不进本接口——包用自己的结构化收窄访问器(见各包 web/bridge.ts),
|
|
341
|
-
// shell 桥接口保持产品中立(3.1)。
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
/** @deprecated Use `HostBridge`. */
|
|
345
|
-
export type ElectronBridge = HostBridge;
|
|
346
|
-
|
|
347
|
-
declare global {
|
|
348
|
-
interface Window {
|
|
349
|
-
steerableHost?: HostBridge;
|
|
350
|
-
electron?: ElectronBridge;
|
|
351
|
-
__TAURI_INTERNALS__?: object;
|
|
352
|
-
/**
|
|
353
|
-
* BS server(src/server/)托管 index.html 时注入的引导信息;存在即代表
|
|
354
|
-
* 当前跑在浏览器-服务器模式,getElectronBridge() 会返回 HTTP 实现。
|
|
355
|
-
*/
|
|
356
|
-
__DEEPPATH_BS__?: {
|
|
357
|
-
platform: NodeJS.Platform;
|
|
358
|
-
flavor: string;
|
|
359
|
-
brandName: string;
|
|
360
|
-
};
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
export function getHostBridge(): HostBridge | null {
|
|
365
|
-
if (typeof window === 'undefined') return null;
|
|
366
|
-
if (window.steerableHost) return window.steerableHost;
|
|
367
|
-
if (window.electron) return window.electron;
|
|
368
|
-
if (window.__TAURI_INTERNALS__ && window.__DEEPPATH_BS__) {
|
|
369
|
-
return getTauriBridge();
|
|
370
|
-
}
|
|
371
|
-
if (window.__DEEPPATH_BS__) return getHttpBridge();
|
|
372
|
-
return null;
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
/** @deprecated Use `getHostBridge`. */
|
|
376
|
-
export const getElectronBridge = getHostBridge;
|
|
377
|
-
|
|
378
|
-
export function isDesktopHost(): boolean {
|
|
379
|
-
if (typeof window === 'undefined') return false;
|
|
380
|
-
return Boolean(
|
|
381
|
-
window.steerableHost ||
|
|
382
|
-
window.electron ||
|
|
383
|
-
(window.__TAURI_INTERNALS__ && window.__DEEPPATH_BS__),
|
|
384
|
-
);
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
/** @deprecated Use `isDesktopHost` when desktop-only behavior is required. */
|
|
388
|
-
export function isElectron(): boolean {
|
|
389
|
-
return getHostBridge() !== null;
|
|
390
|
-
}
|