@inventarch/distribution 0.0.0-stage → 1.0.0
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/LICENSE +202 -0
- package/NOTICE +4 -0
- package/README.md +2 -2
- package/SPEC.md +3 -0
- package/assets/host-launcher.mjs +167 -0
- package/dist/acquire.d.ts +13 -0
- package/dist/acquire.d.ts.map +1 -0
- package/dist/acquire.js +46 -0
- package/dist/acquire.js.map +1 -0
- package/dist/archive.d.ts +20 -0
- package/dist/archive.d.ts.map +1 -0
- package/dist/archive.js +158 -0
- package/dist/archive.js.map +1 -0
- package/dist/authoring-assets.d.ts +11 -0
- package/dist/authoring-assets.d.ts.map +1 -0
- package/dist/authoring-assets.js +251 -0
- package/dist/authoring-assets.js.map +1 -0
- package/dist/bounded-fetch.d.ts +17 -0
- package/dist/bounded-fetch.d.ts.map +1 -0
- package/dist/bounded-fetch.js +67 -0
- package/dist/bounded-fetch.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +29 -0
- package/dist/cli.js.map +1 -0
- package/dist/command.d.ts +6 -0
- package/dist/command.d.ts.map +1 -0
- package/dist/command.js +189 -0
- package/dist/command.js.map +1 -0
- package/dist/config.d.ts +4 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +43 -0
- package/dist/config.js.map +1 -0
- package/dist/decisions.d.ts +26 -0
- package/dist/decisions.d.ts.map +1 -0
- package/dist/decisions.js +119 -0
- package/dist/decisions.js.map +1 -0
- package/dist/files.d.ts +38 -0
- package/dist/files.d.ts.map +1 -0
- package/dist/files.js +224 -0
- package/dist/files.js.map +1 -0
- package/dist/guard-registration.d.ts +95 -0
- package/dist/guard-registration.d.ts.map +1 -0
- package/dist/guard-registration.js +282 -0
- package/dist/guard-registration.js.map +1 -0
- package/dist/host-home.d.ts +33 -0
- package/dist/host-home.d.ts.map +1 -0
- package/dist/host-home.js +116 -0
- package/dist/host-home.js.map +1 -0
- package/dist/host-modes.d.ts +13 -0
- package/dist/host-modes.d.ts.map +1 -0
- package/dist/host-modes.js +36 -0
- package/dist/host-modes.js.map +1 -0
- package/dist/host-observe.d.ts +24 -0
- package/dist/host-observe.d.ts.map +1 -0
- package/dist/host-observe.js +233 -0
- package/dist/host-observe.js.map +1 -0
- package/dist/host.d.ts +100 -0
- package/dist/host.d.ts.map +1 -0
- package/dist/host.js +505 -0
- package/dist/host.js.map +1 -0
- package/dist/hosts.d.ts +66 -0
- package/dist/hosts.d.ts.map +1 -0
- package/dist/hosts.js +39 -0
- package/dist/hosts.js.map +1 -0
- package/dist/ia-home.d.ts +15 -0
- package/dist/ia-home.d.ts.map +1 -0
- package/dist/ia-home.js +101 -0
- package/dist/ia-home.js.map +1 -0
- package/dist/install.d.ts +56 -0
- package/dist/install.d.ts.map +1 -0
- package/dist/install.js +402 -0
- package/dist/install.js.map +1 -0
- package/dist/installation-core.d.ts +41 -0
- package/dist/installation-core.d.ts.map +1 -0
- package/dist/installation-core.js +163 -0
- package/dist/installation-core.js.map +1 -0
- package/dist/inventory.d.ts +3 -0
- package/dist/inventory.d.ts.map +1 -0
- package/dist/inventory.js +49 -0
- package/dist/inventory.js.map +1 -0
- package/dist/json-edit.d.ts +19 -0
- package/dist/json-edit.d.ts.map +1 -0
- package/dist/json-edit.js +81 -0
- package/dist/json-edit.js.map +1 -0
- package/dist/lifecycle-registration.d.ts +46 -0
- package/dist/lifecycle-registration.d.ts.map +1 -0
- package/dist/lifecycle-registration.js +332 -0
- package/dist/lifecycle-registration.js.map +1 -0
- package/dist/minting.d.ts +46 -0
- package/dist/minting.d.ts.map +1 -0
- package/dist/minting.js +192 -0
- package/dist/minting.js.map +1 -0
- package/dist/native-command.d.ts +6 -0
- package/dist/native-command.d.ts.map +1 -0
- package/dist/native-command.js +273 -0
- package/dist/native-command.js.map +1 -0
- package/dist/pack.d.ts +4 -0
- package/dist/pack.d.ts.map +1 -0
- package/dist/pack.js +30 -0
- package/dist/pack.js.map +1 -0
- package/dist/plugin-home.d.ts +45 -0
- package/dist/plugin-home.d.ts.map +1 -0
- package/dist/plugin-home.js +371 -0
- package/dist/plugin-home.js.map +1 -0
- package/dist/projection.d.ts +45 -0
- package/dist/projection.d.ts.map +1 -0
- package/dist/projection.js +218 -0
- package/dist/projection.js.map +1 -0
- package/dist/publication.d.ts +20 -0
- package/dist/publication.d.ts.map +1 -0
- package/dist/publication.js +284 -0
- package/dist/publication.js.map +1 -0
- package/dist/registry-admission.d.ts +5 -0
- package/dist/registry-admission.d.ts.map +1 -0
- package/dist/registry-admission.js +17 -0
- package/dist/registry-admission.js.map +1 -0
- package/dist/registry-build.d.ts +35 -0
- package/dist/registry-build.d.ts.map +1 -0
- package/dist/registry-build.js +156 -0
- package/dist/registry-build.js.map +1 -0
- package/dist/registry-config.d.ts +32 -0
- package/dist/registry-config.d.ts.map +1 -0
- package/dist/registry-config.js +191 -0
- package/dist/registry-config.js.map +1 -0
- package/dist/registry-layout.d.ts +41 -0
- package/dist/registry-layout.d.ts.map +1 -0
- package/dist/registry-layout.js +142 -0
- package/dist/registry-layout.js.map +1 -0
- package/dist/registry-resolve.d.ts +56 -0
- package/dist/registry-resolve.d.ts.map +1 -0
- package/dist/registry-resolve.js +406 -0
- package/dist/registry-resolve.js.map +1 -0
- package/dist/registry-source.d.ts +37 -0
- package/dist/registry-source.d.ts.map +1 -0
- package/dist/registry-source.js +101 -0
- package/dist/registry-source.js.map +1 -0
- package/dist/registry.d.ts +10 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +6 -0
- package/dist/registry.js.map +1 -0
- package/dist/resolve.d.ts +31 -0
- package/dist/resolve.d.ts.map +1 -0
- package/dist/resolve.js +115 -0
- package/dist/resolve.js.map +1 -0
- package/dist/services.d.ts +179 -0
- package/dist/services.d.ts.map +1 -0
- package/dist/services.js +290 -0
- package/dist/services.js.map +1 -0
- package/dist/snapshot.d.ts +19 -0
- package/dist/snapshot.d.ts.map +1 -0
- package/dist/snapshot.js +309 -0
- package/dist/snapshot.js.map +1 -0
- package/dist/transfer.d.ts +22 -0
- package/dist/transfer.d.ts.map +1 -0
- package/dist/transfer.js +98 -0
- package/dist/transfer.js.map +1 -0
- package/dist/updates.d.ts +57 -0
- package/dist/updates.d.ts.map +1 -0
- package/dist/updates.js +174 -0
- package/dist/updates.js.map +1 -0
- package/dist/ustar.d.ts +28 -0
- package/dist/ustar.d.ts.map +1 -0
- package/dist/ustar.js +145 -0
- package/dist/ustar.js.map +1 -0
- package/package.json +305 -3
package/dist/files.js
ADDED
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import { createHash, randomUUID } from 'node:crypto';
|
|
2
|
+
import { closeSync, existsSync, fchmodSync, fsyncSync, linkSync, lstatSync, mkdirSync, openSync, readFileSync, realpathSync, renameSync, unlinkSync, writeFileSync, } from 'node:fs';
|
|
3
|
+
import { dirname, isAbsolute, join, parse, resolve } from 'node:path';
|
|
4
|
+
import { stableSerialize } from '@inventarch/graph';
|
|
5
|
+
/** `path`, when present, is the workspace-relative file the refusal concerns, so a caller can locate it without parsing the message. */
|
|
6
|
+
export class DistributionError extends Error {
|
|
7
|
+
code;
|
|
8
|
+
path;
|
|
9
|
+
constructor(code, message, path) {
|
|
10
|
+
super(message);
|
|
11
|
+
this.code = code;
|
|
12
|
+
this.path = path;
|
|
13
|
+
this.name = 'DistributionError';
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export function fail(code, message) {
|
|
17
|
+
throw new DistributionError(`IA-DIST-${code}`, message);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Run `work` for one file; a refusal it raises without a location is re-raised naming `path`, its code and message
|
|
21
|
+
* unchanged. That covers the codec's own coded refusals too (`decodeDistributionJson` raises `IA-DB-*`), so a file
|
|
22
|
+
* that does not even parse is located like one that parses into the wrong shape.
|
|
23
|
+
*/
|
|
24
|
+
export function locate(path, work) {
|
|
25
|
+
try {
|
|
26
|
+
return work();
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
if (error instanceof DistributionError) {
|
|
30
|
+
if (error.path === undefined)
|
|
31
|
+
throw new DistributionError(error.code, error.message, path);
|
|
32
|
+
throw error;
|
|
33
|
+
}
|
|
34
|
+
if (error instanceof Error &&
|
|
35
|
+
'code' in error &&
|
|
36
|
+
typeof error.code === 'string' &&
|
|
37
|
+
/^IA-/.test(error.code) &&
|
|
38
|
+
!('path' in error))
|
|
39
|
+
throw new DistributionError(error.code, error.message, path);
|
|
40
|
+
throw error;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
export const sha256 = (bytes) => createHash('sha256').update(bytes).digest('hex');
|
|
44
|
+
export const digest = (value) => sha256(stableSerialize(value));
|
|
45
|
+
/** Plain transport JSON; digests use graph's separately typed stable serializer. */
|
|
46
|
+
export const json = (value) => JSON.stringify(value, (_key, item) => {
|
|
47
|
+
if (item !== null && typeof item === 'object' && !Array.isArray(item))
|
|
48
|
+
return Object.fromEntries(Object.entries(item).sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0)));
|
|
49
|
+
return item;
|
|
50
|
+
}) + '\n';
|
|
51
|
+
export function portable(path) {
|
|
52
|
+
if (!path ||
|
|
53
|
+
path !== path.normalize('NFC') ||
|
|
54
|
+
path.length > 1024 ||
|
|
55
|
+
/[\\\u0000-\u001f<>:"|?*]/.test(path) ||
|
|
56
|
+
path
|
|
57
|
+
.split('/')
|
|
58
|
+
.some((part) => !part ||
|
|
59
|
+
part === '.' ||
|
|
60
|
+
part === '..' ||
|
|
61
|
+
/[. ]$/.test(part) ||
|
|
62
|
+
/^(con|prn|aux|nul|com[0-9]|lpt[0-9])(?:\.|$)/i.test(part)))
|
|
63
|
+
fail('PATH-UNSAFE', `Unsafe relative path: ${path}`);
|
|
64
|
+
return path;
|
|
65
|
+
}
|
|
66
|
+
/** Checks every existing ancestor, including the caller-selected absolute root. */
|
|
67
|
+
export function contained(root, path = '') {
|
|
68
|
+
const absolute = resolve(root), volume = parse(absolute).root;
|
|
69
|
+
let current = volume;
|
|
70
|
+
for (const segment of absolute.slice(volume.length).split(/[\\/]/).filter(Boolean)) {
|
|
71
|
+
current = join(current, segment);
|
|
72
|
+
if (existsSync(current) && lstatSync(current).isSymbolicLink())
|
|
73
|
+
fail('PATH-UNSAFE', `Link/junction is not allowed: ${current}`);
|
|
74
|
+
}
|
|
75
|
+
for (const segment of path ? portable(path).split('/') : []) {
|
|
76
|
+
current = join(current, segment);
|
|
77
|
+
// lstat also detects dangling links; existsSync alone does not.
|
|
78
|
+
try {
|
|
79
|
+
if (lstatSync(current).isSymbolicLink())
|
|
80
|
+
fail('PATH-UNSAFE', `Link/junction is not allowed: ${current}`);
|
|
81
|
+
}
|
|
82
|
+
catch (error) {
|
|
83
|
+
if (error.code !== 'ENOENT')
|
|
84
|
+
throw error;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return current;
|
|
88
|
+
}
|
|
89
|
+
export function workspace(path) {
|
|
90
|
+
if (!isAbsolute(path))
|
|
91
|
+
fail('INPUT-INVALID', 'An absolute --root is required');
|
|
92
|
+
const result = contained(path);
|
|
93
|
+
if (!existsSync(result) || !lstatSync(result).isDirectory())
|
|
94
|
+
fail('INPUT-INVALID', 'Workspace root must be an existing directory');
|
|
95
|
+
return realpathSync(result);
|
|
96
|
+
}
|
|
97
|
+
export function bytes(root, path, limit = 1024 * 1024) {
|
|
98
|
+
const target = contained(root, path);
|
|
99
|
+
try {
|
|
100
|
+
return unaliased(target, path, lstatSync(target), limit);
|
|
101
|
+
}
|
|
102
|
+
catch (error) {
|
|
103
|
+
if (error.code === 'ENOENT')
|
|
104
|
+
return null;
|
|
105
|
+
throw error;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* The bytes of `target`, which `stat` (its own lstat, taken by the caller) says is an unaliased regular file within `limit`;
|
|
110
|
+
* `path` names it in refusals. Containment is the caller's: `bytes` checks it first, and a walk that has already checked
|
|
111
|
+
* every level above `target` passes the lstat it took rather than walking the path again.
|
|
112
|
+
*/
|
|
113
|
+
export function unaliased(target, path, stat, limit) {
|
|
114
|
+
if (!stat.isFile() || stat.nlink !== 1)
|
|
115
|
+
fail('PATH-UNSAFE', `Expected unaliased regular file: ${path}`);
|
|
116
|
+
if (stat.size > limit)
|
|
117
|
+
fail('LIMIT-EXCEEDED', `File exceeds ${limit} bytes: ${path}`);
|
|
118
|
+
const content = readFileSync(target);
|
|
119
|
+
if (content.length > limit)
|
|
120
|
+
fail('LIMIT-EXCEEDED', `File grew beyond its bound: ${path}`);
|
|
121
|
+
return content;
|
|
122
|
+
}
|
|
123
|
+
export function utf8(content) {
|
|
124
|
+
try {
|
|
125
|
+
return new TextDecoder('utf-8', { fatal: true, ignoreBOM: true }).decode(content);
|
|
126
|
+
}
|
|
127
|
+
catch {
|
|
128
|
+
return fail('INPUT-INVALID', 'Expected exact UTF-8 bytes');
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
export function syncDirectory(path) {
|
|
132
|
+
// Windows does not expose fsync on directory handles. File flush + same-volume
|
|
133
|
+
// rename is the available primitive there; crash qualification records the OS.
|
|
134
|
+
if (process.platform === 'win32')
|
|
135
|
+
return;
|
|
136
|
+
const fd = openSync(path, 'r');
|
|
137
|
+
try {
|
|
138
|
+
fsyncSync(fd);
|
|
139
|
+
}
|
|
140
|
+
finally {
|
|
141
|
+
closeSync(fd);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
/** `mode` defaults to owner-only; a caller writing public static data (a registry) passes 0o644. It is set explicitly, so umask does not narrow it. */
|
|
145
|
+
export function replace(root, path, content, mode = 0o600) {
|
|
146
|
+
const target = contained(root, path);
|
|
147
|
+
if (content === null) {
|
|
148
|
+
if (existsSync(target)) {
|
|
149
|
+
unlinkSync(target);
|
|
150
|
+
syncDirectory(dirname(target));
|
|
151
|
+
}
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
mkdirSync(dirname(target), { recursive: true });
|
|
155
|
+
contained(root, path);
|
|
156
|
+
const temp = `${target}.${randomUUID()}.tmp`, fd = openSync(temp, 'wx', mode);
|
|
157
|
+
try {
|
|
158
|
+
if (mode !== 0o600)
|
|
159
|
+
fchmodSync(fd, mode);
|
|
160
|
+
writeFileSync(fd, content);
|
|
161
|
+
fsyncSync(fd);
|
|
162
|
+
}
|
|
163
|
+
finally {
|
|
164
|
+
closeSync(fd);
|
|
165
|
+
}
|
|
166
|
+
try {
|
|
167
|
+
renameSync(temp, target);
|
|
168
|
+
syncDirectory(dirname(target));
|
|
169
|
+
}
|
|
170
|
+
finally {
|
|
171
|
+
if (existsSync(temp))
|
|
172
|
+
unlinkSync(temp);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
/** Publish one complete draft file without replacing an existing directory entry. */
|
|
176
|
+
export function createFile(root, path, content, mode = 0o600) {
|
|
177
|
+
const target = contained(root, path);
|
|
178
|
+
mkdirSync(dirname(target), { recursive: true });
|
|
179
|
+
contained(root, path);
|
|
180
|
+
const temp = `${target}.${randomUUID()}.tmp`, fd = openSync(temp, 'wx', mode);
|
|
181
|
+
try {
|
|
182
|
+
if (mode !== 0o600)
|
|
183
|
+
fchmodSync(fd, mode);
|
|
184
|
+
writeFileSync(fd, content);
|
|
185
|
+
fsyncSync(fd);
|
|
186
|
+
}
|
|
187
|
+
finally {
|
|
188
|
+
closeSync(fd);
|
|
189
|
+
}
|
|
190
|
+
try {
|
|
191
|
+
linkSync(temp, target);
|
|
192
|
+
syncDirectory(dirname(target));
|
|
193
|
+
}
|
|
194
|
+
catch (error) {
|
|
195
|
+
if (error.code === 'EEXIST')
|
|
196
|
+
fail('LOCAL-MODIFICATION', 'Draft output already exists');
|
|
197
|
+
throw error;
|
|
198
|
+
}
|
|
199
|
+
finally {
|
|
200
|
+
unlinkSync(temp);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
export function canonicalJson(content) {
|
|
204
|
+
const text = utf8(content);
|
|
205
|
+
let value;
|
|
206
|
+
try {
|
|
207
|
+
value = JSON.parse(text);
|
|
208
|
+
}
|
|
209
|
+
catch {
|
|
210
|
+
return fail('INPUT-INVALID', 'Malformed managed JSON');
|
|
211
|
+
}
|
|
212
|
+
if (json(value) !== text)
|
|
213
|
+
fail('INPUT-INVALID', 'Managed JSON must use exact canonical encoding');
|
|
214
|
+
return value;
|
|
215
|
+
}
|
|
216
|
+
export function object(value, keys) {
|
|
217
|
+
if (value === null ||
|
|
218
|
+
typeof value !== 'object' ||
|
|
219
|
+
Array.isArray(value) ||
|
|
220
|
+
Object.keys(value).sort().join('|') !== [...keys].sort().join('|'))
|
|
221
|
+
fail('INPUT-INVALID', 'Unexpected managed object fields');
|
|
222
|
+
return value;
|
|
223
|
+
}
|
|
224
|
+
//# sourceMappingURL=files.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"files.js","sourceRoot":"","sources":["../src/files.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EACL,SAAS,EACT,UAAU,EACV,UAAU,EACV,SAAS,EACT,QAAQ,EACR,SAAS,EACT,SAAS,EACT,QAAQ,EACR,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,UAAU,EACV,aAAa,GACd,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,wIAAwI;AACxI,MAAM,OAAO,iBAAkB,SAAQ,KAAK;IAE/B;IAEA;IAHX,YACW,IAAY,EACrB,OAAe,EACN,IAAa;QAEtB,KAAK,CAAC,OAAO,CAAC,CAAC;QAJN,SAAI,GAAJ,IAAI,CAAQ;QAEZ,SAAI,GAAJ,IAAI,CAAS;QAGtB,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;I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AAK,KAA+B,CAAC,IAAI,KAAK,QAAQ;YAAE,IAAI,CAAC,oBAAoB,EAAE,6BAA6B,CAAC,CAAC;QAClH,MAAM,KAAK,CAAC;IACd,CAAC;YAAS,CAAC;QACT,UAAU,CAAC,IAAI,CAAC,CAAC;IACnB,CAAC;AACH,CAAC;AACD,MAAM,UAAU,aAAa,CAAC,OAAe;IAC3C,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC;IAC3B,IAAI,KAAc,CAAC;IACnB,IAAI,CAAC;QACH,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC3B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC,eAAe,EAAE,wBAAwB,CAAC,CAAC;IACzD,CAAC;IACD,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,IAAI;QAAE,IAAI,CAAC,eAAe,EAAE,gDAAgD,CAAC,CAAC;IAClG,OAAO,KAAK,CAAC;AACf,CAAC;AACD,MAAM,UAAU,MAAM,CAAC,KAAc,EAAE,IAAuB;IAC5D,IACE,KAAK,KAAK,IAAI;QACd,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QACpB,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC;QAElE,IAAI,CAAC,eAAe,EAAE,kCAAkC,CAAC,CAAC;IAC5D,OAAO,KAAgC,CAAC;AAC1C,CAAC"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import type { HostCacheTarget } from './host.js';
|
|
2
|
+
import type { JsonPath } from './json-edit.js';
|
|
3
|
+
export type GuardRequest = {
|
|
4
|
+
readonly cache: string;
|
|
5
|
+
} | {
|
|
6
|
+
readonly remove: string;
|
|
7
|
+
};
|
|
8
|
+
interface Side {
|
|
9
|
+
readonly config: string | null;
|
|
10
|
+
readonly state: string | null;
|
|
11
|
+
}
|
|
12
|
+
interface Group {
|
|
13
|
+
readonly matcher: string;
|
|
14
|
+
readonly hooks: readonly {
|
|
15
|
+
readonly type: 'command';
|
|
16
|
+
readonly command: string;
|
|
17
|
+
readonly args: readonly string[];
|
|
18
|
+
readonly timeout: number;
|
|
19
|
+
}[];
|
|
20
|
+
}
|
|
21
|
+
interface State {
|
|
22
|
+
readonly format: 'ia.guard-registration-state.v1';
|
|
23
|
+
readonly id: string;
|
|
24
|
+
readonly cache: string;
|
|
25
|
+
readonly release: string;
|
|
26
|
+
readonly created: boolean;
|
|
27
|
+
readonly group: Group;
|
|
28
|
+
readonly existing?: readonly JsonPath[];
|
|
29
|
+
}
|
|
30
|
+
export interface GuardPlan {
|
|
31
|
+
readonly format: 'ia.guard-registration-plan.v1';
|
|
32
|
+
readonly root: string;
|
|
33
|
+
readonly id: string;
|
|
34
|
+
readonly request: GuardRequest;
|
|
35
|
+
readonly release: string | null;
|
|
36
|
+
readonly before: {
|
|
37
|
+
readonly config: string | null;
|
|
38
|
+
readonly state: string | null;
|
|
39
|
+
readonly projectConfig: string | null;
|
|
40
|
+
};
|
|
41
|
+
readonly after: Side;
|
|
42
|
+
readonly digest: string;
|
|
43
|
+
}
|
|
44
|
+
/** Spec §5.1: explicit root, not claude-guard's CLAUDE_PROJECT_DIR, so the recorded root is the one run; on POSIX through `/bin/sh`, so a guard that cannot run denies (`FAIL_CLOSED`). */
|
|
45
|
+
export declare function guardGroup(launcher: string, root: string, platform?: NodeJS.Platform): Group;
|
|
46
|
+
/**
|
|
47
|
+
* The retained group must be the fixed guard derivation for its cache and root, in either form (`guardNode`); the
|
|
48
|
+
* recorded Node executable is kept as written. Exported for `host-observe.ts`, which reuses this real validator rather than a weaker local
|
|
49
|
+
* copy so observation can never drift from what `planGuardRegistration`/`applyGuardRegistration` themselves accept.
|
|
50
|
+
*/
|
|
51
|
+
export declare function saved(content: string | null, root: string, id: string): State | null;
|
|
52
|
+
export declare function planGuardRegistration(rootInput: string, request: GuardRequest): GuardPlan;
|
|
53
|
+
/** `planGuardRegistration` against an expected, unverified cache (`expectedHostCache`); never reads the cache. Apply re-plans with verification. */
|
|
54
|
+
export declare function planGuardFor(rootInput: string, expected: HostCacheTarget): GuardPlan;
|
|
55
|
+
export declare function applyGuardRegistration(input: unknown, checkpoint?: (stage: string) => void): {
|
|
56
|
+
status: 'guard-registered' | 'guard-removed';
|
|
57
|
+
id: string;
|
|
58
|
+
};
|
|
59
|
+
export declare function recoverGuardRegistration(rootInput: string): {
|
|
60
|
+
status: 'guard-recovered' | 'current';
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* The script `/bin/sh` runs the guard with, on POSIX: Node and its arguments come in as `$0` and `$@`, never as script text,
|
|
64
|
+
* and any failure to run the guard at all exits 2, naming the remedy on stderr, which Claude Code shows with the block.
|
|
65
|
+
* Claude Code lets a tool call through when a hook command cannot start or fails any other way, and blocks only on exit 2 or
|
|
66
|
+
* a deny (code.claude.com/docs/en/hooks); the guard's own decisions exit 0 and pass through unchanged. win32 has no
|
|
67
|
+
* `/bin/sh` and keeps the direct form, which still fails open (#323).
|
|
68
|
+
*/
|
|
69
|
+
export declare const FAIL_CLOSED = "\"$0\" \"$@\" || { echo \"IA steward guard could not run: run ia doctor, then ia host claude --apply\" >&2; exit 2; }";
|
|
70
|
+
/**
|
|
71
|
+
* Every script a released `guardGroup` has written, the current one first. A registration made with an earlier one stays an
|
|
72
|
+
* owned registration, so plan, remove and doctor still read it and re-applying rewrites it (`currentGuardForm`); a script
|
|
73
|
+
* this list does not hold is not one IA wrote. A change to `FAIL_CLOSED` MUST keep the previous script here.
|
|
74
|
+
*/
|
|
75
|
+
export declare const FAIL_CLOSED_ACCEPTED: readonly string[];
|
|
76
|
+
/**
|
|
77
|
+
* The Node a guard handler runs when its arguments are the fixed derivation for this launcher and root: the direct form's
|
|
78
|
+
* command (win32, and registrations made before the POSIX form), or the POSIX form's `$0` under any accepted script. Null
|
|
79
|
+
* for any other handler.
|
|
80
|
+
*/
|
|
81
|
+
export declare function guardNode(handler: {
|
|
82
|
+
readonly command?: unknown;
|
|
83
|
+
readonly args?: unknown;
|
|
84
|
+
}, launcher: string, root: string): unknown;
|
|
85
|
+
/**
|
|
86
|
+
* An owned guard handler is in the form `guardGroup` writes now on this platform: the direct form on win32, and elsewhere the
|
|
87
|
+
* `/bin/sh` form with the current `FAIL_CLOSED` script. The direct form on POSIX fails open when its Node cannot run, and an
|
|
88
|
+
* earlier script lacks what the current one adds; both still work, and re-applying rewrites them.
|
|
89
|
+
*/
|
|
90
|
+
export declare function currentGuardForm(handler: {
|
|
91
|
+
readonly command?: unknown;
|
|
92
|
+
readonly args?: unknown;
|
|
93
|
+
}, platform?: NodeJS.Platform): boolean;
|
|
94
|
+
export {};
|
|
95
|
+
//# sourceMappingURL=guard-registration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guard-registration.d.ts","sourceRoot":"","sources":["../src/guard-registration.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAGjD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAoB/C,MAAM,MAAM,YAAY,GAAG;IAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AACpF,UAAU,IAAI;IACZ,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B;AACD,UAAU,KAAK;IACb,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,SAAS;QACvB,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;QACzB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
1
|
+
import { isAbsolute, join, relative, sep } from 'node:path';
|
|
2
|
+
import { decodeDistributionJson } from '@inventarch/db/distribution';
|
|
3
|
+
import { acquireHostRegistrationLock, assertHostRegistrationIdle, doorServer, HOST_REGISTRATION, verifyHostCache, } from './host.js';
|
|
4
|
+
import { bytes, digest, fail, json, locate, object, replace, sha256, utf8, workspace } from './files.js';
|
|
5
|
+
import { editJson, emptyJson, keptPaths, presentJson } from './json-edit.js';
|
|
6
|
+
const area = '.ia/distributions/hosts', pendingPath = area + '/guard-pending.json', configPath = '.claude/settings.local.json', projectPath = '.claude/settings.json';
|
|
7
|
+
const identity = (value) => {
|
|
8
|
+
if (typeof value !== 'string' || !/^[a-z][a-z0-9-]{0,63}$/.test(value))
|
|
9
|
+
fail('INPUT-INVALID', 'Invalid guard registration identity');
|
|
10
|
+
return value;
|
|
11
|
+
};
|
|
12
|
+
const hash = (value) => {
|
|
13
|
+
if (typeof value !== 'string' || !/^[a-f0-9]{64}$/.test(value))
|
|
14
|
+
fail('INPUT-INVALID', 'Invalid guard registration digest');
|
|
15
|
+
return value;
|
|
16
|
+
};
|
|
17
|
+
const statePath = (id) => `${area}/claude-guard-${identity(id)}.json`;
|
|
18
|
+
/** Containers on the owned path; those that existed before the first apply are retained as `existing` and never pruned. */
|
|
19
|
+
const containers = [['hooks'], ['hooks', 'PreToolUse']];
|
|
20
|
+
const GUARD_MATCHER = 'Write|Edit|MultiEdit';
|
|
21
|
+
const read = (root, path, limit = 1024 * 1024) => {
|
|
22
|
+
const value = bytes(root, path, limit);
|
|
23
|
+
return value === null ? null : utf8(value);
|
|
24
|
+
};
|
|
25
|
+
const pin = (value) => (value === null ? null : sha256(value));
|
|
26
|
+
function plain(value) {
|
|
27
|
+
if (value === null || typeof value !== 'object' || Array.isArray(value))
|
|
28
|
+
fail('INPUT-INVALID', 'Expected host settings object');
|
|
29
|
+
return value;
|
|
30
|
+
}
|
|
31
|
+
/** Spec §5.1: explicit root, not claude-guard's CLAUDE_PROJECT_DIR, so the recorded root is the one run; on POSIX through `/bin/sh`, so a guard that cannot run denies (`FAIL_CLOSED`). */
|
|
32
|
+
export function guardGroup(launcher, root, platform = process.platform) {
|
|
33
|
+
const server = doorServer(launcher, ['guard', '--root', root]);
|
|
34
|
+
return {
|
|
35
|
+
matcher: GUARD_MATCHER,
|
|
36
|
+
hooks: [
|
|
37
|
+
{
|
|
38
|
+
type: 'command',
|
|
39
|
+
...(platform === 'win32'
|
|
40
|
+
? server
|
|
41
|
+
: { command: '/bin/sh', args: ['-c', FAIL_CLOSED, server.command, ...server.args] }),
|
|
42
|
+
timeout: 10,
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* The retained group must be the fixed guard derivation for its cache and root, in either form (`guardNode`); the
|
|
49
|
+
* recorded Node executable is kept as written. Exported for `host-observe.ts`, which reuses this real validator rather than a weaker local
|
|
50
|
+
* copy so observation can never drift from what `planGuardRegistration`/`applyGuardRegistration` themselves accept.
|
|
51
|
+
*/
|
|
52
|
+
export function saved(content, root, id) {
|
|
53
|
+
if (content === null)
|
|
54
|
+
return null;
|
|
55
|
+
const value = plain(decodeDistributionJson(content)), row = object(value, [
|
|
56
|
+
'format',
|
|
57
|
+
'id',
|
|
58
|
+
'cache',
|
|
59
|
+
'release',
|
|
60
|
+
'created',
|
|
61
|
+
'group',
|
|
62
|
+
...(Object.hasOwn(value, 'existing') ? ['existing'] : []),
|
|
63
|
+
]);
|
|
64
|
+
if (row['format'] !== 'ia.guard-registration-state.v1' ||
|
|
65
|
+
row['id'] !== id ||
|
|
66
|
+
typeof row['cache'] !== 'string' ||
|
|
67
|
+
!isAbsolute(row['cache']) ||
|
|
68
|
+
typeof row['created'] !== 'boolean')
|
|
69
|
+
fail('INPUT-INVALID', 'Invalid guard ownership state');
|
|
70
|
+
hash(row['release']);
|
|
71
|
+
const group = object(row['group'], ['matcher', 'hooks']);
|
|
72
|
+
if (group['matcher'] !== GUARD_MATCHER || !Array.isArray(group['hooks']) || group['hooks'].length !== 1)
|
|
73
|
+
fail('INPUT-INVALID', 'Invalid owned guard hook group');
|
|
74
|
+
const handler = object(group['hooks'][0], ['type', 'command', 'args', 'timeout']), launcher = join(row['cache'], 'scripts/ia.mjs'), node = guardNode(handler, launcher, root);
|
|
75
|
+
if (handler['type'] !== 'command' ||
|
|
76
|
+
typeof node !== 'string' ||
|
|
77
|
+
!isAbsolute(node) ||
|
|
78
|
+
handler['timeout'] !== guardGroup(launcher, root).hooks[0].timeout)
|
|
79
|
+
fail('INPUT-INVALID', 'Owned guard command differs from its fixed root');
|
|
80
|
+
keptPaths(row['existing'], containers);
|
|
81
|
+
return row;
|
|
82
|
+
}
|
|
83
|
+
export function planGuardRegistration(rootInput, request) {
|
|
84
|
+
const root = workspace(rootInput);
|
|
85
|
+
assertHostRegistrationIdle(root);
|
|
86
|
+
const remove = Object.hasOwn(plain(request), 'remove');
|
|
87
|
+
object(request, remove ? ['remove'] : ['cache']);
|
|
88
|
+
return planGuardWith(root, remove ? null : verifyHostCache(request.cache), remove ? request.remove : null);
|
|
89
|
+
}
|
|
90
|
+
/** `planGuardRegistration` against an expected, unverified cache (`expectedHostCache`); never reads the cache. Apply re-plans with verification. */
|
|
91
|
+
export function planGuardFor(rootInput, expected) {
|
|
92
|
+
const root = workspace(rootInput);
|
|
93
|
+
assertHostRegistrationIdle(root);
|
|
94
|
+
return planGuardWith(root, expected, null);
|
|
95
|
+
}
|
|
96
|
+
function planGuardWith(root, cache, removeId) {
|
|
97
|
+
if (cache && cache.host !== null && cache.host !== 'claude')
|
|
98
|
+
fail('HOST-UNSUPPORTED', 'Guard registration requires a Claude-compatible cache');
|
|
99
|
+
if (cache) {
|
|
100
|
+
const path = relative(cache.directory, root);
|
|
101
|
+
if (!isAbsolute(path) && path !== '..' && !path.startsWith('..' + sep))
|
|
102
|
+
fail('PATH-UNSAFE', 'Consumer root cannot be inside its immutable host cache');
|
|
103
|
+
}
|
|
104
|
+
const id = cache ? HOST_REGISTRATION : identity(removeId);
|
|
105
|
+
const before = {
|
|
106
|
+
config: read(root, configPath),
|
|
107
|
+
state: locate(statePath(id), () => read(root, statePath(id))),
|
|
108
|
+
}, prior = locate(statePath(id), () => saved(before.state, root, id));
|
|
109
|
+
if (!cache && !prior)
|
|
110
|
+
fail('INPUT-INVALID', 'Guard registration is not owned');
|
|
111
|
+
const config = before.config === null ? {} : plain(decodeDistributionJson(before.config)), hooks = config['hooks'] === undefined ? {} : plain(config['hooks']);
|
|
112
|
+
const projectText = read(root, projectPath), project = projectText === null ? {} : plain(decodeDistributionJson(projectText));
|
|
113
|
+
if (cache &&
|
|
114
|
+
(config['disableAllHooks'] === true ||
|
|
115
|
+
(config['disableAllHooks'] === undefined && project['disableAllHooks'] === true)))
|
|
116
|
+
fail('HOST-UNSUPPORTED', 'Project hooks are explicitly disabled by disableAllHooks');
|
|
117
|
+
const rows = hooks['PreToolUse'] === undefined ? [] : hooks['PreToolUse'];
|
|
118
|
+
if (!Array.isArray(rows) || rows.length > 256)
|
|
119
|
+
fail('INPUT-INVALID', 'Expected a bounded PreToolUse hook array');
|
|
120
|
+
const matching = prior
|
|
121
|
+
? rows.map((row, at) => (json(row) === json(prior.group) ? at : -1)).filter((at) => at >= 0)
|
|
122
|
+
: [];
|
|
123
|
+
// A removal whose owned group the user already deleted — no group names this root's guard — removes only the ownership state; a changed or duplicated group still refuses.
|
|
124
|
+
const gone = !cache &&
|
|
125
|
+
prior !== null &&
|
|
126
|
+
matching.length === 0 &&
|
|
127
|
+
!rows.some((row) => json(row).includes(JSON.stringify(['guard', '--root', root]).slice(1, -1)));
|
|
128
|
+
if (prior && !gone && matching.length !== 1)
|
|
129
|
+
fail('LOCAL-MODIFICATION', 'Owned guard hook group changed or was duplicated');
|
|
130
|
+
const group = cache ? guardGroup(cache.launcher, root) : null, remaining = rows.filter((_row, at) => !matching.includes(at));
|
|
131
|
+
if (group && remaining.some((row) => json(row) === json(group)))
|
|
132
|
+
fail('LOCAL-MODIFICATION', 'An unmanaged identical guard group already exists');
|
|
133
|
+
// In place (spec §5.1): replace or append the owned group, or remove it by index; every other byte is kept.
|
|
134
|
+
const existing = prior ? keptPaths(prior.existing, containers) : presentJson(before.config, containers), owned = ['hooks', 'PreToolUse', prior ? matching[0] : -1];
|
|
135
|
+
const edited = gone ? before.config : editJson(before.config, owned, group ?? undefined, existing), nextConfig = !gone && prior?.created && emptyJson(edited) ? null : edited;
|
|
136
|
+
const after = {
|
|
137
|
+
config: nextConfig,
|
|
138
|
+
state: cache && group
|
|
139
|
+
? json({
|
|
140
|
+
format: 'ia.guard-registration-state.v1',
|
|
141
|
+
id,
|
|
142
|
+
cache: cache.directory,
|
|
143
|
+
release: cache.release,
|
|
144
|
+
created: prior?.created ?? before.config === null,
|
|
145
|
+
group,
|
|
146
|
+
...(existing.length ? { existing } : {}),
|
|
147
|
+
})
|
|
148
|
+
: null,
|
|
149
|
+
};
|
|
150
|
+
if (Buffer.byteLength(after.config ?? '') > 1024 * 1024 || Buffer.byteLength(after.state ?? '') > 1024 * 1024)
|
|
151
|
+
fail('LIMIT-EXCEEDED', 'Guard registration exceeds its publication bounds');
|
|
152
|
+
const body = {
|
|
153
|
+
format: 'ia.guard-registration-plan.v1',
|
|
154
|
+
root,
|
|
155
|
+
id,
|
|
156
|
+
request: cache ? { cache: cache.directory } : { remove: id },
|
|
157
|
+
release: cache?.release ?? null,
|
|
158
|
+
before: { config: pin(before.config), state: pin(before.state), projectConfig: pin(projectText) },
|
|
159
|
+
after,
|
|
160
|
+
};
|
|
161
|
+
return { ...body, digest: digest(body) };
|
|
162
|
+
}
|
|
163
|
+
const current = (root, id) => ({
|
|
164
|
+
config: read(root, configPath),
|
|
165
|
+
state: read(root, statePath(id)),
|
|
166
|
+
});
|
|
167
|
+
function same(root, id, side) {
|
|
168
|
+
if (json(current(root, id)) !== json(side))
|
|
169
|
+
fail('LOCAL-MODIFICATION', 'Guard configuration or ownership changed during publication');
|
|
170
|
+
}
|
|
171
|
+
const write = (root, path, content) => replace(root, path, content === null ? null : Buffer.from(content));
|
|
172
|
+
export function applyGuardRegistration(input, checkpoint = () => { }) {
|
|
173
|
+
const row = object(input, ['format', 'root', 'id', 'request', 'release', 'before', 'after', 'digest']);
|
|
174
|
+
if (row['format'] !== 'ia.guard-registration-plan.v1' || typeof row['root'] !== 'string')
|
|
175
|
+
fail('INPUT-INVALID', 'Invalid guard registration plan');
|
|
176
|
+
const root = workspace(row['root']), unlock = acquireHostRegistrationLock(root);
|
|
177
|
+
try {
|
|
178
|
+
const plan = planGuardRegistration(root, row['request']);
|
|
179
|
+
if (json(plan) !== json(input))
|
|
180
|
+
fail('PLAN-STALE', 'Guard plan no longer matches its current inputs');
|
|
181
|
+
const before = current(root, plan.id);
|
|
182
|
+
write(root, pendingPath, json({ format: 'ia.guard-registration-pending.v1', id: plan.id, before, after: plan.after }));
|
|
183
|
+
checkpoint('pending');
|
|
184
|
+
same(root, plan.id, before);
|
|
185
|
+
write(root, configPath, plan.after.config);
|
|
186
|
+
checkpoint('config');
|
|
187
|
+
same(root, plan.id, { ...before, config: plan.after.config });
|
|
188
|
+
if (pin(read(root, projectPath)) !== plan.before.projectConfig ||
|
|
189
|
+
('cache' in plan.request && verifyHostCache(plan.request.cache).release !== plan.release))
|
|
190
|
+
fail('PLAN-STALE', 'Project settings or host cache changed before registration commit');
|
|
191
|
+
write(root, statePath(plan.id), plan.after.state);
|
|
192
|
+
checkpoint('state');
|
|
193
|
+
write(root, pendingPath, null);
|
|
194
|
+
checkpoint('complete');
|
|
195
|
+
return { status: 'cache' in plan.request ? 'guard-registered' : 'guard-removed', id: plan.id };
|
|
196
|
+
}
|
|
197
|
+
finally {
|
|
198
|
+
unlock();
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
export function recoverGuardRegistration(rootInput) {
|
|
202
|
+
const root = workspace(rootInput), unlock = acquireHostRegistrationLock(root, true);
|
|
203
|
+
try {
|
|
204
|
+
if (read(root, area + '/pending.json', 8 * 1024 * 1024) !== null)
|
|
205
|
+
fail('RECOVERY-REQUIRED', 'Run recover-host for pending MCP registration');
|
|
206
|
+
if (read(root, area + '/lifecycle-pending.json', 8 * 1024 * 1024) !== null)
|
|
207
|
+
fail('RECOVERY-REQUIRED', 'Run recover-lifecycle for the pending context registration');
|
|
208
|
+
const content = read(root, pendingPath, 8 * 1024 * 1024);
|
|
209
|
+
if (content === null)
|
|
210
|
+
return { status: 'current' };
|
|
211
|
+
const row = object(decodeDistributionJson(content), ['format', 'id', 'before', 'after']);
|
|
212
|
+
if (row['format'] !== 'ia.guard-registration-pending.v1')
|
|
213
|
+
fail('INPUT-INVALID', 'Unknown guard recovery format');
|
|
214
|
+
const id = identity(row['id']);
|
|
215
|
+
const side = (value) => {
|
|
216
|
+
const data = object(value, ['config', 'state']);
|
|
217
|
+
for (const v of Object.values(data))
|
|
218
|
+
if (!(v === null || (typeof v === 'string' && Buffer.byteLength(v) <= 1024 * 1024)))
|
|
219
|
+
fail('INPUT-INVALID', 'Invalid guard recovery bytes');
|
|
220
|
+
const result = data;
|
|
221
|
+
saved(result.state, root, id);
|
|
222
|
+
if (result.config !== null)
|
|
223
|
+
plain(decodeDistributionJson(result.config));
|
|
224
|
+
return result;
|
|
225
|
+
};
|
|
226
|
+
const before = side(row['before']), after = side(row['after']), actual = current(root, id);
|
|
227
|
+
if (![before.config, after.config].includes(actual.config) || ![before.state, after.state].includes(actual.state))
|
|
228
|
+
fail('LOCAL-MODIFICATION', 'Unexpected local guard edit must be reconciled');
|
|
229
|
+
const desired = actual.state === after.state ? after : before;
|
|
230
|
+
write(root, configPath, desired.config);
|
|
231
|
+
write(root, statePath(id), desired.state);
|
|
232
|
+
write(root, pendingPath, null);
|
|
233
|
+
return { status: 'guard-recovered' };
|
|
234
|
+
}
|
|
235
|
+
finally {
|
|
236
|
+
unlock();
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* The script `/bin/sh` runs the guard with, on POSIX: Node and its arguments come in as `$0` and `$@`, never as script text,
|
|
241
|
+
* and any failure to run the guard at all exits 2, naming the remedy on stderr, which Claude Code shows with the block.
|
|
242
|
+
* Claude Code lets a tool call through when a hook command cannot start or fails any other way, and blocks only on exit 2 or
|
|
243
|
+
* a deny (code.claude.com/docs/en/hooks); the guard's own decisions exit 0 and pass through unchanged. win32 has no
|
|
244
|
+
* `/bin/sh` and keeps the direct form, which still fails open (#323).
|
|
245
|
+
*/
|
|
246
|
+
export const FAIL_CLOSED = '"$0" "$@" || { echo "IA steward guard could not run: run ia doctor, then ia host claude --apply" >&2; exit 2; }';
|
|
247
|
+
/**
|
|
248
|
+
* Every script a released `guardGroup` has written, the current one first. A registration made with an earlier one stays an
|
|
249
|
+
* owned registration, so plan, remove and doctor still read it and re-applying rewrites it (`currentGuardForm`); a script
|
|
250
|
+
* this list does not hold is not one IA wrote. A change to `FAIL_CLOSED` MUST keep the previous script here.
|
|
251
|
+
*/
|
|
252
|
+
export const FAIL_CLOSED_ACCEPTED = [FAIL_CLOSED, '"$0" "$@" || exit 2'];
|
|
253
|
+
/**
|
|
254
|
+
* The Node a guard handler runs when its arguments are the fixed derivation for this launcher and root: the direct form's
|
|
255
|
+
* command (win32, and registrations made before the POSIX form), or the POSIX form's `$0` under any accepted script. Null
|
|
256
|
+
* for any other handler.
|
|
257
|
+
*/
|
|
258
|
+
export function guardNode(handler, launcher, root) {
|
|
259
|
+
const direct = json([launcher, 'guard', '--root', root]), args = handler.args;
|
|
260
|
+
if (!Array.isArray(args))
|
|
261
|
+
return null;
|
|
262
|
+
if (json(args) === direct)
|
|
263
|
+
return handler.command;
|
|
264
|
+
return handler.command === '/bin/sh' &&
|
|
265
|
+
args.length === 7 &&
|
|
266
|
+
args[0] === '-c' &&
|
|
267
|
+
FAIL_CLOSED_ACCEPTED.includes(args[1]) &&
|
|
268
|
+
json(args.slice(3)) === direct
|
|
269
|
+
? args[2]
|
|
270
|
+
: null;
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* An owned guard handler is in the form `guardGroup` writes now on this platform: the direct form on win32, and elsewhere the
|
|
274
|
+
* `/bin/sh` form with the current `FAIL_CLOSED` script. The direct form on POSIX fails open when its Node cannot run, and an
|
|
275
|
+
* earlier script lacks what the current one adds; both still work, and re-applying rewrites them.
|
|
276
|
+
*/
|
|
277
|
+
export function currentGuardForm(handler, platform = process.platform) {
|
|
278
|
+
if (platform === 'win32')
|
|
279
|
+
return handler.command !== '/bin/sh';
|
|
280
|
+
return handler.command === '/bin/sh' && Array.isArray(handler.args) && handler.args[1] === FAIL_CLOSED;
|
|
281
|
+
}
|
|
282
|
+
//# sourceMappingURL=guard-registration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guard-registration.js","sourceRoot":"","sources":["../src/guard-registration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAC5D,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EACL,2BAA2B,EAC3B,0BAA0B,EAC1B,UAAU,EACV,iBAAiB,EACjB,eAAe,GAChB,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACzG,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAG7E,MAAM,IAAI,GAAG,yBAAyB,EACpC,WAAW,GAAG,IAAI,GAAG,qBAAqB,EAC1C,UAAU,GAAG,6BAA6B,EAC1C,WAAW,GAAG,uBAAuB,CAAC;AACxC,MAAM,QAAQ,GAAG,CAAC,KAAc,EAAU,EAAE;IAC1C,IAAI,OAAO,KAAK,KAAK,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