deadbyte-mcp 0.15.25 → 0.15.27

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.
@@ -14,6 +14,10 @@ const packageRoot=path.resolve(here,'..');
14
14
  const stateRoot=path.resolve(process.env.DEADBYTE_STATE_ROOT||path.join(os.homedir(),'.deadbyte-mcp'));
15
15
  const evidenceRoot=path.join(stateRoot,'evidence','deferred-slot-operations');
16
16
  const sha256=bytes=>createHash('sha256').update(bytes).digest('hex');
17
+ const sleep=ms=>new Promise(resolve=>setTimeout(resolve,ms));
18
+ const packageIdentity=JSON.parse(await readFile(path.join(packageRoot,'package.json'),'utf8'));
19
+ if(packageIdentity?.name!=='deadbyte-mcp'||!/^[0-9]+\.[0-9]+\.[0-9]+$/.test(packageIdentity?.version??'')) throw new Error('deferred updater package identity invalid');
20
+ const expectedVersion=packageIdentity.version;
17
21
  const atomicJson=async(file,value)=>{
18
22
  await mkdir(path.dirname(file),{recursive:true});
19
23
  const temp=`${file}.${process.pid}.${randomBytes(4).toString('hex')}.tmp`;
@@ -22,7 +26,7 @@ const atomicJson=async(file,value)=>{
22
26
  };
23
27
  function activationArgs(manifestSha){
24
28
  if(!HEX64.test(manifestSha??'')) throw new Error('activate requires one lowercase manifest SHA-256');
25
- return ['--stage',packageRoot,'--development-root',packageRoot,'--expected-version','0.15.5',
29
+ return ['--stage',packageRoot,'--development-root',packageRoot,'--expected-version',expectedVersion,
26
30
  '--expected-manifest',manifestSha,'--process-policy',path.join(packageRoot,'controller','deadbyte-process-policy.json'),
27
31
  '--process-policy-sha256',null,'--desktop-policy',path.join(packageRoot,'controller','deadbyte-desktop-policy.json'),
28
32
  '--desktop-policy-sha256',null,'--semantic-lsp-config',path.join(packageRoot,'controller','deadbyte-semantic-lsp-config.json'),
@@ -81,6 +85,44 @@ async function normalizedArgs(mode,value,{explicitBridgeRoot=null,explicitBridge
81
85
  }
82
86
  throw new Error("operation must be exactly 'activate' or 'rollback'");
83
87
  }
88
+ async function awaitHandoffCompletion(result,{timeoutMs=900000,pollMs=1000}={}){
89
+ if(result?.handed_off!==true) return result;
90
+ if(typeof result.handoff_path!=='string'||!path.isAbsolute(result.handoff_path)) throw new Error('slot activation handoff path invalid');
91
+ const evidenceDir=path.dirname(result.handoff_path);
92
+ const receiptPath=path.join(evidenceDir,'receipt.json');
93
+ const failurePath=path.join(evidenceDir,'failure-receipt.json');
94
+ const expected=result.pointer;
95
+ const publicKey=createPublicKey(await readFile(path.join(stateRoot,'trust','ed25519-public.pem')));
96
+ const deadline=Date.now()+timeoutMs;
97
+ while(Date.now()<deadline){
98
+ try{
99
+ const envelope=JSON.parse(await readFile(receiptPath,'utf8'));
100
+ if(!verifySlotUpdateEnvelope(envelope,publicKey)) throw new Error('activation receipt signature invalid');
101
+ const body=envelope.body,active=body?.active_pointer;
102
+ if(body?.schema!=='deadbyte.r27-slot-update-receipt.v1'||body?.rollback_performed!==false) throw new Error('activation receipt semantics invalid');
103
+ if(active?.release_id!==expected?.release_id||active?.version!==expected?.version||active?.manifest_sha256!==expected?.manifest_sha256||active?.generation_root!==expected?.generation_root) {
104
+ throw new Error('activation receipt target mismatch');
105
+ }
106
+ parseActivePointer(JSON.stringify(active));
107
+ const pointer=parseActivePointer(await readFile(path.join(stateRoot,'active-release.json'),'utf8'));
108
+ if(pointer.release_id!==active.release_id||pointer.generation_root!==active.generation_root||pointer.manifest_sha256!==active.manifest_sha256) {
109
+ throw new Error('active pointer does not match signed activation receipt');
110
+ }
111
+ return {receipt_path:receiptPath,receipt_sha256:envelope.receipt_sha256,pointer};
112
+ }catch(error){
113
+ if(error?.code!=='ENOENT') throw error;
114
+ }
115
+ try{
116
+ const failure=JSON.parse(await readFile(failurePath,'utf8'));
117
+ if(!verifySlotUpdateEnvelope(failure,publicKey)) throw new Error('activation failure receipt signature invalid');
118
+ throw new Error(`slot activation failed: ${failure.body?.error?.message??'failure receipt emitted'}`);
119
+ }catch(error){
120
+ if(error?.code!=='ENOENT') throw error;
121
+ }
122
+ await sleep(pollMs);
123
+ }
124
+ throw new Error(`slot activation timed out after ${timeoutMs}ms`);
125
+ }
84
126
  const rawArgs=process.argv.slice(2);
85
127
  const mode=rawArgs[0],value=rawArgs[1];
86
128
  if(!value||!['activate','rollback'].includes(mode)) throw new Error('usage: deferred-slot-operation-r46.mjs <activate manifest_sha256|rollback activation_receipt> [--bridge-root ABS --bridge-script-sha256 HEX64]');
@@ -102,7 +144,7 @@ if(workerFlag==='--worker'){
102
144
  await atomicJson(statePath,{schema:'deadbyte.deferred-slot-operation.v1',operation_id:operationIdArg,mode,state:'running',started_at_utc:new Date().toISOString(),bridge_root:explicitBridgeRoot,bridge_script_sha256:explicitBridgeSha256});
103
145
  try{
104
146
  const args=await normalizedArgs(mode,value,{explicitBridgeRoot,explicitBridgeSha256});
105
- const result=await runSlotUpdateCli(args,{stateRoot});
147
+ const result=await awaitHandoffCompletion(await runSlotUpdateCli(args,{stateRoot}));
106
148
  await atomicJson(statePath,{schema:'deadbyte.deferred-slot-operation.v1',operation_id:operationIdArg,mode,state:'completed',
107
149
  completed_at_utc:new Date().toISOString(),receipt_path:result.receipt_path,receipt_sha256:result.receipt_sha256,
108
150
  active_release:result.pointer.release_id,generation_root:result.pointer.generation_root,bridge_root:explicitBridgeRoot,bridge_script_sha256:explicitBridgeSha256});
@@ -0,0 +1,54 @@
1
+ $ErrorActionPreference = 'Stop'
2
+ Set-StrictMode -Version 3.0
3
+
4
+ function Invoke-GateStep {
5
+ param([Parameter(Mandatory)][string]$Name,[Parameter(Mandatory)][string[]]$NpmArgs)
6
+ Write-Host "==== $Name ===="
7
+ & npm.cmd @NpmArgs
8
+ if ($LASTEXITCODE -ne 0) { throw "DEADBYTE 0.15.26 / R49 gate failed at $Name with exit code $LASTEXITCODE" }
9
+ }
10
+
11
+ function Invoke-NodeTest {
12
+ param([Parameter(Mandatory)][string]$Name,[Parameter(Mandatory)][string[]]$TestFiles)
13
+ Write-Host "==== $Name ===="
14
+ & node.exe --test --test-concurrency=1 @TestFiles
15
+ if ($LASTEXITCODE -ne 0) { throw "DEADBYTE 0.15.26 / R49 gate failed at $Name with exit code $LASTEXITCODE" }
16
+ }
17
+
18
+ Invoke-GateStep 'containment-build' @('run','containment:build')
19
+ Invoke-GateStep 'process-policy-refresh' @('run','process:policy:refresh')
20
+ Invoke-GateStep 'desktop-policy-refresh' @('run','desktop:policy:refresh')
21
+ Invoke-GateStep 'hardware-build' @('run','hardware:build')
22
+
23
+ $hostPolicy = [System.IO.Path]::GetFullPath((Join-Path $PSScriptRoot '..\controller\deadbyte-host-policy.json'))
24
+ Remove-Item -LiteralPath $hostPolicy -Force -ErrorAction SilentlyContinue
25
+ if (Test-Path -LiteralPath $hostPolicy) { throw 'could not establish hermetic Host policy absence' }
26
+
27
+ Invoke-GateStep 'r49-release-focused' @('run','r48:release:test')
28
+ Invoke-NodeTest 'r49-donor-proof' @('test/r49-remote-control-donors.test.mjs')
29
+ Invoke-NodeTest 'r49-desktop-wait' @('test/desktop-runtime-r40.test.mjs','test/desktop-mcp-tools-r40.test.mjs','test/autonomous-desktop-r40.test.mjs')
30
+ Invoke-GateStep 'r49-catalog' @('run','r48:catalog:test')
31
+ Invoke-GateStep 'commander-hardening' @('run','r47:hardening:test')
32
+ Invoke-GateStep 'full-regression' @('run','r48:full:test')
33
+ Invoke-GateStep 'mcp-smoke' @('run','mcp:smoke')
34
+ Invoke-GateStep 'mcp-agent-smoke' @('run','mcp:agent:smoke')
35
+ Invoke-GateStep 'mcp-coding-smoke' @('run','mcp:coding:smoke')
36
+ Invoke-GateStep 'mcp-machine-fs-smoke' @('run','mcp:machine-fs:smoke')
37
+ Invoke-GateStep 'mcp-observation-smoke' @('run','mcp:observation:smoke')
38
+ Invoke-GateStep 'mcp-process-smoke' @('run','mcp:process:smoke')
39
+ Invoke-GateStep 'mcp-autonomous-smoke' @('run','mcp:autonomous:smoke')
40
+ Invoke-GateStep 'tunnel-stdio-compat-smoke' @('run','mcp:tunnel-compat:smoke')
41
+ Invoke-GateStep 'containment-smoke' @('run','containment:smoke')
42
+ Invoke-GateStep 'contained-smoke' @('run','contained:smoke')
43
+ Invoke-GateStep 'mcp-contained-smoke' @('run','mcp:contained:smoke')
44
+ Invoke-GateStep 'host-policy-refresh' @('run','host:policy:init')
45
+ Invoke-GateStep 'manifest-write' @('run','manifest:write')
46
+ Invoke-GateStep 'manifest-verify' @('run','manifest:verify')
47
+ Invoke-GateStep 'doctor' @('run','doctor')
48
+ Invoke-GateStep 'mcp-host-smoke' @('run','mcp:host:smoke')
49
+ Invoke-GateStep 'authority-smoke' @('run','authority:smoke')
50
+ Invoke-GateStep 'manifest-final-verify' @('run','manifest:verify')
51
+
52
+ & node.exe (Join-Path $PSScriptRoot 'windows-gate-evidence-r49.mjs')
53
+ if ($LASTEXITCODE -ne 0) { throw "R49 evidence writer failed with exit code $LASTEXITCODE" }
54
+ Write-Host '==== DEADBYTE 0.15.26 / R49 WINDOWS GATE: PASS ===='
@@ -0,0 +1,56 @@
1
+ $ErrorActionPreference = 'Stop'
2
+ Set-StrictMode -Version 3.0
3
+
4
+ function Invoke-GateStep {
5
+ param([Parameter(Mandatory)][string]$Name,[Parameter(Mandatory)][string[]]$NpmArgs)
6
+ Write-Host "==== $Name ===="
7
+ & npm.cmd @NpmArgs
8
+ if ($LASTEXITCODE -ne 0) { throw "DEADBYTE 0.15.27 / R50 gate failed at $Name with exit code $LASTEXITCODE" }
9
+ }
10
+
11
+ function Invoke-NodeTest {
12
+ param([Parameter(Mandatory)][string]$Name,[Parameter(Mandatory)][string[]]$TestFiles)
13
+ Write-Host "==== $Name ===="
14
+ & node.exe --test --test-concurrency=1 @TestFiles
15
+ if ($LASTEXITCODE -ne 0) { throw "DEADBYTE 0.15.27 / R50 gate failed at $Name with exit code $LASTEXITCODE" }
16
+ }
17
+
18
+ Invoke-NodeTest 'r50-package-boundary' @('test/package-boundary.test.mjs')
19
+ Invoke-NodeTest 'r50-release-smoke-isolation' @('test/release-smoke-isolation.test.mjs')
20
+ Invoke-GateStep 'containment-build' @('run','containment:build')
21
+ Invoke-GateStep 'process-policy-refresh' @('run','process:policy:refresh')
22
+ Invoke-GateStep 'desktop-policy-refresh' @('run','desktop:policy:refresh')
23
+ Invoke-GateStep 'hardware-build' @('run','hardware:build')
24
+
25
+ $hostPolicy = [System.IO.Path]::GetFullPath((Join-Path $PSScriptRoot '..\controller\deadbyte-host-policy.json'))
26
+ Remove-Item -LiteralPath $hostPolicy -Force -ErrorAction SilentlyContinue
27
+ if (Test-Path -LiteralPath $hostPolicy) { throw 'could not establish hermetic Host policy absence' }
28
+
29
+ Invoke-GateStep 'r50-release-focused' @('run','r48:release:test')
30
+ Invoke-NodeTest 'r49-donor-proof' @('test/r49-remote-control-donors.test.mjs')
31
+ Invoke-NodeTest 'r49-desktop-wait' @('test/desktop-runtime-r40.test.mjs','test/desktop-mcp-tools-r40.test.mjs','test/autonomous-desktop-r40.test.mjs')
32
+ Invoke-GateStep 'r49-catalog' @('run','r48:catalog:test')
33
+ Invoke-GateStep 'commander-hardening' @('run','r47:hardening:test')
34
+ Invoke-GateStep 'full-regression' @('run','r48:full:test')
35
+ Invoke-GateStep 'mcp-smoke' @('run','mcp:smoke')
36
+ Invoke-GateStep 'mcp-agent-smoke' @('run','mcp:agent:smoke')
37
+ Invoke-GateStep 'mcp-coding-smoke' @('run','mcp:coding:smoke')
38
+ Invoke-GateStep 'mcp-machine-fs-smoke' @('run','mcp:machine-fs:smoke')
39
+ Invoke-GateStep 'mcp-observation-smoke' @('run','mcp:observation:smoke')
40
+ Invoke-GateStep 'mcp-process-smoke' @('run','mcp:process:smoke')
41
+ Invoke-GateStep 'mcp-autonomous-smoke' @('run','mcp:autonomous:smoke')
42
+ Invoke-GateStep 'tunnel-stdio-compat-smoke' @('run','mcp:tunnel-compat:smoke')
43
+ Invoke-GateStep 'containment-smoke' @('run','containment:smoke')
44
+ Invoke-GateStep 'contained-smoke' @('run','contained:smoke')
45
+ Invoke-GateStep 'mcp-contained-smoke' @('run','mcp:contained:smoke')
46
+ Invoke-GateStep 'host-policy-refresh' @('run','host:policy:init')
47
+ Invoke-GateStep 'manifest-write' @('run','manifest:write')
48
+ Invoke-GateStep 'manifest-verify' @('run','manifest:verify')
49
+ Invoke-GateStep 'doctor' @('run','doctor')
50
+ Invoke-GateStep 'mcp-host-smoke' @('run','mcp:host:smoke')
51
+ Invoke-GateStep 'authority-smoke' @('run','authority:smoke')
52
+ Invoke-GateStep 'manifest-final-verify' @('run','manifest:verify')
53
+
54
+ & node.exe (Join-Path $PSScriptRoot 'windows-gate-evidence-r50.mjs')
55
+ if ($LASTEXITCODE -ne 0) { throw "R50 evidence writer failed with exit code $LASTEXITCODE" }
56
+ Write-Host '==== DEADBYTE 0.15.27 / R50 WINDOWS GATE: PASS ===='
@@ -0,0 +1,27 @@
1
+ import {createHash} from 'node:crypto';
2
+ import {mkdir,open,readFile} from 'node:fs/promises';
3
+ import os from 'node:os';
4
+ import path from 'node:path';
5
+ import {fileURLToPath} from 'node:url';
6
+ import {doctor} from '../src/doctor-r45.mjs';
7
+
8
+ const root=path.resolve(path.dirname(fileURLToPath(import.meta.url)),'..');
9
+ const stateRoot=path.resolve(process.env.DEADBYTE_STATE_ROOT||path.join(os.homedir(),'.deadbyte-mcp'));
10
+ const sha256=bytes=>createHash('sha256').update(bytes).digest('hex');
11
+ const insist=(ok,message)=>{if(!ok)throw new Error(message);};
12
+ const pkg=JSON.parse(await readFile(path.join(root,'package.json'),'utf8'));
13
+ const release=JSON.parse(await readFile(path.join(root,'RELEASE.json'),'utf8'));
14
+ const active=JSON.parse(await readFile(path.join(stateRoot,'active-release.json'),'utf8'));
15
+ const manifestSha256=sha256(await readFile(path.join(root,'MANIFEST.SHA256')));
16
+ insist(pkg.version==='0.15.26'&&release.version===pkg.version&&release.train==='R49','R49 candidate identity mismatch');
17
+ insist(active.release_id===release.parent.release_id&&active.manifest_sha256===release.parent.manifest_sha256&&active.generation_manifest_sha256===release.parent.generation_manifest_sha256,'active runtime is not the exact sealed R49 parent');
18
+ const health=await doctor();
19
+ insist(health.status==='ok'&&health.package_version===pkg.version&&health.manifest?.verified===true,'R49 doctor evidence invalid');
20
+ insist(health.policy?.host_v2_ready===true,'R49 Host policy v2 is not ready');
21
+ const evidence={schema:'deadbyte.r49-windows-gate.v1',status:'passed',exit_code:0,version:pkg.version,train:'R49',completed_at_utc:new Date().toISOString(),manifest_sha256:manifestSha256,parent:release.parent,active_predecessor:{release_id:active.release_id,version:active.version,manifest_sha256:active.manifest_sha256,generation_manifest_sha256:active.generation_manifest_sha256},doctor:{verified_entries:health.manifest.verified_entries,host_v2_ready:true},gates:{full_regression:true,commander_hardening:true,donor_proof:true,desktop_wait:true,exact_catalog:true,stdio_smokes:true,manifest_final_verify:true}};
22
+ const bytes=Buffer.from(`${JSON.stringify(evidence,null,2)}\n`);
23
+ const dir=path.join(stateRoot,'evidence','release'); await mkdir(dir,{recursive:true});
24
+ const target=path.join(dir,`r49-windows-gate-${manifestSha256.slice(0,16)}.json`);
25
+ try{const handle=await open(target,'wx',0o600);try{await handle.writeFile(bytes);await handle.sync();}finally{await handle.close();}}
26
+ catch(error){if(error?.code!=='EEXIST')throw error;const prior=JSON.parse(await readFile(target,'utf8'));insist(prior.schema===evidence.schema&&prior.status==='passed'&&prior.version===evidence.version&&prior.manifest_sha256===manifestSha256&&prior.parent?.release_id===release.parent.release_id,'conflicting R49 gate evidence identity');}
27
+ console.log(JSON.stringify({status:'passed',path:target,sha256:sha256(bytes),manifest_sha256:manifestSha256}));
@@ -0,0 +1,80 @@
1
+ import { createHash } from 'node:crypto';
2
+ import { mkdir, open, readFile } from 'node:fs/promises';
3
+ import os from 'node:os';
4
+ import path from 'node:path';
5
+ import { fileURLToPath } from 'node:url';
6
+ import { doctor } from '../src/doctor-r45.mjs';
7
+
8
+ const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
9
+ const stateRoot = path.resolve(process.env.DEADBYTE_STATE_ROOT || path.join(os.homedir(), '.deadbyte-mcp'));
10
+ const sha256 = bytes => createHash('sha256').update(bytes).digest('hex');
11
+ const insist = (ok, message) => { if (!ok) throw new Error(message); };
12
+ const pkg = JSON.parse(await readFile(path.join(root, 'package.json'), 'utf8'));
13
+ const release = JSON.parse(await readFile(path.join(root, 'RELEASE.json'), 'utf8'));
14
+ const active = JSON.parse(await readFile(path.join(stateRoot, 'active-release.json'), 'utf8'));
15
+ const manifestSha256 = sha256(await readFile(path.join(root, 'MANIFEST.SHA256')));
16
+
17
+ insist(pkg.version === '0.15.27' && release.version === pkg.version && release.train === 'R50', 'R50 candidate identity mismatch');
18
+ insist(
19
+ active.release_id === release.parent.release_id &&
20
+ active.manifest_sha256 === release.parent.manifest_sha256 &&
21
+ active.generation_manifest_sha256 === release.parent.generation_manifest_sha256,
22
+ 'active runtime is not the exact sealed R50 parent'
23
+ );
24
+
25
+ const health = await doctor();
26
+ insist(health.status === 'ok' && health.package_version === pkg.version && health.manifest?.verified === true, 'R50 doctor evidence invalid');
27
+ insist(health.policy?.host_v2_ready === true, 'R50 Host policy v2 is not ready');
28
+
29
+ const evidence = {
30
+ schema: 'deadbyte.r50-windows-gate.v1',
31
+ status: 'passed',
32
+ exit_code: 0,
33
+ version: pkg.version,
34
+ train: 'R50',
35
+ completed_at_utc: new Date().toISOString(),
36
+ manifest_sha256: manifestSha256,
37
+ parent: release.parent,
38
+ active_predecessor: {
39
+ release_id: active.release_id,
40
+ version: active.version,
41
+ manifest_sha256: active.manifest_sha256,
42
+ generation_manifest_sha256: active.generation_manifest_sha256
43
+ },
44
+ doctor: { verified_entries: health.manifest.verified_entries, host_v2_ready: true },
45
+ gates: {
46
+ package_boundary: true,
47
+ release_smoke_isolation: true,
48
+ full_regression: true,
49
+ commander_hardening: true,
50
+ donor_proof: true,
51
+ desktop_wait: true,
52
+ exact_catalog: true,
53
+ stdio_smokes: true,
54
+ manifest_final_verify: true
55
+ }
56
+ };
57
+
58
+ const bytes = Buffer.from(`${JSON.stringify(evidence, null, 2)}\n`);
59
+ const dir = path.join(stateRoot, 'evidence', 'release');
60
+ await mkdir(dir, { recursive: true });
61
+ const target = path.join(dir, `r50-windows-gate-${manifestSha256.slice(0, 16)}.json`);
62
+
63
+ try {
64
+ const handle = await open(target, 'wx', 0o600);
65
+ try { await handle.writeFile(bytes); await handle.sync(); }
66
+ finally { await handle.close(); }
67
+ } catch (error) {
68
+ if (error?.code !== 'EEXIST') throw error;
69
+ const prior = JSON.parse(await readFile(target, 'utf8'));
70
+ insist(
71
+ prior.schema === evidence.schema &&
72
+ prior.status === 'passed' &&
73
+ prior.version === evidence.version &&
74
+ prior.manifest_sha256 === manifestSha256 &&
75
+ prior.parent?.release_id === release.parent.release_id,
76
+ 'conflicting R50 gate evidence identity'
77
+ );
78
+ }
79
+
80
+ console.log(JSON.stringify({ status: 'passed', path: target, sha256: sha256(bytes), manifest_sha256: manifestSha256 }));
@@ -132,6 +132,7 @@ const r36TypedActionSchemas=[
132
132
  z.strictObject({kind:z.literal('observation_system_status')}),
133
133
  z.strictObject({kind:z.literal('desktop_status')}),
134
134
  z.strictObject({kind:z.literal('desktop_observe')}),
135
+ z.strictObject({kind:z.literal('desktop_wait'),baseline_frame_id:z.string().regex(HEX64),until:z.enum(['frame_changed','topology_changed','foreground_changed','uia_present','uia_absent']),uia_query:plannerDesktopQuery.nullable().default(null),timeout_ms:z.number().int().min(100).max(30000).default(5000),poll_ms:z.number().int().min(50).max(1000).default(100)}),
135
136
  z.strictObject({kind:z.literal('desktop_target'),frame_id:z.string().regex(HEX64),uia_query:plannerDesktopQuery}),
136
137
  z.strictObject({
137
138
  kind:z.literal('desktop_action'),action_kind:plannerDesktopActionKind,expected_frame_id:z.string().regex(HEX64),
@@ -134,11 +134,17 @@ function validateR36TypedAction(action) {
134
134
  if (typeof action.destination_path === 'string') pathFields.push(action.destination_path);
135
135
  for (const item of action.files ?? []) if (typeof item?.path === 'string') pathFields.push(item.path);
136
136
  for (const candidate of pathFields) validatePortableRelativePath(candidate);
137
- if(action.kind==='desktop_target'){
137
+ if(action.kind==='desktop_target'||action.kind==='desktop_wait'){
138
138
  const q=action.uia_query;
139
- if(q.kind==='root'&&q.value!=='') throw new Error('desktop root query value must be empty');
140
- if(q.kind!=='root'&&q.value.length<1) throw new Error('desktop UIA query value required');
141
- if(q.ordinal>=q.max_results) throw new Error('desktop UIA ordinal must be below max_results');
139
+ const needsQuery=action.kind==='desktop_target'||action.until==='uia_present'||action.until==='uia_absent';
140
+ if(needsQuery&&!q)throw new Error('desktop UIA query required');
141
+ if(!needsQuery&&q)throw new Error('desktop non-UIA wait cannot carry query');
142
+ if(q){
143
+ if(q.kind==='root'&&q.value!=='') throw new Error('desktop root query value must be empty');
144
+ if(q.kind!=='root'&&q.value.length<1) throw new Error('desktop UIA query value required');
145
+ if(q.ordinal>=q.max_results) throw new Error('desktop UIA ordinal must be below max_results');
146
+ }
147
+ if(action.kind==='desktop_wait'&&action.poll_ms>action.timeout_ms)throw new Error('desktop wait poll exceeds timeout');
142
148
  }
143
149
  if(action.kind==='desktop_action'){
144
150
  const pointer=['pointer_move','click_primary','click_secondary','double_click_primary','scroll'].includes(action.action_kind);
@@ -372,7 +378,7 @@ export function buildPlannerPrompt({ goal, policy, view }) {
372
378
  'patch: operations are DEADBYTE Native Diff operations (write, replace, delete) and MUST use exact SHA-256 preconditions from supplied context.',
373
379
  'run_profile: profile_id must be one of the policy profile ids in state.',
374
380
  'delegate: operation is one bounded existing-runtime action. Allowed kinds: machine_stat, machine_list, machine_read, observation_search_start, observation_search_status, observation_search_page, observation_search_cancel, observation_process_list, observation_system_status, process_start, process_read, process_status, process_list, process_action, process_terminate.',
375
- 'When Desktop capabilities are present, use typed desktop_status, desktop_observe, desktop_target with one bounded UIA query, and desktop_action. desktop_action requires separate Desktop authority; Autonomous authority never implies Desktop authority. After stale or unknown Desktop evidence, observe again and replan; never blindly repeat an action.',
381
+ 'When Desktop capabilities are present, use typed desktop_status, desktop_observe, bounded desktop_wait, desktop_target with one bounded UIA query, and desktop_action. desktop_wait is read-only and replaces fixed sleeps; it never retries an action. desktop_action requires separate Desktop authority; Autonomous authority never implies Desktop authority. After stale or unknown Desktop evidence, observe again and replan; never blindly repeat an action.',
376
382
  'Delegate paths are relative to the goal root. Process start accepts only profile_id and cwd; process_action accepts only session_id and fixed action_id. Never emit raw stdin, executable, PID, environment, shell command, or process arguments.',
377
383
  'finish only when the goal is actually satisfied. Required release profiles are enforced by the engine and cannot be bypassed.',
378
384
  'clarify only when one bounded operator choice is genuinely required. Ask one concrete question and provide 2-5 short mutually exclusive choices.',
@@ -726,7 +726,7 @@ const CAPABILITY_BY_ACTION=Object.freeze({
726
726
  machine_stat:'machine_fs.stat',machine_list:'machine_fs.list',machine_read:'machine_fs.read',
727
727
  observation_search_start:'observation.search_start',observation_search_status:'observation.search_status',observation_search_page:'observation.search_page',observation_search_cancel:'observation.search_cancel',
728
728
  observation_process_list:'observation.process_list',observation_system_status:'observation.system_status',
729
- desktop_status:'desktop.status',desktop_observe:'desktop.observe',desktop_target:'desktop.target',desktop_action:'desktop.action'
729
+ desktop_status:'desktop.status',desktop_observe:'desktop.observe',desktop_wait:'desktop.wait',desktop_target:'desktop.target',desktop_action:'desktop.action'
730
730
  });
731
731
  function capabilityIdForOperation(operation){return CAPABILITY_BY_ACTION[operation?.kind]??null;}
732
732
  function assertDelegatedIdentity(events, operation) {
@@ -745,6 +745,12 @@ function assertDelegatedIdentity(events, operation) {
745
745
  event.payload?.operation?.kind==='desktop_observe'&&event.payload?.result?.frame?.frame_id===operation.frame_id);
746
746
  if(!owned) throw new Error(`desktop frame '${operation.frame_id}' was not freshly observed by this goal`);
747
747
  }
748
+ if(operation.kind==='desktop_wait'){
749
+ const owned=events.some(event=>event.type==='delegated_action_completed'&&
750
+ ['desktop_observe','desktop_wait','desktop_target'].includes(event.payload?.operation?.kind)&&
751
+ event.payload?.result?.frame?.frame_id===operation.baseline_frame_id);
752
+ if(!owned)throw new Error(`desktop wait baseline '${operation.baseline_frame_id}' was not freshly observed by this goal`);
753
+ }
748
754
  if(operation.kind==='desktop_action'){
749
755
  const frameOwned=events.some(event=>event.type==='delegated_action_completed'&&
750
756
  ['desktop_observe','desktop_target'].includes(event.payload?.operation?.kind)&&
@@ -856,6 +862,9 @@ async function invokeDelegatedOperation(goal, operation, runtimes, desktopContex
856
862
  case 'desktop_observe':
857
863
  if(!desktopRuntime) throw new Error('desktop runtime unavailable');
858
864
  return desktopRuntime.observe({preview:false});
865
+ case 'desktop_wait':
866
+ if(!desktopRuntime) throw new Error('desktop runtime unavailable');
867
+ return desktopRuntime.wait({baselineFrameId:operation.baseline_frame_id,until:operation.until,query:operation.uia_query,timeoutMs:operation.timeout_ms,pollMs:operation.poll_ms,preview:false});
859
868
  case 'desktop_target':
860
869
  if(!desktopRuntime) throw new Error('desktop runtime unavailable');
861
870
  return desktopRuntime.ground({frameId:operation.frame_id,query:operation.uia_query});
@@ -903,6 +912,7 @@ async function verifyDelegatedEvidence(operation, result, runtimes, verifyKeyPat
903
912
  if(!runtimes.desktopRuntime?.verifyReceipt) throw new Error('desktop receipt verifier unavailable');
904
913
  const refs=[];
905
914
  if(operation.kind==='desktop_observe'&&result?.receipt_id) refs.push([result.receipt_id,result.receipt_sha256,'desktop_observation']);
915
+ if(operation.kind==='desktop_wait'&&result?.receipt_id) refs.push([result.receipt_id,result.receipt_sha256,'desktop_wait_observation']);
906
916
  if(operation.kind==='desktop_target'&&result?.grounding?.receipt_id) refs.push([result.grounding.receipt_id,result.grounding.receipt_sha256,'desktop_grounding']);
907
917
  if(operation.kind==='desktop_action'){
908
918
  refs.push(
@@ -147,6 +147,7 @@ export const R36_CAPABILITY_ENTRIES=Object.freeze([
147
147
 
148
148
  gateway('desktop.status','desktop_status','desktop_control','status','DEADBYTE_DESKTOP_RUNTIME','none',{receipt_class:'desktop'}),
149
149
  gateway('desktop.observe','desktop_observe','desktop_control','observe','DEADBYTE_DESKTOP_RUNTIME','none',{receipt_class:'desktop'}),
150
+ gateway('desktop.wait','desktop_wait','desktop_control','wait','DEADBYTE_DESKTOP_RUNTIME','none',{receipt_class:'desktop'}),
150
151
  gateway('desktop.target','desktop_target','desktop_control','target','DEADBYTE_DESKTOP_RUNTIME','none',{receipt_class:'desktop'}),
151
152
  gateway('desktop.action','desktop_action','desktop_control','action','DEADBYTE_DESKTOP_RUNTIME','desktop',{mutating:true,receipt_class:'desktop'}),
152
153
 
@@ -33,6 +33,19 @@ const explicitTargetFields={
33
33
  confidence:z.number().min(0).max(1),semantic_label_sha256:hex64.nullable().default(null)
34
34
  };
35
35
  const uiaTargetFields={frame_id:hex64,uia_query:uiaQuery};
36
+ const waitFields={
37
+ baseline_frame_id:hex64,
38
+ until:z.enum(['frame_changed','topology_changed','foreground_changed','uia_present','uia_absent']),
39
+ uia_query:uiaQuery.nullable().default(null),timeout_ms:z.number().int().min(100).max(30000).default(5000),
40
+ poll_ms:z.number().int().min(50).max(1000).default(100),preview:z.boolean().default(false)
41
+ };
42
+ function validateWait(value,ctx){
43
+ const needsQuery=value.until==='uia_present'||value.until==='uia_absent';
44
+ if(needsQuery&&value.uia_query===null)ctx.addIssue({code:'custom',path:['uia_query'],message:'UIA wait requires uia_query'});
45
+ if(!needsQuery&&value.uia_query!==null)ctx.addIssue({code:'custom',path:['uia_query'],message:'non-UIA wait cannot carry uia_query'});
46
+ if(value.poll_ms>value.timeout_ms)ctx.addIssue({code:'custom',path:['poll_ms'],message:'poll_ms cannot exceed timeout_ms'});
47
+ }
48
+ export const desktopWaitInputSchema=z.strictObject(waitFields).superRefine(validateWait);
36
49
  export const desktopTargetInputSchema=z.union([
37
50
  z.strictObject(explicitTargetFields),z.strictObject(uiaTargetFields)
38
51
  ]);
@@ -61,12 +74,13 @@ export const desktopActionInputSchema=z.strictObject(actionFields).superRefine(v
61
74
 
62
75
  const statusOp=z.strictObject({op:z.literal('status')});
63
76
  const observeOp=z.strictObject({op:z.literal('observe'),preview:z.boolean().default(false)});
77
+ const waitOp=z.strictObject({op:z.literal('wait'),...waitFields}).superRefine(validateWait);
64
78
  const targetOp=z.union([
65
79
  z.strictObject({op:z.literal('target'),...explicitTargetFields}),
66
80
  z.strictObject({op:z.literal('target'),...uiaTargetFields})
67
81
  ]);
68
82
  const actionOp=z.strictObject({op:z.literal('action'),...actionFields}).superRefine(validateAction);
69
- export const desktopControlInputSchema=z.union([statusOp,observeOp,targetOp,actionOp]);
83
+ export const desktopControlInputSchema=z.union([statusOp,observeOp,waitOp,targetOp,actionOp]);
70
84
 
71
85
  const sha256=value=>createHash('sha256').update(value).digest('hex');
72
86
  function publicResult(value){
@@ -89,6 +103,10 @@ export async function invokeDesktopOperation(args,runtime){
89
103
  let value;
90
104
  if(op==='status') value=await runtime.status();
91
105
  else if(op==='observe') value=await runtime.observe({preview:args.preview??false});
106
+ else if(op==='wait') value=await runtime.wait({
107
+ baselineFrameId:args.baseline_frame_id,until:args.until,query:args.uia_query,
108
+ timeoutMs:args.timeout_ms,pollMs:args.poll_ms,preview:args.preview
109
+ });
92
110
  else if(op==='target'&&args.uia_query) value=await runtime.ground({frameId:args.frame_id,query:args.uia_query});
93
111
  else if(op==='target') value=await runtime.target({
94
112
  frameId:args.frame_id,rect:args.rect,source:args.source,confidence:args.confidence,
@@ -115,6 +133,10 @@ export function registerDesktopTools(server,{runtime}={}){
115
133
  description:'Capture one bounded Windows desktop frame and signed observation evidence. Observation does not require Desktop mutation authority.',
116
134
  inputSchema:desktopObserveInputSchema,outputSchema:compactGatewayOutputSchema
117
135
  },args=>invokeDesktopOperation({op:'observe',...args},runtime));
136
+ server.registerTool('desktop_wait',{
137
+ description:'Wait for one bounded desktop or local UIA condition using fresh observations. This is read-only, returns signed final evidence, and never dispatches or retries an action.',
138
+ inputSchema:desktopWaitInputSchema,outputSchema:compactGatewayOutputSchema
139
+ },args=>invokeDesktopOperation({op:'wait',...args},runtime));
118
140
  server.registerTool('desktop_target',{
119
141
  description:'Bind one explicit rectangle or one local Windows UIA query to fresh desktop evidence. UIA query text is matched locally and is not returned.',
120
142
  inputSchema:desktopTargetInputSchema,outputSchema:compactGatewayOutputSchema
@@ -71,13 +71,14 @@ export function verifyDesktopReceiptObject(receipt,{policySha256,publicKey,keyId
71
71
 
72
72
  export function createDesktopRuntime({
73
73
  policy,observerRuntime,inputProvider,grounderProvider=null,privateKey,publicKey=null,keyId,evidenceDir=policy?.evidence_dir,
74
- now=()=>new Date().toISOString(),maxTargets=64
74
+ now=()=>new Date().toISOString(),clockMs=()=>Date.now(),sleeper=ms=>new Promise(resolve=>setTimeout(resolve,ms)),maxTargets=64
75
75
  }={}){
76
76
  insist(policy?.schema===DESKTOP_POLICY_SCHEMA,'desktop runtime policy invalid');
77
77
  insist(observerRuntime?.capture&&observerRuntime?.frameStatus,'desktop runtime observer invalid');
78
78
  insist(typeof inputProvider==='function','desktop runtime inputProvider required');
79
79
  insist(privateKey,'desktop runtime privateKey required');
80
80
  insist(typeof keyId==='string'&&keyId.length>=1,'desktop runtime keyId invalid');
81
+ insist(typeof clockMs==='function'&&typeof sleeper==='function','desktop wait clock invalid');
81
82
  insist(Number.isInteger(maxTargets)&&maxTargets>=1&&maxTargets<=1024,'maxTargets invalid');
82
83
  const receiptPublicKey=publicKey??createPublicKey(privateKey);
83
84
  const targets=new Map();
@@ -118,6 +119,49 @@ export function createDesktopRuntime({
118
119
  },observed.frame.observed_at_utc);
119
120
  return Object.freeze({...observed,...(previewValue?{preview:previewValue}:{}),receipt_id:evidence.receipt_id,receipt_sha256:evidence.receipt_sha256});
120
121
  }
122
+ async function wait({baselineFrameId,until,query=null,timeoutMs=5000,pollMs=100,preview=false}={}){
123
+ insist(HEX64.test(baselineFrameId??''),'desktop wait baseline frame invalid');
124
+ insist(['frame_changed','topology_changed','foreground_changed','uia_present','uia_absent'].includes(until),'desktop wait condition invalid');
125
+ insist(Number.isInteger(timeoutMs)&&timeoutMs>=100&&timeoutMs<=30000,'desktop wait timeout invalid');
126
+ insist(Number.isInteger(pollMs)&&pollMs>=50&&pollMs<=1000&&pollMs<=timeoutMs,'desktop wait poll invalid');
127
+ insist(typeof preview==='boolean','desktop wait preview invalid');
128
+ const needsQuery=until==='uia_present'||until==='uia_absent';
129
+ insist(needsQuery?query&&typeof grounderProvider==='function':query===null,'desktop wait query invalid');
130
+ const baseline=observerRuntime.frameStatus(baselineFrameId).frame;
131
+ const started=clockMs();
132
+ insist(Number.isFinite(started),'desktop wait clock result invalid');
133
+ let attempts=0,observed=null,match=null,satisfied=false;
134
+ while(true){
135
+ observed=await observerRuntime.capture();attempts++;
136
+ if(until==='frame_changed')satisfied=observed.frame.image_sha256!==baseline.image_sha256;
137
+ else if(until==='topology_changed')satisfied=observed.frame.topology_sha256!==baseline.topology_sha256;
138
+ else if(until==='foreground_changed')satisfied=!sameWindow(observed.frame.active_window,baseline.active_window);
139
+ else{
140
+ const grounded=await grounderProvider({frame:observed.frame,query});
141
+ insist(grounded&&grounded.status==='ok'&&HEX64.test(grounded.query_sha256??''),'desktop wait UIA result invalid');
142
+ const candidate=grounded.matches?.[grounded.ordinal??0]??null;
143
+ const actionable=Boolean(candidate?.enabled===true&&!candidate?.offscreen);
144
+ match=Object.freeze({query_sha256:grounded.query_sha256,query_kind:grounded.query_kind,
145
+ match_count:Array.isArray(grounded.matches)?grounded.matches.length:0,actionable,
146
+ visited:grounded.visited,truncated:grounded.truncated,provider_receipt_sha256:grounded.provider_receipt_sha256});
147
+ satisfied=until==='uia_present'?actionable:!actionable;
148
+ }
149
+ const elapsed=Math.max(0,clockMs()-started);
150
+ if(satisfied||elapsed>=timeoutMs)break;
151
+ await sleeper(Math.min(pollMs,timeoutMs-elapsed));
152
+ }
153
+ const elapsedMs=Math.max(0,clockMs()-started);
154
+ const previewValue=preview?observerRuntime.framePreview?.(observed.frame.frame_id,{maxBytes:policy.limits.max_preview_bytes}):null;
155
+ if(preview)insist(previewValue?.schema==='deadbyte.desktop-preview.v1','desktop preview unavailable');
156
+ const payload={condition:until,satisfied,attempts,elapsed_ms:elapsedMs,baseline_frame_id:baseline.frame_id,
157
+ frame_id:observed.frame.frame_id,desktop_epoch:observed.frame.desktop_epoch,topology_sha256:observed.frame.topology_sha256,
158
+ image_sha256:observed.frame.image_sha256,observed_at_utc:observed.frame.observed_at_utc,active_window:observed.frame.active_window,
159
+ match,preview:previewValue?{sha256:previewValue.sha256,byte_length:previewValue.byte_length,width:previewValue.width,height:previewValue.height,encoding:previewValue.encoding}:null};
160
+ const evidence=await receipt('desktop_wait_observation',payload,observed.frame.observed_at_utc);
161
+ return Object.freeze({status:'ok',condition:until,satisfied,timed_out:!satisfied,attempts,elapsed_ms:elapsedMs,
162
+ baseline_frame_id:baseline.frame_id,frame:observed.frame,match,...(previewValue?{preview:previewValue}:{}),
163
+ receipt_id:evidence.receipt_id,receipt_sha256:evidence.receipt_sha256});
164
+ }
121
165
  function targetFor(targetId){
122
166
  insist(HEX64.test(targetId??''),'targetId invalid');
123
167
  const found=targets.get(targetId);if(!found)throw new Error('desktop target expired or unknown');return found;
@@ -314,5 +358,5 @@ export function createDesktopRuntime({
314
358
  throw wrapped;
315
359
  }
316
360
  }
317
- return Object.freeze({status,observe,target,ground,action,verifyReceipt});
361
+ return Object.freeze({status,observe,wait,target,ground,action,verifyReceipt});
318
362
  }
@@ -1,5 +1,6 @@
1
1
  import { createHash, randomBytes } from 'node:crypto';
2
2
  import { Client, StreamableHTTPClientTransport } from '@modelcontextprotocol/client';
3
+ import { verifyMachinePingPublic } from './machine-identity.mjs';
3
4
 
4
5
  const endpointText = process.argv[2];
5
6
  const mode = process.argv[3] ?? 'smoke';
@@ -151,6 +152,11 @@ try {
151
152
  ping.release_id !== machine.release_id || ping.release_manifest_sha256 !== machine.release_manifest_sha256) {
152
153
  throw new Error('compact machine ping binding mismatch');
153
154
  }
155
+ const pingSignatureValid = await verifyMachinePingPublic({
156
+ ping,
157
+ publicKeySpkiBase64: machine.public_key_spki_base64
158
+ });
159
+ if (!pingSignatureValid) throw new Error('machine ping public Ed25519 verification failed');
154
160
  compact = {
155
161
  profile: 'compact',
156
162
  ledger_sha256: manifest.ledger_sha256,
@@ -160,7 +166,7 @@ try {
160
166
  machine_id: machine.machine_id,
161
167
  release_id: machine.release_id,
162
168
  release_manifest_sha256: machine.release_manifest_sha256,
163
- ping_signature_valid: ping.signature_valid === true
169
+ ping_signature_valid: true
164
170
  };
165
171
  } else {
166
172
  const opened = structured(await client.callTool({ name: 'workspace_open', arguments: { workspace_id: 'demo' } }), 'workspace_open');
@@ -1,15 +1,23 @@
1
1
  import { readFile } from 'node:fs/promises';
2
+ import { createHash } from 'node:crypto';
2
3
  import path from 'node:path';
3
4
  import { fileURLToPath } from 'node:url';
4
5
  import { R36_CAPABILITY_LEDGER } from './capability-ledger.mjs';
5
6
 
6
7
  const packageRoot=path.resolve(path.dirname(fileURLToPath(import.meta.url)),'..');
7
8
  const catalogPath=path.join(packageRoot,'docs','R48-FULL-TOOL-CATALOG.json');
9
+ const overlayPath=path.join(packageRoot,'docs','R49-FULL-TOOL-CATALOG.json');
8
10
  const AGENT_TOOLS=new Set(['agent_task_approve','agent_task_cancel','agent_task_events','agent_task_run','agent_task_status','agent_task_submit','agent_task_verify']);
9
11
 
10
12
  export async function expectedFullCatalogForEnv(env){
11
13
  const canonical=JSON.parse(await readFile(catalogPath,'utf8'));
12
14
  if(canonical.schema!=='deadbyte.r48-full-catalog.v1'||canonical.tool_count!==canonical.tools?.length) throw new Error('canonical R48 full catalog is invalid');
15
+ const overlay=JSON.parse(await readFile(overlayPath,'utf8'));
16
+ const baseSha=createHash('sha256').update(await readFile(catalogPath)).digest('hex');
17
+ if(overlay.schema!=='deadbyte.r49-full-catalog-overlay.v1'||overlay.base?.sha256!==baseSha||overlay.base?.tool_count!==canonical.tool_count||
18
+ overlay.tool_count!==canonical.tool_count+overlay.additions.length-overlay.removals.length) throw new Error('canonical R49 full catalog overlay is invalid');
19
+ const full=[...new Set([...canonical.tools.filter(name=>!overlay.removals.includes(name)),...overlay.additions])].sort((a,b)=>a.localeCompare(b,'en'));
20
+ if(full.length!==overlay.tool_count) throw new Error('canonical R49 full catalog count mismatch');
13
21
  const disabled=new Set();
14
22
  for(const capability of R36_CAPABILITY_LEDGER.entries){
15
23
  const flag=capability.runtime_flag;
@@ -21,7 +29,7 @@ export async function expectedFullCatalogForEnv(env){
21
29
  if(env.DEADBYTE_CODING_RUNTIME==='1') disabled.delete('coding_symbol_rename_preview');
22
30
  if(env.DEADBYTE_AGENT_RUNTIME!=='1') for(const name of AGENT_TOOLS) disabled.add(name);
23
31
  if(env.DEADBYTE_PROCESS_RUNTIME!=='1') disabled.add('process_session_cancel');
24
- return canonical.tools.filter(name=>!disabled.has(name));
32
+ return full.filter(name=>!disabled.has(name));
25
33
  }
26
34
 
27
35
  export function assertExactCatalog(actual,expected,label='MCP'){
package/src/version.mjs CHANGED
@@ -1,4 +1,4 @@
1
- export const DEADBYTE_VERSION = '0.15.25';
1
+ export const DEADBYTE_VERSION = '0.15.27';
2
2
  export const MCP_PROTOCOL_VERSION = '2026-07-28';
3
3
  export const RECEIPT_SCHEMA_V1 = 'deadbyte.receipt.v1';
4
4
  export const RECEIPT_SCHEMA_V2 = 'deadbyte.receipt.v2';