@takboo/dsh-coopanion 0.4.18 → 0.4.20
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 -3
- package/dist/bridge.js +38 -6
- package/dist/bridge.js.map +2 -2
- package/dist/build-info.json +2 -2
- package/dist/client.js +30 -1
- package/dist/index.js +47 -11
- package/dist/index.js.map +2 -2
- package/docs/README.md +2 -0
- package/docs/compatibility.md +45 -7
- package/docs/desktop-recovery-contract.md +1 -1
- package/docs/development.md +22 -3
- package/docs/notification-contract.md +1 -1
- package/docs/release-notes.md +20 -0
- package/docs/releasing.md +22 -5
- package/docs/session-chat-contract.md +1 -1
- package/docs/usage.md +7 -7
- package/npm-shrinkwrap.json +675 -626
- package/package.json +47 -43
- package/scripts/compatibility/check.mjs +5 -2
- package/scripts/compatibility/desktop.mjs +4 -1
- package/scripts/compatibility/planning.mjs +5 -2
- package/scripts/compatibility/prepare.mjs +1 -0
- package/scripts/compatibility/proposal.mjs +8 -0
- package/scripts/compatibility/report.mjs +34 -19
- package/scripts/compatibility/reviewed-dependencies.mjs +25 -0
- package/scripts/verify-engineering.sh +91 -0
- package/src/client/Settings.tsx +8 -1
- package/src/client/locales.ts +6 -0
- package/src/controls.ts +17 -11
- package/src/desktop-lifecycle.ts +11 -0
- package/src/electron-runtime.ts +25 -7
- package/tests/compatibility-monitor.mjs +113 -1
- package/tests/electron-startup.test.ts +29 -4
- package/tests/engineering-targets.json +12 -0
- package/tests/engineering-web-probe.mjs +58 -0
- package/tests/helpers/installed-services.mjs +1 -1
- package/tests/install.mjs +5 -2
- package/tests/multi-display-native.mjs +12 -1
- package/tests/notification-host-contract.mjs +1 -1
- package/tests/notification-integration.test.ts +10 -10
- package/tests/plugin.test.ts +2 -0
package/README.md
CHANGED
|
@@ -51,14 +51,14 @@
|
|
|
51
51
|
|
|
52
52
|
## 开始一起工作
|
|
53
53
|
|
|
54
|
-
需要 **DeepSeek Harness Desktop 0.2.0-rc.2、0.2.1-alpha.1、0.2.1-rc.1、0.2.1-rc.2、0.2.1-rc.3 或 0.2.
|
|
54
|
+
需要 **DeepSeek Harness Desktop 0.2.0-rc.2、0.2.1-alpha.1、0.2.1-rc.1、0.2.1-rc.2、0.2.1-rc.3、0.2.1-rc.5 或 0.2.2-rc.1**。这是 Harness 插件,聊天使用你在 Harness 中配置的模型,无需另填 API Key。
|
|
55
55
|
|
|
56
56
|
### 在 Harness 中从 npm 安装(推荐)
|
|
57
57
|
|
|
58
58
|
打开侧边栏 **插件 → 添加插件**,在「包名或地址」中填入:
|
|
59
59
|
|
|
60
60
|
```text
|
|
61
|
-
@takboo/dsh-coopanion@0.4.
|
|
61
|
+
@takboo/dsh-coopanion@0.4.20
|
|
62
62
|
```
|
|
63
63
|
|
|
64
64
|
点击安装,完成后启用 `dsh-coopanion`,再完全退出并重新打开 Harness。
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
使用 **Desktop 自带的 `dsh` 命令**。先启动 Desktop 一次完成初始化,完全退出应用后执行:
|
|
71
71
|
|
|
72
72
|
```bash
|
|
73
|
-
dsh plugin --profile desktop add @takboo/dsh-coopanion@0.4.
|
|
73
|
+
dsh plugin --profile desktop add @takboo/dsh-coopanion@0.4.20
|
|
74
74
|
```
|
|
75
75
|
|
|
76
76
|
完成后重新打开 Desktop。其他 profile 的安装方法见[使用指南](docs/usage.md#通过-dsh-命令行安装)。
|
package/dist/bridge.js
CHANGED
|
@@ -11,14 +11,40 @@ var NativeStartError = class extends Error {
|
|
|
11
11
|
this.name = "NativeStartError";
|
|
12
12
|
}
|
|
13
13
|
};
|
|
14
|
+
var RuntimePreparationError = class extends NativeStartError {
|
|
15
|
+
constructor(failure, detail) {
|
|
16
|
+
const cause = failure.reason === "http" ? `download rejected (HTTP ${failure.httpStatus})` : {
|
|
17
|
+
network: "download connection failed",
|
|
18
|
+
timeout: "download or installation timed out (240 seconds)",
|
|
19
|
+
unavailable: "installer or executable unavailable",
|
|
20
|
+
install: "installation failed"
|
|
21
|
+
}[failure.reason];
|
|
22
|
+
super(`Electron runtime is missing: ${cause}${detail ? ` (${detail})` : ""}. Prepare Electron or configure electronPath, then start the pet again.`, false);
|
|
23
|
+
this.failure = failure;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
14
26
|
|
|
15
27
|
// src/electron-runtime.ts
|
|
16
28
|
import { spawn } from "node:child_process";
|
|
17
29
|
import { access, readFile } from "node:fs/promises";
|
|
18
30
|
import { createRequire } from "node:module";
|
|
19
31
|
import { dirname, join } from "node:path";
|
|
32
|
+
function installerFailure(stderr, code) {
|
|
33
|
+
const summary = stderr.split(/\r?\n/, 1)[0] ?? "";
|
|
34
|
+
const status = /^HTTPError: Response code ([45]\d\d)\b/.exec(summary);
|
|
35
|
+
if (status) return new RuntimePreparationError({ reason: "http", httpStatus: Number(status[1]) });
|
|
36
|
+
if (/\b(?:ENOTFOUND|EAI_AGAIN|ECONNREFUSED|ECONNRESET|ENETUNREACH|ETIMEDOUT)\b|^TypeError: fetch failed\b/.test(summary)) {
|
|
37
|
+
return new RuntimePreparationError({ reason: "network" });
|
|
38
|
+
}
|
|
39
|
+
return new RuntimePreparationError({ reason: "install" }, code === null ? void 0 : String(code));
|
|
40
|
+
}
|
|
20
41
|
async function electronExecutable(signal) {
|
|
21
|
-
|
|
42
|
+
let directory;
|
|
43
|
+
try {
|
|
44
|
+
directory = dirname(createRequire(import.meta.url).resolve("electron"));
|
|
45
|
+
} catch {
|
|
46
|
+
throw new RuntimePreparationError({ reason: "unavailable" });
|
|
47
|
+
}
|
|
22
48
|
async function installed() {
|
|
23
49
|
let relative;
|
|
24
50
|
try {
|
|
@@ -47,9 +73,13 @@ async function electronExecutable(signal) {
|
|
|
47
73
|
}
|
|
48
74
|
const child = spawn(process.execPath, [join(directory, "install.js")], {
|
|
49
75
|
env: { ...process.env, ELECTRON_RUN_AS_NODE: "1" },
|
|
50
|
-
stdio: "ignore",
|
|
76
|
+
stdio: ["ignore", "ignore", "pipe"],
|
|
51
77
|
windowsHide: true
|
|
52
78
|
});
|
|
79
|
+
let stderr = "";
|
|
80
|
+
child.stderr.on("data", (data) => {
|
|
81
|
+
if (stderr.length < 512) stderr += data.subarray(0, 512 - stderr.length).toString();
|
|
82
|
+
});
|
|
53
83
|
let failure, killTimer;
|
|
54
84
|
const stop = (error) => {
|
|
55
85
|
if (failure) return;
|
|
@@ -58,7 +88,7 @@ async function electronExecutable(signal) {
|
|
|
58
88
|
killTimer = setTimeout(() => child.kill("SIGKILL"), 1e3);
|
|
59
89
|
};
|
|
60
90
|
const aborted = () => stop(new Error("\u684C\u5BA0\u542F\u52A8\u5DF2\u53D6\u6D88"));
|
|
61
|
-
const timer = setTimeout(() => stop(new
|
|
91
|
+
const timer = setTimeout(() => stop(new RuntimePreparationError({ reason: "timeout" })), 24e4);
|
|
62
92
|
signal.addEventListener("abort", aborted, { once: true });
|
|
63
93
|
const finish = (error) => {
|
|
64
94
|
clearTimeout(timer);
|
|
@@ -67,13 +97,15 @@ async function electronExecutable(signal) {
|
|
|
67
97
|
if (failure || error) reject(failure ?? error);
|
|
68
98
|
else resolve();
|
|
69
99
|
};
|
|
70
|
-
child.once("error", (
|
|
71
|
-
|
|
100
|
+
child.once("error", () => {
|
|
101
|
+
failure ??= new RuntimePreparationError({ reason: "unavailable" });
|
|
102
|
+
});
|
|
103
|
+
child.once("close", (code) => finish(code === 0 ? void 0 : installerFailure(stderr, code)));
|
|
72
104
|
if (signal.aborted) aborted();
|
|
73
105
|
});
|
|
74
106
|
if (signal.aborted) throw new Error("\u684C\u5BA0\u542F\u52A8\u5DF2\u53D6\u6D88");
|
|
75
107
|
const executable = await installed();
|
|
76
|
-
if (!executable) throw new
|
|
108
|
+
if (!executable) throw new RuntimePreparationError({ reason: "unavailable" });
|
|
77
109
|
return executable;
|
|
78
110
|
}
|
|
79
111
|
|
package/dist/bridge.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/bridge.ts", "../src/desktop-lifecycle.ts", "../src/electron-runtime.ts"],
|
|
4
|
-
"sourcesContent": ["import { spawn, type ChildProcess } from 'node:child_process';\nimport { fileURLToPath } from 'node:url';\nimport { EventEmitter } from 'node:events';\nimport type { ChatReceipt } from '../web/chat-contract.js';\nimport type { PetSnapshot, PetNotice } from './model.ts';\nimport type { NotificationRuntime, NotificationSnapshot, TaskNotice } from './notification-contract.ts';\nimport { NativeStartError, type StartLifetime, type NativeLifecycle } from './desktop-lifecycle.ts';\nimport { electronExecutable } from './electron-runtime.ts';\nexport { NativeStartError, type StartLifetime, type NativeLifecycle } from './desktop-lifecycle.ts';\n\nimport type { CompanionshipMode } from '../web/companionship.js';\nimport type { TextScale } from '../web/text-scale.js';\n\nexport interface DesktopOptions { size: number; npcHome?: number; npcRange?: number; textScale?: TextScale; roam: boolean; diagnostics?: boolean; companionship?: CompanionshipMode; notifications: boolean; bubbleDurationMs: number; electronPath?: string; locale?: string; systemNotifications?: boolean; reminders?: boolean; reminderDelayMs?: number; }\nexport interface PetBridge {\n start(options: DesktopOptions, lifetime?: StartLifetime): Promise<void>;\n update(snapshot: PetSnapshot): void;\n chatResult?(receipt: ChatReceipt): void;\n notify(notice: PetNotice | TaskNotice, runtime?: NotificationRuntime): boolean;\n notificationState?(snapshot: NotificationSnapshot): void;\n snoozeResult?(interactionId: string, ok: boolean, error?: string): void;\n presentRole?(notice: TaskNotice, runtime: NotificationRuntime): boolean;\n onAction(listener: (action: unknown) => void): void;\n removeAction(listener: (action: unknown) => void): void;\n dispose(): Promise<void>;\n configure?(options: DesktopOptions): void;\n control?(command: 'show' | 'hide' | 'characters'): void;\n focusHarness?(): void;\n onLifecycle?(listener: (state: NativeLifecycle) => void): void;\n removeLifecycle?(listener: (state: NativeLifecycle) => void): void;\n}\n\n/** Owns a separate Electron window; no changes or private IPC in the Harness desktop shell are needed. */\nexport class ElectronBridge extends EventEmitter implements PetBridge {\n private child?: ChildProcess;\n private latest?: PetSnapshot;\n private latestOptions?: DesktopOptions;\n private resultKey?: string;\n private closing = false;\n private preparing?: AbortController;\n private preparation?: Promise<string>;\n\n private generation = 0;\n private visibilityRevision = 0;\n private nativeVisible = false;\n private suspended = false;\n private screenLocked = false;\n private systemAsleep = false;\n private lastNotificationState?: NotificationSnapshot;\n\n async start(options: DesktopOptions, lifetime?: StartLifetime): Promise<void> {\n if (this.child || this.preparing) throw new NativeStartError('Desktop pet is already running or starting', false);\n if (lifetime?.signal.aborted) throw new Error('\u684C\u5BA0\u542F\u52A8\u5DF2\u53D6\u6D88');\n this.latestOptions = { ...options };\n this.closing = false;\n this.generation = lifetime?.generation ?? this.generation + 1;\n this.visibilityRevision = 0; this.nativeVisible = false;\n if (process.platform === 'linux' && !process.env.DISPLAY && !process.env.WAYLAND_DISPLAY) throw new NativeStartError('\u684C\u5BA0\u9700\u8981\u684C\u9762\u663E\u793A\u73AF\u5883\u3002', false);\n let executable: string;\n if (options.electronPath !== undefined) executable = options.electronPath;\n else {\n const preparing = new AbortController(); this.preparing = preparing;\n const abort = () => preparing.abort();\n lifetime?.signal.addEventListener('abort', abort, { once: true });\n if (lifetime?.signal.aborted) abort();\n try {\n this.preparation = electronExecutable(preparing.signal);\n executable = await this.preparation;\n if (preparing.signal.aborted || this.closing) throw new Error('\u684C\u5BA0\u542F\u52A8\u5DF2\u53D6\u6D88');\n } catch (error) { throw error instanceof NativeStartError ? error : new NativeStartError(String(error).slice(0, 600), false); }\n finally { lifetime?.signal.removeEventListener('abort', abort); this.preparing = undefined; this.preparation = undefined; }\n }\n const env: NodeJS.ProcessEnv = { ...process.env, DSH_PET_GENERATION: String(this.generation), DSH_PET_VISIBLE: lifetime?.visible === false ? '0' : '1', DSH_PET_SCREEN_LOCKED: this.screenLocked ? '1' : '0', DSH_PET_SYSTEM_ASLEEP: this.systemAsleep ? '1' : '0' };\n delete (env as NodeJS.ProcessEnv).ELECTRON_RUN_AS_NODE;\n const args = [fileURLToPath(new URL('../desktop/main.cjs', import.meta.url))];\n if (env.DSH_PET_TEST_NO_SANDBOX === '1') args.unshift('--no-sandbox');\n const child = spawn(executable, args, { env, stdio: ['ignore', 'pipe', 'pipe', 'ipc'] });\n const generation = this.generation; this.child = child;\n let diagnostic = '', userClosed = false;\n child.stderr?.on('data', data => { diagnostic = (diagnostic + data.toString()).slice(-4000); });\n child.on('message', message => {\n if (this.child !== child || this.closing || lifetime?.signal.aborted || !isRecord(message)) return;\n if (message.type === 'closed') userClosed = true;\n if (message.type === 'action') this.emit('action', message.action);\n if (message.type === 'tray-state') this.emit('tray-state', message.state);\n if (message.type === 'tray-icon') this.emit('tray-icon', message);\n if (message.type === 'visibility' && message.generation === generation && typeof message.visible === 'boolean' && Number.isSafeInteger(message.visibilityRevision) && (message.visibilityRevision as number) > this.visibilityRevision) {\n this.visibilityRevision = message.visibilityRevision as number;\n this.nativeVisible = message.visible; this.suspended = message.suspended === true;\n if (typeof message.screenLocked === 'boolean') this.screenLocked = message.screenLocked;\n if (typeof message.systemAsleep === 'boolean') this.systemAsleep = message.systemAsleep;\n this.emit('lifecycle', { running: true, visible: this.nativeVisible, generation, visibilityRevision: this.visibilityRevision, suspended: this.suspended, ...(typeof message.desiredVisible === 'boolean' ? { desiredVisible: message.desiredVisible } : {}) });\n }\n });\n child.once('exit', (code, signal) => {\n if (this.child !== child) return;\n this.child = undefined; this.nativeVisible = false;\n const unexpected = !this.closing && !userClosed && !lifetime?.signal.aborted;\n const error = unexpected ? `\u684C\u5BA0\u8FDB\u7A0B\u5DF2\u9000\u51FA (${signal ?? code}): ${diagnostic}`.slice(0, 600) : undefined;\n this.emit('lifecycle', { running: false, visible: false, generation, visibilityRevision: ++this.visibilityRevision, suspended: false, unexpected, ...(error ? { error } : {}) });\n if (error) this.emit('failure', new Error(error));\n });\n child.on('error', error => { if (this.child === child && !this.closing && !lifetime?.signal.aborted) this.emit('failure', error); });\n await new Promise<void>((resolve, reject) => {\n let done = false;\n const finish = (error?: Error) => {\n if (done) return; done = true;\n clearTimeout(timer); child.off('message', ready); child.off('error', failed); child.off('exit', exited); lifetime?.signal.removeEventListener('abort', aborted);\n if (error) { child.kill(); reject(error); } else resolve();\n };\n const ready = (message: unknown) => {\n if (isRecord(message) && message.type === 'startup-error' && this.child === child && typeof message.error === 'string') {\n finish(new NativeStartError(message.error.slice(0, 600), message.recoverable === true)); return;\n }\n if (isRecord(message) && message.type === 'ready' && this.child === child && !lifetime?.signal.aborted) {\n this.resultKey = undefined;\n this.send({ type: 'init', options: { ...this.latestOptions, locale: this.latestOptions?.locale ?? null }, baseline: true, snapshot: this.latest && desktopSnapshot(this.latest, true) });\n if (this.lastNotificationState) this.notificationState(this.lastNotificationState);\n finish();\n }\n };\n const failed = (error: NodeJS.ErrnoException) => finish(new NativeStartError(error.message.slice(0, 600), error.code === 'EAGAIN' || error.code === 'ENOMEM'));\n const exited = (code: number | null, signal: string | null) => finish(new NativeStartError(`\u684C\u5BA0\u542F\u52A8\u5931\u8D25 (${signal ?? code}): ${diagnostic}`.slice(0, 600), true));\n const aborted = () => finish(new Error('\u684C\u5BA0\u542F\u52A8\u5DF2\u53D6\u6D88'));\n const timer = setTimeout(() => finish(new NativeStartError(`\u684C\u5BA0\u672A\u80FD\u5728 20 \u79D2\u5185\u542F\u52A8: ${diagnostic}`.slice(0, 600), true)), 20000);\n child.on('message', ready); child.once('error', failed); child.once('exit', exited);\n lifetime?.signal.addEventListener('abort', aborted, { once: true });\n if (lifetime?.signal.aborted) aborted();\n });\n }\n\n update(snapshot: PetSnapshot): void {\n this.latest = snapshot;\n const key = snapshot.results.map(result => `${result.id}:${result.read}`).join('|');\n this.send({ type: 'snapshot', snapshot: desktopSnapshot(snapshot, key !== this.resultKey) });\n this.resultKey = key;\n }\n notify(notice: PetNotice | TaskNotice, runtime?: NotificationRuntime): boolean {\n if (!this.child?.connected || this.closing) return false;\n if (runtime && (!this.nativeVisible || this.suspended || runtime.generation !== this.generation || runtime.visibilityRevision !== this.visibilityRevision || !runtime.visible)) return false;\n return this.send({ type: 'notice', notice, ...(runtime ? { generation: runtime.generation, visibilityRevision: runtime.visibilityRevision } : {}) });\n }\n notificationState(snapshot: NotificationSnapshot): void { this.lastNotificationState = structuredClone(snapshot); this.send({ type: 'notification-state', snapshot }); }\n snoozeResult(interactionId: string, ok: boolean, error?: string): void { this.send({ type: 'notification-snooze-result', interactionId, ok, ...(error ? { error: error.slice(0, 600) } : {}) }); }\n presentRole(notice: TaskNotice, runtime: NotificationRuntime): boolean { return this.notify(notice, runtime); }\n chatResult(receipt: ChatReceipt): void { this.send(receipt); }\n onAction(listener: (action: unknown) => void): void { this.on('action', listener); }\n removeAction(listener: (action: unknown) => void): void { this.off('action', listener); }\n // JSON IPC omits undefined. An explicit null lets a cleared Harness\n // preference restore the renderer's automatic language instead of retaining\n // its previous locale during a merged configuration update.\n configure(options: DesktopOptions): void { this.latestOptions = { ...options }; this.send({ type: 'configure', options: { ...options, locale: options.locale ?? null } }); }\n control(command: 'show' | 'hide' | 'characters'): void { this.send({ type: 'control', command }); }\n focusHarness(): void { this.send({ type: 'control', command: 'focus-harness' }); }\n onLifecycle(listener: (state: NativeLifecycle) => void): void { this.on('lifecycle', listener); }\n removeLifecycle(listener: (state: NativeLifecycle) => void): void { this.off('lifecycle', listener); }\n private send(message: object): boolean {\n const child = this.child;\n if (!child?.connected || this.closing) return false;\n try {\n // A false Node return can mean backpressure after enqueueing. Reporting\n // rejection here would let callers send the same accepted notice again.\n child.send(message, error => { if (error && this.child === child && !this.closing) this.emit('failure', error); });\n return true;\n } catch { return false; }\n }\n\n async dispose(): Promise<void> {\n this.closing = true;\n this.preparing?.abort();\n await this.preparation?.catch(() => undefined);\n const child = this.child;\n if (!child) return;\n if (child.pid === undefined || child.exitCode !== null || child.signalCode !== null) { if (this.child === child) this.child = undefined; return; }\n await new Promise<void>((resolve, reject) => {\n let deadline: ReturnType<typeof setTimeout>;\n const timer = setTimeout(() => { child.kill('SIGKILL'); deadline = setTimeout(() => { if (child.exitCode !== null || child.signalCode !== null) resolve(); else reject(new Error('\u684C\u5BA0\u8FDB\u7A0B\u672A\u786E\u8BA4\u9000\u51FA')); }, 1000); }, 3000);\n child.once('exit', () => { clearTimeout(timer); clearTimeout(deadline); resolve(); });\n if (child.connected) child.send({ type: 'quit' }, error => { if (error) child.kill(); }); else child.kill();\n });\n if (this.child === child) this.child = undefined;\n }\n}\n\nexport function isRecord(value: unknown): value is Record<string, unknown> { return typeof value === 'object' && value !== null && !Array.isArray(value); }\n\n/** Stream animation updates carry metadata; full result text crosses IPC only when it changes. */\nfunction desktopSnapshot(snapshot: PetSnapshot, includeResults: boolean) {\n const { results, ...state } = snapshot;\n return { ...state, text: state.mood === 'happy' ? '' : state.text,\n sessions: state.sessions.map(session => ({ ...session, text: session.mood === 'happy' ? '' : session.text, reply: '' })),\n ...(includeResults ? { results } : {}),\n };\n}\n", "/** Shared Host/native lifetime contract. Only explicitly recoverable failures retry. */\nexport interface StartLifetime { signal: AbortSignal; generation: number; visible?: boolean; }\nexport interface NativeLifecycle {\n running: boolean; visible: boolean; error?: string;\n generation?: number; visibilityRevision?: number; suspended?: boolean;\n desiredVisible?: boolean; unexpected?: boolean;\n}\nexport class NativeStartError extends Error {\n constructor(message: string, readonly recoverable: boolean) { super(message); this.name = 'NativeStartError'; }\n}\n", "import { spawn } from 'node:child_process';\nimport { access, readFile } from 'node:fs/promises';\nimport { createRequire } from 'node:module';\nimport { dirname, join } from 'node:path';\nimport { NativeStartError } from './desktop-lifecycle.ts';\n\n// Electron 44's index.js may spawnSync its installer. Resolve files without\n// executing that entrypoint, then prepare missing binaries off the Host loop.\nexport async function electronExecutable(signal: AbortSignal): Promise<string> {\n const directory = dirname(createRequire(import.meta.url).resolve('electron'));\n async function installed(): Promise<string | undefined> {\n let relative: string;\n try { relative = await readFile(join(directory, 'path.txt'), 'utf8'); }\n catch (error) { if ((error as NodeJS.ErrnoException).code !== 'ENOENT') throw error; relative = ''; }\n if (process.env.ELECTRON_OVERRIDE_DIST_PATH) return join(process.env.ELECTRON_OVERRIDE_DIST_PATH, relative || 'electron');\n if (!relative) return;\n const executable = join(directory, 'dist', relative);\n try { await access(executable); return executable; }\n catch (error) { if ((error as NodeJS.ErrnoException).code !== 'ENOENT') throw error; }\n }\n if (signal.aborted) throw new Error('\u684C\u5BA0\u542F\u52A8\u5DF2\u53D6\u6D88');\n const existing = await installed();\n if (existing) return existing;\n await new Promise<void>((resolve, reject) => {\n if (signal.aborted) { reject(new Error('\u684C\u5BA0\u542F\u52A8\u5DF2\u53D6\u6D88')); return; }\n const child = spawn(process.execPath, [join(directory, 'install.js')], {\n env: { ...process.env, ELECTRON_RUN_AS_NODE: '1' }, stdio: 'ignore', windowsHide: true,\n });\n let failure: Error | undefined, killTimer: ReturnType<typeof setTimeout> | undefined;\n const stop = (error: Error) => {\n if (failure) return;\n failure = error; child.kill();\n killTimer = setTimeout(() => child.kill('SIGKILL'), 1000);\n };\n const aborted = () => stop(new Error('\u684C\u5BA0\u542F\u52A8\u5DF2\u53D6\u6D88'));\n const timer = setTimeout(() => stop(new NativeStartError('Electron \u8FD0\u884C\u65F6\u51C6\u5907\u8D85\u65F6\uFF0C\u8BF7\u68C0\u67E5\u7F51\u7EDC\u6216\u6309\u4F7F\u7528\u6307\u5357\u9884\u5148\u5B89\u88C5\u8FD0\u884C\u65F6\u3002', false)), 240_000);\n signal.addEventListener('abort', aborted, { once: true });\n const finish = (error?: Error) => {\n clearTimeout(timer); clearTimeout(killTimer); signal.removeEventListener('abort', aborted);\n if (failure || error) reject(failure ?? error); else resolve();\n };\n child.once('error', error => finish(new NativeStartError(error.message.slice(0, 600), false)));\n child.once('exit', code => finish(code === 0 ? undefined : new NativeStartError(`Electron \u8FD0\u884C\u65F6\u51C6\u5907\u5931\u8D25 (${code})\uFF0C\u8BF7\u68C0\u67E5\u7F51\u7EDC\u6216\u6309\u4F7F\u7528\u6307\u5357\u9884\u5148\u5B89\u88C5\u8FD0\u884C\u65F6\u3002`, false)));\n if (signal.aborted) aborted();\n });\n if (signal.aborted) throw new Error('\u684C\u5BA0\u542F\u52A8\u5DF2\u53D6\u6D88');\n const executable = await installed();\n if (!executable) throw new NativeStartError('Electron \u5B89\u88C5\u672A\u751F\u6210\u53EF\u7528\u8FD0\u884C\u65F6\uFF0C\u8BF7\u6309\u4F7F\u7528\u6307\u5357\u91CD\u65B0\u51C6\u5907\u3002', false);\n return executable;\n}\n"],
|
|
5
|
-
"mappings": ";AAAA,SAAS,SAAAA,cAAgC;AACzC,SAAS,qBAAqB;AAC9B,SAAS,oBAAoB;;;ACKtB,IAAM,mBAAN,cAA+B,MAAM;AAAA,EAC1C,YAAY,SAA0B,aAAsB;AAAE,UAAM,OAAO;AAArC;AAAwC,SAAK,OAAO;AAAA,EAAoB;AAChH;;;
|
|
4
|
+
"sourcesContent": ["import { spawn, type ChildProcess } from 'node:child_process';\nimport { fileURLToPath } from 'node:url';\nimport { EventEmitter } from 'node:events';\nimport type { ChatReceipt } from '../web/chat-contract.js';\nimport type { PetSnapshot, PetNotice } from './model.ts';\nimport type { NotificationRuntime, NotificationSnapshot, TaskNotice } from './notification-contract.ts';\nimport { NativeStartError, type StartLifetime, type NativeLifecycle } from './desktop-lifecycle.ts';\nimport { electronExecutable } from './electron-runtime.ts';\nexport { NativeStartError, type StartLifetime, type NativeLifecycle } from './desktop-lifecycle.ts';\n\nimport type { CompanionshipMode } from '../web/companionship.js';\nimport type { TextScale } from '../web/text-scale.js';\n\nexport interface DesktopOptions { size: number; npcHome?: number; npcRange?: number; textScale?: TextScale; roam: boolean; diagnostics?: boolean; companionship?: CompanionshipMode; notifications: boolean; bubbleDurationMs: number; electronPath?: string; locale?: string; systemNotifications?: boolean; reminders?: boolean; reminderDelayMs?: number; }\nexport interface PetBridge {\n start(options: DesktopOptions, lifetime?: StartLifetime): Promise<void>;\n update(snapshot: PetSnapshot): void;\n chatResult?(receipt: ChatReceipt): void;\n notify(notice: PetNotice | TaskNotice, runtime?: NotificationRuntime): boolean;\n notificationState?(snapshot: NotificationSnapshot): void;\n snoozeResult?(interactionId: string, ok: boolean, error?: string): void;\n presentRole?(notice: TaskNotice, runtime: NotificationRuntime): boolean;\n onAction(listener: (action: unknown) => void): void;\n removeAction(listener: (action: unknown) => void): void;\n dispose(): Promise<void>;\n configure?(options: DesktopOptions): void;\n control?(command: 'show' | 'hide' | 'characters'): void;\n focusHarness?(): void;\n onLifecycle?(listener: (state: NativeLifecycle) => void): void;\n removeLifecycle?(listener: (state: NativeLifecycle) => void): void;\n}\n\n/** Owns a separate Electron window; no changes or private IPC in the Harness desktop shell are needed. */\nexport class ElectronBridge extends EventEmitter implements PetBridge {\n private child?: ChildProcess;\n private latest?: PetSnapshot;\n private latestOptions?: DesktopOptions;\n private resultKey?: string;\n private closing = false;\n private preparing?: AbortController;\n private preparation?: Promise<string>;\n\n private generation = 0;\n private visibilityRevision = 0;\n private nativeVisible = false;\n private suspended = false;\n private screenLocked = false;\n private systemAsleep = false;\n private lastNotificationState?: NotificationSnapshot;\n\n async start(options: DesktopOptions, lifetime?: StartLifetime): Promise<void> {\n if (this.child || this.preparing) throw new NativeStartError('Desktop pet is already running or starting', false);\n if (lifetime?.signal.aborted) throw new Error('\u684C\u5BA0\u542F\u52A8\u5DF2\u53D6\u6D88');\n this.latestOptions = { ...options };\n this.closing = false;\n this.generation = lifetime?.generation ?? this.generation + 1;\n this.visibilityRevision = 0; this.nativeVisible = false;\n if (process.platform === 'linux' && !process.env.DISPLAY && !process.env.WAYLAND_DISPLAY) throw new NativeStartError('\u684C\u5BA0\u9700\u8981\u684C\u9762\u663E\u793A\u73AF\u5883\u3002', false);\n let executable: string;\n if (options.electronPath !== undefined) executable = options.electronPath;\n else {\n const preparing = new AbortController(); this.preparing = preparing;\n const abort = () => preparing.abort();\n lifetime?.signal.addEventListener('abort', abort, { once: true });\n if (lifetime?.signal.aborted) abort();\n try {\n this.preparation = electronExecutable(preparing.signal);\n executable = await this.preparation;\n if (preparing.signal.aborted || this.closing) throw new Error('\u684C\u5BA0\u542F\u52A8\u5DF2\u53D6\u6D88');\n } catch (error) { throw error instanceof NativeStartError ? error : new NativeStartError(String(error).slice(0, 600), false); }\n finally { lifetime?.signal.removeEventListener('abort', abort); this.preparing = undefined; this.preparation = undefined; }\n }\n const env: NodeJS.ProcessEnv = { ...process.env, DSH_PET_GENERATION: String(this.generation), DSH_PET_VISIBLE: lifetime?.visible === false ? '0' : '1', DSH_PET_SCREEN_LOCKED: this.screenLocked ? '1' : '0', DSH_PET_SYSTEM_ASLEEP: this.systemAsleep ? '1' : '0' };\n delete (env as NodeJS.ProcessEnv).ELECTRON_RUN_AS_NODE;\n const args = [fileURLToPath(new URL('../desktop/main.cjs', import.meta.url))];\n if (env.DSH_PET_TEST_NO_SANDBOX === '1') args.unshift('--no-sandbox');\n const child = spawn(executable, args, { env, stdio: ['ignore', 'pipe', 'pipe', 'ipc'] });\n const generation = this.generation; this.child = child;\n let diagnostic = '', userClosed = false;\n child.stderr?.on('data', data => { diagnostic = (diagnostic + data.toString()).slice(-4000); });\n child.on('message', message => {\n if (this.child !== child || this.closing || lifetime?.signal.aborted || !isRecord(message)) return;\n if (message.type === 'closed') userClosed = true;\n if (message.type === 'action') this.emit('action', message.action);\n if (message.type === 'tray-state') this.emit('tray-state', message.state);\n if (message.type === 'tray-icon') this.emit('tray-icon', message);\n if (message.type === 'visibility' && message.generation === generation && typeof message.visible === 'boolean' && Number.isSafeInteger(message.visibilityRevision) && (message.visibilityRevision as number) > this.visibilityRevision) {\n this.visibilityRevision = message.visibilityRevision as number;\n this.nativeVisible = message.visible; this.suspended = message.suspended === true;\n if (typeof message.screenLocked === 'boolean') this.screenLocked = message.screenLocked;\n if (typeof message.systemAsleep === 'boolean') this.systemAsleep = message.systemAsleep;\n this.emit('lifecycle', { running: true, visible: this.nativeVisible, generation, visibilityRevision: this.visibilityRevision, suspended: this.suspended, ...(typeof message.desiredVisible === 'boolean' ? { desiredVisible: message.desiredVisible } : {}) });\n }\n });\n child.once('exit', (code, signal) => {\n if (this.child !== child) return;\n this.child = undefined; this.nativeVisible = false;\n const unexpected = !this.closing && !userClosed && !lifetime?.signal.aborted;\n const error = unexpected ? `\u684C\u5BA0\u8FDB\u7A0B\u5DF2\u9000\u51FA (${signal ?? code}): ${diagnostic}`.slice(0, 600) : undefined;\n this.emit('lifecycle', { running: false, visible: false, generation, visibilityRevision: ++this.visibilityRevision, suspended: false, unexpected, ...(error ? { error } : {}) });\n if (error) this.emit('failure', new Error(error));\n });\n child.on('error', error => { if (this.child === child && !this.closing && !lifetime?.signal.aborted) this.emit('failure', error); });\n await new Promise<void>((resolve, reject) => {\n let done = false;\n const finish = (error?: Error) => {\n if (done) return; done = true;\n clearTimeout(timer); child.off('message', ready); child.off('error', failed); child.off('exit', exited); lifetime?.signal.removeEventListener('abort', aborted);\n if (error) { child.kill(); reject(error); } else resolve();\n };\n const ready = (message: unknown) => {\n if (isRecord(message) && message.type === 'startup-error' && this.child === child && typeof message.error === 'string') {\n finish(new NativeStartError(message.error.slice(0, 600), message.recoverable === true)); return;\n }\n if (isRecord(message) && message.type === 'ready' && this.child === child && !lifetime?.signal.aborted) {\n this.resultKey = undefined;\n this.send({ type: 'init', options: { ...this.latestOptions, locale: this.latestOptions?.locale ?? null }, baseline: true, snapshot: this.latest && desktopSnapshot(this.latest, true) });\n if (this.lastNotificationState) this.notificationState(this.lastNotificationState);\n finish();\n }\n };\n const failed = (error: NodeJS.ErrnoException) => finish(new NativeStartError(error.message.slice(0, 600), error.code === 'EAGAIN' || error.code === 'ENOMEM'));\n const exited = (code: number | null, signal: string | null) => finish(new NativeStartError(`\u684C\u5BA0\u542F\u52A8\u5931\u8D25 (${signal ?? code}): ${diagnostic}`.slice(0, 600), true));\n const aborted = () => finish(new Error('\u684C\u5BA0\u542F\u52A8\u5DF2\u53D6\u6D88'));\n const timer = setTimeout(() => finish(new NativeStartError(`\u684C\u5BA0\u672A\u80FD\u5728 20 \u79D2\u5185\u542F\u52A8: ${diagnostic}`.slice(0, 600), true)), 20000);\n child.on('message', ready); child.once('error', failed); child.once('exit', exited);\n lifetime?.signal.addEventListener('abort', aborted, { once: true });\n if (lifetime?.signal.aborted) aborted();\n });\n }\n\n update(snapshot: PetSnapshot): void {\n this.latest = snapshot;\n const key = snapshot.results.map(result => `${result.id}:${result.read}`).join('|');\n this.send({ type: 'snapshot', snapshot: desktopSnapshot(snapshot, key !== this.resultKey) });\n this.resultKey = key;\n }\n notify(notice: PetNotice | TaskNotice, runtime?: NotificationRuntime): boolean {\n if (!this.child?.connected || this.closing) return false;\n if (runtime && (!this.nativeVisible || this.suspended || runtime.generation !== this.generation || runtime.visibilityRevision !== this.visibilityRevision || !runtime.visible)) return false;\n return this.send({ type: 'notice', notice, ...(runtime ? { generation: runtime.generation, visibilityRevision: runtime.visibilityRevision } : {}) });\n }\n notificationState(snapshot: NotificationSnapshot): void { this.lastNotificationState = structuredClone(snapshot); this.send({ type: 'notification-state', snapshot }); }\n snoozeResult(interactionId: string, ok: boolean, error?: string): void { this.send({ type: 'notification-snooze-result', interactionId, ok, ...(error ? { error: error.slice(0, 600) } : {}) }); }\n presentRole(notice: TaskNotice, runtime: NotificationRuntime): boolean { return this.notify(notice, runtime); }\n chatResult(receipt: ChatReceipt): void { this.send(receipt); }\n onAction(listener: (action: unknown) => void): void { this.on('action', listener); }\n removeAction(listener: (action: unknown) => void): void { this.off('action', listener); }\n // JSON IPC omits undefined. An explicit null lets a cleared Harness\n // preference restore the renderer's automatic language instead of retaining\n // its previous locale during a merged configuration update.\n configure(options: DesktopOptions): void { this.latestOptions = { ...options }; this.send({ type: 'configure', options: { ...options, locale: options.locale ?? null } }); }\n control(command: 'show' | 'hide' | 'characters'): void { this.send({ type: 'control', command }); }\n focusHarness(): void { this.send({ type: 'control', command: 'focus-harness' }); }\n onLifecycle(listener: (state: NativeLifecycle) => void): void { this.on('lifecycle', listener); }\n removeLifecycle(listener: (state: NativeLifecycle) => void): void { this.off('lifecycle', listener); }\n private send(message: object): boolean {\n const child = this.child;\n if (!child?.connected || this.closing) return false;\n try {\n // A false Node return can mean backpressure after enqueueing. Reporting\n // rejection here would let callers send the same accepted notice again.\n child.send(message, error => { if (error && this.child === child && !this.closing) this.emit('failure', error); });\n return true;\n } catch { return false; }\n }\n\n async dispose(): Promise<void> {\n this.closing = true;\n this.preparing?.abort();\n await this.preparation?.catch(() => undefined);\n const child = this.child;\n if (!child) return;\n if (child.pid === undefined || child.exitCode !== null || child.signalCode !== null) { if (this.child === child) this.child = undefined; return; }\n await new Promise<void>((resolve, reject) => {\n let deadline: ReturnType<typeof setTimeout>;\n const timer = setTimeout(() => { child.kill('SIGKILL'); deadline = setTimeout(() => { if (child.exitCode !== null || child.signalCode !== null) resolve(); else reject(new Error('\u684C\u5BA0\u8FDB\u7A0B\u672A\u786E\u8BA4\u9000\u51FA')); }, 1000); }, 3000);\n child.once('exit', () => { clearTimeout(timer); clearTimeout(deadline); resolve(); });\n if (child.connected) child.send({ type: 'quit' }, error => { if (error) child.kill(); }); else child.kill();\n });\n if (this.child === child) this.child = undefined;\n }\n}\n\nexport function isRecord(value: unknown): value is Record<string, unknown> { return typeof value === 'object' && value !== null && !Array.isArray(value); }\n\n/** Stream animation updates carry metadata; full result text crosses IPC only when it changes. */\nfunction desktopSnapshot(snapshot: PetSnapshot, includeResults: boolean) {\n const { results, ...state } = snapshot;\n return { ...state, text: state.mood === 'happy' ? '' : state.text,\n sessions: state.sessions.map(session => ({ ...session, text: session.mood === 'happy' ? '' : session.text, reply: '' })),\n ...(includeResults ? { results } : {}),\n };\n}\n", "/** Shared Host/native lifetime contract. Only explicitly recoverable failures retry. */\nexport interface StartLifetime { signal: AbortSignal; generation: number; visible?: boolean; }\nexport interface NativeLifecycle {\n running: boolean; visible: boolean; error?: string;\n generation?: number; visibilityRevision?: number; suspended?: boolean;\n desiredVisible?: boolean; unexpected?: boolean;\n}\nexport class NativeStartError extends Error {\n constructor(message: string, readonly recoverable: boolean) { super(message); this.name = 'NativeStartError'; }\n}\n\nexport type RuntimeFailure = { reason: 'http'; httpStatus: number } | { reason: 'network' | 'timeout' | 'unavailable' | 'install' };\nexport class RuntimePreparationError extends NativeStartError {\n constructor(readonly failure: RuntimeFailure, detail?: string) {\n const cause = failure.reason === 'http' ? `download rejected (HTTP ${failure.httpStatus})` : {\n network: 'download connection failed', timeout: 'download or installation timed out (240 seconds)',\n unavailable: 'installer or executable unavailable', install: 'installation failed',\n }[failure.reason];\n super(`Electron runtime is missing: ${cause}${detail ? ` (${detail})` : ''}. Prepare Electron or configure electronPath, then start the pet again.`, false);\n }\n}\n", "import { spawn } from 'node:child_process';\nimport { access, readFile } from 'node:fs/promises';\nimport { createRequire } from 'node:module';\nimport { dirname, join } from 'node:path';\nimport { RuntimePreparationError } from './desktop-lifecycle.ts';\n\nfunction installerFailure(stderr: string, code: number | null): RuntimePreparationError {\n // Electron prints the error before its stack. Only extract allowlisted\n // diagnostics: URLs can contain credentials and stacks expose local paths.\n const summary = stderr.split(/\\r?\\n/, 1)[0] ?? '';\n const status = /^HTTPError: Response code ([45]\\d\\d)\\b/.exec(summary);\n if (status) return new RuntimePreparationError({ reason: 'http', httpStatus: Number(status[1]) });\n if (/\\b(?:ENOTFOUND|EAI_AGAIN|ECONNREFUSED|ECONNRESET|ENETUNREACH|ETIMEDOUT)\\b|^TypeError: fetch failed\\b/.test(summary)) {\n return new RuntimePreparationError({ reason: 'network' });\n }\n return new RuntimePreparationError({ reason: 'install' }, code === null ? undefined : String(code));\n}\n\n// Electron 44's index.js may spawnSync its installer. Resolve files without\n// executing that entrypoint, then prepare missing binaries off the Host loop.\nexport async function electronExecutable(signal: AbortSignal): Promise<string> {\n let directory: string;\n try { directory = dirname(createRequire(import.meta.url).resolve('electron')); }\n catch { throw new RuntimePreparationError({ reason: 'unavailable' }); }\n async function installed(): Promise<string | undefined> {\n let relative: string;\n try { relative = await readFile(join(directory, 'path.txt'), 'utf8'); }\n catch (error) { if ((error as NodeJS.ErrnoException).code !== 'ENOENT') throw error; relative = ''; }\n if (process.env.ELECTRON_OVERRIDE_DIST_PATH) return join(process.env.ELECTRON_OVERRIDE_DIST_PATH, relative || 'electron');\n if (!relative) return;\n const executable = join(directory, 'dist', relative);\n try { await access(executable); return executable; }\n catch (error) { if ((error as NodeJS.ErrnoException).code !== 'ENOENT') throw error; }\n }\n if (signal.aborted) throw new Error('\u684C\u5BA0\u542F\u52A8\u5DF2\u53D6\u6D88');\n const existing = await installed();\n if (existing) return existing;\n await new Promise<void>((resolve, reject) => {\n if (signal.aborted) { reject(new Error('\u684C\u5BA0\u542F\u52A8\u5DF2\u53D6\u6D88')); return; }\n const child = spawn(process.execPath, [join(directory, 'install.js')], {\n env: { ...process.env, ELECTRON_RUN_AS_NODE: '1' }, stdio: ['ignore', 'ignore', 'pipe'], windowsHide: true,\n });\n let stderr = '';\n child.stderr.on('data', (data: Buffer) => {\n if (stderr.length < 512) stderr += data.subarray(0, 512 - stderr.length).toString();\n });\n let failure: Error | undefined, killTimer: ReturnType<typeof setTimeout> | undefined;\n const stop = (error: Error) => {\n if (failure) return;\n failure = error; child.kill();\n killTimer = setTimeout(() => child.kill('SIGKILL'), 1000);\n };\n const aborted = () => stop(new Error('\u684C\u5BA0\u542F\u52A8\u5DF2\u53D6\u6D88'));\n const timer = setTimeout(() => stop(new RuntimePreparationError({ reason: 'timeout' })), 240_000);\n signal.addEventListener('abort', aborted, { once: true });\n const finish = (error?: Error) => {\n clearTimeout(timer); clearTimeout(killTimer); signal.removeEventListener('abort', aborted);\n if (failure || error) reject(failure ?? error); else resolve();\n };\n child.once('error', () => { failure ??= new RuntimePreparationError({ reason: 'unavailable' }); });\n child.once('close', code => finish(code === 0 ? undefined : installerFailure(stderr, code)));\n if (signal.aborted) aborted();\n });\n if (signal.aborted) throw new Error('\u684C\u5BA0\u542F\u52A8\u5DF2\u53D6\u6D88');\n const executable = await installed();\n if (!executable) throw new RuntimePreparationError({ reason: 'unavailable' });\n return executable;\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,SAAAA,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Aa,QAAQ;AAAG,gBAAQ;AAAA,MAAG,CAAC;AACpF,UAAI,MAAM,UAAW,OAAM,KAAK,EAAE,MAAM,OAAO,GAAG,WAAS;AAAE,YAAI,MAAO,OAAM,KAAK;AAAA,MAAG,CAAC;AAAA,UAAQ,OAAM,KAAK;AAAA,IAC5G,CAAC;AACD,QAAI,KAAK,UAAU,MAAO,MAAK,QAAQ;AAAA,EACzC;AACF;AAEO,SAAS,SAAS,OAAkD;AAAE,SAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAAG;AAG1J,SAAS,gBAAgB,UAAuB,gBAAyB;AACvE,QAAM,EAAE,SAAS,GAAG,MAAM,IAAI;AAC9B,SAAO;AAAA,IAAE,GAAG;AAAA,IAAO,MAAM,MAAM,SAAS,UAAU,KAAK,MAAM;AAAA,IAC3D,UAAU,MAAM,SAAS,IAAI,cAAY,EAAE,GAAG,SAAS,MAAM,QAAQ,SAAS,UAAU,KAAK,QAAQ,MAAM,OAAO,GAAG,EAAE;AAAA,IACvH,GAAI,iBAAiB,EAAE,QAAQ,IAAI,CAAC;AAAA,EACtC;AACF;",
|
|
6
6
|
"names": ["spawn", "executable", "spawn"]
|
|
7
7
|
}
|
package/dist/build-info.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schema": 1,
|
|
3
|
-
"commit": "
|
|
3
|
+
"commit": "5febec8cfe35b4b106ab1587157b2f2574136564",
|
|
4
4
|
"dirty": false,
|
|
5
|
-
"productDigest": "
|
|
5
|
+
"productDigest": "6ef92acb336ae800e3b8bac97f646df81dc832013d5238fd54fe9904f6d193ae"
|
|
6
6
|
}
|
package/dist/client.js
CHANGED
|
@@ -173,6 +173,13 @@ function Settings({ form, call, local, notifier, t }) {
|
|
|
173
173
|
const running = status?.phase === "running";
|
|
174
174
|
const disabled = !local || busy || status?.phase === "starting" || status?.phase === "stopping";
|
|
175
175
|
const statusText = !status ? t("loading") : status.phase === "running" ? t(status.visible ? "running" : "hidden") : t(status.phase);
|
|
176
|
+
const runtimeFailure = status?.runtimeFailure;
|
|
177
|
+
const runtimeReason = runtimeFailure && (runtimeFailure.reason === "http" ? `${t("runtimeHttp")} (HTTP ${runtimeFailure.httpStatus})` : t({
|
|
178
|
+
network: "runtimeNetwork",
|
|
179
|
+
timeout: "runtimeTimeout",
|
|
180
|
+
unavailable: "runtimeUnavailable",
|
|
181
|
+
install: "runtimeInstall"
|
|
182
|
+
}[runtimeFailure.reason]));
|
|
176
183
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsh-coopanion-settings", "data-testid": "coopanion-settings", children: [
|
|
177
184
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", { children: t("title") }),
|
|
178
185
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { children: [
|
|
@@ -201,7 +208,13 @@ function Settings({ form, call, local, notifier, t }) {
|
|
|
201
208
|
status.recoveryAttempt,
|
|
202
209
|
" / 3"
|
|
203
210
|
] }) : null,
|
|
204
|
-
|
|
211
|
+
runtimeReason ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { className: "pet-error", role: "alert", "data-testid": "pet-runtime-failure", children: [
|
|
212
|
+
t("runtimeMissing"),
|
|
213
|
+
runtimeReason,
|
|
214
|
+
t("runtimeRetry"),
|
|
215
|
+
" ",
|
|
216
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", { href: "https://github.com/takboo/dsh-coopanion/blob/main/docs/usage.md#electron-\u8FD0\u884C\u65F6\u51C6\u5907", target: "_blank", rel: "noreferrer", children: t("runtimeGuide") })
|
|
217
|
+
] }) : failure2 || status?.error ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "pet-error", role: "alert", children: failure2 || status?.error }) : null
|
|
205
218
|
] }),
|
|
206
219
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", { className: "pet-card", "aria-label": t("preferences"), children: [
|
|
207
220
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", { children: t("preferences") }),
|
|
@@ -313,6 +326,14 @@ var zh = {
|
|
|
313
326
|
recovering: "\u7B49\u5F85\u81EA\u52A8\u6062\u590D\u2026",
|
|
314
327
|
recoveryHint: "\u81EA\u52A8\u6062\u590D\u6B21\u6570\uFF08\u6700\u591A 3 \u6B21\uFF09",
|
|
315
328
|
runtimeHint: "\u610F\u5916\u9000\u51FA\u4F1A\u6709\u9650\u91CD\u8BD5\uFF0C\u5931\u8D25\u540E\u53EF\u624B\u52A8\u91CD\u542F\u3002\u9690\u85CF\u65F6\u6309\u7CFB\u7EDF\u901A\u77E5\u5F00\u5173\u63A5\u6536\u63D0\u9192\uFF1B\u8FDB\u7A0B\u9000\u51FA\u4F1A\u4E22\u5931\u7A97\u53E3\u5185\u8349\u7A3F\u3002",
|
|
329
|
+
runtimeMissing: "\u7F3A\u5C11 Electron \u8FD0\u884C\u65F6\uFF1A",
|
|
330
|
+
runtimeHttp: "\u4E0B\u8F7D\u88AB\u62D2\u7EDD",
|
|
331
|
+
runtimeNetwork: "\u4E0B\u8F7D\u8FDE\u63A5\u5931\u8D25",
|
|
332
|
+
runtimeTimeout: "\u4E0B\u8F7D\u6216\u5B89\u88C5\u8D85\u8FC7\u56DB\u5206\u949F",
|
|
333
|
+
runtimeUnavailable: "\u627E\u4E0D\u5230\u53EF\u7528\u7684\u5B89\u88C5\u5668\u6216\u8FD0\u884C\u65F6",
|
|
334
|
+
runtimeInstall: "\u5B89\u88C5\u5931\u8D25",
|
|
335
|
+
runtimeRetry: "\u3002\u68C0\u67E5\u7F51\u7EDC\u540E\u70B9\u51FB\u201C\u542F\u52A8\u684C\u5BA0\u201D\uFF0C\u6216\u6309\u6307\u5357\u8BBE\u7F6E\u955C\u50CF\u3001\u624B\u52A8\u5B89\u88C5\u6216\u914D\u7F6E electronPath\u3002",
|
|
336
|
+
runtimeGuide: "Electron \u8FD0\u884C\u65F6\u51C6\u5907\u6307\u5357",
|
|
316
337
|
preferences: "\u504F\u597D\u8BBE\u7F6E",
|
|
317
338
|
autoStart: "\u968F Harness \u542F\u52A8",
|
|
318
339
|
autoStartHint: "\u4E0B\u6B21\u542F\u52A8 Harness \u65F6\u81EA\u52A8\u6253\u5F00\u684C\u5BA0\u3002",
|
|
@@ -391,6 +412,14 @@ var en = {
|
|
|
391
412
|
recovering: "Waiting to recover\u2026",
|
|
392
413
|
recoveryHint: "Automatic recovery attempts (up to 3)",
|
|
393
414
|
runtimeHint: "Unexpected exits retry a limited number of times. You can restart manually after failure. Hidden pets follow system notification settings. Window drafts are lost when the process exits.",
|
|
415
|
+
runtimeMissing: "Electron runtime is missing: ",
|
|
416
|
+
runtimeHttp: "download rejected",
|
|
417
|
+
runtimeNetwork: "download connection failed",
|
|
418
|
+
runtimeTimeout: "download or installation timed out after four minutes",
|
|
419
|
+
runtimeUnavailable: "installer or executable unavailable",
|
|
420
|
+
runtimeInstall: "installation failed",
|
|
421
|
+
runtimeRetry: ". Check your connection and click Start pet, or follow the guide to use a mirror, install manually, or configure electronPath.",
|
|
422
|
+
runtimeGuide: "Electron setup guide",
|
|
394
423
|
preferences: "Preferences",
|
|
395
424
|
autoStart: "Start with Harness",
|
|
396
425
|
autoStartHint: "Open the pet automatically the next time Harness starts.",
|
package/dist/index.js
CHANGED
|
@@ -674,14 +674,40 @@ var NativeStartError = class extends Error {
|
|
|
674
674
|
this.name = "NativeStartError";
|
|
675
675
|
}
|
|
676
676
|
};
|
|
677
|
+
var RuntimePreparationError = class extends NativeStartError {
|
|
678
|
+
constructor(failure, detail) {
|
|
679
|
+
const cause = failure.reason === "http" ? `download rejected (HTTP ${failure.httpStatus})` : {
|
|
680
|
+
network: "download connection failed",
|
|
681
|
+
timeout: "download or installation timed out (240 seconds)",
|
|
682
|
+
unavailable: "installer or executable unavailable",
|
|
683
|
+
install: "installation failed"
|
|
684
|
+
}[failure.reason];
|
|
685
|
+
super(`Electron runtime is missing: ${cause}${detail ? ` (${detail})` : ""}. Prepare Electron or configure electronPath, then start the pet again.`, false);
|
|
686
|
+
this.failure = failure;
|
|
687
|
+
}
|
|
688
|
+
};
|
|
677
689
|
|
|
678
690
|
// src/electron-runtime.ts
|
|
679
691
|
import { spawn } from "node:child_process";
|
|
680
692
|
import { access, readFile } from "node:fs/promises";
|
|
681
693
|
import { createRequire } from "node:module";
|
|
682
694
|
import { dirname, join } from "node:path";
|
|
695
|
+
function installerFailure(stderr, code) {
|
|
696
|
+
const summary = stderr.split(/\r?\n/, 1)[0] ?? "";
|
|
697
|
+
const status = /^HTTPError: Response code ([45]\d\d)\b/.exec(summary);
|
|
698
|
+
if (status) return new RuntimePreparationError({ reason: "http", httpStatus: Number(status[1]) });
|
|
699
|
+
if (/\b(?:ENOTFOUND|EAI_AGAIN|ECONNREFUSED|ECONNRESET|ENETUNREACH|ETIMEDOUT)\b|^TypeError: fetch failed\b/.test(summary)) {
|
|
700
|
+
return new RuntimePreparationError({ reason: "network" });
|
|
701
|
+
}
|
|
702
|
+
return new RuntimePreparationError({ reason: "install" }, code === null ? void 0 : String(code));
|
|
703
|
+
}
|
|
683
704
|
async function electronExecutable(signal) {
|
|
684
|
-
|
|
705
|
+
let directory;
|
|
706
|
+
try {
|
|
707
|
+
directory = dirname(createRequire(import.meta.url).resolve("electron"));
|
|
708
|
+
} catch {
|
|
709
|
+
throw new RuntimePreparationError({ reason: "unavailable" });
|
|
710
|
+
}
|
|
685
711
|
async function installed() {
|
|
686
712
|
let relative;
|
|
687
713
|
try {
|
|
@@ -710,9 +736,13 @@ async function electronExecutable(signal) {
|
|
|
710
736
|
}
|
|
711
737
|
const child = spawn(process.execPath, [join(directory, "install.js")], {
|
|
712
738
|
env: { ...process.env, ELECTRON_RUN_AS_NODE: "1" },
|
|
713
|
-
stdio: "ignore",
|
|
739
|
+
stdio: ["ignore", "ignore", "pipe"],
|
|
714
740
|
windowsHide: true
|
|
715
741
|
});
|
|
742
|
+
let stderr = "";
|
|
743
|
+
child.stderr.on("data", (data) => {
|
|
744
|
+
if (stderr.length < 512) stderr += data.subarray(0, 512 - stderr.length).toString();
|
|
745
|
+
});
|
|
716
746
|
let failure, killTimer;
|
|
717
747
|
const stop = (error) => {
|
|
718
748
|
if (failure) return;
|
|
@@ -721,7 +751,7 @@ async function electronExecutable(signal) {
|
|
|
721
751
|
killTimer = setTimeout(() => child.kill("SIGKILL"), 1e3);
|
|
722
752
|
};
|
|
723
753
|
const aborted = () => stop(new Error("\u684C\u5BA0\u542F\u52A8\u5DF2\u53D6\u6D88"));
|
|
724
|
-
const timer = setTimeout(() => stop(new
|
|
754
|
+
const timer = setTimeout(() => stop(new RuntimePreparationError({ reason: "timeout" })), 24e4);
|
|
725
755
|
signal.addEventListener("abort", aborted, { once: true });
|
|
726
756
|
const finish = (error) => {
|
|
727
757
|
clearTimeout(timer);
|
|
@@ -730,13 +760,15 @@ async function electronExecutable(signal) {
|
|
|
730
760
|
if (failure || error) reject(failure ?? error);
|
|
731
761
|
else resolve();
|
|
732
762
|
};
|
|
733
|
-
child.once("error", (
|
|
734
|
-
|
|
763
|
+
child.once("error", () => {
|
|
764
|
+
failure ??= new RuntimePreparationError({ reason: "unavailable" });
|
|
765
|
+
});
|
|
766
|
+
child.once("close", (code) => finish(code === 0 ? void 0 : installerFailure(stderr, code)));
|
|
735
767
|
if (signal.aborted) aborted();
|
|
736
768
|
});
|
|
737
769
|
if (signal.aborted) throw new Error("\u684C\u5BA0\u542F\u52A8\u5DF2\u53D6\u6D88");
|
|
738
770
|
const executable = await installed();
|
|
739
|
-
if (!executable) throw new
|
|
771
|
+
if (!executable) throw new RuntimePreparationError({ reason: "unavailable" });
|
|
740
772
|
return executable;
|
|
741
773
|
}
|
|
742
774
|
|
|
@@ -1303,6 +1335,7 @@ var PetControls = class {
|
|
|
1303
1335
|
bridge.onLifecycle?.(this.changed);
|
|
1304
1336
|
}
|
|
1305
1337
|
state = { phase: "stopped", visible: false, desiredVisible: true, recoveryAttempt: 0, generation: 0, visibilityRevision: 0, suspended: false };
|
|
1338
|
+
runtimeFailure;
|
|
1306
1339
|
queue = Promise.resolve();
|
|
1307
1340
|
disposed = false;
|
|
1308
1341
|
startup;
|
|
@@ -1335,13 +1368,13 @@ var PetControls = class {
|
|
|
1335
1368
|
} else if (!starting && wasSuspended !== this.state.suspended) this.armStable();
|
|
1336
1369
|
};
|
|
1337
1370
|
status() {
|
|
1338
|
-
return { ...this.state };
|
|
1371
|
+
return { ...this.state, ...this.runtimeFailure && { runtimeFailure: { ...this.runtimeFailure } } };
|
|
1339
1372
|
}
|
|
1340
1373
|
/** Root assembly registers this listener as a context-owned effect. */
|
|
1341
1374
|
onState(listener) {
|
|
1342
1375
|
this.listeners.add(listener);
|
|
1343
1376
|
try {
|
|
1344
|
-
listener(this.
|
|
1377
|
+
listener({ ...this.state });
|
|
1345
1378
|
} catch {
|
|
1346
1379
|
}
|
|
1347
1380
|
return () => this.listeners.delete(listener);
|
|
@@ -1365,9 +1398,10 @@ var PetControls = class {
|
|
|
1365
1398
|
if (!title2) return false;
|
|
1366
1399
|
const sessionId = hintSessionId(value.sessionId);
|
|
1367
1400
|
if (sessionId === false) return false;
|
|
1368
|
-
return this.bridge.notify({ title: title2, body: body2, sessionId: sessionId ?? "", kind: "message" }, this.
|
|
1401
|
+
return this.bridge.notify({ title: title2, body: body2, sessionId: sessionId ?? "", kind: "message" }, { ...this.state });
|
|
1369
1402
|
}
|
|
1370
1403
|
command(command) {
|
|
1404
|
+
const alreadyStarting = this.state.phase === "starting";
|
|
1371
1405
|
if (command === "hide") this.set({ ...this.state, desiredVisible: false });
|
|
1372
1406
|
else if (command === "start" || command === "show" || command === "characters") this.set({ ...this.state, desiredVisible: true });
|
|
1373
1407
|
if (command === "stop" || command === "restart" || command !== "hide" && this.state.phase !== "starting" && this.state.phase !== "running") {
|
|
@@ -1390,7 +1424,7 @@ var PetControls = class {
|
|
|
1390
1424
|
await this.cleanup();
|
|
1391
1425
|
this.set({ ...this.state, phase: "stopped", visible: false, suspended: false });
|
|
1392
1426
|
}
|
|
1393
|
-
if (command !== "stop" && command !== "hide" && this.state.phase !== "running") {
|
|
1427
|
+
if (command !== "stop" && command !== "hide" && this.state.phase !== "running" && (!alreadyStarting || command === "restart")) {
|
|
1394
1428
|
if (this.cleanupBlocked) await this.cleanup();
|
|
1395
1429
|
this.set({ ...this.state, recoveryAttempt: 0, retryAt: void 0 });
|
|
1396
1430
|
await this.launch(epoch);
|
|
@@ -1445,6 +1479,7 @@ var PetControls = class {
|
|
|
1445
1479
|
const diagnostic = this.message(error).slice(0, 600 - cleanup.length) + cleanup;
|
|
1446
1480
|
const attempt = this.state.recoveryAttempt ?? 0;
|
|
1447
1481
|
if (!this.wanted || !recoverable || cleanup || attempt >= 3) {
|
|
1482
|
+
this.runtimeFailure = !cleanup && error instanceof RuntimePreparationError ? error.failure : void 0;
|
|
1448
1483
|
this.set({ ...this.state, phase: "error", visible: false, suspended: false, retryAt: void 0, error: diagnostic });
|
|
1449
1484
|
return;
|
|
1450
1485
|
}
|
|
@@ -1509,9 +1544,10 @@ var PetControls = class {
|
|
|
1509
1544
|
}
|
|
1510
1545
|
set(state) {
|
|
1511
1546
|
this.state = state;
|
|
1547
|
+
if (state.phase !== "error") this.runtimeFailure = void 0;
|
|
1512
1548
|
for (const listener of this.listeners) {
|
|
1513
1549
|
try {
|
|
1514
|
-
listener(
|
|
1550
|
+
listener({ ...state });
|
|
1515
1551
|
} catch {
|
|
1516
1552
|
}
|
|
1517
1553
|
}
|