@masstensor/diagnose 0.8.0 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -7
- package/USER_GUIDE.md +32 -717
- package/dist/discover.js +1 -1
- package/dist/mcp.js +16 -3
- package/dist/peer.d.ts +1 -0
- package/dist/peer.js +11 -1
- package/dist/skill-session.js +18 -3
- package/docs/guide/automation.md +184 -0
- package/docs/guide/diagnose.md +93 -0
- package/docs/guide/on-site.md +139 -0
- package/docs/guide/procedures.md +183 -0
- package/docs/guide/reconnect.md +58 -0
- package/docs/guide/troubleshooting.md +77 -0
- package/npm-shrinkwrap.json +2 -2
- package/package.json +2 -1
- package/skills/connect/SKILL.md +8 -2
- package/skills/connect/scripts/run.mjs +1 -1
- package/src/discover.ts +1 -1
- package/src/mcp.ts +16 -4
- package/src/peer.ts +10 -1
- package/src/skill-session.ts +15 -3
- package/test/skill-session.test.ts +20 -6
|
@@ -11,12 +11,12 @@ import { Peer } from '../dist/peer.js';
|
|
|
11
11
|
import { ProbeEngine } from '../dist/engine.js';
|
|
12
12
|
import { Audit } from '../dist/util.js';
|
|
13
13
|
|
|
14
|
-
function helper(action: string, input: Record<string, unknown
|
|
14
|
+
function helper(action: string, input: Record<string, unknown>, onProgress?: (stderr: string) => void): Promise<Record<string, any>> {
|
|
15
15
|
const script = process.env.DIAGNOSE_TEST_SKILL ?? resolve('skills/connect/scripts/run.mjs');
|
|
16
16
|
const child = spawn(process.execPath, [script, action], { stdio: 'pipe' });
|
|
17
17
|
let out = '', err = '';
|
|
18
18
|
child.stdout.setEncoding('utf8').on('data', text => { out += text; });
|
|
19
|
-
child.stderr.setEncoding('utf8').on('data', text => { err += text; });
|
|
19
|
+
child.stderr.setEncoding('utf8').on('data', text => { err += text; onProgress?.(err); });
|
|
20
20
|
child.stdin.end(JSON.stringify(input));
|
|
21
21
|
return new Promise((resolve, reject) => {
|
|
22
22
|
child.on('error', reject);
|
|
@@ -28,7 +28,7 @@ function helper(action: string, input: Record<string, unknown>): Promise<Record<
|
|
|
28
28
|
});
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
test('native Skill helper pairs once, reuses the connection for a repair and closes it', { timeout: 30000 }, async () => {
|
|
31
|
+
test('native Skill helper pairs once, runs a shell command, reuses the connection for a repair and closes it', { timeout: 30000 }, async () => {
|
|
32
32
|
const scratch = await mkdtemp(join(tmpdir(), 'diagnose-skill-'));
|
|
33
33
|
const config = join(scratch, 'config.txt');
|
|
34
34
|
await writeFile(config, 'offline\n');
|
|
@@ -36,13 +36,21 @@ test('native Skill helper pairs once, reuses the connection for a repair and clo
|
|
|
36
36
|
const url = 'ws://127.0.0.1:' + await relay.listen();
|
|
37
37
|
const code = createInvitation();
|
|
38
38
|
let pairs = 0;
|
|
39
|
+
let approve!: (value: boolean) => void;
|
|
40
|
+
const approval = new Promise<boolean>(resolve => { approve = resolve; });
|
|
39
41
|
const approvals: Array<string> = [];
|
|
40
|
-
const host = new Peer({ role: 'host', code, relay: url, accept: async () => { pairs++; return
|
|
42
|
+
const host = new Peer({ role: 'host', code, relay: url, approvalTimeoutMs: 5000, accept: async () => { pairs++; return approval; } });
|
|
41
43
|
new ProbeEngine(host, async request => { approvals.push(request.stage); return true; }, new Audit(join(scratch, 'audit')));
|
|
42
44
|
let session: string | undefined;
|
|
43
45
|
try {
|
|
44
46
|
await host.open();
|
|
45
|
-
|
|
47
|
+
let progress = '';
|
|
48
|
+
const opened = await helper('open', { code, label: 'Skill test', relay: url }, stderr => {
|
|
49
|
+
progress = stderr;
|
|
50
|
+
if (stderr.includes('Waiting for it to accept the connection')) approve(true);
|
|
51
|
+
});
|
|
52
|
+
assert.match(progress, /Connecting to the Diagnose relay\.[\s\S]+Connected to the relay\.[\s\S]+Authenticated the on-site probe\.[\s\S]+Paired with the on-site probe\./);
|
|
53
|
+
assert.ok(!progress.includes(code));
|
|
46
54
|
assert.equal(opened.connected, true);
|
|
47
55
|
assert.equal(opened.idleSeconds, 6 * 60 * 60);
|
|
48
56
|
session = opened.session;
|
|
@@ -58,13 +66,19 @@ test('native Skill helper pairs once, reuses the connection for a repair and clo
|
|
|
58
66
|
const inspection = await run('system.inspect', {});
|
|
59
67
|
assert.equal(inspection.result.data.platform, process.platform);
|
|
60
68
|
assert.ok(Array.isArray(inspection.result.data.serialPorts));
|
|
69
|
+
const command = process.platform === 'win32'
|
|
70
|
+
? { executable: 'powershell.exe', args: ['-NoProfile', '-NonInteractive', '-Command', '40 + 2'] }
|
|
71
|
+
: { executable: '/bin/sh', args: ['-c', 'printf "%s" "$((40 + 2))"'] };
|
|
72
|
+
const executed = await run('process.run', { ...command, cwd: scratch, timeoutMs: 5000 });
|
|
73
|
+
assert.equal(executed.result.status, 'ok');
|
|
74
|
+
assert.equal(executed.outputs.stdout.trim(), '42');
|
|
61
75
|
assert.equal((await run('file.read', { path: config })).outputs.file, 'offline\n');
|
|
62
76
|
const expectedSha256 = createHash('sha256').update('offline\n').digest('hex');
|
|
63
77
|
assert.equal((await run('file.write', { path: config, content: 'online\n', expectedSha256 })).result.status, 'ok');
|
|
64
78
|
assert.equal((await run('file.read', { path: config })).outputs.file, 'online\n');
|
|
65
79
|
assert.equal(await readFile(config, 'utf8'), 'online\n');
|
|
66
80
|
assert.equal(pairs, 1);
|
|
67
|
-
assert.deepEqual(approvals, ['execute', 'send', 'execute', 'send', 'execute', 'send', 'execute', 'send']);
|
|
81
|
+
assert.deepEqual(approvals, ['execute', 'send', 'execute', 'send', 'execute', 'send', 'execute', 'send', 'execute', 'send']);
|
|
68
82
|
const handle = session;
|
|
69
83
|
assert.equal((await helper('close', { session })).disconnected, true);
|
|
70
84
|
session = undefined;
|