@sentropic/h2a 0.98.7-rc.4 → 0.98.7-rc.8
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/dist/bin-routing.d.ts.map +1 -1
- package/dist/bin-routing.js +23 -3
- package/dist/bin-routing.js.map +1 -1
- package/dist/bin.js +48 -4
- package/dist/bin.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +26 -11
- package/dist/cli.js.map +1 -1
- package/dist/focus-build.d.ts.map +1 -1
- package/dist/focus-build.js +33 -6
- package/dist/focus-build.js.map +1 -1
- package/dist/focus-feedback.d.ts +30 -0
- package/dist/focus-feedback.d.ts.map +1 -0
- package/dist/focus-feedback.js +133 -0
- package/dist/focus-feedback.js.map +1 -0
- package/dist/hosts/native-convergence.d.ts +1 -0
- package/dist/hosts/native-convergence.d.ts.map +1 -1
- package/dist/hosts/native-convergence.js +35 -25
- package/dist/hosts/native-convergence.js.map +1 -1
- package/dist/hosts/native-files.d.ts +1 -0
- package/dist/hosts/native-files.d.ts.map +1 -1
- package/dist/hosts/native-files.js +2 -1
- package/dist/hosts/native-files.js.map +1 -1
- package/dist/hosts/plugin.d.ts +4 -1
- package/dist/hosts/plugin.d.ts.map +1 -1
- package/dist/hosts/plugin.js +27 -2
- package/dist/hosts/plugin.js.map +1 -1
- package/dist/hosts/vibe-equipment.d.ts +1 -0
- package/dist/hosts/vibe-equipment.d.ts.map +1 -1
- package/dist/hosts/vibe-equipment.js +8 -4
- package/dist/hosts/vibe-equipment.js.map +1 -1
- package/dist/identity-operator-break.d.ts +31 -0
- package/dist/identity-operator-break.d.ts.map +1 -0
- package/dist/identity-operator-break.js +77 -0
- package/dist/identity-operator-break.js.map +1 -0
- package/dist/runtime/focus/edit-receipts.d.ts +22 -0
- package/dist/runtime/focus/edit-receipts.d.ts.map +1 -0
- package/dist/runtime/focus/edit-receipts.js +46 -0
- package/dist/runtime/focus/edit-receipts.js.map +1 -0
- package/focus-app/client/_app/immutable/chunks/{unQroC_0.js → BXS4ok-I.js} +2 -2
- package/focus-app/client/_app/immutable/chunks/BXS4ok-I.js.br +0 -0
- package/focus-app/client/_app/immutable/chunks/BXS4ok-I.js.gz +0 -0
- package/focus-app/client/_app/immutable/entry/{app.75Uzo4oj.js → app.BJwKYx8S.js} +2 -2
- package/focus-app/client/_app/immutable/entry/app.BJwKYx8S.js.br +0 -0
- package/focus-app/client/_app/immutable/entry/app.BJwKYx8S.js.gz +0 -0
- package/focus-app/client/_app/immutable/entry/start.to_m_bSO.js +1 -0
- package/focus-app/client/_app/immutable/entry/start.to_m_bSO.js.br +2 -0
- package/focus-app/client/_app/immutable/entry/start.to_m_bSO.js.gz +0 -0
- package/focus-app/client/_app/immutable/nodes/{1.hqfmE-jM.js → 1.CvN150m3.js} +1 -1
- package/focus-app/client/_app/immutable/nodes/1.CvN150m3.js.br +3 -0
- package/focus-app/client/_app/immutable/nodes/1.CvN150m3.js.gz +0 -0
- package/focus-app/client/_app/version.json +1 -1
- package/focus-app/client/_app/version.json.br +0 -0
- package/focus-app/client/_app/version.json.gz +0 -0
- package/focus-app/h2a-focus.json +29 -29
- package/focus-app/handler.js +4 -4
- package/focus-app/index.js +4 -4
- package/focus-app/server/chunks/chunks/{internal.js-vq85iWAx.js → internal.js-BORbEOh-.js} +2 -2
- package/focus-app/server/chunks/chunks/{internal.js-vq85iWAx.js.map → internal.js-BORbEOh-.js.map} +1 -1
- package/focus-app/server/chunks/{handler-f-0S9j72.js → handler-Ccwb0eyC.js} +3 -3
- package/focus-app/server/chunks/{handler-f-0S9j72.js.map → handler-Ccwb0eyC.js.map} +1 -1
- package/focus-app/server/chunks/{index.js-DlbaFcic.js → index.js-CzPOZLjV.js} +2 -2
- package/focus-app/server/chunks/{index.js-DlbaFcic.js.map → index.js-CzPOZLjV.js.map} +1 -1
- package/focus-app/server/chunks/{manifest.js-CxrShg-z.js → manifest.js-E-BEcOes.js} +3 -3
- package/focus-app/server/chunks/{manifest.js-CxrShg-z.js.map → manifest.js-E-BEcOes.js.map} +1 -1
- package/focus-app/server/chunks/nodes/{1.js-O2SZgyXK.js → 1.js-BJ_PpMI-.js} +2 -2
- package/focus-app/server/chunks/nodes/{1.js-O2SZgyXK.js.map → 1.js-BJ_PpMI-.js.map} +1 -1
- package/focus-kit/dossier.evidence.template.json +206 -0
- package/focus-kit/dossier.v2.schema.json +925 -0
- package/focus-kit/renderer-manifest.json +34 -10
- package/focus-kit/renderer.html +4 -4
- package/focus-kit/validator.mjs +355 -16
- package/hooks/hooks.json +1 -11
- package/hooks/workspace-scope-shell.mjs +15 -9
- package/hooks/workspace-scope.opt-in.json +17 -0
- package/package.json +7 -4
- package/focus-app/client/_app/immutable/chunks/unQroC_0.js.br +0 -0
- package/focus-app/client/_app/immutable/chunks/unQroC_0.js.gz +0 -0
- package/focus-app/client/_app/immutable/entry/app.75Uzo4oj.js.br +0 -0
- package/focus-app/client/_app/immutable/entry/app.75Uzo4oj.js.gz +0 -0
- package/focus-app/client/_app/immutable/entry/start.BmwiFFoe.js +0 -1
- package/focus-app/client/_app/immutable/entry/start.BmwiFFoe.js.br +0 -2
- package/focus-app/client/_app/immutable/entry/start.BmwiFFoe.js.gz +0 -0
- package/focus-app/client/_app/immutable/nodes/1.hqfmE-jM.js.br +0 -3
- package/focus-app/client/_app/immutable/nodes/1.hqfmE-jM.js.gz +0 -0
package/focus-kit/validator.mjs
CHANGED
|
@@ -23,6 +23,9 @@ SOFTWARE.
|
|
|
23
23
|
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
|
+
// packages/focus/src/model.ts
|
|
27
|
+
var isEvidenceDossier = (doc) => "schemaVersion" in doc && doc.schemaVersion === 2;
|
|
28
|
+
|
|
26
29
|
// packages/focus/src/validation/readability.ts
|
|
27
30
|
var READABILITY_BUDGETS = { low: 2, medium: 8, high: 30 };
|
|
28
31
|
var READABILITY_LIMITS = {
|
|
@@ -45,7 +48,7 @@ var PLAIN_TOKENS = /* @__PURE__ */ new Set(["GO", "NO-GO", "NO", "PENDING", "DEF
|
|
|
45
48
|
var CHOICE_PATTERN = /\beither\b[\s\S]{0,160}?\bor\b|\bsoit\b[\s\S]{0,160}?\bsoit\b|\b(?:instead of|rather than|plut[oô]t que|versus|vs\.?|choos(?:e|ing) between|choisir entre)\b/i;
|
|
46
49
|
var SUBOPTION_PATTERN = /(?:^|[\n\r\u2028\u2029])\s*(?:[-*+•‣>]|\d+[.)]|[a-z][.)])\s+\S|\([a-z]\)[\s\S]*\([a-z]\)|\b(?:sub[- ]?options?|sous[- ]?options?)\b/i;
|
|
47
50
|
var LINE_BREAK = /[\n\r\u2028\u2029]/;
|
|
48
|
-
var blank = (
|
|
51
|
+
var blank = (text2) => !text2?.trim();
|
|
49
52
|
var asRecord = (value) => value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
50
53
|
var minutesFor = (texts) => (texts.join(" ").match(/\S+/gu)?.length ?? 0) / READABILITY_LIMITS.wordsPerMinute;
|
|
51
54
|
var validateDecisionDossierReadability = (doc) => {
|
|
@@ -103,18 +106,38 @@ var validateDecisionDossierReadability = (doc) => {
|
|
|
103
106
|
glossary.set(term, entry.definition);
|
|
104
107
|
}
|
|
105
108
|
});
|
|
106
|
-
const checkCodes = (
|
|
107
|
-
for (const code of new Set(
|
|
109
|
+
const checkCodes = (text2, path) => {
|
|
110
|
+
for (const code of new Set(text2?.match(CODE_PATTERN) ?? [])) {
|
|
108
111
|
if (!PLAIN_TOKENS.has(code) && !glossary.has(code)) {
|
|
109
112
|
refuse(path, "undefined_code", `Unexpanded code or acronym "${code}": define it in the visible glossary in plain words, or rewrite it.`);
|
|
110
113
|
}
|
|
111
114
|
}
|
|
112
115
|
};
|
|
113
116
|
const shared = [];
|
|
114
|
-
const visible = (
|
|
115
|
-
checkCodes(
|
|
116
|
-
if (
|
|
117
|
+
const visible = (text2, path) => {
|
|
118
|
+
checkCodes(text2, path);
|
|
119
|
+
if (text2) shared.push(text2);
|
|
117
120
|
};
|
|
121
|
+
if (isEvidenceDossier(doc)) {
|
|
122
|
+
doc.sources.forEach((s, i) => {
|
|
123
|
+
checkCodes(s.title, `$.sources[${i}].title`);
|
|
124
|
+
checkCodes(s.alt, `$.sources[${i}].alt`);
|
|
125
|
+
});
|
|
126
|
+
doc.citations.forEach((c, i) => {
|
|
127
|
+
checkCodes(c.label, `$.citations[${i}].label`);
|
|
128
|
+
if (c.locator.kind === "image") checkCodes(c.locator.caption, `$.citations[${i}].locator.caption`);
|
|
129
|
+
});
|
|
130
|
+
doc.evidenceGroups.forEach((g, i) => visible(g.summary, `$.evidenceGroups[${i}].summary`));
|
|
131
|
+
doc.annexes.forEach((a, i) => {
|
|
132
|
+
visible(a.title, `$.annexes[${i}].title`);
|
|
133
|
+
visible(a.summary, `$.annexes[${i}].summary`);
|
|
134
|
+
a.blocks.forEach((b, j) => {
|
|
135
|
+
const path = `$.annexes[${i}].blocks[${j}]`;
|
|
136
|
+
if (b.kind === "text") checkCodes(b.text, `${path}.text`);
|
|
137
|
+
if (b.kind === "table") [...b.columns, ...b.rows.flat()].forEach((t) => checkCodes(t, path));
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
}
|
|
118
141
|
for (const field of ["title", "subject"]) {
|
|
119
142
|
visible(doc[field], `$.${field}`);
|
|
120
143
|
if (blank(doc[field])) refuse(
|
|
@@ -230,14 +253,14 @@ var validateDecisionDossierReadability = (doc) => {
|
|
|
230
253
|
refuse("$.readability.readingBudgetMinutes", "reading_budget_exceeded", "The questions plus shared context and glossary exceed the declared reading budget; shorten the dossier to match its stakes.");
|
|
231
254
|
}
|
|
232
255
|
return issues;
|
|
233
|
-
function checkLine(
|
|
234
|
-
if (!
|
|
235
|
-
if (
|
|
256
|
+
function checkLine(text2, path, max) {
|
|
257
|
+
if (!text2) return;
|
|
258
|
+
if (text2.trim().length > max || LINE_BREAK.test(text2)) refuse(
|
|
236
259
|
path,
|
|
237
260
|
"decision_line_too_long",
|
|
238
261
|
`Use one short line of at most ${max} characters; put explanation in the question context.`
|
|
239
262
|
);
|
|
240
|
-
if (SUBOPTION_PATTERN.test(
|
|
263
|
+
if (SUBOPTION_PATTERN.test(text2)) refuse(
|
|
241
264
|
path,
|
|
242
265
|
"nested_suboptions",
|
|
243
266
|
"Expose sub-choices as separate options or questions, without nested lists or inline branches."
|
|
@@ -252,15 +275,324 @@ var validateDecisionDossierReadability = (doc) => {
|
|
|
252
275
|
];
|
|
253
276
|
if (blank(option.label)) refuse(`${path}.label`, "empty_option_label", "Name this option in a few plain words so the owner can compare it at a glance.");
|
|
254
277
|
if (blank(option.consequence)) refuse(`${path}.consequence`, "missing_consequence", "Add a one-line consequence: what choosing this option changes for the owner.");
|
|
255
|
-
for (const { field, text, max, code } of fields) {
|
|
256
|
-
if (!
|
|
257
|
-
checkCodes(
|
|
258
|
-
if (
|
|
259
|
-
if (SUBOPTION_PATTERN.test(
|
|
278
|
+
for (const { field, text: text2, max, code } of fields) {
|
|
279
|
+
if (!text2) continue;
|
|
280
|
+
checkCodes(text2, `${path}.${field}`);
|
|
281
|
+
if (text2.trim().length > max || LINE_BREAK.test(text2)) refuse(`${path}.${field}`, code, `Keep this option ${field} to one short line of at most ${max} characters; move necessary context to the question.`);
|
|
282
|
+
if (SUBOPTION_PATTERN.test(text2) || CHOICE_PATTERN.test(text2)) refuse(`${path}.${field}`, "nested_suboptions", "This option hides sub-options: expose the choices as separate options or as a separate question.");
|
|
260
283
|
}
|
|
261
284
|
}
|
|
262
285
|
};
|
|
263
286
|
|
|
287
|
+
// packages/focus/src/validation/evidence-shape.ts
|
|
288
|
+
var EvidenceError = class extends Error {
|
|
289
|
+
constructor(issue2) {
|
|
290
|
+
super(issue2.message);
|
|
291
|
+
this.issue = issue2;
|
|
292
|
+
}
|
|
293
|
+
};
|
|
294
|
+
var fail = (path, code, message) => {
|
|
295
|
+
throw new EvidenceError({ path, code, message });
|
|
296
|
+
};
|
|
297
|
+
function record(value, path, required, optional = []) {
|
|
298
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) fail(path, "invalid_evidence", "Expected a closed object");
|
|
299
|
+
const obj = value;
|
|
300
|
+
for (const key of Object.keys(obj)) if (![...required, ...optional].includes(key)) fail(`${path}.${key}`, "invalid_evidence", "Unknown evidence field");
|
|
301
|
+
for (const key of required) if (!Object.hasOwn(obj, key)) fail(`${path}.${key}`, "invalid_evidence", "Missing evidence field");
|
|
302
|
+
return obj;
|
|
303
|
+
}
|
|
304
|
+
function text(value, path, allowEmpty = false) {
|
|
305
|
+
if (typeof value !== "string" || !allowEmpty && !value.trim()) fail(path, "invalid_evidence", "Expected a non-empty string");
|
|
306
|
+
return value;
|
|
307
|
+
}
|
|
308
|
+
function array(value, path) {
|
|
309
|
+
if (!Array.isArray(value)) fail(path, "invalid_evidence", "Expected an array");
|
|
310
|
+
return value;
|
|
311
|
+
}
|
|
312
|
+
var strings = (value, path) => array(value, path).map((v, i) => text(v, `${path}[${i}]`));
|
|
313
|
+
function imageDimensions(bytes, media) {
|
|
314
|
+
const u32 = (n) => new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength).getUint32(n);
|
|
315
|
+
if (media === "image/png") {
|
|
316
|
+
if (bytes.length >= 33 && [137, 80, 78, 71, 13, 10, 26, 10].every((v, i) => bytes[i] === v) && u32(8) === 13 && u32(12) === 1229472850) return [u32(16), u32(20)];
|
|
317
|
+
} else if (bytes[0] === 255 && bytes[1] === 216) {
|
|
318
|
+
let i = 2;
|
|
319
|
+
while (i + 4 < bytes.length && bytes[i] === 255) {
|
|
320
|
+
const marker = bytes[i + 1], size = bytes[i + 2] << 8 | bytes[i + 3];
|
|
321
|
+
if (size < 2 || i + 2 + size > bytes.length) break;
|
|
322
|
+
if ([192, 193, 194, 195, 197, 198, 199, 201, 202, 203, 205, 206, 207].includes(marker) && size >= 8)
|
|
323
|
+
return [bytes[i + 7] << 8 | bytes[i + 8], bytes[i + 5] << 8 | bytes[i + 6]];
|
|
324
|
+
i += size + 2;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
return void 0;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
// packages/focus/src/validation/evidence-bytes.ts
|
|
331
|
+
var K = [
|
|
332
|
+
1116352408,
|
|
333
|
+
1899447441,
|
|
334
|
+
3049323471,
|
|
335
|
+
3921009573,
|
|
336
|
+
961987163,
|
|
337
|
+
1508970993,
|
|
338
|
+
2453635748,
|
|
339
|
+
2870763221,
|
|
340
|
+
3624381080,
|
|
341
|
+
310598401,
|
|
342
|
+
607225278,
|
|
343
|
+
1426881987,
|
|
344
|
+
1925078388,
|
|
345
|
+
2162078206,
|
|
346
|
+
2614888103,
|
|
347
|
+
3248222580,
|
|
348
|
+
3835390401,
|
|
349
|
+
4022224774,
|
|
350
|
+
264347078,
|
|
351
|
+
604807628,
|
|
352
|
+
770255983,
|
|
353
|
+
1249150122,
|
|
354
|
+
1555081692,
|
|
355
|
+
1996064986,
|
|
356
|
+
2554220882,
|
|
357
|
+
2821834349,
|
|
358
|
+
2952996808,
|
|
359
|
+
3210313671,
|
|
360
|
+
3336571891,
|
|
361
|
+
3584528711,
|
|
362
|
+
113926993,
|
|
363
|
+
338241895,
|
|
364
|
+
666307205,
|
|
365
|
+
773529912,
|
|
366
|
+
1294757372,
|
|
367
|
+
1396182291,
|
|
368
|
+
1695183700,
|
|
369
|
+
1986661051,
|
|
370
|
+
2177026350,
|
|
371
|
+
2456956037,
|
|
372
|
+
2730485921,
|
|
373
|
+
2820302411,
|
|
374
|
+
3259730800,
|
|
375
|
+
3345764771,
|
|
376
|
+
3516065817,
|
|
377
|
+
3600352804,
|
|
378
|
+
4094571909,
|
|
379
|
+
275423344,
|
|
380
|
+
430227734,
|
|
381
|
+
506948616,
|
|
382
|
+
659060556,
|
|
383
|
+
883997877,
|
|
384
|
+
958139571,
|
|
385
|
+
1322822218,
|
|
386
|
+
1537002063,
|
|
387
|
+
1747873779,
|
|
388
|
+
1955562222,
|
|
389
|
+
2024104815,
|
|
390
|
+
2227730452,
|
|
391
|
+
2361852424,
|
|
392
|
+
2428436474,
|
|
393
|
+
2756734187,
|
|
394
|
+
3204031479,
|
|
395
|
+
3329325298
|
|
396
|
+
];
|
|
397
|
+
var rr = (v, n) => v >>> n | v << 32 - n;
|
|
398
|
+
function sha256(bytes) {
|
|
399
|
+
const padded = new Uint8Array(Math.ceil((bytes.length + 9) / 64) * 64);
|
|
400
|
+
padded.set(bytes);
|
|
401
|
+
padded[bytes.length] = 128;
|
|
402
|
+
const view = new DataView(padded.buffer), bits = bytes.length * 8;
|
|
403
|
+
view.setUint32(padded.length - 8, Math.floor(bits / 4294967296));
|
|
404
|
+
view.setUint32(padded.length - 4, bits >>> 0);
|
|
405
|
+
const h = [1779033703, 3144134277, 1013904242, 2773480762, 1359893119, 2600822924, 528734635, 1541459225];
|
|
406
|
+
const w = new Int32Array(64);
|
|
407
|
+
for (let offset = 0; offset < padded.length; offset += 64) {
|
|
408
|
+
for (let i = 0; i < 16; i++) w[i] = view.getInt32(offset + i * 4);
|
|
409
|
+
for (let i = 16; i < 64; i++) {
|
|
410
|
+
const x = w[i - 15], y = w[i - 2];
|
|
411
|
+
w[i] = w[i - 16] + (rr(x, 7) ^ rr(x, 18) ^ x >>> 3) + w[i - 7] + (rr(y, 17) ^ rr(y, 19) ^ y >>> 10);
|
|
412
|
+
}
|
|
413
|
+
let [a, b, c, d, e, f, g, j] = h;
|
|
414
|
+
for (let i = 0; i < 64; i++) {
|
|
415
|
+
const t = j + (rr(e, 6) ^ rr(e, 11) ^ rr(e, 25)) + (e & f ^ ~e & g) + K[i] + w[i] | 0;
|
|
416
|
+
const u = (rr(a, 2) ^ rr(a, 13) ^ rr(a, 22)) + (a & b ^ a & c ^ b & c) | 0;
|
|
417
|
+
j = g;
|
|
418
|
+
g = f;
|
|
419
|
+
f = e;
|
|
420
|
+
e = d + t | 0;
|
|
421
|
+
d = c;
|
|
422
|
+
c = b;
|
|
423
|
+
b = a;
|
|
424
|
+
a = t + u | 0;
|
|
425
|
+
}
|
|
426
|
+
[a, b, c, d, e, f, g, j].forEach((v, i) => {
|
|
427
|
+
h[i] = h[i] + v | 0;
|
|
428
|
+
});
|
|
429
|
+
}
|
|
430
|
+
return h.map((v) => (v >>> 0).toString(16).padStart(8, "0")).join("");
|
|
431
|
+
}
|
|
432
|
+
function decodeEvidence(data) {
|
|
433
|
+
if (data.length % 4 || /[^A-Za-z0-9+/]/.test(data.replace(/={1,2}$/, ""))) throw new Error("Invalid base64");
|
|
434
|
+
const binary = atob(data);
|
|
435
|
+
if (btoa(binary) !== data) throw new Error("Non-canonical base64");
|
|
436
|
+
const bytes = new Uint8Array(binary.length);
|
|
437
|
+
for (let i = 0; i < bytes.length; i++) bytes[i] = binary.charCodeAt(i);
|
|
438
|
+
return bytes;
|
|
439
|
+
}
|
|
440
|
+
var evidenceText = (bytes) => new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(bytes);
|
|
441
|
+
var evidenceLines = (text2) => text2.split(/\r\n|\n|\r/);
|
|
442
|
+
|
|
443
|
+
// packages/focus/src/validation/evidence-sources.ts
|
|
444
|
+
var isTextSource = (media) => /^text\/[a-z0-9.+-]+$/.test(media) || ["application/json", "application/yaml", "application/x-yaml", "application/x-ndjson"].includes(media);
|
|
445
|
+
function checkSources(value, register) {
|
|
446
|
+
const lineCounts = /* @__PURE__ */ new Map();
|
|
447
|
+
const sources = array(value, "$.sources").map((raw, i) => {
|
|
448
|
+
const path = `$.sources[${i}]`;
|
|
449
|
+
const s = record(raw, path, ["id", "title", "origin", "mediaType", "encoding", "data", "sha256", "size"], ["width", "height", "alt"]);
|
|
450
|
+
for (const key of ["id", "title", "mediaType", "sha256"]) text(s[key], `${path}.${key}`);
|
|
451
|
+
register(s.id, `${path}.id`);
|
|
452
|
+
const origin = s.origin;
|
|
453
|
+
const fields = origin && Object.hasOwn(origin, "uri") ? ["uri"] : ["repo", "revision", "path"];
|
|
454
|
+
record(origin, `${path}.origin`, fields);
|
|
455
|
+
for (const key of fields) text(origin[key], `${path}.origin.${key}`);
|
|
456
|
+
if (s.encoding !== "base64") fail(`${path}.encoding`, "source_encoding", "Only original base64 bytes are accepted");
|
|
457
|
+
const media = s.mediaType;
|
|
458
|
+
if (!isTextSource(media) && !["image/png", "image/jpeg"].includes(media)) fail(`${path}.mediaType`, "unsupported_media", `Unsupported media for source ${s.id}`);
|
|
459
|
+
let bytes;
|
|
460
|
+
try {
|
|
461
|
+
bytes = decodeEvidence(text(s.data, `${path}.data`, true));
|
|
462
|
+
} catch {
|
|
463
|
+
return fail(`${path}.data`, "source_encoding", `Invalid base64 for source ${s.id}`);
|
|
464
|
+
}
|
|
465
|
+
if (!Number.isSafeInteger(s.size) || s.size !== bytes.length) fail(`${path}.size`, "source_size", `Byte size mismatch for source ${s.id}`);
|
|
466
|
+
if (!/^[a-f0-9]{64}$/.test(s.sha256) || sha256(bytes) !== s.sha256) fail(`${path}.sha256`, "source_digest", `SHA-256 mismatch for source ${s.id}`);
|
|
467
|
+
if (isTextSource(media)) {
|
|
468
|
+
try {
|
|
469
|
+
lineCounts.set(s.id, evidenceLines(evidenceText(bytes)).length);
|
|
470
|
+
} catch {
|
|
471
|
+
fail(`${path}.data`, "source_encoding", `Invalid UTF-8 for source ${s.id}`);
|
|
472
|
+
}
|
|
473
|
+
for (const key of ["width", "height", "alt"]) if (s[key] !== void 0) fail(`${path}.${key}`, "invalid_evidence", "Image metadata on text");
|
|
474
|
+
} else {
|
|
475
|
+
text(s.alt, `${path}.alt`);
|
|
476
|
+
const dimensions = imageDimensions(bytes, media);
|
|
477
|
+
if (!dimensions || !Number.isSafeInteger(s.width) || !Number.isSafeInteger(s.height) || dimensions[0] <= 0 || dimensions[1] <= 0 || dimensions[0] !== s.width || dimensions[1] !== s.height)
|
|
478
|
+
fail(path, "image_metadata", `Image dimensions/signature mismatch for source ${s.id}`);
|
|
479
|
+
}
|
|
480
|
+
return s;
|
|
481
|
+
});
|
|
482
|
+
return { sources, lineCounts };
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
// packages/focus/src/validation/evidence.ts
|
|
486
|
+
function checkEvidence(value, legacy) {
|
|
487
|
+
try {
|
|
488
|
+
const { schemaVersion: _version, sources: rawSources, citations: rawCitations, evidenceGroups: rawGroups, annexes: rawAnnexes, ...base } = value;
|
|
489
|
+
const citationLinks = /* @__PURE__ */ new Map();
|
|
490
|
+
const strip = (raw, path) => {
|
|
491
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return raw;
|
|
492
|
+
const { citationRefs, ...node } = raw;
|
|
493
|
+
if (citationRefs !== void 0) citationLinks.set(path, strings(citationRefs, `${path}.citationRefs`));
|
|
494
|
+
return node;
|
|
495
|
+
};
|
|
496
|
+
if (Array.isArray(base.sections)) base.sections = base.sections.map((raw, i) => {
|
|
497
|
+
const section = strip(raw, `$.sections[${i}]`);
|
|
498
|
+
if (section?.kind === "optionSet" && Array.isArray(section.options)) return {
|
|
499
|
+
...section,
|
|
500
|
+
options: section.options.map((o, j) => strip(o, `$.sections[${i}].options[${j}]`))
|
|
501
|
+
};
|
|
502
|
+
return section;
|
|
503
|
+
});
|
|
504
|
+
const checked = legacy(base);
|
|
505
|
+
if (!checked.ok) return checked;
|
|
506
|
+
const doc = checked.value, seen = /* @__PURE__ */ new Set(), targets = /* @__PURE__ */ new Set([doc.ref]);
|
|
507
|
+
const register = (id, path) => {
|
|
508
|
+
if (seen.has(id)) fail(path, "duplicate_id", `Duplicate id ${id}`);
|
|
509
|
+
seen.add(id);
|
|
510
|
+
};
|
|
511
|
+
doc.sections.forEach((s) => {
|
|
512
|
+
register(s.id, "$.sections");
|
|
513
|
+
targets.add(s.id);
|
|
514
|
+
targets.add(s.targetRef);
|
|
515
|
+
if (s.kind === "optionSet") s.options.forEach((o) => {
|
|
516
|
+
register(o.id, "$.sections.options");
|
|
517
|
+
targets.add(o.id);
|
|
518
|
+
targets.add(o.targetRef);
|
|
519
|
+
});
|
|
520
|
+
});
|
|
521
|
+
const { sources, lineCounts } = checkSources(rawSources, register);
|
|
522
|
+
const sourceMap = new Map(sources.map((s) => [s.id, s]));
|
|
523
|
+
const citations = array(rawCitations, "$.citations").map((raw, i) => {
|
|
524
|
+
const p = `$.citations[${i}]`, c = record(raw, p, ["id", "sourceId", "label", "locator"]);
|
|
525
|
+
for (const key of ["id", "sourceId", "label"]) text(c[key], `${p}.${key}`);
|
|
526
|
+
register(c.id, `${p}.id`);
|
|
527
|
+
const source = sourceMap.get(c.sourceId) ?? fail(`${p}.sourceId`, "unresolved_source", `Unknown source ${c.sourceId}`);
|
|
528
|
+
const loc = c.locator;
|
|
529
|
+
if (loc?.kind === "lines") {
|
|
530
|
+
record(loc, `${p}.locator`, ["kind", "start", "end"]);
|
|
531
|
+
if (!lineCounts.has(source.id)) fail(`${p}.locator`, "citation_media", `Source ${source.id} is not text`);
|
|
532
|
+
if (!Number.isSafeInteger(loc.start) || !Number.isSafeInteger(loc.end) || loc.start < 1 || loc.end < loc.start || loc.end > lineCounts.get(source.id))
|
|
533
|
+
fail(`${p}.locator`, "citation_range", `Invalid inclusive line range for ${source.id}`);
|
|
534
|
+
} else if (loc?.kind === "image") {
|
|
535
|
+
record(loc, `${p}.locator`, ["kind", "caption"]);
|
|
536
|
+
text(loc.caption, `${p}.locator.caption`);
|
|
537
|
+
if (!source.mediaType.startsWith("image/")) fail(`${p}.locator`, "citation_media", `Source ${source.id} is not an image`);
|
|
538
|
+
} else fail(`${p}.locator`, "invalid_evidence", "Unknown citation locator");
|
|
539
|
+
return c;
|
|
540
|
+
});
|
|
541
|
+
const citationIds = new Set(citations.map((c) => c.id));
|
|
542
|
+
const references = (raw, p, ids, code) => {
|
|
543
|
+
const refs = strings(raw, p);
|
|
544
|
+
for (const id of refs) if (!ids.has(id)) fail(p, code, `Unresolved reference ${id}`);
|
|
545
|
+
return refs;
|
|
546
|
+
};
|
|
547
|
+
for (const [path, refs] of citationLinks) references(refs, `${path}.citationRefs`, citationIds, "unresolved_citation");
|
|
548
|
+
const evidenceGroups = array(rawGroups, "$.evidenceGroups").map((raw, i) => {
|
|
549
|
+
const p = `$.evidenceGroups[${i}]`, g = record(raw, p, ["id", "summary", "citationRefs", "sourceRefs"]);
|
|
550
|
+
register(text(g.id, `${p}.id`), `${p}.id`);
|
|
551
|
+
text(g.summary, `${p}.summary`);
|
|
552
|
+
references(g.citationRefs, `${p}.citationRefs`, citationIds, "unresolved_citation");
|
|
553
|
+
references(g.sourceRefs, `${p}.sourceRefs`, new Set(sourceMap.keys()), "unresolved_source");
|
|
554
|
+
return g;
|
|
555
|
+
});
|
|
556
|
+
const annexes = array(rawAnnexes, "$.annexes").map((raw, i) => {
|
|
557
|
+
const p = `$.annexes[${i}]`, a = record(raw, p, ["id", "title", "summary", "blocks", "backRefs"]);
|
|
558
|
+
register(text(a.id, `${p}.id`), `${p}.id`);
|
|
559
|
+
text(a.title, `${p}.title`);
|
|
560
|
+
text(a.summary, `${p}.summary`);
|
|
561
|
+
references(a.backRefs, `${p}.backRefs`, targets, "unresolved_target");
|
|
562
|
+
array(a.blocks, `${p}.blocks`).forEach((rawBlock, j) => {
|
|
563
|
+
const bpath = `${p}.blocks[${j}]`, kind = rawBlock?.kind;
|
|
564
|
+
if (kind === "text" || kind === "code") {
|
|
565
|
+
const b = record(rawBlock, bpath, ["kind", "text"], kind === "code" ? ["language"] : []);
|
|
566
|
+
text(b.text, `${bpath}.text`, true);
|
|
567
|
+
if (b.language !== void 0) text(b.language, `${bpath}.language`);
|
|
568
|
+
} else if (kind === "table") {
|
|
569
|
+
const b = record(rawBlock, bpath, ["kind", "columns", "rows"]);
|
|
570
|
+
const columns = strings(b.columns, `${bpath}.columns`);
|
|
571
|
+
if (!columns.length) fail(bpath, "invalid_evidence", "A table needs columns");
|
|
572
|
+
array(b.rows, `${bpath}.rows`).forEach((row, k) => {
|
|
573
|
+
const cells = array(row, `${bpath}.rows[${k}]`);
|
|
574
|
+
cells.forEach((cell, l) => text(cell, `${bpath}.rows[${k}][${l}]`, true));
|
|
575
|
+
if (cells.length !== columns.length) fail(bpath, "invalid_evidence", "Table row width mismatch");
|
|
576
|
+
});
|
|
577
|
+
} else if (kind === "references") {
|
|
578
|
+
const b = record(rawBlock, bpath, ["kind", "citationRefs"]);
|
|
579
|
+
references(b.citationRefs, `${bpath}.citationRefs`, citationIds, "unresolved_citation");
|
|
580
|
+
} else fail(`${bpath}.kind`, "invalid_evidence", "Unsupported annex block (no decisions or active content)");
|
|
581
|
+
});
|
|
582
|
+
return a;
|
|
583
|
+
});
|
|
584
|
+
const attach = (node, path) => citationLinks.has(path) ? { ...node, citationRefs: citationLinks.get(path) } : node;
|
|
585
|
+
const sections = doc.sections.map((s, i) => attach(s.kind === "optionSet" ? {
|
|
586
|
+
...s,
|
|
587
|
+
options: s.options.map((o, j) => attach(o, `$.sections[${i}].options[${j}]`))
|
|
588
|
+
} : s, `$.sections[${i}]`));
|
|
589
|
+
return { ok: true, value: { ...doc, schemaVersion: 2, sections, sources, citations, evidenceGroups, annexes } };
|
|
590
|
+
} catch (error) {
|
|
591
|
+
if (error instanceof EvidenceError) return { ok: false, issues: [error.issue] };
|
|
592
|
+
throw error;
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
|
|
264
596
|
// packages/focus/src/validation/index.ts
|
|
265
597
|
var DOSSIER_SCHEMA_ID = "urn:sentropic:focus:DecisionDossierDocument:1.0.0";
|
|
266
598
|
var DOSSIER_SCHEMA_VERSION = "1.0.0";
|
|
@@ -604,7 +936,7 @@ var checkReadability = (value, path, issues) => {
|
|
|
604
936
|
...glossary !== void 0 ? { glossary } : {}
|
|
605
937
|
};
|
|
606
938
|
};
|
|
607
|
-
var
|
|
939
|
+
var validateLegacyStructure = (value) => {
|
|
608
940
|
const issues = [];
|
|
609
941
|
const doc = checkClosedObject(value, "$", [...TOP_ALLOWED], [...TOP_REQUIRED], [...TOP_STRINGS], issues);
|
|
610
942
|
if (doc === void 0) return { ok: false, issues };
|
|
@@ -696,6 +1028,13 @@ var validateDecisionDossierStructure = (value) => {
|
|
|
696
1028
|
}
|
|
697
1029
|
};
|
|
698
1030
|
};
|
|
1031
|
+
var validateDecisionDossierStructure = (value) => {
|
|
1032
|
+
if (isRecord(value) && Object.hasOwn(value, "schemaVersion")) {
|
|
1033
|
+
if (value.schemaVersion !== 2) return { ok: false, issues: [issue("$.schemaVersion", "unsupported_version", "Supported explicit version: 2; omit schemaVersion for legacy v1")] };
|
|
1034
|
+
return checkEvidence(value, validateLegacyStructure);
|
|
1035
|
+
}
|
|
1036
|
+
return validateLegacyStructure(value);
|
|
1037
|
+
};
|
|
699
1038
|
var validateDecisionDossierSemantics = (doc) => {
|
|
700
1039
|
const issues = [];
|
|
701
1040
|
const seen = /* @__PURE__ */ new Map();
|
package/hooks/hooks.json
CHANGED
|
@@ -1,17 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
"description": "
|
|
2
|
+
"description": "Prevents manual H2A MCP bypass.",
|
|
3
3
|
"hooks": {
|
|
4
|
-
"SessionStart": [
|
|
5
|
-
{
|
|
6
|
-
"matcher": ".*",
|
|
7
|
-
"hooks": [{ "type": "command", "command": "node \"${CLAUDE_PLUGIN_ROOT:-${CODEX_PLUGIN_ROOT}}/hooks/workspace-scope-guard.mjs\" --initialize-session true", "timeout": 15 }]
|
|
8
|
-
}
|
|
9
|
-
],
|
|
10
4
|
"PreToolUse": [
|
|
11
|
-
{
|
|
12
|
-
"matcher": ".*",
|
|
13
|
-
"hooks": [{ "type": "command", "command": "node \"${CLAUDE_PLUGIN_ROOT:-${CODEX_PLUGIN_ROOT}}/hooks/workspace-scope-guard.mjs\"", "timeout": 15 }]
|
|
14
|
-
},
|
|
15
5
|
{
|
|
16
6
|
"matcher": "Bash",
|
|
17
7
|
"hooks": [
|
|
@@ -507,10 +507,13 @@ export function prBump(request) {
|
|
|
507
507
|
}
|
|
508
508
|
if (!/^\d+$/.test(request.ref)) return undefined;
|
|
509
509
|
const deadline = Date.now() + 10_000;
|
|
510
|
-
const read = args => {
|
|
510
|
+
const read = (args, allowMissing = false) => {
|
|
511
511
|
if (Date.now() >= deadline) return;
|
|
512
512
|
const r = spawnSync('gh', args, { encoding: 'utf8', timeout: Math.min(4000, deadline - Date.now()), maxBuffer: 2_000_000 });
|
|
513
|
-
|
|
513
|
+
if (r.error) return;
|
|
514
|
+
if (r.status === 0) return r.stdout;
|
|
515
|
+
// Only an explicit API 404 proves absence; other failures stay unknown.
|
|
516
|
+
if (allowMissing && r.status === 1 && r.stderr.trim() === 'gh: Not Found (HTTP 404)') return null;
|
|
514
517
|
};
|
|
515
518
|
const diff = read(['pr', 'diff', request.ref, '--repo', request.repo, '--color', 'never']);
|
|
516
519
|
if (diff === undefined) return;
|
|
@@ -521,15 +524,18 @@ export function prBump(request) {
|
|
|
521
524
|
// Full before/after manifests distinguish private fixtures and nested
|
|
522
525
|
// metadata fields from the published package's top-level version.
|
|
523
526
|
try {
|
|
524
|
-
metadata ??= JSON.parse(read(['pr', 'view', request.ref, '--repo', request.repo, '--json', 'baseRefOid,headRefOid']));
|
|
525
|
-
if (![metadata.baseRefOid, metadata.headRefOid].every(s => /^[a-f0-9]{40,64}$/.test(s))) return;
|
|
526
527
|
const [hostname, owner, repo] = request.repo.split('/');
|
|
528
|
+
metadata ??= JSON.parse(read(['api', '--hostname', hostname, `repos/${owner}/${repo}/pulls/${request.ref}`]));
|
|
529
|
+
const shas = [metadata?.base?.sha, metadata?.head?.sha];
|
|
530
|
+
if (!shas.every(s => typeof s === 'string' && /^[a-f0-9]{40,64}$/.test(s))) return;
|
|
527
531
|
const endpoint = `repos/${owner}/${repo}/contents/${path.split('/').map(encodeURIComponent).join('/')}`;
|
|
528
|
-
const content = ref => read(['api', '--hostname', hostname, `${endpoint}?ref=${ref}`, '-H', 'Accept: application/vnd.github.raw+json']);
|
|
529
|
-
const before = content(metadata.
|
|
530
|
-
if (before === undefined || after === undefined) return;
|
|
531
|
-
|
|
532
|
-
|
|
532
|
+
const content = ref => read(['api', '--hostname', hostname, `${endpoint}?ref=${ref}`, '-H', 'Accept: application/vnd.github.raw+json'], true);
|
|
533
|
+
const before = content(metadata.base.sha), after = content(metadata.head.sha);
|
|
534
|
+
if (before === undefined || after === undefined || before === null && after === null) return;
|
|
535
|
+
if (before !== null) JSON.parse(before);
|
|
536
|
+
const next = after === null ? null : JSON.parse(after);
|
|
537
|
+
if (after === null) continue; // Deleting a manifest does not publish a version.
|
|
538
|
+
if (before === null ? next.name && next.version && next.private !== true : publishedBump(before, after)) return true;
|
|
533
539
|
} catch { return; }
|
|
534
540
|
}
|
|
535
541
|
return false;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"description": "Optional workspace scope guard. Qualify in an isolated lab before explicitly enabling.",
|
|
3
|
+
"hooks": {
|
|
4
|
+
"SessionStart": [
|
|
5
|
+
{
|
|
6
|
+
"matcher": ".*",
|
|
7
|
+
"hooks": [{ "type": "command", "command": "node \"${CLAUDE_PLUGIN_ROOT:-${CODEX_PLUGIN_ROOT}}/hooks/workspace-scope-guard.mjs\" --initialize-session true", "timeout": 15 }]
|
|
8
|
+
}
|
|
9
|
+
],
|
|
10
|
+
"PreToolUse": [
|
|
11
|
+
{
|
|
12
|
+
"matcher": ".*",
|
|
13
|
+
"hooks": [{ "type": "command", "command": "node \"${CLAUDE_PLUGIN_ROOT:-${CODEX_PLUGIN_ROOT}}/hooks/workspace-scope-guard.mjs\"", "timeout": 15 }]
|
|
14
|
+
}
|
|
15
|
+
]
|
|
16
|
+
}
|
|
17
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentropic/h2a",
|
|
3
|
-
"version": "0.98.7-rc.
|
|
3
|
+
"version": "0.98.7-rc.8",
|
|
4
4
|
"description": "h2a — the unified CLI + core for human-to-agent coordination.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -48,6 +48,8 @@
|
|
|
48
48
|
"focus-kit/validator.mjs",
|
|
49
49
|
"focus-kit/dossier.template.json",
|
|
50
50
|
"focus-kit/dossier.schema.json",
|
|
51
|
+
"focus-kit/dossier.v2.schema.json",
|
|
52
|
+
"focus-kit/dossier.evidence.template.json",
|
|
51
53
|
"focus-kit/ecosystem.json"
|
|
52
54
|
],
|
|
53
55
|
"publishConfig": {
|
|
@@ -61,17 +63,18 @@
|
|
|
61
63
|
"prepack": "node ../../scripts/check-focus-app.mjs && node ../../scripts/build-focus-dossier.mjs --check && chmod +x dist/bin.js"
|
|
62
64
|
},
|
|
63
65
|
"dependencies": {
|
|
66
|
+
"@sentropic/focus": "0.5.0-rc.8",
|
|
64
67
|
"@hono/mcp": "^0.3.0",
|
|
65
68
|
"@hono/node-server": "^2.0.12",
|
|
66
69
|
"@modelcontextprotocol/sdk": "^1.30.0",
|
|
67
70
|
"@sentropic/cluster-mesh": "0.16.0",
|
|
68
71
|
"@sentropic/contracts": "^0.3.0",
|
|
69
72
|
"@sentropic/events": "^0.2.0",
|
|
70
|
-
"@sentropic/track": "0.98.7-rc.
|
|
71
|
-
"hono": "^4.13.
|
|
73
|
+
"@sentropic/track": "0.98.7-rc.8",
|
|
74
|
+
"hono": "^4.13.13",
|
|
72
75
|
"toml-eslint-parser": "0.10.1"
|
|
73
76
|
},
|
|
74
77
|
"peerDependencies": {
|
|
75
|
-
"@sentropic/h2a-runtime": "0.98.7-rc.
|
|
78
|
+
"@sentropic/h2a-runtime": "0.98.7-rc.8"
|
|
76
79
|
}
|
|
77
80
|
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{l as o,a as r}from"../chunks/unQroC_0.js";export{o as load_css,r as start};
|
|
Binary file
|
|
Binary file
|