@hasna/skills 0.8.11 → 0.8.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -0
- package/bin/index.js +672 -435
- package/bin/mcp.js +62 -2
- package/bin/migrate.js +1 -1
- package/bin/server.js +1 -1
- package/bin/worker.js +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +412 -177
- package/dist/lib/agent-discovery.d.ts +1 -1
- package/dist/lib/claude-settings-witness.d.ts +19 -0
- package/dist/sdk/index.js +499 -265
- package/docs/plugin-admission.md +67 -0
- package/package.json +1 -1
package/bin/index.js
CHANGED
|
@@ -36868,7 +36868,7 @@ var package_default;
|
|
|
36868
36868
|
var init_package = __esm(() => {
|
|
36869
36869
|
package_default = {
|
|
36870
36870
|
name: "@hasna/skills",
|
|
36871
|
-
version: "0.8.
|
|
36871
|
+
version: "0.8.12",
|
|
36872
36872
|
description: "Skills library for AI coding agents",
|
|
36873
36873
|
type: "module",
|
|
36874
36874
|
bin: {
|
|
@@ -43298,7 +43298,9 @@ function assertAgentPolicyCollections(policy) {
|
|
|
43298
43298
|
text(source.path);
|
|
43299
43299
|
requireBound(source.sha256 === null || typeof source.sha256 === "string" && /^[a-f0-9]{64}$/.test(source.sha256));
|
|
43300
43300
|
if (source.hashMode !== undefined)
|
|
43301
|
-
requireBound(["bytes", "path-bytes", "claude-plugin-registry", "claude-marketplace-registry"].includes(source.hashMode) && source.format === undefined && source.fields === undefined && (source.hashMode === "bytes" || source.sha256 !== null));
|
|
43301
|
+
requireBound(["bytes", "path-bytes", "claude-plugin-registry", "claude-marketplace-registry", "claude-settings-v1"].includes(source.hashMode) && source.format === undefined && source.fields === undefined && (source.hashMode === "bytes" || source.sha256 !== null));
|
|
43302
|
+
if (source.hashMode === "claude-settings-v1")
|
|
43303
|
+
requireBound(agent === "claude" && value.agent === "claude" && value.method === "reviewed" && !/[\x00-\x1f\x7f]/.test(source.path) && isAbsolute3(source.path) && resolve5(source.path) === source.path && basename3(source.path) === "settings.json");
|
|
43302
43304
|
if (source.hashMode === "claude-marketplace-registry")
|
|
43303
43305
|
requireBound(agent === "claude" && value.agent === "claude" && value.method === "reviewed" && !/[\x00-\x1f\x7f]/.test(source.path) && isAbsolute3(source.path) && resolve5(source.path) === source.path && basename3(source.path) === "known_marketplaces.json");
|
|
43304
43306
|
if (source.hashMode === "claude-plugin-registry") {
|
|
@@ -54505,10 +54507,232 @@ var init_claude_marketplace_registry = __esm(() => {
|
|
|
54505
54507
|
CLAUDE_MARKETPLACE_REGISTRY_LIMITS = Object.freeze({ bytes: 1024 * 1024, rows: 1024, depth: 32, nodes: 65536, stringCharacters: 16384, pathCharacters: 4096 });
|
|
54506
54508
|
});
|
|
54507
54509
|
|
|
54508
|
-
// src/lib/
|
|
54510
|
+
// src/lib/claude-settings-witness.ts
|
|
54509
54511
|
import { createHash as createHash12 } from "crypto";
|
|
54510
|
-
import {
|
|
54511
|
-
import {
|
|
54512
|
+
import { closeSync as closeSync10, constants as constants10, fstatSync as fstatSync10, lstatSync as lstatSync16, openSync as openSync10, readSync as readSync8 } from "fs";
|
|
54513
|
+
import { basename as basename7, dirname as dirname13, isAbsolute as isAbsolute13, resolve as resolve14 } from "path";
|
|
54514
|
+
function need3(value, reason) {
|
|
54515
|
+
if (!value)
|
|
54516
|
+
throw new Error(`Claude settings witness ${reason}`);
|
|
54517
|
+
}
|
|
54518
|
+
function absolutePath2(value) {
|
|
54519
|
+
need3(typeof value === "string" && value.length > 0 && value.length <= CLAUDE_SETTINGS_WITNESS_LIMITS.pathCharacters && !/[\x00-\x1f\x7f]/.test(value) && isAbsolute13(value) && resolve14(value) === value, "requires a normalized absolute path");
|
|
54520
|
+
}
|
|
54521
|
+
function parents2(path) {
|
|
54522
|
+
const result2 = [];
|
|
54523
|
+
for (let at2 = dirname13(path);; at2 = dirname13(at2)) {
|
|
54524
|
+
const stat2 = lstatSync16(at2, { bigint: true });
|
|
54525
|
+
need3(stat2.isDirectory() && !stat2.isSymbolicLink(), "path traverses a symlink or non-directory");
|
|
54526
|
+
result2.push([at2, stat2]);
|
|
54527
|
+
if (at2 === dirname13(at2))
|
|
54528
|
+
return result2;
|
|
54529
|
+
}
|
|
54530
|
+
}
|
|
54531
|
+
function readSettings(path, budget) {
|
|
54532
|
+
absolutePath2(path);
|
|
54533
|
+
need3(basename7(path) === "settings.json", "requires settings.json");
|
|
54534
|
+
need3(Number.isSafeInteger(budget.remaining) && budget.remaining >= 0, "has an invalid byte budget");
|
|
54535
|
+
const ancestors2 = parents2(path), initial2 = lstatSync16(path, { bigint: true });
|
|
54536
|
+
need3(initial2.isFile() && !initial2.isSymbolicLink() && initial2.size <= BigInt(CLAUDE_SETTINGS_WITNESS_LIMITS.bytes), "is not a bounded regular file");
|
|
54537
|
+
need3(initial2.size <= BigInt(budget.remaining), "exceeds its aggregate byte limit");
|
|
54538
|
+
const fd = openSync10(path, constants10.O_RDONLY | constants10.O_NOFOLLOW | constants10.O_NONBLOCK);
|
|
54539
|
+
try {
|
|
54540
|
+
const opened = fstatSync10(fd, { bigint: true });
|
|
54541
|
+
need3(opened.isFile() && sameFile2(initial2, opened), "changed during open");
|
|
54542
|
+
const bytes = Buffer.alloc(Number(opened.size) + 1);
|
|
54543
|
+
let length = 0;
|
|
54544
|
+
while (length < bytes.length) {
|
|
54545
|
+
const count = readSync8(fd, bytes, length, bytes.length - length, null);
|
|
54546
|
+
if (!count)
|
|
54547
|
+
break;
|
|
54548
|
+
length += count;
|
|
54549
|
+
}
|
|
54550
|
+
const after2 = fstatSync10(fd, { bigint: true }), current = lstatSync16(path, { bigint: true });
|
|
54551
|
+
need3(current.isFile() && sameFile2(opened, after2) && sameFile2(after2, current) && BigInt(length) === opened.size, "changed during read");
|
|
54552
|
+
for (const [ancestor, before2] of ancestors2) {
|
|
54553
|
+
const now3 = lstatSync16(ancestor, { bigint: true });
|
|
54554
|
+
need3(now3.isDirectory() && before2.dev === now3.dev && before2.ino === now3.ino && before2.mode === now3.mode, "parent changed during read");
|
|
54555
|
+
}
|
|
54556
|
+
budget.remaining -= length;
|
|
54557
|
+
try {
|
|
54558
|
+
return new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(bytes.subarray(0, length));
|
|
54559
|
+
} catch {
|
|
54560
|
+
throw new Error("Claude settings witness is not strict UTF-8");
|
|
54561
|
+
}
|
|
54562
|
+
} finally {
|
|
54563
|
+
closeSync10(fd);
|
|
54564
|
+
}
|
|
54565
|
+
}
|
|
54566
|
+
function parse6(text2) {
|
|
54567
|
+
let at2 = 0, nodes = 0;
|
|
54568
|
+
const numberPattern = /-?(?:0|[1-9][0-9]*)(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?/y;
|
|
54569
|
+
const space = () => {
|
|
54570
|
+
while (at2 < text2.length && /[\x20\t\r\n]/.test(text2[at2]))
|
|
54571
|
+
at2++;
|
|
54572
|
+
};
|
|
54573
|
+
function string() {
|
|
54574
|
+
need3(text2[at2] === '"', "contains invalid JSON");
|
|
54575
|
+
const start = at2++;
|
|
54576
|
+
while (at2 < text2.length) {
|
|
54577
|
+
const character = text2[at2++];
|
|
54578
|
+
if (character === '"') {
|
|
54579
|
+
let value2;
|
|
54580
|
+
try {
|
|
54581
|
+
value2 = JSON.parse(text2.slice(start, at2));
|
|
54582
|
+
} catch {
|
|
54583
|
+
throw new Error("Claude settings witness contains invalid JSON string");
|
|
54584
|
+
}
|
|
54585
|
+
need3(value2.length <= CLAUDE_SETTINGS_WITNESS_LIMITS.stringCharacters, "exceeds its string limit");
|
|
54586
|
+
return value2;
|
|
54587
|
+
}
|
|
54588
|
+
if (character === "\\")
|
|
54589
|
+
at2++;
|
|
54590
|
+
}
|
|
54591
|
+
throw new Error("Claude settings witness contains an unterminated JSON string");
|
|
54592
|
+
}
|
|
54593
|
+
function value(depth) {
|
|
54594
|
+
need3(depth <= CLAUDE_SETTINGS_WITNESS_LIMITS.depth && ++nodes <= CLAUDE_SETTINGS_WITNESS_LIMITS.nodes, "exceeds its nesting or node limit");
|
|
54595
|
+
space();
|
|
54596
|
+
const character = text2[at2];
|
|
54597
|
+
if (character === '"')
|
|
54598
|
+
return { kind: "string", value: string() };
|
|
54599
|
+
if (character === "{" || character === "[") {
|
|
54600
|
+
at2++;
|
|
54601
|
+
space();
|
|
54602
|
+
const object4 = character === "{", end = object4 ? "}" : "]", entries = [], items = [], keys2 = new Set;
|
|
54603
|
+
if (text2[at2] !== end)
|
|
54604
|
+
while (true) {
|
|
54605
|
+
if (object4) {
|
|
54606
|
+
space();
|
|
54607
|
+
const key = string();
|
|
54608
|
+
need3(!keys2.has(key), "contains a duplicate JSON key");
|
|
54609
|
+
keys2.add(key);
|
|
54610
|
+
space();
|
|
54611
|
+
need3(text2[at2++] === ":", "contains invalid JSON");
|
|
54612
|
+
entries.push([key, value(depth + 1)]);
|
|
54613
|
+
} else
|
|
54614
|
+
items.push(value(depth + 1));
|
|
54615
|
+
space();
|
|
54616
|
+
if (text2[at2] === end)
|
|
54617
|
+
break;
|
|
54618
|
+
need3(text2[at2++] === ",", "contains invalid JSON");
|
|
54619
|
+
}
|
|
54620
|
+
at2++;
|
|
54621
|
+
return object4 ? { kind: "object", entries } : { kind: "array", items };
|
|
54622
|
+
}
|
|
54623
|
+
for (const literal of ["true", "false", "null"])
|
|
54624
|
+
if (text2.startsWith(literal, at2)) {
|
|
54625
|
+
at2 += literal.length;
|
|
54626
|
+
return { kind: "literal", value: literal };
|
|
54627
|
+
}
|
|
54628
|
+
numberPattern.lastIndex = at2;
|
|
54629
|
+
const number = numberPattern.exec(text2);
|
|
54630
|
+
need3(number, "contains invalid JSON");
|
|
54631
|
+
at2 += number[0].length;
|
|
54632
|
+
return { kind: "number", value: number[0] };
|
|
54633
|
+
}
|
|
54634
|
+
const root2 = value(0);
|
|
54635
|
+
space();
|
|
54636
|
+
need3(at2 === text2.length && root2.kind === "object", "requires a JSON object without trailing content");
|
|
54637
|
+
need3(root2.entries.length <= CLAUDE_SETTINGS_WITNESS_LIMITS.rows, "exceeds its settings field limit");
|
|
54638
|
+
return root2;
|
|
54639
|
+
}
|
|
54640
|
+
function canonical3(value) {
|
|
54641
|
+
if (value.kind === "object")
|
|
54642
|
+
return { kind: "object", entries: value.entries.map(([key, child]) => [key, canonical3(child)]).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0) };
|
|
54643
|
+
if (value.kind === "array")
|
|
54644
|
+
return { kind: "array", items: value.items.map(canonical3) };
|
|
54645
|
+
return value;
|
|
54646
|
+
}
|
|
54647
|
+
function settingsDigest(text2) {
|
|
54648
|
+
const value = parse6(text2);
|
|
54649
|
+
value.entries = value.entries.filter(([key, child]) => {
|
|
54650
|
+
if (key === "model") {
|
|
54651
|
+
need3(child.kind === "string", "contains an invalid model selection");
|
|
54652
|
+
return !BUILTIN_MODEL_SELECTIONS.has(child.value);
|
|
54653
|
+
}
|
|
54654
|
+
if (BOOLEAN_PREFERENCES.has(key)) {
|
|
54655
|
+
need3(child.kind === "literal" && (child.value === "true" || child.value === "false"), "contains an invalid display preference");
|
|
54656
|
+
return false;
|
|
54657
|
+
}
|
|
54658
|
+
if (Object.hasOwn(ENUM_PREFERENCES, key)) {
|
|
54659
|
+
need3(child.kind === "string" && ENUM_PREFERENCES[key].includes(child.value), "contains an invalid display preference");
|
|
54660
|
+
return false;
|
|
54661
|
+
}
|
|
54662
|
+
return true;
|
|
54663
|
+
});
|
|
54664
|
+
return createHash12("sha256").update("hasna.skills.claude-settings.v1\x00").update(JSON.stringify(canonical3(value))).digest("hex");
|
|
54665
|
+
}
|
|
54666
|
+
function hashClaudeSettingsReplacement(text2, budget) {
|
|
54667
|
+
need3(typeof text2 === "string", "requires settings text");
|
|
54668
|
+
const bytes = Buffer.byteLength(text2);
|
|
54669
|
+
need3(bytes <= CLAUDE_SETTINGS_WITNESS_LIMITS.bytes && Number.isSafeInteger(budget.remaining) && budget.remaining >= bytes, "exceeds its byte limit");
|
|
54670
|
+
budget.remaining -= bytes;
|
|
54671
|
+
return settingsDigest(text2);
|
|
54672
|
+
}
|
|
54673
|
+
function captureClaudeSettings(path, budget = { remaining: 256 * 1024 * 1024 }) {
|
|
54674
|
+
return { path, hashMode: "claude-settings-v1", sha256: settingsDigest(readSettings(path, budget)) };
|
|
54675
|
+
}
|
|
54676
|
+
var CLAUDE_SETTINGS_WITNESS_LIMITS, sameFile2 = (a, b) => a.dev === b.dev && a.ino === b.ino && a.mode === b.mode && a.uid === b.uid && a.gid === b.gid && a.nlink === b.nlink && a.size === b.size && a.mtimeNs === b.mtimeNs && a.ctimeNs === b.ctimeNs, BOOLEAN_PREFERENCES, ENUM_PREFERENCES, BUILTIN_MODEL_SELECTIONS;
|
|
54677
|
+
var init_claude_settings_witness = __esm(() => {
|
|
54678
|
+
CLAUDE_SETTINGS_WITNESS_LIMITS = Object.freeze({ bytes: 1024 * 1024, rows: 1024, depth: 32, nodes: 65536, stringCharacters: 16384, pathCharacters: 4096 });
|
|
54679
|
+
BOOLEAN_PREFERENCES = new Set([
|
|
54680
|
+
"autoScrollEnabled",
|
|
54681
|
+
"axScreenReader",
|
|
54682
|
+
"emojiCompletionEnabled",
|
|
54683
|
+
"prefersReducedMotion",
|
|
54684
|
+
"showTurnDuration",
|
|
54685
|
+
"spinnerTipsEnabled",
|
|
54686
|
+
"syntaxHighlightingDisabled",
|
|
54687
|
+
"terminalProgressBarEnabled",
|
|
54688
|
+
"terminalTitleFromRename",
|
|
54689
|
+
"verbose",
|
|
54690
|
+
"wheelScrollAccelerationEnabled"
|
|
54691
|
+
]);
|
|
54692
|
+
ENUM_PREFERENCES = Object.freeze({
|
|
54693
|
+
editorMode: ["normal", "vim"],
|
|
54694
|
+
tui: ["default", "fullscreen"],
|
|
54695
|
+
viewMode: ["default", "verbose", "focus"]
|
|
54696
|
+
});
|
|
54697
|
+
BUILTIN_MODEL_SELECTIONS = new Set([
|
|
54698
|
+
"default",
|
|
54699
|
+
"best",
|
|
54700
|
+
"fable",
|
|
54701
|
+
"fable[1m]",
|
|
54702
|
+
"sonnet",
|
|
54703
|
+
"sonnet[1m]",
|
|
54704
|
+
"opus",
|
|
54705
|
+
"opus[1m]",
|
|
54706
|
+
"haiku",
|
|
54707
|
+
"opusplan",
|
|
54708
|
+
"claude-fable-5-1",
|
|
54709
|
+
"claude-fable-5",
|
|
54710
|
+
"claude-fable-5[1m]",
|
|
54711
|
+
"claude-opus-5",
|
|
54712
|
+
"claude-sonnet-5",
|
|
54713
|
+
"claude-haiku-4-5-20251001",
|
|
54714
|
+
"claude-opus-4-6",
|
|
54715
|
+
"claude-sonnet-4-5",
|
|
54716
|
+
"claude-sonnet-4-5-20250929",
|
|
54717
|
+
"claude-opus-4-8",
|
|
54718
|
+
"claude-opus-4-8[1m]",
|
|
54719
|
+
"claude-opus-4-7",
|
|
54720
|
+
"claude-sonnet-4-6",
|
|
54721
|
+
"claude-opus-4-5-20251101",
|
|
54722
|
+
"claude-opus-4-5",
|
|
54723
|
+
"claude-haiku-4-5",
|
|
54724
|
+
"claude-fable-5-1[1m]",
|
|
54725
|
+
"claude-opus-5[1m]",
|
|
54726
|
+
"claude-opus-4-7[1m]",
|
|
54727
|
+
"claude-opus-4-6[1m]",
|
|
54728
|
+
"claude-sonnet-4-6[1m]"
|
|
54729
|
+
]);
|
|
54730
|
+
});
|
|
54731
|
+
|
|
54732
|
+
// src/lib/agent-discovery.ts
|
|
54733
|
+
import { createHash as createHash13 } from "crypto";
|
|
54734
|
+
import { lstatSync as lstatSync17, readFileSync as readFileSync14, readdirSync as readdirSync9, realpathSync as realpathSync4 } from "fs";
|
|
54735
|
+
import { basename as basename8, dirname as dirname14, isAbsolute as isAbsolute14, join as join28, resolve as resolve15, sep as sep5 } from "path";
|
|
54512
54736
|
function parseConfig(text2, path, toml = false) {
|
|
54513
54737
|
try {
|
|
54514
54738
|
const value = toml ? Bun.TOML.parse(text2) : JSON.parse(text2);
|
|
@@ -54520,12 +54744,12 @@ function parseConfig(text2, path, toml = false) {
|
|
|
54520
54744
|
}
|
|
54521
54745
|
}
|
|
54522
54746
|
function safe4(path) {
|
|
54523
|
-
if (!
|
|
54747
|
+
if (!isAbsolute14(path) || path.includes("\x00"))
|
|
54524
54748
|
throw new Error("Expected an absolute native discovery path");
|
|
54525
|
-
for (let cursor = path;; cursor =
|
|
54526
|
-
if (
|
|
54749
|
+
for (let cursor = path;; cursor = dirname14(cursor)) {
|
|
54750
|
+
if (lstatSync17(cursor, { throwIfNoEntry: false })?.isSymbolicLink())
|
|
54527
54751
|
throw new Error(`Refusing symlink native discovery input: ${cursor}`);
|
|
54528
|
-
if (
|
|
54752
|
+
if (dirname14(cursor) === cursor)
|
|
54529
54753
|
break;
|
|
54530
54754
|
}
|
|
54531
54755
|
}
|
|
@@ -54533,7 +54757,7 @@ function read2(path, changes) {
|
|
|
54533
54757
|
safe4(path);
|
|
54534
54758
|
if (changes?.has(path))
|
|
54535
54759
|
return changes.get(path);
|
|
54536
|
-
const stat2 =
|
|
54760
|
+
const stat2 = lstatSync17(path, { throwIfNoEntry: false });
|
|
54537
54761
|
if (!stat2)
|
|
54538
54762
|
return null;
|
|
54539
54763
|
if (!stat2.isFile() || stat2.size > 16 * 1024 * 1024)
|
|
@@ -54541,6 +54765,14 @@ function read2(path, changes) {
|
|
|
54541
54765
|
return readFileSync14(path, "utf8");
|
|
54542
54766
|
}
|
|
54543
54767
|
function projected(source, changes, budget = discoveryByteBudget()) {
|
|
54768
|
+
if (source.hashMode === "claude-settings-v1") {
|
|
54769
|
+
if (source.format !== undefined || source.fields !== undefined || source.managedPlugins !== undefined || typeof source.sha256 !== "string" || !/^[a-f0-9]{64}$/.test(source.sha256))
|
|
54770
|
+
throw new Error("Claude settings witnesses require exact typed metadata");
|
|
54771
|
+
const current = captureClaudeSettings(source.path, budget).sha256;
|
|
54772
|
+
if (current !== source.sha256)
|
|
54773
|
+
throw new Error(`Native discovery input changed; run skills hook install with a fresh discovery review: ${source.path}`);
|
|
54774
|
+
return changes?.has(source.path) ? hashClaudeSettingsReplacement(changes.get(source.path), budget) : current;
|
|
54775
|
+
}
|
|
54544
54776
|
if (source.hashMode === "claude-marketplace-registry") {
|
|
54545
54777
|
if (source.format !== undefined || source.fields !== undefined || source.managedPlugins !== undefined || typeof source.sha256 !== "string" || !/^[a-f0-9]{64}$/.test(source.sha256) || changes?.has(source.path))
|
|
54546
54778
|
throw new Error("Claude marketplace witnesses require an exact reviewed registry without synthetic changes");
|
|
@@ -54598,6 +54830,8 @@ function verifyAgentDiscovery(binding) {
|
|
|
54598
54830
|
safe4(root2);
|
|
54599
54831
|
}
|
|
54600
54832
|
function assertMarketplaceBinding(binding, source) {
|
|
54833
|
+
if (source.hashMode === "claude-settings-v1" && (binding.agent !== "claude" || binding.method !== "reviewed" || basename8(source.path) !== "settings.json"))
|
|
54834
|
+
throw new Error("Claude settings witnesses require explicit reviewed Claude configuration");
|
|
54601
54835
|
if (source.hashMode === "claude-marketplace-registry" && (binding.agent !== "claude" || binding.method !== "reviewed"))
|
|
54602
54836
|
throw new Error("Claude marketplace witnesses require explicit reviewed Claude discovery");
|
|
54603
54837
|
}
|
|
@@ -54608,9 +54842,9 @@ function rebindAgentDiscovery(binding, changes) {
|
|
|
54608
54842
|
return { ...source, sha256: projected(source, changes, budget) };
|
|
54609
54843
|
}) };
|
|
54610
54844
|
}
|
|
54611
|
-
function assertProjectDiscovery(agent, directories, home,
|
|
54845
|
+
function assertProjectDiscovery(agent, directories, home, canonical4 = resolve15, reviewed) {
|
|
54612
54846
|
for (const directory of directories) {
|
|
54613
|
-
const isHome =
|
|
54847
|
+
const isHome = resolve15(directory) === resolve15(home);
|
|
54614
54848
|
if (agent === "hermes") {
|
|
54615
54849
|
assertHermesEnvironment(home);
|
|
54616
54850
|
continue;
|
|
@@ -54619,7 +54853,7 @@ function assertProjectDiscovery(agent, directories, home, canonical3 = resolve14
|
|
|
54619
54853
|
continue;
|
|
54620
54854
|
const paths = agent === "claude" ? [...isHome ? [] : [".claude/settings.json"], ".claude/settings.local.json"] : agent === "codex" ? [".codex/config.toml"] : agent === "gemini" ? [".gemini/settings.json"] : agent === "opencode" ? ["opencode.json", "opencode.jsonc", ".opencode/opencode.json", ".opencode/opencode.jsonc"] : [".cursor/hooks.json"];
|
|
54621
54855
|
for (const suffix of paths) {
|
|
54622
|
-
const path =
|
|
54856
|
+
const path = canonical4(join28(directory, suffix)), raw = read2(path);
|
|
54623
54857
|
if (raw === null)
|
|
54624
54858
|
continue;
|
|
54625
54859
|
if (suffix.endsWith(".jsonc"))
|
|
@@ -54632,25 +54866,25 @@ function assertProjectDiscovery(agent, directories, home, canonical3 = resolve14
|
|
|
54632
54866
|
const managed = reviewed.sources.flatMap((source) => source.hashMode === "claude-plugin-registry" ? source.managedPlugins ?? [] : []);
|
|
54633
54867
|
if (exact && projected(exact) === exact.sha256 && managed.length) {
|
|
54634
54868
|
const bindings = managed.map((item) => readPluginBinding(item.storeRoot, item.bindingId));
|
|
54635
|
-
admittedPlugins = Object.entries(config.enabledPlugins).every(([id, enabled]) => typeof enabled === "boolean" && bindings.some((binding) => binding.target.pluginId === id && binding.target.registrations.some((scope) => scope.scope === "project" && scope.projectPath ===
|
|
54869
|
+
admittedPlugins = Object.entries(config.enabledPlugins).every(([id, enabled]) => typeof enabled === "boolean" && bindings.some((binding) => binding.target.pluginId === id && binding.target.registrations.some((scope) => scope.scope === "project" && scope.projectPath === canonical4(directory))));
|
|
54636
54870
|
}
|
|
54637
54871
|
}
|
|
54638
54872
|
if (keys2.some((key) => config[key] !== undefined && !(key === "enabledPlugins" && admittedPlugins)) || config.disableAllHooks === true || config.disableBundledSkills === false || config.hooksConfig?.enabled === false || config.permission?.skill !== undefined || config.permissions?.deny?.some((rule) => typeof rule === "string" && /^Skill(?:\(|$)/.test(rule)))
|
|
54639
54873
|
throw new Error(`NATIVE_SKILL_DRIFT: higher-precedence project skill or hook configuration requires review: ${path}`);
|
|
54640
54874
|
}
|
|
54641
54875
|
if (agent === "claude") {
|
|
54642
|
-
const commands =
|
|
54876
|
+
const commands = canonical4(join28(directory, ".claude/commands"));
|
|
54643
54877
|
safe4(commands);
|
|
54644
|
-
if (
|
|
54878
|
+
if (lstatSync17(commands, { throwIfNoEntry: false })?.isDirectory() && readdirSync9(commands).length)
|
|
54645
54879
|
throw new Error("NATIVE_SKILL_DRIFT: legacy project command discovery requires a dedicated format adapter");
|
|
54646
54880
|
}
|
|
54647
54881
|
}
|
|
54648
54882
|
}
|
|
54649
54883
|
function resolveAgentDiscovery(options) {
|
|
54650
|
-
const
|
|
54884
|
+
const canonical4 = options.canonical ?? resolve15, home = resolve15(options.home), agent = options.agent;
|
|
54651
54885
|
const sources = [], roots = new Set, builtinNames = [];
|
|
54652
54886
|
const witness = (path, format, fields) => {
|
|
54653
|
-
const source = { path:
|
|
54887
|
+
const source = { path: canonical4(path), sha256: null, ...format ? { format, fields } : {} };
|
|
54654
54888
|
source.sha256 = projected(source);
|
|
54655
54889
|
sources.push(source);
|
|
54656
54890
|
return read2(source.path);
|
|
@@ -54678,7 +54912,7 @@ function resolveAgentDiscovery(options) {
|
|
|
54678
54912
|
continue;
|
|
54679
54913
|
if (normalized.startsWith("~") && normalized !== "~" && !normalized.startsWith("~/"))
|
|
54680
54914
|
unresolved("user-specific tilde expansion requires a separate discovery adapter");
|
|
54681
|
-
const path = normalized === "~" ? home : normalized.startsWith("~/") ? join28(home, normalized.slice(2)) :
|
|
54915
|
+
const path = normalized === "~" ? home : normalized.startsWith("~/") ? join28(home, normalized.slice(2)) : resolve15(home, ".hermes", normalized);
|
|
54682
54916
|
safe4(path);
|
|
54683
54917
|
roots.add(path);
|
|
54684
54918
|
}
|
|
@@ -54687,21 +54921,21 @@ function resolveAgentDiscovery(options) {
|
|
|
54687
54921
|
const executable = Bun.which("gemini");
|
|
54688
54922
|
if (executable) {
|
|
54689
54923
|
let packageRoot;
|
|
54690
|
-
for (let directory =
|
|
54924
|
+
for (let directory = dirname14(realpathSync4(executable)), depth = 0;depth < 8; directory = dirname14(directory), depth++) {
|
|
54691
54925
|
const path = join28(directory, "package.json"), raw = read2(path);
|
|
54692
54926
|
if (raw !== null && parseConfig(raw, path).name === "@google/gemini-cli") {
|
|
54693
54927
|
packageRoot = directory;
|
|
54694
54928
|
witness(path);
|
|
54695
54929
|
break;
|
|
54696
54930
|
}
|
|
54697
|
-
if (
|
|
54931
|
+
if (dirname14(directory) === directory)
|
|
54698
54932
|
break;
|
|
54699
54933
|
}
|
|
54700
54934
|
if (!packageRoot)
|
|
54701
54935
|
unresolved("installed Gemini package layout is not recognized");
|
|
54702
54936
|
const builtinRoot = join28(packageRoot, "bundle/builtin");
|
|
54703
54937
|
safe4(builtinRoot);
|
|
54704
|
-
if (!
|
|
54938
|
+
if (!lstatSync17(builtinRoot, { throwIfNoEntry: false })?.isDirectory())
|
|
54705
54939
|
unresolved("installed Gemini builtin root is missing");
|
|
54706
54940
|
for (const name of readdirSync9(builtinRoot).sort()) {
|
|
54707
54941
|
const text2 = witness(join28(builtinRoot, name, "SKILL.md"));
|
|
@@ -54722,12 +54956,14 @@ function resolveAgentDiscovery(options) {
|
|
|
54722
54956
|
if (review.sources.some((source) => source.format !== undefined || source.fields !== undefined))
|
|
54723
54957
|
throw new Error("Explicit discovery reviews require full source-file hashes");
|
|
54724
54958
|
verifyAgentDiscovery(supplied);
|
|
54725
|
-
if (
|
|
54959
|
+
if (review.sources.some((source) => source.hashMode === "claude-settings-v1" && source.path !== canonical4(configPath)))
|
|
54960
|
+
throw new Error("Semantic settings witnesses must name the configured Claude configuration source");
|
|
54961
|
+
if (!review.sources.some((source) => source.path === canonical4(configPath)))
|
|
54726
54962
|
throw new Error("Discovery review must include the agent configuration source");
|
|
54727
54963
|
return { ...supplied, roots: [...new Set([...roots, ...supplied.roots])].sort(), sources: [...sources, ...review.sources], ...agent === "gemini" ? { builtinNames } : {} };
|
|
54728
54964
|
}
|
|
54729
54965
|
function plugin(root2) {
|
|
54730
|
-
root2 =
|
|
54966
|
+
root2 = canonical4(root2);
|
|
54731
54967
|
safe4(root2);
|
|
54732
54968
|
const manifestPath = join28(root2, agent === "claude" ? ".claude-plugin/plugin.json" : ".codex-plugin/plugin.json");
|
|
54733
54969
|
const raw = witness(manifestPath);
|
|
@@ -54739,7 +54975,7 @@ function resolveAgentDiscovery(options) {
|
|
|
54739
54975
|
unresolved("plugin hooks require a separate no-skill-injection review");
|
|
54740
54976
|
const commands = join28(root2, "commands");
|
|
54741
54977
|
safe4(commands);
|
|
54742
|
-
if (agent === "claude" && (manifest.commands !== undefined ||
|
|
54978
|
+
if (agent === "claude" && (manifest.commands !== undefined || lstatSync17(commands, { throwIfNoEntry: false })?.isDirectory() && readdirSync9(commands).length))
|
|
54743
54979
|
unresolved("legacy command discovery requires retirement or a dedicated format adapter");
|
|
54744
54980
|
const rootSkill = witness(join28(root2, "SKILL.md"));
|
|
54745
54981
|
if (rootSkill !== null)
|
|
@@ -54750,18 +54986,18 @@ function resolveAgentDiscovery(options) {
|
|
|
54750
54986
|
if (agent === "claude")
|
|
54751
54987
|
roots.add(join28(root2, "skills"));
|
|
54752
54988
|
for (const value of declared) {
|
|
54753
|
-
const path =
|
|
54989
|
+
const path = resolve15(root2, value);
|
|
54754
54990
|
if (path !== root2 && !path.startsWith(root2 + sep5))
|
|
54755
54991
|
unresolved("plugin skill path escapes its root");
|
|
54756
|
-
roots.add(path.endsWith(`${sep5}SKILL.md`) ?
|
|
54992
|
+
roots.add(path.endsWith(`${sep5}SKILL.md`) ? dirname14(path) : path);
|
|
54757
54993
|
}
|
|
54758
54994
|
}
|
|
54759
54995
|
if (agent === "claude") {
|
|
54760
54996
|
const registrations = witness(join28(home, ".claude/plugins/installed_plugins.json"));
|
|
54761
54997
|
const installed = registrations === null ? {} : parseConfig(registrations, join28(home, ".claude/plugins/installed_plugins.json")).plugins;
|
|
54762
|
-
const commands =
|
|
54998
|
+
const commands = canonical4(join28(home, ".claude/commands"));
|
|
54763
54999
|
safe4(commands);
|
|
54764
|
-
if (
|
|
55000
|
+
if (lstatSync17(commands, { throwIfNoEntry: false })?.isDirectory() && readdirSync9(commands).length)
|
|
54765
55001
|
unresolved("legacy home command discovery requires a dedicated format adapter");
|
|
54766
55002
|
for (const [id, enabled] of Object.entries(config.enabledPlugins ?? {})) {
|
|
54767
55003
|
if (enabled === false)
|
|
@@ -54781,7 +55017,7 @@ function resolveAgentDiscovery(options) {
|
|
|
54781
55017
|
unresolved("unsupported plugin enablement");
|
|
54782
55018
|
const split2 = id.lastIndexOf("@"), name = id.slice(0, split2), marketplace = id.slice(split2 + 1);
|
|
54783
55019
|
const market = config.marketplaces?.[marketplace] ?? (marketplace === "personal" ? { source_type: "local", source: home } : undefined);
|
|
54784
|
-
if (split2 < 1 || market?.source_type !== "local" || typeof market.source !== "string" || !
|
|
55020
|
+
if (split2 < 1 || market?.source_type !== "local" || typeof market.source !== "string" || !isAbsolute14(market.source))
|
|
54785
55021
|
unresolved("enabled plugin marketplace is not an explicit local source");
|
|
54786
55022
|
const catalogText = witness(join28(market.source, ".agents/plugins/marketplace.json"));
|
|
54787
55023
|
if (catalogText === null)
|
|
@@ -54789,7 +55025,7 @@ function resolveAgentDiscovery(options) {
|
|
|
54789
55025
|
const catalog = parseConfig(catalogText, join28(market.source, ".agents/plugins/marketplace.json")), matches2 = Array.isArray(catalog.plugins) ? catalog.plugins.filter((item) => item.name === name) : [];
|
|
54790
55026
|
if (matches2.length !== 1 || matches2[0]?.source?.source !== "local" || typeof matches2[0]?.source?.path !== "string")
|
|
54791
55027
|
unresolved("plugin catalog source is missing or ambiguous");
|
|
54792
|
-
plugin(
|
|
55028
|
+
plugin(resolve15(market.source, matches2[0].source.path));
|
|
54793
55029
|
}
|
|
54794
55030
|
} else if (agent === "opencode") {
|
|
54795
55031
|
if (witness(join28(home, ".config/opencode/opencode.jsonc")) !== null || witness(join28(home, ".config/opencode/config.json")) !== null)
|
|
@@ -54797,18 +55033,18 @@ function resolveAgentDiscovery(options) {
|
|
|
54797
55033
|
if ((config.plugin?.length ?? 0) > 0 || config.skills?.urls?.length)
|
|
54798
55034
|
unresolved("external plugin or remote skill source");
|
|
54799
55035
|
for (const path of config.skills?.paths ?? []) {
|
|
54800
|
-
if (typeof path !== "string" || !
|
|
55036
|
+
if (typeof path !== "string" || !isAbsolute14(path))
|
|
54801
55037
|
unresolved("relative or malformed added skill root");
|
|
54802
55038
|
roots.add(path);
|
|
54803
55039
|
}
|
|
54804
55040
|
const localPlugins = join28(home, ".config/opencode/plugins");
|
|
54805
55041
|
safe4(localPlugins);
|
|
54806
|
-
if (
|
|
55042
|
+
if (lstatSync17(localPlugins, { throwIfNoEntry: false }) && readdirSync9(localPlugins).some((name) => name !== "skills-cli.js"))
|
|
54807
55043
|
unresolved("additional local plugin hooks require review");
|
|
54808
55044
|
} else if (agent === "hermes") {
|
|
54809
55045
|
for (const directory of [join28(home, ".hermes/plugins"), join28(home, ".hermes/hermes-agent")]) {
|
|
54810
55046
|
safe4(directory);
|
|
54811
|
-
if (
|
|
55047
|
+
if (lstatSync17(directory, { throwIfNoEntry: false }))
|
|
54812
55048
|
unresolved("installed runtime/plugin discovery requires reviewed source bindings");
|
|
54813
55049
|
}
|
|
54814
55050
|
if (Bun.which("hermes") || Object.keys(config.plugins ?? {}).length)
|
|
@@ -54818,11 +55054,11 @@ function resolveAgentDiscovery(options) {
|
|
|
54818
55054
|
unresolved("custom extension or skill paths");
|
|
54819
55055
|
const directory = join28(home, ".gemini/extensions");
|
|
54820
55056
|
safe4(directory);
|
|
54821
|
-
if (
|
|
55057
|
+
if (lstatSync17(directory, { throwIfNoEntry: false }))
|
|
54822
55058
|
for (const name of readdirSync9(directory)) {
|
|
54823
55059
|
const root2 = join28(directory, name);
|
|
54824
55060
|
safe4(root2);
|
|
54825
|
-
if (!
|
|
55061
|
+
if (!lstatSync17(root2)?.isDirectory())
|
|
54826
55062
|
continue;
|
|
54827
55063
|
const raw = witness(join28(root2, "gemini-extension.json"));
|
|
54828
55064
|
if (raw === null)
|
|
@@ -54833,9 +55069,9 @@ function resolveAgentDiscovery(options) {
|
|
|
54833
55069
|
roots.add(join28(root2, "skills"));
|
|
54834
55070
|
}
|
|
54835
55071
|
}
|
|
54836
|
-
return { agent, roots: [...roots].sort(), sources, method: "automatic", ...agent === "gemini" ? { builtinNames } : {}, ...agent === "hermes" ? { directories: captureDiscoveryDirectories([join28(home, ".hermes/plugins"), join28(home, ".hermes/hermes-agent")].map((path) =>
|
|
55072
|
+
return { agent, roots: [...roots].sort(), sources, method: "automatic", ...agent === "gemini" ? { builtinNames } : {}, ...agent === "hermes" ? { directories: captureDiscoveryDirectories([join28(home, ".hermes/plugins"), join28(home, ".hermes/hermes-agent")].map((path) => canonical4(path))) } : {} };
|
|
54837
55073
|
}
|
|
54838
|
-
var digest = (text2) =>
|
|
55074
|
+
var digest = (text2) => createHash13("sha256").update(text2).digest("hex");
|
|
54839
55075
|
var init_agent_discovery = __esm(() => {
|
|
54840
55076
|
init_agent_policy_limits();
|
|
54841
55077
|
init_agent_hermes();
|
|
@@ -54845,6 +55081,7 @@ var init_agent_discovery = __esm(() => {
|
|
|
54845
55081
|
init_plugin_discovery();
|
|
54846
55082
|
init_plugin_admission();
|
|
54847
55083
|
init_claude_marketplace_registry();
|
|
55084
|
+
init_claude_settings_witness();
|
|
54848
55085
|
init_agent_discovery_directories();
|
|
54849
55086
|
});
|
|
54850
55087
|
|
|
@@ -55006,16 +55243,16 @@ var init_agent_codex = __esm(() => {
|
|
|
55006
55243
|
});
|
|
55007
55244
|
|
|
55008
55245
|
// src/lib/agent-integration.ts
|
|
55009
|
-
import { createHash as
|
|
55010
|
-
import { existsSync as existsSync15, lstatSync as
|
|
55011
|
-
import { dirname as
|
|
55246
|
+
import { createHash as createHash14, randomUUID as randomUUID6 } from "crypto";
|
|
55247
|
+
import { existsSync as existsSync15, lstatSync as lstatSync18, statSync as statSync8, mkdirSync as mkdirSync7, readFileSync as readFileSync15, readdirSync as readdirSync10, opendirSync as opendirSync5, readlinkSync as readlinkSync2, realpathSync as realpathSync5, renameSync as renameSync4, rmdirSync as rmdirSync3, writeFileSync as writeFileSync5, unlinkSync as unlinkSync4, chmodSync, openSync as openSync11, closeSync as closeSync11, fsyncSync as fsyncSync3, fstatSync as fstatSync11, readSync as readSync9, constants as constants11, linkSync as linkSync2 } from "fs";
|
|
55248
|
+
import { dirname as dirname15, join as join29, resolve as resolve16, relative as relative5, isAbsolute as isAbsolute15, sep as sep6 } from "path";
|
|
55012
55249
|
import { homedir as homedir4 } from "os";
|
|
55013
55250
|
function assertSafePath(path) {
|
|
55014
|
-
let cursor =
|
|
55251
|
+
let cursor = resolve16(path);
|
|
55015
55252
|
while (true) {
|
|
55016
|
-
if (
|
|
55253
|
+
if (lstatSync18(cursor, { throwIfNoEntry: false })?.isSymbolicLink())
|
|
55017
55254
|
throw new Error(`Refusing symlink path: ${cursor}`);
|
|
55018
|
-
const parent =
|
|
55255
|
+
const parent = dirname15(cursor);
|
|
55019
55256
|
if (parent === cursor)
|
|
55020
55257
|
return;
|
|
55021
55258
|
cursor = parent;
|
|
@@ -55024,16 +55261,16 @@ function assertSafePath(path) {
|
|
|
55024
55261
|
function readRootAlias(home, agent) {
|
|
55025
55262
|
assertSafePath(home);
|
|
55026
55263
|
const realHome = realpathSync5(home), alias = join29(realHome, `.${agent}`);
|
|
55027
|
-
const stat2 =
|
|
55264
|
+
const stat2 = lstatSync18(alias, { throwIfNoEntry: false, bigint: true });
|
|
55028
55265
|
if (!stat2?.isSymbolicLink())
|
|
55029
55266
|
throw new Error(`Agent root alias changed after planning: ${alias}`);
|
|
55030
|
-
const link2 = readlinkSync2(alias), targetPath =
|
|
55267
|
+
const link2 = readlinkSync2(alias), targetPath = resolve16(dirname15(alias), link2);
|
|
55031
55268
|
assertSafePath(targetPath);
|
|
55032
|
-
const targetStat =
|
|
55269
|
+
const targetStat = lstatSync18(targetPath, { throwIfNoEntry: false });
|
|
55033
55270
|
if (!targetStat?.isDirectory())
|
|
55034
55271
|
throw new Error(`Agent root alias must target an existing directory: ${alias}`);
|
|
55035
55272
|
const target = realpathSync5(targetPath), inside = relative5(realHome, target);
|
|
55036
|
-
if (!inside || inside === ".." || inside.startsWith(`..${sep6}`) ||
|
|
55273
|
+
if (!inside || inside === ".." || inside.startsWith(`..${sep6}`) || isAbsolute15(inside))
|
|
55037
55274
|
throw new Error(`Agent root alias target must be inside the real home: ${alias}`);
|
|
55038
55275
|
return { agent, home: realHome, alias, target, link: link2, aliasIdentity: `${stat2.dev}:${stat2.ino}:${stat2.ctimeNs}`, targetIdentity: `${targetStat.dev}:${targetStat.ino}` };
|
|
55039
55276
|
}
|
|
@@ -55042,14 +55279,14 @@ function rootAliases(home, allowed = false) {
|
|
|
55042
55279
|
return [];
|
|
55043
55280
|
const result2 = [];
|
|
55044
55281
|
for (const agent of ["claude", "codex"])
|
|
55045
|
-
if (
|
|
55282
|
+
if (lstatSync18(join29(home, `.${agent}`), { throwIfNoEntry: false })?.isSymbolicLink())
|
|
55046
55283
|
result2.push(readRootAlias(home, agent));
|
|
55047
55284
|
if (result2.some((item, index) => result2.slice(index + 1).some((other) => item.target === other.target || item.target.startsWith(other.target + sep6) || other.target.startsWith(item.target + sep6))))
|
|
55048
55285
|
throw new Error("Agent root alias targets must not overlap");
|
|
55049
55286
|
return result2;
|
|
55050
55287
|
}
|
|
55051
55288
|
function canonicalAgentPath(path, aliases) {
|
|
55052
|
-
const absolute =
|
|
55289
|
+
const absolute = resolve16(path), binding = aliases.find((item) => absolute === item.alias || absolute.startsWith(item.alias + sep6));
|
|
55053
55290
|
return binding ? join29(binding.target, relative5(binding.alias, absolute)) : absolute;
|
|
55054
55291
|
}
|
|
55055
55292
|
function recheckRootAliases(aliases) {
|
|
@@ -55063,35 +55300,35 @@ function recheckRootAliases(aliases) {
|
|
|
55063
55300
|
}
|
|
55064
55301
|
function readNativeBytes(path, maximum = 64 * 1024 * 1024) {
|
|
55065
55302
|
assertSafePath(path);
|
|
55066
|
-
const before2 =
|
|
55303
|
+
const before2 = lstatSync18(path);
|
|
55067
55304
|
if (!before2.isFile() || before2.size > maximum)
|
|
55068
55305
|
throw new Error("Unsupported or oversized native skill file");
|
|
55069
|
-
const descriptor =
|
|
55306
|
+
const descriptor = openSync11(path, constants11.O_RDONLY | constants11.O_NOFOLLOW | constants11.O_NONBLOCK);
|
|
55070
55307
|
try {
|
|
55071
|
-
const opened =
|
|
55308
|
+
const opened = fstatSync11(descriptor);
|
|
55072
55309
|
if (!opened.isFile() || opened.dev !== before2.dev || opened.ino !== before2.ino || opened.size !== before2.size)
|
|
55073
55310
|
throw new Error("Native skill file changed while reading");
|
|
55074
55311
|
const bytes = Buffer.allocUnsafe(before2.size + 1);
|
|
55075
55312
|
let length = 0;
|
|
55076
55313
|
while (length < bytes.length) {
|
|
55077
|
-
const count =
|
|
55314
|
+
const count = readSync9(descriptor, bytes, length, bytes.length - length, null);
|
|
55078
55315
|
if (!count)
|
|
55079
55316
|
break;
|
|
55080
55317
|
length += count;
|
|
55081
55318
|
}
|
|
55082
|
-
const after2 =
|
|
55319
|
+
const after2 = fstatSync11(descriptor);
|
|
55083
55320
|
if (length !== before2.size || after2.size !== before2.size || after2.mtimeMs !== opened.mtimeMs || after2.ctimeMs !== opened.ctimeMs)
|
|
55084
55321
|
throw new Error("Native skill file changed while reading");
|
|
55085
55322
|
return bytes.subarray(0, length);
|
|
55086
55323
|
} finally {
|
|
55087
|
-
|
|
55324
|
+
closeSync11(descriptor);
|
|
55088
55325
|
}
|
|
55089
55326
|
}
|
|
55090
55327
|
function treeHash(root2) {
|
|
55091
|
-
const hash2 =
|
|
55328
|
+
const hash2 = createHash14("sha256");
|
|
55092
55329
|
let bytes = 0, files = 0;
|
|
55093
55330
|
function visit2(path) {
|
|
55094
|
-
const stat2 =
|
|
55331
|
+
const stat2 = lstatSync18(path);
|
|
55095
55332
|
if (stat2.isSymbolicLink())
|
|
55096
55333
|
throw new Error(`Refusing symlink in skill: ${path}`);
|
|
55097
55334
|
const rel = relative5(root2, path);
|
|
@@ -55117,11 +55354,11 @@ function treeHash(root2) {
|
|
|
55117
55354
|
function projectAncestorDirectories(projects) {
|
|
55118
55355
|
const directories = new Set;
|
|
55119
55356
|
for (const project of projects) {
|
|
55120
|
-
for (let path =
|
|
55357
|
+
for (let path = resolve16(project), depth = 0;; depth++) {
|
|
55121
55358
|
if (depth >= 100)
|
|
55122
55359
|
throw new Error("NATIVE_SKILL_DRIFT: project ancestor discovery limit exceeded");
|
|
55123
55360
|
directories.add(path);
|
|
55124
|
-
const parent =
|
|
55361
|
+
const parent = dirname15(path);
|
|
55125
55362
|
if (parent === path)
|
|
55126
55363
|
break;
|
|
55127
55364
|
path = parent;
|
|
@@ -55148,10 +55385,10 @@ function inventoryNativeSkills(home = homedir4(), options = {}) {
|
|
|
55148
55385
|
throw new Error("Native skill discovery metadata limit exceeded");
|
|
55149
55386
|
}
|
|
55150
55387
|
function emptySiblingCacheAlias(path, parent) {
|
|
55151
|
-
const link2 = readlinkSync2(path), target =
|
|
55152
|
-
if (
|
|
55388
|
+
const link2 = readlinkSync2(path), target = resolve16(parent, link2);
|
|
55389
|
+
if (dirname15(target) !== parent || (isAbsolute15(link2) ? link2 !== target : dirname15(link2) !== "."))
|
|
55153
55390
|
return false;
|
|
55154
|
-
if (!
|
|
55391
|
+
if (!lstatSync18(target, { throwIfNoEntry: false })?.isDirectory())
|
|
55155
55392
|
return false;
|
|
55156
55393
|
const scan = cacheScans.get(target);
|
|
55157
55394
|
return Boolean(scan?.complete && !scan.hasSkills && scan.entries <= maxAliasProofEntries);
|
|
@@ -55163,7 +55400,7 @@ function inventoryNativeSkills(home = homedir4(), options = {}) {
|
|
|
55163
55400
|
assertSafePath(path);
|
|
55164
55401
|
if (!existsSync15(path))
|
|
55165
55402
|
return scan;
|
|
55166
|
-
const stat2 =
|
|
55403
|
+
const stat2 = lstatSync18(path);
|
|
55167
55404
|
if (stat2.isFile())
|
|
55168
55405
|
return scan;
|
|
55169
55406
|
if (!stat2.isDirectory())
|
|
@@ -55182,7 +55419,7 @@ function inventoryNativeSkills(home = homedir4(), options = {}) {
|
|
|
55182
55419
|
}
|
|
55183
55420
|
const bridge = !vendor && isOwnedCliBridge(path, bridgePaths);
|
|
55184
55421
|
const rootAlias = aliases.find((item) => path === item.target || path.startsWith(item.target + sep6));
|
|
55185
|
-
entries.push({ agent, path, hash: treeHash(path), managed, vendor, ...agent === "codex" && path.startsWith(canonicalAgentPath(join29(home, ".codex", "skills", ".system"), aliases) + sep6) ? { system: true } : {}, ...bridge ? { bridge: true, bridgeHome:
|
|
55422
|
+
entries.push({ agent, path, hash: treeHash(path), managed, vendor, ...agent === "codex" && path.startsWith(canonicalAgentPath(join29(home, ".codex", "skills", ".system"), aliases) + sep6) ? { system: true } : {}, ...bridge ? { bridge: true, bridgeHome: resolve16(home) } : {}, ...rootAlias ? { rootAlias } : {} });
|
|
55186
55423
|
return scan;
|
|
55187
55424
|
}
|
|
55188
55425
|
if (depth > (vendor ? 32 : 3))
|
|
@@ -55209,7 +55446,7 @@ function inventoryNativeSkills(home = homedir4(), options = {}) {
|
|
|
55209
55446
|
if (isVendor && !options.includeVendor)
|
|
55210
55447
|
continue;
|
|
55211
55448
|
const child = join29(path, name);
|
|
55212
|
-
if (isVendor &&
|
|
55449
|
+
if (isVendor && lstatSync18(child, { throwIfNoEntry: false })?.isSymbolicLink()) {
|
|
55213
55450
|
const target = statSync8(child, { throwIfNoEntry: false });
|
|
55214
55451
|
if (target?.isFile() || pluginCache && target?.isDirectory() && emptySiblingCacheAlias(child, path)) {
|
|
55215
55452
|
scan.entries++;
|
|
@@ -55331,7 +55568,7 @@ function configureHooks(config, agent, command, profileId, nativeReady) {
|
|
|
55331
55568
|
function disableCodexSkills(text2, skills, aliases, bridgePath) {
|
|
55332
55569
|
const bundled = disableCodexBundledSkills(text2);
|
|
55333
55570
|
let result2 = bundled;
|
|
55334
|
-
const bridgeSelector = (entry) => typeof entry.name === "string" && entry.name.trim() === CLI_BRIDGE_NAME || typeof entry.path === "string" && [
|
|
55571
|
+
const bridgeSelector = (entry) => typeof entry.name === "string" && entry.name.trim() === CLI_BRIDGE_NAME || typeof entry.path === "string" && [resolve16(bridgePath), resolve16(join29(bridgePath, "SKILL.md"))].includes(canonicalAgentPath(entry.path, aliases));
|
|
55335
55572
|
const previousConfig = Bun.TOML.parse(bundled).skills?.config;
|
|
55336
55573
|
if (previousConfig !== undefined && (!Array.isArray(previousConfig) || previousConfig.some((entry) => !entry || typeof entry !== "object" || entry.path !== undefined && entry.name !== undefined)))
|
|
55337
55574
|
throw new Error("Codex skill controls require one path or name selector per [[skills.config]] entry; review ambiguous entries before running skills hook install");
|
|
@@ -55343,7 +55580,7 @@ function disableCodexSkills(text2, skills, aliases, bridgePath) {
|
|
|
55343
55580
|
result2 = result2.replace(CODEX_SKILL_CONFIG_SECTIONS, (section) => {
|
|
55344
55581
|
const parsed = Bun.TOML.parse(section);
|
|
55345
55582
|
const declared = parsed.skills?.config?.[0];
|
|
55346
|
-
if (!declared || !(skill.enabled && bridgeSelector(declared)) && !(typeof declared.path === "string" && [
|
|
55583
|
+
if (!declared || !(skill.enabled && bridgeSelector(declared)) && !(typeof declared.path === "string" && [resolve16(path), resolve16(skill.path)].includes(canonicalAgentPath(declared.path, aliases))))
|
|
55347
55584
|
return section;
|
|
55348
55585
|
found = true;
|
|
55349
55586
|
return /^\s*enabled\s*=/m.test(section) ? section.replace(/^\s*enabled\s*=.*$/m, `enabled = ${skill.enabled}`) : `${section.trimEnd()}
|
|
@@ -55461,7 +55698,7 @@ function planAgentIntegration(options) {
|
|
|
55461
55698
|
version: CLI_BRIDGE_VERSION,
|
|
55462
55699
|
digest: CLI_BRIDGE_DIGEST,
|
|
55463
55700
|
agents: [...new Set([...priorAgents, ...options.agents])].sort(),
|
|
55464
|
-
home:
|
|
55701
|
+
home: resolve16(home),
|
|
55465
55702
|
includeVendor: true,
|
|
55466
55703
|
...options.agents.includes("hermes") ? { supervisors: { ...policy.bridge?.supervisors, hermes: { path: join29(dataDir3, "agent-hooks", "hermes.js"), runtime: process.execPath, sha256: sha(renderHermesSupervisor(bindings.get("hermes").command, bindings.get("hermes").profileId)) } } } : {},
|
|
55467
55704
|
commands: { ...policy.bridge?.commands, ...Object.fromEntries([...bindings].map(([agent, binding]) => [agent, binding.command])) },
|
|
@@ -55478,7 +55715,7 @@ function planAgentIntegration(options) {
|
|
|
55478
55715
|
}
|
|
55479
55716
|
function atomicWrite2(path, content) {
|
|
55480
55717
|
assertSafePath(path);
|
|
55481
|
-
mkdirSync7(
|
|
55718
|
+
mkdirSync7(dirname15(path), { recursive: true, mode: 448 });
|
|
55482
55719
|
const temporary = `${path}.skills-${randomUUID6()}`;
|
|
55483
55720
|
try {
|
|
55484
55721
|
writeFileSync5(temporary, content, { mode: 384, flag: "wx" });
|
|
@@ -55491,10 +55728,10 @@ function atomicWrite2(path, content) {
|
|
|
55491
55728
|
function applyAgentIntegration(plan) {
|
|
55492
55729
|
const policyPath = join29(plan.dataDir, "agent-policy.json");
|
|
55493
55730
|
assertSafePath(policyPath);
|
|
55494
|
-
const currentText = (path) =>
|
|
55731
|
+
const currentText = (path) => resolve16(path) === resolve16(policyPath) ? readManagedSkillPolicySnapshot(plan.dataDir)?.text ?? null : readOptional(path);
|
|
55495
55732
|
readManagedSkillPolicySnapshot(plan.dataDir);
|
|
55496
55733
|
for (const change of plan.changes)
|
|
55497
|
-
if (
|
|
55734
|
+
if (resolve16(change.path) === resolve16(policyPath))
|
|
55498
55735
|
parseManagedSkillPolicy(change.after);
|
|
55499
55736
|
const aliases = plan.rootAliases ?? [];
|
|
55500
55737
|
recheckRootAliases(aliases);
|
|
@@ -55524,7 +55761,7 @@ function applyAgentIntegration(plan) {
|
|
|
55524
55761
|
recheckRootAliases(aliases);
|
|
55525
55762
|
if (currentText(change.path) !== change.before)
|
|
55526
55763
|
throw new Error(`Configuration changed after planning: ${change.path}`);
|
|
55527
|
-
for (let directory =
|
|
55764
|
+
for (let directory = dirname15(change.path);!existsSync15(directory); directory = dirname15(directory))
|
|
55528
55765
|
createdDirectories.add(directory);
|
|
55529
55766
|
const after2 = change.after;
|
|
55530
55767
|
atomicWrite2(change.path, after2);
|
|
@@ -55564,11 +55801,11 @@ function applyAgentIntegration(plan) {
|
|
|
55564
55801
|
}
|
|
55565
55802
|
function syncArchiveDirectory(path) {
|
|
55566
55803
|
assertSafePath(path);
|
|
55567
|
-
const descriptor =
|
|
55804
|
+
const descriptor = openSync11(path, constants11.O_RDONLY | constants11.O_DIRECTORY | constants11.O_NOFOLLOW | constants11.O_NONBLOCK);
|
|
55568
55805
|
try {
|
|
55569
55806
|
fsyncSync3(descriptor);
|
|
55570
55807
|
} finally {
|
|
55571
|
-
|
|
55808
|
+
closeSync11(descriptor);
|
|
55572
55809
|
}
|
|
55573
55810
|
}
|
|
55574
55811
|
function writeArchiveJournal(path, value) {
|
|
@@ -55576,18 +55813,18 @@ function writeArchiveJournal(path, value) {
|
|
|
55576
55813
|
const temporary = `${path}.skills-${randomUUID6()}`;
|
|
55577
55814
|
let descriptor;
|
|
55578
55815
|
try {
|
|
55579
|
-
descriptor =
|
|
55816
|
+
descriptor = openSync11(temporary, constants11.O_WRONLY | constants11.O_CREAT | constants11.O_EXCL | constants11.O_NOFOLLOW, 384);
|
|
55580
55817
|
writeFileSync5(descriptor, `${JSON.stringify(value)}
|
|
55581
55818
|
`);
|
|
55582
55819
|
fsyncSync3(descriptor);
|
|
55583
|
-
|
|
55820
|
+
closeSync11(descriptor);
|
|
55584
55821
|
descriptor = undefined;
|
|
55585
55822
|
renameSync4(temporary, path);
|
|
55586
|
-
syncArchiveDirectory(
|
|
55823
|
+
syncArchiveDirectory(dirname15(path));
|
|
55587
55824
|
} finally {
|
|
55588
55825
|
if (descriptor !== undefined)
|
|
55589
|
-
|
|
55590
|
-
if (
|
|
55826
|
+
closeSync11(descriptor);
|
|
55827
|
+
if (lstatSync18(temporary, { throwIfNoEntry: false }))
|
|
55591
55828
|
unlinkSync4(temporary);
|
|
55592
55829
|
}
|
|
55593
55830
|
}
|
|
@@ -55620,7 +55857,7 @@ function archiveNativeSkills(inventory, options) {
|
|
|
55620
55857
|
const moved = [];
|
|
55621
55858
|
const verifyArchive = (entry) => {
|
|
55622
55859
|
assertSafePath(entry.archive);
|
|
55623
|
-
const stat2 =
|
|
55860
|
+
const stat2 = lstatSync18(entry.archive);
|
|
55624
55861
|
if (entry.discoveryOnly ? !stat2.isFile() : !stat2.isDirectory())
|
|
55625
55862
|
throw new Error("Archive type changed");
|
|
55626
55863
|
if ((entry.discoveryOnly ? sha(readNativeBytes(entry.archive)) : treeHash(entry.archive)) !== entry.hash)
|
|
@@ -55628,14 +55865,14 @@ function archiveNativeSkills(inventory, options) {
|
|
|
55628
55865
|
};
|
|
55629
55866
|
assertSafePath(archiveRoot);
|
|
55630
55867
|
const created = [];
|
|
55631
|
-
for (let path = archiveRoot;!existsSync15(path); path =
|
|
55868
|
+
for (let path = archiveRoot;!existsSync15(path); path = dirname15(path))
|
|
55632
55869
|
created.push(path);
|
|
55633
55870
|
mkdirSync7(archiveRoot, { recursive: true, mode: 448 });
|
|
55634
55871
|
try {
|
|
55635
55872
|
for (const directory of created)
|
|
55636
55873
|
syncArchiveDirectory(directory);
|
|
55637
55874
|
if (created.length)
|
|
55638
|
-
syncArchiveDirectory(
|
|
55875
|
+
syncArchiveDirectory(dirname15(created.at(-1)));
|
|
55639
55876
|
writeArchiveJournal(receiptPath, journal);
|
|
55640
55877
|
for (const [index, entry] of selected.entries()) {
|
|
55641
55878
|
recheckRootAliases(aliases);
|
|
@@ -55647,7 +55884,7 @@ function archiveNativeSkills(inventory, options) {
|
|
|
55647
55884
|
writeArchiveJournal(receiptPath, journal);
|
|
55648
55885
|
renameSync4(move.source, move.archive);
|
|
55649
55886
|
moved.push(move);
|
|
55650
|
-
syncArchiveDirectory(
|
|
55887
|
+
syncArchiveDirectory(dirname15(move.source));
|
|
55651
55888
|
syncArchiveDirectory(archiveRoot);
|
|
55652
55889
|
verifyArchive(move);
|
|
55653
55890
|
move.status = "archived";
|
|
@@ -55668,7 +55905,7 @@ function archiveNativeSkills(inventory, options) {
|
|
|
55668
55905
|
recheckRootAliases(aliases);
|
|
55669
55906
|
assertSafePath(entry.source);
|
|
55670
55907
|
assertSafePath(entry.archive);
|
|
55671
|
-
if (
|
|
55908
|
+
if (lstatSync18(entry.source, { throwIfNoEntry: false })) {
|
|
55672
55909
|
entry.status = "recovery-required";
|
|
55673
55910
|
entry.conflict = "source-occupied";
|
|
55674
55911
|
continue;
|
|
@@ -55682,10 +55919,10 @@ function archiveNativeSkills(inventory, options) {
|
|
|
55682
55919
|
}
|
|
55683
55920
|
if (entry.discoveryOnly) {
|
|
55684
55921
|
linkSync2(entry.archive, entry.source);
|
|
55685
|
-
syncArchiveDirectory(
|
|
55922
|
+
syncArchiveDirectory(dirname15(entry.source));
|
|
55686
55923
|
unlinkSync4(entry.archive);
|
|
55687
55924
|
} else {
|
|
55688
|
-
if (
|
|
55925
|
+
if (lstatSync18(entry.source, { throwIfNoEntry: false })) {
|
|
55689
55926
|
entry.status = "recovery-required";
|
|
55690
55927
|
entry.conflict = "source-occupied";
|
|
55691
55928
|
continue;
|
|
@@ -55693,7 +55930,7 @@ function archiveNativeSkills(inventory, options) {
|
|
|
55693
55930
|
renameSync4(entry.archive, entry.source);
|
|
55694
55931
|
}
|
|
55695
55932
|
entry.status = "restored";
|
|
55696
|
-
syncArchiveDirectory(
|
|
55933
|
+
syncArchiveDirectory(dirname15(entry.source));
|
|
55697
55934
|
syncArchiveDirectory(archiveRoot);
|
|
55698
55935
|
} catch {
|
|
55699
55936
|
entry.status = "recovery-required";
|
|
@@ -55713,7 +55950,7 @@ function archiveNativeSkills(inventory, options) {
|
|
|
55713
55950
|
return { entries: entries.map(({ status, conflict, ...entry }) => entry), receiptPath, ...aliases.length ? { rootAliases: aliases } : {} };
|
|
55714
55951
|
}
|
|
55715
55952
|
function assertManagedAgentBridge(agent, options = {}) {
|
|
55716
|
-
const home =
|
|
55953
|
+
const home = resolve16(options.home ?? homedir4()), dataDir3 = options.dataDir ?? getDataDirReadOnly();
|
|
55717
55954
|
assertSafePath(join29(dataDir3, "agent-policy.json"));
|
|
55718
55955
|
const snapshot = readManagedSkillPolicySnapshot(dataDir3);
|
|
55719
55956
|
if (!snapshot)
|
|
@@ -55836,7 +56073,7 @@ function assertNativeExportAllowed(dataDir3 = getDataDirReadOnly()) {
|
|
|
55836
56073
|
if (requiresCliSkillLoading(dataDir3))
|
|
55837
56074
|
throw new Error("NATIVE_SKILL_EXPORT_DISABLED: this station loads skills through the Skills CLI; use skills sync --selection-profile <id>");
|
|
55838
56075
|
}
|
|
55839
|
-
var sha = (data) =>
|
|
56076
|
+
var sha = (data) => createHash14("sha256").update(data).digest("hex"), HOOK_EVENTS, ROOTS, SKILLS_LOADING_POLICY = "Skills loading policy: discover skills with `skills list` or `skills search`, and read selected instructions with `skills load <slug>`. Use `skills sync` to refresh the shared profile. The only native skill is the owned skills-cli bridge. Create and edit payload skills in the Skills authoring workspace; do not copy payload instructions into native discovery folders. Context loading does not authorize execution; use `skills run` only when the task calls for running a skill.";
|
|
55840
56077
|
var init_agent_integration = __esm(() => {
|
|
55841
56078
|
init_config();
|
|
55842
56079
|
init_managed_policy();
|
|
@@ -56004,7 +56241,7 @@ var init_home_migration = __esm(() => {
|
|
|
56004
56241
|
import {
|
|
56005
56242
|
cpSync as cpSync2,
|
|
56006
56243
|
existsSync as existsSync17,
|
|
56007
|
-
lstatSync as
|
|
56244
|
+
lstatSync as lstatSync19,
|
|
56008
56245
|
mkdirSync as mkdirSync9,
|
|
56009
56246
|
mkdtempSync as mkdtempSync2,
|
|
56010
56247
|
readFileSync as readFileSync16,
|
|
@@ -56015,14 +56252,14 @@ import {
|
|
|
56015
56252
|
writeFileSync as writeFileSync7
|
|
56016
56253
|
} from "fs";
|
|
56017
56254
|
import { homedir as homedir5 } from "os";
|
|
56018
|
-
import { basename as
|
|
56255
|
+
import { basename as basename9, dirname as dirname16, join as join31 } from "path";
|
|
56019
56256
|
function isSkillsOwnershipMarker(marker) {
|
|
56020
56257
|
return typeof marker === "object" && marker !== null && Object.hasOwn(marker, "managedBy") && marker.managedBy === SYNC_MARKER_MANAGED_BY;
|
|
56021
56258
|
}
|
|
56022
56259
|
function hasSkillsOwnershipMarker(dir) {
|
|
56023
56260
|
const path = join31(dir, SYNC_MARKER_FILE);
|
|
56024
56261
|
try {
|
|
56025
|
-
if (!
|
|
56262
|
+
if (!lstatSync19(path).isFile())
|
|
56026
56263
|
return false;
|
|
56027
56264
|
const marker = JSON.parse(readFileSync16(path, "utf8"));
|
|
56028
56265
|
return isSkillsOwnershipMarker(marker);
|
|
@@ -56247,9 +56484,9 @@ function writeManagedSkillDir(dir, skillMd, options) {
|
|
|
56247
56484
|
const action = dirExists ? "update" : "create";
|
|
56248
56485
|
if (options.dryRun)
|
|
56249
56486
|
return { action, path: skillMdPath };
|
|
56250
|
-
const parentDir =
|
|
56487
|
+
const parentDir = dirname16(dir);
|
|
56251
56488
|
mkdirSync9(parentDir, { recursive: true });
|
|
56252
|
-
const transactionDir = mkdtempSync2(join31(parentDir, `.hasna-skills-write-${
|
|
56489
|
+
const transactionDir = mkdtempSync2(join31(parentDir, `.hasna-skills-write-${basename9(dir)}-`));
|
|
56253
56490
|
const candidateDir = join31(transactionDir, "candidate");
|
|
56254
56491
|
const backupDir = join31(transactionDir, "backup");
|
|
56255
56492
|
const candidateSkillMdPath = join31(candidateDir, "SKILL.md");
|
|
@@ -58099,7 +58336,7 @@ var _parse = (_Err) => {
|
|
|
58099
58336
|
return result2.value;
|
|
58100
58337
|
};
|
|
58101
58338
|
return fn;
|
|
58102
|
-
},
|
|
58339
|
+
}, parse7, _parseAsync = (_Err) => {
|
|
58103
58340
|
const fn = async (schema, value, _ctx, params) => {
|
|
58104
58341
|
const ctx = _ctx ? { ..._ctx, async: true } : { async: true };
|
|
58105
58342
|
let result2 = schema._zod.run({ value, issues: [] }, ctx);
|
|
@@ -58144,16 +58381,16 @@ var _parse = (_Err) => {
|
|
|
58144
58381
|
result2 = await result2;
|
|
58145
58382
|
return result2.issues.length === 0;
|
|
58146
58383
|
}, _encode = (_Err) => {
|
|
58147
|
-
const
|
|
58384
|
+
const parse8 = _parse(_Err);
|
|
58148
58385
|
const fn = (schema, value, _ctx, _params) => {
|
|
58149
58386
|
const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
|
|
58150
|
-
return
|
|
58387
|
+
return parse8(schema, value, ctx, finalizeParams(fn, _params));
|
|
58151
58388
|
};
|
|
58152
58389
|
return fn;
|
|
58153
58390
|
}, encode, _decode = (_Err) => {
|
|
58154
|
-
const
|
|
58391
|
+
const parse8 = _parse(_Err);
|
|
58155
58392
|
const fn = (schema, value, _ctx, _params) => {
|
|
58156
|
-
return
|
|
58393
|
+
return parse8(schema, value, _ctx, finalizeParams(fn, _params));
|
|
58157
58394
|
};
|
|
58158
58395
|
return fn;
|
|
58159
58396
|
}, decode, _encodeAsync = (_Err) => {
|
|
@@ -58184,7 +58421,7 @@ var init_parse = __esm(() => {
|
|
|
58184
58421
|
init_core();
|
|
58185
58422
|
init_errors();
|
|
58186
58423
|
init_util();
|
|
58187
|
-
|
|
58424
|
+
parse7 = /* @__PURE__ */ _parse($ZodRealError);
|
|
58188
58425
|
parseAsync = /* @__PURE__ */ _parseAsync($ZodRealError);
|
|
58189
58426
|
safeParse = /* @__PURE__ */ _safeParse($ZodRealError);
|
|
58190
58427
|
safeParseAsync = /* @__PURE__ */ _safeParseAsync($ZodRealError);
|
|
@@ -61109,10 +61346,10 @@ var init_schemas = __esm(() => {
|
|
|
61109
61346
|
throw new Error("implement() must be called with a function");
|
|
61110
61347
|
}
|
|
61111
61348
|
return Object.defineProperty(function(...args) {
|
|
61112
|
-
const parsedArgs = inst._def.input ?
|
|
61349
|
+
const parsedArgs = inst._def.input ? parse7(inst._def.input, args) : args;
|
|
61113
61350
|
const result2 = Reflect.apply(func, this, parsedArgs);
|
|
61114
61351
|
if (inst._def.output) {
|
|
61115
|
-
return
|
|
61352
|
+
return parse7(inst._def.output, result2);
|
|
61116
61353
|
}
|
|
61117
61354
|
return result2;
|
|
61118
61355
|
}, "_zod", { value: inst._zod, enumerable: false });
|
|
@@ -72813,7 +73050,7 @@ __export(exports_core2, {
|
|
|
72813
73050
|
prettifyError: () => prettifyError,
|
|
72814
73051
|
parseURLObject: () => parseURLObject,
|
|
72815
73052
|
parseAsync: () => parseAsync,
|
|
72816
|
-
parse: () =>
|
|
73053
|
+
parse: () => parse7,
|
|
72817
73054
|
meta: () => meta,
|
|
72818
73055
|
mergeValues: () => mergeValues,
|
|
72819
73056
|
memoizer: () => memoizer,
|
|
@@ -73203,12 +73440,12 @@ var init_errors2 = __esm(() => {
|
|
|
73203
73440
|
});
|
|
73204
73441
|
|
|
73205
73442
|
// node_modules/zod/v4/classic/parse.js
|
|
73206
|
-
var
|
|
73443
|
+
var parse9, parseAsync2, safeParse2, safeParseAsync2, encode2, decode2, encodeAsync2, decodeAsync2, safeEncode2, safeDecode2, safeEncodeAsync2, safeDecodeAsync2;
|
|
73207
73444
|
var init_parse2 = __esm(() => {
|
|
73208
73445
|
init_core2();
|
|
73209
73446
|
init_errors2();
|
|
73210
73447
|
init_core2();
|
|
73211
|
-
|
|
73448
|
+
parse9 = /* @__PURE__ */ _parse(ZodRealError);
|
|
73212
73449
|
parseAsync2 = /* @__PURE__ */ _parseAsync(ZodRealError);
|
|
73213
73450
|
safeParse2 = /* @__PURE__ */ _safeParse(ZodRealError);
|
|
73214
73451
|
safeParseAsync2 = /* @__PURE__ */ _safeParseAsync(ZodRealError);
|
|
@@ -74009,7 +74246,7 @@ var init_schemas2 = __esm(() => {
|
|
|
74009
74246
|
exports_util.own(this, "~standard", value);
|
|
74010
74247
|
},
|
|
74011
74248
|
parse: function _parse2(data, params) {
|
|
74012
|
-
return
|
|
74249
|
+
return parse9(this, data, params, { callee: _parse2 });
|
|
74013
74250
|
},
|
|
74014
74251
|
parseAsync: async function _parseAsync2(data, params) {
|
|
74015
74252
|
return await parseAsync2(this, data, params, { callee: _parseAsync2 });
|
|
@@ -75702,7 +75939,7 @@ __export(exports_external, {
|
|
|
75702
75939
|
pipe: () => pipe,
|
|
75703
75940
|
partialRecord: () => partialRecord,
|
|
75704
75941
|
parseAsync: () => parseAsync2,
|
|
75705
|
-
parse: () =>
|
|
75942
|
+
parse: () => parse9,
|
|
75706
75943
|
overwrite: () => _overwrite,
|
|
75707
75944
|
output: () => output,
|
|
75708
75945
|
optional: () => optional,
|
|
@@ -76183,7 +76420,7 @@ var init_v4 = __esm(() => {
|
|
|
76183
76420
|
});
|
|
76184
76421
|
|
|
76185
76422
|
// src/lib/canonical-json.ts
|
|
76186
|
-
import { createHash as
|
|
76423
|
+
import { createHash as createHash15 } from "crypto";
|
|
76187
76424
|
function canonicalJson2(value, maximumBytes = 2 * 1024 * 1024) {
|
|
76188
76425
|
return canonicalJsonAtDepth(value, maximumBytes, 64);
|
|
76189
76426
|
}
|
|
@@ -76227,7 +76464,7 @@ function canonicalJsonAtDepth(value, maximumBytes, maximumDepth) {
|
|
|
76227
76464
|
return visit3(value, 0);
|
|
76228
76465
|
}
|
|
76229
76466
|
function canonicalJsonSha256(value, maximumBytes) {
|
|
76230
|
-
return
|
|
76467
|
+
return createHash15("sha256").update(canonicalJson2(value, maximumBytes)).digest("hex");
|
|
76231
76468
|
}
|
|
76232
76469
|
var init_canonical_json = () => {};
|
|
76233
76470
|
|
|
@@ -76981,13 +77218,13 @@ var init_remote_workspace_leave = __esm(() => {
|
|
|
76981
77218
|
|
|
76982
77219
|
// src/lib/auth-store.ts
|
|
76983
77220
|
import { chmodSync as chmodSync2, existsSync as existsSync20, mkdirSync as mkdirSync11, readFileSync as readFileSync19, renameSync as renameSync7, statSync as statSync11, unlinkSync as unlinkSync5, writeFileSync as writeFileSync9 } from "fs";
|
|
76984
|
-
import { basename as
|
|
77221
|
+
import { basename as basename10, dirname as dirname17, join as join34 } from "path";
|
|
76985
77222
|
function getAuthFilePath(env3 = process.env) {
|
|
76986
77223
|
return skillsCredentialFilePath(env3);
|
|
76987
77224
|
}
|
|
76988
77225
|
function getIdentityFilePath(env3 = process.env) {
|
|
76989
77226
|
const file2 = skillsCredentialFilePath(env3);
|
|
76990
|
-
return join34(
|
|
77227
|
+
return join34(dirname17(file2), basename10(file2).replace(/^credentials/, "identity") + ".json");
|
|
76991
77228
|
}
|
|
76992
77229
|
function getAuthIdentity(env3 = process.env) {
|
|
76993
77230
|
return readIdentity(env3);
|
|
@@ -77021,7 +77258,7 @@ function getAuthConfig(env3 = process.env, options = {}) {
|
|
|
77021
77258
|
}
|
|
77022
77259
|
function writeCredentialValues(values2, env3 = process.env) {
|
|
77023
77260
|
const file2 = skillsCredentialFilePath(env3);
|
|
77024
|
-
mkdirSync11(
|
|
77261
|
+
mkdirSync11(dirname17(file2), { recursive: true, mode: 448 });
|
|
77025
77262
|
const lines = [];
|
|
77026
77263
|
const written = new Set;
|
|
77027
77264
|
if (existsSync20(file2)) {
|
|
@@ -77359,10 +77596,10 @@ async function readQuoteUnavailableCode(response) {
|
|
|
77359
77596
|
let timer;
|
|
77360
77597
|
let deadlineExceeded = false;
|
|
77361
77598
|
const expired = Symbol("quote body deadline");
|
|
77362
|
-
const deadline = new Promise((
|
|
77599
|
+
const deadline = new Promise((resolve17) => {
|
|
77363
77600
|
timer = setTimeout(() => {
|
|
77364
77601
|
deadlineExceeded = true;
|
|
77365
|
-
|
|
77602
|
+
resolve17(expired);
|
|
77366
77603
|
reader.cancel().catch(() => {});
|
|
77367
77604
|
}, 1500);
|
|
77368
77605
|
});
|
|
@@ -78424,9 +78661,9 @@ var init_remote_client = __esm(() => {
|
|
|
78424
78661
|
});
|
|
78425
78662
|
|
|
78426
78663
|
// src/lib/revision.ts
|
|
78427
|
-
import { createHash as
|
|
78664
|
+
import { createHash as createHash16 } from "crypto";
|
|
78428
78665
|
function revisionIdOf(content) {
|
|
78429
|
-
const
|
|
78666
|
+
const canonical4 = JSON.stringify({
|
|
78430
78667
|
slug: content.slug,
|
|
78431
78668
|
displayName: content.displayName,
|
|
78432
78669
|
description: content.description,
|
|
@@ -78439,7 +78676,7 @@ function revisionIdOf(content) {
|
|
|
78439
78676
|
bundleSha256: content.bundleSha256 ?? null,
|
|
78440
78677
|
bundleByteSize: content.bundleByteSize ?? null
|
|
78441
78678
|
});
|
|
78442
|
-
return
|
|
78679
|
+
return createHash16("sha256").update(canonical4).digest("hex");
|
|
78443
78680
|
}
|
|
78444
78681
|
var REVISION_ID_PATTERN;
|
|
78445
78682
|
var init_revision = __esm(() => {
|
|
@@ -78469,7 +78706,7 @@ var init_skill_bundles = __esm(() => {
|
|
|
78469
78706
|
|
|
78470
78707
|
// src/lib/pull.ts
|
|
78471
78708
|
import { existsSync as existsSync21, mkdirSync as mkdirSync12, mkdtempSync as mkdtempSync3, readFileSync as readFileSync20, renameSync as renameSync8, rmSync as rmSync6, writeFileSync as writeFileSync10 } from "fs";
|
|
78472
|
-
import { dirname as
|
|
78709
|
+
import { dirname as dirname18, join as join35 } from "path";
|
|
78473
78710
|
async function pullSkills(options = {}) {
|
|
78474
78711
|
const client2 = options.client !== undefined ? options.client : await createRemoteSkillsClient();
|
|
78475
78712
|
if (!client2) {
|
|
@@ -78773,7 +79010,7 @@ function installBundleAtomically(name, entries, options = {}, marker = {}) {
|
|
|
78773
79010
|
try {
|
|
78774
79011
|
for (const entry of entries) {
|
|
78775
79012
|
const destination = join35(staging, entry.path);
|
|
78776
|
-
mkdirSync12(
|
|
79013
|
+
mkdirSync12(dirname18(destination), { recursive: true });
|
|
78777
79014
|
writeFileSync10(destination, entry.bytes, { mode: entry.mode });
|
|
78778
79015
|
}
|
|
78779
79016
|
writePullMarker(staging, {
|
|
@@ -78888,8 +79125,8 @@ var init_pull = __esm(() => {
|
|
|
78888
79125
|
});
|
|
78889
79126
|
|
|
78890
79127
|
// src/lib/skill-context.ts
|
|
78891
|
-
import { createHash as
|
|
78892
|
-
import { resolve as
|
|
79128
|
+
import { createHash as createHash17 } from "crypto";
|
|
79129
|
+
import { resolve as resolve17 } from "path";
|
|
78893
79130
|
function words2(value) {
|
|
78894
79131
|
return new Set(value.toLowerCase().match(/[a-z0-9]+/g) ?? []);
|
|
78895
79132
|
}
|
|
@@ -78924,7 +79161,7 @@ async function buildSkillContext(input2, options = {}) {
|
|
|
78924
79161
|
const promptWords = words2(prompt);
|
|
78925
79162
|
const promptNames = new Set(prompt.toLowerCase().match(/[a-z0-9]+(?:-[a-z0-9]+)*/g) ?? []);
|
|
78926
79163
|
const loaded = new Set(resolved.session?.loaded ?? []);
|
|
78927
|
-
const paths = [...input2.paths ?? [], ...input2.cwd ? [input2.cwd,
|
|
79164
|
+
const paths = [...input2.paths ?? [], ...input2.cwd ? [input2.cwd, resolve17(input2.cwd)] : []];
|
|
78928
79165
|
const candidates = profile.selections.map((selection) => {
|
|
78929
79166
|
const key = selectionKey(selection);
|
|
78930
79167
|
if (input2.restore && loaded.has(key))
|
|
@@ -78977,7 +79214,7 @@ ${content}`;
|
|
|
78977
79214
|
`);
|
|
78978
79215
|
const receipt = {
|
|
78979
79216
|
schemaVersion: 1,
|
|
78980
|
-
id:
|
|
79217
|
+
id: createHash17("sha256").update(JSON.stringify({ profile: profile.profileRevision, sessionId, selections, omitted })).digest("hex"),
|
|
78981
79218
|
profileId: profile.profileId,
|
|
78982
79219
|
profileRevision: profile.profileRevision,
|
|
78983
79220
|
authority: profile.authority,
|
|
@@ -78999,7 +79236,7 @@ var init_skill_context = __esm(() => {
|
|
|
78999
79236
|
});
|
|
79000
79237
|
|
|
79001
79238
|
// src/lib/session-reconciliation.ts
|
|
79002
|
-
import { createHash as
|
|
79239
|
+
import { createHash as createHash18 } from "crypto";
|
|
79003
79240
|
function exactTimestamp(value) {
|
|
79004
79241
|
const parsed = value === undefined ? Number.NaN : Date.parse(value);
|
|
79005
79242
|
if (!Number.isFinite(parsed) || new Date(parsed).toISOString() !== value) {
|
|
@@ -79092,7 +79329,7 @@ async function reconcileSkillSession(input2, options = {}) {
|
|
|
79092
79329
|
const result2 = replaceSkillSession(skillSessionSnapshotBinding(snapshot), replacement, { ...plan, planDigest }, options, () => assertPlanWindow(issuedAt, expiresAt, (options.now ?? Date.now)()));
|
|
79093
79330
|
return { applied: true, plan, planDigest, ...result2 };
|
|
79094
79331
|
}
|
|
79095
|
-
var SESSION_RECONCILIATION_PLAN_TTL_MS, digest3 = (value) =>
|
|
79332
|
+
var SESSION_RECONCILIATION_PLAN_TTL_MS, digest3 = (value) => createHash18("sha256").update(JSON.stringify(value)).digest("hex");
|
|
79096
79333
|
var init_session_reconciliation = __esm(() => {
|
|
79097
79334
|
init_profile_client();
|
|
79098
79335
|
init_selection_cache();
|
|
@@ -79108,7 +79345,7 @@ __export(exports_context, {
|
|
|
79108
79345
|
parseSkillContextInput: () => parseSkillContextInput,
|
|
79109
79346
|
contextResolverOptions: () => contextResolverOptions
|
|
79110
79347
|
});
|
|
79111
|
-
import { readSync as
|
|
79348
|
+
import { readSync as readSync10 } from "fs";
|
|
79112
79349
|
function selectedProfileId(explicit) {
|
|
79113
79350
|
return explicit ?? process.env.HASNA_SKILLS_SELECTION_PROFILE ?? readManagedSkillPolicy()?.profileId ?? "default";
|
|
79114
79351
|
}
|
|
@@ -79186,7 +79423,7 @@ async function readContextStdin() {
|
|
|
79186
79423
|
let size2 = 0;
|
|
79187
79424
|
while (true) {
|
|
79188
79425
|
const chunk2 = Buffer.allocUnsafe(8192);
|
|
79189
|
-
const count =
|
|
79426
|
+
const count = readSync10(0, chunk2, 0, chunk2.length, null);
|
|
79190
79427
|
if (count === 0)
|
|
79191
79428
|
break;
|
|
79192
79429
|
size2 += count;
|
|
@@ -79663,12 +79900,12 @@ function handleBrowseError(error61) {
|
|
|
79663
79900
|
async function writeJson(value, space) {
|
|
79664
79901
|
const text3 = `${JSON.stringify(value, null, space)}
|
|
79665
79902
|
`;
|
|
79666
|
-
await new Promise((
|
|
79903
|
+
await new Promise((resolve18, reject2) => {
|
|
79667
79904
|
process.stdout.write(text3, (error61) => {
|
|
79668
79905
|
if (error61)
|
|
79669
79906
|
reject2(error61);
|
|
79670
79907
|
else
|
|
79671
|
-
|
|
79908
|
+
resolve18();
|
|
79672
79909
|
});
|
|
79673
79910
|
});
|
|
79674
79911
|
}
|
|
@@ -80200,7 +80437,7 @@ function handleDiff(name, options) {
|
|
|
80200
80437
|
const sourcePath = getSkillPath(bare);
|
|
80201
80438
|
const canonicalDir = join36(resolveCorpusRoot(), normalized);
|
|
80202
80439
|
const canonicalSkillMd = join36(canonicalDir, "SKILL.md");
|
|
80203
|
-
const
|
|
80440
|
+
const canonical4 = {
|
|
80204
80441
|
present: existsSync22(canonicalSkillMd),
|
|
80205
80442
|
path: canonicalDir,
|
|
80206
80443
|
...existsSync22(canonicalSkillMd) ? { hash: hashSkillMarkdownFile(canonicalSkillMd) } : {},
|
|
@@ -80232,7 +80469,7 @@ function handleDiff(name, options) {
|
|
|
80232
80469
|
stub = undefined;
|
|
80233
80470
|
}
|
|
80234
80471
|
}
|
|
80235
|
-
const diverged = present &&
|
|
80472
|
+
const diverged = present && canonical4.present && managed && hash3 !== canonical4.hash;
|
|
80236
80473
|
homes.push({
|
|
80237
80474
|
agent,
|
|
80238
80475
|
path: dir,
|
|
@@ -80247,7 +80484,7 @@ function handleDiff(name, options) {
|
|
|
80247
80484
|
if (options.json) {
|
|
80248
80485
|
console.log(JSON.stringify({
|
|
80249
80486
|
name: bare,
|
|
80250
|
-
canonical:
|
|
80487
|
+
canonical: canonical4,
|
|
80251
80488
|
pinned,
|
|
80252
80489
|
installedVersion,
|
|
80253
80490
|
registryVersion,
|
|
@@ -80255,10 +80492,10 @@ function handleDiff(name, options) {
|
|
|
80255
80492
|
homes
|
|
80256
80493
|
}, null, 2));
|
|
80257
80494
|
} else {
|
|
80258
|
-
if (!
|
|
80495
|
+
if (!canonical4.present) {
|
|
80259
80496
|
console.log(source_default.yellow(`${bare}: no canonical corpus entry`));
|
|
80260
80497
|
} else {
|
|
80261
|
-
console.log(source_default.dim(`${bare} canonical: ${
|
|
80498
|
+
console.log(source_default.dim(`${bare} canonical: ${canonical4.hash?.slice(0, 12)}\u2026`));
|
|
80262
80499
|
}
|
|
80263
80500
|
if (pinned) {
|
|
80264
80501
|
console.log(upToDate ? source_default.green(`\u2713 pin is up to date (${installedVersion})`) : source_default.yellow(`pin metadata differs: ${installedVersion} \u2192 ${registryVersion}`));
|
|
@@ -80269,14 +80506,14 @@ function handleDiff(name, options) {
|
|
|
80269
80506
|
} else if (!home.managed) {
|
|
80270
80507
|
console.log(`${source_default.dim("\u2022")} ${home.agent}: ${source_default.yellow("unmarked (adoption candidate)")}`);
|
|
80271
80508
|
} else if (home.diverged) {
|
|
80272
|
-
const stubNote = home.stub === true ? " (home is a pointer stub; canonical holds content)" :
|
|
80273
|
-
console.log(`${source_default.red("\u2717")} ${home.agent}: ${source_default.red("diverged")} ${source_default.dim(home.hash?.slice(0, 12))} \u2260 ${source_default.dim(
|
|
80509
|
+
const stubNote = home.stub === true ? " (home is a pointer stub; canonical holds content)" : canonical4.stub === true ? " (home holds content; canonical renders a pointer stub \u2014 sync refuses to replace it)" : "";
|
|
80510
|
+
console.log(`${source_default.red("\u2717")} ${home.agent}: ${source_default.red("diverged")} ${source_default.dim(home.hash?.slice(0, 12))} \u2260 ${source_default.dim(canonical4.hash?.slice(0, 12))}${stubNote}`);
|
|
80274
80511
|
} else {
|
|
80275
80512
|
console.log(`${source_default.green("\u2713")} ${home.agent}: ${source_default.green("matches canonical")}`);
|
|
80276
80513
|
}
|
|
80277
80514
|
}
|
|
80278
80515
|
}
|
|
80279
|
-
if (divergedHomes.length > 0 || homes.length > 0 && !
|
|
80516
|
+
if (divergedHomes.length > 0 || homes.length > 0 && !canonical4.present)
|
|
80280
80517
|
process.exitCode = 1;
|
|
80281
80518
|
}
|
|
80282
80519
|
var init_introspect = __esm(() => {
|
|
@@ -81012,7 +81249,7 @@ var init_init = __esm(() => {
|
|
|
81012
81249
|
});
|
|
81013
81250
|
|
|
81014
81251
|
// src/lib/home-adoption.ts
|
|
81015
|
-
import { constants as
|
|
81252
|
+
import { constants as constants12, closeSync as closeSync12, fstatSync as fstatSync12, lstatSync as lstatSync20, openSync as openSync12, readSync as readSync11, existsSync as existsSync24, mkdirSync as mkdirSync13, readdirSync as readdirSync13, readFileSync as readFileSync25, rmSync as rmSync7, statSync as statSync12, writeFileSync as writeFileSync12 } from "fs";
|
|
81016
81253
|
import { homedir as homedir7 } from "os";
|
|
81017
81254
|
import { join as join38 } from "path";
|
|
81018
81255
|
function indexCanonicalCorpus(corpusRoot) {
|
|
@@ -81167,25 +81404,25 @@ function adoptUnmarkedHomes(options = {}) {
|
|
|
81167
81404
|
function pruneOwnership(dir) {
|
|
81168
81405
|
let descriptor;
|
|
81169
81406
|
try {
|
|
81170
|
-
const directory =
|
|
81407
|
+
const directory = lstatSync20(dir);
|
|
81171
81408
|
if (!directory.isDirectory())
|
|
81172
81409
|
return;
|
|
81173
|
-
const markerPath = join38(dir, SYNC_MARKER_FILE), markerPathBefore =
|
|
81410
|
+
const markerPath = join38(dir, SYNC_MARKER_FILE), markerPathBefore = lstatSync20(markerPath);
|
|
81174
81411
|
if (!markerPathBefore.isFile())
|
|
81175
81412
|
return;
|
|
81176
|
-
descriptor =
|
|
81177
|
-
const before2 =
|
|
81413
|
+
descriptor = openSync12(markerPath, constants12.O_RDONLY | constants12.O_NOFOLLOW | constants12.O_NONBLOCK);
|
|
81414
|
+
const before2 = fstatSync12(descriptor);
|
|
81178
81415
|
if (!before2.isFile() || before2.dev !== markerPathBefore.dev || before2.ino !== markerPathBefore.ino || before2.size !== markerPathBefore.size || before2.mtimeMs !== markerPathBefore.mtimeMs || before2.ctimeMs !== markerPathBefore.ctimeMs || before2.size < 1 || before2.size > 65536)
|
|
81179
81416
|
return;
|
|
81180
81417
|
const bytes = Buffer.alloc(before2.size + 1);
|
|
81181
81418
|
let length = 0;
|
|
81182
81419
|
while (length < bytes.length) {
|
|
81183
|
-
const count =
|
|
81420
|
+
const count = readSync11(descriptor, bytes, length, bytes.length - length, length);
|
|
81184
81421
|
if (!count)
|
|
81185
81422
|
break;
|
|
81186
81423
|
length += count;
|
|
81187
81424
|
}
|
|
81188
|
-
const after2 =
|
|
81425
|
+
const after2 = fstatSync12(descriptor), current = lstatSync20(dir), markerPathAfter = lstatSync20(markerPath);
|
|
81189
81426
|
if (!markerPathAfter.isFile() || markerPathAfter.dev !== before2.dev || markerPathAfter.ino !== before2.ino || markerPathAfter.size !== before2.size || markerPathAfter.mtimeMs !== before2.mtimeMs || markerPathAfter.ctimeMs !== before2.ctimeMs || length !== before2.size || after2.size !== before2.size || after2.mtimeMs !== before2.mtimeMs || after2.ctimeMs !== before2.ctimeMs || !current.isDirectory() || current.dev !== directory.dev || current.ino !== directory.ino)
|
|
81190
81427
|
return;
|
|
81191
81428
|
const text3 = bytes.subarray(0, length).toString("utf8"), marker = JSON.parse(text3);
|
|
@@ -81196,7 +81433,7 @@ function pruneOwnership(dir) {
|
|
|
81196
81433
|
return;
|
|
81197
81434
|
} finally {
|
|
81198
81435
|
if (descriptor !== undefined)
|
|
81199
|
-
|
|
81436
|
+
closeSync12(descriptor);
|
|
81200
81437
|
}
|
|
81201
81438
|
}
|
|
81202
81439
|
function pruneStrayHomes(options = {}) {
|
|
@@ -81381,7 +81618,7 @@ var init_home_census = __esm(() => {
|
|
|
81381
81618
|
});
|
|
81382
81619
|
|
|
81383
81620
|
// src/cli/env-assignment.ts
|
|
81384
|
-
import { closeSync as
|
|
81621
|
+
import { closeSync as closeSync13, constants as constants13, fstatSync as fstatSync13, ftruncateSync as ftruncateSync2, lstatSync as lstatSync21, openSync as openSync13, readFileSync as readFileSync27, writeSync as writeSync3 } from "fs";
|
|
81385
81622
|
function serializeValue(value) {
|
|
81386
81623
|
if (controls.test(value))
|
|
81387
81624
|
throw new EnvAssignmentError("Environment values cannot contain control characters or newlines.");
|
|
@@ -81460,7 +81697,7 @@ function setEnvAssignment(path, assignment) {
|
|
|
81460
81697
|
try {
|
|
81461
81698
|
const previous = (() => {
|
|
81462
81699
|
try {
|
|
81463
|
-
return
|
|
81700
|
+
return lstatSync21(path);
|
|
81464
81701
|
} catch (error61) {
|
|
81465
81702
|
if (error61.code === "ENOENT")
|
|
81466
81703
|
return;
|
|
@@ -81469,8 +81706,8 @@ function setEnvAssignment(path, assignment) {
|
|
|
81469
81706
|
})();
|
|
81470
81707
|
if (previous && !previous.isFile())
|
|
81471
81708
|
throw new EnvAssignmentError("The project .env must be a regular file, not a symlink or special file.");
|
|
81472
|
-
descriptor =
|
|
81473
|
-
const opened =
|
|
81709
|
+
descriptor = openSync13(path, previous ? constants13.O_RDWR | constants13.O_NOFOLLOW | constants13.O_NONBLOCK : constants13.O_WRONLY | constants13.O_CREAT | constants13.O_EXCL | constants13.O_NOFOLLOW, 384);
|
|
81710
|
+
const opened = fstatSync13(descriptor);
|
|
81474
81711
|
if (!opened.isFile() || previous && (opened.ino !== previous.ino || opened.dev !== previous.dev)) {
|
|
81475
81712
|
throw new EnvAssignmentError("The project .env changed while opening it; retry with a regular file.");
|
|
81476
81713
|
}
|
|
@@ -81497,7 +81734,7 @@ function setEnvAssignment(path, assignment) {
|
|
|
81497
81734
|
throw new EnvAssignmentError("Cannot safely read or write the project .env file.");
|
|
81498
81735
|
} finally {
|
|
81499
81736
|
if (descriptor !== undefined)
|
|
81500
|
-
|
|
81737
|
+
closeSync13(descriptor);
|
|
81501
81738
|
}
|
|
81502
81739
|
}
|
|
81503
81740
|
var INVALID_LAYOUT = "Cannot safely update .env with multiline or unsupported assignments. Use single-line KEY=VALUE entries or edit the file manually.", controls, EnvAssignmentError;
|
|
@@ -82006,11 +82243,11 @@ var init_cloud_executions = __esm(() => {
|
|
|
82006
82243
|
// node_modules/@hasna/secrets/dist/sdk.js
|
|
82007
82244
|
import { isIP as isIP3 } from "net";
|
|
82008
82245
|
import { spawnSync as spawnSync2 } from "child_process";
|
|
82009
|
-
import { closeSync as
|
|
82246
|
+
import { closeSync as closeSync14, fstatSync as fstatSync14, openSync as openSync14, readFileSync as readFileSync29 } from "fs";
|
|
82010
82247
|
import { O_NOFOLLOW as O_NOFOLLOW3, O_NONBLOCK as O_NONBLOCK3, O_RDONLY as O_RDONLY3 } from "constants";
|
|
82011
82248
|
import { createRequire as createRequire2 } from "module";
|
|
82012
82249
|
import { hostname as osHostname2 } from "os";
|
|
82013
|
-
import { isAbsolute as
|
|
82250
|
+
import { isAbsolute as isAbsolute16, join as join41 } from "path";
|
|
82014
82251
|
import { createRequire as createRequire22 } from "module";
|
|
82015
82252
|
function envToken2(name) {
|
|
82016
82253
|
return name.toUpperCase().replace(/-/g, "_");
|
|
@@ -82034,7 +82271,7 @@ function homeDir2(env3) {
|
|
|
82034
82271
|
}
|
|
82035
82272
|
function absoluteOverride2(env3, key) {
|
|
82036
82273
|
const value = env3[key]?.trim();
|
|
82037
|
-
return value &&
|
|
82274
|
+
return value && isAbsolute16(value) ? value : null;
|
|
82038
82275
|
}
|
|
82039
82276
|
function hasnaHomeDir2(env3) {
|
|
82040
82277
|
const override = absoluteOverride2(env3, HASNA_HOME_ENV_KEY2);
|
|
@@ -82111,7 +82348,7 @@ function readAppConfigFile2(path) {
|
|
|
82111
82348
|
};
|
|
82112
82349
|
let fd = -1;
|
|
82113
82350
|
try {
|
|
82114
|
-
fd =
|
|
82351
|
+
fd = openSync14(path, O_RDONLY3 | O_NOFOLLOW3 | O_NONBLOCK3);
|
|
82115
82352
|
} catch (error61) {
|
|
82116
82353
|
const code = error61.code;
|
|
82117
82354
|
if (code === "ENOENT" || code === "ENOTDIR")
|
|
@@ -82121,7 +82358,7 @@ function readAppConfigFile2(path) {
|
|
|
82121
82358
|
unsafe(`the path could not be opened (${code ?? "unknown error"})`);
|
|
82122
82359
|
}
|
|
82123
82360
|
try {
|
|
82124
|
-
const before2 =
|
|
82361
|
+
const before2 = fstatSync14(fd);
|
|
82125
82362
|
if (!before2.isFile())
|
|
82126
82363
|
unsafe("the path is not a regular file");
|
|
82127
82364
|
if (!configFileModeAllowed2(before2.mode)) {
|
|
@@ -82133,14 +82370,14 @@ function readAppConfigFile2(path) {
|
|
|
82133
82370
|
if (before2.size > MAX_CREDENTIAL_FILE_BYTES2)
|
|
82134
82371
|
unsafe("the file exceeds the size limit");
|
|
82135
82372
|
const bytes = readFileSync29(fd);
|
|
82136
|
-
const after2 =
|
|
82373
|
+
const after2 = fstatSync14(fd);
|
|
82137
82374
|
if (!configFileReadsCoherent2(before2, after2)) {
|
|
82138
82375
|
unsafe("the file changed while being read");
|
|
82139
82376
|
}
|
|
82140
82377
|
return parseEnvFile2(bytes.toString("utf8"));
|
|
82141
82378
|
} finally {
|
|
82142
82379
|
if (fd !== -1)
|
|
82143
|
-
|
|
82380
|
+
closeSync14(fd);
|
|
82144
82381
|
}
|
|
82145
82382
|
}
|
|
82146
82383
|
function readCredentialFile2(path, apiKeyKeys) {
|
|
@@ -83171,7 +83408,7 @@ function createSecretsClientFromEnv(env3 = process.env, overrides = {}) {
|
|
|
83171
83408
|
});
|
|
83172
83409
|
return new SecretsClient({ ...clientOverrides, baseUrl, apiKey });
|
|
83173
83410
|
}
|
|
83174
|
-
var __esm2 = (fn, res) => () => (fn && (res = fn(fn = 0)), res), CREDENTIAL_PROFILE_ENV_KEY2 = "HASNA_PROFILE", CredentialResolutionError2, CredentialFileUnsafeError2, HASNA_HOME_ENV_KEY2 = "HASNA_HOME", HASNA_CONFIG_HOME_ENV_KEY2 = "HASNA_CONFIG_HOME", KEYCHAIN_STATION_ENV_KEY2 = "HASNA_STATION", HASNA_HOME_DIR2 = ".hasna", CONFIG_SUBDIR2 = "config", CREDENTIALS_FILE2 = "credentials", KEYCHAIN_SECURITY_BIN2 = "/usr/bin/security", KEYCHAIN_SERVICE_PREFIX2 = "hasna.credentials", KEYCHAIN_ITEM_NOT_FOUND_STATUS2 = 44, KEYCHAIN_SPAWN_TIMEOUT_MS2 = 1e4, MAX_CREDENTIAL_FILE_BYTES2, SAFE_APP_SLUG2, SAFE_PROFILE2, ILLEGAL_IN_HEADER_VALUE2, VAULT_POINTER_SHAPE2, CREDENTIAL_SHAPED_KEY2, INSPECT_CUSTOM2, CREDENTIAL_SEAL2, CALLER_SUPPLIED_CREDENTIAL_PROVIDER_SOURCE = "caller-supplied CredentialProvider", AMBIENT_ENVIRONMENT2, SECRETS_PACKAGE_SPECIFIER, requireSecretsSdk2, DEFAULT_FLEET_GATEWAY_ORIGIN2 = "https://api.hasna.com", DEFAULT_AUTHORITY_SOURCE = "default", ASCII_CONTROL_PATTERN2, DNS_LABEL_PATTERN2, ClientTransportConfigurationError2, HasnaHttpError, DEFAULT_RETRY_STATUSES, IDEMPOTENT_METHODS2, AUTHORITY_OVERRIDE_HEADERS2, defaultSleep = (ms) => new Promise((
|
|
83411
|
+
var __esm2 = (fn, res) => () => (fn && (res = fn(fn = 0)), res), CREDENTIAL_PROFILE_ENV_KEY2 = "HASNA_PROFILE", CredentialResolutionError2, CredentialFileUnsafeError2, HASNA_HOME_ENV_KEY2 = "HASNA_HOME", HASNA_CONFIG_HOME_ENV_KEY2 = "HASNA_CONFIG_HOME", KEYCHAIN_STATION_ENV_KEY2 = "HASNA_STATION", HASNA_HOME_DIR2 = ".hasna", CONFIG_SUBDIR2 = "config", CREDENTIALS_FILE2 = "credentials", KEYCHAIN_SECURITY_BIN2 = "/usr/bin/security", KEYCHAIN_SERVICE_PREFIX2 = "hasna.credentials", KEYCHAIN_ITEM_NOT_FOUND_STATUS2 = 44, KEYCHAIN_SPAWN_TIMEOUT_MS2 = 1e4, MAX_CREDENTIAL_FILE_BYTES2, SAFE_APP_SLUG2, SAFE_PROFILE2, ILLEGAL_IN_HEADER_VALUE2, VAULT_POINTER_SHAPE2, CREDENTIAL_SHAPED_KEY2, INSPECT_CUSTOM2, CREDENTIAL_SEAL2, CALLER_SUPPLIED_CREDENTIAL_PROVIDER_SOURCE = "caller-supplied CredentialProvider", AMBIENT_ENVIRONMENT2, SECRETS_PACKAGE_SPECIFIER, requireSecretsSdk2, DEFAULT_FLEET_GATEWAY_ORIGIN2 = "https://api.hasna.com", DEFAULT_AUTHORITY_SOURCE = "default", ASCII_CONTROL_PATTERN2, DNS_LABEL_PATTERN2, ClientTransportConfigurationError2, HasnaHttpError, DEFAULT_RETRY_STATUSES, IDEMPOTENT_METHODS2, AUTHORITY_OVERRIDE_HEADERS2, defaultSleep = (ms) => new Promise((resolve18) => setTimeout(resolve18, ms)), init_transport2, MAX_CREDENTIAL_FILE_BYTES22, INSPECT_CUSTOM22, CREDENTIAL_SEAL22, AMBIENT_ENVIRONMENT22, SECRETS_PACKAGE_SPECIFIER2, requireSecretsSdk22, IDEMPOTENT_METHODS22, AUTHORITY_OVERRIDE_HEADERS22, init_storage, PATHS_RESOLVER_APP_SLUG_RE3, SQLITE_SIDECAR_FILES, LEGACY_SERVICE_FILES, init_data_dir, SecretsTestIsolationError, TEST_ENTRYPOINT_RE, init_test_isolation, init_client, ApiError;
|
|
83175
83412
|
var init_sdk = __esm(() => {
|
|
83176
83413
|
init_transport2 = __esm2(() => {
|
|
83177
83414
|
CredentialResolutionError2 = class CredentialResolutionError3 extends Error {
|
|
@@ -83306,7 +83543,7 @@ var init_sdk = __esm(() => {
|
|
|
83306
83543
|
});
|
|
83307
83544
|
|
|
83308
83545
|
// src/lib/execution-secrets.ts
|
|
83309
|
-
import { constants as
|
|
83546
|
+
import { constants as constants14, closeSync as closeSync15, fstatSync as fstatSync15, openSync as openSync15, readSync as readSync12, realpathSync as realpathSync6 } from "fs";
|
|
83310
83547
|
import { hostname as stationHostname } from "os";
|
|
83311
83548
|
function selectedSecretBindingsTemplate(scope, names, createClient2 = createSecretsClientFromEnv) {
|
|
83312
83549
|
let secretsAuthority;
|
|
@@ -83350,13 +83587,13 @@ function declaredSecretNames(value) {
|
|
|
83350
83587
|
function readSelectedSecretBindings(path) {
|
|
83351
83588
|
let fd;
|
|
83352
83589
|
try {
|
|
83353
|
-
fd =
|
|
83354
|
-
const stat2 =
|
|
83590
|
+
fd = openSync15(path, constants14.O_RDONLY | constants14.O_NOFOLLOW | constants14.O_NONBLOCK);
|
|
83591
|
+
const stat2 = fstatSync15(fd);
|
|
83355
83592
|
if (!stat2.isFile() || stat2.size > 65536)
|
|
83356
83593
|
throw new Error;
|
|
83357
83594
|
const bytes = Buffer.alloc(65537);
|
|
83358
83595
|
let size2 = 0, count;
|
|
83359
|
-
while ((count =
|
|
83596
|
+
while ((count = readSync12(fd, bytes, size2, bytes.length - size2, null)) > 0) {
|
|
83360
83597
|
size2 += count;
|
|
83361
83598
|
if (size2 > 65536)
|
|
83362
83599
|
throw new Error;
|
|
@@ -83366,7 +83603,7 @@ function readSelectedSecretBindings(path) {
|
|
|
83366
83603
|
return refuse("INVALID_SECRET_BINDINGS", "Secret bindings must be a regular JSON file of at most 64 KiB, containing reference names only.");
|
|
83367
83604
|
} finally {
|
|
83368
83605
|
if (fd !== undefined)
|
|
83369
|
-
|
|
83606
|
+
closeSync15(fd);
|
|
83370
83607
|
}
|
|
83371
83608
|
}
|
|
83372
83609
|
function validateSelectedSecretBindings(value, scope, names) {
|
|
@@ -83655,10 +83892,10 @@ __export(exports_selected_run, {
|
|
|
83655
83892
|
prepareSelectedSecretBindings: () => prepareSelectedSecretBindings,
|
|
83656
83893
|
executeSelectedLocal: () => executeSelectedLocal
|
|
83657
83894
|
});
|
|
83658
|
-
import { createHash as
|
|
83895
|
+
import { createHash as createHash19 } from "crypto";
|
|
83659
83896
|
import { spawn as spawn2 } from "child_process";
|
|
83660
83897
|
import { mkdirSync as mkdirSync14, mkdtempSync as mkdtempSync4, writeFileSync as writeFileSync13, realpathSync as realpathSync7 } from "fs";
|
|
83661
|
-
import { dirname as
|
|
83898
|
+
import { dirname as dirname19, join as join42, resolve as resolve18 } from "path";
|
|
83662
83899
|
import { tmpdir, hostname as stationHostname2 } from "os";
|
|
83663
83900
|
async function resolveSelectedRun(spec, profileId, options = {}) {
|
|
83664
83901
|
const context = await resolveSelectionContext(profileId, options);
|
|
@@ -83747,11 +83984,11 @@ async function executeSelectedLocal(selected, options = {}) {
|
|
|
83747
83984
|
throw new SkillSelectionError("INVALID_BUNDLE_PATH", "The execution bundle path exceeds its limit.");
|
|
83748
83985
|
});
|
|
83749
83986
|
const destination = join42(runDirectory, entry.path);
|
|
83750
|
-
mkdirSync14(
|
|
83987
|
+
mkdirSync14(dirname19(destination), { recursive: true, mode: 448 });
|
|
83751
83988
|
writeFileSync13(destination, entry.bytes, { flag: "wx", mode: entry.mode & 511 });
|
|
83752
83989
|
}
|
|
83753
83990
|
env3.SKILLS_INPUT_JSON = input2;
|
|
83754
|
-
env3.SKILLS_WORKSPACE_DIR =
|
|
83991
|
+
env3.SKILLS_WORKSPACE_DIR = resolve18(options.cwd ?? process.cwd());
|
|
83755
83992
|
env3.SKILLS_RUN_DIR = runDirectory;
|
|
83756
83993
|
if (runtime.version) {
|
|
83757
83994
|
const version2 = await subprocess([executable, ...runtimeName === "bun" ? ["--no-env-file"] : [], "--version"], runDirectory, env3, "", Math.min(timeoutMs, 5000));
|
|
@@ -83781,7 +84018,7 @@ async function executeSelectedLocal(selected, options = {}) {
|
|
|
83781
84018
|
selection: selection2,
|
|
83782
84019
|
target: "local",
|
|
83783
84020
|
runtime: runtimeName,
|
|
83784
|
-
inputDigest: `sha256:${
|
|
84021
|
+
inputDigest: `sha256:${createHash19("sha256").update(input2).digest("hex")}`,
|
|
83785
84022
|
runDirectory,
|
|
83786
84023
|
...executionGrant ? { executionGrant } : {},
|
|
83787
84024
|
...bindings ? { secretBinding: { schema: bindings.schema, selection: bindings.selection, consumer: bindings.consumer, secretsAuthority: bindings.secretsAuthority, bindings: bindings.bindings } } : {},
|
|
@@ -87998,7 +88235,7 @@ var init_runs = __esm(() => {
|
|
|
87998
88235
|
});
|
|
87999
88236
|
|
|
88000
88237
|
// src/lib/run-state.ts
|
|
88001
|
-
import { createHash as
|
|
88238
|
+
import { createHash as createHash20, randomBytes } from "crypto";
|
|
88002
88239
|
import { existsSync as existsSync27, mkdirSync as mkdirSync15, readFileSync as readFileSync30, readdirSync as readdirSync16, statSync as statSync15, writeFileSync as writeFileSync14 } from "fs";
|
|
88003
88240
|
import { extname, join as join43, relative as relative6 } from "path";
|
|
88004
88241
|
function createSkillRun(params, targetDir = process.cwd()) {
|
|
@@ -88135,7 +88372,7 @@ function collectRunArtifacts(context) {
|
|
|
88135
88372
|
artifacts.push({
|
|
88136
88373
|
path: toProjectRelative(context.targetDir, path),
|
|
88137
88374
|
mime: mimeForPath(path),
|
|
88138
|
-
sha256:
|
|
88375
|
+
sha256: createHash20("sha256").update(bytes).digest("hex"),
|
|
88139
88376
|
sizeBytes: stat2.size
|
|
88140
88377
|
});
|
|
88141
88378
|
}
|
|
@@ -89138,12 +89375,12 @@ class StdioServerTransport {
|
|
|
89138
89375
|
this.onclose?.();
|
|
89139
89376
|
}
|
|
89140
89377
|
send(message) {
|
|
89141
|
-
return new Promise((
|
|
89378
|
+
return new Promise((resolve19) => {
|
|
89142
89379
|
const json2 = serializeMessage(message);
|
|
89143
89380
|
if (this._stdout.write(json2)) {
|
|
89144
|
-
|
|
89381
|
+
resolve19();
|
|
89145
89382
|
} else {
|
|
89146
|
-
this._stdout.once("drain",
|
|
89383
|
+
this._stdout.once("drain", resolve19);
|
|
89147
89384
|
}
|
|
89148
89385
|
});
|
|
89149
89386
|
}
|
|
@@ -89185,7 +89422,7 @@ var init_schemas3 = __esm(() => {
|
|
|
89185
89422
|
own(this, "with", value);
|
|
89186
89423
|
},
|
|
89187
89424
|
parse(data, params) {
|
|
89188
|
-
return
|
|
89425
|
+
return parse7(this, data, params, { callee: this.parse });
|
|
89189
89426
|
},
|
|
89190
89427
|
parseAsync(data, params) {
|
|
89191
89428
|
return parseAsync(this, data, params, { callee: this.parseAsync });
|
|
@@ -91329,7 +91566,7 @@ class Protocol {
|
|
|
91329
91566
|
return;
|
|
91330
91567
|
}
|
|
91331
91568
|
const pollInterval = task2.pollInterval ?? this._options?.defaultTaskPollInterval ?? 1000;
|
|
91332
|
-
await new Promise((
|
|
91569
|
+
await new Promise((resolve19) => setTimeout(resolve19, pollInterval));
|
|
91333
91570
|
options?.signal?.throwIfAborted();
|
|
91334
91571
|
}
|
|
91335
91572
|
} catch (error61) {
|
|
@@ -91341,7 +91578,7 @@ class Protocol {
|
|
|
91341
91578
|
}
|
|
91342
91579
|
request(request2, resultSchema, options) {
|
|
91343
91580
|
const { relatedRequestId, resumptionToken, onresumptiontoken, task, relatedTask } = options ?? {};
|
|
91344
|
-
return new Promise((
|
|
91581
|
+
return new Promise((resolve19, reject2) => {
|
|
91345
91582
|
const earlyReject = (error61) => {
|
|
91346
91583
|
reject2(error61);
|
|
91347
91584
|
};
|
|
@@ -91419,7 +91656,7 @@ class Protocol {
|
|
|
91419
91656
|
if (!parseResult.success) {
|
|
91420
91657
|
reject2(parseResult.error);
|
|
91421
91658
|
} else {
|
|
91422
|
-
|
|
91659
|
+
resolve19(parseResult.data);
|
|
91423
91660
|
}
|
|
91424
91661
|
} catch (error61) {
|
|
91425
91662
|
reject2(error61);
|
|
@@ -91610,12 +91847,12 @@ class Protocol {
|
|
|
91610
91847
|
interval = task.pollInterval;
|
|
91611
91848
|
}
|
|
91612
91849
|
} catch {}
|
|
91613
|
-
return new Promise((
|
|
91850
|
+
return new Promise((resolve19, reject2) => {
|
|
91614
91851
|
if (signal.aborted) {
|
|
91615
91852
|
reject2(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
|
|
91616
91853
|
return;
|
|
91617
91854
|
}
|
|
91618
|
-
const timeoutId = setTimeout(
|
|
91855
|
+
const timeoutId = setTimeout(resolve19, interval);
|
|
91619
91856
|
signal.addEventListener("abort", () => {
|
|
91620
91857
|
clearTimeout(timeoutId);
|
|
91621
91858
|
reject2(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
|
|
@@ -92092,11 +92329,11 @@ var require_codegen = __commonJS((exports) => {
|
|
|
92092
92329
|
const rhs = this.rhs === undefined ? "" : ` = ${this.rhs}`;
|
|
92093
92330
|
return `${varKind} ${this.name}${rhs};` + _n;
|
|
92094
92331
|
}
|
|
92095
|
-
optimizeNames(names,
|
|
92332
|
+
optimizeNames(names, constants15) {
|
|
92096
92333
|
if (!names[this.name.str])
|
|
92097
92334
|
return;
|
|
92098
92335
|
if (this.rhs)
|
|
92099
|
-
this.rhs = optimizeExpr(this.rhs, names,
|
|
92336
|
+
this.rhs = optimizeExpr(this.rhs, names, constants15);
|
|
92100
92337
|
return this;
|
|
92101
92338
|
}
|
|
92102
92339
|
get names() {
|
|
@@ -92114,10 +92351,10 @@ var require_codegen = __commonJS((exports) => {
|
|
|
92114
92351
|
render({ _n }) {
|
|
92115
92352
|
return `${this.lhs} = ${this.rhs};` + _n;
|
|
92116
92353
|
}
|
|
92117
|
-
optimizeNames(names,
|
|
92354
|
+
optimizeNames(names, constants15) {
|
|
92118
92355
|
if (this.lhs instanceof code_1.Name && !names[this.lhs.str] && !this.sideEffects)
|
|
92119
92356
|
return;
|
|
92120
|
-
this.rhs = optimizeExpr(this.rhs, names,
|
|
92357
|
+
this.rhs = optimizeExpr(this.rhs, names, constants15);
|
|
92121
92358
|
return this;
|
|
92122
92359
|
}
|
|
92123
92360
|
get names() {
|
|
@@ -92183,8 +92420,8 @@ var require_codegen = __commonJS((exports) => {
|
|
|
92183
92420
|
optimizeNodes() {
|
|
92184
92421
|
return `${this.code}` ? this : undefined;
|
|
92185
92422
|
}
|
|
92186
|
-
optimizeNames(names,
|
|
92187
|
-
this.code = optimizeExpr(this.code, names,
|
|
92423
|
+
optimizeNames(names, constants15) {
|
|
92424
|
+
this.code = optimizeExpr(this.code, names, constants15);
|
|
92188
92425
|
return this;
|
|
92189
92426
|
}
|
|
92190
92427
|
get names() {
|
|
@@ -92214,12 +92451,12 @@ var require_codegen = __commonJS((exports) => {
|
|
|
92214
92451
|
}
|
|
92215
92452
|
return nodes.length > 0 ? this : undefined;
|
|
92216
92453
|
}
|
|
92217
|
-
optimizeNames(names,
|
|
92454
|
+
optimizeNames(names, constants15) {
|
|
92218
92455
|
const { nodes } = this;
|
|
92219
92456
|
let i = nodes.length;
|
|
92220
92457
|
while (i--) {
|
|
92221
92458
|
const n2 = nodes[i];
|
|
92222
|
-
if (n2.optimizeNames(names,
|
|
92459
|
+
if (n2.optimizeNames(names, constants15))
|
|
92223
92460
|
continue;
|
|
92224
92461
|
subtractNames(names, n2.names);
|
|
92225
92462
|
nodes.splice(i, 1);
|
|
@@ -92276,12 +92513,12 @@ var require_codegen = __commonJS((exports) => {
|
|
|
92276
92513
|
return;
|
|
92277
92514
|
return this;
|
|
92278
92515
|
}
|
|
92279
|
-
optimizeNames(names,
|
|
92516
|
+
optimizeNames(names, constants15) {
|
|
92280
92517
|
var _a3;
|
|
92281
|
-
this.else = (_a3 = this.else) === null || _a3 === undefined ? undefined : _a3.optimizeNames(names,
|
|
92282
|
-
if (!(super.optimizeNames(names,
|
|
92518
|
+
this.else = (_a3 = this.else) === null || _a3 === undefined ? undefined : _a3.optimizeNames(names, constants15);
|
|
92519
|
+
if (!(super.optimizeNames(names, constants15) || this.else))
|
|
92283
92520
|
return;
|
|
92284
|
-
this.condition = optimizeExpr(this.condition, names,
|
|
92521
|
+
this.condition = optimizeExpr(this.condition, names, constants15);
|
|
92285
92522
|
return this;
|
|
92286
92523
|
}
|
|
92287
92524
|
get names() {
|
|
@@ -92306,10 +92543,10 @@ var require_codegen = __commonJS((exports) => {
|
|
|
92306
92543
|
render(opts) {
|
|
92307
92544
|
return `for(${this.iteration})` + super.render(opts);
|
|
92308
92545
|
}
|
|
92309
|
-
optimizeNames(names,
|
|
92310
|
-
if (!super.optimizeNames(names,
|
|
92546
|
+
optimizeNames(names, constants15) {
|
|
92547
|
+
if (!super.optimizeNames(names, constants15))
|
|
92311
92548
|
return;
|
|
92312
|
-
this.iteration = optimizeExpr(this.iteration, names,
|
|
92549
|
+
this.iteration = optimizeExpr(this.iteration, names, constants15);
|
|
92313
92550
|
return this;
|
|
92314
92551
|
}
|
|
92315
92552
|
get names() {
|
|
@@ -92347,10 +92584,10 @@ var require_codegen = __commonJS((exports) => {
|
|
|
92347
92584
|
render(opts) {
|
|
92348
92585
|
return `for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})` + super.render(opts);
|
|
92349
92586
|
}
|
|
92350
|
-
optimizeNames(names,
|
|
92351
|
-
if (!super.optimizeNames(names,
|
|
92587
|
+
optimizeNames(names, constants15) {
|
|
92588
|
+
if (!super.optimizeNames(names, constants15))
|
|
92352
92589
|
return;
|
|
92353
|
-
this.iterable = optimizeExpr(this.iterable, names,
|
|
92590
|
+
this.iterable = optimizeExpr(this.iterable, names, constants15);
|
|
92354
92591
|
return this;
|
|
92355
92592
|
}
|
|
92356
92593
|
get names() {
|
|
@@ -92395,11 +92632,11 @@ var require_codegen = __commonJS((exports) => {
|
|
|
92395
92632
|
(_b = this.finally) === null || _b === undefined || _b.optimizeNodes();
|
|
92396
92633
|
return this;
|
|
92397
92634
|
}
|
|
92398
|
-
optimizeNames(names,
|
|
92635
|
+
optimizeNames(names, constants15) {
|
|
92399
92636
|
var _a3, _b;
|
|
92400
|
-
super.optimizeNames(names,
|
|
92401
|
-
(_a3 = this.catch) === null || _a3 === undefined || _a3.optimizeNames(names,
|
|
92402
|
-
(_b = this.finally) === null || _b === undefined || _b.optimizeNames(names,
|
|
92637
|
+
super.optimizeNames(names, constants15);
|
|
92638
|
+
(_a3 = this.catch) === null || _a3 === undefined || _a3.optimizeNames(names, constants15);
|
|
92639
|
+
(_b = this.finally) === null || _b === undefined || _b.optimizeNames(names, constants15);
|
|
92403
92640
|
return this;
|
|
92404
92641
|
}
|
|
92405
92642
|
get names() {
|
|
@@ -92673,7 +92910,7 @@ var require_codegen = __commonJS((exports) => {
|
|
|
92673
92910
|
function addExprNames(names, from) {
|
|
92674
92911
|
return from instanceof code_1._CodeOrName ? addNames(names, from.names) : names;
|
|
92675
92912
|
}
|
|
92676
|
-
function optimizeExpr(expr, names,
|
|
92913
|
+
function optimizeExpr(expr, names, constants15) {
|
|
92677
92914
|
if (expr instanceof code_1.Name)
|
|
92678
92915
|
return replaceName(expr);
|
|
92679
92916
|
if (!canOptimize(expr))
|
|
@@ -92688,14 +92925,14 @@ var require_codegen = __commonJS((exports) => {
|
|
|
92688
92925
|
return items;
|
|
92689
92926
|
}, []));
|
|
92690
92927
|
function replaceName(n2) {
|
|
92691
|
-
const c =
|
|
92928
|
+
const c = constants15[n2.str];
|
|
92692
92929
|
if (c === undefined || names[n2.str] !== 1)
|
|
92693
92930
|
return n2;
|
|
92694
92931
|
delete names[n2.str];
|
|
92695
92932
|
return c;
|
|
92696
92933
|
}
|
|
92697
92934
|
function canOptimize(e2) {
|
|
92698
|
-
return e2 instanceof code_1._Code && e2._items.some((c) => c instanceof code_1.Name && names[c.str] === 1 &&
|
|
92935
|
+
return e2 instanceof code_1._Code && e2._items.some((c) => c instanceof code_1.Name && names[c.str] === 1 && constants15[c.str] !== undefined);
|
|
92699
92936
|
}
|
|
92700
92937
|
}
|
|
92701
92938
|
function subtractNames(names, from) {
|
|
@@ -94600,7 +94837,7 @@ var require_compile = __commonJS((exports) => {
|
|
|
94600
94837
|
const schOrFunc = root2.refs[ref];
|
|
94601
94838
|
if (schOrFunc)
|
|
94602
94839
|
return schOrFunc;
|
|
94603
|
-
let _sch =
|
|
94840
|
+
let _sch = resolve19.call(this, root2, ref);
|
|
94604
94841
|
if (_sch === undefined) {
|
|
94605
94842
|
const schema = (_a3 = root2.localRefs) === null || _a3 === undefined ? undefined : _a3[ref];
|
|
94606
94843
|
const { schemaId } = this.opts;
|
|
@@ -94627,7 +94864,7 @@ var require_compile = __commonJS((exports) => {
|
|
|
94627
94864
|
function sameSchemaEnv(s1, s2) {
|
|
94628
94865
|
return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
|
|
94629
94866
|
}
|
|
94630
|
-
function
|
|
94867
|
+
function resolve19(root2, ref) {
|
|
94631
94868
|
let sch;
|
|
94632
94869
|
while (typeof (sch = this.refs[ref]) == "string")
|
|
94633
94870
|
ref = sch;
|
|
@@ -95425,11 +95662,11 @@ var require_fast_uri = __commonJS((exports, module) => {
|
|
|
95425
95662
|
if (typeof uri === "string") {
|
|
95426
95663
|
uri = normalizeString(uri, options);
|
|
95427
95664
|
} else if (typeof uri === "object") {
|
|
95428
|
-
uri =
|
|
95665
|
+
uri = parse12(serialize(uri, options), options);
|
|
95429
95666
|
}
|
|
95430
95667
|
return uri;
|
|
95431
95668
|
}
|
|
95432
|
-
function
|
|
95669
|
+
function resolve19(baseURI, relativeURI, options) {
|
|
95433
95670
|
const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
|
|
95434
95671
|
const {
|
|
95435
95672
|
parsed: baseParsed,
|
|
@@ -95465,8 +95702,8 @@ var require_fast_uri = __commonJS((exports, module) => {
|
|
|
95465
95702
|
function resolveComponent(base2, relative7, options, skipNormalization) {
|
|
95466
95703
|
const target = {};
|
|
95467
95704
|
if (!skipNormalization) {
|
|
95468
|
-
base2 =
|
|
95469
|
-
relative7 =
|
|
95705
|
+
base2 = parse12(serialize(base2, options), options);
|
|
95706
|
+
relative7 = parse12(serialize(relative7, options), options);
|
|
95470
95707
|
}
|
|
95471
95708
|
options = options || {};
|
|
95472
95709
|
if (!options.tolerant && relative7.scheme) {
|
|
@@ -95766,7 +96003,7 @@ var require_fast_uri = __commonJS((exports, module) => {
|
|
|
95766
96003
|
}
|
|
95767
96004
|
return { parsed, malformedAuthorityOrPort, malformedPercentEncoding, malformedSchemeSpecific, malformedHost, malformedScheme };
|
|
95768
96005
|
}
|
|
95769
|
-
function
|
|
96006
|
+
function parse12(uri, opts) {
|
|
95770
96007
|
return parseWithStatus(uri, opts).parsed;
|
|
95771
96008
|
}
|
|
95772
96009
|
function normalizeString(uri, opts) {
|
|
@@ -95799,11 +96036,11 @@ var require_fast_uri = __commonJS((exports, module) => {
|
|
|
95799
96036
|
var fastUri = {
|
|
95800
96037
|
SCHEMES,
|
|
95801
96038
|
normalize: normalize3,
|
|
95802
|
-
resolve:
|
|
96039
|
+
resolve: resolve19,
|
|
95803
96040
|
resolveComponent,
|
|
95804
96041
|
equal,
|
|
95805
96042
|
serialize,
|
|
95806
|
-
parse:
|
|
96043
|
+
parse: parse12
|
|
95807
96044
|
};
|
|
95808
96045
|
module.exports = fastUri;
|
|
95809
96046
|
module.exports.default = fastUri;
|
|
@@ -99585,7 +99822,7 @@ class McpServer {
|
|
|
99585
99822
|
let task = createTaskResult.task;
|
|
99586
99823
|
const pollInterval = task.pollInterval ?? 5000;
|
|
99587
99824
|
while (task.status !== "completed" && task.status !== "failed" && task.status !== "cancelled") {
|
|
99588
|
-
await new Promise((
|
|
99825
|
+
await new Promise((resolve19) => setTimeout(resolve19, pollInterval));
|
|
99589
99826
|
const updatedTask = await extra.taskStore.getTask(taskId);
|
|
99590
99827
|
if (!updatedTask) {
|
|
99591
99828
|
throw new McpError(ErrorCode.InternalError, `Task ${taskId} not found during polling`);
|
|
@@ -100272,7 +100509,7 @@ var init_remote_invitation_recovery = __esm(() => {
|
|
|
100272
100509
|
});
|
|
100273
100510
|
|
|
100274
100511
|
// src/lib/remote-private-publications.ts
|
|
100275
|
-
import { createHash as
|
|
100512
|
+
import { createHash as createHash21 } from "crypto";
|
|
100276
100513
|
function checkedPublicationDeclaration(value) {
|
|
100277
100514
|
if (!exact(value, ["idempotencyKey", "version", "expectedCurrentVersionId", "manifestText", "archiveSha256", "archiveByteSize"]) || !publicationUuid(value.idempotencyKey) || !(value.expectedCurrentVersionId === null || publicationUuid(value.expectedCurrentVersionId)) || typeof value.version !== "string" || !value.version || value.version.length > 128 || /[\p{Cc}\p{Cs}]/u.test(value.version) || typeof value.manifestText !== "string" || Buffer.byteLength(value.manifestText) > 16384 || !hash3(value.archiveSha256) || !Number.isSafeInteger(value.archiveByteSize) || Number(value.archiveByteSize) < 1 || Number(value.archiveByteSize) > PRIVATE_PUBLICATION_MAX_BYTES)
|
|
100278
100515
|
return bad();
|
|
@@ -100517,12 +100754,12 @@ class RemotePrivatePublicationsClient {
|
|
|
100517
100754
|
previous = view;
|
|
100518
100755
|
if (!["queued", "verifying"].includes(view.state) || Date.now() >= until)
|
|
100519
100756
|
return view;
|
|
100520
|
-
await new Promise((
|
|
100757
|
+
await new Promise((resolve19) => {
|
|
100521
100758
|
const timer = setTimeout(done, Math.min(1000, until - Date.now()));
|
|
100522
100759
|
function done() {
|
|
100523
100760
|
clearTimeout(timer);
|
|
100524
100761
|
options.signal?.removeEventListener("abort", done);
|
|
100525
|
-
|
|
100762
|
+
resolve19();
|
|
100526
100763
|
}
|
|
100527
100764
|
options.signal?.addEventListener("abort", done, { once: true });
|
|
100528
100765
|
});
|
|
@@ -100533,7 +100770,7 @@ var PRIVATE_PUBLICATION_MAX_BYTES, failures2, PrivatePublicationError, bad = ()
|
|
|
100533
100770
|
throw new PrivatePublicationError("INVALID_PUBLICATION_INPUT", "Invalid publication input or recovery data.");
|
|
100534
100771
|
}, invalid5 = () => {
|
|
100535
100772
|
throw new PrivatePublicationError("INVALID_PUBLICATION_RESPONSE", "The server returned an invalid publication result.");
|
|
100536
|
-
}, publicationUuid = (v) => typeof v === "string" && /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/.test(v), hash3 = (v) => typeof v === "string" && /^[a-f0-9]{64}$/.test(v), record10 = (v) => !!v && typeof v === "object" && !Array.isArray(v), exact = (v, keys3) => record10(v) && Object.keys(v).sort().join(",") === keys3.sort().join(","), date6 = (v) => typeof v === "string" && /^\d{4}-\d\d-\d\dT[0-9:.]+(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/.test(v) && Number.isFinite(Date.parse(v)), publicationSha256 = (bytes) =>
|
|
100773
|
+
}, publicationUuid = (v) => typeof v === "string" && /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/.test(v), hash3 = (v) => typeof v === "string" && /^[a-f0-9]{64}$/.test(v), record10 = (v) => !!v && typeof v === "object" && !Array.isArray(v), exact = (v, keys3) => record10(v) && Object.keys(v).sort().join(",") === keys3.sort().join(","), date6 = (v) => typeof v === "string" && /^\d{4}-\d\d-\d\dT[0-9:.]+(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/.test(v) && Number.isFinite(Date.parse(v)), publicationSha256 = (bytes) => createHash21("sha256").update(bytes).digest("hex");
|
|
100537
100774
|
var init_remote_private_publications = __esm(() => {
|
|
100538
100775
|
init_fleet_credentials();
|
|
100539
100776
|
init_remote_workspace_selection();
|
|
@@ -100810,11 +101047,11 @@ var init_remote_auth = __esm(() => {
|
|
|
100810
101047
|
});
|
|
100811
101048
|
|
|
100812
101049
|
// src/lib/workspace-profile.ts
|
|
100813
|
-
import { constants as
|
|
100814
|
-
import { dirname as
|
|
101050
|
+
import { constants as constants15, closeSync as closeSync16, fstatSync as fstatSync16, lstatSync as lstatSync22, mkdirSync as mkdirSync16, mkdtempSync as mkdtempSync5, openSync as openSync16, readFileSync as readFileSync31, renameSync as renameSync9, rmSync as rmSync8, writeFileSync as writeFileSync15 } from "fs";
|
|
101051
|
+
import { dirname as dirname20, join as join44 } from "path";
|
|
100815
101052
|
function stat2(path) {
|
|
100816
101053
|
try {
|
|
100817
|
-
return
|
|
101054
|
+
return lstatSync22(path);
|
|
100818
101055
|
} catch (error61) {
|
|
100819
101056
|
if (error61.code === "ENOENT")
|
|
100820
101057
|
return null;
|
|
@@ -100824,14 +101061,14 @@ function stat2(path) {
|
|
|
100824
101061
|
function safeText(file2) {
|
|
100825
101062
|
if (stat2(file2) === null)
|
|
100826
101063
|
return null;
|
|
100827
|
-
const fd =
|
|
101064
|
+
const fd = openSync16(file2, constants15.O_RDONLY | constants15.O_NOFOLLOW | constants15.O_NONBLOCK);
|
|
100828
101065
|
try {
|
|
100829
|
-
const s =
|
|
101066
|
+
const s = fstatSync16(fd);
|
|
100830
101067
|
if (!s.isFile() || s.size > 65536 || ![256, 384].includes(s.mode & 4095) || process.getuid && s.uid !== process.getuid())
|
|
100831
101068
|
return fail2("The selected profile must use bounded owner-only regular files.");
|
|
100832
101069
|
return readFileSync31(fd, "utf8");
|
|
100833
101070
|
} finally {
|
|
100834
|
-
|
|
101071
|
+
closeSync16(fd);
|
|
100835
101072
|
}
|
|
100836
101073
|
}
|
|
100837
101074
|
function checkIdentityMetadata(file2, identity4) {
|
|
@@ -100896,18 +101133,18 @@ async function prepareWorkspaceEnrollment(membershipId, source = process.env) {
|
|
|
100896
101133
|
`);
|
|
100897
101134
|
if (Buffer.byteLength(credentialBody("x".repeat(8192)), "utf8") > 65536)
|
|
100898
101135
|
return fail2("The selected profile has insufficient space for a bounded credential. Reduce its unrelated configuration before signing in.");
|
|
100899
|
-
const
|
|
100900
|
-
for (let path =
|
|
101136
|
+
const parents3 = [];
|
|
101137
|
+
for (let path = dirname20(file2);; path = dirname20(path)) {
|
|
100901
101138
|
const before2 = stat2(path);
|
|
100902
101139
|
if (before2 && (!before2.isDirectory() || before2.isSymbolicLink()))
|
|
100903
101140
|
return fail2("The profile directory must not be a symbolic link.");
|
|
100904
|
-
|
|
100905
|
-
if (path ===
|
|
101141
|
+
parents3.push([path, before2]);
|
|
101142
|
+
if (path === dirname20(path))
|
|
100906
101143
|
break;
|
|
100907
101144
|
}
|
|
100908
101145
|
const unchanged2 = () => {
|
|
100909
101146
|
unchangedFiles();
|
|
100910
|
-
for (const [path, before2] of
|
|
101147
|
+
for (const [path, before2] of parents3) {
|
|
100911
101148
|
const now3 = stat2(path);
|
|
100912
101149
|
if (!before2 ? now3 !== null : !now3 || !now3.isDirectory() || before2.dev !== now3.dev || before2.ino !== now3.ino)
|
|
100913
101150
|
changed();
|
|
@@ -100961,14 +101198,14 @@ async function prepareWorkspaceEnrollment(membershipId, source = process.env) {
|
|
|
100961
101198
|
return fail2("The new profile exceeds the credential reader size limit.");
|
|
100962
101199
|
const identity4 = JSON.stringify({ email: verified.user.email, userId: verified.user.id, orgId: verified.organization.id, orgSlug: verified.organization.slug, apiUrl: origin }, null, 2) + `
|
|
100963
101200
|
`;
|
|
100964
|
-
mkdirSync16(
|
|
100965
|
-
const temp = mkdtempSync5(join44(
|
|
101201
|
+
mkdirSync16(dirname20(file2), { recursive: true, mode: 448 });
|
|
101202
|
+
const temp = mkdtempSync5(join44(dirname20(file2), ".workspace-login-"));
|
|
100966
101203
|
let identityInstalled = false;
|
|
100967
101204
|
try {
|
|
100968
101205
|
writeFileSync15(join44(temp, "credentials"), body, { mode: 384, flag: "wx" });
|
|
100969
101206
|
writeFileSync15(join44(temp, "identity"), identity4, { mode: 384, flag: "wx" });
|
|
100970
101207
|
unchangedFiles();
|
|
100971
|
-
for (const [path, before2] of
|
|
101208
|
+
for (const [path, before2] of parents3) {
|
|
100972
101209
|
const now3 = stat2(path);
|
|
100973
101210
|
if (!now3 || !now3.isDirectory() || now3.isSymbolicLink() || before2 && (before2.dev !== now3.dev || before2.ino !== now3.ino))
|
|
100974
101211
|
changed();
|
|
@@ -101178,8 +101415,8 @@ var init_recurring_customer = __esm(() => {
|
|
|
101178
101415
|
});
|
|
101179
101416
|
|
|
101180
101417
|
// src/lib/recurring-recovery.ts
|
|
101181
|
-
import { constants as
|
|
101182
|
-
import { dirname as
|
|
101418
|
+
import { constants as constants16, closeSync as closeSync17, fsyncSync as fsyncSync4, fstatSync as fstatSync17, lstatSync as lstatSync23, mkdirSync as mkdirSync17, openSync as openSync17, readSync as readSync13, realpathSync as realpathSync8, renameSync as renameSync10, unlinkSync as unlinkSync6, writeFileSync as writeFileSync16 } from "fs";
|
|
101419
|
+
import { dirname as dirname21, isAbsolute as isAbsolute17, join as join45, resolve as resolve19 } from "path";
|
|
101183
101420
|
import { randomUUID as randomUUID7 } from "crypto";
|
|
101184
101421
|
|
|
101185
101422
|
class RecoveryOwner {
|
|
@@ -101187,14 +101424,14 @@ class RecoveryOwner {
|
|
|
101187
101424
|
parents = [];
|
|
101188
101425
|
constructor(directory) {
|
|
101189
101426
|
this.directory = directory;
|
|
101190
|
-
if (!
|
|
101427
|
+
if (!isAbsolute17(directory) || resolve19(directory) !== directory || realpathSync8(directory) !== directory)
|
|
101191
101428
|
invalid6();
|
|
101192
|
-
for (let path = directory;; path =
|
|
101193
|
-
const stat3 =
|
|
101429
|
+
for (let path = directory;; path = dirname21(path)) {
|
|
101430
|
+
const stat3 = lstatSync23(path);
|
|
101194
101431
|
if (!stat3.isDirectory() || stat3.isSymbolicLink())
|
|
101195
101432
|
invalid6();
|
|
101196
101433
|
this.parents.push({ path, dev: stat3.dev, ino: stat3.ino });
|
|
101197
|
-
if (path ===
|
|
101434
|
+
if (path === dirname21(path))
|
|
101198
101435
|
break;
|
|
101199
101436
|
}
|
|
101200
101437
|
this.assert();
|
|
@@ -101203,59 +101440,59 @@ class RecoveryOwner {
|
|
|
101203
101440
|
if (realpathSync8(this.directory) !== this.directory)
|
|
101204
101441
|
invalid6();
|
|
101205
101442
|
for (const prior of this.parents) {
|
|
101206
|
-
const now3 =
|
|
101443
|
+
const now3 = lstatSync23(prior.path);
|
|
101207
101444
|
if (!now3.isDirectory() || now3.isSymbolicLink() || now3.dev !== prior.dev || now3.ino !== prior.ino)
|
|
101208
101445
|
invalid6();
|
|
101209
101446
|
}
|
|
101210
|
-
const own2 =
|
|
101447
|
+
const own2 = lstatSync23(this.directory);
|
|
101211
101448
|
if ((own2.mode & 511) !== 448 || (own2.mode & 3584) !== 0 || process.getuid && own2.uid !== process.getuid())
|
|
101212
101449
|
invalid6();
|
|
101213
101450
|
}
|
|
101214
101451
|
read(name) {
|
|
101215
101452
|
this.assert();
|
|
101216
|
-
const fd =
|
|
101453
|
+
const fd = openSync17(join45(this.directory, name), constants16.O_RDONLY | constants16.O_NOFOLLOW | constants16.O_NONBLOCK);
|
|
101217
101454
|
try {
|
|
101218
|
-
const before2 =
|
|
101455
|
+
const before2 = fstatSync17(fd);
|
|
101219
101456
|
if (!before2.isFile() || before2.nlink !== 1 || (before2.mode & 4095) !== 384 || before2.size < 1 || before2.size > 8192 || process.getuid && before2.uid !== process.getuid())
|
|
101220
101457
|
invalid6();
|
|
101221
101458
|
const bytes = Buffer.alloc(before2.size + 1);
|
|
101222
101459
|
let size2 = 0;
|
|
101223
101460
|
while (size2 < bytes.length) {
|
|
101224
|
-
const n2 =
|
|
101461
|
+
const n2 = readSync13(fd, bytes, size2, bytes.length - size2, size2);
|
|
101225
101462
|
if (!n2)
|
|
101226
101463
|
break;
|
|
101227
101464
|
size2 += n2;
|
|
101228
101465
|
}
|
|
101229
|
-
const after2 =
|
|
101466
|
+
const after2 = fstatSync17(fd), path = lstatSync23(join45(this.directory, name));
|
|
101230
101467
|
if (size2 !== before2.size || after2.size !== before2.size || before2.mtimeMs !== after2.mtimeMs || before2.ctimeMs !== after2.ctimeMs || path.dev !== before2.dev || path.ino !== before2.ino || !path.isFile() || path.isSymbolicLink())
|
|
101231
101468
|
invalid6();
|
|
101232
101469
|
this.assert();
|
|
101233
101470
|
return new TextDecoder("utf-8", { fatal: true }).decode(bytes.subarray(0, size2));
|
|
101234
101471
|
} finally {
|
|
101235
|
-
|
|
101472
|
+
closeSync17(fd);
|
|
101236
101473
|
}
|
|
101237
101474
|
}
|
|
101238
101475
|
write(name, value) {
|
|
101239
101476
|
this.assert();
|
|
101240
101477
|
const bytes = canonicalJson2(value, 8192) + `
|
|
101241
101478
|
`;
|
|
101242
|
-
const fd =
|
|
101479
|
+
const fd = openSync17(join45(this.directory, name), constants16.O_WRONLY | constants16.O_CREAT | constants16.O_EXCL | constants16.O_NOFOLLOW, 384);
|
|
101243
101480
|
try {
|
|
101244
101481
|
writeFileSync16(fd, bytes);
|
|
101245
101482
|
fsyncSync4(fd);
|
|
101246
101483
|
} finally {
|
|
101247
|
-
|
|
101484
|
+
closeSync17(fd);
|
|
101248
101485
|
}
|
|
101249
101486
|
this.assert();
|
|
101250
101487
|
this.sync();
|
|
101251
101488
|
}
|
|
101252
101489
|
sync() {
|
|
101253
101490
|
this.assert();
|
|
101254
|
-
const fd =
|
|
101491
|
+
const fd = openSync17(this.directory, constants16.O_RDONLY | constants16.O_NOFOLLOW);
|
|
101255
101492
|
try {
|
|
101256
101493
|
fsyncSync4(fd);
|
|
101257
101494
|
} finally {
|
|
101258
|
-
|
|
101495
|
+
closeSync17(fd);
|
|
101259
101496
|
}
|
|
101260
101497
|
}
|
|
101261
101498
|
saveState(state, expected) {
|
|
@@ -101273,20 +101510,20 @@ class RecoveryOwner {
|
|
|
101273
101510
|
this.assert();
|
|
101274
101511
|
let fd;
|
|
101275
101512
|
try {
|
|
101276
|
-
fd =
|
|
101513
|
+
fd = openSync17(join45(this.directory, "operation.lock"), constants16.O_WRONLY | constants16.O_CREAT | constants16.O_EXCL | constants16.O_NOFOLLOW, 384);
|
|
101277
101514
|
} catch {
|
|
101278
101515
|
throw new RecurringCustomerError("RECURRING_RECOVERY_BUSY", "Recovery is locked. Confirm the original process has stopped before explicitly reconciling the retained lock; no request was retried.");
|
|
101279
101516
|
}
|
|
101280
|
-
const owner2 =
|
|
101517
|
+
const owner2 = fstatSync17(fd);
|
|
101281
101518
|
try {
|
|
101282
101519
|
writeFileSync16(fd, JSON.stringify({ pid: process.pid }));
|
|
101283
101520
|
fsyncSync4(fd);
|
|
101284
101521
|
this.sync();
|
|
101285
101522
|
return await action();
|
|
101286
101523
|
} finally {
|
|
101287
|
-
|
|
101524
|
+
closeSync17(fd);
|
|
101288
101525
|
this.assert();
|
|
101289
|
-
const now3 =
|
|
101526
|
+
const now3 = lstatSync23(join45(this.directory, "operation.lock"));
|
|
101290
101527
|
if (owner2.dev !== now3.dev || owner2.ino !== now3.ino || !now3.isFile() || now3.isSymbolicLink())
|
|
101291
101528
|
invalid6();
|
|
101292
101529
|
unlinkSync6(join45(this.directory, "operation.lock"));
|
|
@@ -101322,7 +101559,7 @@ function base2(customer, organizationId) {
|
|
|
101322
101559
|
};
|
|
101323
101560
|
}
|
|
101324
101561
|
function create3(directory, intent) {
|
|
101325
|
-
if (!
|
|
101562
|
+
if (!isAbsolute17(directory) || resolve19(directory) !== directory || realpathSync8(dirname21(directory)) !== dirname21(directory))
|
|
101326
101563
|
invalid6();
|
|
101327
101564
|
mkdirSync17(directory, { mode: 448 });
|
|
101328
101565
|
const owner2 = new RecoveryOwner(directory), checked = intentSchema.parse(intent), intentSha256 = canonicalJsonSha256(checked);
|
|
@@ -101485,7 +101722,7 @@ var init_recurring_recovery = __esm(() => {
|
|
|
101485
101722
|
});
|
|
101486
101723
|
|
|
101487
101724
|
// src/lib/recurring-surface.ts
|
|
101488
|
-
import { isAbsolute as
|
|
101725
|
+
import { isAbsolute as isAbsolute18 } from "path";
|
|
101489
101726
|
function recurringMcpSchema(action) {
|
|
101490
101727
|
return action === "activate" ? recurringSurfaceSchemas.activate.extend({ code, confirm: exports_external.literal(true) }) : recurringSurfaceSchemas[action];
|
|
101491
101728
|
}
|
|
@@ -101590,7 +101827,7 @@ var init_recurring_surface = __esm(() => {
|
|
|
101590
101827
|
uuid13 = exports_external.string().regex(/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/);
|
|
101591
101828
|
context = { userId: uuid13.optional(), membershipId: uuid13.optional() };
|
|
101592
101829
|
page2 = { limit: exports_external.number().int().min(1).max(100).optional(), cursor: exports_external.string().min(1).max(2048).optional() };
|
|
101593
|
-
directory = exports_external.string().max(4096).refine(
|
|
101830
|
+
directory = exports_external.string().max(4096).refine(isAbsolute18, "Use an absolute recovery directory");
|
|
101594
101831
|
email4 = exports_external.string().trim().toLowerCase().email().max(254);
|
|
101595
101832
|
code = exports_external.string().regex(/^\d{6}$/);
|
|
101596
101833
|
recurringSurfaceSchemas = {
|
|
@@ -103496,14 +103733,14 @@ var init_operation_tools = __esm(() => {
|
|
|
103496
103733
|
|
|
103497
103734
|
// src/lib/feedback.ts
|
|
103498
103735
|
import { appendFileSync as appendFileSync2, existsSync as existsSync29, mkdirSync as mkdirSync18 } from "fs";
|
|
103499
|
-
import { dirname as
|
|
103736
|
+
import { dirname as dirname22, join as join47 } from "path";
|
|
103500
103737
|
import { Database } from "bun:sqlite";
|
|
103501
103738
|
function getFeedbackDbPath() {
|
|
103502
103739
|
return join47(getDataDir(), "skills.db");
|
|
103503
103740
|
}
|
|
103504
103741
|
function getFeedbackDb() {
|
|
103505
103742
|
const dbPath = getFeedbackDbPath();
|
|
103506
|
-
const dir =
|
|
103743
|
+
const dir = dirname22(dbPath);
|
|
103507
103744
|
if (!existsSync29(dir))
|
|
103508
103745
|
mkdirSync18(dir, { recursive: true });
|
|
103509
103746
|
const db = new Database(dbPath);
|
|
@@ -103532,7 +103769,7 @@ function saveFeedback(input2) {
|
|
|
103532
103769
|
const category = input2.category ?? "general";
|
|
103533
103770
|
if (isApiMode()) {
|
|
103534
103771
|
const path = join47(getDataDir(), "feedback.jsonl");
|
|
103535
|
-
const dir =
|
|
103772
|
+
const dir = dirname22(path);
|
|
103536
103773
|
if (!existsSync29(dir))
|
|
103537
103774
|
mkdirSync18(dir, { recursive: true });
|
|
103538
103775
|
appendFileSync2(path, JSON.stringify({ message, category, email: input2.email ?? null, agent: input2.agent ?? null, version: input2.version ?? null, createdAt: new Date().toISOString() }) + `
|
|
@@ -104010,7 +104247,7 @@ var init_schedule_tools = __esm(() => {
|
|
|
104010
104247
|
});
|
|
104011
104248
|
|
|
104012
104249
|
// src/lib/native-storage.ts
|
|
104013
|
-
import { createHash as
|
|
104250
|
+
import { createHash as createHash22, createHmac as createHmac3 } from "crypto";
|
|
104014
104251
|
import {
|
|
104015
104252
|
existsSync as existsSync31,
|
|
104016
104253
|
mkdirSync as mkdirSync20,
|
|
@@ -104019,7 +104256,7 @@ import {
|
|
|
104019
104256
|
statSync as statSync17,
|
|
104020
104257
|
writeFileSync as writeFileSync18
|
|
104021
104258
|
} from "fs";
|
|
104022
|
-
import { dirname as
|
|
104259
|
+
import { dirname as dirname23, join as join49, normalize as normalize3, relative as relative7, sep as sep7 } from "path";
|
|
104023
104260
|
function resolveSkillsNativeStorageConfig(env3 = process.env) {
|
|
104024
104261
|
assertNoRetiredModeEnvVars(env3, {
|
|
104025
104262
|
app: SKILLS_ENV_NAMESPACE,
|
|
@@ -104087,7 +104324,7 @@ function exportSkillsLocalSnapshot(targetDir = process.cwd(), options = {}) {
|
|
|
104087
104324
|
files.push({
|
|
104088
104325
|
path: relativePath,
|
|
104089
104326
|
sizeBytes: bytes.byteLength,
|
|
104090
|
-
sha256:
|
|
104327
|
+
sha256: createHash22("sha256").update(bytes).digest("hex"),
|
|
104091
104328
|
...options.includeFileContents ? { contentBase64: Buffer.from(bytes).toString("base64") } : {}
|
|
104092
104329
|
});
|
|
104093
104330
|
}
|
|
@@ -104379,20 +104616,20 @@ var init_private_publication_customer = __esm(() => {
|
|
|
104379
104616
|
});
|
|
104380
104617
|
|
|
104381
104618
|
// src/lib/private-publication-recovery.ts
|
|
104382
|
-
import { constants as
|
|
104383
|
-
import { dirname as
|
|
104619
|
+
import { constants as constants17, closeSync as closeSync18, fsyncSync as fsyncSync5, fstatSync as fstatSync18, lstatSync as lstatSync24, mkdirSync as mkdirSync21, openSync as openSync18, readSync as readSync14, realpathSync as realpathSync9, renameSync as renameSync11, unlinkSync as unlinkSync7, writeFileSync as writeFileSync19 } from "fs";
|
|
104620
|
+
import { dirname as dirname24, isAbsolute as isAbsolute19, join as join50, resolve as resolve20 } from "path";
|
|
104384
104621
|
import { randomUUID as randomUUID8 } from "crypto";
|
|
104385
104622
|
function safeDirectory(directory2) {
|
|
104386
|
-
if (!
|
|
104623
|
+
if (!isAbsolute19(directory2) || directory2 !== resolve20(directory2) || realpathSync9(directory2) !== directory2)
|
|
104387
104624
|
return fail3();
|
|
104388
|
-
for (let path = directory2;; path =
|
|
104389
|
-
const stat3 =
|
|
104625
|
+
for (let path = directory2;; path = dirname24(path)) {
|
|
104626
|
+
const stat3 = lstatSync24(path);
|
|
104390
104627
|
if (!stat3.isDirectory() || stat3.isSymbolicLink())
|
|
104391
104628
|
return fail3();
|
|
104392
|
-
if (path ===
|
|
104629
|
+
if (path === dirname24(path))
|
|
104393
104630
|
break;
|
|
104394
104631
|
}
|
|
104395
|
-
const own2 =
|
|
104632
|
+
const own2 = lstatSync24(directory2);
|
|
104396
104633
|
if ((own2.mode & 63) !== 0 || process.getuid && own2.uid !== process.getuid())
|
|
104397
104634
|
return fail3();
|
|
104398
104635
|
return { dev: own2.dev, ino: own2.ino };
|
|
@@ -104404,35 +104641,35 @@ function unchangedDirectory(directory2, identity4) {
|
|
|
104404
104641
|
}
|
|
104405
104642
|
function readOwned(directory2, name, max2) {
|
|
104406
104643
|
const identity4 = safeDirectory(directory2), file2 = join50(directory2, name);
|
|
104407
|
-
const fd =
|
|
104644
|
+
const fd = openSync18(file2, constants17.O_RDONLY | constants17.O_NOFOLLOW);
|
|
104408
104645
|
try {
|
|
104409
|
-
const stat3 =
|
|
104646
|
+
const stat3 = fstatSync18(fd);
|
|
104410
104647
|
if (!stat3.isFile() || stat3.nlink !== 1 || stat3.size > max2 || stat3.size < 1 || (stat3.mode & 63) !== 0 || process.getuid && stat3.uid !== process.getuid())
|
|
104411
104648
|
return fail3();
|
|
104412
104649
|
const buffer = Buffer.alloc(Math.min(max2, stat3.size) + 1);
|
|
104413
104650
|
let length = 0;
|
|
104414
104651
|
while (length < buffer.length) {
|
|
104415
|
-
const count =
|
|
104652
|
+
const count = readSync14(fd, buffer, length, buffer.length - length, length);
|
|
104416
104653
|
if (count === 0)
|
|
104417
104654
|
break;
|
|
104418
104655
|
length += count;
|
|
104419
104656
|
}
|
|
104420
|
-
const bytes = buffer.subarray(0, length), after2 =
|
|
104657
|
+
const bytes = buffer.subarray(0, length), after2 = fstatSync18(fd);
|
|
104421
104658
|
unchangedDirectory(directory2, identity4);
|
|
104422
104659
|
if (bytes.length !== stat3.size || stat3.size !== after2.size || stat3.mtimeMs !== after2.mtimeMs || stat3.ctimeMs !== after2.ctimeMs)
|
|
104423
104660
|
return fail3();
|
|
104424
104661
|
return bytes;
|
|
104425
104662
|
} finally {
|
|
104426
|
-
|
|
104663
|
+
closeSync18(fd);
|
|
104427
104664
|
}
|
|
104428
104665
|
}
|
|
104429
104666
|
function writeOwned(directory2, name, bytes) {
|
|
104430
|
-
const fd =
|
|
104667
|
+
const fd = openSync18(join50(directory2, name), constants17.O_WRONLY | constants17.O_CREAT | constants17.O_EXCL | constants17.O_NOFOLLOW, 384);
|
|
104431
104668
|
try {
|
|
104432
104669
|
writeFileSync19(fd, bytes);
|
|
104433
104670
|
fsyncSync5(fd);
|
|
104434
104671
|
} finally {
|
|
104435
|
-
|
|
104672
|
+
closeSync18(fd);
|
|
104436
104673
|
}
|
|
104437
104674
|
}
|
|
104438
104675
|
function save(directory2, value) {
|
|
@@ -104441,11 +104678,11 @@ function save(directory2, value) {
|
|
|
104441
104678
|
`);
|
|
104442
104679
|
unchangedDirectory(directory2, identity4);
|
|
104443
104680
|
renameSync11(join50(directory2, temporary), join50(directory2, "receipt.json"));
|
|
104444
|
-
const fd =
|
|
104681
|
+
const fd = openSync18(directory2, constants17.O_RDONLY | constants17.O_NOFOLLOW);
|
|
104445
104682
|
try {
|
|
104446
104683
|
fsyncSync5(fd);
|
|
104447
104684
|
} finally {
|
|
104448
|
-
|
|
104685
|
+
closeSync18(fd);
|
|
104449
104686
|
}
|
|
104450
104687
|
}
|
|
104451
104688
|
function bind2(client2, receipt) {
|
|
@@ -104456,20 +104693,20 @@ async function locked(directory2, action) {
|
|
|
104456
104693
|
const identity4 = safeDirectory(directory2), file2 = join50(directory2, "operation.lock");
|
|
104457
104694
|
let fd;
|
|
104458
104695
|
try {
|
|
104459
|
-
fd =
|
|
104696
|
+
fd = openSync18(file2, constants17.O_WRONLY | constants17.O_CREAT | constants17.O_EXCL | constants17.O_NOFOLLOW, 384);
|
|
104460
104697
|
} catch {
|
|
104461
104698
|
throw new PrivatePublicationError("PUBLICATION_RECOVERY_BUSY", "Another operation holds this recovery directory. If it crashed, confirm that process has stopped before explicitly removing operation.lock and resuming.");
|
|
104462
104699
|
}
|
|
104463
|
-
const lock =
|
|
104700
|
+
const lock = fstatSync18(fd);
|
|
104464
104701
|
try {
|
|
104465
104702
|
writeFileSync19(fd, JSON.stringify({ pid: process.pid }) + `
|
|
104466
104703
|
`);
|
|
104467
104704
|
fsyncSync5(fd);
|
|
104468
104705
|
return await action();
|
|
104469
104706
|
} finally {
|
|
104470
|
-
|
|
104707
|
+
closeSync18(fd);
|
|
104471
104708
|
unchangedDirectory(directory2, identity4);
|
|
104472
|
-
const now3 =
|
|
104709
|
+
const now3 = lstatSync24(file2);
|
|
104473
104710
|
if (now3.dev !== lock.dev || now3.ino !== lock.ino || !now3.isFile() || now3.isSymbolicLink())
|
|
104474
104711
|
fail3();
|
|
104475
104712
|
unlinkSync7(file2);
|
|
@@ -104521,15 +104758,15 @@ async function preparePrivatePublication(client2, sourceDirectory, recoveryDirec
|
|
|
104521
104758
|
phase: "prepared",
|
|
104522
104759
|
intent: null
|
|
104523
104760
|
};
|
|
104524
|
-
if (!
|
|
104761
|
+
if (!isAbsolute19(recoveryDirectory) || resolve20(recoveryDirectory) !== recoveryDirectory || realpathSync9(dirname24(recoveryDirectory)) !== dirname24(recoveryDirectory))
|
|
104525
104762
|
return fail3();
|
|
104526
104763
|
mkdirSync21(recoveryDirectory, { mode: 448 });
|
|
104527
104764
|
safeDirectory(recoveryDirectory);
|
|
104528
|
-
const parent =
|
|
104765
|
+
const parent = openSync18(dirname24(recoveryDirectory), constants17.O_RDONLY | constants17.O_NOFOLLOW);
|
|
104529
104766
|
try {
|
|
104530
104767
|
fsyncSync5(parent);
|
|
104531
104768
|
} finally {
|
|
104532
|
-
|
|
104769
|
+
closeSync18(parent);
|
|
104533
104770
|
}
|
|
104534
104771
|
writeOwned(recoveryDirectory, "bundle.tgz", packed.bytes);
|
|
104535
104772
|
save(recoveryDirectory, receipt);
|
|
@@ -104622,10 +104859,10 @@ var init_private_publication_recovery = __esm(() => {
|
|
|
104622
104859
|
});
|
|
104623
104860
|
|
|
104624
104861
|
// src/mcp/private-publication-tools.ts
|
|
104625
|
-
import { isAbsolute as
|
|
104862
|
+
import { isAbsolute as isAbsolute20 } from "path";
|
|
104626
104863
|
function registerPrivatePublicationTools(server) {
|
|
104627
104864
|
const uuid9 = exports_external.string().regex(/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/);
|
|
104628
|
-
const directory2 = exports_external.string().max(4096).refine(
|
|
104865
|
+
const directory2 = exports_external.string().max(4096).refine(isAbsolute20, "Use an absolute local directory");
|
|
104629
104866
|
const verification2 = { email: exports_external.string().email().max(254), code: exports_external.string().regex(/^\d{6}$/), userId: uuid9, membershipId: uuid9, recoveryDirectory: directory2 };
|
|
104630
104867
|
const description = "Manage a private source publication using fresh workspace-bound verification and a host-local recovery directory. Publishing requires explicit UUID current-version comparison and upload consent. Resume reuses immutable saved bytes and intent; an uncertain PUT is finalized for server verification, never uploaded twice. Sessions and signed URLs are not returned or persisted. Private execution is unavailable. Host request history may contain the supplied verification code.";
|
|
104631
104868
|
const handler = (action) => async (value) => {
|
|
@@ -104985,7 +105222,7 @@ var init_mcp2 = __esm(() => {
|
|
|
104985
105222
|
// src/cli/commands/runtime-mcp.ts
|
|
104986
105223
|
import { existsSync as existsSync32, mkdirSync as mkdirSync22, readFileSync as readFileSync34, writeFileSync as writeFileSync20 } from "fs";
|
|
104987
105224
|
import { homedir as homedir9 } from "os";
|
|
104988
|
-
import { dirname as
|
|
105225
|
+
import { dirname as dirname25, join as join51 } from "path";
|
|
104989
105226
|
async function handleMcp(options) {
|
|
104990
105227
|
if (options.register) {
|
|
104991
105228
|
let agents;
|
|
@@ -105159,7 +105396,7 @@ function writeJsonObject(path, data) {
|
|
|
105159
105396
|
`);
|
|
105160
105397
|
}
|
|
105161
105398
|
function writeTextFile(path, content) {
|
|
105162
|
-
mkdirSync22(
|
|
105399
|
+
mkdirSync22(dirname25(path), { recursive: true });
|
|
105163
105400
|
writeFileSync20(path, content.endsWith(`
|
|
105164
105401
|
`) ? content : `${content}
|
|
105165
105402
|
`);
|
|
@@ -105269,9 +105506,9 @@ var exports_runtime = {};
|
|
|
105269
105506
|
__export(exports_runtime, {
|
|
105270
105507
|
registerRuntime: () => registerRuntime
|
|
105271
105508
|
});
|
|
105272
|
-
import { createHash as
|
|
105273
|
-
import { lstatSync as
|
|
105274
|
-
import { basename as
|
|
105509
|
+
import { createHash as createHash23, randomUUID as randomUUID9 } from "crypto";
|
|
105510
|
+
import { lstatSync as lstatSync25, mkdirSync as mkdirSync23, readFileSync as readFileSync35, realpathSync as realpathSync10, writeFileSync as writeFileSync21 } from "fs";
|
|
105511
|
+
import { basename as basename11, isAbsolute as isAbsolute21, join as join52 } from "path";
|
|
105275
105512
|
import { createInterface } from "readline";
|
|
105276
105513
|
function registerRuntime(parent) {
|
|
105277
105514
|
parent.command("run").argument("<skill>", "Skill name").argument("[args...]", "Arguments to pass to the skill; use -- to end Skills options").allowUnknownOption(true).passThroughOptions(true).option("--json", "Output result as JSON", false).option("--remote", "Run on the configured server, using its catalog and quote", false).option("--target <target>", "Execution target: local or cloud").option("--secret-bindings <path>", "Reviewed, exact-selection local execution vault bindings (JSON file)").option("--secret-bindings-template", "Print a scoped bindings template without resolving secrets or running the skill", false).option("--input <json>", "Structured cloud execution input").option("--skill-version <version>", "Exact selected skill version").option("--selection-profile <id>", "Selected Skills profile").option("--session <id>", "Pinned Skills session").option("--cached", "Use the explicit verified selected cache", false).option("--yes", "Approve the server's quoted credit cost for this run", false).option("--idempotency-key <key>", "Reuse this key when retrying the same remote submission").option("--file <path>", "Attach a local input file to a remote run (repeatable)", (value, prior) => [...prior, value], []).option("--wait", "Poll remote runs until a terminal status", false).option("--poll-interval-ms <ms>", "Remote polling interval in milliseconds", "1000").option("--poll-timeout-ms <ms>", "Maximum time to wait for a remote run", "300000").description("Run a skill directly").action(async (name, args2, options, command) => {
|
|
@@ -105301,7 +105538,7 @@ function registerRuntime(parent) {
|
|
|
105301
105538
|
if (!expected)
|
|
105302
105539
|
throw new Error("Cloud artifact not found");
|
|
105303
105540
|
const bytes = await client2.download(id2, name);
|
|
105304
|
-
if (bytes.length !== expected.byteSize ||
|
|
105541
|
+
if (bytes.length !== expected.byteSize || createHash23("sha256").update(bytes).digest("hex") !== expected.sha256)
|
|
105305
105542
|
throw new Error("Cloud artifact integrity verification failed");
|
|
105306
105543
|
writeFileSync21(options.output, bytes, { flag: "wx", mode: 384 });
|
|
105307
105544
|
console.log(JSON.stringify({ path: options.output, sha256: expected.sha256, byteSize: bytes.length }));
|
|
@@ -105389,7 +105626,7 @@ Updating ${name}...
|
|
|
105389
105626
|
async function readUpdatedVersion(bunExecutable) {
|
|
105390
105627
|
const output2 = await readUpdateCommand([bunExecutable, "pm", "bin", "-g"]);
|
|
105391
105628
|
const globalBin = output2.replace(/\r?\n$/, "");
|
|
105392
|
-
if (!globalBin || !
|
|
105629
|
+
if (!globalBin || !isAbsolute21(globalBin) || /[\r\n\0]/.test(globalBin))
|
|
105393
105630
|
throw new Error("Update bin discovery failed");
|
|
105394
105631
|
const installed = Bun.which("skills", { PATH: globalBin, cwd: globalBin });
|
|
105395
105632
|
const selected = Bun.which("skills");
|
|
@@ -105525,14 +105762,14 @@ function requireHttpUrl(value) {
|
|
|
105525
105762
|
}
|
|
105526
105763
|
function promptLine(question) {
|
|
105527
105764
|
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
105528
|
-
return new Promise((
|
|
105765
|
+
return new Promise((resolve21) => {
|
|
105529
105766
|
let settled = false;
|
|
105530
105767
|
const finish = (answer) => {
|
|
105531
105768
|
if (settled)
|
|
105532
105769
|
return;
|
|
105533
105770
|
settled = true;
|
|
105534
105771
|
rl.close();
|
|
105535
|
-
|
|
105772
|
+
resolve21(answer);
|
|
105536
105773
|
};
|
|
105537
105774
|
rl.once("SIGINT", () => finish(null));
|
|
105538
105775
|
rl.once("close", () => finish(null));
|
|
@@ -105709,10 +105946,10 @@ async function handleRun(name, args2, options, separatorBeforeSkill) {
|
|
|
105709
105946
|
try {
|
|
105710
105947
|
parsePollingOptions(options);
|
|
105711
105948
|
inputFiles = (options.file ?? []).map((path) => {
|
|
105712
|
-
const info =
|
|
105949
|
+
const info = lstatSync25(path);
|
|
105713
105950
|
if (!info.isFile() || info.size > 20 * 1024 * 1024)
|
|
105714
105951
|
throw new Error("Input must be a regular file no larger than 20 MiB");
|
|
105715
|
-
return { name:
|
|
105952
|
+
return { name: basename11(path), bytes: new Uint8Array(readFileSync35(path)) };
|
|
105716
105953
|
});
|
|
105717
105954
|
describeRemoteFiles(inputFiles);
|
|
105718
105955
|
client2 = new RemoteSkillsClient(routing.apiKey, routing.apiOrigin);
|
|
@@ -106139,7 +106376,7 @@ function ensureSafeExportParent(root2, relativePath) {
|
|
|
106139
106376
|
if (part)
|
|
106140
106377
|
parent = join52(parent, part);
|
|
106141
106378
|
try {
|
|
106142
|
-
if (!
|
|
106379
|
+
if (!lstatSync25(parent).isDirectory() || lstatSync25(parent).isSymbolicLink())
|
|
106143
106380
|
throw new Error("Unsafe artifact directory");
|
|
106144
106381
|
} catch (error61) {
|
|
106145
106382
|
if (error61.code !== "ENOENT")
|
|
@@ -106177,7 +106414,7 @@ async function pollRemoteRun(client2, runId2, options) {
|
|
|
106177
106414
|
const remaining = deadline - Date.now();
|
|
106178
106415
|
if (remaining <= 0)
|
|
106179
106416
|
break;
|
|
106180
|
-
await new Promise((
|
|
106417
|
+
await new Promise((resolve21) => setTimeout(resolve21, Math.min(options.intervalMs, remaining)));
|
|
106181
106418
|
}
|
|
106182
106419
|
return {
|
|
106183
106420
|
run: current ?? { id: runId2, status: "queued" },
|
|
@@ -106369,7 +106606,7 @@ async function readCode() {
|
|
|
106369
106606
|
function promptCode() {
|
|
106370
106607
|
const { stdin, stderr: output2 } = process;
|
|
106371
106608
|
const { isRaw: wasRaw, readableFlowing: wasFlowing } = stdin;
|
|
106372
|
-
return new Promise((
|
|
106609
|
+
return new Promise((resolve21) => {
|
|
106373
106610
|
let value = "", settled = false;
|
|
106374
106611
|
const finish = (answer) => {
|
|
106375
106612
|
if (settled)
|
|
@@ -106386,7 +106623,7 @@ function promptCode() {
|
|
|
106386
106623
|
`);
|
|
106387
106624
|
if (answer === null)
|
|
106388
106625
|
process.exitCode = 130;
|
|
106389
|
-
|
|
106626
|
+
resolve21(answer);
|
|
106390
106627
|
};
|
|
106391
106628
|
const cancel = () => finish(null);
|
|
106392
106629
|
const keypress = (text3, key) => {
|
|
@@ -106431,37 +106668,37 @@ var exports_recurring = {};
|
|
|
106431
106668
|
__export(exports_recurring, {
|
|
106432
106669
|
registerRecurringCommands: () => registerRecurringCommands
|
|
106433
106670
|
});
|
|
106434
|
-
import { constants as
|
|
106671
|
+
import { constants as constants18, closeSync as closeSync19, fstatSync as fstatSync19, lstatSync as lstatSync26, openSync as openSync19, readSync as readSync15 } from "fs";
|
|
106435
106672
|
import { createInterface as createInterface2 } from "readline";
|
|
106436
106673
|
function readRequest(path) {
|
|
106437
|
-
const fd =
|
|
106674
|
+
const fd = openSync19(path, constants18.O_RDONLY | constants18.O_NOFOLLOW | constants18.O_NONBLOCK);
|
|
106438
106675
|
try {
|
|
106439
|
-
const before2 =
|
|
106676
|
+
const before2 = fstatSync19(fd);
|
|
106440
106677
|
if (!before2.isFile() || before2.size > 1048576 || before2.size < 1)
|
|
106441
106678
|
throw new RecurringInputError;
|
|
106442
106679
|
const bytes = Buffer.alloc(before2.size + 1);
|
|
106443
106680
|
let length = 0;
|
|
106444
106681
|
while (length < bytes.length) {
|
|
106445
|
-
const n2 =
|
|
106682
|
+
const n2 = readSync15(fd, bytes, length, bytes.length - length, length);
|
|
106446
106683
|
if (!n2)
|
|
106447
106684
|
break;
|
|
106448
106685
|
length += n2;
|
|
106449
106686
|
}
|
|
106450
|
-
const after2 =
|
|
106687
|
+
const after2 = fstatSync19(fd), current = lstatSync26(path);
|
|
106451
106688
|
if (length !== before2.size || after2.size !== before2.size || before2.mtimeMs !== after2.mtimeMs || before2.ctimeMs !== after2.ctimeMs || current.dev !== before2.dev || current.ino !== before2.ino || !current.isFile() || current.isSymbolicLink())
|
|
106452
106689
|
throw new RecurringInputError;
|
|
106453
106690
|
return JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(bytes.subarray(0, length)));
|
|
106454
106691
|
} catch {
|
|
106455
106692
|
throw new RecurringInputError;
|
|
106456
106693
|
} finally {
|
|
106457
|
-
|
|
106694
|
+
closeSync19(fd);
|
|
106458
106695
|
}
|
|
106459
106696
|
}
|
|
106460
106697
|
async function acceptAtTerminal(draft) {
|
|
106461
|
-
await new Promise((
|
|
106698
|
+
await new Promise((resolve21, reject2) => process.stderr.write(`${jsonText(draft)}
|
|
106462
106699
|
This grants an additional recurring budget. Each occurrence reprices within the approved ceilings. Revocation prevents new authority; an already-authorized attempt may finish, and cancellation is separate.
|
|
106463
|
-
`, (error61) => error61 ? reject2(error61) :
|
|
106464
|
-
return new Promise((
|
|
106700
|
+
`, (error61) => error61 ? reject2(error61) : resolve21()));
|
|
106701
|
+
return new Promise((resolve21) => {
|
|
106465
106702
|
const rl = createInterface2({ input: process.stdin, output: process.stderr });
|
|
106466
106703
|
let settled = false;
|
|
106467
106704
|
const finish = (accepted) => {
|
|
@@ -106472,7 +106709,7 @@ This grants an additional recurring budget. Each occurrence reprices within the
|
|
|
106472
106709
|
rl.close();
|
|
106473
106710
|
if (!accepted)
|
|
106474
106711
|
process.exitCode = 130;
|
|
106475
|
-
|
|
106712
|
+
resolve21(accepted);
|
|
106476
106713
|
};
|
|
106477
106714
|
const timer = setTimeout(() => finish(false), 5 * 60 * 1000);
|
|
106478
106715
|
rl.once("SIGINT", () => finish(false));
|
|
@@ -106880,7 +107117,7 @@ var init_portable_snapshot_filter = __esm(() => {
|
|
|
106880
107117
|
});
|
|
106881
107118
|
|
|
106882
107119
|
// src/lib/station-snapshot.ts
|
|
106883
|
-
import { createHash as
|
|
107120
|
+
import { createHash as createHash24 } from "crypto";
|
|
106884
107121
|
import {
|
|
106885
107122
|
copyFileSync,
|
|
106886
107123
|
mkdirSync as mkdirSync24,
|
|
@@ -106888,14 +107125,14 @@ import {
|
|
|
106888
107125
|
statSync as statSync19,
|
|
106889
107126
|
writeFileSync as writeFileSync22
|
|
106890
107127
|
} from "fs";
|
|
106891
|
-
import { dirname as
|
|
107128
|
+
import { dirname as dirname27, isAbsolute as isAbsolute22, relative as relative8, resolve as resolve21, sep as sep9 } from "path";
|
|
106892
107129
|
function validateStationId(stationId) {
|
|
106893
107130
|
if (!/^[a-z0-9-]+$/.test(stationId)) {
|
|
106894
107131
|
throw new StationSnapshotError("INVALID_STATION", `station id must be a slug, got: ${stationId}`);
|
|
106895
107132
|
}
|
|
106896
107133
|
}
|
|
106897
107134
|
function sha256File(filePath) {
|
|
106898
|
-
return
|
|
107135
|
+
return createHash24("sha256").update(readFileSync36(filePath)).digest("hex");
|
|
106899
107136
|
}
|
|
106900
107137
|
function scanHome(definition, homesRoot) {
|
|
106901
107138
|
const homePath = homePathFor(definition, homesRoot);
|
|
@@ -106966,7 +107203,7 @@ function humanHomes(scanned) {
|
|
|
106966
107203
|
}));
|
|
106967
107204
|
}
|
|
106968
107205
|
function writeStationSnapshot(options) {
|
|
106969
|
-
const repoRoot =
|
|
107206
|
+
const repoRoot = resolve21(options.repoRoot ?? process.cwd());
|
|
106970
107207
|
const { scanned, plans, totalBytes } = planStationSnapshot(options);
|
|
106971
107208
|
const manifestFiles = plans.map((plan) => ({
|
|
106972
107209
|
relativePath: plan.source.relativePath,
|
|
@@ -106992,9 +107229,9 @@ function writeStationSnapshot(options) {
|
|
|
106992
107229
|
const conflicts = [];
|
|
106993
107230
|
const untouched = [];
|
|
106994
107231
|
for (const plan of plans) {
|
|
106995
|
-
const destination =
|
|
107232
|
+
const destination = resolve21(repoRoot, plan.destination);
|
|
106996
107233
|
const destinationRelative = relative8(repoRoot, destination);
|
|
106997
|
-
if (destinationRelative.startsWith("..") || destinationRelative.startsWith(sep9) ||
|
|
107234
|
+
if (destinationRelative.startsWith("..") || destinationRelative.startsWith(sep9) || isAbsolute22(destinationRelative)) {
|
|
106998
107235
|
throw new StationSnapshotError("DESTINATION_ESCAPE", `destination escapes repo root: ${plan.destination}`);
|
|
106999
107236
|
}
|
|
107000
107237
|
let existingDigest = null;
|
|
@@ -107015,8 +107252,8 @@ function writeStationSnapshot(options) {
|
|
|
107015
107252
|
}
|
|
107016
107253
|
let written = 0;
|
|
107017
107254
|
for (const plan of untouched) {
|
|
107018
|
-
const destination =
|
|
107019
|
-
mkdirSync24(
|
|
107255
|
+
const destination = resolve21(repoRoot, plan.destination);
|
|
107256
|
+
mkdirSync24(dirname27(destination), { recursive: true });
|
|
107020
107257
|
copyFileSync(plan.source.fullPath, destination);
|
|
107021
107258
|
written += 1;
|
|
107022
107259
|
}
|
|
@@ -107034,8 +107271,8 @@ function writeStationSnapshot(options) {
|
|
|
107034
107271
|
},
|
|
107035
107272
|
files: manifestFiles
|
|
107036
107273
|
};
|
|
107037
|
-
const manifestPath =
|
|
107038
|
-
mkdirSync24(
|
|
107274
|
+
const manifestPath = resolve21(repoRoot, "resources", options.stationId, "skills", "sync-manifest.json");
|
|
107275
|
+
mkdirSync24(dirname27(manifestPath), { recursive: true });
|
|
107039
107276
|
writeFileSync22(manifestPath, `${JSON.stringify(manifest, null, 2)}
|
|
107040
107277
|
`);
|
|
107041
107278
|
return {
|
|
@@ -107469,10 +107706,10 @@ var init_create_sync_config = __esm(() => {
|
|
|
107469
107706
|
// src/lib/codex-hook-rpc.ts
|
|
107470
107707
|
import { execFile, spawn as spawn3 } from "child_process";
|
|
107471
107708
|
import { realpathSync as realpathSync11, statSync as statSync20 } from "fs";
|
|
107472
|
-
import { isAbsolute as
|
|
107709
|
+
import { isAbsolute as isAbsolute23 } from "path";
|
|
107473
107710
|
import { promisify } from "util";
|
|
107474
107711
|
async function connectCodexHookRpc(options) {
|
|
107475
|
-
const found =
|
|
107712
|
+
const found = isAbsolute23(options.command) ? options.command : Bun.which(options.command, { PATH: process.env.PATH });
|
|
107476
107713
|
if (!found)
|
|
107477
107714
|
throw new Error("CODEX_HOOK_TRUST_NATIVE_UNAVAILABLE: install Codex or pass --codex-command");
|
|
107478
107715
|
const binary = realpathSync11(found), stat3 = statSync20(binary);
|
|
@@ -107558,13 +107795,13 @@ async function connectCodexHookRpc(options) {
|
|
|
107558
107795
|
request(method2, params) {
|
|
107559
107796
|
if (stopped)
|
|
107560
107797
|
return Promise.reject(new Error("CODEX_HOOK_TRUST_NATIVE_RPC_CLOSED"));
|
|
107561
|
-
return new Promise((
|
|
107798
|
+
return new Promise((resolve22, reject2) => {
|
|
107562
107799
|
const id2 = nextId++;
|
|
107563
107800
|
const timer = setTimeout(() => {
|
|
107564
107801
|
fail4();
|
|
107565
107802
|
child.kill();
|
|
107566
107803
|
}, 20000);
|
|
107567
|
-
pending.set(id2, { resolve:
|
|
107804
|
+
pending.set(id2, { resolve: resolve22, reject: reject2, timer });
|
|
107568
107805
|
child.stdin.write(JSON.stringify({ id: id2, method: method2, params }) + `
|
|
107569
107806
|
`);
|
|
107570
107807
|
});
|
|
@@ -107574,14 +107811,14 @@ async function connectCodexHookRpc(options) {
|
|
|
107574
107811
|
child.stdin.end();
|
|
107575
107812
|
if (child.exitCode !== null || child.signalCode !== null)
|
|
107576
107813
|
return;
|
|
107577
|
-
await new Promise((
|
|
107814
|
+
await new Promise((resolve22) => {
|
|
107578
107815
|
const timer = setTimeout(() => {
|
|
107579
107816
|
child.kill();
|
|
107580
|
-
|
|
107817
|
+
resolve22();
|
|
107581
107818
|
}, 1000);
|
|
107582
107819
|
child.once("exit", () => {
|
|
107583
107820
|
clearTimeout(timer);
|
|
107584
|
-
|
|
107821
|
+
resolve22();
|
|
107585
107822
|
});
|
|
107586
107823
|
});
|
|
107587
107824
|
}
|
|
@@ -107688,59 +107925,59 @@ var fail4 = () => new Error('CODEX_HOOK_TRUST_UNSUPPORTED_LAYOUT: preserve and c
|
|
|
107688
107925
|
var init_codex_hook_trust_layout = () => {};
|
|
107689
107926
|
|
|
107690
107927
|
// src/lib/codex-hook-trust-files.ts
|
|
107691
|
-
import { closeSync as
|
|
107692
|
-
import { createHash as
|
|
107693
|
-
import { dirname as
|
|
107694
|
-
function
|
|
107928
|
+
import { closeSync as closeSync20, constants as constants19, fstatSync as fstatSync20, fsyncSync as fsyncSync6, lstatSync as lstatSync27, openSync as openSync20, readSync as readSync16, writeFileSync as writeFileSync23 } from "fs";
|
|
107929
|
+
import { createHash as createHash25 } from "crypto";
|
|
107930
|
+
import { dirname as dirname28 } from "path";
|
|
107931
|
+
function need4(value, code2) {
|
|
107695
107932
|
if (!value)
|
|
107696
107933
|
throw new Error(`CODEX_HOOK_TRUST_${code2}`);
|
|
107697
107934
|
}
|
|
107698
107935
|
function safeParents(file2) {
|
|
107699
|
-
for (let p =
|
|
107700
|
-
const s =
|
|
107701
|
-
|
|
107702
|
-
|
|
107703
|
-
if (
|
|
107936
|
+
for (let p = dirname28(file2);; p = dirname28(p)) {
|
|
107937
|
+
const s = lstatSync27(p);
|
|
107938
|
+
need4(s.isDirectory() && !s.isSymbolicLink(), "UNSAFE_PARENT");
|
|
107939
|
+
need4((s.mode & 18) === 0 || s.uid === 0 && (s.mode & 512) !== 0, "UNSAFE_PARENT");
|
|
107940
|
+
if (dirname28(p) === p)
|
|
107704
107941
|
break;
|
|
107705
107942
|
}
|
|
107706
107943
|
}
|
|
107707
107944
|
function snapshot(file2, privateFile = false, options = {}) {
|
|
107708
107945
|
const readOnlyPackage = options.readOnlyPackage === true && !privateFile;
|
|
107709
107946
|
safeParents(file2);
|
|
107710
|
-
const initial2 =
|
|
107711
|
-
|
|
107712
|
-
|
|
107713
|
-
const fd =
|
|
107947
|
+
const initial2 = lstatSync27(file2, { bigint: true });
|
|
107948
|
+
need4(initial2.isFile() && initial2.uid === BigInt(process.getuid()) && (initial2.nlink === 1n || readOnlyPackage && initial2.nlink > 1n) && (initial2.mode & 0o022n) === 0n && (!privateFile || (initial2.mode & 0o777n) === 0o600n), "UNSAFE_FILE");
|
|
107949
|
+
need4(initial2.size <= 8n * 1024n * 1024n, "FILE_BOUND");
|
|
107950
|
+
const fd = openSync20(file2, constants19.O_RDONLY | constants19.O_NOFOLLOW | constants19.O_NONBLOCK);
|
|
107714
107951
|
try {
|
|
107715
|
-
const before2 =
|
|
107716
|
-
|
|
107952
|
+
const before2 = fstatSync20(fd, { bigint: true });
|
|
107953
|
+
need4(sameStat(initial2, before2), "INPUT_CHANGED");
|
|
107717
107954
|
const bytes = Buffer.alloc(Number(before2.size) + 1);
|
|
107718
107955
|
let length = 0;
|
|
107719
107956
|
while (length < bytes.length) {
|
|
107720
|
-
const n2 =
|
|
107957
|
+
const n2 = readSync16(fd, bytes, length, bytes.length - length, null);
|
|
107721
107958
|
if (!n2)
|
|
107722
107959
|
break;
|
|
107723
107960
|
length += n2;
|
|
107724
107961
|
}
|
|
107725
|
-
|
|
107962
|
+
need4(length === Number(before2.size) && sameStat(before2, fstatSync20(fd, { bigint: true })) && sameStat(before2, lstatSync27(file2, { bigint: true })), "INPUT_CHANGED");
|
|
107726
107963
|
const content = bytes.subarray(0, length), text3 = new TextDecoder("utf-8", { fatal: true }).decode(content);
|
|
107727
|
-
return { file: file2, privateFile, readOnlyPackage, text: text3, bytes: content, stat: before2, sha256:
|
|
107964
|
+
return { file: file2, privateFile, readOnlyPackage, text: text3, bytes: content, stat: before2, sha256: createHash25("sha256").update(content).digest("hex") };
|
|
107728
107965
|
} finally {
|
|
107729
|
-
|
|
107966
|
+
closeSync20(fd);
|
|
107730
107967
|
}
|
|
107731
107968
|
}
|
|
107732
107969
|
function unchanged2(before2) {
|
|
107733
107970
|
const after2 = snapshot(before2.file, before2.privateFile, before2.readOnlyPackage ? { readOnlyPackage: true } : {});
|
|
107734
|
-
|
|
107971
|
+
need4(sameStat(before2.stat, after2.stat) && after2.sha256 === before2.sha256, "INPUT_CHANGED");
|
|
107735
107972
|
}
|
|
107736
107973
|
function save2(file2, content) {
|
|
107737
107974
|
safeParents(file2);
|
|
107738
|
-
const fd =
|
|
107975
|
+
const fd = openSync20(file2, constants19.O_WRONLY | constants19.O_CREAT | constants19.O_EXCL | constants19.O_NOFOLLOW, 384);
|
|
107739
107976
|
try {
|
|
107740
107977
|
writeFileSync23(fd, content);
|
|
107741
107978
|
fsyncSync6(fd);
|
|
107742
107979
|
} finally {
|
|
107743
|
-
|
|
107980
|
+
closeSync20(fd);
|
|
107744
107981
|
}
|
|
107745
107982
|
}
|
|
107746
107983
|
var sameStat = (a, b) => ["dev", "ino", "uid", "nlink", "mode", "size", "mtimeNs", "ctimeNs"].every((key) => a[key] === b[key]);
|
|
@@ -107748,26 +107985,26 @@ var init_codex_hook_trust_files = () => {};
|
|
|
107748
107985
|
|
|
107749
107986
|
// src/lib/codex-hook-trust-identity.ts
|
|
107750
107987
|
import { realpathSync as realpathSync12 } from "fs";
|
|
107751
|
-
import { dirname as
|
|
107988
|
+
import { dirname as dirname29, isAbsolute as isAbsolute24, join as join55 } from "path";
|
|
107752
107989
|
function bindSkillsCli(command, reviewed) {
|
|
107753
107990
|
const normal = Bun.which("skills", { PATH: process.env.PATH });
|
|
107754
|
-
|
|
107991
|
+
need4(normal, "SKILLS_COMMAND_UNAVAILABLE");
|
|
107755
107992
|
const resolved = realpathSync12(normal);
|
|
107756
|
-
const bound =
|
|
107757
|
-
|
|
107993
|
+
const bound = isAbsolute24(command) ? command : command === "skills" ? normal : undefined;
|
|
107994
|
+
need4(bound && realpathSync12(bound) === resolved, "SKILLS_COMMAND_MISMATCH");
|
|
107758
107995
|
const entrypoint = reviewed?.path ?? process.argv[1];
|
|
107759
|
-
|
|
107996
|
+
need4(entrypoint && realpathSync12(entrypoint) === resolved, "SKILLS_ENTRYPOINT_MISMATCH");
|
|
107760
107997
|
const cli = snapshot(resolved, false, { readOnlyPackage: true });
|
|
107761
|
-
const manifest = snapshot(join55(
|
|
107998
|
+
const manifest = snapshot(join55(dirname29(dirname29(resolved)), "package.json"), false, { readOnlyPackage: true });
|
|
107762
107999
|
const pkg = JSON.parse(manifest.text);
|
|
107763
|
-
|
|
108000
|
+
need4(pkg.name === "@hasna/skills" && /^\d+\.\d+\.\d+$/.test(pkg.version) && pkg.bin?.skills === "bin/index.js" && resolved === join55(dirname29(manifest.file), "bin/index.js"), "SKILLS_PACKAGE_MISMATCH");
|
|
107764
108001
|
if (reviewed)
|
|
107765
|
-
|
|
107766
|
-
|
|
108002
|
+
need4(/^[a-f0-9]{64}$/.test(reviewed.sha256) && reviewed.sha256 === cli.sha256 && reviewed.version === pkg.version, "SKILLS_RELEASE_MISMATCH");
|
|
108003
|
+
need4((cli.stat.mode & 0o100n) !== 0n, "SKILLS_COMMAND_NOT_EXECUTABLE");
|
|
107767
108004
|
return {
|
|
107768
108005
|
receipt: { path: resolved, version: pkg.version, sha256: cli.sha256, manifestSha256: manifest.sha256 },
|
|
107769
108006
|
recheck() {
|
|
107770
|
-
|
|
108007
|
+
need4(Bun.which("skills", { PATH: process.env.PATH }) === normal && realpathSync12(normal) === resolved && realpathSync12(bound) === resolved && realpathSync12(entrypoint) === resolved, "SKILLS_COMMAND_CHANGED");
|
|
107771
108008
|
unchanged2(cli);
|
|
107772
108009
|
unchanged2(manifest);
|
|
107773
108010
|
}
|
|
@@ -107778,15 +108015,15 @@ var init_codex_hook_trust_identity = __esm(() => {
|
|
|
107778
108015
|
});
|
|
107779
108016
|
|
|
107780
108017
|
// src/lib/agent-codex-trust.ts
|
|
107781
|
-
import { lstatSync as
|
|
107782
|
-
import { createHash as
|
|
107783
|
-
import { join as join56, resolve as
|
|
108018
|
+
import { lstatSync as lstatSync28, mkdirSync as mkdirSync25, readdirSync as readdirSync20 } from "fs";
|
|
108019
|
+
import { createHash as createHash26, randomUUID as randomUUID10 } from "crypto";
|
|
108020
|
+
import { join as join56, resolve as resolve22 } from "path";
|
|
107784
108021
|
import { homedir as homedir11 } from "os";
|
|
107785
108022
|
import { isDeepStrictEqual as isDeepStrictEqual6 } from "util";
|
|
107786
108023
|
async function enrollCodexNativeHooks(options = {}, connect = connectCodexHookRpc) {
|
|
107787
108024
|
let rpc, journal;
|
|
107788
108025
|
try {
|
|
107789
|
-
const home =
|
|
108026
|
+
const home = resolve22(options.home ?? homedir11()), dataDir3 = resolve22(options.dataDir ?? getDataDirReadOnly());
|
|
107790
108027
|
assertManagedAgentBridge("codex", { home, dataDir: dataDir3, projectDir: home });
|
|
107791
108028
|
const policyFile = snapshot(join56(dataDir3, "agent-policy.json"), true), policy = parseManagedSkillPolicy(policyFile.text);
|
|
107792
108029
|
const binding = policy.bridge, alias = binding.rootAliases?.find((item) => item.agent === "codex");
|
|
@@ -107797,35 +108034,35 @@ async function enrollCodexNativeHooks(options = {}, connect = connectCodexHookRp
|
|
|
107797
108034
|
for (const [event, [nativeEvent, label]] of Object.entries(eventNames)) {
|
|
107798
108035
|
const command = renderAgentHookCommand(binding.commands.codex, "codex", binding.profiles.codex, event);
|
|
107799
108036
|
const groups = declarations[event];
|
|
107800
|
-
|
|
108037
|
+
need4(Array.isArray(groups), "DECLARATION_CHANGED");
|
|
107801
108038
|
const matches2 = groups.flatMap((group, gi) => (group.hooks ?? []).flatMap((entry, hi) => entry.command === command ? [{ group, entry, gi, hi }] : []));
|
|
107802
|
-
|
|
108039
|
+
need4(matches2.length === 1 && isDeepStrictEqual6(matches2[0].group, { hooks: [{ type: "command", command, timeout: 15 }] }), "DECLARATION_CHANGED");
|
|
107803
108040
|
expected.push({ event: nativeEvent, key: `${join56(home, ".codex/hooks.json")}:${label}:${matches2[0].gi}:${matches2[0].hi}`, command });
|
|
107804
108041
|
}
|
|
107805
108042
|
codexTrustTextWitness(configFile.text, expected.map((h) => h.key));
|
|
107806
108043
|
rpc = await connect({ command: options.codexCommand ?? "codex", home, codexHome });
|
|
107807
|
-
|
|
108044
|
+
need4(SUPPORTED_CODEX_HOOK_VERSIONS.includes(rpc.version), "NATIVE_UNSUPPORTED_VERSION");
|
|
107808
108045
|
const list2 = async () => {
|
|
107809
108046
|
const response = await rpc.request("hooks/list", { cwds: [home] });
|
|
107810
|
-
|
|
108047
|
+
need4(Array.isArray(response?.data) && response.data.length === 1 && response.data[0].cwd === home && Array.isArray(response.data[0].hooks) && response.data[0].hooks.length <= 1e4 && !response.data[0].errors?.length && !response.data[0].warnings?.length, "NATIVE_DISCOVERY_REFUSED");
|
|
107811
108048
|
return response.data[0].hooks;
|
|
107812
108049
|
};
|
|
107813
108050
|
const admit = (hooks) => expected.map((wanted) => {
|
|
107814
108051
|
const canonicalKey = wanted.key.replace(join56(home, ".codex/hooks.json"), hooksPath);
|
|
107815
108052
|
const matches2 = hooks.filter((h2) => h2.key === wanted.key || h2.key === canonicalKey);
|
|
107816
|
-
|
|
108053
|
+
need4(matches2.length === 1, "AMBIGUOUS_IDENTITY");
|
|
107817
108054
|
const h = matches2[0];
|
|
107818
|
-
|
|
107819
|
-
|
|
107820
|
-
|
|
108055
|
+
need4(h.eventName === wanted.event && h.handlerType === "command" && h.command === wanted.command && h.matcher === null && h.timeoutSec === 15 && h.async === false && h.statusMessage === null && h.additionalContextLimit === null && [hooksPath, join56(home, ".codex/hooks.json")].includes(h.sourcePath) && h.source === "user" && h.pluginId === null && h.isManaged === false && /^sha256:[a-f0-9]{64}$/.test(h.currentHash) && typeof h.enabled === "boolean", "NATIVE_IDENTITY_CHANGED");
|
|
108056
|
+
need4(hooks.filter((other) => other.command === wanted.command).length === 1, "AMBIGUOUS_IDENTITY");
|
|
108057
|
+
need4(["trusted", "untrusted", "modified"].includes(h.trustStatus), "UNKNOWN_TRUST_STATUS");
|
|
107821
108058
|
return { key: h.key, event: wanted.event, command: wanted.command, handlerType: h.handlerType, timeoutSec: h.timeoutSec, sourcePath: h.sourcePath, currentHash: h.currentHash, enabled: h.enabled, trustStatus: h.trustStatus };
|
|
107822
108059
|
});
|
|
107823
108060
|
const discovered = await list2(), admitted = admit(discovered);
|
|
107824
108061
|
const config2 = await rpc.request("config/read", { includeLayers: true, cwd: home });
|
|
107825
108062
|
const layers = config2?.layers?.filter((layer) => layer.name?.type === "user" && layer.name.file === configPath && !layer.name.profile);
|
|
107826
|
-
|
|
107827
|
-
|
|
107828
|
-
|
|
108063
|
+
need4(layers?.length === 1 && /^sha256:[a-f0-9]{64}$/.test(layers[0].version) && !layers[0].disabledReason && isDeepStrictEqual6(layers[0].config, original), "NATIVE_CONFIG_MISMATCH");
|
|
108064
|
+
need4(config2.config && config2.config.features?.hooks !== false, "NATIVE_HOOKS_DISABLED");
|
|
108065
|
+
need4(config2.layers.slice(0, config2.layers.indexOf(layers[0])).every((layer) => layer.config?.hooks === undefined && layer.config?.features?.hooks === undefined), "NATIVE_CONFIG_OVERRIDDEN");
|
|
107829
108066
|
const keys3 = admitted.map((h) => h.key), planned = admitted.filter((h) => !h.enabled || h.trustStatus !== "trusted");
|
|
107830
108067
|
const preservationText = codexTrustTextWitness(configFile.text, keys3);
|
|
107831
108068
|
const checkInputs = () => {
|
|
@@ -107836,19 +108073,19 @@ async function enrollCodexNativeHooks(options = {}, connect = connectCodexHookRp
|
|
|
107836
108073
|
unchanged2(configFile);
|
|
107837
108074
|
};
|
|
107838
108075
|
checkInputs();
|
|
107839
|
-
const planDigest =
|
|
108076
|
+
const planDigest = createHash26("sha256").update(json2({ version: 1, home, configPath, configSha256: configFile.sha256, configVersion: layers[0].version, policySha256: policyFile.sha256, hooksSha256: hooksFile.sha256, skillsCli: skillsCli.receipt, nativeVersion: rpc.version, declarations: expected, admitted })).digest("hex");
|
|
107840
108077
|
const baseReceipt = { planDigest, skillsCli: skillsCli.receipt, nativeVersion: rpc.version, ownedNativeProcessId: rpc.processId, agent: "codex", applied: false, planned, nativeEligible: planned.length === 0, transport: "owned-stdio-process", existingSessionsReloaded: false, nativeExecutionVerified: false };
|
|
107841
108078
|
if (options.apply)
|
|
107842
|
-
|
|
108079
|
+
need4(options.reviewedPlanDigest === planDigest, "PLAN_CHANGED: run the dry-run again and pass its reviewed --plan-digest with --apply");
|
|
107843
108080
|
const parent = join56(dataDir3, "native-hook-trust");
|
|
107844
|
-
const st =
|
|
108081
|
+
const st = lstatSync28(parent, { throwIfNoEntry: false });
|
|
107845
108082
|
if (st) {
|
|
107846
|
-
|
|
108083
|
+
need4(st.isDirectory() && !st.isSymbolicLink() && st.uid === process.getuid() && (st.mode & 511) === 448, "UNSAFE_JOURNAL");
|
|
107847
108084
|
const priorJournals = readdirSync20(parent);
|
|
107848
|
-
|
|
108085
|
+
need4(priorJournals.length < 1000, "JOURNAL_BOUND");
|
|
107849
108086
|
for (const name of priorJournals) {
|
|
107850
|
-
|
|
107851
|
-
|
|
108087
|
+
need4(/^[a-f0-9-]{36}$/.test(name), "UNSAFE_JOURNAL");
|
|
108088
|
+
need4(lstatSync28(join56(parent, name, "receipt.json"), { throwIfNoEntry: false })?.isFile(), "RECONCILE_REQUIRED: inspect the incomplete private journal before applying again");
|
|
107852
108089
|
}
|
|
107853
108090
|
}
|
|
107854
108091
|
if (!options.apply || !planned.length)
|
|
@@ -107861,7 +108098,7 @@ async function enrollCodexNativeHooks(options = {}, connect = connectCodexHookRp
|
|
|
107861
108098
|
save2(join56(journal, "hooks.before.json"), hooksFile.bytes);
|
|
107862
108099
|
save2(join56(journal, "policy.before.json"), policyFile.bytes);
|
|
107863
108100
|
save2(join56(journal, "intent.json"), json2({ version: 1, planDigest, skillsCli: skillsCli.receipt, nativeVersion: rpc.version, configPath, beforeSha256: configFile.sha256, hooksSha256: hooksFile.sha256, policySha256: policyFile.sha256, expectedVersion: layers[0].version, hooks: planned }));
|
|
107864
|
-
|
|
108101
|
+
need4(isDeepStrictEqual6(admit(await list2()), admitted), "NATIVE_DISCOVERY_CHANGED");
|
|
107865
108102
|
checkInputs();
|
|
107866
108103
|
let result2;
|
|
107867
108104
|
try {
|
|
@@ -107869,19 +108106,19 @@ async function enrollCodexNativeHooks(options = {}, connect = connectCodexHookRp
|
|
|
107869
108106
|
} catch {
|
|
107870
108107
|
throw new Error("CODEX_HOOK_TRUST_NATIVE_WRITE_FAILED: reconcile the private journal before retrying");
|
|
107871
108108
|
}
|
|
107872
|
-
|
|
108109
|
+
need4(result2?.status === "ok" && result2.filePath === configPath && /^sha256:[a-f0-9]{64}$/.test(result2.version), "NATIVE_WRITE_OVERRIDDEN");
|
|
107873
108110
|
const after2 = snapshot(configPath, true), expectedConfig = structuredClone(original);
|
|
107874
108111
|
expectedConfig.hooks ??= {};
|
|
107875
108112
|
expectedConfig.hooks.state ??= {};
|
|
107876
108113
|
for (const h of planned)
|
|
107877
108114
|
expectedConfig.hooks.state[h.key] = { ...expectedConfig.hooks.state[h.key], enabled: true, trusted_hash: h.currentHash };
|
|
107878
|
-
|
|
108115
|
+
need4(isDeepStrictEqual6(structure(after2.text), expectedConfig) && codexTrustTextWitness(after2.text, keys3) === preservationText, "PRESERVATION_FAILED");
|
|
107879
108116
|
unchanged2(policyFile);
|
|
107880
108117
|
unchanged2(hooksFile);
|
|
107881
108118
|
assertManagedAgentBridge("codex", { home, dataDir: dataDir3, projectDir: home });
|
|
107882
108119
|
const current = await list2(), confirmed = admit(current);
|
|
107883
|
-
|
|
107884
|
-
|
|
108120
|
+
need4(confirmed.every((h) => h.enabled && h.trustStatus === "trusted") && isDeepStrictEqual6(confirmed.map((h) => [h.key, h.currentHash]), admitted.map((h) => [h.key, h.currentHash])), "NATIVE_NOT_ELIGIBLE");
|
|
108121
|
+
need4(isDeepStrictEqual6(current.filter((h) => !keys3.includes(h.key)), discovered.filter((h) => !keys3.includes(h.key))), "UNRELATED_HOOK_CHANGED");
|
|
107885
108122
|
unchanged2(after2);
|
|
107886
108123
|
unchanged2(hooksFile);
|
|
107887
108124
|
unchanged2(policyFile);
|
|
@@ -107996,7 +108233,7 @@ __export(exports_agent_integration, {
|
|
|
107996
108233
|
registerAgentIntegration: () => registerAgentIntegration
|
|
107997
108234
|
});
|
|
107998
108235
|
import { readFileSync as readFileSync37 } from "fs";
|
|
107999
|
-
import { isAbsolute as
|
|
108236
|
+
import { isAbsolute as isAbsolute25 } from "path";
|
|
108000
108237
|
function pinnedHookProfile(input3, configuredProfile) {
|
|
108001
108238
|
try {
|
|
108002
108239
|
const parsed = parseSkillContextInput(JSON.stringify(input3));
|
|
@@ -108114,12 +108351,12 @@ function registerAgentIntegration(parent) {
|
|
|
108114
108351
|
input3.hook_event_name = event;
|
|
108115
108352
|
const projects = [process.cwd()];
|
|
108116
108353
|
if (input3.cwd !== undefined) {
|
|
108117
|
-
if (typeof input3.cwd !== "string" || !
|
|
108354
|
+
if (typeof input3.cwd !== "string" || !isAbsolute25(input3.cwd) || input3.cwd.includes("\x00"))
|
|
108118
108355
|
throw new Error("Invalid native hook working directory");
|
|
108119
108356
|
projects.push(input3.cwd);
|
|
108120
108357
|
}
|
|
108121
108358
|
if (options.agent === "cursor") {
|
|
108122
|
-
if (!Array.isArray(input3.workspace_roots) || input3.workspace_roots.length > 32 || input3.workspace_roots.some((path) => typeof path !== "string" || !
|
|
108359
|
+
if (!Array.isArray(input3.workspace_roots) || input3.workspace_roots.length > 32 || input3.workspace_roots.some((path) => typeof path !== "string" || !isAbsolute25(path) || path.includes("\x00")))
|
|
108123
108360
|
throw new Error("Invalid Cursor workspace roots");
|
|
108124
108361
|
projects.push(...input3.workspace_roots);
|
|
108125
108362
|
input3.cwd ??= input3.workspace_roots[0] ?? process.cwd();
|
|
@@ -108357,17 +108594,17 @@ var exports_profiles = {};
|
|
|
108357
108594
|
__export(exports_profiles, {
|
|
108358
108595
|
registerProfiles: () => registerProfiles
|
|
108359
108596
|
});
|
|
108360
|
-
import { closeSync as
|
|
108597
|
+
import { closeSync as closeSync21, constants as constants20, fstatSync as fstatSync21, openSync as openSync21, readSync as readSync17, writeFileSync as writeFileSync24 } from "fs";
|
|
108361
108598
|
function readProfileInput(path) {
|
|
108362
|
-
const fd =
|
|
108599
|
+
const fd = openSync21(path, constants20.O_RDONLY | constants20.O_NONBLOCK);
|
|
108363
108600
|
try {
|
|
108364
|
-
const stat3 =
|
|
108601
|
+
const stat3 = fstatSync21(fd);
|
|
108365
108602
|
if (!stat3.isFile() || stat3.size > MAX_PROFILE_DOCUMENT_BYTES)
|
|
108366
108603
|
throw new Error("Profile input exceeds the size limit or is not a regular file");
|
|
108367
108604
|
const bytes = Buffer.alloc(MAX_PROFILE_DOCUMENT_BYTES + 1);
|
|
108368
108605
|
let size2 = 0;
|
|
108369
108606
|
while (size2 < bytes.length) {
|
|
108370
|
-
const read3 =
|
|
108607
|
+
const read3 = readSync17(fd, bytes, size2, bytes.length - size2, null);
|
|
108371
108608
|
if (!read3)
|
|
108372
108609
|
break;
|
|
108373
108610
|
size2 += read3;
|
|
@@ -108376,7 +108613,7 @@ function readProfileInput(path) {
|
|
|
108376
108613
|
throw new Error("Profile input exceeds the size limit");
|
|
108377
108614
|
return new TextDecoder("utf-8", { fatal: true }).decode(bytes.subarray(0, size2));
|
|
108378
108615
|
} finally {
|
|
108379
|
-
|
|
108616
|
+
closeSync21(fd);
|
|
108380
108617
|
}
|
|
108381
108618
|
}
|
|
108382
108619
|
function registerProfiles(parent) {
|
|
@@ -108427,23 +108664,23 @@ __export(exports_grants, {
|
|
|
108427
108664
|
registerGrants: () => registerGrants
|
|
108428
108665
|
});
|
|
108429
108666
|
import {
|
|
108430
|
-
constants as
|
|
108431
|
-
closeSync as
|
|
108432
|
-
fstatSync as
|
|
108433
|
-
openSync as
|
|
108434
|
-
readSync as
|
|
108667
|
+
constants as constants21,
|
|
108668
|
+
closeSync as closeSync23,
|
|
108669
|
+
fstatSync as fstatSync23,
|
|
108670
|
+
openSync as openSync23,
|
|
108671
|
+
readSync as readSync18,
|
|
108435
108672
|
writeFileSync as writeFileSync25
|
|
108436
108673
|
} from "fs";
|
|
108437
108674
|
function readInput(path) {
|
|
108438
|
-
const fd =
|
|
108675
|
+
const fd = openSync23(path, constants21.O_RDONLY | constants21.O_NONBLOCK);
|
|
108439
108676
|
try {
|
|
108440
|
-
const stat3 =
|
|
108677
|
+
const stat3 = fstatSync23(fd);
|
|
108441
108678
|
if (!stat3.isFile() || stat3.size > MAX_EXECUTION_GRANT_BYTES)
|
|
108442
108679
|
throw new Error("Grant input must be a regular file within the policy size limit.");
|
|
108443
108680
|
const bytes = Buffer.alloc(MAX_EXECUTION_GRANT_BYTES + 1);
|
|
108444
108681
|
let size2 = 0;
|
|
108445
108682
|
while (size2 < bytes.length) {
|
|
108446
|
-
const count =
|
|
108683
|
+
const count = readSync18(fd, bytes, size2, bytes.length - size2, null);
|
|
108447
108684
|
if (!count)
|
|
108448
108685
|
break;
|
|
108449
108686
|
size2 += count;
|
|
@@ -108456,7 +108693,7 @@ function readInput(path) {
|
|
|
108456
108693
|
throw new Error("Grant input must be a JSON document containing a grants array.");
|
|
108457
108694
|
}
|
|
108458
108695
|
} finally {
|
|
108459
|
-
|
|
108696
|
+
closeSync23(fd);
|
|
108460
108697
|
}
|
|
108461
108698
|
}
|
|
108462
108699
|
function registerGrants(parent) {
|
|
@@ -108492,7 +108729,7 @@ var init_grants = __esm(() => {
|
|
|
108492
108729
|
});
|
|
108493
108730
|
|
|
108494
108731
|
// src/lib/station-hydrate.ts
|
|
108495
|
-
import { createHash as
|
|
108732
|
+
import { createHash as createHash27 } from "crypto";
|
|
108496
108733
|
import {
|
|
108497
108734
|
copyFileSync as copyFileSync2,
|
|
108498
108735
|
mkdirSync as mkdirSync26,
|
|
@@ -108501,7 +108738,7 @@ import {
|
|
|
108501
108738
|
statSync as statSync21,
|
|
108502
108739
|
writeFileSync as writeFileSync26
|
|
108503
108740
|
} from "fs";
|
|
108504
|
-
import { dirname as
|
|
108741
|
+
import { dirname as dirname30, join as join57, resolve as resolve23, sep as sep10 } from "path";
|
|
108505
108742
|
function fail5(code2, message, detail = []) {
|
|
108506
108743
|
throw new StationSnapshotError(code2, message, detail);
|
|
108507
108744
|
}
|
|
@@ -108695,12 +108932,12 @@ function skillSha256(skill) {
|
|
|
108695
108932
|
return sha256File(skill.files[0].winner.fullPath);
|
|
108696
108933
|
}
|
|
108697
108934
|
const joined = skill.files.map((file2) => sha256File(file2.winner.fullPath));
|
|
108698
|
-
return
|
|
108935
|
+
return createHash27("sha256").update(joined.sort().join(`
|
|
108699
108936
|
`)).digest("hex");
|
|
108700
108937
|
}
|
|
108701
108938
|
function writeStationHydration(options) {
|
|
108702
|
-
const repoRoot =
|
|
108703
|
-
const cacheRoot =
|
|
108939
|
+
const repoRoot = resolve23(options.repoRoot ?? process.cwd());
|
|
108940
|
+
const cacheRoot = resolve23(options.cacheRoot ?? resolveCorpusRoot());
|
|
108704
108941
|
const plan = planStationHydration(options.stationId, repoRoot);
|
|
108705
108942
|
const resultSkills = plan.winners.map((skill) => ({
|
|
108706
108943
|
ident: skill.ident,
|
|
@@ -108754,7 +108991,7 @@ function writeStationHydration(options) {
|
|
|
108754
108991
|
}
|
|
108755
108992
|
let written = 0;
|
|
108756
108993
|
for (const entry of toWrite) {
|
|
108757
|
-
mkdirSync26(
|
|
108994
|
+
mkdirSync26(dirname30(entry.destination), { recursive: true });
|
|
108758
108995
|
copyFileSync2(entry.fullPath, entry.destination);
|
|
108759
108996
|
written += 1;
|
|
108760
108997
|
}
|
|
@@ -108775,8 +109012,8 @@ function writeStationHydration(options) {
|
|
|
108775
109012
|
},
|
|
108776
109013
|
skills: resultSkills
|
|
108777
109014
|
};
|
|
108778
|
-
const hydrationManifestPath = join57(
|
|
108779
|
-
mkdirSync26(
|
|
109015
|
+
const hydrationManifestPath = join57(dirname30(cacheRoot), `hydration-${options.stationId}.json`);
|
|
109016
|
+
mkdirSync26(dirname30(hydrationManifestPath), { recursive: true });
|
|
108780
109017
|
writeFileSync26(hydrationManifestPath, `${JSON.stringify(hydration, null, 2)}
|
|
108781
109018
|
`);
|
|
108782
109019
|
return {
|
|
@@ -108852,10 +109089,10 @@ var init_hydrate = __esm(() => {
|
|
|
108852
109089
|
});
|
|
108853
109090
|
|
|
108854
109091
|
// src/lib/prepare-skill.ts
|
|
108855
|
-
import { createHash as
|
|
108856
|
-
import { chmodSync as chmodSync3, existsSync as existsSync34, lstatSync as
|
|
109092
|
+
import { createHash as createHash28, randomUUID as randomUUID11 } from "crypto";
|
|
109093
|
+
import { chmodSync as chmodSync3, existsSync as existsSync34, lstatSync as lstatSync29, mkdirSync as mkdirSync27, mkdtempSync as mkdtempSync6, readFileSync as readFileSync39, readdirSync as readdirSync22, renameSync as renameSync12, rmSync as rmSync9, writeFileSync as writeFileSync27 } from "fs";
|
|
108857
109094
|
import { tmpdir as tmpdir2 } from "os";
|
|
108858
|
-
import { dirname as
|
|
109095
|
+
import { dirname as dirname31, isAbsolute as isAbsolute26, join as join58, relative as relative9, resolve as resolve24, sep as sep11 } from "path";
|
|
108859
109096
|
function prepareSkill(name, options) {
|
|
108860
109097
|
const normalized = normalizePortableSkillName(name);
|
|
108861
109098
|
if (!new RegExp(SEMVER_PATTERN).test(options.version))
|
|
@@ -108900,7 +109137,7 @@ function prepareSkill(name, options) {
|
|
|
108900
109137
|
mkdirSync27(join58(staging, directory2), { recursive: true });
|
|
108901
109138
|
for (const file2 of before2.files) {
|
|
108902
109139
|
const destination = join58(staging, file2.path);
|
|
108903
|
-
mkdirSync27(
|
|
109140
|
+
mkdirSync27(dirname31(destination), { recursive: true });
|
|
108904
109141
|
writeFileSync27(destination, file2.bytes, { mode: file2.mode });
|
|
108905
109142
|
}
|
|
108906
109143
|
const stagedManifest = join58(staging, "skill.json");
|
|
@@ -108960,8 +109197,8 @@ function validateRuntimeEntrypoint(candidate2, root2) {
|
|
|
108960
109197
|
const entry = candidate2.runtime.entrypoint;
|
|
108961
109198
|
if (typeof entry !== "string")
|
|
108962
109199
|
return;
|
|
108963
|
-
const target =
|
|
108964
|
-
if (
|
|
109200
|
+
const target = resolve24(root2, entry), rel = relative9(root2, target);
|
|
109201
|
+
if (isAbsolute26(entry) || /^[a-zA-Z]:/.test(entry) || entry.includes("\\") || !rel || rel === ".." || rel.startsWith(`..${sep11}`) || isAbsolute26(rel) || !existsSync34(target) || !lstatSync29(target).isFile()) {
|
|
108965
109202
|
throw new Error("Executable runtime.entrypoint must name an existing regular file inside the skill directory.");
|
|
108966
109203
|
}
|
|
108967
109204
|
}
|
|
@@ -109033,11 +109270,11 @@ function compareVersions(left, right) {
|
|
|
109033
109270
|
return 0;
|
|
109034
109271
|
}
|
|
109035
109272
|
function snapshot2(root2) {
|
|
109036
|
-
const rootStat =
|
|
109273
|
+
const rootStat = lstatSync29(root2);
|
|
109037
109274
|
if (rootStat.isSymbolicLink() || !rootStat.isDirectory())
|
|
109038
109275
|
throw new Error("Skill root must be a real directory, not a symlink.");
|
|
109039
109276
|
const files = [], directories = [];
|
|
109040
|
-
const hash4 =
|
|
109277
|
+
const hash4 = createHash28("sha256").update(`${rootStat.dev}:${rootStat.ino}\x00`);
|
|
109041
109278
|
let count = 0, bytes = 0;
|
|
109042
109279
|
const walk2 = (relative10) => {
|
|
109043
109280
|
for (const name of readdirSync22(join58(root2, relative10)).sort()) {
|
|
@@ -109046,7 +109283,7 @@ function snapshot2(root2) {
|
|
|
109046
109283
|
const path = relative10 ? `${relative10}/${name}` : name;
|
|
109047
109284
|
if (++count > 20000)
|
|
109048
109285
|
throw new Error("Skill exceeds the preparation entry limit (20000).");
|
|
109049
|
-
const absolute = join58(root2, path), stat3 =
|
|
109286
|
+
const absolute = join58(root2, path), stat3 = lstatSync29(absolute);
|
|
109050
109287
|
if (stat3.isSymbolicLink())
|
|
109051
109288
|
throw new Error(`Skill contains a symlink: ${path}. No files were changed.`);
|
|
109052
109289
|
if (stat3.isDirectory() && name === "node_modules")
|
|
@@ -109461,7 +109698,7 @@ var init_schedule = __esm(() => {
|
|
|
109461
109698
|
|
|
109462
109699
|
// src/lib/registry-sync.ts
|
|
109463
109700
|
import { mkdirSync as mkdirSync28, writeFileSync as writeFileSync28 } from "fs";
|
|
109464
|
-
import { dirname as
|
|
109701
|
+
import { dirname as dirname32, relative as relative10 } from "path";
|
|
109465
109702
|
function createRegistrySyncArtifact(options = {}) {
|
|
109466
109703
|
const profile = options.profile ?? "all";
|
|
109467
109704
|
const includeDocs = options.includeDocs ?? true;
|
|
@@ -109518,7 +109755,7 @@ function createRegistrySyncArtifact(options = {}) {
|
|
|
109518
109755
|
};
|
|
109519
109756
|
}
|
|
109520
109757
|
function writeRegistrySyncArtifact(path, artifact) {
|
|
109521
|
-
mkdirSync28(
|
|
109758
|
+
mkdirSync28(dirname32(path), { recursive: true });
|
|
109522
109759
|
writeFileSync28(path, `${JSON.stringify(artifact, null, 2)}
|
|
109523
109760
|
`);
|
|
109524
109761
|
}
|
|
@@ -109551,12 +109788,12 @@ function registerRegistry(parent) {
|
|
|
109551
109788
|
async function writeJson2(value, space) {
|
|
109552
109789
|
const text3 = `${JSON.stringify(value, null, space)}
|
|
109553
109790
|
`;
|
|
109554
|
-
await new Promise((
|
|
109791
|
+
await new Promise((resolve25, reject2) => {
|
|
109555
109792
|
process.stdout.write(text3, (error61) => {
|
|
109556
109793
|
if (error61)
|
|
109557
109794
|
reject2(error61);
|
|
109558
109795
|
else
|
|
109559
|
-
|
|
109796
|
+
resolve25();
|
|
109560
109797
|
});
|
|
109561
109798
|
});
|
|
109562
109799
|
}
|
|
@@ -110013,7 +110250,7 @@ var exports_private_publications = {};
|
|
|
110013
110250
|
__export(exports_private_publications, {
|
|
110014
110251
|
registerPrivatePublications: () => registerPrivatePublications
|
|
110015
110252
|
});
|
|
110016
|
-
import { resolve as
|
|
110253
|
+
import { resolve as resolve25 } from "path";
|
|
110017
110254
|
function verifyOptions(options, action) {
|
|
110018
110255
|
if (options.userId === undefined !== (options.membershipId === undefined) || options.userId !== undefined && (!publicationUuid(options.userId) || !publicationUuid(options.membershipId)))
|
|
110019
110256
|
throw new PrivatePublicationError("PUBLICATION_CONTEXT_REQUIRED", "Provide both observed --user-id and --membership-id UUIDs.");
|
|
@@ -110058,9 +110295,9 @@ function registerPrivatePublications(parent) {
|
|
|
110058
110295
|
if (code2 === null)
|
|
110059
110296
|
return;
|
|
110060
110297
|
const context2 = options.userId ? { userId: options.userId, membershipId: options.membershipId } : undefined;
|
|
110061
|
-
const client2 = await privatePublicationSession(options.email, code2, context2), directory2 =
|
|
110298
|
+
const client2 = await privatePublicationSession(options.email, code2, context2), directory2 = resolve25(options.recoveryDir);
|
|
110062
110299
|
if (action === "publish")
|
|
110063
|
-
await preparePrivatePublication(client2,
|
|
110300
|
+
await preparePrivatePublication(client2, resolve25(args2[0]), directory2, { skillId: options.skillId, expectedCurrentVersionId: options.expectedCurrentVersion ?? null, idempotencyKey: options.idempotencyKey });
|
|
110064
110301
|
const result2 = action === "publish" || action === "resume" ? await continuePrivatePublication(client2, directory2, { confirm: true, waitMs: Number(options.waitSeconds) * 1000 }) : await inspectPrivatePublication(client2, directory2, action === "cancel");
|
|
110065
110302
|
print2(result2, options.json);
|
|
110066
110303
|
} catch (error61) {
|
|
@@ -110161,7 +110398,7 @@ __export(exports_auth, {
|
|
|
110161
110398
|
import { createInterface as createInterface3 } from "readline";
|
|
110162
110399
|
function prompt(question) {
|
|
110163
110400
|
const rl = createInterface3({ input: process.stdin, output: process.stdout });
|
|
110164
|
-
return new Promise((
|
|
110401
|
+
return new Promise((resolve26) => {
|
|
110165
110402
|
let settled = false;
|
|
110166
110403
|
const finish = (answer) => {
|
|
110167
110404
|
if (settled)
|
|
@@ -110170,7 +110407,7 @@ function prompt(question) {
|
|
|
110170
110407
|
rl.close();
|
|
110171
110408
|
if (answer === null)
|
|
110172
110409
|
process.exitCode = 130;
|
|
110173
|
-
|
|
110410
|
+
resolve26(answer);
|
|
110174
110411
|
};
|
|
110175
110412
|
rl.once("SIGINT", () => finish(null));
|
|
110176
110413
|
rl.once("close", () => finish(null));
|
|
@@ -110278,7 +110515,7 @@ function printWhoami(payload) {
|
|
|
110278
110515
|
console.log(source_default.dim("(offline \u2014 showing cached info)"));
|
|
110279
110516
|
}
|
|
110280
110517
|
function sleep(ms) {
|
|
110281
|
-
return new Promise((
|
|
110518
|
+
return new Promise((resolve26) => setTimeout(resolve26, ms));
|
|
110282
110519
|
}
|
|
110283
110520
|
function browserCommand(url2) {
|
|
110284
110521
|
if (process.platform === "darwin")
|
|
@@ -110780,7 +111017,7 @@ function promptInvitationProof(kind) {
|
|
|
110780
111017
|
const label = kind === "token" ? "invitation token" : "recovery code";
|
|
110781
111018
|
const character = kind === "token" ? /^[A-Za-z0-9_-]$/ : /^\d$/;
|
|
110782
111019
|
const { stdin, stderr: output2 } = process, wasRaw = stdin.isRaw, wasFlowing = stdin.readableFlowing;
|
|
110783
|
-
return new Promise((
|
|
111020
|
+
return new Promise((resolve26) => {
|
|
110784
111021
|
let value = "", settled = false, overflow = false;
|
|
110785
111022
|
const finish = (answer) => {
|
|
110786
111023
|
if (settled)
|
|
@@ -110797,7 +111034,7 @@ function promptInvitationProof(kind) {
|
|
|
110797
111034
|
`);
|
|
110798
111035
|
if (answer === null)
|
|
110799
111036
|
process.exitCode = 130;
|
|
110800
|
-
|
|
111037
|
+
resolve26(answer);
|
|
110801
111038
|
};
|
|
110802
111039
|
const cancel = () => finish(null);
|
|
110803
111040
|
const keypress = (text3, key) => {
|