@holmes-lab/holmes-kit 0.35.0 → 0.35.2
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/CHANGELOG.md +108 -0
- package/README.md +7 -0
- package/dist/.build-id +1 -1
- package/dist/holmes/cli/approve.js +9 -2
- package/dist/holmes/cli/codex-oracle.js +36 -2
- package/dist/holmes/cli/doctor.d.ts +14 -1
- package/dist/holmes/cli/doctor.js +355 -72
- package/dist/holmes/cli/index.d.ts +1 -1
- package/dist/holmes/cli/index.js +38 -5
- package/dist/holmes/cli/init.d.ts +2 -0
- package/dist/holmes/cli/init.js +37 -1
- package/dist/holmes/cli/runtime-binding-approval.d.ts +7 -0
- package/dist/holmes/cli/runtime-binding-approval.js +102 -0
- package/dist/holmes/cli/runtime-binding.d.ts +45 -0
- package/dist/holmes/cli/runtime-binding.js +630 -0
- package/dist/holmes/governance/approval-grants.d.ts +7 -0
- package/dist/holmes/governance/approval-grants.js +8 -2
- package/dist/holmes/governance/approval-queue.d.ts +2 -0
- package/dist/holmes/governance/approval-queue.js +11 -4
- package/dist/holmes/governance/autonomy.d.ts +9 -0
- package/dist/holmes/governance/autonomy.js +65 -13
- package/dist/holmes/guardrail/risk-classifier.js +76 -26
- package/dist/holmes/guardrail/shell-argument-roles.d.ts +15 -0
- package/dist/holmes/guardrail/shell-argument-roles.js +209 -0
- package/dist/holmes/guardrail/shell-syntax.d.ts +20 -0
- package/dist/holmes/guardrail/shell-syntax.js +489 -0
- package/dist/holmes/guardrail/shell-words.d.ts +2 -18
- package/dist/holmes/guardrail/shell-words.js +15 -441
- package/dist/holmes/guardrail/write-target.d.ts +54 -0
- package/dist/holmes/guardrail/write-target.js +327 -1
- package/dist/holmes/guardrail/write-verb-word.d.ts +13 -0
- package/dist/holmes/guardrail/write-verb-word.js +55 -0
- package/dist/holmes/hooks/pre-tool-use.d.ts +14 -0
- package/dist/holmes/hooks/pre-tool-use.js +391 -66
- package/dist/holmes/mcp/handlers/spec-approval.js +14 -2
- package/dist/holmes/mcp/handlers.d.ts +9 -1
- package/dist/holmes/mcp/handlers.js +6 -4
- package/dist/holmes/mcp/harness-attestation.d.ts +10 -1
- package/dist/holmes/mcp/harness-attestation.js +70 -3
- package/dist/holmes/mcp/operator-recovery.d.ts +9 -0
- package/dist/holmes/mcp/operator-recovery.js +66 -0
- package/dist/holmes/mcp/server.js +6 -3
- package/dist/holmes/runtime/binding.d.ts +30 -0
- package/dist/holmes/runtime/binding.js +164 -0
- package/dist/holmes/runtime/dispatch.d.ts +9 -0
- package/dist/holmes/runtime/dispatch.js +169 -0
- package/dist/holmes/runtime/hook-process.d.ts +11 -0
- package/dist/holmes/runtime/hook-process.js +130 -0
- package/docs/install-guide.md +65 -0
- package/package.json +1 -1
|
@@ -406,7 +406,15 @@ declare function makeRawHandlers(store: SpecStore, opts?: ElicitOpts): {
|
|
|
406
406
|
root: string;
|
|
407
407
|
base?: string;
|
|
408
408
|
head?: string;
|
|
409
|
-
since
|
|
409
|
+
since
|
|
410
|
+
/**
|
|
411
|
+
* A root the caller named that this process cannot read is the CALLER'S mistake, not a fault.
|
|
412
|
+
* @implements A-SPEC-189 §10 (round 11)
|
|
413
|
+
*/
|
|
414
|
+
? /**
|
|
415
|
+
* A root the caller named that this process cannot read is the CALLER'S mistake, not a fault.
|
|
416
|
+
* @implements A-SPEC-189 §10 (round 11)
|
|
417
|
+
*/: string;
|
|
410
418
|
}) => Promise<{
|
|
411
419
|
requirementSemanticWarm?: {
|
|
412
420
|
tier: string;
|
|
@@ -38,7 +38,8 @@ exports.isHandlerRefusal = isHandlerRefusal;
|
|
|
38
38
|
exports.unreadableAmong = unreadableAmong;
|
|
39
39
|
exports.makeHandlers = makeHandlers;
|
|
40
40
|
exports.collectDecisions = collectDecisions;
|
|
41
|
-
// @implements A-SPEC-723, A-SPEC-720, A-SPEC-718, A-SPEC-703, A-SPEC-629, A-SPEC-628, A-SPEC-599, A-SPEC-603, A-SPEC-604, A-SPEC-605, A-SPEC-606, A-SPEC-607, A-SPEC-608, A-SPEC-609, A-SPEC-610, A-SPEC-611, A-SPEC-612, A-SPEC-613, A-SPEC-614, A-SPEC-615, A-SPEC-616, A-SPEC-617, A-SPEC-618, A-SPEC-621, A-SPEC-622, A-SPEC-624, A-SPEC-625, A-SPEC-627, A-SPEC-713, A-SPEC-732
|
|
41
|
+
// @implements A-SPEC-723, A-SPEC-720, A-SPEC-718, A-SPEC-703, A-SPEC-629, A-SPEC-628, A-SPEC-599, A-SPEC-603, A-SPEC-604, A-SPEC-605, A-SPEC-606, A-SPEC-607, A-SPEC-608, A-SPEC-609, A-SPEC-610, A-SPEC-611, A-SPEC-612, A-SPEC-613, A-SPEC-614, A-SPEC-615, A-SPEC-616, A-SPEC-617, A-SPEC-618, A-SPEC-621, A-SPEC-622, A-SPEC-624, A-SPEC-625, A-SPEC-627, A-SPEC-713, A-SPEC-732, A-SPEC-754
|
|
42
|
+
const operator_recovery_1 = require("./operator-recovery");
|
|
42
43
|
// @implements A-SPEC-643
|
|
43
44
|
// @implements A-SPEC-642
|
|
44
45
|
// @implements A-SPEC-642
|
|
@@ -213,7 +214,7 @@ function resolveHandlerApproval(rootArg, store, envApproval, action, now) {
|
|
|
213
214
|
const r = (0, approval_grants_1.resolveApproval)(root, envApproval, action, now);
|
|
214
215
|
return r ? { ...r, root } : undefined;
|
|
215
216
|
}
|
|
216
|
-
function refusalQueueHint(rootArg, store, req) {
|
|
217
|
+
function refusalQueueHint(rootArg, store, req, operation) {
|
|
217
218
|
try {
|
|
218
219
|
// The SpecStore interface carries no root; the file-backed store exposes one. A store without a
|
|
219
220
|
// root files nothing — the queue lives on disk, and with no disk location there is nothing to do.
|
|
@@ -221,7 +222,8 @@ function refusalQueueHint(rootArg, store, req) {
|
|
|
221
222
|
const base = rootArg !== undefined ? rootArg : (typeof storeRoot === 'string' ? storeRoot : undefined);
|
|
222
223
|
if (base === undefined)
|
|
223
224
|
return '';
|
|
224
|
-
|
|
225
|
+
const root = projectRootOf(base);
|
|
226
|
+
return (0, approval_queue_1.queueHint)(root, req, (0, operator_recovery_1.operatorRecovery)(root, req.target, operation));
|
|
225
227
|
}
|
|
226
228
|
catch {
|
|
227
229
|
return '';
|
|
@@ -873,7 +875,7 @@ function makeRawHandlers(store, opts) {
|
|
|
873
875
|
prepareHostApproval,
|
|
874
876
|
consumeHostApproval,
|
|
875
877
|
resolveHandlerApproval: (root, approval, action, now) => resolveHandlerApproval(root, store, approval, action, now),
|
|
876
|
-
refusalQueueHint: (root, request) => refusalQueueHint(root, store, request),
|
|
878
|
+
refusalQueueHint: (root, request) => refusalQueueHint(root, store, request, 'spec_approve'),
|
|
877
879
|
foreignRootReason: (root) => foreignRootReason(store, root),
|
|
878
880
|
});
|
|
879
881
|
/**
|
|
@@ -14,7 +14,16 @@ export interface HarnessAttestation {
|
|
|
14
14
|
harness?: string;
|
|
15
15
|
reason?: string;
|
|
16
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* @implements A-SPEC-751.3 — is `script` one of the operator runtime registry's own MCP dispatcher files, unchanged
|
|
19
|
+
* since its installation receipt. Measured 2026-10-04: A-SPEC-751 starts the server through
|
|
20
|
+
* `node <registry dir>/<harness>-mcp.js`; the walk below read that as a plain node script and stopped, so in-session
|
|
21
|
+
* approval was switched off on every workspace of a registered machine. Any read or parse failure is "no".
|
|
22
|
+
* Limit, stated: the receipt and the file are writable by the operator's own account — this shows the launcher is the
|
|
23
|
+
* installed dispatcher, not that the account is uncompromised (the trust the image check already rests on).
|
|
24
|
+
*/
|
|
25
|
+
export declare function dispatcherVerifier(registryPath: string): (script: string) => boolean;
|
|
17
26
|
/** Walk up from `pid` (the server's parent) through launchers to a harness executable. */
|
|
18
|
-
export declare function attestHarness(pid: number, lookup: ProcLookup, maxDepth?: number): HarnessAttestation;
|
|
27
|
+
export declare function attestHarness(pid: number, lookup: ProcLookup, maxDepth?: number, isDispatcher?: (script: string) => boolean): HarnessAttestation;
|
|
19
28
|
/** The live process table: `ps` on POSIX, CIM through PowerShell on Windows. Null when unreadable. */
|
|
20
29
|
export declare function systemProcLookup(platform?: NodeJS.Platform): ProcLookup;
|
|
@@ -33,9 +33,10 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.dispatcherVerifier = dispatcherVerifier;
|
|
36
37
|
exports.attestHarness = attestHarness;
|
|
37
38
|
exports.systemProcLookup = systemProcLookup;
|
|
38
|
-
// @implements A-SPEC-732
|
|
39
|
+
// @implements A-SPEC-732, A-SPEC-751.3
|
|
39
40
|
// In-session approval (a form, or the host-gated continuation) trusts the client that answers it. An
|
|
40
41
|
// agent can start its own copy of this server, name itself `claude-code` and answer for a person
|
|
41
42
|
// (measured, H7 round 1). So before offering either route, the server asks who launched it: the
|
|
@@ -50,6 +51,7 @@ exports.systemProcLookup = systemProcLookup;
|
|
|
50
51
|
const fs = __importStar(require("node:fs"));
|
|
51
52
|
const path = __importStar(require("node:path"));
|
|
52
53
|
const node_child_process_1 = require("node:child_process");
|
|
54
|
+
const node_crypto_1 = require("node:crypto");
|
|
53
55
|
const HARNESS_EXES = new Set(['claude', 'codex', 'agy', 'antigravity']);
|
|
54
56
|
const imageName = (image) => path.win32.basename(path.posix.basename(image)).toLowerCase().replace(/\.exe$/, '');
|
|
55
57
|
/** `agy` and `antigravity` name the same harness. */
|
|
@@ -101,8 +103,66 @@ function isLauncher(args) {
|
|
|
101
103
|
}
|
|
102
104
|
return false;
|
|
103
105
|
}
|
|
106
|
+
const NODE_PROGRAM_OPTIONS = new Set(['-e', '-p', '-r', '--eval', '--print', '--require', '--import', '--loader', '--experimental-loader']);
|
|
107
|
+
/** Quote-aware words of a process's argument string (the first is the executable). */
|
|
108
|
+
function argWords(args) {
|
|
109
|
+
const out = [];
|
|
110
|
+
const re = /"([^"]*)"|'([^']*)'|(\S+)/g;
|
|
111
|
+
for (let m = re.exec(args); m !== null; m = re.exec(args))
|
|
112
|
+
out.push(m[1] ?? m[2] ?? m[3]);
|
|
113
|
+
return out;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* @implements A-SPEC-751.3 — the script a `node` process runs, or null when an option names a program or a preload
|
|
117
|
+
* (`-e`, `-r`, `--require`, `--import`, `--loader` …: such a process runs something other than its script).
|
|
118
|
+
* Options that take no program are stepped over; `--` ends options.
|
|
119
|
+
*/
|
|
120
|
+
function nodeScriptOf(args) {
|
|
121
|
+
const words = argWords(args).slice(1);
|
|
122
|
+
for (let i = 0; i < words.length; i++) {
|
|
123
|
+
const w = words[i];
|
|
124
|
+
if (w === '--')
|
|
125
|
+
return words[i + 1] ?? null;
|
|
126
|
+
if (!w.startsWith('-'))
|
|
127
|
+
return w;
|
|
128
|
+
if (NODE_PROGRAM_OPTIONS.has(w.split('=')[0]) || !w.startsWith('--'))
|
|
129
|
+
return null;
|
|
130
|
+
}
|
|
131
|
+
return null;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* @implements A-SPEC-751.3 — is `script` one of the operator runtime registry's own MCP dispatcher files, unchanged
|
|
135
|
+
* since its installation receipt. Measured 2026-10-04: A-SPEC-751 starts the server through
|
|
136
|
+
* `node <registry dir>/<harness>-mcp.js`; the walk below read that as a plain node script and stopped, so in-session
|
|
137
|
+
* approval was switched off on every workspace of a registered machine. Any read or parse failure is "no".
|
|
138
|
+
* Limit, stated: the receipt and the file are writable by the operator's own account — this shows the launcher is the
|
|
139
|
+
* installed dispatcher, not that the account is uncompromised (the trust the image check already rests on).
|
|
140
|
+
*/
|
|
141
|
+
function dispatcherVerifier(registryPath) {
|
|
142
|
+
return (script) => {
|
|
143
|
+
try {
|
|
144
|
+
if (!path.isAbsolute(script))
|
|
145
|
+
return false;
|
|
146
|
+
const dir = fs.realpathSync.native(path.dirname(registryPath));
|
|
147
|
+
const real = fs.realpathSync.native(script);
|
|
148
|
+
if (path.dirname(real) !== dir || !/^(?:claude|codex|antigravity)-mcp\.js$/.test(path.basename(real)))
|
|
149
|
+
return false;
|
|
150
|
+
const st = fs.lstatSync(real);
|
|
151
|
+
if (!st.isFile() || st.size > 1024 * 1024)
|
|
152
|
+
return false;
|
|
153
|
+
const rows = JSON.parse(fs.readFileSync(path.join(dir, 'installation.json'), 'utf8')).files;
|
|
154
|
+
if (!Array.isArray(rows))
|
|
155
|
+
return false;
|
|
156
|
+
const digest = (0, node_crypto_1.createHash)('sha256').update(fs.readFileSync(real, 'utf8')).digest('hex');
|
|
157
|
+
return rows.some((r) => !!r && typeof r === 'object' && r.path === real && r.digest === digest);
|
|
158
|
+
}
|
|
159
|
+
catch {
|
|
160
|
+
return false;
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
}
|
|
104
164
|
/** Walk up from `pid` (the server's parent) through launchers to a harness executable. */
|
|
105
|
-
function attestHarness(pid, lookup, maxDepth = 8) {
|
|
165
|
+
function attestHarness(pid, lookup, maxDepth = 8, isDispatcher) {
|
|
106
166
|
const chain = [];
|
|
107
167
|
const seen = new Set();
|
|
108
168
|
let cur = pid;
|
|
@@ -114,8 +174,15 @@ function attestHarness(pid, lookup, maxDepth = 8) {
|
|
|
114
174
|
if (row === null)
|
|
115
175
|
return { attested: false, chain, reason: 'the process table could not be read' };
|
|
116
176
|
const harness = harnessOf(row.args, row.exe);
|
|
117
|
-
|
|
177
|
+
// @implements A-SPEC-751.3 — the receipted runtime dispatcher is a launcher; the chain records the hop as such.
|
|
178
|
+
const viaDispatcher = harness === null && isDispatcher !== undefined && ['node', 'nodejs'].includes(exeName(row.args))
|
|
179
|
+
&& (() => { const script = nodeScriptOf(row.args); return script !== null && isDispatcher(script); })();
|
|
180
|
+
const shown = viaDispatcher ? 'dispatcher' : harness ?? (exeName(row.args) || '?');
|
|
118
181
|
chain.push(shown);
|
|
182
|
+
if (viaDispatcher) {
|
|
183
|
+
cur = row.ppid;
|
|
184
|
+
continue;
|
|
185
|
+
}
|
|
119
186
|
if (harness !== null) {
|
|
120
187
|
if (typeof row.image !== 'string' || row.image === '') {
|
|
121
188
|
return { attested: false, chain, reason: `the executable image of ${shown} could not be read` };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Formatting only: the caller must return pending text only after a successful enqueue. */
|
|
2
|
+
export declare function operatorRecovery(root: string, target: string, operation?: string, options?: {
|
|
3
|
+
platform?: NodeJS.Platform;
|
|
4
|
+
executable?: string;
|
|
5
|
+
cli?: string;
|
|
6
|
+
}): {
|
|
7
|
+
reviewCommand: string;
|
|
8
|
+
pendingHint(id: string): string;
|
|
9
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.operatorRecovery = operatorRecovery;
|
|
37
|
+
// @implements A-SPEC-754, A-SPEC-532.3
|
|
38
|
+
const path = __importStar(require("node:path"));
|
|
39
|
+
const unsafeDisplay = /[\u0000-\u001f\u007f-\u009f\u202a-\u202e\u2066-\u2069]/;
|
|
40
|
+
function literal(value, platform) {
|
|
41
|
+
return platform === 'win32' ? `'${value.replace(/'/g, "''")}'` : `'${value.replace(/'/g, `'\\''`)}'`;
|
|
42
|
+
}
|
|
43
|
+
/** Formatting only: the caller must return pending text only after a successful enqueue. */
|
|
44
|
+
function operatorRecovery(root, target, operation, options) {
|
|
45
|
+
const platform = options?.platform ?? process.platform;
|
|
46
|
+
const executable = options?.executable ?? process.execPath;
|
|
47
|
+
// Both src/holmes/mcp (tests) and dist/holmes/mcp (installed) have the same depth.
|
|
48
|
+
const cli = options?.cli ?? path.resolve(__dirname, '../../..', 'bin/holmes-kit.js');
|
|
49
|
+
const commandSafe = [root, executable, cli].every(value => value.length > 0 && value.length <= 2048 && !unsafeDisplay.test(value));
|
|
50
|
+
const command = commandSafe ? `${platform === 'win32' ? '& ' : ''}${literal(executable, platform)} ${literal(cli, platform)} approve --target ${literal(root, platform)}` : '';
|
|
51
|
+
const display = (value) => JSON.stringify(value.slice(0, 300)).replace(/[\u007f-\u009f\u202a-\u202e\u2066-\u2069]/g, char => `\\u${char.charCodeAt(0).toString(16).padStart(4, '0')}`);
|
|
52
|
+
return {
|
|
53
|
+
reviewCommand: command || 'the installed Holmes-Kit approval UI (path cannot be safely displayed; no command emitted)',
|
|
54
|
+
pendingHint(id) {
|
|
55
|
+
if (!/^req-[a-f0-9]{12}$/.test(id))
|
|
56
|
+
return '';
|
|
57
|
+
if (!command)
|
|
58
|
+
return `\n[승인 대기 ${id}] The request was recorded. Use the installed approval UI; a path exceeds the safe command display limit. No truncated command is provided.`;
|
|
59
|
+
// @implements A-SPEC-532.3 — the resident surface is offered beside the one-off command (owner, 2026-10-04:
|
|
60
|
+
// "why am I still pasting commands"): one key per arriving request.
|
|
61
|
+
return `\n[승인 대기 ${id}] 운영자: ${command} --grant ${literal(id, platform)}`
|
|
62
|
+
+ `\nOr keep the approval surface open and decide each arriving request with one key: ${command} --watch`
|
|
63
|
+
+ `\nAfter official approval, retry ${operation ? display(operation) : 'the original MCP operation'} for target ${display(target)} in the same workspace. Do not retry until approval is available.`;
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.HOOK_ENFORCED_TOOLS = void 0;
|
|
4
|
-
// @implements A-SPEC-720, A-SPEC-718, A-SPEC-625, A-SPEC-564.1, A-SPEC-732, A-SPEC-734
|
|
4
|
+
// @implements A-SPEC-720, A-SPEC-718, A-SPEC-625, A-SPEC-564.1, A-SPEC-732, A-SPEC-734, A-SPEC-751.3
|
|
5
5
|
const index_js_1 = require("@modelcontextprotocol/sdk/server/index.js");
|
|
6
6
|
const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
|
|
7
7
|
const types_js_1 = require("@modelcontextprotocol/sdk/types.js");
|
|
@@ -49,12 +49,15 @@ const elicit = async (req) => {
|
|
|
49
49
|
}
|
|
50
50
|
};
|
|
51
51
|
// @implements A-SPEC-732 (round 2) — who launched this server, asked once, on first need.
|
|
52
|
-
const { attestHarness, systemProcLookup } = require('./harness-attestation');
|
|
52
|
+
const { attestHarness, systemProcLookup, dispatcherVerifier } = require('./harness-attestation');
|
|
53
|
+
// @implements A-SPEC-751.3 — the operator runtime registry's dispatcher is a launcher (it sits between the harness and
|
|
54
|
+
// this server on a registered machine); the path is the registry's fixed default, never taken from the request.
|
|
55
|
+
const runtimeRegistryPath = require('node:path').join(require('node:os').homedir(), '.holmes', 'runtime', 'bindings.json');
|
|
53
56
|
let attested;
|
|
54
57
|
const harnessAttestation = () => {
|
|
55
58
|
if (attested === undefined) {
|
|
56
59
|
try {
|
|
57
|
-
attested = attestHarness(process.ppid, systemProcLookup());
|
|
60
|
+
attested = attestHarness(process.ppid, systemProcLookup(), 8, dispatcherVerifier(runtimeRegistryPath));
|
|
58
61
|
}
|
|
59
62
|
catch {
|
|
60
63
|
attested = { attested: false, chain: [], reason: 'the process table could not be read' };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export interface RuntimeRegistry {
|
|
2
|
+
version: 1;
|
|
3
|
+
releasePackageRoot: string;
|
|
4
|
+
bindings: {
|
|
5
|
+
workspaceRoot: string;
|
|
6
|
+
packageRoot: string;
|
|
7
|
+
}[];
|
|
8
|
+
}
|
|
9
|
+
export interface RuntimeSelection {
|
|
10
|
+
mode: 'development' | 'release';
|
|
11
|
+
workspaceRoot: string;
|
|
12
|
+
packageRoot: string;
|
|
13
|
+
buildId: string;
|
|
14
|
+
specsRoot: string;
|
|
15
|
+
}
|
|
16
|
+
export type RuntimeHarness = 'claude' | 'codex' | 'antigravity';
|
|
17
|
+
export type RuntimeEntry = 'mcp' | 'pre-tool-use' | 'stop';
|
|
18
|
+
export declare const RUNTIME_ENTRIES: string[];
|
|
19
|
+
export declare function readBounded(file: string, max?: number): string;
|
|
20
|
+
export declare function canonicalDirectory(value: string): string;
|
|
21
|
+
export declare function workspaceRoot(cwd: string): string;
|
|
22
|
+
export declare function inside(root: string, target: string): boolean;
|
|
23
|
+
export declare function validateRegistry(input: unknown): RuntimeRegistry;
|
|
24
|
+
export declare function readRuntimeRegistry(file: string): RuntimeRegistry;
|
|
25
|
+
export declare function verifyRuntime(packageRoot: string): string;
|
|
26
|
+
export declare function selectRuntime(registry: RuntimeRegistry, context: {
|
|
27
|
+
cwd: string;
|
|
28
|
+
workspaceHints?: string[];
|
|
29
|
+
specsHint?: string;
|
|
30
|
+
}): RuntimeSelection;
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.RUNTIME_ENTRIES = void 0;
|
|
37
|
+
exports.readBounded = readBounded;
|
|
38
|
+
exports.canonicalDirectory = canonicalDirectory;
|
|
39
|
+
exports.workspaceRoot = workspaceRoot;
|
|
40
|
+
exports.inside = inside;
|
|
41
|
+
exports.validateRegistry = validateRegistry;
|
|
42
|
+
exports.readRuntimeRegistry = readRuntimeRegistry;
|
|
43
|
+
exports.verifyRuntime = verifyRuntime;
|
|
44
|
+
exports.selectRuntime = selectRuntime;
|
|
45
|
+
// @implements A-SPEC-751
|
|
46
|
+
const fs = __importStar(require("node:fs"));
|
|
47
|
+
const path = __importStar(require("node:path"));
|
|
48
|
+
exports.RUNTIME_ENTRIES = ['bin/holmes-mcp.js', 'bin/holmes-hook-antigravity.js', 'bin/holmes-stop-antigravity.js',
|
|
49
|
+
'dist/holmes/hooks/pre-tool-use.js', 'dist/holmes/hooks/stop.js'];
|
|
50
|
+
function readBounded(file, max = 2 * 1024 * 1024) {
|
|
51
|
+
// O_NONBLOCK prevents a raced FIFO from holding a lifecycle hook indefinitely.
|
|
52
|
+
const fd = fs.openSync(file, fs.constants.O_RDONLY | (fs.constants.O_NONBLOCK ?? 0));
|
|
53
|
+
try {
|
|
54
|
+
const st = fs.fstatSync(fd);
|
|
55
|
+
if (!st.isFile() || st.size > max)
|
|
56
|
+
throw new Error(`Not a bounded regular file: ${file}`);
|
|
57
|
+
const bytes = Buffer.alloc(max + 1);
|
|
58
|
+
let length = 0;
|
|
59
|
+
while (length < bytes.length) {
|
|
60
|
+
const n = fs.readSync(fd, bytes, length, bytes.length - length, null);
|
|
61
|
+
if (!n)
|
|
62
|
+
break;
|
|
63
|
+
length += n;
|
|
64
|
+
}
|
|
65
|
+
if (length > max)
|
|
66
|
+
throw new Error(`File exceeds size limit: ${file}`);
|
|
67
|
+
return new TextDecoder('utf-8', { fatal: true }).decode(bytes.subarray(0, length));
|
|
68
|
+
}
|
|
69
|
+
finally {
|
|
70
|
+
fs.closeSync(fd);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
function canonicalDirectory(value) {
|
|
74
|
+
if (typeof value !== 'string' || !path.isAbsolute(value))
|
|
75
|
+
throw new Error('Runtime paths must be absolute');
|
|
76
|
+
const real = fs.realpathSync.native(value);
|
|
77
|
+
if (!fs.statSync(real).isDirectory())
|
|
78
|
+
throw new Error(`Not a directory: ${value}`);
|
|
79
|
+
return real;
|
|
80
|
+
}
|
|
81
|
+
function workspaceRoot(cwd) {
|
|
82
|
+
const initial = canonicalDirectory(cwd);
|
|
83
|
+
for (let at = initial;; at = path.dirname(at)) {
|
|
84
|
+
if (fs.existsSync(path.join(at, '.ax')) || fs.existsSync(path.join(at, '.git')))
|
|
85
|
+
return at;
|
|
86
|
+
if (path.dirname(at) === at)
|
|
87
|
+
return initial;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
function inside(root, target) {
|
|
91
|
+
const rel = path.relative(root, target);
|
|
92
|
+
return rel === '' || (!path.isAbsolute(rel) && rel !== '..' && !rel.startsWith(`..${path.sep}`));
|
|
93
|
+
}
|
|
94
|
+
function validateRegistry(input) {
|
|
95
|
+
const r = input;
|
|
96
|
+
if (!r || r.version !== 1 || !Array.isArray(r.bindings) || r.bindings.length > 1000)
|
|
97
|
+
throw new Error('Invalid runtime registry schema');
|
|
98
|
+
const canonical = (p) => {
|
|
99
|
+
const c = canonicalDirectory(p);
|
|
100
|
+
if (c !== p)
|
|
101
|
+
throw new Error(`Registry path is no longer canonical: ${p}; register its current location explicitly`);
|
|
102
|
+
return c;
|
|
103
|
+
};
|
|
104
|
+
const releasePackageRoot = canonical(r.releasePackageRoot);
|
|
105
|
+
const seen = new Set();
|
|
106
|
+
const bindings = r.bindings.map((b) => {
|
|
107
|
+
if (!b || typeof b !== 'object')
|
|
108
|
+
throw new Error('Invalid runtime binding');
|
|
109
|
+
const root = canonical(b.workspaceRoot);
|
|
110
|
+
if (seen.has(root))
|
|
111
|
+
throw new Error(`Duplicate runtime binding: ${root}`);
|
|
112
|
+
seen.add(root);
|
|
113
|
+
return { workspaceRoot: root, packageRoot: canonical(b.packageRoot) };
|
|
114
|
+
});
|
|
115
|
+
return { version: 1, releasePackageRoot, bindings };
|
|
116
|
+
}
|
|
117
|
+
function readRuntimeRegistry(file) {
|
|
118
|
+
if (!path.isAbsolute(file))
|
|
119
|
+
throw new Error('Runtime registry path must be absolute');
|
|
120
|
+
try {
|
|
121
|
+
return validateRegistry(JSON.parse(readBounded(file)));
|
|
122
|
+
}
|
|
123
|
+
catch (e) {
|
|
124
|
+
throw new Error(`Cannot use runtime registry ${file}: ${e.message}. Repair runtime-binding setup.`);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
function verifyRuntime(packageRoot) {
|
|
128
|
+
try {
|
|
129
|
+
const pkg = JSON.parse(readBounded(path.join(packageRoot, 'package.json'), 128 * 1024));
|
|
130
|
+
if (pkg.name !== '@holmes-lab/holmes-kit')
|
|
131
|
+
throw new Error('Unexpected package name');
|
|
132
|
+
for (const relative of exports.RUNTIME_ENTRIES) {
|
|
133
|
+
const entry = fs.realpathSync.native(path.join(packageRoot, relative));
|
|
134
|
+
if (!inside(packageRoot, entry) || !fs.statSync(entry).isFile())
|
|
135
|
+
throw new Error(`Invalid entrypoint ${relative}`);
|
|
136
|
+
}
|
|
137
|
+
const buildId = readBounded(path.join(packageRoot, 'dist/.build-id'), 1024).trim();
|
|
138
|
+
if (!buildId || /[\x00-\x1f\x7f]/.test(buildId))
|
|
139
|
+
throw new Error('Invalid build identity');
|
|
140
|
+
return buildId;
|
|
141
|
+
}
|
|
142
|
+
catch (e) {
|
|
143
|
+
throw new Error(`Runtime build unavailable at ${packageRoot}: ${e.message}. Run npm run build in that checkout or repair the installed package; no release fallback.`);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
function selectRuntime(registry, context) {
|
|
147
|
+
const checked = validateRegistry(registry);
|
|
148
|
+
const root = workspaceRoot(context.cwd);
|
|
149
|
+
for (const hint of context.workspaceHints ?? []) {
|
|
150
|
+
if (workspaceRoot(hint) !== root)
|
|
151
|
+
throw new Error('Conflicting runtime workspace hints; repair harness wiring');
|
|
152
|
+
}
|
|
153
|
+
const specsRoot = path.join(root, '.ax', 'specs');
|
|
154
|
+
const governanceRoot = path.join(root, '.ax');
|
|
155
|
+
if (fs.existsSync(governanceRoot) && !inside(root, fs.realpathSync.native(governanceRoot)))
|
|
156
|
+
throw new Error('Governance directory escapes the selected workspace');
|
|
157
|
+
if (context.specsHint && path.resolve(root, context.specsHint) !== specsRoot)
|
|
158
|
+
throw new Error('Conflicting HOLMES_SPECS; remove the fixed spec-store override');
|
|
159
|
+
if (fs.existsSync(specsRoot) && !inside(root, fs.realpathSync.native(specsRoot)))
|
|
160
|
+
throw new Error('Spec store escapes the selected workspace');
|
|
161
|
+
const binding = checked.bindings.find((b) => b.workspaceRoot === root);
|
|
162
|
+
const packageRoot = binding?.packageRoot ?? checked.releasePackageRoot;
|
|
163
|
+
return { mode: binding ? 'development' : 'release', workspaceRoot: root, packageRoot, buildId: verifyRuntime(packageRoot), specsRoot };
|
|
164
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { RuntimeHarness, RuntimeEntry } from './binding';
|
|
2
|
+
export interface DispatchOptions {
|
|
3
|
+
registryPath: string;
|
|
4
|
+
harness: RuntimeHarness;
|
|
5
|
+
entry: RuntimeEntry;
|
|
6
|
+
hookBudgetMs?: number;
|
|
7
|
+
cleanupBudgetMs?: number;
|
|
8
|
+
}
|
|
9
|
+
export declare function runDispatch(opts: DispatchOptions): Promise<void>;
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.runDispatch = runDispatch;
|
|
37
|
+
// @implements A-SPEC-751, A-SPEC-751.1, A-SPEC-754
|
|
38
|
+
const path = __importStar(require("node:path"));
|
|
39
|
+
const node_child_process_1 = require("node:child_process");
|
|
40
|
+
const binding_1 = require("./binding");
|
|
41
|
+
const hook_process_1 = require("./hook-process");
|
|
42
|
+
function hookInput(budget) {
|
|
43
|
+
return new Promise((resolve, reject) => {
|
|
44
|
+
const chunks = [];
|
|
45
|
+
let length = 0;
|
|
46
|
+
const timeout = setTimeout(() => finish(new Error('Hook input deadline exceeded')), budget);
|
|
47
|
+
const finish = (error) => {
|
|
48
|
+
clearTimeout(timeout);
|
|
49
|
+
process.stdin.removeListener('data', data);
|
|
50
|
+
process.stdin.removeListener('end', end);
|
|
51
|
+
process.stdin.removeListener('error', fail);
|
|
52
|
+
process.stdin.pause();
|
|
53
|
+
if (error)
|
|
54
|
+
reject(error);
|
|
55
|
+
else
|
|
56
|
+
resolve(Buffer.concat(chunks));
|
|
57
|
+
};
|
|
58
|
+
const data = (chunk) => { length += chunk.length; if (length > 2 * 1024 * 1024)
|
|
59
|
+
finish(new Error('Hook input exceeds 2 MiB'));
|
|
60
|
+
else
|
|
61
|
+
chunks.push(chunk); };
|
|
62
|
+
const end = () => finish();
|
|
63
|
+
const fail = (error) => finish(error);
|
|
64
|
+
process.stdin.on('data', data).once('end', end).once('error', fail);
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
function hintsFromInput(input) {
|
|
68
|
+
const value = JSON.parse(new TextDecoder('utf-8', { fatal: true }).decode(input));
|
|
69
|
+
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
70
|
+
throw new Error('Invalid hook input object');
|
|
71
|
+
const hints = [];
|
|
72
|
+
for (const name of ['cwd', 'project_dir']) {
|
|
73
|
+
if (value[name] !== undefined) {
|
|
74
|
+
if (typeof value[name] !== 'string' || !value[name])
|
|
75
|
+
throw new Error(`Invalid hook ${name}`);
|
|
76
|
+
hints.push(value[name]);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
if (value.workspacePaths !== undefined) {
|
|
80
|
+
if (!Array.isArray(value.workspacePaths) || !value.workspacePaths.length || value.workspacePaths.some((v) => typeof v !== 'string' || !v))
|
|
81
|
+
throw new Error('Invalid workspacePaths');
|
|
82
|
+
hints.push(...value.workspacePaths);
|
|
83
|
+
}
|
|
84
|
+
return hints;
|
|
85
|
+
}
|
|
86
|
+
async function runDispatch(opts) {
|
|
87
|
+
const started = performance.now();
|
|
88
|
+
let selectedBuild;
|
|
89
|
+
let selectedPackage;
|
|
90
|
+
let selectedWorkspace = process.cwd();
|
|
91
|
+
try {
|
|
92
|
+
if (!['claude', 'codex', 'antigravity'].includes(opts.harness) || !['mcp', 'pre-tool-use', 'stop'].includes(opts.entry))
|
|
93
|
+
throw new Error('Invalid runtime dispatcher entry or harness');
|
|
94
|
+
const hookBudget = (0, hook_process_1.boundedHookBudget)(opts.hookBudgetMs, hook_process_1.HOOK_BUDGET_MS);
|
|
95
|
+
const cleanupBudget = (0, hook_process_1.boundedHookBudget)(opts.cleanupBudgetMs, hook_process_1.HOOK_CLEANUP_MS);
|
|
96
|
+
const input = opts.entry === 'mcp' ? undefined : await hookInput(hookBudget);
|
|
97
|
+
const hints = input ? hintsFromInput(input) : [];
|
|
98
|
+
if (process.env.CLAUDE_PROJECT_DIR)
|
|
99
|
+
hints.push(process.env.CLAUDE_PROJECT_DIR);
|
|
100
|
+
const selection = (0, binding_1.selectRuntime)((0, binding_1.readRuntimeRegistry)(opts.registryPath), { cwd: process.cwd(), workspaceHints: hints, specsHint: process.env.HOLMES_SPECS });
|
|
101
|
+
selectedBuild = selection.buildId;
|
|
102
|
+
selectedPackage = selection.packageRoot;
|
|
103
|
+
selectedWorkspace = selection.workspaceRoot;
|
|
104
|
+
const relative = opts.entry === 'mcp' ? 'bin/holmes-mcp.js'
|
|
105
|
+
: opts.harness === 'antigravity' ? (opts.entry === 'stop' ? 'bin/holmes-stop-antigravity.js' : 'bin/holmes-hook-antigravity.js')
|
|
106
|
+
: `dist/holmes/hooks/${opts.entry}.js`;
|
|
107
|
+
const remaining = hookBudget - (performance.now() - started);
|
|
108
|
+
if (input && remaining <= 0)
|
|
109
|
+
throw new Error('Hook input/selection deadline exceeded');
|
|
110
|
+
if (opts.entry === 'mcp') {
|
|
111
|
+
// This is a dedicated transport process, not a reusable multi-server host.
|
|
112
|
+
// Keep its genuine parent and argv for native attestation. The selected
|
|
113
|
+
// entry still owns build validation, package dependencies and autoreload.
|
|
114
|
+
process.chdir(selection.workspaceRoot);
|
|
115
|
+
process.env.HOLMES_SPECS = selection.specsRoot;
|
|
116
|
+
process.env.CLAUDE_PROJECT_DIR = selection.workspaceRoot;
|
|
117
|
+
require(path.join(selection.packageRoot, relative));
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
const child = (0, node_child_process_1.spawn)(process.execPath, [path.join(selection.packageRoot, relative)], {
|
|
121
|
+
cwd: selection.workspaceRoot,
|
|
122
|
+
env: { ...process.env, HOLMES_SPECS: selection.specsRoot, CLAUDE_PROJECT_DIR: selection.workspaceRoot },
|
|
123
|
+
stdio: ['pipe', input ? 'pipe' : 'inherit', 'inherit'],
|
|
124
|
+
detached: input !== undefined && process.platform !== 'win32', windowsHide: true,
|
|
125
|
+
});
|
|
126
|
+
if (input) {
|
|
127
|
+
const result = await (0, hook_process_1.runHookChild)(child, input, remaining, cleanupBudget);
|
|
128
|
+
if (result.signal) {
|
|
129
|
+
process.kill(process.pid, result.signal);
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
if (!result.bytes.length && result.code !== 0)
|
|
133
|
+
throw new Error(`Selected hook runtime failed (exit ${result.code}) without a decision`);
|
|
134
|
+
if (result.bytes.length) {
|
|
135
|
+
try {
|
|
136
|
+
JSON.parse(new TextDecoder('utf-8', { fatal: true }).decode(result.bytes));
|
|
137
|
+
}
|
|
138
|
+
catch {
|
|
139
|
+
throw new Error('Selected hook runtime returned invalid JSON');
|
|
140
|
+
}
|
|
141
|
+
process.stdout.write(result.bytes);
|
|
142
|
+
}
|
|
143
|
+
process.exitCode = result.code ?? 1;
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
catch (error) {
|
|
148
|
+
const shellWord = (word) => process.platform === 'win32' ? JSON.stringify(word) : `'${word.replace(/'/g, `'\\''`)}'`;
|
|
149
|
+
const cli = selectedPackage ? `${shellWord(process.execPath)} ${shellWord(path.join(selectedPackage, 'bin/holmes-kit.js'))}` : 'holmes-kit';
|
|
150
|
+
const recovery = opts.entry === 'mcp' ? '' : ` [${opts.harness}/${opts.entry}${selectedBuild ? ` build ${selectedBuild}` : ''}]. Diagnose with ${cli} runtime-binding status --workspace ${shellWord(selectedWorkspace)} --registry ${shellWord(opts.registryPath)} and ${cli} doctor --target ${shellWord(selectedWorkspace)} --registry ${shellWord(opts.registryPath)}. Repair the selected runtime through the approved installation workflow, then retry the original operation. Pending governance findings remain unresolved.`;
|
|
151
|
+
const reason = `[Holmes-Kit] Runtime dispatch refused: ${error.message}${recovery}`;
|
|
152
|
+
process.stderr.write(`${reason}\n`);
|
|
153
|
+
// A partially loaded entry may have opened handles; exitCode alone would
|
|
154
|
+
// leave a failed transport alive indefinitely.
|
|
155
|
+
if (opts.entry === 'mcp') {
|
|
156
|
+
process.exit(1);
|
|
157
|
+
}
|
|
158
|
+
const output = opts.harness === 'antigravity' ? { decision: opts.entry === 'stop' ? 'continue' : 'deny', reason }
|
|
159
|
+
: opts.entry === 'stop' ? { decision: 'block', reason }
|
|
160
|
+
: { hookSpecificOutput: { hookEventName: 'PreToolUse', permissionDecision: 'deny', permissionDecisionReason: reason } };
|
|
161
|
+
process.stdout.write(`${JSON.stringify(output)}\n`);
|
|
162
|
+
process.exitCode = 0;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
if (require.main === module) {
|
|
166
|
+
const args = process.argv.slice(2);
|
|
167
|
+
const value = (name) => args[args.indexOf(name) + 1];
|
|
168
|
+
void runDispatch({ registryPath: value('--registry'), harness: value('--harness'), entry: value('--entry') });
|
|
169
|
+
}
|