@takboo/dsh-coopanion 0.4.19 → 0.4.21
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 -2
- package/THIRD_PARTY_NOTICES.md +4 -0
- package/assets/coopanion.png +0 -0
- package/assets/coopanion.svg +9 -0
- 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 +41 -27
- package/docs/desktop-recovery-contract.md +1 -1
- package/docs/development.md +22 -3
- package/docs/market/takboo__dsh-coopanion.yml +1 -0
- package/docs/notification-contract.md +1 -1
- package/docs/release-notes.md +16 -0
- package/docs/releasing.md +32 -5
- package/docs/session-chat-contract.md +1 -1
- package/docs/usage.md +7 -7
- package/npm-shrinkwrap.json +2 -2
- package/package.json +5 -1
- package/scripts/check-package.mjs +9 -0
- package/scripts/compatibility/check.mjs +10 -2
- package/scripts/compatibility/discover.mjs +8 -0
- package/scripts/compatibility/planning.mjs +1 -1
- package/scripts/compatibility/published.mjs +157 -0
- package/scripts/compatibility/report.mjs +39 -9
- package/scripts/compatibility/runner.mjs +6 -3
- 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 +32 -0
- 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/install.mjs +11 -0
|
@@ -6,6 +6,7 @@ import { tmpdir } from 'node:os';
|
|
|
6
6
|
import { join } from 'node:path';
|
|
7
7
|
import { pathToFileURL } from 'node:url';
|
|
8
8
|
import type { ElectronBridge as Bridge } from '../src/bridge.ts';
|
|
9
|
+
import type { PetControls as Controls } from '../src/controls.ts';
|
|
9
10
|
|
|
10
11
|
// Keep Electron's real lazy-install entrypoint; replace only the download with
|
|
11
12
|
// a deterministic slow installer and a tiny IPC peer, without network access.
|
|
@@ -32,12 +33,12 @@ async function fixture(install = '') {
|
|
|
32
33
|
await writeFile(join(directory, 'desktop/main.cjs'), `process.on('message', m => { if(m.type === 'quit') process.exit(0); }); process.send({type:'ready'});`);
|
|
33
34
|
// A real executable plus a JS main works on Windows as well as POSIX;
|
|
34
35
|
// spawning a shebang-only fixture silently omitted the Windows regression.
|
|
35
|
-
const success = `setTimeout(()=>{fs.mkdirSync(path.join(__dirname,'dist'));const executable=path.join(__dirname,'dist/peer.exe');try{fs.linkSync(process.execPath,executable);}catch(error){if(error.code
|
|
36
|
+
const success = `setTimeout(()=>{fs.mkdirSync(path.join(__dirname,'dist'));const executable=path.join(__dirname,'dist/peer.exe');try{fs.linkSync(process.execPath,executable);}catch(error){if(!['EXDEV','EPERM','EACCES'].includes(error.code))throw error;fs.copyFileSync(process.execPath,executable);fs.chmodSync(executable,0o700);}fs.writeFileSync(path.join(__dirname,'path.txt'),'peer.exe');},800);`;
|
|
36
37
|
await writeFile(join(electron, 'install.js'), `const fs=require('node:fs'),path=require('node:path');fs.writeFileSync(path.join(__dirname,'installer-pid'),String(process.pid));${install || success}`);
|
|
37
|
-
await build({
|
|
38
|
-
const { ElectronBridge } = await import(pathToFileURL(join(directory, 'dist/bridge.mjs')).href);
|
|
38
|
+
await build({ stdin: { contents: "export { ElectronBridge } from './src/bridge.ts'; export { PetControls } from './src/controls.ts';", resolveDir: process.cwd() }, outfile: join(directory, 'dist/bridge.mjs'), bundle: true, packages: 'external', platform: 'node', format: 'esm' });
|
|
39
|
+
const { ElectronBridge, PetControls } = await import(pathToFileURL(join(directory, 'dist/bridge.mjs')).href);
|
|
39
40
|
bridge = new ElectronBridge();
|
|
40
|
-
return { bridge: bridge!, electron, close };
|
|
41
|
+
return { bridge: bridge!, electron, close, PetControls: PetControls as typeof Controls };
|
|
41
42
|
} catch (error) { await close(); throw error; }
|
|
42
43
|
}
|
|
43
44
|
const options = { size: 150, roam: false, notifications: false, bubbleDurationMs: 12000 };
|
|
@@ -66,6 +67,30 @@ it('reports installer failure without launching a native window', async () => {
|
|
|
66
67
|
finally { await close(); }
|
|
67
68
|
});
|
|
68
69
|
|
|
70
|
+
it('keeps a refused download actionable and shares the attempt with queued start commands', async () => {
|
|
71
|
+
const { bridge, electron, close, PetControls } = await fixture(`
|
|
72
|
+
fs.appendFileSync(path.join(__dirname, 'attempts'), 'started\\n');
|
|
73
|
+
setTimeout(() => {
|
|
74
|
+
console.error('HTTPError: Response code 403 (Forbidden) for https://mirror.invalid/file?token=secret');
|
|
75
|
+
console.error('private stack '.repeat(1024));
|
|
76
|
+
process.exitCode = 1;
|
|
77
|
+
}, 200);`);
|
|
78
|
+
const controls = new PetControls(bridge, () => options);
|
|
79
|
+
try {
|
|
80
|
+
const starting = controls.command('start');
|
|
81
|
+
await Promise.resolve();
|
|
82
|
+
expect(controls.status().phase).toBe('starting');
|
|
83
|
+
const results = await Promise.all([starting, controls.command('start'), controls.command('show')]);
|
|
84
|
+
for (const status of results) {
|
|
85
|
+
expect(status).toMatchObject({ phase: 'error', recoveryAttempt: 0, runtimeFailure: { reason: 'http', httpStatus: 403 } });
|
|
86
|
+
expect(status.error).not.toMatch(/mirror\.invalid|secret|private stack/);
|
|
87
|
+
}
|
|
88
|
+
expect(await readFile(join(electron, 'attempts'), 'utf8')).toBe('started\n');
|
|
89
|
+
await controls.command('start');
|
|
90
|
+
expect(await readFile(join(electron, 'attempts'), 'utf8')).toBe('started\nstarted\n');
|
|
91
|
+
} finally { await controls.dispose(); await close(); }
|
|
92
|
+
});
|
|
93
|
+
|
|
69
94
|
it('cancels runtime preparation, reaps its installer and rejects a concurrent start', async () => {
|
|
70
95
|
const { bridge, electron, close } = await fixture('setInterval(()=>{},1000);');
|
|
71
96
|
const controller = new AbortController();
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"admit": {
|
|
3
|
+
"version": "0.2.2-rc.1",
|
|
4
|
+
"integrity": "sha512-ijR9UEVYkG15Q/Q79JzvzLBzQOQfc63VLr9n6flpwHPhr5IKn2UxthnSoto/P9l7qGd7pPvI1Ra6TW7LH3oKpg==",
|
|
5
|
+
"upstreamCommit": "66491b05e3f05ad35bcdd4f6cd7ed26041d9e3db"
|
|
6
|
+
},
|
|
7
|
+
"refuse": {
|
|
8
|
+
"version": "0.2.1-rc.4",
|
|
9
|
+
"integrity": "sha512-8gxl6zOi6vx1sDolH+vjh9txrpbXD+t74Z2YfWkEBtR3xP2YEtk0bbLkgLZRnYQgDxCoXitXyXDKn5k0+6iXrg==",
|
|
10
|
+
"upstreamCommit": "504a01a9578abc2c6f1fb896b1dc322c9fe24f66"
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
|
|
3
|
+
// Business probe for the shared engineering runner's clean rc.1 Web profile.
|
|
4
|
+
// The container has no graphical session; native startup is tested separately.
|
|
5
|
+
export async function prepareClient(page) {
|
|
6
|
+
const entry = page.getByText(/^(Add API Key|添加 API Key)$/i).first();
|
|
7
|
+
const welcome = page.getByRole('button', { name: /^(Continue|继续)$/ }).and(page.locator(':enabled')).first();
|
|
8
|
+
await entry.or(welcome).first().waitFor();
|
|
9
|
+
if (await welcome.isVisible()) await welcome.click();
|
|
10
|
+
await entry.click();
|
|
11
|
+
const skip = page.getByText(/^(Set up later|Configure later|稍后设置|稍后配置)$/i).first();
|
|
12
|
+
await skip.click();
|
|
13
|
+
await skip.waitFor({ state: 'hidden' });
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export async function verifyClient(page) {
|
|
17
|
+
await page.locator('style[data-plugin="dsh-coopanion"]').waitFor({ state: 'attached' });
|
|
18
|
+
const direct = page.getByRole('button', { name: /^(Settings|设置)$/ });
|
|
19
|
+
const account = page.getByRole('button', { name: /^(Account menu|账号菜单)$/ });
|
|
20
|
+
await direct.or(account).first().waitFor();
|
|
21
|
+
if (await direct.isVisible()) await direct.click();
|
|
22
|
+
else {
|
|
23
|
+
await account.click();
|
|
24
|
+
await page.getByRole('menuitem', { name: /^(Settings|设置)(?:\s|$)/ }).click();
|
|
25
|
+
}
|
|
26
|
+
await page.getByRole('button', { name: /^(Desktop pet|桌宠)$/ }).click();
|
|
27
|
+
const section = page.getByTestId('coopanion-settings');
|
|
28
|
+
const start = section.getByRole('button', { name: /^(Start pet|启动桌宠)$/ });
|
|
29
|
+
await section.getByTestId('pet-status').filter({ hasText: /Unable to start or run|启动或运行失败/ }).waitFor();
|
|
30
|
+
await section.getByRole('alert').filter({ hasText: '桌宠需要桌面显示环境' }).waitFor();
|
|
31
|
+
assert.equal(await section.getByTestId('pet-runtime-failure').count(), 0, 'A headless Host is not a missing Electron runtime');
|
|
32
|
+
await section.getByRole('button', { name: /^(Close pet|关闭桌宠)$/ }).click();
|
|
33
|
+
await section.getByTestId('pet-status').filter({ hasText: /Closed|已关闭/ }).waitFor();
|
|
34
|
+
await start.click();
|
|
35
|
+
await section.getByRole('alert').filter({ hasText: '桌宠需要桌面显示环境' }).waitFor();
|
|
36
|
+
assert.equal(await start.isEnabled(), true);
|
|
37
|
+
const autoStart = section.getByRole('switch', { name: /^(Start with Harness|随 Harness 启动)$/ });
|
|
38
|
+
await autoStart.click();
|
|
39
|
+
await section.getByRole('status').filter({ hasText: /^(Saved|已保存)$/ }).waitFor();
|
|
40
|
+
assert.equal(await autoStart.getAttribute('aria-checked'), 'false');
|
|
41
|
+
|
|
42
|
+
// This last assertion exercises the new browser UI with a controlled
|
|
43
|
+
// runtime failure. The headless carrier cannot start the native installer.
|
|
44
|
+
const statusRoute = '**/api/coopanion/status';
|
|
45
|
+
await page.route(statusRoute, async route => {
|
|
46
|
+
const upstream = await route.fetch();
|
|
47
|
+
const envelope = await upstream.json();
|
|
48
|
+
if (envelope.result?.ok) envelope.result.value.runtimeFailure = { reason: 'http', httpStatus: 403 };
|
|
49
|
+
await route.fulfill({ response: upstream, json: envelope });
|
|
50
|
+
});
|
|
51
|
+
try {
|
|
52
|
+
const alert = section.getByTestId('pet-runtime-failure');
|
|
53
|
+
await alert.filter({ hasText: 'HTTP 403' }).waitFor();
|
|
54
|
+
assert.match(await alert.innerText(), /electronPath/);
|
|
55
|
+
assert.match(await alert.getByRole('link').getAttribute('href'), /docs\/usage\.md#electron-/);
|
|
56
|
+
} finally { await page.unroute(statusRoute); }
|
|
57
|
+
return ['official settings loaded and Host status responded', 'headless failure shown; close and manual retry work', 'auto-start preference saved through Host', 'controlled HTTP 403 status renders a recovery guide'];
|
|
58
|
+
}
|
package/tests/install.mjs
CHANGED
|
@@ -94,6 +94,13 @@ let hostUrl;
|
|
|
94
94
|
let settingsPage;
|
|
95
95
|
const uiErrors = [];
|
|
96
96
|
const consoleErrors = [];
|
|
97
|
+
const phaseFile = process.env.DSH_TEST_PHASE_FILE;
|
|
98
|
+
const phases = [];
|
|
99
|
+
async function recordPhase(phase) {
|
|
100
|
+
if (!phaseFile) return;
|
|
101
|
+
phases.push(phase);
|
|
102
|
+
await writeFile(phaseFile, JSON.stringify(phases) + '\n');
|
|
103
|
+
}
|
|
97
104
|
let hostLog = '';
|
|
98
105
|
|
|
99
106
|
async function run(command, args, cwd = project, timeoutMs = 240000) {
|
|
@@ -177,11 +184,14 @@ try {
|
|
|
177
184
|
assert.equal(existsSync(join(profile, 'compatibility.json')), false, 'no risk exemption is used');
|
|
178
185
|
const installed = join(profile, 'node_modules', manifest.name);
|
|
179
186
|
assert.equal(JSON.parse(await readFile(join(installed, 'package.json'), 'utf8')).version, manifest.version);
|
|
187
|
+
await recordPhase('admitted');
|
|
180
188
|
await run(process.execPath, [join(project, 'tests/notification-host-contract.mjs'), '--runtime', runtime, '--version', version]);
|
|
181
189
|
|
|
182
190
|
await run(process.execPath, [join(project, 'tests/goal-host-contract.mjs'), '--runtime', runtime, '--version', version, '--package', archive]);
|
|
183
191
|
await run(process.execPath, [join(project, 'tests/session-host-contract.mjs'), '--verify-plugin', '--runtime', runtime, '--version', version, '--package', archive]);
|
|
184
192
|
|
|
193
|
+
await recordPhase('host-contracts');
|
|
194
|
+
|
|
185
195
|
// Keep the observer in its own package. The Client loader identifies packages
|
|
186
196
|
// from ancestor manifests; a fixture inside this repository can be mistaken
|
|
187
197
|
// for a second active copy of the installed dsh-coopanion client.
|
|
@@ -334,6 +344,7 @@ try {
|
|
|
334
344
|
await settings.getByRole('navigation', { name: '会话层级', exact: true }).filter({ hasText: '安装验证' }).waitFor();
|
|
335
345
|
assert.equal(await page.locator('#chat-session-name').innerText(), '安装验证');
|
|
336
346
|
await openPetSettings(settings);
|
|
347
|
+
await recordPhase('web-settings-and-native-window');
|
|
337
348
|
const surface = settings.getByTestId('coopanion-settings');
|
|
338
349
|
await surface.waitFor();
|
|
339
350
|
console.log('Official DSH settings page loaded; checking controls and persisted preferences…');
|