@alan-ai-hq/agent-manager-darwin-arm64 0.1.170 → 0.1.171
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/alan-agent.cjs +870 -606
- package/alan-holder.cjs +488 -308
- package/alan-lease.cjs +1 -1
- package/package.json +1 -1
package/alan-agent.cjs
CHANGED
|
@@ -1576,8 +1576,8 @@ var init_regexes = __esm({
|
|
|
1576
1576
|
_emoji = `^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`;
|
|
1577
1577
|
ipv4 = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/;
|
|
1578
1578
|
ipv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;
|
|
1579
|
-
mac = (
|
|
1580
|
-
const escapedDelim = escapeRegex(
|
|
1579
|
+
mac = (delimiter2) => {
|
|
1580
|
+
const escapedDelim = escapeRegex(delimiter2 ?? ":");
|
|
1581
1581
|
return new RegExp(`^(?:[0-9A-F]{2}${escapedDelim}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${escapedDelim}){5}[0-9a-f]{2}$`);
|
|
1582
1582
|
};
|
|
1583
1583
|
cidrv4 = /^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/;
|
|
@@ -20664,7 +20664,7 @@ var init_cloud_repositories = __esm({
|
|
|
20664
20664
|
"../shared/dist/constants/cloud-repositories.js"() {
|
|
20665
20665
|
"use strict";
|
|
20666
20666
|
MAX_CLOUD_REPOSITORIES = 64;
|
|
20667
|
-
CLOUD_REPOSITORY_LIMIT_MESSAGE = `Select at most ${MAX_CLOUD_REPOSITORIES} repositories
|
|
20667
|
+
CLOUD_REPOSITORY_LIMIT_MESSAGE = `Select at most ${MAX_CLOUD_REPOSITORIES} repositories for one cloud session`;
|
|
20668
20668
|
}
|
|
20669
20669
|
});
|
|
20670
20670
|
|
|
@@ -27167,7 +27167,7 @@ var init_chunk_WYNUYKKN = __esm({
|
|
|
27167
27167
|
}
|
|
27168
27168
|
});
|
|
27169
27169
|
|
|
27170
|
-
// ../agent-core/dist/chunk-
|
|
27170
|
+
// ../agent-core/dist/chunk-A5UQ6YFO.js
|
|
27171
27171
|
function windowsEnvValue(env, name) {
|
|
27172
27172
|
const wanted = name.toLowerCase();
|
|
27173
27173
|
for (const [key, value2] of Object.entries(env).reverse()) {
|
|
@@ -27415,28 +27415,123 @@ function invalidChoiceIndicatesSupport(output2, flag2) {
|
|
|
27415
27415
|
if (output2.includes(`unknown option '${flag2}'`)) return false;
|
|
27416
27416
|
return output2.includes(`'${flag2}`) && output2.includes("is invalid");
|
|
27417
27417
|
}
|
|
27418
|
-
function createFlagProbe(
|
|
27419
|
-
const
|
|
27420
|
-
const
|
|
27421
|
-
|
|
27422
|
-
|
|
27423
|
-
|
|
27424
|
-
|
|
27425
|
-
|
|
27418
|
+
function createFlagProbe(options = {}) {
|
|
27419
|
+
const { capture = captureOutput, store } = typeof options === "function" ? { capture: options, store: void 0 } : options;
|
|
27420
|
+
const commands = /* @__PURE__ */ new Map();
|
|
27421
|
+
const answersFor = (command, env) => {
|
|
27422
|
+
const known = commands.get(command);
|
|
27423
|
+
if (known) return known;
|
|
27424
|
+
const loading = (store?.read(command, env) ?? Promise.resolve(null)).catch(() => null).then(
|
|
27425
|
+
(stored) => ({
|
|
27426
|
+
record: stored ?? { hiddenChoiceFlags: {} },
|
|
27427
|
+
hidden: /* @__PURE__ */ new Map(),
|
|
27428
|
+
persisting: Promise.resolve()
|
|
27429
|
+
})
|
|
27430
|
+
);
|
|
27431
|
+
commands.set(command, loading);
|
|
27432
|
+
return loading;
|
|
27433
|
+
};
|
|
27434
|
+
const persist = (command, env, answers) => {
|
|
27435
|
+
if (store === void 0) return;
|
|
27436
|
+
answers.persisting = answers.persisting.then(() => store.write(command, env, answers.record)).catch(() => void 0);
|
|
27437
|
+
};
|
|
27438
|
+
const helpOf = async (command, env) => {
|
|
27439
|
+
const answers = await answersFor(command, env);
|
|
27440
|
+
if (answers.record.help !== void 0) return answers.record.help;
|
|
27441
|
+
answers.help ??= capture(command, ["--help"], { env }).then(({ stdout, stderr, exitCode }) => {
|
|
27442
|
+
const help = `${stdout}${stderr}`;
|
|
27443
|
+
if (exitCode !== void 0) {
|
|
27444
|
+
answers.record.help = help;
|
|
27445
|
+
persist(command, env, answers);
|
|
27446
|
+
}
|
|
27447
|
+
return help;
|
|
27448
|
+
});
|
|
27449
|
+
return answers.help;
|
|
27426
27450
|
};
|
|
27427
27451
|
return {
|
|
27428
|
-
|
|
27429
|
-
const
|
|
27430
|
-
|
|
27431
|
-
}
|
|
27432
|
-
|
|
27433
|
-
|
|
27434
|
-
|
|
27435
|
-
|
|
27436
|
-
|
|
27452
|
+
persisted: async () => {
|
|
27453
|
+
const loaded = await Promise.all(commands.values());
|
|
27454
|
+
await Promise.all(loaded.map((answers) => answers.persisting));
|
|
27455
|
+
},
|
|
27456
|
+
supportsFlag: async (command, flag2, env) => helpAdvertisesFlag(await helpOf(command, env), flag2),
|
|
27457
|
+
supportsHiddenChoiceFlag: async (command, flag2, env) => {
|
|
27458
|
+
const answers = await answersFor(command, env);
|
|
27459
|
+
const stored = answers.record.hiddenChoiceFlags[flag2];
|
|
27460
|
+
if (stored !== void 0) return stored;
|
|
27461
|
+
const known = answers.hidden.get(flag2);
|
|
27462
|
+
if (known) return known;
|
|
27463
|
+
const probing = capture(command, [flag2, HIDDEN_FLAG_PROBE_VALUE, "--version"], { env }).then(
|
|
27464
|
+
({ stdout, stderr, exitCode }) => {
|
|
27465
|
+
const supported = invalidChoiceIndicatesSupport(`${stdout}${stderr}`, flag2);
|
|
27466
|
+
if (exitCode !== void 0) {
|
|
27467
|
+
answers.record.hiddenChoiceFlags[flag2] = supported;
|
|
27468
|
+
persist(command, env, answers);
|
|
27469
|
+
}
|
|
27470
|
+
return supported;
|
|
27471
|
+
}
|
|
27437
27472
|
);
|
|
27438
|
-
|
|
27439
|
-
|
|
27473
|
+
answers.hidden.set(flag2, probing);
|
|
27474
|
+
return probing;
|
|
27475
|
+
}
|
|
27476
|
+
};
|
|
27477
|
+
}
|
|
27478
|
+
async function resolveBinary(command, env) {
|
|
27479
|
+
const candidates2 = command.includes("/") ? [command] : (env.PATH ?? "").split(import_path2.delimiter).filter((dir) => dir.length > 0).map((dir) => (0, import_path2.join)(dir, command));
|
|
27480
|
+
for (const candidate of candidates2) {
|
|
27481
|
+
if (!(0, import_path2.isAbsolute)(candidate)) continue;
|
|
27482
|
+
try {
|
|
27483
|
+
await (0, import_promises19.access)(candidate, import_fs2.constants.X_OK);
|
|
27484
|
+
return candidate;
|
|
27485
|
+
} catch {
|
|
27486
|
+
}
|
|
27487
|
+
}
|
|
27488
|
+
return null;
|
|
27489
|
+
}
|
|
27490
|
+
async function identify(command, env) {
|
|
27491
|
+
const path4 = await resolveBinary(command, env);
|
|
27492
|
+
if (path4 === null) return null;
|
|
27493
|
+
const { mtimeMs, size } = await (0, import_promises19.stat)(path4);
|
|
27494
|
+
return { path: path4, mtimeMs, size };
|
|
27495
|
+
}
|
|
27496
|
+
function isStoredBinary(value2) {
|
|
27497
|
+
if (typeof value2 !== "object" || value2 === null) return false;
|
|
27498
|
+
const entry = value2;
|
|
27499
|
+
return typeof entry.mtimeMs === "number" && typeof entry.size === "number" && typeof entry.record === "object" && entry.record !== null && typeof entry.record.hiddenChoiceFlags === "object";
|
|
27500
|
+
}
|
|
27501
|
+
async function readAll(file2) {
|
|
27502
|
+
try {
|
|
27503
|
+
const parsed = JSON.parse(await (0, import_promises19.readFile)(file2, "utf8"));
|
|
27504
|
+
if (typeof parsed !== "object" || parsed === null) return {};
|
|
27505
|
+
return Object.fromEntries(
|
|
27506
|
+
Object.entries(parsed).filter(
|
|
27507
|
+
(entry) => isStoredBinary(entry[1])
|
|
27508
|
+
)
|
|
27509
|
+
);
|
|
27510
|
+
} catch {
|
|
27511
|
+
return {};
|
|
27512
|
+
}
|
|
27513
|
+
}
|
|
27514
|
+
function createFileFlagProbeStore(file2, platform3 = process.platform) {
|
|
27515
|
+
return {
|
|
27516
|
+
read: async (command, env) => {
|
|
27517
|
+
if (platform3 === "win32") return null;
|
|
27518
|
+
const identity = await identify(command, env);
|
|
27519
|
+
if (identity === null) return null;
|
|
27520
|
+
const stored = (await readAll(file2))[identity.path];
|
|
27521
|
+
if (stored?.mtimeMs !== identity.mtimeMs || stored.size !== identity.size) return null;
|
|
27522
|
+
return stored.record;
|
|
27523
|
+
},
|
|
27524
|
+
write: async (command, env, record2) => {
|
|
27525
|
+
if (platform3 === "win32") return;
|
|
27526
|
+
const identity = await identify(command, env);
|
|
27527
|
+
if (identity === null) return;
|
|
27528
|
+
const all = await readAll(file2);
|
|
27529
|
+
all[identity.path] = { mtimeMs: identity.mtimeMs, size: identity.size, record: record2 };
|
|
27530
|
+
await (0, import_promises19.mkdir)((0, import_path2.dirname)(file2), { recursive: true });
|
|
27531
|
+
const staging = `${file2}.${process.pid}.tmp`;
|
|
27532
|
+
await (0, import_promises19.writeFile)(staging, JSON.stringify(all), { mode: 384 });
|
|
27533
|
+
await (0, import_promises19.rename)(staging, file2);
|
|
27534
|
+
}
|
|
27440
27535
|
};
|
|
27441
27536
|
}
|
|
27442
27537
|
function decode3(bytes, start2, end) {
|
|
@@ -27445,8 +27540,8 @@ function decode3(bytes, start2, end) {
|
|
|
27445
27540
|
}
|
|
27446
27541
|
async function linuxStartTicks(pid) {
|
|
27447
27542
|
try {
|
|
27448
|
-
const
|
|
27449
|
-
const fields =
|
|
27543
|
+
const stat24 = await (0, import_promises20.readFile)(`/proc/${pid}/stat`, "utf8");
|
|
27544
|
+
const fields = stat24.slice(stat24.lastIndexOf(")") + 2).split(" ");
|
|
27450
27545
|
return fields[19];
|
|
27451
27546
|
} catch {
|
|
27452
27547
|
return void 0;
|
|
@@ -27704,15 +27799,15 @@ function helperFile(env) {
|
|
|
27704
27799
|
if (override) return override;
|
|
27705
27800
|
const entry = process.argv[1];
|
|
27706
27801
|
if (!entry) throw new CoreFault("spawn_failed", "Cannot locate the Windows agent helper");
|
|
27707
|
-
return (0,
|
|
27802
|
+
return (0, import_path3.join)((0, import_path3.dirname)(entry), "alan-winhelper.exe");
|
|
27708
27803
|
}
|
|
27709
27804
|
function spawnInWindowsJob(plan2, options) {
|
|
27710
27805
|
if (plan2.commandLine === null) {
|
|
27711
27806
|
throw new CoreFault("internal", `No Windows command line was planned for ${plan2.file}`);
|
|
27712
27807
|
}
|
|
27713
27808
|
const file2 = helperFile(options.env);
|
|
27714
|
-
const directory = (0,
|
|
27715
|
-
const path4 = (0,
|
|
27809
|
+
const directory = (0, import_fs4.mkdtempSync)((0, import_path3.join)((0, import_os.tmpdir)(), `alan-job-${(0, import_crypto2.randomUUID)()}-`));
|
|
27810
|
+
const path4 = (0, import_path3.join)(directory, "started");
|
|
27716
27811
|
const child = (0, import_child_process6.spawn)(file2, [String(process.pid)], {
|
|
27717
27812
|
cwd: options.cwd,
|
|
27718
27813
|
env: {
|
|
@@ -27732,13 +27827,14 @@ function spawnInWindowsJob(plan2, options) {
|
|
|
27732
27827
|
statuses.set(child, status);
|
|
27733
27828
|
return child;
|
|
27734
27829
|
}
|
|
27735
|
-
async function waitForWindowsJob(child, command) {
|
|
27830
|
+
async function waitForWindowsJob(child, command, options = {}) {
|
|
27736
27831
|
const status = statuses.get(child);
|
|
27737
27832
|
if (!status) throw new CoreFault("internal", "Missing Windows helper startup state");
|
|
27738
|
-
const deadline = systemClock2.monotonic() + START_TIMEOUT_MS;
|
|
27833
|
+
const deadline = systemClock2.monotonic() + (options.timeoutMs ?? START_TIMEOUT_MS);
|
|
27739
27834
|
try {
|
|
27740
27835
|
while (systemClock2.monotonic() < deadline) {
|
|
27741
|
-
|
|
27836
|
+
options.signal?.throwIfAborted();
|
|
27837
|
+
const providerPid = await (0, import_promises21.readFile)(status.path, "utf8").catch(() => void 0);
|
|
27742
27838
|
if (providerPid !== void 0) {
|
|
27743
27839
|
requireStartedProvider(providerPid, command);
|
|
27744
27840
|
return;
|
|
@@ -27755,18 +27851,18 @@ async function waitForWindowsJob(child, command) {
|
|
|
27755
27851
|
if (child.exitCode !== null || child.signalCode !== null) {
|
|
27756
27852
|
throw new CoreFault("spawn_failed", `Could not start ${command} (Windows helper exited)`);
|
|
27757
27853
|
}
|
|
27758
|
-
await systemClock2.sleep(25);
|
|
27854
|
+
await systemClock2.sleep(25, options.signal);
|
|
27759
27855
|
}
|
|
27760
27856
|
child.kill("SIGKILL");
|
|
27761
27857
|
throw new CoreFault("spawn_failed", `Could not start ${command} (Windows helper timed out)`);
|
|
27762
27858
|
} finally {
|
|
27763
27859
|
statuses.delete(child);
|
|
27764
|
-
await (0,
|
|
27860
|
+
await (0, import_promises21.rm)(status.directory, { recursive: true, force: true });
|
|
27765
27861
|
}
|
|
27766
27862
|
}
|
|
27767
27863
|
function preferForOomKill(pid) {
|
|
27768
27864
|
try {
|
|
27769
|
-
(0,
|
|
27865
|
+
(0, import_fs3.writeFileSync)(`/proc/${pid}/oom_score_adj`, String(CLI_OOM_SCORE_ADJ));
|
|
27770
27866
|
} catch {
|
|
27771
27867
|
}
|
|
27772
27868
|
}
|
|
@@ -27815,7 +27911,7 @@ function waitForSpawn(child, command) {
|
|
|
27815
27911
|
}
|
|
27816
27912
|
function inode(path4) {
|
|
27817
27913
|
try {
|
|
27818
|
-
return (0,
|
|
27914
|
+
return (0, import_fs5.statSync)(path4).ino;
|
|
27819
27915
|
} catch (error62) {
|
|
27820
27916
|
if (errnoCode2(error62) !== "ENOENT") throw error62;
|
|
27821
27917
|
return void 0;
|
|
@@ -27826,7 +27922,7 @@ async function removeDeadOwner(path4) {
|
|
|
27826
27922
|
try {
|
|
27827
27923
|
let owner;
|
|
27828
27924
|
try {
|
|
27829
|
-
owner = asRecord(JSON.parse((0,
|
|
27925
|
+
owner = asRecord(JSON.parse((0, import_fs5.readFileSync)(path4, "utf8")));
|
|
27830
27926
|
} catch (error62) {
|
|
27831
27927
|
if (!(error62 instanceof SyntaxError)) throw error62;
|
|
27832
27928
|
}
|
|
@@ -27843,24 +27939,24 @@ async function removeDeadOwner(path4) {
|
|
|
27843
27939
|
const actualStart = expectedStart ? await readProcessStartTime(pid) : void 0;
|
|
27844
27940
|
dead ||= actualStart !== void 0 && actualStart !== expectedStart;
|
|
27845
27941
|
}
|
|
27846
|
-
if (dead && observed !== void 0 && inode(path4) === observed) (0,
|
|
27942
|
+
if (dead && observed !== void 0 && inode(path4) === observed) (0, import_fs5.rmSync)(path4, { force: true });
|
|
27847
27943
|
} catch (error62) {
|
|
27848
27944
|
if (errnoCode2(error62) !== "ENOENT") throw error62;
|
|
27849
27945
|
}
|
|
27850
27946
|
}
|
|
27851
27947
|
async function withStartupLock(path4, clock, work, signal) {
|
|
27852
|
-
(0,
|
|
27948
|
+
(0, import_fs5.mkdirSync)((0, import_path4.dirname)(path4), { recursive: true, mode: 448 });
|
|
27853
27949
|
const candidate = `${path4}.${(0, import_crypto3.randomUUID)()}`;
|
|
27854
27950
|
const startedAt = await readProcessStartTime(process.pid);
|
|
27855
|
-
(0,
|
|
27856
|
-
const owned = (0,
|
|
27951
|
+
(0, import_fs5.writeFileSync)(candidate, JSON.stringify({ pid: process.pid, startedAt }), { mode: 384 });
|
|
27952
|
+
const owned = (0, import_fs5.statSync)(candidate).ino;
|
|
27857
27953
|
const deadline = clock.monotonic() + 12e4;
|
|
27858
27954
|
let acquired = false;
|
|
27859
27955
|
try {
|
|
27860
27956
|
for (; ; ) {
|
|
27861
27957
|
signal?.throwIfAborted();
|
|
27862
27958
|
try {
|
|
27863
|
-
(0,
|
|
27959
|
+
(0, import_fs5.linkSync)(candidate, path4);
|
|
27864
27960
|
acquired = true;
|
|
27865
27961
|
break;
|
|
27866
27962
|
} catch (error62) {
|
|
@@ -27873,33 +27969,36 @@ async function withStartupLock(path4, clock, work, signal) {
|
|
|
27873
27969
|
}
|
|
27874
27970
|
return await work();
|
|
27875
27971
|
} finally {
|
|
27876
|
-
if (acquired && inode(path4) === owned) (0,
|
|
27877
|
-
(0,
|
|
27972
|
+
if (acquired && inode(path4) === owned) (0, import_fs5.rmSync)(path4, { force: true });
|
|
27973
|
+
(0, import_fs5.rmSync)(candidate, { force: true });
|
|
27878
27974
|
}
|
|
27879
27975
|
}
|
|
27880
|
-
var import_child_process, import_fs, import_path,
|
|
27881
|
-
var
|
|
27882
|
-
"../agent-core/dist/chunk-
|
|
27976
|
+
var import_child_process, import_fs, import_path, import_fs2, import_promises19, import_path2, import_child_process2, import_promises20, import_child_process3, import_child_process4, import_child_process5, import_fs3, import_child_process6, import_crypto2, import_fs4, import_promises21, import_os, import_path3, import_crypto3, import_fs5, import_path4, SHIM_MAX_BYTES, CMD_MAX_COMMAND_LINE, MAX_COMMAND_LINE, DEFAULT_PATHEXT, LAUNCHABLE_EXTENSIONS, nodeWindowsFiles, NODE_SHIM_ENTRY, SCRIPT_EXTENSION, NATIVE_SHIM_LINES, NATIVE_SHIM_ENTRY, CMD_META, NEVER_STARTED, HIDDEN_FLAG_PROBE_VALUE, NEWLINE, CARRIAGE_RETURN, EMPTY, MAX_LINE_BYTES2, LineSplitter, PS_LINE, POLL_MS, DEFAULT_GRACE_MS, DEFAULT_KILL_WAIT_MS, DEFAULT_TASKKILL_TIMEOUT_MS, statuses, START_TIMEOUT_MS, CLI_OOM_SCORE_ADJ, spawnListeners;
|
|
27977
|
+
var init_chunk_A5UQ6YFO = __esm({
|
|
27978
|
+
"../agent-core/dist/chunk-A5UQ6YFO.js"() {
|
|
27883
27979
|
"use strict";
|
|
27884
27980
|
init_chunk_YXWJW7I5();
|
|
27885
27981
|
import_child_process = require("child_process");
|
|
27886
27982
|
import_fs = require("fs");
|
|
27887
27983
|
import_path = require("path");
|
|
27888
|
-
|
|
27984
|
+
import_fs2 = require("fs");
|
|
27889
27985
|
import_promises19 = require("fs/promises");
|
|
27986
|
+
import_path2 = require("path");
|
|
27987
|
+
import_child_process2 = require("child_process");
|
|
27988
|
+
import_promises20 = require("fs/promises");
|
|
27890
27989
|
import_child_process3 = require("child_process");
|
|
27891
27990
|
import_child_process4 = require("child_process");
|
|
27892
27991
|
import_child_process5 = require("child_process");
|
|
27893
|
-
|
|
27992
|
+
import_fs3 = require("fs");
|
|
27894
27993
|
import_child_process6 = require("child_process");
|
|
27895
27994
|
import_crypto2 = require("crypto");
|
|
27896
|
-
import_fs3 = require("fs");
|
|
27897
|
-
import_promises20 = require("fs/promises");
|
|
27898
|
-
import_os = require("os");
|
|
27899
|
-
import_path2 = require("path");
|
|
27900
|
-
import_crypto3 = require("crypto");
|
|
27901
27995
|
import_fs4 = require("fs");
|
|
27996
|
+
import_promises21 = require("fs/promises");
|
|
27997
|
+
import_os = require("os");
|
|
27902
27998
|
import_path3 = require("path");
|
|
27999
|
+
import_crypto3 = require("crypto");
|
|
28000
|
+
import_fs5 = require("fs");
|
|
28001
|
+
import_path4 = require("path");
|
|
27903
28002
|
SHIM_MAX_BYTES = 64 * 1024;
|
|
27904
28003
|
CMD_MAX_COMMAND_LINE = 8191;
|
|
27905
28004
|
MAX_COMMAND_LINE = 32766;
|
|
@@ -27990,7 +28089,7 @@ var init_chunk_KVTSAS2T = __esm({
|
|
|
27990
28089
|
}
|
|
27991
28090
|
});
|
|
27992
28091
|
|
|
27993
|
-
// ../agent-core/dist/chunk-
|
|
28092
|
+
// ../agent-core/dist/chunk-CGBCAZEN.js
|
|
27994
28093
|
function detectImageMimeType(buffer) {
|
|
27995
28094
|
if (buffer.length >= 8 && buffer.subarray(0, 8).equals(PNG_SIGNATURE)) return "image/png";
|
|
27996
28095
|
if (buffer.length >= 3 && buffer[0] === 255 && buffer[1] === 216 && buffer[2] === 255) {
|
|
@@ -28055,14 +28154,14 @@ function normalizePath(candidate, cwd) {
|
|
|
28055
28154
|
} catch {
|
|
28056
28155
|
}
|
|
28057
28156
|
if (path4.startsWith("~/")) return void 0;
|
|
28058
|
-
if ((0,
|
|
28059
|
-
return cwd ? (0,
|
|
28157
|
+
if ((0, import_path5.isAbsolute)(path4)) return path4;
|
|
28158
|
+
return cwd ? (0, import_path5.join)(cwd, path4) : void 0;
|
|
28060
28159
|
}
|
|
28061
28160
|
function toolCwd(cwd, toolInput2) {
|
|
28062
28161
|
if (!isJsonRecord(toolInput2)) return cwd;
|
|
28063
28162
|
const raw = asString(toolInput2.cwd) || asString(toolInput2.workdir) || asString(toolInput2.workingDirectory);
|
|
28064
28163
|
if (!raw) return cwd;
|
|
28065
|
-
return (0,
|
|
28164
|
+
return (0, import_path5.isAbsolute)(raw) || !cwd ? raw : (0, import_path5.join)(cwd, raw);
|
|
28066
28165
|
}
|
|
28067
28166
|
function jpegDimensions(buffer) {
|
|
28068
28167
|
let offset = 2;
|
|
@@ -28092,14 +28191,14 @@ function readMediaFiles(query) {
|
|
|
28092
28191
|
const files = [];
|
|
28093
28192
|
for (const candidate of query.candidates) {
|
|
28094
28193
|
const path4 = normalizePath(candidate, query.cwd);
|
|
28095
|
-
if (!path4 || seen.has(path4) || !(0,
|
|
28194
|
+
if (!path4 || seen.has(path4) || !(0, import_fs6.existsSync)(path4)) continue;
|
|
28096
28195
|
seen.add(path4);
|
|
28097
|
-
const mimeType = query.mimeByExt[(0,
|
|
28196
|
+
const mimeType = query.mimeByExt[(0, import_path5.extname)(path4).toLowerCase()];
|
|
28098
28197
|
if (!mimeType) continue;
|
|
28099
|
-
const
|
|
28100
|
-
if (!
|
|
28101
|
-
if (
|
|
28102
|
-
files.push({ path: path4, mimeType, buffer: (0,
|
|
28198
|
+
const stat24 = (0, import_fs6.statSync)(path4);
|
|
28199
|
+
if (!stat24.isFile() || stat24.size <= 0 || stat24.size > query.maxBytes) continue;
|
|
28200
|
+
if (stat24.mtimeMs < query.writtenSince && !query.named.has(path4)) continue;
|
|
28201
|
+
files.push({ path: path4, mimeType, buffer: (0, import_fs6.readFileSync)(path4) });
|
|
28103
28202
|
}
|
|
28104
28203
|
return files;
|
|
28105
28204
|
}
|
|
@@ -28430,17 +28529,17 @@ function silentStartError(name, timeoutMs) {
|
|
|
28430
28529
|
message: `${name} printed nothing for ${seconds}s after it started and was stopped. Send your message again.`
|
|
28431
28530
|
};
|
|
28432
28531
|
}
|
|
28433
|
-
var import_crypto4,
|
|
28434
|
-
var
|
|
28435
|
-
"../agent-core/dist/chunk-
|
|
28532
|
+
var import_crypto4, import_fs6, import_path5, PNG_SIGNATURE, IMAGE_MIME_BY_EXT, VIDEO_MIME_BY_EXT, IMAGE_EXTENSIONS, VIDEO_EXTENSIONS, MAX_IMAGE_BYTES, MAX_VIDEO_BYTES, MAX_TURN_MEDIA_DATA_CHARS, MTIME_SLACK_MS, AGENT_BROWSER_MENTION, AGENT_BROWSER_CAPTURE_COMMAND, LocalMediaReader, SessionOpenRefusal, JsonRpcError, ACP_PROTOCOL_VERSION, ACP_ERROR, STDERR_TAIL_LINES, RESULT_EXIT_GRACE_MS, PerTurnSession;
|
|
28533
|
+
var init_chunk_CGBCAZEN = __esm({
|
|
28534
|
+
"../agent-core/dist/chunk-CGBCAZEN.js"() {
|
|
28436
28535
|
"use strict";
|
|
28437
28536
|
init_chunk_AF3IPGDT();
|
|
28438
28537
|
init_chunk_WYNUYKKN();
|
|
28439
|
-
|
|
28538
|
+
init_chunk_A5UQ6YFO();
|
|
28440
28539
|
init_chunk_YXWJW7I5();
|
|
28441
28540
|
import_crypto4 = require("crypto");
|
|
28442
|
-
|
|
28443
|
-
|
|
28541
|
+
import_fs6 = require("fs");
|
|
28542
|
+
import_path5 = require("path");
|
|
28444
28543
|
init_agent2();
|
|
28445
28544
|
init_acp();
|
|
28446
28545
|
PNG_SIGNATURE = Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]);
|
|
@@ -28553,7 +28652,7 @@ var init_chunk_U4RQE7JS = __esm({
|
|
|
28553
28652
|
source,
|
|
28554
28653
|
kind,
|
|
28555
28654
|
mimeType: file2.mimeType,
|
|
28556
|
-
filename: (0,
|
|
28655
|
+
filename: (0, import_path5.basename)(file2.path),
|
|
28557
28656
|
data: file2.buffer,
|
|
28558
28657
|
sha256: (0, import_crypto4.createHash)("sha256").update(file2.buffer).digest("hex"),
|
|
28559
28658
|
...kind === "image" ? imageDimensions(file2.buffer, file2.mimeType) : {},
|
|
@@ -28817,10 +28916,10 @@ var init_chunk_U4RQE7JS = __esm({
|
|
|
28817
28916
|
var init_dist = __esm({
|
|
28818
28917
|
"../agent-core/dist/index.js"() {
|
|
28819
28918
|
"use strict";
|
|
28820
|
-
|
|
28919
|
+
init_chunk_CGBCAZEN();
|
|
28821
28920
|
init_chunk_AF3IPGDT();
|
|
28822
28921
|
init_chunk_WYNUYKKN();
|
|
28823
|
-
|
|
28922
|
+
init_chunk_A5UQ6YFO();
|
|
28824
28923
|
init_chunk_YXWJW7I5();
|
|
28825
28924
|
}
|
|
28826
28925
|
});
|
|
@@ -29458,7 +29557,7 @@ function byListingPriority(left, right) {
|
|
|
29458
29557
|
return platform3 !== 0 ? platform3 : left.name.localeCompare(right.name);
|
|
29459
29558
|
}
|
|
29460
29559
|
function overflowLine(omitted) {
|
|
29461
|
-
const folders = [...new Set(omitted.map((skill) => (0,
|
|
29560
|
+
const folders = [...new Set(omitted.map((skill) => (0, import_path6.dirname)(skill.packageDirectory)))].sort();
|
|
29462
29561
|
return `${omitted.length} more installed skills are not listed. Each is a folder holding a SKILL.md under ${folders.map((folder) => JSON.stringify(folder)).join(" or ")}; look there before assuming a named skill is unavailable.`;
|
|
29463
29562
|
}
|
|
29464
29563
|
function installedSkillLines(skills) {
|
|
@@ -29554,13 +29653,13 @@ function buildTurnText(input2) {
|
|
|
29554
29653
|
${body}` : body;
|
|
29555
29654
|
return spec.mode === "plan" ? planModePrefix(prefixed) : prefixed;
|
|
29556
29655
|
}
|
|
29557
|
-
var
|
|
29656
|
+
var import_path6, startCommandStateSchema, repositorySnapshotSchema, environmentSnapshotSchema, agentContextSnapshotSchema, BRANCH_REASONS, SLACK_SURFACE_INSTRUCTIONS, PLAIN_SCALAR, COMMAND_PREVIEW_CHARS, MAX_PARSED_ATTACHMENTS, MAX_PARSED_ATTACHMENT_CHARS, MAX_METADATA_CHARS, UNAVAILABLE, READ_ONLY_MODES, AGENT_MODES, INSTALLED_SKILLS_MAX_CHARS, INSTALLED_SKILL_DESCRIPTION_MAX_CHARS;
|
|
29558
29657
|
var init_chunk_7FJ7QKFN = __esm({
|
|
29559
29658
|
"../agent-core/dist/chunk-7FJ7QKFN.js"() {
|
|
29560
29659
|
"use strict";
|
|
29561
29660
|
init_runtime_v2();
|
|
29562
29661
|
init_zod();
|
|
29563
|
-
|
|
29662
|
+
import_path6 = require("path");
|
|
29564
29663
|
init_agent2();
|
|
29565
29664
|
startCommandStateSchema = external_exports.discriminatedUnion("state", [
|
|
29566
29665
|
external_exports.object({ state: external_exports.literal("not_configured") }),
|
|
@@ -29755,20 +29854,20 @@ function canonicalizeManagedMcpToolName(toolName2) {
|
|
|
29755
29854
|
return flattened ? `mcp__${MANAGED_MCP_SERVER_NAME}__${flattened[1]}` : toolName2;
|
|
29756
29855
|
}
|
|
29757
29856
|
async function writeSecretFile(name, contents) {
|
|
29758
|
-
const dir = await (0,
|
|
29759
|
-
const path4 = (0,
|
|
29857
|
+
const dir = await (0, import_promises22.mkdtemp)((0, import_path7.join)((0, import_os2.tmpdir)(), "alan-mcp-"));
|
|
29858
|
+
const path4 = (0, import_path7.join)(dir, name);
|
|
29760
29859
|
const remove = async () => {
|
|
29761
|
-
await (0,
|
|
29860
|
+
await (0, import_promises22.rm)(dir, { recursive: true, force: true });
|
|
29762
29861
|
};
|
|
29763
29862
|
try {
|
|
29764
|
-
await (0,
|
|
29863
|
+
await (0, import_promises22.writeFile)(path4, contents, { mode: 384, flag: "wx" });
|
|
29765
29864
|
} catch (error62) {
|
|
29766
29865
|
await remove();
|
|
29767
29866
|
throw error62;
|
|
29768
29867
|
}
|
|
29769
29868
|
return { path: path4, remove, [Symbol.asyncDispose]: remove };
|
|
29770
29869
|
}
|
|
29771
|
-
var import_crypto5, import_crypto6,
|
|
29870
|
+
var import_crypto5, import_crypto6, import_promises22, import_os2, import_path7, OPENCODE_CODE_MODE_ENV, OPENCODE_CODE_MODE_TOOL, CODE_MODE_CALLS_META, MANAGED_MCP_SERVER_NAME, RUN_SCOPED_SERVER, NAMESPACED_RUN_TOOL, FLATTENED_RUN_TOOL;
|
|
29772
29871
|
var init_chunk_OSECDZA5 = __esm({
|
|
29773
29872
|
"../agent-core/dist/chunk-OSECDZA5.js"() {
|
|
29774
29873
|
"use strict";
|
|
@@ -29777,9 +29876,9 @@ var init_chunk_OSECDZA5 = __esm({
|
|
|
29777
29876
|
import_crypto6 = require("crypto");
|
|
29778
29877
|
init_agent2();
|
|
29779
29878
|
init_runtime_v2();
|
|
29780
|
-
|
|
29879
|
+
import_promises22 = require("fs/promises");
|
|
29781
29880
|
import_os2 = require("os");
|
|
29782
|
-
|
|
29881
|
+
import_path7 = require("path");
|
|
29783
29882
|
OPENCODE_CODE_MODE_ENV = "OPENCODE_EXPERIMENTAL_CODE_MODE";
|
|
29784
29883
|
OPENCODE_CODE_MODE_TOOL = "execute";
|
|
29785
29884
|
CODE_MODE_CALLS_META = "alanToolCalls";
|
|
@@ -30025,16 +30124,16 @@ function classifyAcpError(error62) {
|
|
|
30025
30124
|
return classifyAcpText(acpErrorText(error62));
|
|
30026
30125
|
}
|
|
30027
30126
|
function within(root, path4) {
|
|
30028
|
-
const rel = (0,
|
|
30029
|
-
return rel === "" || !rel.startsWith(`..${
|
|
30127
|
+
const rel = (0, import_path8.relative)(root, path4);
|
|
30128
|
+
return rel === "" || !rel.startsWith(`..${import_path8.sep}`) && rel !== ".." && !(0, import_path8.isAbsolute)(rel);
|
|
30030
30129
|
}
|
|
30031
30130
|
async function resolveReal(path4) {
|
|
30032
30131
|
try {
|
|
30033
|
-
return await (0,
|
|
30132
|
+
return await (0, import_promises23.realpath)(path4);
|
|
30034
30133
|
} catch {
|
|
30035
|
-
const parent = (0,
|
|
30134
|
+
const parent = (0, import_path8.dirname)(path4);
|
|
30036
30135
|
if (parent === path4) return path4;
|
|
30037
|
-
return (0,
|
|
30136
|
+
return (0, import_path8.join)(await resolveReal(parent), (0, import_path8.basename)(path4));
|
|
30038
30137
|
}
|
|
30039
30138
|
}
|
|
30040
30139
|
function sliceLines(text3, params) {
|
|
@@ -30049,7 +30148,7 @@ function createWorkspaceFs(roots, writable) {
|
|
|
30049
30148
|
const realRoots = Promise.all(roots.map((root) => resolveReal(root)));
|
|
30050
30149
|
const confined = async (params) => {
|
|
30051
30150
|
const path4 = asString(params.path);
|
|
30052
|
-
if (!(0,
|
|
30151
|
+
if (!(0, import_path8.isAbsolute)(path4)) throw new FsDenied(`fs path must be absolute: ${path4 || "(empty)"}`);
|
|
30053
30152
|
const real = await resolveReal(path4);
|
|
30054
30153
|
if (!(await realRoots).some((root) => within(root, real))) {
|
|
30055
30154
|
throw new FsDenied(`${path4} is outside the session's workspace`);
|
|
@@ -30059,14 +30158,14 @@ function createWorkspaceFs(roots, writable) {
|
|
|
30059
30158
|
return {
|
|
30060
30159
|
read: async (params) => {
|
|
30061
30160
|
const path4 = await confined(params);
|
|
30062
|
-
const bytes = await (0,
|
|
30161
|
+
const bytes = await (0, import_promises23.readFile)(path4);
|
|
30063
30162
|
if (bytes.byteLength > MAX_READ_BYTES) throw new FsDenied(`${path4} is too large to read`);
|
|
30064
30163
|
return { content: sliceLines(bytes.toString("utf8"), params) };
|
|
30065
30164
|
},
|
|
30066
30165
|
write: async (params) => {
|
|
30067
30166
|
if (!writable) throw new FsDenied("This session is read-only");
|
|
30068
30167
|
const path4 = await confined(params);
|
|
30069
|
-
await (0,
|
|
30168
|
+
await (0, import_promises23.writeFile)(path4, asString(params.content));
|
|
30070
30169
|
return {};
|
|
30071
30170
|
}
|
|
30072
30171
|
};
|
|
@@ -30669,7 +30768,7 @@ async function acpTurnInput(run2, context) {
|
|
|
30669
30768
|
const encoded = await Promise.all(
|
|
30670
30769
|
images.map(async (image) => ({
|
|
30671
30770
|
mimeType: image.mimeType,
|
|
30672
|
-
data: (await (0,
|
|
30771
|
+
data: (await (0, import_promises24.readFile)(image.path)).toString("base64")
|
|
30673
30772
|
}))
|
|
30674
30773
|
);
|
|
30675
30774
|
return {
|
|
@@ -30678,23 +30777,23 @@ async function acpTurnInput(run2, context) {
|
|
|
30678
30777
|
...encoded.length ? { images: encoded, imagePaths: images.map((image) => image.path) } : {}
|
|
30679
30778
|
};
|
|
30680
30779
|
}
|
|
30681
|
-
var
|
|
30780
|
+
var import_promises23, import_path8, import_crypto7, import_promises24, CURSOR_ASK_QUESTION, copilotAcpProfile, cursorAcpProfile, MODEL_REJECTED, MAX_READ_BYTES, FsDenied, ENV_REFERENCE, AcpBackgroundTasks, CURSOR_CREATE_PLAN, STATUSES2, READ_KINDS, ALLOW_KINDS, REJECT_KINDS, CANCELLED_PERMISSION, STOP_REASONS, CHUNKS, ECHOES, AcpTurn, STDERR_TAIL_LINES2, MAX_BETWEEN_UPDATES, AcpSession, DEFAULTS, CLIENT_INFO, TASK_BACKGROUNDED, TASK_COMPLETED, SESSION_NOTIFICATION, KILLED_STATUSES, SUCCESS_STATUSES, SUBAGENT_ID, grokTaskDialect, grokAcpProfile, kimiAcpProfile, ACP_PROFILES, ACP_MODES;
|
|
30682
30781
|
var init_acp2 = __esm({
|
|
30683
30782
|
"../agent-core/dist/providers/acp.js"() {
|
|
30684
30783
|
"use strict";
|
|
30685
|
-
|
|
30784
|
+
init_chunk_CGBCAZEN();
|
|
30686
30785
|
init_chunk_AF3IPGDT();
|
|
30687
30786
|
init_chunk_WYNUYKKN();
|
|
30688
|
-
|
|
30787
|
+
init_chunk_A5UQ6YFO();
|
|
30689
30788
|
init_chunk_7FJ7QKFN();
|
|
30690
30789
|
init_chunk_OSECDZA5();
|
|
30691
30790
|
init_chunk_YXWJW7I5();
|
|
30692
|
-
|
|
30693
|
-
|
|
30791
|
+
import_promises23 = require("fs/promises");
|
|
30792
|
+
import_path8 = require("path");
|
|
30694
30793
|
init_effort();
|
|
30695
30794
|
init_acp();
|
|
30696
30795
|
import_crypto7 = require("crypto");
|
|
30697
|
-
|
|
30796
|
+
import_promises24 = require("fs/promises");
|
|
30698
30797
|
init_agent2();
|
|
30699
30798
|
CURSOR_ASK_QUESTION = "cursor/ask_question";
|
|
30700
30799
|
copilotAcpProfile = {
|
|
@@ -32255,14 +32354,14 @@ function getJson(url3, headers, timeout, signal) {
|
|
|
32255
32354
|
outgoing.end();
|
|
32256
32355
|
});
|
|
32257
32356
|
}
|
|
32258
|
-
async function fetchAlanCodeModels(
|
|
32357
|
+
async function fetchAlanCodeModels(access8, options = {}) {
|
|
32259
32358
|
const clock = options.clock ?? systemClock2;
|
|
32260
32359
|
const deadline = clock.monotonic() + ACTIVATION_WAIT_MS;
|
|
32261
|
-
const url3 = new URL(ALAN_CODE_CATALOG_PATH,
|
|
32360
|
+
const url3 = new URL(ALAN_CODE_CATALOG_PATH, access8.apiOrigin);
|
|
32262
32361
|
const headers = {
|
|
32263
32362
|
Accept: "application/json",
|
|
32264
|
-
Authorization:
|
|
32265
|
-
[MANAGED_MCP_CONVERSATION_HEADER]:
|
|
32363
|
+
Authorization: access8.authorization,
|
|
32364
|
+
[MANAGED_MCP_CONVERSATION_HEADER]: access8.conversationId
|
|
32266
32365
|
};
|
|
32267
32366
|
for (; ; ) {
|
|
32268
32367
|
options.signal?.throwIfAborted();
|
|
@@ -32286,13 +32385,13 @@ function alanCodeEngineBinary(platform3) {
|
|
|
32286
32385
|
return platform3 === "win32" ? "opencode.exe" : "opencode";
|
|
32287
32386
|
}
|
|
32288
32387
|
function packagedAlanCodeEnginePath(bundle, platform3) {
|
|
32289
|
-
return (0,
|
|
32388
|
+
return (0, import_path9.join)((0, import_path9.dirname)(bundle), "..", "engine", alanCodeEngineBinary(platform3));
|
|
32290
32389
|
}
|
|
32291
32390
|
function isRunnableFile(path4, platform3) {
|
|
32292
32391
|
try {
|
|
32293
|
-
if (!(0,
|
|
32392
|
+
if (!(0, import_fs7.statSync)(path4).isFile()) return false;
|
|
32294
32393
|
if (platform3 === "win32") return WINDOWS_RUNNABLE_EXTENSION.test(path4);
|
|
32295
|
-
(0,
|
|
32394
|
+
(0, import_fs7.accessSync)(path4, import_fs7.constants.X_OK);
|
|
32296
32395
|
return true;
|
|
32297
32396
|
} catch {
|
|
32298
32397
|
return false;
|
|
@@ -32488,13 +32587,13 @@ export const AlanEnginePlugin = async () => ({
|
|
|
32488
32587
|
`;
|
|
32489
32588
|
}
|
|
32490
32589
|
function alanCodeEngineRoot(home) {
|
|
32491
|
-
return (0,
|
|
32590
|
+
return (0, import_path10.join)(home, ".alan", "alan-code", "engine");
|
|
32492
32591
|
}
|
|
32493
32592
|
function alanCodeEngineDirectories(root) {
|
|
32494
32593
|
return {
|
|
32495
|
-
XDG_DATA_HOME: (0,
|
|
32496
|
-
XDG_STATE_HOME: (0,
|
|
32497
|
-
XDG_CACHE_HOME: (0,
|
|
32594
|
+
XDG_DATA_HOME: (0, import_path10.join)(root, "share"),
|
|
32595
|
+
XDG_STATE_HOME: (0, import_path10.join)(root, "state"),
|
|
32596
|
+
XDG_CACHE_HOME: (0, import_path10.join)(root, "cache")
|
|
32498
32597
|
};
|
|
32499
32598
|
}
|
|
32500
32599
|
function bearerToken(authorization) {
|
|
@@ -32510,8 +32609,8 @@ function alanCodeEngineEnv(input2) {
|
|
|
32510
32609
|
};
|
|
32511
32610
|
}
|
|
32512
32611
|
function openCodeGlobalConfigDirectory(env, home) {
|
|
32513
|
-
const configHome = env.XDG_CONFIG_HOME?.trim() || (0,
|
|
32514
|
-
return (0,
|
|
32612
|
+
const configHome = env.XDG_CONFIG_HOME?.trim() || (0, import_path10.join)(home, ".config");
|
|
32613
|
+
return (0, import_path10.join)(configHome, "opencode");
|
|
32515
32614
|
}
|
|
32516
32615
|
function stripJsonc(text3) {
|
|
32517
32616
|
let out = "";
|
|
@@ -32570,7 +32669,7 @@ function parseJsonc(text3) {
|
|
|
32570
32669
|
async function inheritedMcpServerNames(configDirectory) {
|
|
32571
32670
|
const names = /* @__PURE__ */ new Set();
|
|
32572
32671
|
for (const file2 of ["config.json", "opencode.json", "opencode.jsonc"]) {
|
|
32573
|
-
const text3 = await (0,
|
|
32672
|
+
const text3 = await (0, import_promises25.readFile)((0, import_path10.join)(configDirectory, file2), "utf8").catch(() => null);
|
|
32574
32673
|
if (text3 === null) continue;
|
|
32575
32674
|
const parsed = parseJsonc(text3);
|
|
32576
32675
|
const mcp = parsed !== null && typeof parsed === "object" ? parsed.mcp : void 0;
|
|
@@ -32582,20 +32681,20 @@ async function inheritedMcpServerNames(configDirectory) {
|
|
|
32582
32681
|
}
|
|
32583
32682
|
async function writePlugin(directory, apiOrigin) {
|
|
32584
32683
|
const origin = (0, import_crypto8.createHash)("sha256").update(apiOrigin).digest("hex").slice(0, 12);
|
|
32585
|
-
const target = (0,
|
|
32684
|
+
const target = (0, import_path10.join)(directory, `engine-plugin-v${ALAN_CODE_ENGINE_PLUGIN_VERSION}-${origin}.mjs`);
|
|
32586
32685
|
const temporary = `${target}.${(0, import_crypto8.randomUUID)()}.tmp`;
|
|
32587
|
-
await (0,
|
|
32588
|
-
await (0,
|
|
32589
|
-
await (0,
|
|
32686
|
+
await (0, import_promises25.mkdir)(directory, { recursive: true, mode: 448 });
|
|
32687
|
+
await (0, import_promises25.writeFile)(temporary, alanCodeEnginePluginSource(apiOrigin), { mode: 384 });
|
|
32688
|
+
await (0, import_promises25.rename)(temporary, target);
|
|
32590
32689
|
return (0, import_url.pathToFileURL)(target).href;
|
|
32591
32690
|
}
|
|
32592
32691
|
async function prepareAlanCodeProfile(input2) {
|
|
32593
32692
|
const directories = Object.values(alanCodeEngineDirectories(input2.engineRoot));
|
|
32594
32693
|
await Promise.all(
|
|
32595
|
-
directories.map((directory) => (0,
|
|
32694
|
+
directories.map((directory) => (0, import_promises25.mkdir)(directory, { recursive: true, mode: 448 }))
|
|
32596
32695
|
);
|
|
32597
32696
|
const [pluginUrl, models, inheritedMcpServers] = await Promise.all([
|
|
32598
|
-
writePlugin((0,
|
|
32697
|
+
writePlugin((0, import_path10.join)(input2.engineRoot, "plugin"), input2.access.apiOrigin),
|
|
32599
32698
|
(input2.loadModels ?? fetchAlanCodeModels)(input2.access),
|
|
32600
32699
|
input2.globalConfigDirectory === void 0 ? Promise.resolve([]) : inheritedMcpServerNames(input2.globalConfigDirectory)
|
|
32601
32700
|
]);
|
|
@@ -32617,7 +32716,7 @@ function alanCodeSystemPrompt(alanSystemPrompt) {
|
|
|
32617
32716
|
|
|
32618
32717
|
${instructions}` : ALAN_CODE_TOOL_NAMING_PROMPT;
|
|
32619
32718
|
}
|
|
32620
|
-
var import_http9, import_https,
|
|
32719
|
+
var import_http9, import_https, import_fs7, import_path9, import_crypto8, import_promises25, import_path10, import_url, ALAN_CODE_BASELINE_PROMPT, ALAN_CODE_ENGINE_PROVIDER_ID, DEFAULT_CONTEXT_WINDOW, DEFAULT_MAX_OUTPUT_TOKENS, ALAN_CODE_API_KEY_ENV, ALAN_CODE_CONVERSATION_ID_ENV, ALAN_CODE_PROXY_PATH, ALAN_CODE_WEBSEARCH_PATH, ALAN_CODE_CATALOG_PATH, ALAN_CODE_CHUNK_TIMEOUT_MS, CATALOG_TIMEOUT_MS, MAX_CATALOG_BYTES, ACTIVATION_WAIT_MS, ACTIVATION_POLL_MS, CatalogResponseError, ALAN_CODE_ENGINE_PATH_ENV, ALAN_CODE_ENGINE_COMMAND, ALAN_CODE_ENGINE_NAME, WINDOWS_RUNNABLE_EXTENSION, ALAN_CODE_ENGINE_PLUGIN_VERSION, ALAN_CODE_TOOL_NAMING_PROMPT;
|
|
32621
32720
|
var init_alan_code = __esm({
|
|
32622
32721
|
"../agent-core/dist/providers/alan-code.js"() {
|
|
32623
32722
|
"use strict";
|
|
@@ -32628,12 +32727,12 @@ var init_alan_code = __esm({
|
|
|
32628
32727
|
init_runtime_v2();
|
|
32629
32728
|
init_runtime_v2();
|
|
32630
32729
|
init_models();
|
|
32631
|
-
|
|
32632
|
-
|
|
32730
|
+
import_fs7 = require("fs");
|
|
32731
|
+
import_path9 = require("path");
|
|
32633
32732
|
init_runtime_v2();
|
|
32634
32733
|
import_crypto8 = require("crypto");
|
|
32635
|
-
|
|
32636
|
-
|
|
32734
|
+
import_promises25 = require("fs/promises");
|
|
32735
|
+
import_path10 = require("path");
|
|
32637
32736
|
import_url = require("url");
|
|
32638
32737
|
ALAN_CODE_BASELINE_PROMPT = "You are alan-code, an interactive CLI coding agent that helps users with software engineering tasks. Use the instructions below and the tools available to you to assist the user.\n\nDo not invent URLs. Use verified URLs or ones supplied by the user or project.\n\nIf the user asks for help or wants to give feedback, inform them of the following:\n- `--harness-help` / harness help: learn how to run alan-code\n- For product feedback or bugs, report through the Alan / Supatest issue channels used by this repository\n\nWhen the user directly asks about alan-code capabilities (for example \"can alan-code\u2026\", \"does the harness have\u2026\") or asks in second person about your abilities, answer from the tools and instructions available in this session. If a docs/fetch tool is available and project docs URLs are known, use them; otherwise inspect local README / AGENTS.md rather than inventing product claims.\n\n# Personality\n\nYour default personality and tone is concise, direct, and friendly. You communicate efficiently, always keeping the user clearly informed about ongoing actions without unnecessary detail. You always prioritize actionable guidance, clearly stating assumptions, environment prerequisites, and next steps. Unless explicitly asked, you avoid excessively verbose explanations about your work.\n\n# Tone and style\n\nYou should be concise, direct, and to the point. When you run a non-trivial bash command, you should explain what the command does and why you are running it, so the user understands what you are doing (especially important for commands that change their system).\nRemember that your output will be displayed on a command line interface. Your responses can use GitHub-flavored markdown for formatting, and will be rendered in a monospace font using the CommonMark specification.\nOutput text to communicate with the user; all text you output outside of tool use is displayed to the user. Only use tools to complete tasks. Never use tools like Bash or code comments as means to communicate with the user during the session.\nIf you cannot or will not help the user with something, do not lecture about why. Offer helpful alternatives if possible; otherwise keep the response to 1-2 sentences.\nOnly use emojis if the user explicitly requests it. Avoid emojis in all communication unless asked.\nIMPORTANT: Minimize output tokens while staying helpful, correct, and accurate. Only address the specific query or task. Avoid tangential information unless it is critical to completing the request. If you can answer in 1-3 sentences or a short paragraph, do that.\nAnswer the user's question directly. One-word answers are best when they suffice. Avoid text before/after your response such as \"The answer is <answer>.\", \"Here is the content of the file\u2026\", \"Based on the information provided\u2026\", or \"Here is what I will do next\u2026\". Examples of appropriate verbosity:\n<example>\nuser: what is 2+2?\nassistant: 4\n</example>\n\n<example>\nuser: is 11 a prime number?\nassistant: Yes\n</example>\n\n<example>\nuser: what command should I run to list files in the current directory?\nassistant: ls\n</example>\n\n<example>\nuser: what command should I run to watch files in the current directory?\nassistant: [use tools to inspect the project, then answer]\nnpm run dev\n</example>\n\n<example>\nuser: what files are in the directory src/?\nassistant: [lists files and sees foo.c, bar.c, baz.c]\nuser: which file contains the implementation of foo?\nassistant: src/foo.c\n</example>\n\n<example>\nuser: write tests for new feature\nassistant: [searches for similar tests, reads relevant files concurrently, edits/writes tests]\n</example>\n\n# Responsiveness\n\n## Preamble messages\n\nBefore making tool calls, send a brief preamble to the user explaining what you're about to do. When sending preamble messages, follow these principles and examples:\n\n- **Logically group related actions**: if you're about to run several related commands, describe them together in one preamble rather than sending a separate note for each.\n- **Keep it concise**: be no more than 1-2 sentences, focused on immediate, tangible next steps. (8\u201312 words for quick updates).\n- **Build on prior context**: if this is not your first tool call, use the preamble message to connect the dots with what's been done so far and create a sense of momentum and clarity for the user to understand your next actions.\n- **Keep your tone light, friendly and curious**: add small touches of personality in preambles feel collaborative and engaging.\n- **Exception**: Avoid adding a preamble for every trivial read (e.g., `cat` a single file) unless it's part of a larger grouped action.\n\nExamples:\n\n- \"I've explored the repo; now checking the API route definitions.\"\n- \"Next, I'll patch the config and update the related tests.\"\n- \"I'm about to scaffold the CLI commands and helper functions.\"\n- \"Ok cool, so I've wrapped my head around the repo. Now digging into the API routes.\"\n- \"Config's looking tidy. Next up is patching helpers to keep things in sync.\"\n- \"Finished poking at the DB gateway. I will now chase down error handling.\"\n- \"Alright, build pipeline order is interesting. Checking how it reports failures.\"\n- \"Spotted a clever caching util; now hunting where it gets used.\"\n\n# Planning\n\nIf a planning tool is available, use it when it helps track complex work. Keep the plan brief and update it as work progresses.\n\nNote that plans are not for padding out simple work with filler steps or stating the obvious. The content of your plan should not involve doing anything that you aren't capable of doing (i.e. don't try to test things that you can't test). Do not use plans for simple or single-step queries that you can just do or answer immediately.\n\nWhen a planning tool displays the plan, summarize only what changed or what comes next.\n\nKeep any active plan aligned with the work completed and remaining.\n\nUse a plan when:\n\n- The task is non-trivial and will require multiple actions over a long time horizon.\n- There are logical phases or dependencies where sequencing matters.\n- The work has ambiguity that benefits from outlining high-level goals.\n- You want intermediate checkpoints for feedback and validation.\n- When the user asked you to do more than one thing in a single prompt\n- The user has asked you to use the plan tool (aka \"TODOs\")\n- You generate additional steps while working, and plan to do them before yielding to the user\n\n## Examples\n\n**High-quality plans**\n\nExample 1:\n\n1. Add CLI entry with file args\n2. Parse Markdown via CommonMark library\n3. Apply semantic HTML template\n4. Handle code blocks, images, links\n5. Add error handling for invalid files\n\nExample 2:\n\n1. Define CSS variables for colors\n2. Add toggle with localStorage state\n3. Refactor components to use variables\n4. Verify all views for readability\n5. Add smooth theme-change transition\n\nExample 3:\n\n1. Set up Node.js + WebSocket server\n2. Add join/leave broadcast events\n3. Implement messaging with timestamps\n4. Add usernames + mention highlighting\n5. Persist messages in lightweight DB\n6. Add typing indicators + unread count\n\n**Low-quality plans**\n\nExample 1:\n\n1. Create CLI tool\n2. Add Markdown parser\n3. Convert to HTML\n\nExample 2:\n\n1. Add dark mode toggle\n2. Save preference\n3. Make styles look good\n\nExample 3:\n\n1. Create single-file HTML game\n2. Run quick sanity check\n3. Summarize usage instructions\n\nIf you need to write a plan, only write high quality plans, not low quality ones.\n\n## Plan mode and clarification (harness specifics)\n\n- When the session is in plan mode, inspect without making changes and produce a concrete plan. Outside plan mode, proceed with authorized work and ask for approval only when the action requires it.\n- Prefer the durable plan file path over relying on chat memory after compaction.\n- When requirements are ambiguous, ask a targeted question using an available user-input tool instead of guessing.\n- An execution checklist is not a substitute for a durable plan when the task requires one.\n\n# Task execution\n\nYou are a coding agent. Please keep going until the query is completely resolved, before ending your turn and yielding back to the user. Only terminate your turn when you are sure that the problem is solved. Autonomously resolve the query to the best of your ability, using the tools available to you, before coming back to the user. Do NOT guess or make up an answer.\n\nYou MUST adhere to the following criteria when solving queries:\n\n- Working on the repo(s) in the current environment is allowed, even if they are proprietary.\n- Analyzing code for vulnerabilities is allowed.\n- Showing user code and tool call details is allowed.\n- Use the editing tools available in the current host to modify files. Do not assume a particular tool name.\n\nIf completing the user's task requires writing or modifying files, your code and final answer should follow these coding guidelines, though user instructions (i.e. AGENTS.md) may override these guidelines:\n\n- Fix the problem at the root cause rather than applying surface-level patches, when possible.\n- Avoid unneeded complexity in your solution.\n- Do not attempt to fix unrelated bugs or broken tests. It is not your responsibility to fix them. (You may mention them to the user in your final message though.)\n- Update documentation as necessary.\n- Keep changes consistent with the style of the existing codebase. Changes should be minimal and focused on the task.\n- Use `git log` and `git blame` to search the history of the codebase if additional context is required.\n- NEVER add copyright or license headers unless specifically requested.\n- Do not waste tokens by re-reading files after editing them. The tool call will fail if it didn't work. The same goes for making folders, deleting folders, etc.\n- Do not `git commit` your changes or create new git branches unless explicitly requested.\n- Add comments when they explain a non-obvious invariant or reason for a decision.\n- Do not use one-letter variable names unless explicitly requested.\n- NEVER output inline citations like \"\u3010F:README.md\u2020L5-L14\u3011\" in your outputs. The CLI is not able to render these so they will just be broken in the UI. Instead, if you output valid filepaths, users will be able to click on them to open the files in their editor.\n\n# Validating your work\n\nIf the codebase has tests or the ability to build or run, consider using them to verify that your work is complete.\n\nWhen testing, your philosophy should be to start as specific as possible to the code you changed so that you can catch issues efficiently, then make your way to broader tests as you build confidence. If there's no test for the code you changed, and if the adjacent patterns in the codebases show that there's a logical place for you to add a test, you may do so. However, do not add tests to codebases with no tests.\n\nSimilarly, once you're confident in correctness, you can suggest or use formatting commands to ensure that your code is well formatted. If there are issues you can iterate up to 3 times to get formatting right, but if you still can't manage it's better to save the user time and present them a correct solution where you call out the formatting in your final message. If the codebase does not have a formatter configured, do not add one.\n\nFor all of testing, running, building, and formatting, do not attempt to fix unrelated bugs. It is not your responsibility to fix them. (You may mention them to the user in your final message though.)\n\nBe mindful of whether to run validation commands proactively. In the absence of behavioral guidance:\n\n- When running in a non-interactive mode where edits are auto-approved (print/headless, or the `allow edits` permission mode), proactively run tests, lint and do whatever you need to ensure you've completed the task.\n- In plan mode, stay read-only. Otherwise, run focused checks after changes when the host permits them.\n- When working on test-related tasks, such as adding tests, fixing tests, or reproducing a bug to verify behavior, you may proactively run tests regardless of permission mode. Use your judgement to decide whether this is a test-related task.\n\n# Ambition vs. precision\n\nFor tasks that have no prior context (i.e. the user is starting something brand new), you should feel free to be ambitious and demonstrate creativity with your implementation.\n\nIf you're operating in an existing codebase, you should make sure you do exactly what the user asks with surgical precision. Treat the surrounding codebase with respect, and don't overstep (i.e. changing filenames or variables unnecessarily). You should balance being sufficiently ambitious and proactive when completing tasks of this nature.\n\nYou should use judicious initiative to decide on the right level of detail and complexity to deliver based on the user's needs. This means showing good judgment that you're capable of doing the right extras without gold-plating. This might be demonstrated by high-value, creative touches when scope of the task is vague; while being surgical and targeted when scope is tightly specified.\n\n# Sharing progress updates\n\nFor especially longer tasks that you work on (i.e. requiring many tool calls, or a plan with multiple steps), you should provide progress updates back to the user at reasonable intervals. These updates should be structured as a concise sentence or two (no more than 8-10 words long) recapping progress so far in plain language: this update demonstrates your understanding of what needs to be done, progress so far (i.e. files explores, subtasks complete), and where you're going next.\n\nBefore doing large chunks of work that may incur latency as experienced by the user (i.e. writing a new file), you should send a concise message to the user with an update indicating what you're about to do to ensure they know what you're spending time on. Don't start editing or writing large files before informing the user what you are doing and why.\n\nThe messages you send before tool calls should describe what is immediately about to be done next in very concise language. If there was previous work done, this preamble message should also include a note about the work done so far to bring the user along.\n\n# Presenting your work and final message\n\nYour final message should read naturally, like an update from a concise teammate. For casual conversation, brainstorming tasks, or quick questions from the user, respond in a friendly, conversational tone. You should ask questions, suggest ideas, and adapt to the user's style. If you've finished a large amount of work, when describing what you've done to the user, you should follow the final answer formatting guidelines to communicate substantive changes. You don't need to add structured formatting for one-word answers, greetings, or purely conversational exchanges.\n\nYou can skip heavy formatting for single, simple actions or confirmations. In these cases, respond in plain sentences with any relevant next step or quick option. Reserve multi-section structured responses for results that need grouping or explanation.\n\nThe user is working on the same computer as you, and has access to your work. As such there's no need to show the full contents of large files you have already written unless the user explicitly asks for them. Similarly, if you've created or modified files, there's no need to tell users to \"save the file\" or \"copy the code into a file\"\u2014just reference the file path.\n\nComplete authorized next steps, including relevant tests. Ask before a consequential action that needs approval, and briefly report anything you could not verify.\n\nBrevity is very important as a default. You should be very concise (i.e. no more than 10 lines), but can relax this requirement for tasks where additional detail and comprehensiveness is important for the user's understanding.\n\n## Final answer structure and style guidelines\n\nYou are producing plain text that will later be styled by the CLI. Follow these rules exactly. Formatting should make results easy to scan, but not feel mechanical. Use judgment to decide how much structure adds value.\n\n**Section Headers**\n\n- Use only when they improve clarity \u2014 they are not mandatory for every answer.\n- Choose descriptive names that fit the content\n- Keep headers short (1\u20133 words) and in `**Title Case**`. Always start headers with `**` and end with `**`\n- Use the blank lines required by the renderer for headings and lists.\n- Section headers should only be used where they genuinely improve scanability; avoid fragmenting the answer.\n\n**Bullets**\n\n- Use `-` followed by a space for every bullet.\n- Merge related points when possible; avoid a bullet for every trivial detail.\n- Keep bullets to one line unless breaking for clarity is unavoidable.\n- Group into short lists (4\u20136 bullets) ordered by importance.\n- Use consistent keyword phrasing and formatting across sections.\n\n**Monospace**\n\n- Wrap all commands, file paths, env vars, and code identifiers in backticks (`` `...` ``).\n- Apply to inline examples and to bullet keywords if the keyword itself is a literal file/command.\n- Never mix monospace and bold markers; choose one based on whether it's a keyword (`**`) or inline code/path (`` ` ``).\n\n**File References**\n\nWhen referencing files in your response, make sure to include the relevant start line and always follow the below rules:\n\n- Use inline code to make file paths clickable.\n- Each reference should have a stand alone path. Even if it's the same file.\n- Accepted: absolute, workspace\u2011relative, a/ or b/ diff prefixes, or bare filename/suffix.\n- Line/column (1\u2011based, optional): :line[:column] or #Lline[Ccolumn] (column defaults to 1).\n- Do not use URIs like file://, vscode://, or https://.\n- Do not provide range of lines\n- Examples: src/app.ts, src/app.ts:42, b/server/index.js#L10, C:\\repo\\project\\main.rs:12:5\n\n**Structure**\n\n- Place related bullets together; don't mix unrelated concepts in the same section.\n- Order sections from general \u2192 specific \u2192 supporting info.\n- For subsections (e.g., \"Binaries\" under \"Rust Workspace\"), introduce with a bolded keyword bullet, then list items under it.\n- Match structure to complexity:\n - Multi-part or detailed results \u2192 use clear headers and grouped bullets.\n - Simple results \u2192 minimal headers, possibly just a short list or paragraph.\n\n**Tone**\n\n- Keep the voice collaborative and natural, like a coding partner handing off work.\n- Be concise and factual \u2014 no filler or conversational commentary and avoid unnecessary repetition\n- Use present tense and active voice (e.g., \"Runs tests\" not \"This will run tests\").\n- Keep descriptions self-contained; don't refer to \"above\" or \"below\".\n- Use parallel structure in lists for consistency.\n\n**Don't**\n\n- Don't use literal words \"bold\" or \"monospace\" in the content.\n- Don't nest bullets or create deep hierarchies.\n- Don't output ANSI escape codes directly \u2014 the CLI renderer applies them.\n- Don't cram unrelated keywords into a single bullet; split for clarity.\n- Don't let keyword lists run long \u2014 wrap or reformat for scanability.\n\nGenerally, ensure your final answers adapt their shape and depth to the request. For example, answers to code explanations should have a precise, structured explanation with code references that answer the question directly. For tasks with a simple implementation, lead with the outcome and supplement only with what's needed for clarity. Larger changes can be presented as a logical walkthrough of your approach, grouping related steps, explaining rationale where it adds value, and highlighting next actions to accelerate the user. Your answers should provide the right level of detail while being easily scannable.\n\nFor casual greetings, acknowledgements, or other one-off conversational messages that are not delivering substantive information or structured results, respond naturally without section headers or bullet formatting.\n\n# Professional objectivity\n\nPrioritize technical accuracy and truthfulness over validating the user's beliefs. Focus on facts and problem-solving. Be direct and objective without unnecessary praise or emotional validation. Disagree when needed. When uncertain, investigate before confirming the user's assumptions.\n\n# Proactiveness\n\nProactively complete work that follows from the user's request. Avoid unrelated actions that would surprise the user. Strike a balance between:\n\n1. Doing the right thing when asked, including follow-up actions\n2. Not surprising the user with unrequested actions\n For example, if the user asks how to approach something, answer first; do not immediately jump into edits.\n\n# Following conventions\n\nWhen changing files, first understand the file's conventions. Mimic code style, use existing libraries and utilities, and follow existing patterns.\n\n- NEVER assume a library is available, even if it is well known. Whenever you write code that uses a library or framework, first check that this codebase already uses it (neighboring files, package.json, cargo.toml, go.mod, etc.).\n- When creating a new component, first look at existing components for framework choice, naming, typing, and other conventions.\n- When editing code, first look at surrounding context (especially imports) to understand chosen frameworks/libraries, then make the change idiomatically.\n- Always follow security best practices. Never introduce code that exposes or logs secrets and keys. Never commit secrets or keys to the repository.\n\n# Doing tasks\n\nThe user will primarily request software engineering tasks: bugs, features, refactors, explanations, and more. Recommended steps:\n\n- Use available search/read tools extensively to understand the codebase and the query (in parallel when independent).\n- Implement the solution with the tools available to you.\n- Prefer editing existing files. Create documentation when the task or project instructions require it.\n- Verify when possible with tests. NEVER assume a specific test framework or script \u2014 check README / AGENTS.md or search the repo.\n- Run lint and typecheck commands (for example npm run lint, npm run typecheck, ruff, pnpm lint) if they were provided to you \u2014 see Validating your work for when to run them proactively vs. when to hold off. If you cannot find the correct command, ask the user, and if they supply it, proactively suggest writing it to AGENTS.md so you know next time.\n\n- Tool results and user messages may include <system-reminder> tags. Those tags contain useful reminders. They are NOT part of the user's provided input or the tool result.\n\n# Tool usage policy\n\n- Prefer specialized file tools over shell for reading, editing, writing, listing, and searching when those tools are available. Use the `grep`, `glob`, and `list` tools instead of bash for search and listing \u2014 they are ripgrep-backed and return structured, length-capped results. Use shell for real system commands (git, package managers, builds, tests, process control).\n- When doing broad codebase exploration, use the available search tools and delegate only when the task benefits from independent work.\n- You can call multiple tools in one response. When multiple independent pieces of information are needed, batch tool calls for performance. When making multiple bash tool calls, send a single message with multiple tool calls so they can run in parallel (for example git status and git diff together).\n- Match edit old-text exactly, including whitespace.\n- If a tool call is denied by policy, adapt: use an allowed approach or ask the user. Do not retry the same blocked call in a loop.\n\n## Shell commands\n\nWhen using the shell, you must adhere to the following guidelines:\n\n- When searching for text or files, prefer using `rg` or `rg --files` respectively because `rg` is much faster than alternatives like `grep` and `find`. (If the `rg` command is not found, then use alternatives.) Reach for the shell only when the `grep`/`glob` tools cannot express the query \u2014 for example counting matches, or piping results into another command.\n- Search narrow first: use `rg -l` or `rg -c` to find which files match, then read only those files. Do not dump full match bodies across a repo into context.\n- Never pipe a large file into your context. Do not `cat` a big file; use the `read` tool with an offset/limit, or `sed -n 'START,ENDp'` for a specific range.\n- Do not use python scripts to attempt to output larger chunks of a file.\n\nIMPORTANT: Before you begin work, think about what the code you're editing is supposed to do based on the filenames and directory structure.\n\n# AGENTS.md spec\n\n- Repos often contain AGENTS.md files. These files can appear anywhere within the repository.\n- These files are a way for humans to give you (the agent) instructions or tips for working within the container.\n- Some examples might be: coding conventions, info about how code is organized, or instructions for how to run or test code.\n- Instructions in AGENTS.md files:\n - The scope of an AGENTS.md file is the entire directory tree rooted at the folder that contains it.\n - For every file you touch in the final change, you must obey instructions in any AGENTS.md file whose scope includes that file.\n - Instructions about code style, structure, naming, etc. apply only to code within the AGENTS.md file's scope, unless the file states otherwise.\n - More-deeply-nested AGENTS.md files take precedence in the case of conflicting instructions.\n - Direct system/developer/user instructions (as part of a prompt) take precedence over AGENTS.md instructions.\n- The contents of the AGENTS.md file at the root of the repo and the project directory are loaded into your context automatically and don't need to be re-read. AGENTS.md files in subdirectories are NOT loaded automatically: when working in a subdirectory, or a directory outside the CWD, check for any AGENTS.md files that may be applicable.\n\n# Permissions and safety\n\n- Never commit secrets or keys.\n- Never create a git commit unless the user explicitly asks.\n- Do not run destructive commands (mass delete, force-push, hard reset) unless the user clearly requested them.\n";
|
|
32639
32738
|
ALAN_CODE_ENGINE_PROVIDER_ID = "alan";
|
|
@@ -33005,7 +33104,7 @@ function notice(kind, message2) {
|
|
|
33005
33104
|
function promptParts2(input2) {
|
|
33006
33105
|
const files = (input2.imagePaths ?? []).map((path4, index) => ({
|
|
33007
33106
|
type: "file",
|
|
33008
|
-
mime: input2.images?.[index]?.mimeType ?? IMAGE_TYPES[(0,
|
|
33107
|
+
mime: input2.images?.[index]?.mimeType ?? IMAGE_TYPES[(0, import_path12.extname)(path4).toLowerCase()] ?? "application/octet-stream",
|
|
33009
33108
|
filename: path4.split(/[\\/]/).at(-1) ?? path4,
|
|
33010
33109
|
url: (0, import_url2.pathToFileURL)(path4).href
|
|
33011
33110
|
}));
|
|
@@ -33045,10 +33144,28 @@ function judgeOpenCodeVersion(version2) {
|
|
|
33045
33144
|
function unsupportedOpenCodeMessage(version2) {
|
|
33046
33145
|
return `OpenCode ${version2} is not supported yet: Alan speaks the OpenCode ${OPENCODE_SUPPORTED_MAJOR}.x server API, which OpenCode 2 replaced. Install opencode-ai@${OPENCODE_SUPPORTED_MAJOR}.`;
|
|
33047
33146
|
}
|
|
33048
|
-
async function withDeadline2(work, clock, ms, what) {
|
|
33147
|
+
async function withDeadline2(work, clock, ms, what, code = "protocol_violation") {
|
|
33049
33148
|
work.catch(() => void 0);
|
|
33050
33149
|
if (await settlesWithin(work, clock, ms)) return work;
|
|
33051
|
-
throw new CoreFault(
|
|
33150
|
+
throw new CoreFault(code, `opencode serve did not ${what} within ${ms} ms`);
|
|
33151
|
+
}
|
|
33152
|
+
function exitFault(session) {
|
|
33153
|
+
return new CoreFault(
|
|
33154
|
+
"spawn_failed",
|
|
33155
|
+
`opencode serve exited while opening a session: ${session.outputTail}`
|
|
33156
|
+
);
|
|
33157
|
+
}
|
|
33158
|
+
function whileAlive(session, options, work) {
|
|
33159
|
+
const exited = session.exited.then(() => {
|
|
33160
|
+
throw exitFault(session);
|
|
33161
|
+
});
|
|
33162
|
+
exited.catch(() => void 0);
|
|
33163
|
+
return Promise.race([work, exited]).catch(async (error62) => {
|
|
33164
|
+
if (error62 instanceof CoreFault && error62.code === "spawn_failed") throw error62;
|
|
33165
|
+
if (await settlesWithin(session.exited, options.clock, options.stdoutDrainMs))
|
|
33166
|
+
throw exitFault(session);
|
|
33167
|
+
throw error62;
|
|
33168
|
+
});
|
|
33052
33169
|
}
|
|
33053
33170
|
function serverEnv(env, password) {
|
|
33054
33171
|
const { OPENCODE_SERVER_USERNAME: _user, OPENCODE_SERVER_PASSWORD: _password, ...rest } = env;
|
|
@@ -33126,12 +33243,12 @@ async function sameDirectory(left, right) {
|
|
|
33126
33243
|
}
|
|
33127
33244
|
async function canonicalDirectory(directory) {
|
|
33128
33245
|
try {
|
|
33129
|
-
return await (0,
|
|
33246
|
+
return await (0, import_promises26.realpath)(directory);
|
|
33130
33247
|
} catch {
|
|
33131
|
-
return (0,
|
|
33248
|
+
return (0, import_path11.resolve)(directory);
|
|
33132
33249
|
}
|
|
33133
33250
|
}
|
|
33134
|
-
async function
|
|
33251
|
+
async function checkHealth(client, log) {
|
|
33135
33252
|
const health = await client.health();
|
|
33136
33253
|
const verdict = judgeOpenCodeVersion(health.version);
|
|
33137
33254
|
log.info("opencode.healthy", { version: health.version, verdict, healthy: health.healthy });
|
|
@@ -33144,7 +33261,34 @@ async function openSession(session, client, spec, log) {
|
|
|
33144
33261
|
if (verdict === "too_new") {
|
|
33145
33262
|
throw new SessionOpenRefusal("unsupported_version", unsupportedOpenCodeMessage(health.version));
|
|
33146
33263
|
}
|
|
33147
|
-
|
|
33264
|
+
}
|
|
33265
|
+
function slowBootstrapNotice(engine, ms) {
|
|
33266
|
+
return noticeUpdate(
|
|
33267
|
+
"info",
|
|
33268
|
+
"engine_bootstrap_slow",
|
|
33269
|
+
`${engine.label} took ${Math.round(ms / 1e3)}s to start`,
|
|
33270
|
+
"A first start installs the engine's dependencies from npm into its config folder; later starts skip this."
|
|
33271
|
+
);
|
|
33272
|
+
}
|
|
33273
|
+
async function connectEvents(session, client, options) {
|
|
33274
|
+
const { clock, log, slowBootstrapMs } = options;
|
|
33275
|
+
const startedAt = clock.monotonic();
|
|
33276
|
+
const done = new AbortController();
|
|
33277
|
+
void clock.sleep(slowBootstrapMs, done.signal).then(
|
|
33278
|
+
() => log.warn("opencode.bootstrap_slow", { pid: session.pid, waitedMs: slowBootstrapMs }),
|
|
33279
|
+
() => void 0
|
|
33280
|
+
);
|
|
33281
|
+
try {
|
|
33282
|
+
await session.connect(client);
|
|
33283
|
+
} finally {
|
|
33284
|
+
done.abort();
|
|
33285
|
+
}
|
|
33286
|
+
const ms = clock.monotonic() - startedAt;
|
|
33287
|
+
if (ms < slowBootstrapMs) return [];
|
|
33288
|
+
log.info("opencode.bootstrap_done", { pid: session.pid, ms: Math.round(ms) });
|
|
33289
|
+
return [slowBootstrapNotice(options.engine, ms)];
|
|
33290
|
+
}
|
|
33291
|
+
async function openSession(client, session, spec, log) {
|
|
33148
33292
|
const resumeId = spec.resumeSessionId;
|
|
33149
33293
|
if (resumeId && await canResume(client, resumeId, log)) return { id: resumeId, resumed: true };
|
|
33150
33294
|
if (resumeId) session.resumeFailed = true;
|
|
@@ -33168,8 +33312,22 @@ async function openOnce(spec, password, options) {
|
|
|
33168
33312
|
});
|
|
33169
33313
|
try {
|
|
33170
33314
|
const client = new OpenCodeClient(url3, password, options.engine.label);
|
|
33315
|
+
const alive = (work) => whileAlive(session, options, work);
|
|
33316
|
+
await withDeadline2(
|
|
33317
|
+
alive(checkHealth(client, options.log)),
|
|
33318
|
+
options.clock,
|
|
33319
|
+
options.openTimeoutMs,
|
|
33320
|
+
"answer a health check"
|
|
33321
|
+
);
|
|
33322
|
+
const notices = await withDeadline2(
|
|
33323
|
+
alive(connectEvents(session, client, options)),
|
|
33324
|
+
options.clock,
|
|
33325
|
+
options.bootstrapTimeoutMs,
|
|
33326
|
+
"open its event stream (a first start installs engine dependencies from npm)",
|
|
33327
|
+
"spawn_failed"
|
|
33328
|
+
);
|
|
33171
33329
|
const opened = await withDeadline2(
|
|
33172
|
-
openSession(
|
|
33330
|
+
alive(openSession(client, session, spec, options.log)),
|
|
33173
33331
|
options.clock,
|
|
33174
33332
|
options.openTimeoutMs,
|
|
33175
33333
|
"open a session"
|
|
@@ -33177,7 +33335,7 @@ async function openOnce(spec, password, options) {
|
|
|
33177
33335
|
session.attach(
|
|
33178
33336
|
opened.id,
|
|
33179
33337
|
spec.prompt,
|
|
33180
|
-
expiredSignInNotices(spec.env, options.clock.now()),
|
|
33338
|
+
[...expiredSignInNotices(spec.env, options.clock.now()), ...notices],
|
|
33181
33339
|
opened.resumed
|
|
33182
33340
|
);
|
|
33183
33341
|
} catch (error62) {
|
|
@@ -33211,6 +33369,8 @@ function createOpenCodeDriver(options = {}) {
|
|
|
33211
33369
|
stdoutDrainMs: options.stdoutDrainMs ?? DEFAULTS2.stdoutDrainMs,
|
|
33212
33370
|
descendantScanMs: options.descendantScanMs ?? DEFAULTS2.descendantScanMs,
|
|
33213
33371
|
openTimeoutMs: options.openTimeoutMs ?? DEFAULTS2.openTimeoutMs,
|
|
33372
|
+
bootstrapTimeoutMs: options.bootstrapTimeoutMs ?? DEFAULTS2.bootstrapTimeoutMs,
|
|
33373
|
+
slowBootstrapMs: options.slowBootstrapMs ?? DEFAULTS2.slowBootstrapMs,
|
|
33214
33374
|
openAttempts: options.openAttempts ?? DEFAULTS2.openAttempts,
|
|
33215
33375
|
startAttempts: options.startAttempts ?? DEFAULTS2.startAttempts,
|
|
33216
33376
|
reconnectAttempts: options.reconnectAttempts ?? DEFAULTS2.reconnectAttempts,
|
|
@@ -33228,9 +33388,9 @@ function createOpenCodeDriver(options = {}) {
|
|
|
33228
33388
|
const spec = { ...planned, env: launchEnv(planned, authorization) };
|
|
33229
33389
|
const password = options.password?.() ?? (0, import_crypto10.randomBytes)(24).toString("base64url");
|
|
33230
33390
|
try {
|
|
33231
|
-
const data = spec.env.XDG_DATA_HOME ?? (0,
|
|
33391
|
+
const data = spec.env.XDG_DATA_HOME ?? (0, import_path11.join)(spec.env.HOME ?? spec.env.USERPROFILE ?? spec.cwd, ".local", "share");
|
|
33232
33392
|
const session = await withStartupLock(
|
|
33233
|
-
(0,
|
|
33393
|
+
(0, import_path11.join)(data, "opencode", ".alan-startup.lock"),
|
|
33234
33394
|
resolved.clock,
|
|
33235
33395
|
() => openWithRetries(spec, password, resolved)
|
|
33236
33396
|
);
|
|
@@ -33328,14 +33488,14 @@ function openCodeTurnInput(run2, context) {
|
|
|
33328
33488
|
...context.attachments.length ? { readableFiles: context.attachments.map((attachment) => attachment.path) } : {}
|
|
33329
33489
|
};
|
|
33330
33490
|
}
|
|
33331
|
-
var import_crypto9, import_http10, import_crypto10,
|
|
33491
|
+
var import_crypto9, import_http10, import_crypto10, import_promises26, import_path11, import_path12, import_url2, import_path13, import_crypto11, IDLE_SOCKET_MS3, OpenCodeHttpError, BASE62, messageIdClock, OpenCodeClient, OPENCODE_CONFIG_ENV, OPENCODE_ENGINE, TEXT_PARTS, STEP_PARTS, STOPPED_BY_USER, OpenCodeSubagents, NAMED_KINDS, OPENCODE_ABORTED_ERROR, PROVIDER_EVENT_META, TASK_TOOL_NAME, TASK_RESULT_TAG, TASK_ERROR_TAG, PERMISSION_DENIED, FILE_OPERATIONS, NO_USAGE, PartReader, NOTHING, NON_INTERACTIVE_PERMISSIONS, CONTENT_FILTER_FINISHES, TRUNCATED_FINISHES, OUTPUT_PARTS, OpenCodeTurn, LISTENING, OUTPUT_TAIL_LINES, IMAGE_TYPES, OpenCodeSession, OPENCODE_MIN_VERSION, OPENCODE_REQUIREMENT, OPENCODE_TESTED_LINE, OPENCODE_SUPPORTED_MAJOR, DEFAULTS2, STORE_LOCKED, NON_INTERACTIVE_RULES, TITLE_LENGTH, MAX_VARIANT_LENGTH;
|
|
33332
33492
|
var init_opencode = __esm({
|
|
33333
33493
|
"../agent-core/dist/providers/opencode.js"() {
|
|
33334
33494
|
"use strict";
|
|
33335
|
-
|
|
33495
|
+
init_chunk_CGBCAZEN();
|
|
33336
33496
|
init_chunk_AF3IPGDT();
|
|
33337
33497
|
init_chunk_WYNUYKKN();
|
|
33338
|
-
|
|
33498
|
+
init_chunk_A5UQ6YFO();
|
|
33339
33499
|
init_chunk_7FJ7QKFN();
|
|
33340
33500
|
init_chunk_OSECDZA5();
|
|
33341
33501
|
init_chunk_YXWJW7I5();
|
|
@@ -33343,13 +33503,13 @@ var init_opencode = __esm({
|
|
|
33343
33503
|
import_http10 = require("http");
|
|
33344
33504
|
init_runtime_v2();
|
|
33345
33505
|
import_crypto10 = require("crypto");
|
|
33346
|
-
|
|
33347
|
-
import_path10 = require("path");
|
|
33348
|
-
init_agent2();
|
|
33506
|
+
import_promises26 = require("fs/promises");
|
|
33349
33507
|
import_path11 = require("path");
|
|
33508
|
+
init_agent2();
|
|
33509
|
+
import_path12 = require("path");
|
|
33350
33510
|
import_url2 = require("url");
|
|
33351
33511
|
init_acp();
|
|
33352
|
-
|
|
33512
|
+
import_path13 = require("path");
|
|
33353
33513
|
init_acp();
|
|
33354
33514
|
init_constants();
|
|
33355
33515
|
import_crypto11 = require("crypto");
|
|
@@ -33987,7 +34147,7 @@ var init_opencode = __esm({
|
|
|
33987
34147
|
this.#readOnly = readOnly;
|
|
33988
34148
|
this.#memory = memory;
|
|
33989
34149
|
this.#engine = engine;
|
|
33990
|
-
this.#readableFiles = new Set(readableFiles.map((path4) => (0,
|
|
34150
|
+
this.#readableFiles = new Set(readableFiles.map((path4) => (0, import_path13.normalize)(path4)));
|
|
33991
34151
|
}
|
|
33992
34152
|
get childSessionIds() {
|
|
33993
34153
|
return [...this.#children.keys()];
|
|
@@ -34227,7 +34387,7 @@ var init_opencode = __esm({
|
|
|
34227
34387
|
#opensAttachment(kind, properties) {
|
|
34228
34388
|
if (kind !== "external_directory") return false;
|
|
34229
34389
|
const filepath = asString(asRecord(properties.metadata)?.filepath);
|
|
34230
|
-
return (0,
|
|
34390
|
+
return (0, import_path13.isAbsolute)(filepath) && this.#readableFiles.has((0, import_path13.normalize)(filepath));
|
|
34231
34391
|
}
|
|
34232
34392
|
#question(properties) {
|
|
34233
34393
|
const requestId = asString(properties.id).trim();
|
|
@@ -34717,6 +34877,8 @@ var init_opencode = __esm({
|
|
|
34717
34877
|
stdoutDrainMs: 2e3,
|
|
34718
34878
|
descendantScanMs: 5e3,
|
|
34719
34879
|
openTimeoutMs: 6e4,
|
|
34880
|
+
bootstrapTimeoutMs: 6e5,
|
|
34881
|
+
slowBootstrapMs: 5e3,
|
|
34720
34882
|
openAttempts: 2,
|
|
34721
34883
|
startAttempts: 3,
|
|
34722
34884
|
reconnectAttempts: 3,
|
|
@@ -35027,13 +35189,13 @@ function readTranscriptTurns(transcript, chunk, baseOffset, skipped = []) {
|
|
|
35027
35189
|
});
|
|
35028
35190
|
return { turns, consumedBytes: consumedEnd - baseOffset };
|
|
35029
35191
|
}
|
|
35030
|
-
var
|
|
35192
|
+
var import_fs8, NEWLINE2, TranscriptCursor, TranscriptLineLookup, CONTENT_UPDATES;
|
|
35031
35193
|
var init_chunk_VUWLTOVK = __esm({
|
|
35032
35194
|
"../agent-core/dist/chunk-VUWLTOVK.js"() {
|
|
35033
35195
|
"use strict";
|
|
35034
35196
|
init_chunk_AF3IPGDT();
|
|
35035
35197
|
init_chunk_YXWJW7I5();
|
|
35036
|
-
|
|
35198
|
+
import_fs8 = require("fs");
|
|
35037
35199
|
NEWLINE2 = 10;
|
|
35038
35200
|
TranscriptCursor = class {
|
|
35039
35201
|
#path;
|
|
@@ -35051,7 +35213,7 @@ var init_chunk_VUWLTOVK = __esm({
|
|
|
35051
35213
|
try {
|
|
35052
35214
|
this.#offset = Math.max(
|
|
35053
35215
|
this.#offset,
|
|
35054
|
-
(0,
|
|
35216
|
+
(0, import_fs8.statSync)(this.#path, { throwIfNoEntry: false })?.size ?? 0
|
|
35055
35217
|
);
|
|
35056
35218
|
} catch {
|
|
35057
35219
|
}
|
|
@@ -35073,15 +35235,15 @@ var init_chunk_VUWLTOVK = __esm({
|
|
|
35073
35235
|
/** Runs on the CLI's stdout path, so an unreadable file reads as no new lines. */
|
|
35074
35236
|
#unread() {
|
|
35075
35237
|
try {
|
|
35076
|
-
const size = (0,
|
|
35238
|
+
const size = (0, import_fs8.statSync)(this.#path, { throwIfNoEntry: false })?.size ?? 0;
|
|
35077
35239
|
if (size <= this.#offset) return void 0;
|
|
35078
35240
|
const buffer = Buffer.alloc(size - this.#offset);
|
|
35079
|
-
const fd = (0,
|
|
35241
|
+
const fd = (0, import_fs8.openSync)(this.#path, "r");
|
|
35080
35242
|
try {
|
|
35081
|
-
const read = (0,
|
|
35243
|
+
const read = (0, import_fs8.readSync)(fd, buffer, 0, buffer.length, this.#offset);
|
|
35082
35244
|
return buffer.subarray(0, read);
|
|
35083
35245
|
} finally {
|
|
35084
|
-
(0,
|
|
35246
|
+
(0, import_fs8.closeSync)(fd);
|
|
35085
35247
|
}
|
|
35086
35248
|
} catch {
|
|
35087
35249
|
return void 0;
|
|
@@ -36106,35 +36268,35 @@ function createClaudeDriver(options = {}) {
|
|
|
36106
36268
|
};
|
|
36107
36269
|
}
|
|
36108
36270
|
function claudeHomeFor(env, homeDir) {
|
|
36109
|
-
return env.CLAUDE_CONFIG_DIR || (0,
|
|
36271
|
+
return env.CLAUDE_CONFIG_DIR || (0, import_path14.join)(env.HOME || homeDir, ".claude");
|
|
36110
36272
|
}
|
|
36111
36273
|
function encodeProjectDir(cwd) {
|
|
36112
36274
|
return cwd.replace(/[^a-zA-Z0-9]/g, "-");
|
|
36113
36275
|
}
|
|
36114
36276
|
function realCwd(cwd) {
|
|
36115
36277
|
try {
|
|
36116
|
-
return (0,
|
|
36278
|
+
return (0, import_fs9.realpathSync)(cwd);
|
|
36117
36279
|
} catch {
|
|
36118
36280
|
return cwd;
|
|
36119
36281
|
}
|
|
36120
36282
|
}
|
|
36121
36283
|
function projectDirs(projectsRoot) {
|
|
36122
36284
|
try {
|
|
36123
|
-
return (0,
|
|
36285
|
+
return (0, import_fs9.readdirSync)(projectsRoot, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name);
|
|
36124
36286
|
} catch {
|
|
36125
36287
|
return [];
|
|
36126
36288
|
}
|
|
36127
36289
|
}
|
|
36128
36290
|
function claudeSessionLogExists(query) {
|
|
36129
36291
|
if (!query.sessionId || !query.cwd) return false;
|
|
36130
|
-
const projectsRoot = (0,
|
|
36292
|
+
const projectsRoot = (0, import_path14.join)(query.claudeHome, "projects");
|
|
36131
36293
|
const fileName = `${query.sessionId}.jsonl`;
|
|
36132
36294
|
const here = new Set([query.cwd, realCwd(query.cwd)].map(encodeProjectDir));
|
|
36133
36295
|
for (const dir of here) {
|
|
36134
|
-
if ((0,
|
|
36296
|
+
if ((0, import_fs9.existsSync)((0, import_path14.join)(projectsRoot, dir, fileName))) return true;
|
|
36135
36297
|
}
|
|
36136
36298
|
return projectDirs(projectsRoot).some(
|
|
36137
|
-
(dir) => !here.has(dir) && (0,
|
|
36299
|
+
(dir) => !here.has(dir) && (0, import_fs9.existsSync)((0, import_path14.join)(projectsRoot, dir, fileName))
|
|
36138
36300
|
);
|
|
36139
36301
|
}
|
|
36140
36302
|
function envDigest3(env) {
|
|
@@ -36203,7 +36365,7 @@ async function claudeTurnInput(run2, context) {
|
|
|
36203
36365
|
const encoded = await Promise.all(
|
|
36204
36366
|
images.map(async (image) => ({
|
|
36205
36367
|
mimeType: image.mimeType,
|
|
36206
|
-
data: (await (0,
|
|
36368
|
+
data: (await (0, import_promises27.readFile)(image.path)).toString("base64")
|
|
36207
36369
|
}))
|
|
36208
36370
|
);
|
|
36209
36371
|
return { turnId: run2.runId, text: text22, ...encoded.length ? { images: encoded } : {} };
|
|
@@ -36406,15 +36568,15 @@ function claudeTurnClosingUpdates(records, state) {
|
|
|
36406
36568
|
function readClaudeTranscriptTurns(chunk, baseOffset, skipped) {
|
|
36407
36569
|
return readTranscriptTurns(claudeTranscriptFile, chunk, baseOffset, skipped);
|
|
36408
36570
|
}
|
|
36409
|
-
var import_crypto12,
|
|
36571
|
+
var import_crypto12, import_fs9, import_path14, import_crypto13, import_promises27, EDIT_TOOLS, ThoughtBlocks, UNDERSTOOD_SYSTEM_SUBTYPES, CLAUDE_MCP_STATUS, RATE_LIMIT_WARN_AT, CLAUDE_GRAMMAR_NAME, SUBAGENT_TOOL_NAMES, controlResponseSchema, STOPPED_STATUSES, TaskRecords, TERMINAL_BACKGROUND_STATUSES, NON_TERMINAL_BACKGROUND_STATUSES, ASYNC_LAUNCH_ACK, BackgroundTasks, FAILED_STATUSES, STOPPED_BY_USER_TEXT, ClaudeTurn, STDERR_TAIL_LINES3, MAX_EARLY_LINES, UNSUPPORTED_STOP, OUTPUT_CLOSED_REASON, ClaudeSession, DEFAULTS3, READ_ONLY_DISALLOWED_TOOLS, DEFAULT_MCP_TIMEOUT_MS, CLOUD_SKILL_LISTING_MAX_DESCRIPTION_CHARS, SYNTHETIC_MODEL, INTERRUPT_MARKER, NON_PROMPT_PREFIXES, PRELUDE_TYPES, claudeTranscriptFile;
|
|
36410
36572
|
var init_claude = __esm({
|
|
36411
36573
|
"../agent-core/dist/providers/claude.js"() {
|
|
36412
36574
|
"use strict";
|
|
36413
36575
|
init_chunk_VUWLTOVK();
|
|
36414
|
-
|
|
36576
|
+
init_chunk_CGBCAZEN();
|
|
36415
36577
|
init_chunk_AF3IPGDT();
|
|
36416
36578
|
init_chunk_WYNUYKKN();
|
|
36417
|
-
|
|
36579
|
+
init_chunk_A5UQ6YFO();
|
|
36418
36580
|
init_chunk_7FJ7QKFN();
|
|
36419
36581
|
init_chunk_OSECDZA5();
|
|
36420
36582
|
init_chunk_YXWJW7I5();
|
|
@@ -36426,10 +36588,10 @@ var init_claude = __esm({
|
|
|
36426
36588
|
init_acp();
|
|
36427
36589
|
init_constants();
|
|
36428
36590
|
init_agent2();
|
|
36429
|
-
|
|
36430
|
-
|
|
36591
|
+
import_fs9 = require("fs");
|
|
36592
|
+
import_path14 = require("path");
|
|
36431
36593
|
import_crypto13 = require("crypto");
|
|
36432
|
-
|
|
36594
|
+
import_promises27 = require("fs/promises");
|
|
36433
36595
|
init_agent2();
|
|
36434
36596
|
EDIT_TOOLS = /* @__PURE__ */ new Set([
|
|
36435
36597
|
"Edit",
|
|
@@ -37429,7 +37591,12 @@ __export(claude_exports, {
|
|
|
37429
37591
|
});
|
|
37430
37592
|
function createClaudeHolderDriver(options) {
|
|
37431
37593
|
const clock = options.clock ?? systemClock2;
|
|
37432
|
-
const sessions = options.sessions ?? createClaudeDriver({
|
|
37594
|
+
const sessions = options.sessions ?? createClaudeDriver({
|
|
37595
|
+
...options.timings,
|
|
37596
|
+
clock,
|
|
37597
|
+
log: options.log,
|
|
37598
|
+
...options.flagProbe === void 0 ? {} : { probe: createClaudeCapabilityProbe(options.flagProbe) }
|
|
37599
|
+
});
|
|
37433
37600
|
return createPersistentDriver(
|
|
37434
37601
|
{
|
|
37435
37602
|
harness: "claude_cli",
|
|
@@ -37576,11 +37743,11 @@ function codexExecArgs(input2) {
|
|
|
37576
37743
|
];
|
|
37577
37744
|
}
|
|
37578
37745
|
function codexHomeOf(env) {
|
|
37579
|
-
return env.CODEX_HOME || (0,
|
|
37746
|
+
return env.CODEX_HOME || (0, import_path15.join)(env.HOME ?? "", ".codex");
|
|
37580
37747
|
}
|
|
37581
37748
|
function namesNewestFirst(dir, isDir) {
|
|
37582
37749
|
try {
|
|
37583
|
-
return (0,
|
|
37750
|
+
return (0, import_fs10.readdirSync)(dir, { withFileTypes: true }).filter((entry) => isDir ? entry.isDirectory() : entry.isFile()).map((entry) => entry.name).sort().reverse();
|
|
37584
37751
|
} catch {
|
|
37585
37752
|
return [];
|
|
37586
37753
|
}
|
|
@@ -37592,15 +37759,15 @@ function findCodexRollout(codexHome, sessionId) {
|
|
|
37592
37759
|
const name = namesNewestFirst(dir, false).find(
|
|
37593
37760
|
(file2) => file2.startsWith("rollout-") && file2.endsWith(suffix)
|
|
37594
37761
|
);
|
|
37595
|
-
return name ? (0,
|
|
37762
|
+
return name ? (0, import_path15.join)(dir, name) : void 0;
|
|
37596
37763
|
}
|
|
37597
37764
|
for (const child of namesNewestFirst(dir, true)) {
|
|
37598
|
-
const found = walk((0,
|
|
37765
|
+
const found = walk((0, import_path15.join)(dir, child), depth - 1);
|
|
37599
37766
|
if (found) return found;
|
|
37600
37767
|
}
|
|
37601
37768
|
return void 0;
|
|
37602
37769
|
};
|
|
37603
|
-
return sessionId ? walk((0,
|
|
37770
|
+
return sessionId ? walk((0, import_path15.join)(codexHome, "sessions"), 3) : void 0;
|
|
37604
37771
|
}
|
|
37605
37772
|
function codexRolloutExists(codexHome, sessionId) {
|
|
37606
37773
|
return Promise.resolve(findCodexRollout(codexHome, sessionId) !== void 0);
|
|
@@ -39398,20 +39565,20 @@ function codexTurnInput(run2, context) {
|
|
|
39398
39565
|
...images.length ? { imagePaths: images.map((image) => image.path) } : {}
|
|
39399
39566
|
};
|
|
39400
39567
|
}
|
|
39401
|
-
var
|
|
39568
|
+
var import_fs10, import_path15, import_crypto14, import_crypto15, import_crypto16, import_crypto17, TokenRefresher, MCP_STARTUP_TIMEOUT_SEC, FIELD_TYPES, YES_NO, ACCEPT_DECLINE, MAX_INLINE_GENERATED_IMAGE_BYTES, PNG_SIGNATURE2, JPEG_NON_FRAME_MARKERS, IMAGE_GEN_CALL, PROMPT_LITERAL, RELOCATE_EVERY_MS, CodexImageGenerationFold, CodexRolloutImages, CodexRateLimits, USER_INPUT_METHOD, PERMISSIONS_METHOD, ELICITATION_METHOD, COMMAND_OR_FILE, LEGACY, DECISIONS, COORDINATION_TOOLS, SETTLED_AGENT, STATUS, CHANGE_OPERATIONS, SILENT_ON_START, IGNORED_ITEMS, PLAN_STATUS, CodexTurnTokens, CODEX_MCP_STATUS, WORKER_LIFECYCLE, INFO_KINDS, SILENT, CodexTurn, STDERR_TAIL_LINES4, MAX_BETWEEN_UPDATES2, UNSUPPORTED_REQUEST, DECLINED_ELICITATION, IMAGE_CATCH_UP_MS, IMAGE_POLL_MS, CodexSession, CODEX_MIN_VERSION, CODEX_REQUIREMENT, CODEX_TESTED_LINE, DEFAULTS4, CLIENT_INFO2, STATUS2, EXITED_WITHOUT_RESPONSE, CodexExecTurn, DEFAULTS22, CodexExecSession, INJECTED_USER_PREFIXES, SHELL_TOOL_NAMES, ANNOUNCING_ITEM_TYPES, OUTPUT_MARKER, OPEN_PAGE_ACTIONS, FIND_IN_PAGE_ACTIONS, FILE_OPERATIONS2, UNDERSTOOD_ITEM_TYPES, PRELUDE_TYPES2, PRELUDE_EVENTS, codexRolloutFile;
|
|
39402
39569
|
var init_codex = __esm({
|
|
39403
39570
|
"../agent-core/dist/providers/codex.js"() {
|
|
39404
39571
|
"use strict";
|
|
39405
39572
|
init_chunk_VUWLTOVK();
|
|
39406
|
-
|
|
39573
|
+
init_chunk_CGBCAZEN();
|
|
39407
39574
|
init_chunk_AF3IPGDT();
|
|
39408
39575
|
init_chunk_WYNUYKKN();
|
|
39409
|
-
|
|
39576
|
+
init_chunk_A5UQ6YFO();
|
|
39410
39577
|
init_chunk_7FJ7QKFN();
|
|
39411
39578
|
init_chunk_OSECDZA5();
|
|
39412
39579
|
init_chunk_YXWJW7I5();
|
|
39413
|
-
|
|
39414
|
-
|
|
39580
|
+
import_fs10 = require("fs");
|
|
39581
|
+
import_path15 = require("path");
|
|
39415
39582
|
init_effort();
|
|
39416
39583
|
import_crypto14 = require("crypto");
|
|
39417
39584
|
import_crypto15 = require("crypto");
|
|
@@ -40133,10 +40300,10 @@ var init_codex = __esm({
|
|
|
40133
40300
|
images.startAtEnd();
|
|
40134
40301
|
let finish = () => {
|
|
40135
40302
|
};
|
|
40136
|
-
let
|
|
40303
|
+
let identify2 = () => {
|
|
40137
40304
|
};
|
|
40138
40305
|
const identified = new Promise((resolve14) => {
|
|
40139
|
-
|
|
40306
|
+
identify2 = resolve14;
|
|
40140
40307
|
});
|
|
40141
40308
|
const done = new Promise((resolve14) => {
|
|
40142
40309
|
finish = (outcome2) => {
|
|
@@ -40155,7 +40322,7 @@ var init_codex = __esm({
|
|
|
40155
40322
|
done,
|
|
40156
40323
|
finish,
|
|
40157
40324
|
identified,
|
|
40158
|
-
identify,
|
|
40325
|
+
identify: identify2,
|
|
40159
40326
|
images,
|
|
40160
40327
|
cancelRequested: false,
|
|
40161
40328
|
ending: false
|
|
@@ -41140,25 +41307,25 @@ async function droidTurnInput(run2, context) {
|
|
|
41140
41307
|
const encoded = await Promise.all(
|
|
41141
41308
|
images.map(async (image) => ({
|
|
41142
41309
|
mimeType: image.mimeType,
|
|
41143
|
-
data: (await (0,
|
|
41310
|
+
data: (await (0, import_promises28.readFile)(image.path)).toString("base64")
|
|
41144
41311
|
}))
|
|
41145
41312
|
);
|
|
41146
41313
|
return { turnId: run2.runId, text: text3, ...encoded.length ? { images: encoded } : {} };
|
|
41147
41314
|
}
|
|
41148
|
-
var import_crypto18,
|
|
41315
|
+
var import_crypto18, import_promises28, FACTORY_API_VERSION, FACTORY_PROTOCOL_VERSION, SUBAGENT_TOOLS, TASK_OUTPUT_TOOLS, TASK_STOP_TOOLS, SILENT2, DroidTurn, STDERR_TAIL_LINES5, UNSUPPORTED_REQUEST2, DroidSession, DEFAULTS5, DROID_REQUIREMENT, DROID_JSONRPC_ARGS;
|
|
41149
41316
|
var init_droid = __esm({
|
|
41150
41317
|
"../agent-core/dist/providers/droid.js"() {
|
|
41151
41318
|
"use strict";
|
|
41152
|
-
|
|
41319
|
+
init_chunk_CGBCAZEN();
|
|
41153
41320
|
init_chunk_AF3IPGDT();
|
|
41154
41321
|
init_chunk_WYNUYKKN();
|
|
41155
|
-
|
|
41322
|
+
init_chunk_A5UQ6YFO();
|
|
41156
41323
|
init_chunk_7FJ7QKFN();
|
|
41157
41324
|
init_chunk_OSECDZA5();
|
|
41158
41325
|
init_chunk_YXWJW7I5();
|
|
41159
41326
|
init_runtime_v2();
|
|
41160
41327
|
import_crypto18 = require("crypto");
|
|
41161
|
-
|
|
41328
|
+
import_promises28 = require("fs/promises");
|
|
41162
41329
|
init_agent2();
|
|
41163
41330
|
FACTORY_API_VERSION = "1.0.0";
|
|
41164
41331
|
FACTORY_PROTOCOL_VERSION = "1.187.0";
|
|
@@ -41640,12 +41807,12 @@ var init_opencode2 = __esm({
|
|
|
41640
41807
|
// ../agent-core/dist/providers/antigravity.js
|
|
41641
41808
|
function settingsPath(env) {
|
|
41642
41809
|
const home = env.HOME?.trim() || env.USERPROFILE?.trim();
|
|
41643
|
-
return home ? (0,
|
|
41810
|
+
return home ? (0, import_path16.resolve)(home, ".gemini", "antigravity-cli", "settings.json") : void 0;
|
|
41644
41811
|
}
|
|
41645
41812
|
async function readSettings(path4) {
|
|
41646
41813
|
let raw;
|
|
41647
41814
|
try {
|
|
41648
|
-
raw = (await (0,
|
|
41815
|
+
raw = (await (0, import_promises29.readFile)(path4, "utf8")).trim();
|
|
41649
41816
|
} catch {
|
|
41650
41817
|
return {};
|
|
41651
41818
|
}
|
|
@@ -41663,8 +41830,8 @@ async function selectAntigravityApiKeyMode(env) {
|
|
|
41663
41830
|
const settings2 = await readSettings(path4);
|
|
41664
41831
|
if (settings2 === "malformed") return "malformed";
|
|
41665
41832
|
if (settings2.modelProvider === "gemini") return "already_selected";
|
|
41666
|
-
await (0,
|
|
41667
|
-
await (0,
|
|
41833
|
+
await (0, import_promises29.mkdir)((0, import_path16.dirname)(path4), { recursive: true });
|
|
41834
|
+
await (0, import_promises29.writeFile)(path4, JSON.stringify({ ...settings2, modelProvider: "gemini" }), { mode: 384 });
|
|
41668
41835
|
return "selected";
|
|
41669
41836
|
}
|
|
41670
41837
|
function readAntigravityCapabilities(version2, help) {
|
|
@@ -41707,21 +41874,21 @@ function antigravityArgs(input2, capabilities, prompt) {
|
|
|
41707
41874
|
];
|
|
41708
41875
|
}
|
|
41709
41876
|
function workspaceRoot(cwd) {
|
|
41710
|
-
for (let current = (0,
|
|
41711
|
-
if ((0,
|
|
41712
|
-
if ((0,
|
|
41877
|
+
for (let current = (0, import_path17.resolve)(cwd); ; current = (0, import_path17.dirname)(current)) {
|
|
41878
|
+
if ((0, import_fs11.existsSync)((0, import_path17.join)(current, ".git"))) return current;
|
|
41879
|
+
if ((0, import_path17.dirname)(current) === current) return (0, import_path17.resolve)(cwd);
|
|
41713
41880
|
}
|
|
41714
41881
|
}
|
|
41715
41882
|
function instructionPaths(cwd) {
|
|
41716
41883
|
const root = workspaceRoot(cwd);
|
|
41717
41884
|
const paths = [];
|
|
41718
|
-
for (let current = (0,
|
|
41719
|
-
const path4 = (0,
|
|
41885
|
+
for (let current = (0, import_path17.resolve)(cwd); ; current = (0, import_path17.dirname)(current)) {
|
|
41886
|
+
const path4 = (0, import_path17.join)(current, INSTRUCTIONS_FILE);
|
|
41720
41887
|
try {
|
|
41721
|
-
if ((0,
|
|
41888
|
+
if ((0, import_fs11.existsSync)(path4) && (0, import_fs11.statSync)(path4).isFile()) paths.unshift(path4);
|
|
41722
41889
|
} catch {
|
|
41723
41890
|
}
|
|
41724
|
-
if (current === root || (0,
|
|
41891
|
+
if (current === root || (0, import_path17.dirname)(current) === current) return paths;
|
|
41725
41892
|
}
|
|
41726
41893
|
}
|
|
41727
41894
|
function antigravityWorkspaceInstructions(cwd, maxChars = MAX_INSTRUCTION_CHARS) {
|
|
@@ -41732,7 +41899,7 @@ function antigravityWorkspaceInstructions(cwd, maxChars = MAX_INSTRUCTION_CHARS)
|
|
|
41732
41899
|
if (remaining <= 0) break;
|
|
41733
41900
|
let content;
|
|
41734
41901
|
try {
|
|
41735
|
-
content = (0,
|
|
41902
|
+
content = (0, import_fs11.readFileSync)(path4, "utf8").trim();
|
|
41736
41903
|
} catch {
|
|
41737
41904
|
continue;
|
|
41738
41905
|
}
|
|
@@ -41975,7 +42142,7 @@ function normalizeAntigravityFrame(event) {
|
|
|
41975
42142
|
}
|
|
41976
42143
|
function antigravityBrainRoot(env) {
|
|
41977
42144
|
const home = env.HOME?.trim() || env.USERPROFILE?.trim();
|
|
41978
|
-
return home ? (0,
|
|
42145
|
+
return home ? (0, import_path18.resolve)(home, ".gemini", "antigravity-cli", "brain") : void 0;
|
|
41979
42146
|
}
|
|
41980
42147
|
function parseEntry(text3) {
|
|
41981
42148
|
try {
|
|
@@ -42013,14 +42180,14 @@ function childTranscriptPath(root, frame) {
|
|
|
42013
42180
|
try {
|
|
42014
42181
|
const url3 = new URL(logUri);
|
|
42015
42182
|
if (url3.protocol !== "file:") return void 0;
|
|
42016
|
-
path4 = (0,
|
|
42183
|
+
path4 = (0, import_path18.resolve)((0, import_url3.fileURLToPath)(url3));
|
|
42017
42184
|
} catch {
|
|
42018
42185
|
return void 0;
|
|
42019
42186
|
}
|
|
42020
|
-
const fromRoot = (0,
|
|
42021
|
-
if (!fromRoot || (0,
|
|
42187
|
+
const fromRoot = (0, import_path18.relative)(root, path4);
|
|
42188
|
+
if (!fromRoot || (0, import_path18.isAbsolute)(fromRoot) || fromRoot.split(import_path18.sep).includes("..")) return void 0;
|
|
42022
42189
|
const expected = [conversationId, ...LOG_DIRS, TRANSCRIPT_FILE];
|
|
42023
|
-
const segments = fromRoot.split(
|
|
42190
|
+
const segments = fromRoot.split(import_path18.sep);
|
|
42024
42191
|
const matches = segments.length === expected.length && segments.every((segment, index) => segment === expected[index]);
|
|
42025
42192
|
return matches ? path4 : void 0;
|
|
42026
42193
|
}
|
|
@@ -42282,24 +42449,24 @@ function antigravityTurnInput(run2, context) {
|
|
|
42282
42449
|
});
|
|
42283
42450
|
return { turnId: run2.runId, text: appendImagePathReferences(text3, images) };
|
|
42284
42451
|
}
|
|
42285
|
-
var
|
|
42452
|
+
var import_promises29, import_path16, import_fs11, import_path17, import_path18, import_url3, import_crypto19, NO_ANTIGRAVITY_CAPABILITIES, INSTRUCTIONS_FILE, MAX_INSTRUCTION_CHARS, SHORTENED_NOTE, DIFF_BLOCK_START, DIFF_BLOCK_END, HUNK_HEADER, TRANSCRIPT_FILE, FULL_TRANSCRIPT_FILE, LOG_DIRS, TOOL_RESULT_TYPES, BrainTranscript, AntigravityTranscripts, ANTIGRAVITY_GRAMMAR_NAME, AntigravityGrammar, ignored, HANDLERS, SUCCESSFUL_STATUSES, SESSION_START_TYPES, RESULT_TYPES, SUBAGENT_START_TYPES, RESUME_FORKED, EXITED_WITHOUT_RESULT, AntigravityTurn, DEFAULTS6, AntigravitySession, WINDOWS_LINE_MARGIN;
|
|
42286
42453
|
var init_antigravity = __esm({
|
|
42287
42454
|
"../agent-core/dist/providers/antigravity.js"() {
|
|
42288
42455
|
"use strict";
|
|
42289
42456
|
init_chunk_VUWLTOVK();
|
|
42290
|
-
|
|
42457
|
+
init_chunk_CGBCAZEN();
|
|
42291
42458
|
init_chunk_AF3IPGDT();
|
|
42292
42459
|
init_chunk_WYNUYKKN();
|
|
42293
|
-
|
|
42460
|
+
init_chunk_A5UQ6YFO();
|
|
42294
42461
|
init_chunk_7FJ7QKFN();
|
|
42295
42462
|
init_chunk_YXWJW7I5();
|
|
42296
|
-
|
|
42297
|
-
import_path15 = require("path");
|
|
42298
|
-
init_type_guards();
|
|
42299
|
-
import_fs10 = require("fs");
|
|
42463
|
+
import_promises29 = require("fs/promises");
|
|
42300
42464
|
import_path16 = require("path");
|
|
42301
|
-
|
|
42465
|
+
init_type_guards();
|
|
42466
|
+
import_fs11 = require("fs");
|
|
42302
42467
|
import_path17 = require("path");
|
|
42468
|
+
init_effort();
|
|
42469
|
+
import_path18 = require("path");
|
|
42303
42470
|
import_url3 = require("url");
|
|
42304
42471
|
import_crypto19 = require("crypto");
|
|
42305
42472
|
init_agent2();
|
|
@@ -42339,7 +42506,7 @@ var init_antigravity = __esm({
|
|
|
42339
42506
|
#full;
|
|
42340
42507
|
constructor(path4) {
|
|
42341
42508
|
this.#cursor = new TranscriptCursor(path4);
|
|
42342
|
-
this.#fullPath = (0,
|
|
42509
|
+
this.#fullPath = (0, import_path18.resolve)((0, import_path18.dirname)(path4), FULL_TRANSCRIPT_FILE);
|
|
42343
42510
|
}
|
|
42344
42511
|
skipExisting() {
|
|
42345
42512
|
this.#cursor.read();
|
|
@@ -42387,7 +42554,7 @@ var init_antigravity = __esm({
|
|
|
42387
42554
|
/** A conversation this turn did not resume was created by it, so it is read whole. */
|
|
42388
42555
|
trackParent(conversationId) {
|
|
42389
42556
|
if (this.#parent?.conversationId === conversationId) return;
|
|
42390
|
-
const path4 = (0,
|
|
42557
|
+
const path4 = (0, import_path18.resolve)(this.#root, conversationId, ...LOG_DIRS, TRANSCRIPT_FILE);
|
|
42391
42558
|
this.#parent = { conversationId, transcript: new BrainTranscript(path4) };
|
|
42392
42559
|
}
|
|
42393
42560
|
/** A launcher keeps the first valid transcript it names; later frames change nothing. */
|
|
@@ -42818,8 +42985,8 @@ function parseConfig(raw) {
|
|
|
42818
42985
|
}
|
|
42819
42986
|
}
|
|
42820
42987
|
async function writeCommandCodeProjectMcp(cwd, mcp) {
|
|
42821
|
-
const path4 = (0,
|
|
42822
|
-
const original = await (0,
|
|
42988
|
+
const path4 = (0, import_path19.join)(cwd, ".mcp.json");
|
|
42989
|
+
const original = await (0, import_promises30.readFile)(path4, "utf8").catch(() => null);
|
|
42823
42990
|
const config2 = parseConfig(original);
|
|
42824
42991
|
const next = {
|
|
42825
42992
|
...config2,
|
|
@@ -42836,12 +43003,12 @@ async function writeCommandCodeProjectMcp(cwd, mcp) {
|
|
|
42836
43003
|
}
|
|
42837
43004
|
}
|
|
42838
43005
|
};
|
|
42839
|
-
await (0,
|
|
42840
|
-
await (0,
|
|
43006
|
+
await (0, import_promises30.mkdir)(cwd, { recursive: true });
|
|
43007
|
+
await (0, import_promises30.writeFile)(path4, `${JSON.stringify(next, null, 2)}
|
|
42841
43008
|
`);
|
|
42842
43009
|
return async () => {
|
|
42843
|
-
if (original === null) await (0,
|
|
42844
|
-
else await (0,
|
|
43010
|
+
if (original === null) await (0, import_promises30.rm)(path4, { force: true });
|
|
43011
|
+
else await (0, import_promises30.writeFile)(path4, original);
|
|
42845
43012
|
};
|
|
42846
43013
|
}
|
|
42847
43014
|
function commandCodeString(value2) {
|
|
@@ -43013,19 +43180,19 @@ function commandCodeTurnInput(run2, context) {
|
|
|
43013
43180
|
});
|
|
43014
43181
|
return { turnId: run2.runId, text: appendImagePathReferences(text3, images) };
|
|
43015
43182
|
}
|
|
43016
|
-
var
|
|
43183
|
+
var import_promises30, import_path19, import_crypto20, COMMAND_CODE_GRAMMAR_NAME, SILENT3, CommandCodeGrammar, SHELL_TOOL, STOP_TOOLS, REPORTED_STATUS, SHELL_STATUS, SWEEP_INTERVAL_MS, CommandCodeBackgroundTasks, EXITED_WITHOUT_RESULT2, CommandCodeTurn, COMMAND_CODE_MAX_TURNS, DEFAULTS7, CommandCodeSession;
|
|
43017
43184
|
var init_command_code = __esm({
|
|
43018
43185
|
"../agent-core/dist/providers/command-code.js"() {
|
|
43019
43186
|
"use strict";
|
|
43020
|
-
|
|
43187
|
+
init_chunk_CGBCAZEN();
|
|
43021
43188
|
init_chunk_AF3IPGDT();
|
|
43022
43189
|
init_chunk_WYNUYKKN();
|
|
43023
|
-
|
|
43190
|
+
init_chunk_A5UQ6YFO();
|
|
43024
43191
|
init_chunk_7FJ7QKFN();
|
|
43025
43192
|
init_chunk_OSECDZA5();
|
|
43026
43193
|
init_chunk_YXWJW7I5();
|
|
43027
|
-
|
|
43028
|
-
|
|
43194
|
+
import_promises30 = require("fs/promises");
|
|
43195
|
+
import_path19 = require("path");
|
|
43029
43196
|
init_agent2();
|
|
43030
43197
|
init_runtime_v2();
|
|
43031
43198
|
init_acp();
|
|
@@ -53162,7 +53329,7 @@ var require_extract = __commonJS({
|
|
|
53162
53329
|
var require_constants = __commonJS({
|
|
53163
53330
|
"../../node_modules/tar-stream/constants.js"(exports2, module2) {
|
|
53164
53331
|
"use strict";
|
|
53165
|
-
var
|
|
53332
|
+
var constants6 = {
|
|
53166
53333
|
// just for envs without fs
|
|
53167
53334
|
S_IFMT: 61440,
|
|
53168
53335
|
S_IFDIR: 16384,
|
|
@@ -53172,9 +53339,9 @@ var require_constants = __commonJS({
|
|
|
53172
53339
|
S_IFLNK: 40960
|
|
53173
53340
|
};
|
|
53174
53341
|
try {
|
|
53175
|
-
module2.exports = require("fs").constants ||
|
|
53342
|
+
module2.exports = require("fs").constants || constants6;
|
|
53176
53343
|
} catch {
|
|
53177
|
-
module2.exports =
|
|
53344
|
+
module2.exports = constants6;
|
|
53178
53345
|
}
|
|
53179
53346
|
}
|
|
53180
53347
|
});
|
|
@@ -53185,7 +53352,7 @@ var require_pack = __commonJS({
|
|
|
53185
53352
|
"use strict";
|
|
53186
53353
|
var { Readable: Readable2, Writable, getStreamError } = require_streamx();
|
|
53187
53354
|
var b4a = require_b4a();
|
|
53188
|
-
var
|
|
53355
|
+
var constants6 = require_constants();
|
|
53189
53356
|
var headers = require_headers();
|
|
53190
53357
|
var DMODE = 493;
|
|
53191
53358
|
var FMODE = 420;
|
|
@@ -53388,16 +53555,16 @@ var require_pack = __commonJS({
|
|
|
53388
53555
|
return new Pack(opts);
|
|
53389
53556
|
};
|
|
53390
53557
|
function modeToType(mode) {
|
|
53391
|
-
switch (mode &
|
|
53392
|
-
case
|
|
53558
|
+
switch (mode & constants6.S_IFMT) {
|
|
53559
|
+
case constants6.S_IFBLK:
|
|
53393
53560
|
return "block-device";
|
|
53394
|
-
case
|
|
53561
|
+
case constants6.S_IFCHR:
|
|
53395
53562
|
return "character-device";
|
|
53396
|
-
case
|
|
53563
|
+
case constants6.S_IFDIR:
|
|
53397
53564
|
return "directory";
|
|
53398
|
-
case
|
|
53565
|
+
case constants6.S_IFIFO:
|
|
53399
53566
|
return "fifo";
|
|
53400
|
-
case
|
|
53567
|
+
case constants6.S_IFLNK:
|
|
53401
53568
|
return "symlink";
|
|
53402
53569
|
}
|
|
53403
53570
|
return "file";
|
|
@@ -54038,8 +54205,8 @@ var require_common = __commonJS({
|
|
|
54038
54205
|
}
|
|
54039
54206
|
return debug12;
|
|
54040
54207
|
}
|
|
54041
|
-
function extend2(namespace,
|
|
54042
|
-
const newDebug = createDebug(this.namespace + (typeof
|
|
54208
|
+
function extend2(namespace, delimiter2) {
|
|
54209
|
+
const newDebug = createDebug(this.namespace + (typeof delimiter2 === "undefined" ? ":" : delimiter2) + namespace);
|
|
54043
54210
|
newDebug.log = this.log;
|
|
54044
54211
|
return newDebug;
|
|
54045
54212
|
}
|
|
@@ -58209,7 +58376,7 @@ var import_node_worker_threads2 = require("worker_threads");
|
|
|
58209
58376
|
// package.json
|
|
58210
58377
|
var package_default = {
|
|
58211
58378
|
name: "@alan-ai-hq/agent-manager",
|
|
58212
|
-
version: "0.1.
|
|
58379
|
+
version: "0.1.171",
|
|
58213
58380
|
private: true,
|
|
58214
58381
|
type: "module",
|
|
58215
58382
|
description: "Alan machine runtime (alan-agent): identity, link, reconciler, session holders, run log, uploader, local API",
|
|
@@ -59740,9 +59907,9 @@ function isProcessAlive(pid) {
|
|
|
59740
59907
|
}
|
|
59741
59908
|
}
|
|
59742
59909
|
async function linuxStartTime(pid) {
|
|
59743
|
-
const
|
|
59744
|
-
if (
|
|
59745
|
-
const fields =
|
|
59910
|
+
const stat24 = await (0, import_promises5.readFile)(`/proc/${pid}/stat`, "utf8").catch(() => null);
|
|
59911
|
+
if (stat24 === null) return null;
|
|
59912
|
+
const fields = stat24.slice(stat24.lastIndexOf(")") + 2).split(" ");
|
|
59746
59913
|
return fields[19] ?? null;
|
|
59747
59914
|
}
|
|
59748
59915
|
async function linuxCommand(pid) {
|
|
@@ -60177,8 +60344,8 @@ function ipcEndpoint(socketsDir, id, platform3 = process.platform) {
|
|
|
60177
60344
|
return (0, import_node_path6.join)(dir, `${id}.sock`);
|
|
60178
60345
|
}
|
|
60179
60346
|
function assertPrivateDirectory(dir, uid) {
|
|
60180
|
-
const
|
|
60181
|
-
if (!
|
|
60347
|
+
const stat24 = (0, import_node_fs6.lstatSync)(dir);
|
|
60348
|
+
if (!stat24.isDirectory() || stat24.uid !== uid || (stat24.mode & 63) !== 0) {
|
|
60182
60349
|
throw new RuntimeFault(
|
|
60183
60350
|
"io_failed",
|
|
60184
60351
|
`Refusing socket directory ${dir}: it must be a directory owned by uid ${uid} with mode 0700`
|
|
@@ -61978,8 +62145,8 @@ async function readVmCounters(platform3 = process.platform) {
|
|
|
61978
62145
|
return null;
|
|
61979
62146
|
}
|
|
61980
62147
|
}
|
|
61981
|
-
function parseProcStat(
|
|
61982
|
-
const fields =
|
|
62148
|
+
function parseProcStat(stat24) {
|
|
62149
|
+
const fields = stat24.slice(stat24.lastIndexOf(")") + 2).split(" ");
|
|
61983
62150
|
const ppid = Number(fields[1]);
|
|
61984
62151
|
const utime = Number(fields[11]);
|
|
61985
62152
|
const stime = Number(fields[12]);
|
|
@@ -61992,8 +62159,8 @@ async function readProcessCpuTable(platform3 = process.platform) {
|
|
|
61992
62159
|
const entries = await (0, import_promises16.readdir)("/proc").catch(() => []);
|
|
61993
62160
|
await Promise.all(
|
|
61994
62161
|
entries.filter((entry) => /^\d+$/.test(entry)).map(async (entry) => {
|
|
61995
|
-
const
|
|
61996
|
-
const row =
|
|
62162
|
+
const stat24 = await (0, import_promises16.readFile)(`/proc/${entry}/stat`, "utf8").catch(() => null);
|
|
62163
|
+
const row = stat24 === null ? null : parseProcStat(stat24);
|
|
61997
62164
|
if (row !== null) table.set(Number(entry), row);
|
|
61998
62165
|
})
|
|
61999
62166
|
);
|
|
@@ -62172,7 +62339,7 @@ function startWakeClock(options) {
|
|
|
62172
62339
|
}
|
|
62173
62340
|
|
|
62174
62341
|
// src/cli/commands/activity-lease-producer.ts
|
|
62175
|
-
var
|
|
62342
|
+
var import_promises71 = require("fs/promises");
|
|
62176
62343
|
var import_node_path68 = require("path");
|
|
62177
62344
|
init_runtime_v2();
|
|
62178
62345
|
|
|
@@ -62349,7 +62516,7 @@ var GitFault = class extends Error {
|
|
|
62349
62516
|
};
|
|
62350
62517
|
|
|
62351
62518
|
// src/capabilities/git/remote.ts
|
|
62352
|
-
var
|
|
62519
|
+
var import_promises31 = require("fs/promises");
|
|
62353
62520
|
var import_node_path18 = require("path");
|
|
62354
62521
|
var import_node_url2 = require("url");
|
|
62355
62522
|
var SUPPORTED_REMOTE_PROTOCOLS = /* @__PURE__ */ new Set([
|
|
@@ -62363,7 +62530,7 @@ async function canonicalPathWithMissingTail(path4) {
|
|
|
62363
62530
|
let cursor = (0, import_node_path18.resolve)(path4);
|
|
62364
62531
|
for (; ; ) {
|
|
62365
62532
|
try {
|
|
62366
|
-
return (0, import_node_path18.join)(await (0,
|
|
62533
|
+
return (0, import_node_path18.join)(await (0, import_promises31.realpath)(cursor), ...missing);
|
|
62367
62534
|
} catch (error62) {
|
|
62368
62535
|
if (errnoCode(error62) !== "ENOENT" && errnoCode(error62) !== "ENOTDIR") throw error62;
|
|
62369
62536
|
const parent = (0, import_node_path18.dirname)(cursor);
|
|
@@ -62457,11 +62624,11 @@ async function inspectedRemoteUrl(git, repoRoot, remote, signal) {
|
|
|
62457
62624
|
}
|
|
62458
62625
|
|
|
62459
62626
|
// src/capabilities/git/repository.ts
|
|
62460
|
-
var
|
|
62627
|
+
var import_promises32 = require("fs/promises");
|
|
62461
62628
|
var import_node_path19 = require("path");
|
|
62462
62629
|
async function isDirectory2(path4) {
|
|
62463
62630
|
try {
|
|
62464
|
-
return (await (0,
|
|
62631
|
+
return (await (0, import_promises32.stat)(path4)).isDirectory();
|
|
62465
62632
|
} catch {
|
|
62466
62633
|
return false;
|
|
62467
62634
|
}
|
|
@@ -62482,7 +62649,7 @@ async function resolveRepositoryRoot(git, path4, signal) {
|
|
|
62482
62649
|
"The selected folder is not inside a Git repository"
|
|
62483
62650
|
);
|
|
62484
62651
|
}
|
|
62485
|
-
return (0,
|
|
62652
|
+
return (0, import_promises32.realpath)((0, import_node_path19.resolve)(root));
|
|
62486
62653
|
}
|
|
62487
62654
|
async function listWorktrees(git, repoRoot, signal) {
|
|
62488
62655
|
const output2 = await git.ok(
|
|
@@ -62546,12 +62713,12 @@ async function repositoryCommonDir(git, repoRoot, signal) {
|
|
|
62546
62713
|
signal,
|
|
62547
62714
|
"git_operation_failed"
|
|
62548
62715
|
);
|
|
62549
|
-
return (0,
|
|
62716
|
+
return (0, import_promises32.realpath)(commonDir);
|
|
62550
62717
|
}
|
|
62551
62718
|
|
|
62552
62719
|
// src/capabilities/git/status.ts
|
|
62553
62720
|
var import_node_crypto13 = require("crypto");
|
|
62554
|
-
var
|
|
62721
|
+
var import_promises33 = require("fs/promises");
|
|
62555
62722
|
var import_node_path20 = require("path");
|
|
62556
62723
|
var BRANCH_LABEL_MAX_LENGTH = 256;
|
|
62557
62724
|
var HASH_OBJECT_BATCH = 128;
|
|
@@ -62631,8 +62798,8 @@ async function readWorkspaceStatus(context) {
|
|
|
62631
62798
|
};
|
|
62632
62799
|
}
|
|
62633
62800
|
async function proposedTreeSha(context, headSha) {
|
|
62634
|
-
await (0,
|
|
62635
|
-
const tempDir = await (0,
|
|
62801
|
+
await (0, import_promises33.mkdir)(context.tmpDir, { recursive: true, mode: 448 });
|
|
62802
|
+
const tempDir = await (0, import_promises33.mkdtemp)((0, import_node_path20.join)(context.tmpDir, "index-"));
|
|
62636
62803
|
const env = { GIT_INDEX_FILE: (0, import_node_path20.join)(tempDir, "index") };
|
|
62637
62804
|
const run2 = (args) => context.git.ok({ cwd: context.repoRoot, args, env }, context.signal, "git_status_unreadable");
|
|
62638
62805
|
try {
|
|
@@ -62642,7 +62809,7 @@ async function proposedTreeSha(context, headSha) {
|
|
|
62642
62809
|
assertCommitSha(tree, "proposedTreeSha");
|
|
62643
62810
|
return tree;
|
|
62644
62811
|
} finally {
|
|
62645
|
-
await (0,
|
|
62812
|
+
await (0, import_promises33.rm)(tempDir, { recursive: true, force: true });
|
|
62646
62813
|
}
|
|
62647
62814
|
}
|
|
62648
62815
|
function updateLengthPrefixed(hash2, value2) {
|
|
@@ -62839,14 +63006,14 @@ async function verifyHead(context, request2) {
|
|
|
62839
63006
|
}
|
|
62840
63007
|
|
|
62841
63008
|
// src/capabilities/git/checkpoint.ts
|
|
62842
|
-
var
|
|
63009
|
+
var import_promises34 = require("fs/promises");
|
|
62843
63010
|
var import_node_path21 = require("path");
|
|
62844
63011
|
function sourceChanged(message2) {
|
|
62845
63012
|
return new GitFault("source_changed_since_approval", message2);
|
|
62846
63013
|
}
|
|
62847
63014
|
async function createLockFile(path4) {
|
|
62848
63015
|
try {
|
|
62849
|
-
await (0,
|
|
63016
|
+
await (0, import_promises34.writeFile)(path4, "", { flag: "wx" });
|
|
62850
63017
|
return true;
|
|
62851
63018
|
} catch {
|
|
62852
63019
|
return false;
|
|
@@ -62860,13 +63027,13 @@ async function acquireHeadLock(locks) {
|
|
|
62860
63027
|
}
|
|
62861
63028
|
async function releaseHeadLock(locks) {
|
|
62862
63029
|
if (!locks.headLockHeld) return;
|
|
62863
|
-
await (0,
|
|
63030
|
+
await (0, import_promises34.rm)(locks.headLockPath, { force: true });
|
|
62864
63031
|
locks.headLockHeld = false;
|
|
62865
63032
|
}
|
|
62866
63033
|
async function releaseLocks(locks) {
|
|
62867
63034
|
await releaseHeadLock(locks);
|
|
62868
63035
|
if (locks.indexLockHeld) {
|
|
62869
|
-
await (0,
|
|
63036
|
+
await (0, import_promises34.rm)(locks.indexLockPath, { force: true });
|
|
62870
63037
|
locks.indexLockHeld = false;
|
|
62871
63038
|
}
|
|
62872
63039
|
}
|
|
@@ -62910,8 +63077,8 @@ async function assertHead(context, expectedRef, expectedHeadSha) {
|
|
|
62910
63077
|
}
|
|
62911
63078
|
}
|
|
62912
63079
|
async function createIndexBaseline(context, sha) {
|
|
62913
|
-
await (0,
|
|
62914
|
-
const tempDir = await (0,
|
|
63080
|
+
await (0, import_promises34.mkdir)(context.tmpDir, { recursive: true, mode: 448 });
|
|
63081
|
+
const tempDir = await (0, import_promises34.mkdtemp)((0, import_node_path21.join)(context.tmpDir, "checkpoint-index-"));
|
|
62915
63082
|
const indexPath = (0, import_node_path21.join)(tempDir, "index");
|
|
62916
63083
|
try {
|
|
62917
63084
|
await context.git.ok(
|
|
@@ -62921,14 +63088,14 @@ async function createIndexBaseline(context, sha) {
|
|
|
62921
63088
|
);
|
|
62922
63089
|
return { indexPath, tempDir };
|
|
62923
63090
|
} catch (error62) {
|
|
62924
|
-
await (0,
|
|
63091
|
+
await (0, import_promises34.rm)(tempDir, { recursive: true, force: true });
|
|
62925
63092
|
throw error62;
|
|
62926
63093
|
}
|
|
62927
63094
|
}
|
|
62928
63095
|
async function installIndexBaseline(locks, baselinePath) {
|
|
62929
63096
|
try {
|
|
62930
|
-
await (0,
|
|
62931
|
-
await (0,
|
|
63097
|
+
await (0, import_promises34.copyFile)(baselinePath, locks.indexLockPath);
|
|
63098
|
+
await (0, import_promises34.rename)(locks.indexLockPath, locks.indexPath);
|
|
62932
63099
|
locks.indexLockHeld = false;
|
|
62933
63100
|
} catch (error62) {
|
|
62934
63101
|
throw new GitFault(
|
|
@@ -62956,7 +63123,7 @@ async function replayCheckpoint(context, expectedRef, headSha) {
|
|
|
62956
63123
|
return { repoRoot: context.repoRoot, sha: headSha, replayed: true };
|
|
62957
63124
|
} finally {
|
|
62958
63125
|
if (locks) await releaseLocks(locks);
|
|
62959
|
-
await (0,
|
|
63126
|
+
await (0, import_promises34.rm)(baseline.tempDir, { recursive: true, force: true });
|
|
62960
63127
|
}
|
|
62961
63128
|
}
|
|
62962
63129
|
async function commitApprovedTree(context, request2) {
|
|
@@ -63087,7 +63254,7 @@ async function finalize2(context, expectedRef, previousSha, sha) {
|
|
|
63087
63254
|
);
|
|
63088
63255
|
}
|
|
63089
63256
|
if (locks) await releaseLocks(locks);
|
|
63090
|
-
await (0,
|
|
63257
|
+
await (0, import_promises34.rm)(baseline.tempDir, { recursive: true, force: true });
|
|
63091
63258
|
}
|
|
63092
63259
|
}
|
|
63093
63260
|
|
|
@@ -63182,7 +63349,7 @@ async function push(context, request2) {
|
|
|
63182
63349
|
var import_node_child_process9 = require("child_process");
|
|
63183
63350
|
|
|
63184
63351
|
// ../agent-core/dist/process.js
|
|
63185
|
-
|
|
63352
|
+
init_chunk_A5UQ6YFO();
|
|
63186
63353
|
init_chunk_YXWJW7I5();
|
|
63187
63354
|
|
|
63188
63355
|
// src/capabilities/git/run-git.ts
|
|
@@ -63363,7 +63530,7 @@ function createGitRunner(options) {
|
|
|
63363
63530
|
|
|
63364
63531
|
// src/capabilities/git/checkout-freshness.ts
|
|
63365
63532
|
var import_node_crypto14 = require("crypto");
|
|
63366
|
-
var
|
|
63533
|
+
var import_promises35 = require("fs/promises");
|
|
63367
63534
|
var import_node_path22 = require("path");
|
|
63368
63535
|
init_zod();
|
|
63369
63536
|
var REMOTE = "origin";
|
|
@@ -63526,14 +63693,14 @@ async function moveSnapshotTo(git, cwd, snapshot, tip, signal) {
|
|
|
63526
63693
|
return moved.exitCode === 0 && back.exitCode === 0;
|
|
63527
63694
|
}
|
|
63528
63695
|
async function isCheckout(path4) {
|
|
63529
|
-
return (0,
|
|
63696
|
+
return (0, import_promises35.stat)((0, import_node_path22.join)(path4, ".git")).then(
|
|
63530
63697
|
() => true,
|
|
63531
63698
|
() => false
|
|
63532
63699
|
);
|
|
63533
63700
|
}
|
|
63534
63701
|
async function checkoutsUnder(root) {
|
|
63535
63702
|
if (await isCheckout(root)) return [root];
|
|
63536
|
-
const entries = await (0,
|
|
63703
|
+
const entries = await (0, import_promises35.readdir)(root, { withFileTypes: true }).catch(() => []);
|
|
63537
63704
|
const found = await Promise.all(
|
|
63538
63705
|
entries.filter((entry) => entry.isDirectory()).map(
|
|
63539
63706
|
async (entry) => await isCheckout((0, import_node_path22.join)(root, entry.name)) ? (0, import_node_path22.join)(root, entry.name) : null
|
|
@@ -63697,7 +63864,7 @@ var GIT_CREDENTIAL_QUIT = "quit=1\n";
|
|
|
63697
63864
|
|
|
63698
63865
|
// src/capabilities/git/credential-server.ts
|
|
63699
63866
|
var import_node_crypto15 = require("crypto");
|
|
63700
|
-
var
|
|
63867
|
+
var import_promises36 = require("fs/promises");
|
|
63701
63868
|
var import_node_net2 = require("net");
|
|
63702
63869
|
|
|
63703
63870
|
// src/capabilities/git/credential-socket.ts
|
|
@@ -63884,7 +64051,7 @@ async function startGitCredentialServer(options) {
|
|
|
63884
64051
|
closing.abort();
|
|
63885
64052
|
await new Promise((resolve14) => server.close(() => resolve14()));
|
|
63886
64053
|
removeStaleEndpoint(options.endpoint);
|
|
63887
|
-
await (0,
|
|
64054
|
+
await (0, import_promises36.rm)(options.tokenPath, { force: true });
|
|
63888
64055
|
}
|
|
63889
64056
|
};
|
|
63890
64057
|
}
|
|
@@ -63934,7 +64101,7 @@ function createGit(options) {
|
|
|
63934
64101
|
// src/capabilities/github-proxy/certificates.ts
|
|
63935
64102
|
var import_node_child_process10 = require("child_process");
|
|
63936
64103
|
var import_node_crypto16 = require("crypto");
|
|
63937
|
-
var
|
|
64104
|
+
var import_promises37 = require("fs/promises");
|
|
63938
64105
|
var import_node_path24 = require("path");
|
|
63939
64106
|
var OPENSSL_TIMEOUT_MS = 1e4;
|
|
63940
64107
|
var VALIDITY_DAYS = "30";
|
|
@@ -63972,13 +64139,13 @@ function openssl(args, cwd) {
|
|
|
63972
64139
|
}
|
|
63973
64140
|
async function createGitHubProxyCertificates(stateDir) {
|
|
63974
64141
|
const work = (0, import_node_path24.join)(stateDir, "github-proxy");
|
|
63975
|
-
await (0,
|
|
63976
|
-
await (0,
|
|
64142
|
+
await (0, import_promises37.rm)(work, { recursive: true, force: true });
|
|
64143
|
+
await (0, import_promises37.mkdir)(work, { recursive: true, mode: 448 });
|
|
63977
64144
|
try {
|
|
63978
|
-
await (0,
|
|
64145
|
+
await (0, import_promises37.writeFile)((0, import_node_path24.join)(work, "ca.cnf"), opensslConfig("Alan sandbox GitHub proxy CA"), {
|
|
63979
64146
|
mode: 384
|
|
63980
64147
|
});
|
|
63981
|
-
await (0,
|
|
64148
|
+
await (0, import_promises37.writeFile)((0, import_node_path24.join)(work, "leaf.cnf"), opensslConfig("github.com"), { mode: 384 });
|
|
63982
64149
|
const curve = ["ecparam", "-name", "prime256v1", "-genkey", "-noout"];
|
|
63983
64150
|
await openssl([...curve, "-out", "ca.key"], work);
|
|
63984
64151
|
await openssl(
|
|
@@ -64002,19 +64169,19 @@ async function createGitHubProxyCertificates(stateDir) {
|
|
|
64002
64169
|
work
|
|
64003
64170
|
);
|
|
64004
64171
|
const caPath = (0, import_node_path24.join)(stateDir, "github-ca.pem");
|
|
64005
|
-
await (0,
|
|
64172
|
+
await (0, import_promises37.writeFile)(caPath, await (0, import_promises37.readFile)((0, import_node_path24.join)(work, "ca.pem")), { mode: 384 });
|
|
64006
64173
|
return {
|
|
64007
64174
|
caPath,
|
|
64008
|
-
leafKeyPem: await (0,
|
|
64009
|
-
leafCertPem: await (0,
|
|
64175
|
+
leafKeyPem: await (0, import_promises37.readFile)((0, import_node_path24.join)(work, "leaf.key"), "utf8"),
|
|
64176
|
+
leafCertPem: await (0, import_promises37.readFile)((0, import_node_path24.join)(work, "leaf.pem"), "utf8")
|
|
64010
64177
|
};
|
|
64011
64178
|
} finally {
|
|
64012
|
-
await (0,
|
|
64179
|
+
await (0, import_promises37.rm)(work, { recursive: true, force: true });
|
|
64013
64180
|
}
|
|
64014
64181
|
}
|
|
64015
64182
|
|
|
64016
64183
|
// src/capabilities/github-proxy/config.ts
|
|
64017
|
-
var
|
|
64184
|
+
var import_promises38 = require("fs/promises");
|
|
64018
64185
|
var import_node_path25 = require("path");
|
|
64019
64186
|
init_runtime_v2();
|
|
64020
64187
|
var GITHUB_URL = "https://github.com/";
|
|
@@ -64031,10 +64198,10 @@ function withGhConfigKey(yaml, key, value2) {
|
|
|
64031
64198
|
`;
|
|
64032
64199
|
}
|
|
64033
64200
|
async function configureGh(ghConfigDir, socketPath) {
|
|
64034
|
-
await (0,
|
|
64201
|
+
await (0, import_promises38.mkdir)(ghConfigDir, { recursive: true, mode: 448 });
|
|
64035
64202
|
const path4 = (0, import_node_path25.join)(ghConfigDir, "config.yml");
|
|
64036
|
-
const current = await (0,
|
|
64037
|
-
await (0,
|
|
64203
|
+
const current = await (0, import_promises38.readFile)(path4, "utf8").catch(() => "");
|
|
64204
|
+
await (0, import_promises38.writeFile)(path4, withGhConfigKey(current, GH_SOCKET_KEY, socketPath), { mode: 384 });
|
|
64038
64205
|
}
|
|
64039
64206
|
async function configureGit(input2, git) {
|
|
64040
64207
|
const run2 = async (args, allowedExitCodes = [0]) => {
|
|
@@ -64064,7 +64231,7 @@ async function configureGitHubProxyClients(input2) {
|
|
|
64064
64231
|
}
|
|
64065
64232
|
|
|
64066
64233
|
// src/capabilities/github-proxy/server.ts
|
|
64067
|
-
var
|
|
64234
|
+
var import_promises39 = require("fs/promises");
|
|
64068
64235
|
var import_node_http3 = require("http");
|
|
64069
64236
|
var import_node_tls = require("tls");
|
|
64070
64237
|
init_runtime_v2();
|
|
@@ -64206,7 +64373,7 @@ async function startGitHubProxy(options) {
|
|
|
64206
64373
|
});
|
|
64207
64374
|
removeStaleEndpoint(options.socketPath);
|
|
64208
64375
|
await listen(gh, options.socketPath);
|
|
64209
|
-
await (0,
|
|
64376
|
+
await (0, import_promises39.chmod)(options.socketPath, 384);
|
|
64210
64377
|
const git = options.certificates === null ? null : await startGitListener(options.certificates, relay);
|
|
64211
64378
|
options.log.info("github_proxy.listening", {
|
|
64212
64379
|
socketPath: options.socketPath,
|
|
@@ -64225,7 +64392,7 @@ async function startGitHubProxy(options) {
|
|
|
64225
64392
|
|
|
64226
64393
|
// src/capabilities/mcp-config/mcp-config.ts
|
|
64227
64394
|
var import_node_crypto17 = require("crypto");
|
|
64228
|
-
var
|
|
64395
|
+
var import_promises40 = require("fs/promises");
|
|
64229
64396
|
var import_node_path26 = require("path");
|
|
64230
64397
|
|
|
64231
64398
|
// ../../node_modules/smol-toml/dist/error.js
|
|
@@ -65175,7 +65342,7 @@ function isCredentialFreeAlanEntry(entry, endpoint) {
|
|
|
65175
65342
|
}
|
|
65176
65343
|
async function isInstalled(cli, home) {
|
|
65177
65344
|
try {
|
|
65178
|
-
return (await (0,
|
|
65345
|
+
return (await (0, import_promises40.stat)((0, import_node_path26.join)(home, cli.guardDir))).isDirectory();
|
|
65179
65346
|
} catch (error62) {
|
|
65180
65347
|
if (errorCode2(error62) === "ENOENT") return false;
|
|
65181
65348
|
throw error62;
|
|
@@ -65183,7 +65350,7 @@ async function isInstalled(cli, home) {
|
|
|
65183
65350
|
}
|
|
65184
65351
|
async function readText3(path4) {
|
|
65185
65352
|
try {
|
|
65186
|
-
return await (0,
|
|
65353
|
+
return await (0, import_promises40.readFile)(path4, "utf8");
|
|
65187
65354
|
} catch (error62) {
|
|
65188
65355
|
if (errorCode2(error62) === "ENOENT") return null;
|
|
65189
65356
|
throw error62;
|
|
@@ -65210,10 +65377,10 @@ async function readConfig(cli, home) {
|
|
|
65210
65377
|
async function writeConfig(path4, text3) {
|
|
65211
65378
|
const temporary = `${path4}.alan-${(0, import_node_crypto17.randomUUID)()}.tmp`;
|
|
65212
65379
|
try {
|
|
65213
|
-
await (0,
|
|
65214
|
-
await (0,
|
|
65380
|
+
await (0, import_promises40.writeFile)(temporary, text3, { encoding: "utf8", mode: 384, flag: "wx" });
|
|
65381
|
+
await (0, import_promises40.rename)(temporary, path4);
|
|
65215
65382
|
} finally {
|
|
65216
|
-
await (0,
|
|
65383
|
+
await (0, import_promises40.rm)(temporary, { force: true });
|
|
65217
65384
|
}
|
|
65218
65385
|
}
|
|
65219
65386
|
async function editCli(cli, home, endpoint, edit) {
|
|
@@ -65291,7 +65458,7 @@ async function inspectAlanMcp(options) {
|
|
|
65291
65458
|
}
|
|
65292
65459
|
|
|
65293
65460
|
// src/capabilities/models/opencode-models.ts
|
|
65294
|
-
var
|
|
65461
|
+
var import_promises41 = require("fs/promises");
|
|
65295
65462
|
var import_node_path27 = require("path");
|
|
65296
65463
|
init_runtime_v2();
|
|
65297
65464
|
init_zod();
|
|
@@ -65607,7 +65774,7 @@ async function readOpenCodeCatalogueCache(env) {
|
|
|
65607
65774
|
const home = env.HOME?.trim();
|
|
65608
65775
|
const cacheHome = env.XDG_CACHE_HOME?.trim() || (home ? (0, import_node_path27.join)(home, ".cache") : "");
|
|
65609
65776
|
if (cacheHome === "") return null;
|
|
65610
|
-
const text3 = await (0,
|
|
65777
|
+
const text3 = await (0, import_promises41.readFile)((0, import_node_path27.join)(cacheHome, ...CATALOGUE_CACHE_SEGMENTS), "utf8").catch(
|
|
65611
65778
|
() => void 0
|
|
65612
65779
|
);
|
|
65613
65780
|
if (text3 === void 0) return null;
|
|
@@ -65726,7 +65893,7 @@ async function discoverModels(backendKind, executable, env, capture) {
|
|
|
65726
65893
|
}
|
|
65727
65894
|
|
|
65728
65895
|
// src/capabilities/models/opencode-entitlement.ts
|
|
65729
|
-
var
|
|
65896
|
+
var import_promises42 = require("fs/promises");
|
|
65730
65897
|
var import_node_os4 = require("os");
|
|
65731
65898
|
var import_node_path28 = require("path");
|
|
65732
65899
|
init_agent2();
|
|
@@ -65736,7 +65903,7 @@ async function readOpenCodeZenCredential(env) {
|
|
|
65736
65903
|
const injected = env.OPENCODE_AUTH_CONTENT?.trim();
|
|
65737
65904
|
if (injected) return readZenCredentialFromAuthDocument(injected);
|
|
65738
65905
|
const dataHome = env.XDG_DATA_HOME?.trim() || (0, import_node_path28.join)(env.HOME?.trim() || (0, import_node_os4.homedir)(), ".local", "share");
|
|
65739
|
-
const document2 = await (0,
|
|
65906
|
+
const document2 = await (0, import_promises42.readFile)((0, import_node_path28.join)(dataHome, "opencode", "auth.json"), "utf8").catch(
|
|
65740
65907
|
() => void 0
|
|
65741
65908
|
);
|
|
65742
65909
|
return readZenCredentialFromAuthDocument(document2);
|
|
@@ -66179,7 +66346,7 @@ function nextAlanBoundary(entry, inFlightFrom) {
|
|
|
66179
66346
|
}
|
|
66180
66347
|
|
|
66181
66348
|
// src/capabilities/native-ingest/pass.ts
|
|
66182
|
-
var
|
|
66349
|
+
var import_promises44 = require("fs/promises");
|
|
66183
66350
|
|
|
66184
66351
|
// src/capabilities/native-ingest/ports.ts
|
|
66185
66352
|
var NativeRequestFailure = class extends Error {
|
|
@@ -66317,7 +66484,7 @@ function reconcileTranscriptIdentity(entry, transcriptPath, identity, size) {
|
|
|
66317
66484
|
|
|
66318
66485
|
// src/capabilities/native-ingest/transcript-window.ts
|
|
66319
66486
|
var import_node_crypto18 = require("crypto");
|
|
66320
|
-
var
|
|
66487
|
+
var import_promises43 = require("fs/promises");
|
|
66321
66488
|
init_acp3();
|
|
66322
66489
|
init_claude();
|
|
66323
66490
|
init_codex();
|
|
@@ -66372,7 +66539,7 @@ async function findRecordEnd(handle, from, size) {
|
|
|
66372
66539
|
return null;
|
|
66373
66540
|
}
|
|
66374
66541
|
async function readTranscriptWindow(path4, offset, limits) {
|
|
66375
|
-
const handle = await (0,
|
|
66542
|
+
const handle = await (0, import_promises43.open)(path4, "r");
|
|
66376
66543
|
try {
|
|
66377
66544
|
const stats = await handle.stat({ bigint: true });
|
|
66378
66545
|
const size = Number(stats.size);
|
|
@@ -66839,7 +67006,7 @@ async function runPass(ctx, worker) {
|
|
|
66839
67006
|
});
|
|
66840
67007
|
if (signal.ending) ctx.log.info("native_ingest.closed", workerFields(worker));
|
|
66841
67008
|
}
|
|
66842
|
-
const current = await (0,
|
|
67009
|
+
const current = await (0, import_promises44.stat)(worker.latest.transcriptPath).catch(() => void 0);
|
|
66843
67010
|
return { grewDuringPass: current !== void 0 && current.size > state.lastSize };
|
|
66844
67011
|
}
|
|
66845
67012
|
|
|
@@ -67196,7 +67363,7 @@ init_alan_code();
|
|
|
67196
67363
|
|
|
67197
67364
|
// src/capabilities/providers/commands.ts
|
|
67198
67365
|
var import_node_fs13 = require("fs");
|
|
67199
|
-
var
|
|
67366
|
+
var import_promises45 = require("fs/promises");
|
|
67200
67367
|
var import_node_path34 = require("path");
|
|
67201
67368
|
var PROVIDER_COMMANDS = [
|
|
67202
67369
|
// The engine, not a CLI of its own: `resolveProviderExecutable` finds the bundled one first.
|
|
@@ -67232,8 +67399,8 @@ function pathDelimiter(platform3) {
|
|
|
67232
67399
|
}
|
|
67233
67400
|
async function isRunnable(path4, platform3) {
|
|
67234
67401
|
try {
|
|
67235
|
-
if (!(await (0,
|
|
67236
|
-
if (platform3 !== "win32") await (0,
|
|
67402
|
+
if (!(await (0, import_promises45.stat)(path4)).isFile()) return false;
|
|
67403
|
+
if (platform3 !== "win32") await (0, import_promises45.access)(path4, import_node_fs13.constants.X_OK);
|
|
67237
67404
|
return true;
|
|
67238
67405
|
} catch {
|
|
67239
67406
|
return false;
|
|
@@ -67298,6 +67465,9 @@ function alanCodeProviderModels() {
|
|
|
67298
67465
|
var import_node_child_process11 = require("child_process");
|
|
67299
67466
|
var DEFAULT_TIMEOUT_MS2 = 5e3;
|
|
67300
67467
|
var DEFAULT_MAX_BYTES = 1024 * 1024;
|
|
67468
|
+
var STOP_TIMEOUT_MS = 3e4;
|
|
67469
|
+
var ProbeShutdownError = class extends Error {
|
|
67470
|
+
};
|
|
67301
67471
|
function withWindowsHelper(env) {
|
|
67302
67472
|
const helper = windowsHelperPath();
|
|
67303
67473
|
return helper === null ? env : { ...env, ALAN_WINHELPER_PATH: helper };
|
|
@@ -67324,16 +67494,19 @@ function directLaunch(command, args, options) {
|
|
|
67324
67494
|
}
|
|
67325
67495
|
}
|
|
67326
67496
|
function captureProbe(command, args, options) {
|
|
67497
|
+
if (options.signal?.aborted) {
|
|
67498
|
+
return Promise.resolve({ stdout: "", stderr: "", exitCode: void 0, failure: "cancelled" });
|
|
67499
|
+
}
|
|
67327
67500
|
const platform3 = options.platform ?? process.platform;
|
|
67328
67501
|
const launch = directLaunch(command, args, options);
|
|
67329
67502
|
if (launch === void 0) return Promise.resolve({ stdout: "", stderr: "", exitCode: void 0 });
|
|
67330
67503
|
const env = platform3 === "win32" ? withWindowsHelper(canonicalWindowsEnvironment(options.env)) : options.env;
|
|
67331
|
-
return new Promise((resolve14) => {
|
|
67504
|
+
return new Promise((resolve14, reject) => {
|
|
67332
67505
|
const limit = options.maxBufferBytes ?? DEFAULT_MAX_BYTES;
|
|
67333
67506
|
const stdout = [];
|
|
67334
67507
|
const stderr = [];
|
|
67335
67508
|
let bytes = 0;
|
|
67336
|
-
let
|
|
67509
|
+
let failure7;
|
|
67337
67510
|
const windowsChild = platform3 === "win32" ? spawnInWindowsJob(planSpawn({ command, args, env, platform: platform3 }), {
|
|
67338
67511
|
cwd: process.cwd(),
|
|
67339
67512
|
env
|
|
@@ -67358,59 +67531,87 @@ function captureProbe(command, args, options) {
|
|
|
67358
67531
|
};
|
|
67359
67532
|
let settled2 = false;
|
|
67360
67533
|
const deadlineController = new AbortController();
|
|
67534
|
+
const startupController = new AbortController();
|
|
67535
|
+
const stopController = new AbortController();
|
|
67536
|
+
const dispose = () => {
|
|
67537
|
+
deadlineController.abort();
|
|
67538
|
+
startupController.abort();
|
|
67539
|
+
stopController.abort();
|
|
67540
|
+
options.signal?.removeEventListener("abort", abort);
|
|
67541
|
+
};
|
|
67361
67542
|
const finish = (exitCode) => {
|
|
67362
67543
|
if (settled2) return;
|
|
67363
67544
|
settled2 = true;
|
|
67364
|
-
|
|
67365
|
-
options.signal?.removeEventListener("abort", abort);
|
|
67545
|
+
dispose();
|
|
67366
67546
|
resolve14({
|
|
67367
67547
|
stdout: Buffer.concat(stdout).toString("utf8"),
|
|
67368
67548
|
stderr: Buffer.concat(stderr).toString("utf8"),
|
|
67369
|
-
exitCode
|
|
67549
|
+
exitCode,
|
|
67550
|
+
...failure7 === void 0 ? {} : { failure: failure7 }
|
|
67370
67551
|
});
|
|
67371
67552
|
};
|
|
67372
|
-
|
|
67373
|
-
()
|
|
67374
|
-
|
|
67375
|
-
|
|
67376
|
-
|
|
67377
|
-
finish(void 0);
|
|
67378
|
-
},
|
|
67379
|
-
() => void 0
|
|
67380
|
-
);
|
|
67381
|
-
const abort = () => {
|
|
67553
|
+
const stop = (reason) => {
|
|
67554
|
+
if (settled2 || failure7 !== void 0) return;
|
|
67555
|
+
failure7 = reason;
|
|
67556
|
+
deadlineController.abort();
|
|
67557
|
+
startupController.abort();
|
|
67382
67558
|
terminate2();
|
|
67383
67559
|
child.stdout.destroy();
|
|
67384
67560
|
child.stderr.destroy();
|
|
67385
|
-
|
|
67561
|
+
void systemClock.sleep(STOP_TIMEOUT_MS, stopController.signal).then(
|
|
67562
|
+
() => {
|
|
67563
|
+
if (settled2) return;
|
|
67564
|
+
settled2 = true;
|
|
67565
|
+
dispose();
|
|
67566
|
+
reject(
|
|
67567
|
+
new ProbeShutdownError(`${reason}; process did not close within ${STOP_TIMEOUT_MS}ms`)
|
|
67568
|
+
);
|
|
67569
|
+
},
|
|
67570
|
+
() => void 0
|
|
67571
|
+
);
|
|
67572
|
+
};
|
|
67573
|
+
const abort = () => stop("cancelled");
|
|
67574
|
+
const startDeadline = () => {
|
|
67575
|
+
if (settled2 || failure7 !== void 0) return;
|
|
67576
|
+
const timeout = options.timeoutMs ?? DEFAULT_TIMEOUT_MS2;
|
|
67577
|
+
void systemClock.sleep(timeout, deadlineController.signal).then(
|
|
67578
|
+
() => stop(`command timed out after ${timeout}ms`),
|
|
67579
|
+
() => void 0
|
|
67580
|
+
);
|
|
67386
67581
|
};
|
|
67387
|
-
options.signal?.addEventListener("abort", abort, { once: true });
|
|
67388
|
-
if (options.signal?.aborted) abort();
|
|
67389
67582
|
const collect = (into) => (chunk) => {
|
|
67583
|
+
if (failure7 !== void 0) return;
|
|
67390
67584
|
bytes += chunk.length;
|
|
67391
67585
|
if (bytes > limit) {
|
|
67392
|
-
|
|
67393
|
-
terminate2();
|
|
67394
|
-
finish(void 0);
|
|
67586
|
+
stop(`output exceeded ${limit} bytes`);
|
|
67395
67587
|
return;
|
|
67396
67588
|
}
|
|
67397
67589
|
into.push(chunk);
|
|
67398
67590
|
};
|
|
67399
67591
|
child.stdout.on("data", collect(stdout));
|
|
67400
67592
|
child.stderr.on("data", collect(stderr));
|
|
67401
|
-
child.once("error", () =>
|
|
67593
|
+
child.once("error", (error62) => stop(`launch failed: ${error62.message}`));
|
|
67402
67594
|
child.once(
|
|
67403
67595
|
"close",
|
|
67404
|
-
(code, signal) => finish(
|
|
67596
|
+
(code, signal) => finish(failure7 !== void 0 || signal !== null || code === null ? void 0 : code)
|
|
67405
67597
|
);
|
|
67406
67598
|
if (windowsChild !== void 0) {
|
|
67407
|
-
void waitForWindowsJob(windowsChild, command
|
|
67408
|
-
|
|
67599
|
+
void waitForWindowsJob(windowsChild, command, {
|
|
67600
|
+
timeoutMs: options.startupTimeoutMs,
|
|
67601
|
+
signal: startupController.signal
|
|
67602
|
+
}).then(startDeadline, (error62) => {
|
|
67603
|
+
if (!settled2 && failure7 === void 0) {
|
|
67604
|
+
stop(error62 instanceof Error ? error62.message : "Windows startup failed");
|
|
67605
|
+
}
|
|
67606
|
+
});
|
|
67607
|
+
} else startDeadline();
|
|
67608
|
+
options.signal?.addEventListener("abort", abort, { once: true });
|
|
67609
|
+
if (options.signal?.aborted) abort();
|
|
67409
67610
|
});
|
|
67410
67611
|
}
|
|
67411
67612
|
|
|
67412
67613
|
// src/capabilities/providers/inventory.ts
|
|
67413
|
-
var
|
|
67614
|
+
var import_promises46 = require("fs/promises");
|
|
67414
67615
|
var import_node_os5 = require("os");
|
|
67415
67616
|
init_runtime_v2();
|
|
67416
67617
|
|
|
@@ -67870,8 +68071,8 @@ async function executablesFingerprint(env, platform3) {
|
|
|
67870
68071
|
const executable = await resolveProviderExecutable(provider4, env, platform3);
|
|
67871
68072
|
if (executable === null) return `${provider4.backendKind}:-`;
|
|
67872
68073
|
try {
|
|
67873
|
-
const target = await (0,
|
|
67874
|
-
const { size, mtimeMs } = await (0,
|
|
68074
|
+
const target = await (0, import_promises46.realpath)(executable);
|
|
68075
|
+
const { size, mtimeMs } = await (0, import_promises46.stat)(target);
|
|
67875
68076
|
return `${provider4.backendKind}:${target}:${size}:${mtimeMs}`;
|
|
67876
68077
|
} catch {
|
|
67877
68078
|
return `${provider4.backendKind}:${executable}:?`;
|
|
@@ -68108,15 +68309,15 @@ async function readLoginShellPath(env, capture) {
|
|
|
68108
68309
|
});
|
|
68109
68310
|
return between(login.stdout);
|
|
68110
68311
|
}
|
|
68111
|
-
function appendPathDirectories(first, extra,
|
|
68112
|
-
const directories = first.split(
|
|
68312
|
+
function appendPathDirectories(first, extra, delimiter2) {
|
|
68313
|
+
const directories = first.split(delimiter2).filter((directory) => directory.length > 0);
|
|
68113
68314
|
const seen = new Set(directories);
|
|
68114
68315
|
for (const directory of extra) {
|
|
68115
68316
|
if (directory.length === 0 || seen.has(directory)) continue;
|
|
68116
68317
|
seen.add(directory);
|
|
68117
68318
|
directories.push(directory);
|
|
68118
68319
|
}
|
|
68119
|
-
return directories.join(
|
|
68320
|
+
return directories.join(delimiter2);
|
|
68120
68321
|
}
|
|
68121
68322
|
async function readLastKnownGood(file2) {
|
|
68122
68323
|
if (file2 === void 0) return null;
|
|
@@ -68145,15 +68346,15 @@ async function resolveCliEnvironmentDetailed(options) {
|
|
|
68145
68346
|
if (loginPath !== null) await rememberLastKnownGood(options.lastKnownGoodFile, loginPath);
|
|
68146
68347
|
const lastKnownGood = loginPath === null ? await readLastKnownGood(options.lastKnownGoodFile) : null;
|
|
68147
68348
|
const shellPath = loginPath ?? lastKnownGood;
|
|
68148
|
-
const
|
|
68349
|
+
const delimiter2 = pathDelimiter(platform3);
|
|
68149
68350
|
const home = envValue(env, "HOME");
|
|
68150
68351
|
const versionManagers = home.length > 0 ? resolveVersionManagerBinDirs(home, platform3) : [];
|
|
68151
68352
|
const extra = [
|
|
68152
|
-
...shellPath?.split(
|
|
68353
|
+
...shellPath?.split(delimiter2) ?? [],
|
|
68153
68354
|
...installerDirectories(home, platform3),
|
|
68154
68355
|
...versionManagers
|
|
68155
68356
|
];
|
|
68156
|
-
const combined = appendPathDirectories(envValue(env, "PATH"), extra,
|
|
68357
|
+
const combined = appendPathDirectories(envValue(env, "PATH"), extra, delimiter2);
|
|
68157
68358
|
const key = Object.keys(env).find((candidate) => candidate.toUpperCase() === "PATH") ?? "PATH";
|
|
68158
68359
|
return {
|
|
68159
68360
|
env: { ...env, [key]: promoteUserBinDirs(combined, home, versionManagers) },
|
|
@@ -68188,7 +68389,7 @@ async function openCliEnvironment(options) {
|
|
|
68188
68389
|
|
|
68189
68390
|
// src/capabilities/providers/managed.ts
|
|
68190
68391
|
var import_node_crypto20 = require("crypto");
|
|
68191
|
-
var
|
|
68392
|
+
var import_promises47 = require("fs/promises");
|
|
68192
68393
|
var import_node_path40 = require("path");
|
|
68193
68394
|
init_zod();
|
|
68194
68395
|
var PACKAGES = {
|
|
@@ -68203,9 +68404,26 @@ var PACKAGES = {
|
|
|
68203
68404
|
};
|
|
68204
68405
|
var VERSION = /^[0-9]+\.[0-9]+\.[0-9]+(?:[-+][0-9A-Za-z.-]+)?$/;
|
|
68205
68406
|
var selectedSchema = external_exports.record(external_exports.string(), external_exports.string());
|
|
68407
|
+
var MANAGED_PROBE_TIMEOUT_MS = 6e4;
|
|
68408
|
+
async function cleanFailedInstall(staged, error62) {
|
|
68409
|
+
if (error62 instanceof ProbeShutdownError) {
|
|
68410
|
+
throw new Error(`${error62.message}; retained staging directory: ${staged}`, { cause: error62 });
|
|
68411
|
+
}
|
|
68412
|
+
try {
|
|
68413
|
+
await (0, import_promises47.rm)(staged, { recursive: true, force: true, maxRetries: 5, retryDelay: 200 });
|
|
68414
|
+
} catch (cleanupError) {
|
|
68415
|
+
const message2 = error62 instanceof Error ? error62.message : String(error62);
|
|
68416
|
+
throw new AggregateError(
|
|
68417
|
+
[error62, cleanupError],
|
|
68418
|
+
`${message2}; staging cleanup also failed: ${staged}`,
|
|
68419
|
+
{ cause: error62 }
|
|
68420
|
+
);
|
|
68421
|
+
}
|
|
68422
|
+
throw error62;
|
|
68423
|
+
}
|
|
68206
68424
|
async function readManagedProviderVersion(file2, backendKind) {
|
|
68207
68425
|
try {
|
|
68208
|
-
const selected = selectedSchema.parse(JSON.parse(await (0,
|
|
68426
|
+
const selected = selectedSchema.parse(JSON.parse(await (0, import_promises47.readFile)(file2, "utf8")));
|
|
68209
68427
|
const version2 = selected[backendKind];
|
|
68210
68428
|
return version2 !== void 0 && VERSION.test(version2) ? version2 : null;
|
|
68211
68429
|
} catch {
|
|
@@ -68272,7 +68490,7 @@ function selection(root, backendKind, version2) {
|
|
|
68272
68490
|
};
|
|
68273
68491
|
}
|
|
68274
68492
|
async function runnable(file2) {
|
|
68275
|
-
return (0,
|
|
68493
|
+
return (0, import_promises47.stat)(file2).then(
|
|
68276
68494
|
(value2) => value2.isFile(),
|
|
68277
68495
|
() => false
|
|
68278
68496
|
);
|
|
@@ -68315,20 +68533,21 @@ function createManagedProviderClis(options) {
|
|
|
68315
68533
|
return next;
|
|
68316
68534
|
};
|
|
68317
68535
|
const persist = async () => {
|
|
68318
|
-
await (0,
|
|
68536
|
+
await (0, import_promises47.mkdir)(options.root, { recursive: true, mode: 448 });
|
|
68319
68537
|
const staged = `${file2}.${(0, import_node_crypto20.randomUUID)()}`;
|
|
68320
68538
|
try {
|
|
68321
|
-
await (0,
|
|
68322
|
-
await (0,
|
|
68539
|
+
await (0, import_promises47.writeFile)(staged, JSON.stringify(state), { mode: 384 });
|
|
68540
|
+
await (0, import_promises47.rename)(staged, file2);
|
|
68323
68541
|
} finally {
|
|
68324
|
-
await (0,
|
|
68542
|
+
await (0, import_promises47.rm)(staged, { force: true });
|
|
68325
68543
|
}
|
|
68326
68544
|
};
|
|
68327
|
-
const activate = async (backendKind, version2) => {
|
|
68545
|
+
const activate = async (backendKind, version2, signal) => {
|
|
68328
68546
|
const next = selection(options.root, backendKind, checkedVersion(version2));
|
|
68329
|
-
if (!await runnable(next.executable) || !await options.probe(next.executable, backendKind)) {
|
|
68547
|
+
if (!await runnable(next.executable) || !await options.probe(next.executable, backendKind, signal)) {
|
|
68330
68548
|
throw new Error(`${backendKind}@${version2} failed its executable probe`);
|
|
68331
68549
|
}
|
|
68550
|
+
signal?.throwIfAborted();
|
|
68332
68551
|
const previous = state[backendKind];
|
|
68333
68552
|
state[backendKind] = version2;
|
|
68334
68553
|
try {
|
|
@@ -68343,7 +68562,7 @@ function createManagedProviderClis(options) {
|
|
|
68343
68562
|
return {
|
|
68344
68563
|
selectionFile: file2,
|
|
68345
68564
|
load: async () => {
|
|
68346
|
-
const raw = await (0,
|
|
68565
|
+
const raw = await (0, import_promises47.readFile)(file2, "utf8").catch((error62) => {
|
|
68347
68566
|
if (error62 instanceof Error && "code" in error62 && error62.code === "ENOENT") return "{}";
|
|
68348
68567
|
throw error62;
|
|
68349
68568
|
});
|
|
@@ -68351,7 +68570,7 @@ function createManagedProviderClis(options) {
|
|
|
68351
68570
|
try {
|
|
68352
68571
|
parsed = selectedSchema.parse(JSON.parse(raw));
|
|
68353
68572
|
} catch {
|
|
68354
|
-
await (0,
|
|
68573
|
+
await (0, import_promises47.rename)(file2, `${file2}.invalid.${(0, import_node_crypto20.randomUUID)()}`).catch(() => void 0);
|
|
68355
68574
|
return;
|
|
68356
68575
|
}
|
|
68357
68576
|
for (const [backendKind, version2] of Object.entries(parsed)) {
|
|
@@ -68371,7 +68590,7 @@ function createManagedProviderClis(options) {
|
|
|
68371
68590
|
const groups = await Promise.all(
|
|
68372
68591
|
Object.keys(PACKAGES).map(async (backendKind) => {
|
|
68373
68592
|
const directory = (0, import_node_path40.join)(options.root, "versions", backendKind);
|
|
68374
|
-
const versions = await (0,
|
|
68593
|
+
const versions = await (0, import_promises47.readdir)(directory).catch((error62) => {
|
|
68375
68594
|
if (error62 instanceof Error && "code" in error62 && error62.code === "ENOENT") return [];
|
|
68376
68595
|
throw error62;
|
|
68377
68596
|
});
|
|
@@ -68403,26 +68622,28 @@ function createManagedProviderClis(options) {
|
|
|
68403
68622
|
return results;
|
|
68404
68623
|
},
|
|
68405
68624
|
install: (backendKind, version2, signal) => serialize(async () => {
|
|
68625
|
+
signal?.throwIfAborted();
|
|
68406
68626
|
const provider4 = packageFor(backendKind);
|
|
68407
68627
|
const exact = await installVersion2(backendKind, version2, options, signal);
|
|
68408
68628
|
const target = (0, import_node_path40.join)(options.root, "versions", backendKind, exact);
|
|
68409
68629
|
const existing = selection(options.root, backendKind, exact);
|
|
68410
|
-
if (!await runnable(existing.executable) || !await options.probe(existing.executable, backendKind)) {
|
|
68411
|
-
await (0,
|
|
68630
|
+
if (!await runnable(existing.executable) || !await options.probe(existing.executable, backendKind, signal)) {
|
|
68631
|
+
await (0, import_promises47.mkdir)((0, import_node_path40.dirname)(target), { recursive: true, mode: 448 });
|
|
68412
68632
|
const staged = `${target}.${(0, import_node_crypto20.randomUUID)()}`;
|
|
68413
68633
|
try {
|
|
68414
68634
|
await options.installPackage(provider4.name, exact, staged, provider4.command, signal);
|
|
68415
68635
|
const built = (0, import_node_path40.join)(staged, "node_modules", ".bin", provider4.command);
|
|
68416
|
-
if (!await runnable(built) || !await options.probe(built, backendKind)) {
|
|
68636
|
+
if (!await runnable(built) || !await options.probe(built, backendKind, signal)) {
|
|
68417
68637
|
throw new Error(`${backendKind}@${exact} failed its executable probe`);
|
|
68418
68638
|
}
|
|
68419
|
-
|
|
68420
|
-
await (0,
|
|
68421
|
-
|
|
68422
|
-
|
|
68639
|
+
signal?.throwIfAborted();
|
|
68640
|
+
await (0, import_promises47.rm)(target, { recursive: true, force: true });
|
|
68641
|
+
await (0, import_promises47.rename)(staged, target);
|
|
68642
|
+
} catch (error62) {
|
|
68643
|
+
await cleanFailedInstall(staged, error62);
|
|
68423
68644
|
}
|
|
68424
68645
|
}
|
|
68425
|
-
return activate(backendKind, exact);
|
|
68646
|
+
return activate(backendKind, exact, signal);
|
|
68426
68647
|
}),
|
|
68427
68648
|
select: (backendKind, version2) => serialize(() => activate(backendKind, version2)),
|
|
68428
68649
|
useExternal: (backendKind) => serialize(async () => {
|
|
@@ -68472,7 +68693,7 @@ function createNpmPackageInstaller(options) {
|
|
|
68472
68693
|
const output2 = `${result.stdout}
|
|
68473
68694
|
${result.stderr}`.trim().slice(-8e3);
|
|
68474
68695
|
throw new Error(
|
|
68475
|
-
`npm install failed (${result.exitCode ?? "timeout, cancellation or launch"}): ${output2}`
|
|
68696
|
+
`npm install failed (${result.failure ?? result.exitCode ?? "timeout, cancellation or launch"}): ${output2}`
|
|
68476
68697
|
);
|
|
68477
68698
|
}
|
|
68478
68699
|
};
|
|
@@ -68498,10 +68719,12 @@ function parseNpmVersion(output2, packageName) {
|
|
|
68498
68719
|
if (latest === void 0) throw new Error(`No ${packageName} version found`);
|
|
68499
68720
|
return checkedVersion(latest);
|
|
68500
68721
|
}
|
|
68501
|
-
async function probeManagedProvider(executable, backendKind, env) {
|
|
68722
|
+
async function probeManagedProvider(executable, backendKind, env, signal) {
|
|
68502
68723
|
const result = await captureProbe(executable, ["--version"], {
|
|
68503
68724
|
env: { ...env },
|
|
68504
|
-
|
|
68725
|
+
signal,
|
|
68726
|
+
startupTimeoutMs: MANAGED_PROBE_TIMEOUT_MS,
|
|
68727
|
+
timeoutMs: MANAGED_PROBE_TIMEOUT_MS
|
|
68505
68728
|
});
|
|
68506
68729
|
if (result.exitCode !== 0) return false;
|
|
68507
68730
|
if (backendKind === "opencode_serve" && !/\b1\.\d+\.\d+\b/.test(result.stdout)) return false;
|
|
@@ -68515,30 +68738,32 @@ async function probeManagedProvider(executable, backendKind, env) {
|
|
|
68515
68738
|
if (required2 === void 0) return true;
|
|
68516
68739
|
const help = await captureProbe(executable, required2.args, {
|
|
68517
68740
|
env: { ...env },
|
|
68518
|
-
|
|
68741
|
+
signal,
|
|
68742
|
+
startupTimeoutMs: MANAGED_PROBE_TIMEOUT_MS,
|
|
68743
|
+
timeoutMs: MANAGED_PROBE_TIMEOUT_MS
|
|
68519
68744
|
});
|
|
68520
68745
|
return help.exitCode === 0 && required2.pattern.test(`${help.stdout}
|
|
68521
68746
|
${help.stderr}`);
|
|
68522
68747
|
}
|
|
68523
68748
|
|
|
68524
68749
|
// src/capabilities/skills/legacy-cleanup.ts
|
|
68525
|
-
var
|
|
68750
|
+
var import_promises48 = require("fs/promises");
|
|
68526
68751
|
var import_node_path41 = require("path");
|
|
68527
68752
|
var LEGACY_FOLDER = /--(?:alan-(?:production|staging|local(?:-[0-9a-f]{12})?)|[0-9a-f]{8})$/;
|
|
68528
68753
|
var MANAGED_MARKER = ".alan-managed.json";
|
|
68529
68754
|
var COMPATIBILITY_MARKER = ".alan-compatibility.json";
|
|
68530
68755
|
async function listEntries(directory) {
|
|
68531
|
-
return (0,
|
|
68756
|
+
return (0, import_promises48.readdir)(directory, { withFileTypes: true }).catch(() => []);
|
|
68532
68757
|
}
|
|
68533
68758
|
async function isRegularFile(path4) {
|
|
68534
|
-
return (0,
|
|
68759
|
+
return (0, import_promises48.lstat)(path4).then(
|
|
68535
68760
|
(stats) => stats.isFile(),
|
|
68536
68761
|
() => false
|
|
68537
68762
|
);
|
|
68538
68763
|
}
|
|
68539
68764
|
async function isMissing(path4) {
|
|
68540
68765
|
try {
|
|
68541
|
-
await (0,
|
|
68766
|
+
await (0, import_promises48.lstat)(path4);
|
|
68542
68767
|
return false;
|
|
68543
68768
|
} catch (error62) {
|
|
68544
68769
|
return errnoCode(error62) === "ENOENT";
|
|
@@ -68546,15 +68771,15 @@ async function isMissing(path4) {
|
|
|
68546
68771
|
}
|
|
68547
68772
|
async function removeLink(path4) {
|
|
68548
68773
|
try {
|
|
68549
|
-
await (0,
|
|
68774
|
+
await (0, import_promises48.unlink)(path4);
|
|
68550
68775
|
} catch (error62) {
|
|
68551
68776
|
const code = errnoCode(error62);
|
|
68552
68777
|
if (code !== "EPERM" && code !== "EISDIR") throw error62;
|
|
68553
|
-
await (0,
|
|
68778
|
+
await (0, import_promises48.rmdir)(path4);
|
|
68554
68779
|
}
|
|
68555
68780
|
}
|
|
68556
68781
|
async function isOrphanedLegacyLink(agentsDir, path4, removed) {
|
|
68557
|
-
const target = await (0,
|
|
68782
|
+
const target = await (0, import_promises48.readlink)(path4).catch(() => null);
|
|
68558
68783
|
if (target === null) return false;
|
|
68559
68784
|
const absolute = (0, import_node_path41.resolve)((0, import_node_path41.dirname)(path4), target);
|
|
68560
68785
|
return (0, import_node_path41.dirname)(absolute) === agentsDir && (removed.has(absolute) || LEGACY_FOLDER.test((0, import_node_path41.basename)(absolute))) && await isMissing(absolute);
|
|
@@ -68564,7 +68789,7 @@ async function removeLegacyPackages(agentsDir, attempt2) {
|
|
|
68564
68789
|
for (const entry of await listEntries(agentsDir)) {
|
|
68565
68790
|
const path4 = (0, import_node_path41.join)(agentsDir, entry.name);
|
|
68566
68791
|
if (!entry.isDirectory() || !await isRegularFile((0, import_node_path41.join)(path4, MANAGED_MARKER))) continue;
|
|
68567
|
-
if (await attempt2(path4, () => (0,
|
|
68792
|
+
if (await attempt2(path4, () => (0, import_promises48.rm)(path4, { recursive: true, force: true }))) removed.push(path4);
|
|
68568
68793
|
}
|
|
68569
68794
|
return removed;
|
|
68570
68795
|
}
|
|
@@ -68578,7 +68803,7 @@ async function removeLegacyClaudeEntries(claudeDir, agentsDir, removedPackages,
|
|
|
68578
68803
|
for (const entry of await listEntries(claudeDir)) {
|
|
68579
68804
|
const path4 = (0, import_node_path41.join)(claudeDir, entry.name);
|
|
68580
68805
|
if (!await isLegacyClaudeEntry(agentsDir, path4, entry, removedSet)) continue;
|
|
68581
|
-
const remove = entry.isSymbolicLink() ? () => removeLink(path4) : () => (0,
|
|
68806
|
+
const remove = entry.isSymbolicLink() ? () => removeLink(path4) : () => (0, import_promises48.rm)(path4, { recursive: true, force: true });
|
|
68582
68807
|
if (await attempt2(path4, remove)) removed.push(path4);
|
|
68583
68808
|
}
|
|
68584
68809
|
return removed;
|
|
@@ -68603,18 +68828,18 @@ async function removeLegacySkillFolders(home) {
|
|
|
68603
68828
|
attempt2
|
|
68604
68829
|
);
|
|
68605
68830
|
const profiles = (0, import_node_path41.join)(home, ".alan", "skills", "profiles");
|
|
68606
|
-
const profilesRemoved = !await isMissing(profiles) && await attempt2(profiles, () => (0,
|
|
68831
|
+
const profilesRemoved = !await isMissing(profiles) && await attempt2(profiles, () => (0, import_promises48.rm)(profiles, { recursive: true, force: true }));
|
|
68607
68832
|
return { packages, links, profilesRemoved, failed };
|
|
68608
68833
|
}
|
|
68609
68834
|
|
|
68610
68835
|
// src/capabilities/skills/local-preview.ts
|
|
68611
|
-
var
|
|
68836
|
+
var import_promises53 = require("fs/promises");
|
|
68612
68837
|
var import_node_path46 = __toESM(require("path"));
|
|
68613
68838
|
|
|
68614
68839
|
// ../shared/dist/node/skill-package.js
|
|
68615
68840
|
var import_node_buffer = require("buffer");
|
|
68616
68841
|
var import_node_crypto21 = require("crypto");
|
|
68617
|
-
var
|
|
68842
|
+
var import_promises49 = require("fs/promises");
|
|
68618
68843
|
var import_node_path42 = require("path");
|
|
68619
68844
|
var import_yaml = __toESM(require_dist(), 1);
|
|
68620
68845
|
init_contracts();
|
|
@@ -68710,11 +68935,11 @@ async function readSkillPackageFile(packageRoot, path4, expectedSha256) {
|
|
|
68710
68935
|
if (!normalizedPath || normalizedPath !== path4 || normalizedPath.includes("\\") || components.some((component) => !component || component === "." || component === "..")) {
|
|
68711
68936
|
throw new SkillPackageError("INVALID_PATH", `Invalid Skill package path: ${path4}`, path4);
|
|
68712
68937
|
}
|
|
68713
|
-
const absolutePath = await (0,
|
|
68938
|
+
const absolutePath = await (0, import_promises49.realpath)((0, import_node_path42.resolve)(root, ...components)).catch(() => null);
|
|
68714
68939
|
if (!absolutePath || normalizeRelativePath(root, absolutePath) !== normalizedPath) {
|
|
68715
68940
|
throw new SkillPackageError("INVALID_PATH", `Skill package file was not found: ${path4}`, path4);
|
|
68716
68941
|
}
|
|
68717
|
-
const entryStat = await (0,
|
|
68942
|
+
const entryStat = await (0, import_promises49.lstat)(absolutePath);
|
|
68718
68943
|
if (!entryStat.isFile()) {
|
|
68719
68944
|
throw new SkillPackageError("SPECIAL_FILE_BLOCKED", `Only regular files are allowed in Skill packages: ${path4}`, path4);
|
|
68720
68945
|
}
|
|
@@ -68731,11 +68956,11 @@ async function readSkillPackageFile(packageRoot, path4, expectedSha256) {
|
|
|
68731
68956
|
return { file: read.manifest, bytes: read.bytes };
|
|
68732
68957
|
}
|
|
68733
68958
|
async function requirePackageRoot(packageRoot) {
|
|
68734
|
-
const root = await (0,
|
|
68959
|
+
const root = await (0, import_promises49.realpath)((0, import_node_path42.resolve)(packageRoot)).catch(() => null);
|
|
68735
68960
|
if (!root) {
|
|
68736
68961
|
throw new SkillPackageError("INVALID_PACKAGE_ROOT", "Skill package directory does not exist");
|
|
68737
68962
|
}
|
|
68738
|
-
const rootStat = await (0,
|
|
68963
|
+
const rootStat = await (0, import_promises49.lstat)(root);
|
|
68739
68964
|
if (!rootStat.isDirectory()) {
|
|
68740
68965
|
throw new SkillPackageError("INVALID_PACKAGE_ROOT", "Skill package root must be a directory");
|
|
68741
68966
|
}
|
|
@@ -68755,13 +68980,13 @@ async function walkPackage(root, ignoredPaths) {
|
|
|
68755
68980
|
}
|
|
68756
68981
|
return files;
|
|
68757
68982
|
async function walkDirectory(directory) {
|
|
68758
|
-
const entries = await (0,
|
|
68983
|
+
const entries = await (0, import_promises49.readdir)(directory, { withFileTypes: true });
|
|
68759
68984
|
for (const entry of entries) {
|
|
68760
68985
|
const absolutePath = (0, import_node_path42.resolve)(directory, entry.name);
|
|
68761
68986
|
const normalizedPath = normalizeRelativePath(root, absolutePath);
|
|
68762
68987
|
if (isIgnored(normalizedPath, entry.name, entry.isDirectory(), ignored2))
|
|
68763
68988
|
continue;
|
|
68764
|
-
const entryStat = await (0,
|
|
68989
|
+
const entryStat = await (0, import_promises49.lstat)(absolutePath);
|
|
68765
68990
|
if (entryStat.isSymbolicLink()) {
|
|
68766
68991
|
throw new SkillPackageError("SYMLINK_BLOCKED", `Nested symbolic links are not allowed in Skill packages: ${normalizedPath}`, normalizedPath);
|
|
68767
68992
|
}
|
|
@@ -68870,7 +69095,7 @@ function isSecretPath(path4) {
|
|
|
68870
69095
|
return name.endsWith(".private-key.pem") || name.endsWith(".private-key.key");
|
|
68871
69096
|
}
|
|
68872
69097
|
async function readPackageFile(file2) {
|
|
68873
|
-
const bytes = await (0,
|
|
69098
|
+
const bytes = await (0, import_promises49.readFile)(file2.absolutePath);
|
|
68874
69099
|
return {
|
|
68875
69100
|
bytes,
|
|
68876
69101
|
manifest: {
|
|
@@ -69042,13 +69267,13 @@ function uint642(value2) {
|
|
|
69042
69267
|
|
|
69043
69268
|
// src/capabilities/skills/local-sources.ts
|
|
69044
69269
|
var import_node_crypto23 = require("crypto");
|
|
69045
|
-
var
|
|
69270
|
+
var import_promises51 = require("fs/promises");
|
|
69046
69271
|
var import_node_path44 = __toESM(require("path"));
|
|
69047
69272
|
init_type_guards();
|
|
69048
69273
|
|
|
69049
69274
|
// src/capabilities/skills/local-scan.ts
|
|
69050
69275
|
var import_node_crypto22 = require("crypto");
|
|
69051
|
-
var
|
|
69276
|
+
var import_promises50 = require("fs/promises");
|
|
69052
69277
|
var import_node_path43 = __toESM(require("path"));
|
|
69053
69278
|
var MAX_CANDIDATES = 2e3;
|
|
69054
69279
|
var MAX_DIAGNOSTICS = 100;
|
|
@@ -69169,7 +69394,7 @@ function invalid(resolvedRoot, name, error62) {
|
|
|
69169
69394
|
}
|
|
69170
69395
|
async function scanRootAsPackage(pass, resolvedRoot) {
|
|
69171
69396
|
if (!await exists3(import_node_path43.default.join(resolvedRoot.directory, "SKILL.md"))) return null;
|
|
69172
|
-
const canonical = await (0,
|
|
69397
|
+
const canonical = await (0, import_promises50.realpath)(resolvedRoot.directory).catch(() => resolvedRoot.directory);
|
|
69173
69398
|
if (isManaged(pass, canonical)) return { candidates: [], diagnostics: [], incomplete: false };
|
|
69174
69399
|
try {
|
|
69175
69400
|
const inspected = await inspectCached(pass, canonical, null);
|
|
@@ -69199,7 +69424,7 @@ async function scanRoot(pass, resolvedRoot) {
|
|
|
69199
69424
|
if (asPackage !== null) return asPackage;
|
|
69200
69425
|
let entries;
|
|
69201
69426
|
try {
|
|
69202
|
-
entries = await (0,
|
|
69427
|
+
entries = await (0, import_promises50.readdir)(resolvedRoot.directory, { withFileTypes: true });
|
|
69203
69428
|
} catch (error62) {
|
|
69204
69429
|
const code = errnoCode(error62);
|
|
69205
69430
|
if (code === "ENOENT" || code === "ENOTDIR") {
|
|
@@ -69217,7 +69442,7 @@ async function scanRoot(pass, resolvedRoot) {
|
|
|
69217
69442
|
incomplete: true
|
|
69218
69443
|
};
|
|
69219
69444
|
}
|
|
69220
|
-
const canonicalRoot = await (0,
|
|
69445
|
+
const canonicalRoot = await (0, import_promises50.realpath)(resolvedRoot.directory).catch(() => resolvedRoot.directory);
|
|
69221
69446
|
const scan = { candidates: [], diagnostics: [], incomplete: false };
|
|
69222
69447
|
for (const entry of entries) {
|
|
69223
69448
|
if (!entry.isDirectory() && !entry.isSymbolicLink()) continue;
|
|
@@ -69229,7 +69454,7 @@ async function scanRoot(pass, resolvedRoot) {
|
|
|
69229
69454
|
}
|
|
69230
69455
|
async function scanEntry(pass, resolvedRoot, canonicalRoot, name) {
|
|
69231
69456
|
const rootLabel = resolvedRoot.root.label;
|
|
69232
|
-
const canonical = await (0,
|
|
69457
|
+
const canonical = await (0, import_promises50.realpath)(import_node_path43.default.join(resolvedRoot.directory, name)).catch(() => null);
|
|
69233
69458
|
if (canonical === null) {
|
|
69234
69459
|
const message2 = `Could not resolve Skill ${name}`;
|
|
69235
69460
|
return { kind: "diagnostic", diagnostic: { code: "SOURCE_UNREADABLE", message: message2, rootLabel } };
|
|
@@ -69314,12 +69539,12 @@ function deduplicateByContent(candidates2) {
|
|
|
69314
69539
|
async function fingerprintPackage(root) {
|
|
69315
69540
|
const hash2 = (0, import_node_crypto22.createHash)("sha256").update("alan-skill-stat-fingerprint-v1\0");
|
|
69316
69541
|
const visit2 = async (directory, relativeDirectory) => {
|
|
69317
|
-
const entries = await (0,
|
|
69542
|
+
const entries = await (0, import_promises50.readdir)(directory, { withFileTypes: true });
|
|
69318
69543
|
entries.sort((left, right) => Buffer.compare(Buffer.from(left.name), Buffer.from(right.name)));
|
|
69319
69544
|
for (const entry of entries) {
|
|
69320
69545
|
const relative6 = relativeDirectory ? `${relativeDirectory}/${entry.name}` : entry.name;
|
|
69321
69546
|
const absolute = import_node_path43.default.join(directory, entry.name);
|
|
69322
|
-
const metadata = await (0,
|
|
69547
|
+
const metadata = await (0, import_promises50.lstat)(absolute);
|
|
69323
69548
|
const kind = entryKind(entry);
|
|
69324
69549
|
hash2.update(relative6.normalize("NFC")).update(`\0${kind}\0${metadata.size}\0${metadata.mtimeMs}\0${metadata.mode & 511}\0`);
|
|
69325
69550
|
if (entry.isDirectory()) await visit2(absolute, relative6);
|
|
@@ -69335,7 +69560,7 @@ function entryKind(entry) {
|
|
|
69335
69560
|
}
|
|
69336
69561
|
async function canonicalDirectories(directories) {
|
|
69337
69562
|
const canonical = await Promise.all(
|
|
69338
|
-
directories.map((directory) => (0,
|
|
69563
|
+
directories.map((directory) => (0, import_promises50.realpath)(directory).catch(() => directory))
|
|
69339
69564
|
);
|
|
69340
69565
|
return [...new Set(canonical)];
|
|
69341
69566
|
}
|
|
@@ -69348,7 +69573,7 @@ function isWithinDirectory2(parent, candidate) {
|
|
|
69348
69573
|
}
|
|
69349
69574
|
async function exists3(candidate) {
|
|
69350
69575
|
try {
|
|
69351
|
-
await (0,
|
|
69576
|
+
await (0, import_promises50.access)(candidate);
|
|
69352
69577
|
return true;
|
|
69353
69578
|
} catch {
|
|
69354
69579
|
return false;
|
|
@@ -69356,7 +69581,7 @@ async function exists3(candidate) {
|
|
|
69356
69581
|
}
|
|
69357
69582
|
async function isDirectory3(candidate) {
|
|
69358
69583
|
try {
|
|
69359
|
-
return (await (0,
|
|
69584
|
+
return (await (0, import_promises50.lstat)(candidate)).isDirectory();
|
|
69360
69585
|
} catch {
|
|
69361
69586
|
return false;
|
|
69362
69587
|
}
|
|
@@ -69444,7 +69669,7 @@ async function resolveLocalScanInput(home, context, mode) {
|
|
|
69444
69669
|
async function readSkillSourceConfig(home) {
|
|
69445
69670
|
let content;
|
|
69446
69671
|
try {
|
|
69447
|
-
content = await (0,
|
|
69672
|
+
content = await (0, import_promises51.readFile)(skillSourceConfigPath(home), "utf8");
|
|
69448
69673
|
} catch (error62) {
|
|
69449
69674
|
if (errnoCode(error62) !== "ENOENT") {
|
|
69450
69675
|
return { kind: "invalid_config", diagnostic: "~/.alan/config.toml could not be read" };
|
|
@@ -69561,7 +69786,7 @@ async function scanLocalSkills(home, context, cache2, mode = "incremental", mana
|
|
|
69561
69786
|
}
|
|
69562
69787
|
|
|
69563
69788
|
// src/capabilities/skills/store.ts
|
|
69564
|
-
var
|
|
69789
|
+
var import_promises52 = require("fs/promises");
|
|
69565
69790
|
var import_node_path45 = require("path");
|
|
69566
69791
|
|
|
69567
69792
|
// ../shared/dist/node/alan-skill-identity.js
|
|
@@ -69632,7 +69857,7 @@ function writeLocalSkills(layout, file2) {
|
|
|
69632
69857
|
async function isLocalSkillCurrent(entry, contentHash, ignoredPaths) {
|
|
69633
69858
|
if (entry.contentHash !== contentHash) return false;
|
|
69634
69859
|
try {
|
|
69635
|
-
if (await (0,
|
|
69860
|
+
if (await (0, import_promises52.realpath)(entry.path) !== entry.path) return false;
|
|
69636
69861
|
const inspected = await inspectSkillPackage(entry.path, { expectedName: null, ignoredPaths });
|
|
69637
69862
|
return inspected.contentHash === contentHash;
|
|
69638
69863
|
} catch {
|
|
@@ -69647,7 +69872,7 @@ async function resolveLocalSkill(local, invocation) {
|
|
|
69647
69872
|
}
|
|
69648
69873
|
async function hasSkillFile(directory) {
|
|
69649
69874
|
try {
|
|
69650
|
-
return (await (0,
|
|
69875
|
+
return (await (0, import_promises52.stat)((0, import_node_path45.join)(directory, "SKILL.md"))).isFile();
|
|
69651
69876
|
} catch {
|
|
69652
69877
|
return false;
|
|
69653
69878
|
}
|
|
@@ -69704,7 +69929,7 @@ async function resolveSkillInvocations(layout, invocations, baked = "any") {
|
|
|
69704
69929
|
async function nativeCandidates(layout) {
|
|
69705
69930
|
const nativeDir = layout.nativeDir;
|
|
69706
69931
|
if (nativeDir === null) return [];
|
|
69707
|
-
const entries = await (0,
|
|
69932
|
+
const entries = await (0, import_promises52.readdir)(nativeDir, { withFileTypes: true }).catch(() => []);
|
|
69708
69933
|
return entries.filter((entry) => entry.isDirectory() || entry.isSymbolicLink()).map((entry) => ({ directory: (0, import_node_path45.join)(nativeDir, entry.name) }));
|
|
69709
69934
|
}
|
|
69710
69935
|
async function availableSkillIndex(layout, sources = { synced: true, native: true }) {
|
|
@@ -69802,7 +70027,7 @@ async function readLocalSkillFile(layout, ref) {
|
|
|
69802
70027
|
}
|
|
69803
70028
|
async function isDirectory4(candidate) {
|
|
69804
70029
|
try {
|
|
69805
|
-
return (await (0,
|
|
70030
|
+
return (await (0, import_promises53.stat)(candidate)).isDirectory();
|
|
69806
70031
|
} catch {
|
|
69807
70032
|
return false;
|
|
69808
70033
|
}
|
|
@@ -69815,21 +70040,21 @@ async function addSkillSource(home, input2) {
|
|
|
69815
70040
|
return { state: "invalid", diagnostic: `${sourcePath} is not a folder` };
|
|
69816
70041
|
}
|
|
69817
70042
|
const configPath = skillSourceConfigPath(home);
|
|
69818
|
-
await (0,
|
|
69819
|
-
await (0,
|
|
70043
|
+
await (0, import_promises53.mkdir)(import_node_path46.default.dirname(configPath), { recursive: true, mode: 448 });
|
|
70044
|
+
await (0, import_promises53.writeFile)(configPath, DEFAULT_SKILL_CONFIG, { flag: "wx", mode: 384 }).catch(
|
|
69820
70045
|
(error62) => {
|
|
69821
70046
|
if (errnoCode(error62) !== "EEXIST") throw error62;
|
|
69822
70047
|
}
|
|
69823
70048
|
);
|
|
69824
70049
|
const loaded = await readSkillSourceConfig(home);
|
|
69825
70050
|
if (loaded.kind === "invalid_config") return { state: "invalid", diagnostic: loaded.diagnostic };
|
|
69826
|
-
const canonical = await (0,
|
|
70051
|
+
const canonical = await (0, import_promises53.realpath)(sourcePath).catch(() => sourcePath);
|
|
69827
70052
|
for (const source of loaded.config.sources) {
|
|
69828
|
-
if (await (0,
|
|
70053
|
+
if (await (0, import_promises53.realpath)(source.path).catch(() => source.path) === canonical) {
|
|
69829
70054
|
return { state: "already_present", label: source.label };
|
|
69830
70055
|
}
|
|
69831
70056
|
}
|
|
69832
|
-
const current = await (0,
|
|
70057
|
+
const current = await (0, import_promises53.readFile)(configPath, "utf8");
|
|
69833
70058
|
const block2 = [
|
|
69834
70059
|
"",
|
|
69835
70060
|
"[[skills.sources]]",
|
|
@@ -69837,7 +70062,7 @@ async function addSkillSource(home, input2) {
|
|
|
69837
70062
|
`label = ${JSON.stringify(label)}`,
|
|
69838
70063
|
""
|
|
69839
70064
|
].join("\n");
|
|
69840
|
-
await (0,
|
|
70065
|
+
await (0, import_promises53.writeFile)(configPath, `${current.replace(/\n*$/, "\n")}${block2}`, { mode: 384 });
|
|
69841
70066
|
const reloaded = await readSkillSourceConfig(home);
|
|
69842
70067
|
if (reloaded.kind === "invalid_config") {
|
|
69843
70068
|
return { state: "invalid", diagnostic: reloaded.diagnostic };
|
|
@@ -69846,12 +70071,12 @@ async function addSkillSource(home, input2) {
|
|
|
69846
70071
|
}
|
|
69847
70072
|
|
|
69848
70073
|
// src/capabilities/skills/local-upload.ts
|
|
69849
|
-
var
|
|
70074
|
+
var import_promises55 = require("fs/promises");
|
|
69850
70075
|
|
|
69851
70076
|
// ../shared/dist/node/skill-bundle.js
|
|
69852
70077
|
var import_node_buffer2 = require("buffer");
|
|
69853
70078
|
var import_node_crypto25 = require("crypto");
|
|
69854
|
-
var
|
|
70079
|
+
var import_promises54 = require("fs/promises");
|
|
69855
70080
|
var import_node_path47 = require("path");
|
|
69856
70081
|
var import_node_stream = require("stream");
|
|
69857
70082
|
var import_node_zlib = require("zlib");
|
|
@@ -69862,7 +70087,7 @@ async function createSkillBundle(packageRoot, options = {}) {
|
|
|
69862
70087
|
const archive = (0, import_tar_stream.pack)();
|
|
69863
70088
|
const tarPromise = collectStream(archive);
|
|
69864
70089
|
for (const file2 of before.files) {
|
|
69865
|
-
const bytes2 = await (0,
|
|
70090
|
+
const bytes2 = await (0, import_promises54.readFile)((0, import_node_path47.join)(packageRoot, ...file2.path.split("/")));
|
|
69866
70091
|
await addArchiveEntry(archive, {
|
|
69867
70092
|
name: file2.path,
|
|
69868
70093
|
type: "file",
|
|
@@ -69894,7 +70119,7 @@ async function extractSkillBundle(archiveBytes, destination, expected) {
|
|
|
69894
70119
|
throw new Error("Skill archive hash does not match the expected immutable Version");
|
|
69895
70120
|
}
|
|
69896
70121
|
const tarBytes = await decompressBounded(archiveBytes);
|
|
69897
|
-
await (0,
|
|
70122
|
+
await (0, import_promises54.mkdir)(destination, { recursive: false, mode: 448 });
|
|
69898
70123
|
try {
|
|
69899
70124
|
await extractTar(tarBytes, destination);
|
|
69900
70125
|
const inspected = await inspectSkillPackage(destination, { expectedName: null });
|
|
@@ -69902,7 +70127,7 @@ async function extractSkillBundle(archiveBytes, destination, expected) {
|
|
|
69902
70127
|
throw new Error("Extracted Skill package hash does not match the expected immutable Version");
|
|
69903
70128
|
}
|
|
69904
70129
|
} catch (error62) {
|
|
69905
|
-
await (0,
|
|
70130
|
+
await (0, import_promises54.rm)(destination, { recursive: true, force: true });
|
|
69906
70131
|
throw error62;
|
|
69907
70132
|
}
|
|
69908
70133
|
}
|
|
@@ -69978,8 +70203,8 @@ async function extractEntry(header, stream, destination, limits) {
|
|
|
69978
70203
|
throw new Error(`Skill archive file size is invalid: ${path4}`);
|
|
69979
70204
|
}
|
|
69980
70205
|
const outputPath = (0, import_node_path47.join)(destination, ...path4.split("/"));
|
|
69981
|
-
await (0,
|
|
69982
|
-
await (0,
|
|
70206
|
+
await (0, import_promises54.mkdir)((0, import_node_path47.dirname)(outputPath), { recursive: true, mode: 448 });
|
|
70207
|
+
await (0, import_promises54.writeFile)(outputPath, bytes, { mode: (header.mode ?? 420) & 73 ? 493 : 420 });
|
|
69983
70208
|
}
|
|
69984
70209
|
function requireSafeArchivePath(value2) {
|
|
69985
70210
|
const normalized2 = value2.replaceAll("\\", "/").normalize("NFC");
|
|
@@ -70005,8 +70230,8 @@ async function publishLocalSkill(options) {
|
|
|
70005
70230
|
if (Date.parse(request2.uploadGrant.expiresAt) <= (options.now ?? Date.now())) {
|
|
70006
70231
|
throw new RuntimeFault("invalid_file", "Skill upload grant expired");
|
|
70007
70232
|
}
|
|
70008
|
-
const folder = await (0,
|
|
70009
|
-
if (!folder.isDirectory() || await (0,
|
|
70233
|
+
const folder = await (0, import_promises55.lstat)(entry.path);
|
|
70234
|
+
if (!folder.isDirectory() || await (0, import_promises55.realpath)(entry.path) !== entry.path) {
|
|
70010
70235
|
throw new RuntimeFault("invalid_file", "Skill folder moved since the last scan");
|
|
70011
70236
|
}
|
|
70012
70237
|
const bundle = await createSkillBundle(entry.path, {
|
|
@@ -70035,7 +70260,7 @@ async function publishLocalSkill(options) {
|
|
|
70035
70260
|
// src/capabilities/skills/native-index.ts
|
|
70036
70261
|
var import_node_crypto26 = require("crypto");
|
|
70037
70262
|
var import_node_fs17 = require("fs");
|
|
70038
|
-
var
|
|
70263
|
+
var import_promises56 = require("fs/promises");
|
|
70039
70264
|
var import_node_path48 = require("path");
|
|
70040
70265
|
var ALAN_SKILLS_PLUGIN_NAME = "alan";
|
|
70041
70266
|
var PLUGIN_MANIFEST = `${JSON.stringify(
|
|
@@ -70049,32 +70274,32 @@ var PLUGIN_MANIFEST = `${JSON.stringify(
|
|
|
70049
70274
|
`;
|
|
70050
70275
|
async function entryKind2(path4) {
|
|
70051
70276
|
try {
|
|
70052
|
-
return (await (0,
|
|
70277
|
+
return (await (0, import_promises56.lstat)(path4)).isSymbolicLink() ? "link" : "other";
|
|
70053
70278
|
} catch (error62) {
|
|
70054
70279
|
if (errnoCode(error62) === "ENOENT") return "missing";
|
|
70055
70280
|
throw error62;
|
|
70056
70281
|
}
|
|
70057
70282
|
}
|
|
70058
70283
|
async function linkTarget(path4) {
|
|
70059
|
-
return (0,
|
|
70284
|
+
return (0, import_promises56.readlink)(path4).catch(() => null);
|
|
70060
70285
|
}
|
|
70061
70286
|
async function removeLink2(path4) {
|
|
70062
70287
|
try {
|
|
70063
|
-
await (0,
|
|
70288
|
+
await (0, import_promises56.unlink)(path4);
|
|
70064
70289
|
} catch (error62) {
|
|
70065
70290
|
const code = errnoCode(error62);
|
|
70066
70291
|
if (code === "ENOENT") return;
|
|
70067
70292
|
if (code !== "EPERM" && code !== "EISDIR") throw error62;
|
|
70068
|
-
await (0,
|
|
70293
|
+
await (0, import_promises56.rmdir)(path4);
|
|
70069
70294
|
}
|
|
70070
70295
|
}
|
|
70071
70296
|
async function placeLink(plan2, platform3) {
|
|
70072
70297
|
if (await linkTarget(plan2.path) === plan2.target) return false;
|
|
70073
70298
|
const staged = (0, import_node_path48.join)((0, import_node_path48.dirname)(plan2.path), `.${(0, import_node_path48.basename)(plan2.path)}.${(0, import_node_crypto26.randomUUID)()}.tmp`);
|
|
70074
|
-
await (0,
|
|
70299
|
+
await (0, import_promises56.symlink)(plan2.target, staged, platform3 === "win32" ? "junction" : "dir");
|
|
70075
70300
|
try {
|
|
70076
70301
|
if (platform3 === "win32") await removeLink2(plan2.path);
|
|
70077
|
-
await (0,
|
|
70302
|
+
await (0, import_promises56.rename)(staged, plan2.path);
|
|
70078
70303
|
} catch (error62) {
|
|
70079
70304
|
await removeLink2(staged).catch(() => void 0);
|
|
70080
70305
|
throw error62;
|
|
@@ -70087,14 +70312,14 @@ function versionTarget(layout, versionId, platform3) {
|
|
|
70087
70312
|
}
|
|
70088
70313
|
async function writeManifest(layout) {
|
|
70089
70314
|
const manifest = (0, import_node_path48.join)(layout.pluginDir, ".claude-plugin", "plugin.json");
|
|
70090
|
-
if (await (0,
|
|
70091
|
-
await (0,
|
|
70315
|
+
if (await (0, import_promises56.readFile)(manifest, "utf8").catch(() => null) === PLUGIN_MANIFEST) return;
|
|
70316
|
+
await (0, import_promises56.mkdir)((0, import_node_path48.dirname)(manifest), { recursive: true, mode: 448 });
|
|
70092
70317
|
const staged = `${manifest}.${(0, import_node_crypto26.randomUUID)()}.tmp`;
|
|
70093
|
-
await (0,
|
|
70094
|
-
await (0,
|
|
70318
|
+
await (0, import_promises56.writeFile)(staged, PLUGIN_MANIFEST, { mode: 384 });
|
|
70319
|
+
await (0, import_promises56.rename)(staged, manifest);
|
|
70095
70320
|
}
|
|
70096
70321
|
async function reconcilePluginSkills(layout, installed, platform3) {
|
|
70097
|
-
await (0,
|
|
70322
|
+
await (0, import_promises56.mkdir)(layout.pluginSkillsDir, { recursive: true, mode: 448 });
|
|
70098
70323
|
const wanted = new Map(installed.map((skill) => [skill.slug, skill]));
|
|
70099
70324
|
let linked = 0;
|
|
70100
70325
|
for (const skill of installed) {
|
|
@@ -70103,16 +70328,16 @@ async function reconcilePluginSkills(layout, installed, platform3) {
|
|
|
70103
70328
|
target: versionTarget(layout, skill.versionId, platform3)
|
|
70104
70329
|
};
|
|
70105
70330
|
if (await entryKind2(plan2.path) === "other") {
|
|
70106
|
-
await (0,
|
|
70331
|
+
await (0, import_promises56.rm)(plan2.path, { recursive: true, force: true });
|
|
70107
70332
|
}
|
|
70108
70333
|
if (await placeLink(plan2, platform3)) linked += 1;
|
|
70109
70334
|
}
|
|
70110
70335
|
let unlinked = 0;
|
|
70111
|
-
for (const name of await (0,
|
|
70336
|
+
for (const name of await (0, import_promises56.readdir)(layout.pluginSkillsDir)) {
|
|
70112
70337
|
if (wanted.has(name)) continue;
|
|
70113
70338
|
const path4 = (0, import_node_path48.join)(layout.pluginSkillsDir, name);
|
|
70114
70339
|
if (await entryKind2(path4) === "link") await removeLink2(path4);
|
|
70115
|
-
else await (0,
|
|
70340
|
+
else await (0, import_promises56.rm)(path4, { recursive: true, force: true });
|
|
70116
70341
|
unlinked += 1;
|
|
70117
70342
|
}
|
|
70118
70343
|
return { linked, unlinked };
|
|
@@ -70124,9 +70349,9 @@ async function isOwnCodexLink(layout, path4) {
|
|
|
70124
70349
|
return isWithinDirectory2(layout.pluginSkillsDir, absolute);
|
|
70125
70350
|
}
|
|
70126
70351
|
async function isForeignPackage(layout, path4) {
|
|
70127
|
-
const resolved = await (0,
|
|
70352
|
+
const resolved = await (0, import_promises56.realpath)(path4).catch(() => null);
|
|
70128
70353
|
if (resolved === null) return false;
|
|
70129
|
-
const root = await (0,
|
|
70354
|
+
const root = await (0, import_promises56.realpath)(layout.root).catch(() => layout.root);
|
|
70130
70355
|
return !isWithinDirectory2(root, resolved);
|
|
70131
70356
|
}
|
|
70132
70357
|
async function codexSlot(layout, path4, slug) {
|
|
@@ -70143,7 +70368,7 @@ async function codexSlot(layout, path4, slug) {
|
|
|
70143
70368
|
}
|
|
70144
70369
|
async function unlinkStaleCodexEntries(layout, codexSkillsDir2, wanted) {
|
|
70145
70370
|
let unlinked = 0;
|
|
70146
|
-
for (const name of await (0,
|
|
70371
|
+
for (const name of await (0, import_promises56.readdir)(codexSkillsDir2)) {
|
|
70147
70372
|
const path4 = (0, import_node_path48.join)(codexSkillsDir2, name);
|
|
70148
70373
|
if (wanted.has(name) && !name.endsWith(".tmp")) continue;
|
|
70149
70374
|
if (await entryKind2(path4) !== "link" || !await isOwnCodexLink(layout, path4)) continue;
|
|
@@ -70153,7 +70378,7 @@ async function unlinkStaleCodexEntries(layout, codexSkillsDir2, wanted) {
|
|
|
70153
70378
|
return unlinked;
|
|
70154
70379
|
}
|
|
70155
70380
|
async function reconcileCodexSkills(layout, installed, codexSkillsDir2, platform3) {
|
|
70156
|
-
await (0,
|
|
70381
|
+
await (0, import_promises56.mkdir)(codexSkillsDir2, { recursive: true, mode: 448 });
|
|
70157
70382
|
const report2 = { linked: 0, unlinked: 0, skipped: [] };
|
|
70158
70383
|
for (const skill of installed) {
|
|
70159
70384
|
const path4 = (0, import_node_path48.join)(codexSkillsDir2, skill.slug);
|
|
@@ -70190,7 +70415,7 @@ function installedSkillFolders(layout) {
|
|
|
70190
70415
|
|
|
70191
70416
|
// src/capabilities/skills/sync.ts
|
|
70192
70417
|
var import_node_crypto27 = require("crypto");
|
|
70193
|
-
var
|
|
70418
|
+
var import_promises57 = require("fs/promises");
|
|
70194
70419
|
var import_node_path49 = require("path");
|
|
70195
70420
|
init_zod();
|
|
70196
70421
|
var SKILL_PREPARE_WAIT_MS = 15e3;
|
|
@@ -70198,28 +70423,28 @@ var FIRST_INSTALL_WAIT_MS = 5e3;
|
|
|
70198
70423
|
var RETIRED_VERSION_RETENTION_MS = 24 * 60 * 60 * 1e3;
|
|
70199
70424
|
async function makeFilesReadOnly(directory, platform3) {
|
|
70200
70425
|
if (platform3 === "win32") return;
|
|
70201
|
-
for (const entry of await (0,
|
|
70426
|
+
for (const entry of await (0, import_promises57.readdir)(directory, { withFileTypes: true })) {
|
|
70202
70427
|
const path4 = (0, import_node_path49.join)(directory, entry.name);
|
|
70203
70428
|
if (entry.isDirectory()) await makeFilesReadOnly(path4, platform3);
|
|
70204
70429
|
else if (entry.isFile()) {
|
|
70205
|
-
const executable = ((await (0,
|
|
70206
|
-
await (0,
|
|
70430
|
+
const executable = ((await (0, import_promises57.lstat)(path4)).mode & 64) !== 0;
|
|
70431
|
+
await (0, import_promises57.chmod)(path4, executable ? 365 : 292);
|
|
70207
70432
|
}
|
|
70208
70433
|
}
|
|
70209
70434
|
}
|
|
70210
70435
|
async function install(env, skill, download, signal) {
|
|
70211
70436
|
const { layout, source, platform: platform3 } = env;
|
|
70212
70437
|
const bytes = await source.download(download.url, signal);
|
|
70213
|
-
await (0,
|
|
70438
|
+
await (0, import_promises57.mkdir)(layout.tmpDir, { recursive: true, mode: 448 });
|
|
70214
70439
|
const staging = (0, import_node_path49.join)(layout.tmpDir, (0, import_node_crypto27.randomUUID)());
|
|
70215
70440
|
await extractSkillBundle(Buffer.from(bytes), staging, {
|
|
70216
70441
|
expectedArchiveHash: download.archiveHash,
|
|
70217
70442
|
expectedContentHash: skill.contentHash
|
|
70218
70443
|
});
|
|
70219
70444
|
const target = packageDirectory(layout, skill.versionId);
|
|
70220
|
-
await (0,
|
|
70221
|
-
await (0,
|
|
70222
|
-
await (0,
|
|
70445
|
+
await (0, import_promises57.mkdir)(layout.versionsDir, { recursive: true, mode: 448 });
|
|
70446
|
+
await (0, import_promises57.rm)(target, { recursive: true, force: true });
|
|
70447
|
+
await (0, import_promises57.rename)(staging, target);
|
|
70223
70448
|
await makeFilesReadOnly(target, platform3);
|
|
70224
70449
|
}
|
|
70225
70450
|
var retiredFileSchema = external_exports.record(external_exports.string(), external_exports.number());
|
|
@@ -70231,14 +70456,14 @@ async function sweep(env, keep) {
|
|
|
70231
70456
|
const now = env.now();
|
|
70232
70457
|
const stillRetired = {};
|
|
70233
70458
|
const expired = [];
|
|
70234
|
-
for (const name of await (0,
|
|
70459
|
+
for (const name of await (0, import_promises57.readdir)(layout.versionsDir).catch(() => [])) {
|
|
70235
70460
|
if (kept.has(name)) continue;
|
|
70236
70461
|
const since = retired[name] ?? now;
|
|
70237
70462
|
if (now - since >= RETIRED_VERSION_RETENTION_MS) expired.push(name);
|
|
70238
70463
|
else stillRetired[name] = since;
|
|
70239
70464
|
}
|
|
70240
70465
|
const results = await Promise.allSettled(
|
|
70241
|
-
expired.map((name) => (0,
|
|
70466
|
+
expired.map((name) => (0, import_promises57.rm)((0, import_node_path49.join)(layout.versionsDir, name), { recursive: true, force: true }))
|
|
70242
70467
|
);
|
|
70243
70468
|
results.forEach((result, index) => {
|
|
70244
70469
|
const name = expired[index];
|
|
@@ -70247,7 +70472,7 @@ async function sweep(env, keep) {
|
|
|
70247
70472
|
if (JSON.stringify(stillRetired) !== JSON.stringify(retired)) {
|
|
70248
70473
|
await writeJsonFileAtomic(layout.retiredFile, stillRetired);
|
|
70249
70474
|
}
|
|
70250
|
-
await (0,
|
|
70475
|
+
await (0, import_promises57.rm)(layout.tmpDir, { recursive: true, force: true });
|
|
70251
70476
|
return results.filter((result) => result.status === "fulfilled").length;
|
|
70252
70477
|
}
|
|
70253
70478
|
var INSTALL_CONCURRENCY = 4;
|
|
@@ -70593,7 +70818,7 @@ var import_node_path52 = require("path");
|
|
|
70593
70818
|
init_runtime_v2();
|
|
70594
70819
|
|
|
70595
70820
|
// src/capabilities/workspace/approved-paths.ts
|
|
70596
|
-
var
|
|
70821
|
+
var import_promises58 = require("fs/promises");
|
|
70597
70822
|
init_zod();
|
|
70598
70823
|
|
|
70599
70824
|
// src/capabilities/workspace/paths.ts
|
|
@@ -70631,7 +70856,7 @@ var storeSchema = external_exports.object({
|
|
|
70631
70856
|
});
|
|
70632
70857
|
async function realpathOrNull(path4) {
|
|
70633
70858
|
try {
|
|
70634
|
-
return await (0,
|
|
70859
|
+
return await (0, import_promises58.realpath)(path4);
|
|
70635
70860
|
} catch (error62) {
|
|
70636
70861
|
const code = errnoCode(error62);
|
|
70637
70862
|
if (code === "ENOENT" || code === "ENOTDIR" || code === "EACCES" || code === "EPERM") {
|
|
@@ -70691,7 +70916,7 @@ async function openApprovedPaths(options) {
|
|
|
70691
70916
|
|
|
70692
70917
|
// src/capabilities/workspace/locks.ts
|
|
70693
70918
|
var import_node_crypto28 = require("crypto");
|
|
70694
|
-
var
|
|
70919
|
+
var import_promises59 = require("fs/promises");
|
|
70695
70920
|
var import_node_path51 = require("path");
|
|
70696
70921
|
init_zod();
|
|
70697
70922
|
var LOCK_FORMAT = 1;
|
|
@@ -70712,7 +70937,7 @@ function repositoryLockKey(commonDir, platform3) {
|
|
|
70712
70937
|
async function readOwner2(path4) {
|
|
70713
70938
|
let text3;
|
|
70714
70939
|
try {
|
|
70715
|
-
text3 = await (0,
|
|
70940
|
+
text3 = await (0, import_promises59.readFile)(path4, "utf8");
|
|
70716
70941
|
} catch (error62) {
|
|
70717
70942
|
if (errnoCode(error62) === "ENOENT") return { kind: "missing" };
|
|
70718
70943
|
return { kind: "unreadable" };
|
|
@@ -70733,7 +70958,7 @@ async function removeIfSame(path4, expected) {
|
|
|
70733
70958
|
if (current.kind !== "owner" || current.owner.since !== expected.since) return;
|
|
70734
70959
|
if (current.owner.pid !== expected.pid || current.owner.holder !== expected.holder) return;
|
|
70735
70960
|
}
|
|
70736
|
-
await (0,
|
|
70961
|
+
await (0, import_promises59.unlink)(path4).catch((error62) => {
|
|
70737
70962
|
if (errnoCode(error62) !== "ENOENT") throw error62;
|
|
70738
70963
|
});
|
|
70739
70964
|
}
|
|
@@ -70758,7 +70983,7 @@ function openRepositoryLocks(options) {
|
|
|
70758
70983
|
await removeIfSame(path4, read.owner);
|
|
70759
70984
|
return null;
|
|
70760
70985
|
}
|
|
70761
|
-
const age = await (0,
|
|
70986
|
+
const age = await (0, import_promises59.stat)(path4).then(
|
|
70762
70987
|
(info) => clock.now() - info.mtimeMs,
|
|
70763
70988
|
() => 0
|
|
70764
70989
|
);
|
|
@@ -70773,12 +70998,12 @@ function openRepositoryLocks(options) {
|
|
|
70773
70998
|
const folder = async (commonDir) => {
|
|
70774
70999
|
const key = repositoryLockKey(commonDir, platform3);
|
|
70775
71000
|
const dir = (0, import_node_path51.join)(options.dir, key);
|
|
70776
|
-
await (0,
|
|
71001
|
+
await (0, import_promises59.mkdir)(dir, { recursive: true, mode: 448 });
|
|
70777
71002
|
return { key, dir };
|
|
70778
71003
|
};
|
|
70779
71004
|
const createExclusive = async (path4, owner) => {
|
|
70780
71005
|
try {
|
|
70781
|
-
const handle = await (0,
|
|
71006
|
+
const handle = await (0, import_promises59.open)(path4, "wx", 384);
|
|
70782
71007
|
try {
|
|
70783
71008
|
await handle.writeFile(JSON.stringify(owner));
|
|
70784
71009
|
} finally {
|
|
@@ -70791,7 +71016,7 @@ function openRepositoryLocks(options) {
|
|
|
70791
71016
|
}
|
|
70792
71017
|
};
|
|
70793
71018
|
const liveRun = async (dir) => {
|
|
70794
|
-
const entries = await (0,
|
|
71019
|
+
const entries = await (0, import_promises59.readdir)(dir);
|
|
70795
71020
|
for (const entry of entries) {
|
|
70796
71021
|
if (!entry.startsWith(RUN_FILE_PREFIX)) continue;
|
|
70797
71022
|
const holder = await heldBy((0, import_node_path51.join)(dir, entry));
|
|
@@ -71315,17 +71540,17 @@ function createConversationMcpAuthorization(options) {
|
|
|
71315
71540
|
}
|
|
71316
71541
|
|
|
71317
71542
|
// src/holder/mcp-helper-access.ts
|
|
71318
|
-
var
|
|
71543
|
+
var import_promises60 = require("fs/promises");
|
|
71319
71544
|
function createHelperMcpAccess(options) {
|
|
71320
71545
|
return {
|
|
71321
71546
|
[Symbol.asyncDispose]: async () => {
|
|
71322
|
-
await (0,
|
|
71547
|
+
await (0, import_promises60.rm)(options.credentialPath, { force: true });
|
|
71323
71548
|
},
|
|
71324
71549
|
url: options.managedMcp.url,
|
|
71325
71550
|
authorization: async (signal) => {
|
|
71326
71551
|
const authorization = await options.managedMcp.authorization(signal);
|
|
71327
71552
|
if (authorization === void 0 || signal.aborted) {
|
|
71328
|
-
await (0,
|
|
71553
|
+
await (0, import_promises60.rm)(options.credentialPath, { force: true });
|
|
71329
71554
|
return void 0;
|
|
71330
71555
|
}
|
|
71331
71556
|
const credential = {
|
|
@@ -71340,7 +71565,7 @@ function createHelperMcpAccess(options) {
|
|
|
71340
71565
|
}
|
|
71341
71566
|
|
|
71342
71567
|
// src/holder/run-inputs.ts
|
|
71343
|
-
var
|
|
71568
|
+
var import_promises61 = require("fs/promises");
|
|
71344
71569
|
var import_node_path55 = require("path");
|
|
71345
71570
|
init_dist();
|
|
71346
71571
|
var NO_RUN_INPUTS = {
|
|
@@ -71377,7 +71602,7 @@ function runMediaUploader(source, runId) {
|
|
|
71377
71602
|
async function prepareRunInputs(spec, { source, tmpDir, signal, skills = [] }) {
|
|
71378
71603
|
const dir = (0, import_node_path55.join)(tmpDir, "runs", spec.runId);
|
|
71379
71604
|
const cleanup = async () => {
|
|
71380
|
-
await (0,
|
|
71605
|
+
await (0, import_promises61.rm)(dir, { recursive: true, force: true });
|
|
71381
71606
|
};
|
|
71382
71607
|
try {
|
|
71383
71608
|
const credential = await source.fetchProviderCredential(spec.runId, signal);
|
|
@@ -71385,8 +71610,8 @@ async function prepareRunInputs(spec, { source, tmpDir, signal, skills = [] }) {
|
|
|
71385
71610
|
for (const [index, attachment] of (spec.attachments ?? []).entries()) {
|
|
71386
71611
|
const bytes = await source.downloadAttachment(spec.runId, attachment.id, signal);
|
|
71387
71612
|
const path4 = attachmentPath(spec, attachment, index, dir);
|
|
71388
|
-
await (0,
|
|
71389
|
-
await (0,
|
|
71613
|
+
await (0, import_promises61.mkdir)((0, import_node_path55.dirname)(path4), { recursive: true, mode: 448 });
|
|
71614
|
+
await (0, import_promises61.writeFile)(path4, bytes, { mode: 384 });
|
|
71390
71615
|
const imageMimeType = attachment.kind === "image" ? detectImageMimeType(Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength)) : null;
|
|
71391
71616
|
attachments.push({
|
|
71392
71617
|
id: attachment.id,
|
|
@@ -71424,7 +71649,7 @@ init_runtime_v2();
|
|
|
71424
71649
|
|
|
71425
71650
|
// src/holder/admission.ts
|
|
71426
71651
|
var import_node_fs20 = require("fs");
|
|
71427
|
-
var
|
|
71652
|
+
var import_promises65 = require("fs/promises");
|
|
71428
71653
|
var import_node_os9 = require("os");
|
|
71429
71654
|
var import_node_path61 = require("path");
|
|
71430
71655
|
init_constants();
|
|
@@ -71438,7 +71663,7 @@ function resolveAlanDefaultWorkspacePath(homeDirectory = (0, import_node_os8.hom
|
|
|
71438
71663
|
}
|
|
71439
71664
|
|
|
71440
71665
|
// src/holder/agent-context.ts
|
|
71441
|
-
var
|
|
71666
|
+
var import_promises62 = require("fs/promises");
|
|
71442
71667
|
var import_node_path57 = require("path");
|
|
71443
71668
|
|
|
71444
71669
|
// ../agent-core/dist/prompt.js
|
|
@@ -71446,7 +71671,7 @@ init_chunk_7FJ7QKFN();
|
|
|
71446
71671
|
|
|
71447
71672
|
// src/holder/agent-context.ts
|
|
71448
71673
|
async function readText4(path4) {
|
|
71449
|
-
return (0,
|
|
71674
|
+
return (0, import_promises62.readFile)(path4, "utf8").then(
|
|
71450
71675
|
(text3) => text3.trim(),
|
|
71451
71676
|
() => null
|
|
71452
71677
|
);
|
|
@@ -71492,12 +71717,12 @@ var import_node_path60 = require("path");
|
|
|
71492
71717
|
|
|
71493
71718
|
// src/holder/claim-once.ts
|
|
71494
71719
|
var import_node_crypto29 = require("crypto");
|
|
71495
|
-
var
|
|
71720
|
+
var import_promises63 = require("fs/promises");
|
|
71496
71721
|
var import_node_path58 = require("path");
|
|
71497
71722
|
async function claimOnce(dir, name) {
|
|
71498
71723
|
try {
|
|
71499
|
-
await (0,
|
|
71500
|
-
await (await (0,
|
|
71724
|
+
await (0, import_promises63.mkdir)(dir, { recursive: true, mode: 448 });
|
|
71725
|
+
await (await (0, import_promises63.open)((0, import_node_path58.join)(dir, name), "wx")).close();
|
|
71501
71726
|
return true;
|
|
71502
71727
|
} catch {
|
|
71503
71728
|
return false;
|
|
@@ -71508,7 +71733,7 @@ function claimFirstLease(freshnessDir, path4) {
|
|
|
71508
71733
|
}
|
|
71509
71734
|
|
|
71510
71735
|
// src/holder/requested-checkout.ts
|
|
71511
|
-
var
|
|
71736
|
+
var import_promises64 = require("fs/promises");
|
|
71512
71737
|
var import_node_path59 = require("path");
|
|
71513
71738
|
var REMOTE2 = "origin";
|
|
71514
71739
|
var REASON_MAX_CHARS = 200;
|
|
@@ -71531,7 +71756,7 @@ function notSwitched(checkout, current, reason) {
|
|
|
71531
71756
|
}
|
|
71532
71757
|
async function clone2(checkout, deps, signal) {
|
|
71533
71758
|
const parent = (0, import_node_path59.dirname)(checkout.path);
|
|
71534
|
-
await (0,
|
|
71759
|
+
await (0, import_promises64.mkdir)(parent, { recursive: true });
|
|
71535
71760
|
await assertValidBranch(deps.git, parent, checkout.branch, signal);
|
|
71536
71761
|
const output2 = await deps.git.run(
|
|
71537
71762
|
{
|
|
@@ -71839,7 +72064,7 @@ function volumeRoot(path4) {
|
|
|
71839
72064
|
}
|
|
71840
72065
|
async function exists4(path4) {
|
|
71841
72066
|
try {
|
|
71842
|
-
await (0,
|
|
72067
|
+
await (0, import_promises65.stat)(path4);
|
|
71843
72068
|
return true;
|
|
71844
72069
|
} catch {
|
|
71845
72070
|
return false;
|
|
@@ -71847,10 +72072,10 @@ async function exists4(path4) {
|
|
|
71847
72072
|
}
|
|
71848
72073
|
async function inspectReadiness(path4) {
|
|
71849
72074
|
try {
|
|
71850
|
-
if (!(await (0,
|
|
72075
|
+
if (!(await (0, import_promises65.stat)(path4)).isDirectory()) {
|
|
71851
72076
|
return { ready: false, missing: true, message: MESSAGES.missing };
|
|
71852
72077
|
}
|
|
71853
|
-
await (0,
|
|
72078
|
+
await (0, import_promises65.access)(path4, import_node_fs20.constants.R_OK | import_node_fs20.constants.W_OK | import_node_fs20.constants.X_OK);
|
|
71854
72079
|
return { ready: true };
|
|
71855
72080
|
} catch (error62) {
|
|
71856
72081
|
const code = errnoCode(error62) ?? "";
|
|
@@ -71894,8 +72119,8 @@ async function admitDefaultWorkspace(spec, context, skills) {
|
|
|
71894
72119
|
const { env } = context;
|
|
71895
72120
|
const path4 = resolveAlanDefaultWorkspacePath(env.HOME || env.USERPROFILE || (0, import_node_os9.homedir)());
|
|
71896
72121
|
try {
|
|
71897
|
-
await (0,
|
|
71898
|
-
await (0,
|
|
72122
|
+
await (0, import_promises65.mkdir)(path4, { recursive: true, mode: 448 });
|
|
72123
|
+
await (0, import_promises65.access)(path4, import_node_fs20.constants.R_OK | import_node_fs20.constants.W_OK | import_node_fs20.constants.X_OK);
|
|
71899
72124
|
return { kind: "admitted", spec: { ...spec, projectPath: path4 }, skills };
|
|
71900
72125
|
} catch (error62) {
|
|
71901
72126
|
const code = errnoCode(error62);
|
|
@@ -72023,7 +72248,7 @@ async function respondToTurn(runningRunId, driver, request2) {
|
|
|
72023
72248
|
}
|
|
72024
72249
|
|
|
72025
72250
|
// src/holder/session-facts.ts
|
|
72026
|
-
var
|
|
72251
|
+
var import_promises66 = require("fs/promises");
|
|
72027
72252
|
var CLI_RSS_CACHE_MS = 1e4;
|
|
72028
72253
|
var LOGIN_PROBLEM_PREFIX = "cli.auth.";
|
|
72029
72254
|
function isLoginFailure(result) {
|
|
@@ -72045,12 +72270,12 @@ function createSessionFacts(options) {
|
|
|
72045
72270
|
loginFailed: false,
|
|
72046
72271
|
rss: null
|
|
72047
72272
|
};
|
|
72048
|
-
const
|
|
72273
|
+
const identify2 = async (command) => {
|
|
72049
72274
|
const path4 = await resolveCommandOnPath(command, env, platform3);
|
|
72050
72275
|
if (path4 === null) return null;
|
|
72051
72276
|
try {
|
|
72052
|
-
const real = await (0,
|
|
72053
|
-
const info = await (0,
|
|
72277
|
+
const real = await (0, import_promises66.realpath)(path4);
|
|
72278
|
+
const info = await (0, import_promises66.stat)(real);
|
|
72054
72279
|
return { command, key: `${real}:${info.ino}:${info.size}:${info.mtimeMs}` };
|
|
72055
72280
|
} catch {
|
|
72056
72281
|
return null;
|
|
@@ -72064,9 +72289,9 @@ function createSessionFacts(options) {
|
|
|
72064
72289
|
const selectionFile = env.ALAN_MANAGED_PROVIDER_SELECTION_FILE;
|
|
72065
72290
|
state.managedVersion = selectionFile === void 0 ? null : await readManagedProviderVersion(selectionFile, spec.backendKind);
|
|
72066
72291
|
const command = providerCommandFor(spec.backendKind);
|
|
72067
|
-
state.executable = command === void 0 ? null : await
|
|
72292
|
+
state.executable = command === void 0 ? null : await identify2(command);
|
|
72068
72293
|
if (state.executable === null && spec.backendKind === "kimi_cli") {
|
|
72069
|
-
state.executable = await
|
|
72294
|
+
state.executable = await identify2("kimi-cli");
|
|
72070
72295
|
}
|
|
72071
72296
|
};
|
|
72072
72297
|
const liveCliRss = async () => {
|
|
@@ -72088,7 +72313,7 @@ function createSessionFacts(options) {
|
|
|
72088
72313
|
}
|
|
72089
72314
|
const spawned = state.executable;
|
|
72090
72315
|
if (spawned === null) return false;
|
|
72091
|
-
const current = await
|
|
72316
|
+
const current = await identify2(spawned.command);
|
|
72092
72317
|
return current?.key !== spawned.key;
|
|
72093
72318
|
};
|
|
72094
72319
|
return {
|
|
@@ -72144,12 +72369,12 @@ async function steerTurn(runningRunId, driver, request2) {
|
|
|
72144
72369
|
init_acp3();
|
|
72145
72370
|
|
|
72146
72371
|
// src/run-log/archive.ts
|
|
72147
|
-
var
|
|
72372
|
+
var import_promises67 = require("fs/promises");
|
|
72148
72373
|
var import_node_path62 = require("path");
|
|
72149
72374
|
init_runtime_v2();
|
|
72150
72375
|
async function openRunArchive(runsDir) {
|
|
72151
72376
|
const path4 = (0, import_node_path62.join)((0, import_node_path62.dirname)(runsDir), "archived-runs.txt");
|
|
72152
|
-
const text3 = await (0,
|
|
72377
|
+
const text3 = await (0, import_promises67.readFile)(path4, "utf8").catch((error62) => {
|
|
72153
72378
|
if (errnoCode(error62) === "ENOENT") return "";
|
|
72154
72379
|
throw error62;
|
|
72155
72380
|
});
|
|
@@ -72163,7 +72388,7 @@ async function openRunArchive(runsDir) {
|
|
|
72163
72388
|
add: async (runIds) => {
|
|
72164
72389
|
const added = runIds.filter((runId) => !archived.has(runId));
|
|
72165
72390
|
if (added.length === 0) return;
|
|
72166
|
-
await (0,
|
|
72391
|
+
await (0, import_promises67.appendFile)(path4, `
|
|
72167
72392
|
${added.join("\n")}
|
|
72168
72393
|
`, { mode: 384 });
|
|
72169
72394
|
for (const runId of added) archived.add(runId);
|
|
@@ -72177,7 +72402,7 @@ var import_node_fs21 = require("fs");
|
|
|
72177
72402
|
var import_node_path64 = require("path");
|
|
72178
72403
|
|
|
72179
72404
|
// src/run-log/directory.ts
|
|
72180
|
-
var
|
|
72405
|
+
var import_promises68 = require("fs/promises");
|
|
72181
72406
|
var import_node_path63 = require("path");
|
|
72182
72407
|
init_runtime_v2();
|
|
72183
72408
|
init_zod();
|
|
@@ -72214,7 +72439,7 @@ function runDirectory(runsDir, runId) {
|
|
|
72214
72439
|
}
|
|
72215
72440
|
async function isRunClaimed(runsDir, runId) {
|
|
72216
72441
|
try {
|
|
72217
|
-
return (await (0,
|
|
72442
|
+
return (await (0, import_promises68.stat)(runDirectory(runsDir, runId).log)).size > 0;
|
|
72218
72443
|
} catch (error62) {
|
|
72219
72444
|
if (errnoCode(error62) === "ENOENT") return false;
|
|
72220
72445
|
throw error62;
|
|
@@ -72252,7 +72477,7 @@ async function writeCompleteRunLog(runsDir, meta3, records) {
|
|
|
72252
72477
|
}
|
|
72253
72478
|
|
|
72254
72479
|
// src/run-log/conversation-index.ts
|
|
72255
|
-
var
|
|
72480
|
+
var import_promises69 = require("fs/promises");
|
|
72256
72481
|
var import_node_path65 = require("path");
|
|
72257
72482
|
init_runtime_v2();
|
|
72258
72483
|
init_zod();
|
|
@@ -72285,8 +72510,8 @@ async function indexConversationRun(runsDir, conversationId, ordinal, assistantO
|
|
|
72285
72510
|
const nextOrdinal = assistantOrdinal + 1;
|
|
72286
72511
|
if (nextOrdinal <= ordinal) throw new Error("Assistant order must follow the prompt");
|
|
72287
72512
|
const path4 = shardPath(runsDir, conversationId, ordinal);
|
|
72288
|
-
await (0,
|
|
72289
|
-
await (0,
|
|
72513
|
+
await (0, import_promises69.mkdir)((0, import_node_path65.dirname)(path4), { recursive: true, mode: 448 });
|
|
72514
|
+
await (0, import_promises69.appendFile)(path4, `${JSON.stringify({ ordinal, nextOrdinal, runId })}
|
|
72290
72515
|
`, { mode: 384 });
|
|
72291
72516
|
const coveragePath = (0, import_node_path65.join)((0, import_node_path65.dirname)((0, import_node_path65.dirname)(path4)), "coverage.json");
|
|
72292
72517
|
const coverage = await readJsonFile(coveragePath, coverageSchema);
|
|
@@ -72309,7 +72534,7 @@ async function readConversationIndexCoverage(runsDir, conversationId) {
|
|
|
72309
72534
|
}
|
|
72310
72535
|
async function readConversationRunIndex(runsDir, conversationId, before, limit) {
|
|
72311
72536
|
const directory = indexDirectory(runsDir, conversationId);
|
|
72312
|
-
const names = await (0,
|
|
72537
|
+
const names = await (0, import_promises69.readdir)(directory).catch((error62) => {
|
|
72313
72538
|
if (error62.code === "ENOENT") return [];
|
|
72314
72539
|
throw error62;
|
|
72315
72540
|
});
|
|
@@ -72318,7 +72543,7 @@ async function readConversationRunIndex(runsDir, conversationId, before, limit)
|
|
|
72318
72543
|
).sort((left, right) => right - left);
|
|
72319
72544
|
const selected = [];
|
|
72320
72545
|
for (const shard of shards) {
|
|
72321
|
-
const text3 = await (0,
|
|
72546
|
+
const text3 = await (0, import_promises69.readFile)((0, import_node_path65.join)(directory, `${shard}.jsonl`), "utf8");
|
|
72322
72547
|
const records = text3.split("\n").flatMap((line) => {
|
|
72323
72548
|
if (!line) return [];
|
|
72324
72549
|
const parsed = indexRecordSchema.parse(JSON.parse(line));
|
|
@@ -72343,7 +72568,7 @@ async function readIndexableRun(runsDir, name) {
|
|
|
72343
72568
|
return { conversationId: meta3.conversationId, ordinal, assistantOrdinal, runId: runId.data };
|
|
72344
72569
|
}
|
|
72345
72570
|
async function readIndexableRuns(runsDir) {
|
|
72346
|
-
const names = await (0,
|
|
72571
|
+
const names = await (0, import_promises69.readdir)(runsDir).catch(() => []);
|
|
72347
72572
|
const byConversation = /* @__PURE__ */ new Map();
|
|
72348
72573
|
let next = 0;
|
|
72349
72574
|
const worker = async () => {
|
|
@@ -72373,21 +72598,21 @@ async function writeConversationIndex(directory, runs) {
|
|
|
72373
72598
|
else lines2.push(line);
|
|
72374
72599
|
coverage = nextCoverage(coverage, run2.ordinal, nextOrdinal) ?? coverage;
|
|
72375
72600
|
}
|
|
72376
|
-
await (0,
|
|
72601
|
+
await (0, import_promises69.mkdir)((0, import_node_path65.join)(directory, "turn-index"), { recursive: true, mode: 448 });
|
|
72377
72602
|
for (const [shard, lines2] of shards) {
|
|
72378
|
-
await (0,
|
|
72603
|
+
await (0, import_promises69.writeFile)((0, import_node_path65.join)(directory, "turn-index", `${shard}.jsonl`), `${lines2.join("\n")}
|
|
72379
72604
|
`, {
|
|
72380
72605
|
mode: 384
|
|
72381
72606
|
});
|
|
72382
72607
|
}
|
|
72383
|
-
await (0,
|
|
72608
|
+
await (0, import_promises69.writeFile)((0, import_node_path65.join)(directory, "coverage.json"), `${JSON.stringify(coverage)}
|
|
72384
72609
|
`, {
|
|
72385
72610
|
mode: 384
|
|
72386
72611
|
});
|
|
72387
72612
|
}
|
|
72388
72613
|
async function rebuildConversationIndexes(runsDir) {
|
|
72389
72614
|
const root = conversationsDirectory(runsDir);
|
|
72390
|
-
const exists6 = await (0,
|
|
72615
|
+
const exists6 = await (0, import_promises69.stat)(root).then(
|
|
72391
72616
|
() => true,
|
|
72392
72617
|
(error62) => {
|
|
72393
72618
|
if (errnoCode(error62) === "ENOENT") return false;
|
|
@@ -72396,18 +72621,18 @@ async function rebuildConversationIndexes(runsDir) {
|
|
|
72396
72621
|
);
|
|
72397
72622
|
if (exists6) return 0;
|
|
72398
72623
|
const building = `${root}.rebuilding`;
|
|
72399
|
-
await (0,
|
|
72400
|
-
await (0,
|
|
72624
|
+
await (0, import_promises69.rm)(building, { recursive: true, force: true });
|
|
72625
|
+
await (0, import_promises69.mkdir)(building, { recursive: true, mode: 448 });
|
|
72401
72626
|
const byConversation = await readIndexableRuns(runsDir);
|
|
72402
72627
|
for (const [conversationId, runs] of byConversation) {
|
|
72403
72628
|
await writeConversationIndex((0, import_node_path65.join)(building, conversationId), runs);
|
|
72404
72629
|
}
|
|
72405
|
-
await (0,
|
|
72630
|
+
await (0, import_promises69.rename)(building, root);
|
|
72406
72631
|
return byConversation.size;
|
|
72407
72632
|
}
|
|
72408
72633
|
|
|
72409
72634
|
// src/run-log/reader.ts
|
|
72410
|
-
var
|
|
72635
|
+
var import_promises70 = require("fs/promises");
|
|
72411
72636
|
init_runtime_v2();
|
|
72412
72637
|
|
|
72413
72638
|
// src/run-log/tail.ts
|
|
@@ -72430,7 +72655,7 @@ function firstRecordLength(bytes) {
|
|
|
72430
72655
|
return bytes.indexOf(RUN_LOG_RECORD_SEPARATOR) + 1;
|
|
72431
72656
|
}
|
|
72432
72657
|
async function openRunLogReader(path4) {
|
|
72433
|
-
const handle = await (0,
|
|
72658
|
+
const handle = await (0, import_promises70.open)(path4, "r");
|
|
72434
72659
|
const readAt = async (position, length) => {
|
|
72435
72660
|
const buffer = Buffer.alloc(length);
|
|
72436
72661
|
const { bytesRead } = await handle.read(buffer, 0, length, position);
|
|
@@ -72464,7 +72689,7 @@ async function openRunLogReader(path4) {
|
|
|
72464
72689
|
};
|
|
72465
72690
|
}
|
|
72466
72691
|
async function readLastRecord(path4) {
|
|
72467
|
-
const handle = await (0,
|
|
72692
|
+
const handle = await (0, import_promises70.open)(path4, "r").catch(() => null);
|
|
72468
72693
|
if (handle === null) return null;
|
|
72469
72694
|
try {
|
|
72470
72695
|
const { size } = await handle.stat();
|
|
@@ -73016,11 +73241,11 @@ function delta(current, previous) {
|
|
|
73016
73241
|
return previous === void 0 ? 0 : Math.max(0, Math.round(current - previous));
|
|
73017
73242
|
}
|
|
73018
73243
|
async function lastOutputAtMs(runsDir, run2) {
|
|
73019
|
-
const info = await (0,
|
|
73244
|
+
const info = await (0, import_promises71.stat)(runDirectory(runsDir, run2.runId).log).catch(() => null);
|
|
73020
73245
|
return info === null ? null : Math.floor(info.mtimeMs);
|
|
73021
73246
|
}
|
|
73022
73247
|
async function readHolderActivities(sessionsDir) {
|
|
73023
|
-
const names = await (0,
|
|
73248
|
+
const names = await (0, import_promises71.readdir)(sessionsDir).catch(() => []);
|
|
73024
73249
|
const found = [];
|
|
73025
73250
|
for (const name of names) {
|
|
73026
73251
|
const parsed = conversationIdSchema.safeParse(name);
|
|
@@ -73303,7 +73528,7 @@ async function runActivityLeaseWorker(rawData, port) {
|
|
|
73303
73528
|
|
|
73304
73529
|
// src/cli/commands/compat.ts
|
|
73305
73530
|
var import_node_crypto33 = require("crypto");
|
|
73306
|
-
var
|
|
73531
|
+
var import_promises75 = require("fs/promises");
|
|
73307
73532
|
init_runtime_v2();
|
|
73308
73533
|
init_zod();
|
|
73309
73534
|
|
|
@@ -73593,7 +73818,7 @@ var mcpConfigResultSchema = external_exports.object({
|
|
|
73593
73818
|
});
|
|
73594
73819
|
|
|
73595
73820
|
// src/client/runtime-client.ts
|
|
73596
|
-
var
|
|
73821
|
+
var import_promises72 = require("fs/promises");
|
|
73597
73822
|
init_acp();
|
|
73598
73823
|
init_runtime_v2();
|
|
73599
73824
|
|
|
@@ -73654,7 +73879,7 @@ var DEFAULT_BACKOFF = { initialMs: 250, maxMs: 3e4 };
|
|
|
73654
73879
|
async function readDiscovery(path4) {
|
|
73655
73880
|
let text3;
|
|
73656
73881
|
try {
|
|
73657
|
-
text3 = await (0,
|
|
73882
|
+
text3 = await (0, import_promises72.readFile)(path4, "utf8");
|
|
73658
73883
|
} catch (error62) {
|
|
73659
73884
|
throw new RuntimeClientError("unavailable", "The runtime is not running", { cause: error62 });
|
|
73660
73885
|
}
|
|
@@ -74037,7 +74262,7 @@ async function sendNativeHookSignal(discoveryPath, hookSignal, signal) {
|
|
|
74037
74262
|
|
|
74038
74263
|
// src/sessions/index.ts
|
|
74039
74264
|
var import_node_crypto32 = require("crypto");
|
|
74040
|
-
var
|
|
74265
|
+
var import_promises73 = require("fs/promises");
|
|
74041
74266
|
var import_node_path71 = require("path");
|
|
74042
74267
|
init_runtime_v2();
|
|
74043
74268
|
|
|
@@ -74084,7 +74309,7 @@ var DEFAULT_MAX_ACTIVE_RUNS = 32;
|
|
|
74084
74309
|
var HOLDER_BUSY = "busy";
|
|
74085
74310
|
async function listIds(dir, schema) {
|
|
74086
74311
|
const ids = [];
|
|
74087
|
-
for (const name of await (0,
|
|
74312
|
+
for (const name of await (0, import_promises73.readdir)(dir).catch(() => [])) {
|
|
74088
74313
|
const parsed = schema.safeParse(name);
|
|
74089
74314
|
if (parsed.success) ids.push(parsed.data);
|
|
74090
74315
|
}
|
|
@@ -74109,9 +74334,9 @@ async function removeHolderFiles(files) {
|
|
|
74109
74334
|
sessionActivityPath(files.dir)
|
|
74110
74335
|
];
|
|
74111
74336
|
for (const path4 of holderWritten) {
|
|
74112
|
-
await (0,
|
|
74337
|
+
await (0, import_promises73.rm)(path4, { force: true });
|
|
74113
74338
|
}
|
|
74114
|
-
await (0,
|
|
74339
|
+
await (0, import_promises73.rmdir)(files.dir).catch((error62) => {
|
|
74115
74340
|
if (!["ENOENT", "ENOTEMPTY", "EEXIST"].includes(errnoCode(error62) ?? "")) throw error62;
|
|
74116
74341
|
});
|
|
74117
74342
|
}
|
|
@@ -74307,7 +74532,7 @@ async function openSessions(deps) {
|
|
|
74307
74532
|
const meta3 = await readRunMeta(dir.meta);
|
|
74308
74533
|
const last = await readLastRecord(dir.log);
|
|
74309
74534
|
if (meta3 === null || last === null) return null;
|
|
74310
|
-
const logged = await (0,
|
|
74535
|
+
const logged = await (0, import_promises73.stat)(dir.log).catch((error62) => {
|
|
74311
74536
|
if (errnoCode(error62) === "ENOENT") return null;
|
|
74312
74537
|
throw error62;
|
|
74313
74538
|
});
|
|
@@ -74735,7 +74960,7 @@ function takeEnrollmentCodeFromEnv(env = process.env) {
|
|
|
74735
74960
|
}
|
|
74736
74961
|
|
|
74737
74962
|
// src/cli/context.ts
|
|
74738
|
-
var
|
|
74963
|
+
var import_promises74 = require("fs/promises");
|
|
74739
74964
|
var import_node_os11 = require("os");
|
|
74740
74965
|
var import_node_path73 = require("path");
|
|
74741
74966
|
var DESKTOP_BUNDLE_IDS = {
|
|
@@ -74785,7 +75010,7 @@ async function installedServiceSpec(ctx) {
|
|
|
74785
75010
|
const spec = serviceSpec(ctx);
|
|
74786
75011
|
if (ctx.config.host === "app") return spec;
|
|
74787
75012
|
const layout = installLayout(ctx.config.installDir, ctx.config.profile);
|
|
74788
|
-
const installed = await (0,
|
|
75013
|
+
const installed = await (0, import_promises74.access)(layout.launcher).then(
|
|
74789
75014
|
() => true,
|
|
74790
75015
|
() => false
|
|
74791
75016
|
);
|
|
@@ -74916,7 +75141,7 @@ var manifestRevisionSchema = external_exports.object({ revision: external_export
|
|
|
74916
75141
|
async function manifestRevision(path4) {
|
|
74917
75142
|
let raw;
|
|
74918
75143
|
try {
|
|
74919
|
-
raw = JSON.parse(await (0,
|
|
75144
|
+
raw = JSON.parse(await (0, import_promises75.readFile)(path4, "utf8"));
|
|
74920
75145
|
} catch (error62) {
|
|
74921
75146
|
throw new RuntimeFault("invalid_file", `Cannot read the skill manifest at ${path4}`, {
|
|
74922
75147
|
cause: error62
|
|
@@ -74970,7 +75195,7 @@ async function runSkills(argv) {
|
|
|
74970
75195
|
}
|
|
74971
75196
|
|
|
74972
75197
|
// src/cli/commands/doctor.ts
|
|
74973
|
-
var
|
|
75198
|
+
var import_promises78 = require("fs/promises");
|
|
74974
75199
|
var import_node_path77 = require("path");
|
|
74975
75200
|
init_runtime_v2();
|
|
74976
75201
|
|
|
@@ -75019,14 +75244,14 @@ var storedCredentialSchema = external_exports.object({
|
|
|
75019
75244
|
renewalToken: external_exports.string().min(1).optional(),
|
|
75020
75245
|
issuedAt: external_exports.iso.datetime().optional()
|
|
75021
75246
|
});
|
|
75022
|
-
function credentialStoreFor(paths, kind,
|
|
75247
|
+
function credentialStoreFor(paths, kind, access8) {
|
|
75023
75248
|
return openCredentialStore({
|
|
75024
75249
|
kind,
|
|
75025
75250
|
filePath: paths.credential,
|
|
75026
75251
|
stateDir: paths.stateDir,
|
|
75027
|
-
exec:
|
|
75028
|
-
...
|
|
75029
|
-
...
|
|
75252
|
+
exec: access8.exec,
|
|
75253
|
+
...access8.keychainPath === void 0 ? {} : { keychainPath: access8.keychainPath },
|
|
75254
|
+
...access8.platform === void 0 ? {} : { platform: access8.platform }
|
|
75030
75255
|
});
|
|
75031
75256
|
}
|
|
75032
75257
|
function credentialFromGrant(grant, clock) {
|
|
@@ -75046,10 +75271,10 @@ async function saveGrant({
|
|
|
75046
75271
|
storeKind,
|
|
75047
75272
|
grant,
|
|
75048
75273
|
clock,
|
|
75049
|
-
access:
|
|
75274
|
+
access: access8
|
|
75050
75275
|
}) {
|
|
75051
75276
|
const previous = await readMachineFile(paths);
|
|
75052
|
-
await credentialStoreFor(paths, storeKind,
|
|
75277
|
+
await credentialStoreFor(paths, storeKind, access8).write(credentialFromGrant(grant, clock));
|
|
75053
75278
|
const machine = {
|
|
75054
75279
|
machineId: grant.machineId,
|
|
75055
75280
|
endpoints: grant.endpoints,
|
|
@@ -75058,7 +75283,7 @@ async function saveGrant({
|
|
|
75058
75283
|
await writeJsonFileAtomic(paths.machine, machine);
|
|
75059
75284
|
await rememberInstallationMachine(paths, machine.machineId);
|
|
75060
75285
|
if (previous !== null && previous.credentialStore !== storeKind) {
|
|
75061
|
-
await credentialStoreFor(paths, previous.credentialStore,
|
|
75286
|
+
await credentialStoreFor(paths, previous.credentialStore, access8).clear();
|
|
75062
75287
|
}
|
|
75063
75288
|
return machine;
|
|
75064
75289
|
}
|
|
@@ -75179,7 +75404,7 @@ async function authorizeDevice(input2) {
|
|
|
75179
75404
|
}
|
|
75180
75405
|
|
|
75181
75406
|
// src/identity/enroll.ts
|
|
75182
|
-
var
|
|
75407
|
+
var import_promises76 = require("fs/promises");
|
|
75183
75408
|
init_runtime_v2();
|
|
75184
75409
|
async function enrollMachine(input2) {
|
|
75185
75410
|
const machineId = input2.machineId ?? (await readMachineFile(input2.paths))?.machineId ?? (await readInstallation(input2.paths))?.machineId;
|
|
@@ -75262,12 +75487,12 @@ async function enrollFromGrantFile(input2) {
|
|
|
75262
75487
|
clock: input2.clock,
|
|
75263
75488
|
access: input2.access
|
|
75264
75489
|
});
|
|
75265
|
-
await (0,
|
|
75490
|
+
await (0, import_promises76.rm)(input2.grantPath, { force: true });
|
|
75266
75491
|
return machine;
|
|
75267
75492
|
}
|
|
75268
75493
|
|
|
75269
75494
|
// src/identity/migrate-v1.ts
|
|
75270
|
-
var
|
|
75495
|
+
var import_promises77 = require("fs/promises");
|
|
75271
75496
|
var import_node_path75 = require("path");
|
|
75272
75497
|
init_runtime_v2();
|
|
75273
75498
|
init_zod();
|
|
@@ -75353,12 +75578,12 @@ async function scrubLegacyInstall(install2) {
|
|
|
75353
75578
|
const scrubbed = { ...install2.config, migratedToRuntimeV2: true };
|
|
75354
75579
|
for (const key of SCRUBBED_KEYS) delete scrubbed[key];
|
|
75355
75580
|
await writeJsonFileAtomic(`${install2.configPath}.migrated-v1`, scrubbed);
|
|
75356
|
-
await (0,
|
|
75357
|
-
await (0,
|
|
75581
|
+
await (0, import_promises77.rm)(install2.configPath, { force: true });
|
|
75582
|
+
await (0, import_promises77.rm)(install2.ownerLeasePath, { force: true });
|
|
75358
75583
|
}
|
|
75359
75584
|
async function retireLegacyInstall(install2) {
|
|
75360
|
-
await (0,
|
|
75361
|
-
await (0,
|
|
75585
|
+
await (0, import_promises77.rename)(install2.configPath, `${install2.configPath}.retired-v1`);
|
|
75586
|
+
await (0, import_promises77.rm)(install2.ownerLeasePath, { force: true });
|
|
75362
75587
|
}
|
|
75363
75588
|
async function exchangeCredential(deps) {
|
|
75364
75589
|
const { config: config2 } = deps.install;
|
|
@@ -75423,7 +75648,7 @@ async function migrateFromV1(deps) {
|
|
|
75423
75648
|
}
|
|
75424
75649
|
|
|
75425
75650
|
// src/identity/index.ts
|
|
75426
|
-
async function readStoredIdentity(paths,
|
|
75651
|
+
async function readStoredIdentity(paths, access8) {
|
|
75427
75652
|
const machine = await readJsonFile(paths.machine, machineFileSchema);
|
|
75428
75653
|
if (machine.kind !== "ok") {
|
|
75429
75654
|
throw new RuntimeFault(
|
|
@@ -75431,7 +75656,7 @@ async function readStoredIdentity(paths, access7) {
|
|
|
75431
75656
|
machine.kind === "missing" ? "This computer is not set up yet: run `alan-agent setup`" : `machine.json is invalid: ${machine.reason}`
|
|
75432
75657
|
);
|
|
75433
75658
|
}
|
|
75434
|
-
const store = credentialStoreFor(paths, machine.value.credentialStore,
|
|
75659
|
+
const store = credentialStoreFor(paths, machine.value.credentialStore, access8);
|
|
75435
75660
|
const credential = await store.read(storedCredentialSchema);
|
|
75436
75661
|
if (credential.kind !== "ok") {
|
|
75437
75662
|
throw new RuntimeFault(
|
|
@@ -75441,8 +75666,8 @@ async function readStoredIdentity(paths, access7) {
|
|
|
75441
75666
|
}
|
|
75442
75667
|
return { machine: machine.value, store, credential: credential.value };
|
|
75443
75668
|
}
|
|
75444
|
-
async function loadStoredAccess(paths,
|
|
75445
|
-
const { machine, credential } = await readStoredIdentity(paths,
|
|
75669
|
+
async function loadStoredAccess(paths, access8 = { exec: systemExec }) {
|
|
75670
|
+
const { machine, credential } = await readStoredIdentity(paths, access8);
|
|
75446
75671
|
return { endpoints: machine.endpoints, accessToken: credential.accessToken };
|
|
75447
75672
|
}
|
|
75448
75673
|
async function loadIdentity(paths, options = {}) {
|
|
@@ -75772,7 +75997,7 @@ async function probeHolder(dir, conversationId) {
|
|
|
75772
75997
|
}
|
|
75773
75998
|
}
|
|
75774
75999
|
async function holdersCheck(ctx) {
|
|
75775
|
-
const names = await (0,
|
|
76000
|
+
const names = await (0, import_promises78.readdir)(ctx.paths.sessions).catch(() => []);
|
|
75776
76001
|
const holders = (await Promise.all(names.map((name) => probeHolder((0, import_node_path77.join)(ctx.paths.sessions, name), name)))).filter((facts) => facts !== null);
|
|
75777
76002
|
const dead = holders.filter((holder) => !holder.alive).length;
|
|
75778
76003
|
return check2(
|
|
@@ -75784,7 +76009,7 @@ async function holdersCheck(ctx) {
|
|
|
75784
76009
|
}
|
|
75785
76010
|
async function freeBytesAt(path4) {
|
|
75786
76011
|
try {
|
|
75787
|
-
const stats = await (0,
|
|
76012
|
+
const stats = await (0, import_promises78.statfs)(path4);
|
|
75788
76013
|
return { path: path4, freeBytes: stats.bavail * stats.bsize };
|
|
75789
76014
|
} catch (error62) {
|
|
75790
76015
|
const parent = (0, import_node_path77.dirname)(path4);
|
|
@@ -75808,9 +76033,9 @@ var resolveFromLoginShell = (own2) => resolveCliEnvironment({ env: own2, platfor
|
|
|
75808
76033
|
async function cliDiscoveryCheck(resolve14) {
|
|
75809
76034
|
const own2 = readCliEnvironment();
|
|
75810
76035
|
const env = await resolve14(own2);
|
|
75811
|
-
const
|
|
75812
|
-
const ownDirs = new Set((own2.PATH ?? "").split(
|
|
75813
|
-
const added = (env.PATH ?? "").split(
|
|
76036
|
+
const delimiter2 = process.platform === "win32" ? ";" : ":";
|
|
76037
|
+
const ownDirs = new Set((own2.PATH ?? "").split(delimiter2));
|
|
76038
|
+
const added = (env.PATH ?? "").split(delimiter2).filter((dir) => dir.length > 0 && !ownDirs.has(dir));
|
|
75814
76039
|
const commands = await Promise.all(
|
|
75815
76040
|
PROVIDER_COMMANDS.map(async (provider4) => ({
|
|
75816
76041
|
backendKind: provider4.backendKind,
|
|
@@ -75923,10 +76148,10 @@ async function runDoctor(argv, context = cliContext) {
|
|
|
75923
76148
|
}
|
|
75924
76149
|
|
|
75925
76150
|
// src/cli/commands/git-credential.ts
|
|
75926
|
-
var
|
|
76151
|
+
var import_promises79 = require("fs/promises");
|
|
75927
76152
|
var import_node_net4 = require("net");
|
|
75928
76153
|
var MAX_RESPONSE_BYTES = 64 * 1024;
|
|
75929
|
-
async function
|
|
76154
|
+
async function readAll2(stream) {
|
|
75930
76155
|
const chunks = [];
|
|
75931
76156
|
for await (const chunk of stream) {
|
|
75932
76157
|
chunks.push(typeof chunk === "string" ? Buffer.from(chunk) : chunk);
|
|
@@ -75935,7 +76160,7 @@ async function readAll(stream) {
|
|
|
75935
76160
|
}
|
|
75936
76161
|
function processIo() {
|
|
75937
76162
|
return {
|
|
75938
|
-
readStdin: () =>
|
|
76163
|
+
readStdin: () => readAll2(process.stdin),
|
|
75939
76164
|
stdout: (text3) => process.stdout.write(text3),
|
|
75940
76165
|
stderr: (text3) => process.stderr.write(text3)
|
|
75941
76166
|
};
|
|
@@ -76040,7 +76265,7 @@ async function configure(argv) {
|
|
|
76040
76265
|
}
|
|
76041
76266
|
async function configureGitGateway(config2, gatewayUrl, signal) {
|
|
76042
76267
|
const { launcher } = installLayout(config2.installDir, config2.profile);
|
|
76043
|
-
const installed = await (0,
|
|
76268
|
+
const installed = await (0, import_promises79.access)(launcher).then(
|
|
76044
76269
|
() => true,
|
|
76045
76270
|
() => false
|
|
76046
76271
|
);
|
|
@@ -76069,9 +76294,31 @@ async function runGitCredential(argv) {
|
|
|
76069
76294
|
}
|
|
76070
76295
|
|
|
76071
76296
|
// src/cli/commands/hold.ts
|
|
76072
|
-
var
|
|
76297
|
+
var import_node_path79 = require("path");
|
|
76073
76298
|
init_agent2();
|
|
76074
76299
|
init_runtime_v2();
|
|
76300
|
+
|
|
76301
|
+
// src/cli/commands/cli-flag-probes.ts
|
|
76302
|
+
var import_node_path78 = require("path");
|
|
76303
|
+
init_claude();
|
|
76304
|
+
var CLI_FLAG_PROBES_FILE = "cli-flag-probes.json";
|
|
76305
|
+
function openCliFlagProbe(stateDir) {
|
|
76306
|
+
return createFlagProbe({
|
|
76307
|
+
store: createFileFlagProbeStore((0, import_node_path78.join)(stateDir, CLI_FLAG_PROBES_FILE))
|
|
76308
|
+
});
|
|
76309
|
+
}
|
|
76310
|
+
async function prewarmCliFlagProbes(stateDir, env) {
|
|
76311
|
+
if (await resolveCommandOnPath("claude", env, process.platform) === null) return;
|
|
76312
|
+
const flags = openCliFlagProbe(stateDir);
|
|
76313
|
+
await createClaudeCapabilityProbe(flags).detect({
|
|
76314
|
+
command: "claude",
|
|
76315
|
+
env,
|
|
76316
|
+
needsApproveMcps: true
|
|
76317
|
+
});
|
|
76318
|
+
await flags.persisted();
|
|
76319
|
+
}
|
|
76320
|
+
|
|
76321
|
+
// src/cli/commands/hold.ts
|
|
76075
76322
|
async function machineAccess(paths, log, conversationId, transport) {
|
|
76076
76323
|
const initial = await loadStoredAccess(paths).catch(
|
|
76077
76324
|
(error62) => {
|
|
@@ -76080,10 +76327,10 @@ async function machineAccess(paths, log, conversationId, transport) {
|
|
|
76080
76327
|
}
|
|
76081
76328
|
);
|
|
76082
76329
|
const api = async () => {
|
|
76083
|
-
const
|
|
76330
|
+
const access8 = await loadStoredAccess(paths);
|
|
76084
76331
|
return createHolderApiClient({
|
|
76085
|
-
apiUrl:
|
|
76086
|
-
accessToken: () =>
|
|
76332
|
+
apiUrl: access8.endpoints.apiUrl,
|
|
76333
|
+
accessToken: () => access8.accessToken,
|
|
76087
76334
|
transport
|
|
76088
76335
|
});
|
|
76089
76336
|
};
|
|
@@ -76128,7 +76375,7 @@ async function runHold(argv) {
|
|
|
76128
76375
|
const config2 = loadRuntimeConfig();
|
|
76129
76376
|
const paths = runtimePaths(config2.stateDir);
|
|
76130
76377
|
const log = __using(_stack, openFileLog(
|
|
76131
|
-
(0,
|
|
76378
|
+
(0, import_node_path79.join)(paths.logs, `holder-${launch.value.conversationId}.jsonl`),
|
|
76132
76379
|
config2.logLevel,
|
|
76133
76380
|
systemClock
|
|
76134
76381
|
));
|
|
@@ -76138,19 +76385,19 @@ async function runHold(argv) {
|
|
|
76138
76385
|
process.platform
|
|
76139
76386
|
);
|
|
76140
76387
|
const transport = __using(_stack, createHttpTransport());
|
|
76141
|
-
const
|
|
76142
|
-
const credentialPath = (0,
|
|
76143
|
-
const managedMcp = __using(_stack,
|
|
76144
|
-
managedMcp:
|
|
76388
|
+
const access8 = await machineAccess(paths, log, launch.value.conversationId, transport);
|
|
76389
|
+
const credentialPath = (0, import_node_path79.join)(paths.tmp, "mcp", `${launch.value.conversationId}.json`);
|
|
76390
|
+
const managedMcp = __using(_stack, access8.managedMcp === void 0 ? void 0 : createHelperMcpAccess({
|
|
76391
|
+
managedMcp: access8.managedMcp,
|
|
76145
76392
|
conversationId: launch.value.conversationId,
|
|
76146
76393
|
credentialPath
|
|
76147
76394
|
}), true);
|
|
76148
|
-
const providerEnvironment2 =
|
|
76395
|
+
const providerEnvironment2 = access8.managedMcp === void 0 ? cliEnvironment : {
|
|
76149
76396
|
...cliEnvironment,
|
|
76150
|
-
[ALAN_MCP_URL_ENV]:
|
|
76397
|
+
[ALAN_MCP_URL_ENV]: access8.managedMcp.url,
|
|
76151
76398
|
[ALAN_MCP_CREDENTIAL_FILE_ENV]: credentialPath
|
|
76152
76399
|
};
|
|
76153
|
-
const flags =
|
|
76400
|
+
const flags = openCliFlagProbe(paths.stateDir);
|
|
76154
76401
|
await runHolder({
|
|
76155
76402
|
launch: launch.value,
|
|
76156
76403
|
driver: createProviderDrivers({
|
|
@@ -76159,12 +76406,13 @@ async function runHold(argv) {
|
|
|
76159
76406
|
timings: config2.sessionTimings,
|
|
76160
76407
|
log,
|
|
76161
76408
|
...managedMcp === void 0 ? {} : { managedMcp },
|
|
76162
|
-
codexCredentials:
|
|
76163
|
-
installedSkills: () => installedSkillFolders(skillsLayout(paths.stateDir))
|
|
76409
|
+
codexCredentials: access8.codexCredentials,
|
|
76410
|
+
installedSkills: () => installedSkillFolders(skillsLayout(paths.stateDir)),
|
|
76411
|
+
flagProbe: flags
|
|
76164
76412
|
}),
|
|
76165
76413
|
clock: systemClock,
|
|
76166
76414
|
log,
|
|
76167
|
-
inputs: { source:
|
|
76415
|
+
inputs: { source: access8.source, tmpDir: paths.tmp },
|
|
76168
76416
|
machine: {
|
|
76169
76417
|
env: cliEnvironment,
|
|
76170
76418
|
stateDir: paths.stateDir,
|
|
@@ -76185,7 +76433,7 @@ async function runHold(argv) {
|
|
|
76185
76433
|
}
|
|
76186
76434
|
|
|
76187
76435
|
// src/cli/commands/hook.ts
|
|
76188
|
-
var
|
|
76436
|
+
var import_node_path80 = require("path");
|
|
76189
76437
|
var RUNTIME_ANSWER_MS = 2e3;
|
|
76190
76438
|
var DEBUG_VARIABLE = "ALAN_HOOK_DEBUG";
|
|
76191
76439
|
function flag(argv, name) {
|
|
@@ -76217,7 +76465,7 @@ async function forwardHook(argv, io) {
|
|
|
76217
76465
|
return "transcript outside provider root";
|
|
76218
76466
|
}
|
|
76219
76467
|
const verdict = await io.send(
|
|
76220
|
-
(0,
|
|
76468
|
+
(0, import_node_path80.join)(io.stateDir, LOCAL_API_DISCOVERY_FILE),
|
|
76221
76469
|
hookSignal,
|
|
76222
76470
|
AbortSignal.timeout(RUNTIME_ANSWER_MS)
|
|
76223
76471
|
);
|
|
@@ -76253,7 +76501,7 @@ async function runHook(argv, overrides = {}) {
|
|
|
76253
76501
|
}
|
|
76254
76502
|
|
|
76255
76503
|
// src/cli/commands/ingestion-hooks.ts
|
|
76256
|
-
var
|
|
76504
|
+
var import_promises80 = require("fs/promises");
|
|
76257
76505
|
var CODEX_TRUST_NOTE = "Codex runs new hooks only after you review them: open /hooks in Codex.";
|
|
76258
76506
|
function isAction(value2) {
|
|
76259
76507
|
return value2 === "enable" || value2 === "disable" || value2 === "status";
|
|
@@ -76276,7 +76524,7 @@ function errorMessage2(error62) {
|
|
|
76276
76524
|
return error62 instanceof Error ? error62.message : String(error62);
|
|
76277
76525
|
}
|
|
76278
76526
|
async function exists5(path4) {
|
|
76279
|
-
return (0,
|
|
76527
|
+
return (0, import_promises80.access)(path4).then(
|
|
76280
76528
|
() => true,
|
|
76281
76529
|
() => false
|
|
76282
76530
|
);
|
|
@@ -76379,10 +76627,10 @@ async function runIntegrationsCommand(argv) {
|
|
|
76379
76627
|
}
|
|
76380
76628
|
|
|
76381
76629
|
// src/cli/commands/legacy.ts
|
|
76382
|
-
var
|
|
76630
|
+
var import_node_path82 = require("path");
|
|
76383
76631
|
|
|
76384
76632
|
// src/cli/commands/setup.ts
|
|
76385
|
-
var
|
|
76633
|
+
var import_node_path81 = require("path");
|
|
76386
76634
|
init_zod();
|
|
76387
76635
|
|
|
76388
76636
|
// src/cli/legacy.ts
|
|
@@ -76488,7 +76736,7 @@ async function grantFileCredential(argv, grantPath, ctx, deps) {
|
|
|
76488
76736
|
return enrollFromGrantFile({
|
|
76489
76737
|
paths: ctx.paths,
|
|
76490
76738
|
storeKind: credentialStoreFlag(argv) ?? ctx.config.credentialStore,
|
|
76491
|
-
grantPath: (0,
|
|
76739
|
+
grantPath: (0, import_node_path81.resolve)(grantPath),
|
|
76492
76740
|
clock: deps.clock,
|
|
76493
76741
|
access: ctx.access
|
|
76494
76742
|
});
|
|
@@ -76564,7 +76812,7 @@ async function runSetup(argv, signal) {
|
|
|
76564
76812
|
var _stack = [];
|
|
76565
76813
|
try {
|
|
76566
76814
|
const ctx = cliContext();
|
|
76567
|
-
const log = __using(_stack, openFileLog((0,
|
|
76815
|
+
const log = __using(_stack, openFileLog((0, import_node_path81.join)(ctx.paths.logs, "cli.jsonl"), ctx.config.logLevel, systemClock));
|
|
76568
76816
|
const result = await setupMachine(argv, ctx, {
|
|
76569
76817
|
enrollment: (apiUrl) => createEnrollmentClient({ apiUrl }),
|
|
76570
76818
|
isProcessAlive,
|
|
@@ -76647,7 +76895,7 @@ async function runToken(argv, signal) {
|
|
|
76647
76895
|
);
|
|
76648
76896
|
}
|
|
76649
76897
|
const ctx = cliContext();
|
|
76650
|
-
const log = __using(_stack, openFileLog((0,
|
|
76898
|
+
const log = __using(_stack, openFileLog((0, import_node_path82.join)(ctx.paths.logs, "cli.jsonl"), ctx.config.logLevel, systemClock));
|
|
76651
76899
|
const result = await rotateMachineCredential(ctx, { clock: systemClock, log, signal });
|
|
76652
76900
|
process.stdout.write(`${rotationMessage(result)}
|
|
76653
76901
|
`);
|
|
@@ -76659,8 +76907,8 @@ async function runToken(argv, signal) {
|
|
|
76659
76907
|
}
|
|
76660
76908
|
|
|
76661
76909
|
// src/cli/commands/logout.ts
|
|
76662
|
-
var
|
|
76663
|
-
var
|
|
76910
|
+
var import_promises81 = require("fs/promises");
|
|
76911
|
+
var import_node_path83 = require("path");
|
|
76664
76912
|
init_runtime_v2();
|
|
76665
76913
|
var RUNTIME_EXIT_WAIT_MS = 35e3;
|
|
76666
76914
|
var TURN_END_WAIT_MS = 3e4;
|
|
@@ -76719,9 +76967,9 @@ async function stopHolder(launch, deps, outcome2) {
|
|
|
76719
76967
|
}
|
|
76720
76968
|
async function stopHeldRuns(ctx, deps, outcome2 = "aborted") {
|
|
76721
76969
|
const stopped = [];
|
|
76722
|
-
for (const name of await (0,
|
|
76970
|
+
for (const name of await (0, import_promises81.readdir)(ctx.paths.sessions).catch(() => [])) {
|
|
76723
76971
|
const launch = await readJsonFile(
|
|
76724
|
-
(0,
|
|
76972
|
+
(0, import_node_path83.join)(ctx.paths.sessions, name, "launch.json"),
|
|
76725
76973
|
holderLaunchSchema
|
|
76726
76974
|
);
|
|
76727
76975
|
if (launch.kind !== "ok") continue;
|
|
@@ -76758,13 +77006,13 @@ async function forgetMachineLocally(ctx) {
|
|
|
76758
77006
|
const machine = await readMachineFile(ctx.paths);
|
|
76759
77007
|
if (machine === null) return;
|
|
76760
77008
|
await credentialStoreFor(ctx.paths, machine.credentialStore, ctx.access).clear();
|
|
76761
|
-
await (0,
|
|
77009
|
+
await (0, import_promises81.rm)(ctx.paths.machine, { force: true });
|
|
76762
77010
|
}
|
|
76763
77011
|
async function runLogout(argv, signal) {
|
|
76764
77012
|
var _stack = [];
|
|
76765
77013
|
try {
|
|
76766
77014
|
const ctx = cliContext();
|
|
76767
|
-
const log = __using(_stack, openFileLog((0,
|
|
77015
|
+
const log = __using(_stack, openFileLog((0, import_node_path83.join)(ctx.paths.logs, "cli.jsonl"), ctx.config.logLevel, systemClock));
|
|
76768
77016
|
const result = await logoutMachine(argv, ctx, {
|
|
76769
77017
|
api: (apiUrl, accessToken) => createApiClient({ apiUrl, accessToken }),
|
|
76770
77018
|
stopHeldRuns,
|
|
@@ -76782,7 +77030,7 @@ async function runLogout(argv, signal) {
|
|
|
76782
77030
|
|
|
76783
77031
|
// src/cli/commands/run.ts
|
|
76784
77032
|
var import_node_fs27 = require("fs");
|
|
76785
|
-
var
|
|
77033
|
+
var import_node_path88 = require("path");
|
|
76786
77034
|
|
|
76787
77035
|
// src/local-api/app-attachments.ts
|
|
76788
77036
|
function createAppAttachments(clock) {
|
|
@@ -76859,9 +77107,9 @@ function createRunAppends() {
|
|
|
76859
77107
|
|
|
76860
77108
|
// src/local-api/server.ts
|
|
76861
77109
|
var import_node_crypto36 = require("crypto");
|
|
76862
|
-
var
|
|
77110
|
+
var import_promises82 = require("fs/promises");
|
|
76863
77111
|
var import_node_http4 = require("http");
|
|
76864
|
-
var
|
|
77112
|
+
var import_node_path84 = require("path");
|
|
76865
77113
|
|
|
76866
77114
|
// src/local-api/guard.ts
|
|
76867
77115
|
var import_node_crypto35 = require("crypto");
|
|
@@ -77917,7 +78165,7 @@ async function serveLocalApi(deps) {
|
|
|
77917
78165
|
startedAtMs,
|
|
77918
78166
|
runtimeVersion: deps.runtimeVersion
|
|
77919
78167
|
};
|
|
77920
|
-
const discoveryPath = (0,
|
|
78168
|
+
const discoveryPath = (0, import_node_path84.join)(deps.stateDir, LOCAL_API_DISCOVERY_FILE);
|
|
77921
78169
|
await writeJsonFileAtomic(discoveryPath, discovery);
|
|
77922
78170
|
const followers = startMaintenance({
|
|
77923
78171
|
everyMs: limits.refreshEveryMs,
|
|
@@ -77951,7 +78199,7 @@ async function serveLocalApi(deps) {
|
|
|
77951
78199
|
await watchedStatus[Symbol.asyncDispose]();
|
|
77952
78200
|
const current = await readJsonFile(discoveryPath, localApiDiscoverySchema);
|
|
77953
78201
|
if (current.kind === "ok" && current.value.token === token) {
|
|
77954
|
-
await (0,
|
|
78202
|
+
await (0, import_promises82.rm)(discoveryPath, { force: true });
|
|
77955
78203
|
}
|
|
77956
78204
|
await closeServer(server);
|
|
77957
78205
|
log.info("local_api.closed", {});
|
|
@@ -78036,7 +78284,7 @@ function machineFeatureActions(deps) {
|
|
|
78036
78284
|
}
|
|
78037
78285
|
|
|
78038
78286
|
// src/cli/commands/machine-plane.ts
|
|
78039
|
-
var
|
|
78287
|
+
var import_node_path87 = require("path");
|
|
78040
78288
|
|
|
78041
78289
|
// src/link/index.ts
|
|
78042
78290
|
init_runtime_v2();
|
|
@@ -81704,7 +81952,7 @@ function refusalFailure(refusal2) {
|
|
|
81704
81952
|
}
|
|
81705
81953
|
|
|
81706
81954
|
// src/link/probe.ts
|
|
81707
|
-
var
|
|
81955
|
+
var import_promises83 = require("dns/promises");
|
|
81708
81956
|
var import_node_net5 = require("net");
|
|
81709
81957
|
var import_node_tls2 = require("tls");
|
|
81710
81958
|
var PROBE_TIMEOUT_MS4 = 5e3;
|
|
@@ -81740,7 +81988,7 @@ async function connectOnce(url3, clock) {
|
|
|
81740
81988
|
}
|
|
81741
81989
|
async function probeEndpoint(url3, clock) {
|
|
81742
81990
|
try {
|
|
81743
|
-
await (0,
|
|
81991
|
+
await (0, import_promises83.lookup)(url3.hostname);
|
|
81744
81992
|
} catch (error62) {
|
|
81745
81993
|
const reason = classifyTransportFailure(error62);
|
|
81746
81994
|
return reason === "other" ? "dns" : reason;
|
|
@@ -82135,20 +82383,33 @@ function fingerprintOf(desired) {
|
|
|
82135
82383
|
var FAILED_READ_RETRY_MS = 3e4;
|
|
82136
82384
|
function createDesiredSync(deps) {
|
|
82137
82385
|
const { clock, log } = deps;
|
|
82138
|
-
const state = {
|
|
82386
|
+
const state = {
|
|
82387
|
+
known: null,
|
|
82388
|
+
dueAt: 0,
|
|
82389
|
+
failures: 0
|
|
82390
|
+
};
|
|
82139
82391
|
const schedule = () => {
|
|
82140
82392
|
state.dueAt = clock.monotonic() + deps.everyMs * (0.75 + 0.5 * deps.random());
|
|
82141
82393
|
};
|
|
82142
82394
|
schedule();
|
|
82143
82395
|
const read = async (signal) => {
|
|
82144
82396
|
try {
|
|
82145
|
-
|
|
82397
|
+
const result = await deps.read(state.known?.etag ?? null, signal);
|
|
82398
|
+
state.failures = 0;
|
|
82399
|
+
return result;
|
|
82146
82400
|
} catch (error62) {
|
|
82147
|
-
state.
|
|
82401
|
+
state.failures = Math.min(state.failures + 1, 3);
|
|
82402
|
+
const retryMs = Math.min(
|
|
82403
|
+
deps.everyMs,
|
|
82404
|
+
4 * FAILED_READ_RETRY_MS,
|
|
82405
|
+
FAILED_READ_RETRY_MS * 2 ** (state.failures - 1) * (0.75 + 0.5 * deps.random())
|
|
82406
|
+
);
|
|
82407
|
+
state.dueAt = Math.min(state.dueAt, clock.monotonic() + retryMs);
|
|
82148
82408
|
throw error62;
|
|
82149
82409
|
}
|
|
82150
82410
|
};
|
|
82151
82411
|
const accept = (desired, etag) => {
|
|
82412
|
+
state.failures = 0;
|
|
82152
82413
|
state.known = { desired, fingerprint: fingerprintOf(desired), etag };
|
|
82153
82414
|
schedule();
|
|
82154
82415
|
deps.apply(desired);
|
|
@@ -82267,7 +82528,7 @@ function createReconciler(host, lifecycle, log, signal) {
|
|
|
82267
82528
|
}
|
|
82268
82529
|
|
|
82269
82530
|
// src/uploader/index.ts
|
|
82270
|
-
var
|
|
82531
|
+
var import_promises84 = require("fs/promises");
|
|
82271
82532
|
init_runtime_v2();
|
|
82272
82533
|
init_zod();
|
|
82273
82534
|
var RETRY_DELAYS_MS = [250, 500, 1e3, 2e3, 5e3, 1e4, 3e4];
|
|
@@ -82557,13 +82818,13 @@ function startUploader({
|
|
|
82557
82818
|
const isDone = (runId) => sealed.has(runId) || archive?.has(runId) === true;
|
|
82558
82819
|
const unsealedRunIds = async () => {
|
|
82559
82820
|
const runIds = [];
|
|
82560
|
-
for (const name of await (0,
|
|
82821
|
+
for (const name of await (0, import_promises84.readdir)(runsDir).catch(() => [])) {
|
|
82561
82822
|
const runId = runIdSchema.safeParse(name);
|
|
82562
82823
|
if (runId.success && !isDone(runId.data)) runIds.push(runId.data);
|
|
82563
82824
|
}
|
|
82564
82825
|
return runIds;
|
|
82565
82826
|
};
|
|
82566
|
-
const hasProgress = async (runId) => await (0,
|
|
82827
|
+
const hasProgress = async (runId) => await (0, import_promises84.stat)(runDirectory(runsDir, runId).upload).catch(() => null) !== null;
|
|
82567
82828
|
const sweep2 = async () => {
|
|
82568
82829
|
for (const runId of await unsealedRunIds()) {
|
|
82569
82830
|
if (!await hasProgress(runId)) run2(runId);
|
|
@@ -82579,13 +82840,13 @@ function startUploader({
|
|
|
82579
82840
|
const dir = runDirectory(runsDir, runId);
|
|
82580
82841
|
const progress = await readJsonFile(dir.upload, uploadProgressSchema);
|
|
82581
82842
|
if (progress.kind !== "ok" || !progress.value.sealed) return false;
|
|
82582
|
-
const sealedAt = (await (0,
|
|
82843
|
+
const sealedAt = (await (0, import_promises84.stat)(dir.upload)).mtimeMs;
|
|
82583
82844
|
if (clock.now() - sealedAt < options.sealedForMs) return false;
|
|
82584
82845
|
return (await readLastRecord(dir.log))?.update.sessionUpdate === "_alan/run.ended";
|
|
82585
82846
|
};
|
|
82586
82847
|
const archivable = async (options) => {
|
|
82587
82848
|
const found = [];
|
|
82588
|
-
for (const name of await (0,
|
|
82849
|
+
for (const name of await (0, import_promises84.readdir)(runsDir).catch(() => [])) {
|
|
82589
82850
|
const runId = runIdSchema.safeParse(name);
|
|
82590
82851
|
if (!runId.success || archive?.has(runId.data)) continue;
|
|
82591
82852
|
try {
|
|
@@ -82622,7 +82883,7 @@ function startUploader({
|
|
|
82622
82883
|
|
|
82623
82884
|
// src/cli/commands/activity-lease.ts
|
|
82624
82885
|
var import_node_fs26 = require("fs");
|
|
82625
|
-
var
|
|
82886
|
+
var import_node_path85 = require("path");
|
|
82626
82887
|
var import_node_worker_threads = require("worker_threads");
|
|
82627
82888
|
init_runtime_v2();
|
|
82628
82889
|
var LEASE_BUNDLE = "alan-lease.cjs";
|
|
@@ -82646,7 +82907,7 @@ function spawnThread(script, data) {
|
|
|
82646
82907
|
};
|
|
82647
82908
|
}
|
|
82648
82909
|
function leaseWorkerScript(bundlePath, exists6 = import_node_fs26.existsSync) {
|
|
82649
|
-
const lean = (0,
|
|
82910
|
+
const lean = (0, import_node_path85.join)((0, import_node_path85.dirname)(bundlePath), LEASE_BUNDLE);
|
|
82650
82911
|
return exists6(lean) ? lean : bundlePath;
|
|
82651
82912
|
}
|
|
82652
82913
|
function leasedRuns(held) {
|
|
@@ -82666,7 +82927,7 @@ function startActivityLeases(deps) {
|
|
|
82666
82927
|
epoch: Math.floor(clock.now()),
|
|
82667
82928
|
sessionsDir: deps.paths.sessions,
|
|
82668
82929
|
runsDir: deps.paths.runs,
|
|
82669
|
-
logPath: (0,
|
|
82930
|
+
logPath: (0, import_node_path85.join)(deps.paths.logs, "runtime.jsonl"),
|
|
82670
82931
|
logLevel: deps.logLevel,
|
|
82671
82932
|
intervalMs: ACTIVITY_LEASE_INTERVAL_MS,
|
|
82672
82933
|
watchdogMs: deps.watchdogMs,
|
|
@@ -82906,12 +83167,12 @@ async function startMachineNativeIngest(deps) {
|
|
|
82906
83167
|
}
|
|
82907
83168
|
|
|
82908
83169
|
// src/cli/commands/run-updates.ts
|
|
82909
|
-
var
|
|
83170
|
+
var import_node_path86 = require("path");
|
|
82910
83171
|
init_runtime_v2();
|
|
82911
83172
|
var UPDATE_CHECK_EVERY_MS = 6 * 60 * 60 * 1e3;
|
|
82912
83173
|
var DEFERRED_RETRY_MS = 5 * 60 * 1e3;
|
|
82913
83174
|
function isInstalledBundle(layout, bundlePath) {
|
|
82914
|
-
return (0,
|
|
83175
|
+
return (0, import_node_path86.resolve)((0, import_node_path86.dirname)((0, import_node_path86.dirname)(bundlePath))) === (0, import_node_path86.resolve)(layout.versions);
|
|
82915
83176
|
}
|
|
82916
83177
|
async function settleUpgradeOnStart({
|
|
82917
83178
|
layout,
|
|
@@ -83018,7 +83279,7 @@ function startRuntimeUpdates(options) {
|
|
|
83018
83279
|
layout,
|
|
83019
83280
|
release: npmRelease,
|
|
83020
83281
|
tarball: await options.downloader.download(npmRelease.dist.tarball, signal),
|
|
83021
|
-
tmpDir: (0,
|
|
83282
|
+
tmpDir: (0, import_node_path86.join)(layout.root, ".downloads")
|
|
83022
83283
|
});
|
|
83023
83284
|
await lifecycle.exclusive("upgrade", async () => {
|
|
83024
83285
|
await recordPendingUpgrade(layout, currentVersion2, version2, clock.now());
|
|
@@ -83273,7 +83534,7 @@ async function startMachinePlane(deps) {
|
|
|
83273
83534
|
[ALAN_MANAGED_SESSION_ENV]: "1"
|
|
83274
83535
|
},
|
|
83275
83536
|
cwd: paths.stateDir,
|
|
83276
|
-
outputPath: (0,
|
|
83537
|
+
outputPath: (0, import_node_path87.join)(paths.logs, "holders.log")
|
|
83277
83538
|
},
|
|
83278
83539
|
deps.holderIsolation
|
|
83279
83540
|
);
|
|
@@ -83535,6 +83796,9 @@ async function startMachinePlane(deps) {
|
|
|
83535
83796
|
log
|
|
83536
83797
|
})
|
|
83537
83798
|
);
|
|
83799
|
+
prewarmCliFlagProbes(paths.stateDir, cliEnvironment).catch(
|
|
83800
|
+
(error62) => log.warn("cli_flag_probes.prewarm_failed", { error: error62 })
|
|
83801
|
+
);
|
|
83538
83802
|
const workspaceRoot2 = config2.workspaceRoot;
|
|
83539
83803
|
if (workspaceRoot2 !== null && deps.gitGatewayReady !== void 0) {
|
|
83540
83804
|
void deps.gitGatewayReady.then(async (ready) => {
|
|
@@ -83545,7 +83809,7 @@ async function startMachinePlane(deps) {
|
|
|
83545
83809
|
git: createGitRunner({ env: cliEnvironment }),
|
|
83546
83810
|
clock,
|
|
83547
83811
|
log,
|
|
83548
|
-
dir: (0,
|
|
83812
|
+
dir: (0, import_node_path87.join)(paths.stateDir, "checkout-freshness")
|
|
83549
83813
|
},
|
|
83550
83814
|
stopped.signal
|
|
83551
83815
|
);
|
|
@@ -83852,7 +84116,7 @@ function lockWaitMs(argv) {
|
|
|
83852
84116
|
}
|
|
83853
84117
|
async function openManagedProviders(config2, paths) {
|
|
83854
84118
|
const providerEnv = readCliEnvironment();
|
|
83855
|
-
const bundledNpm = (0,
|
|
84119
|
+
const bundledNpm = (0, import_node_path88.join)((0, import_node_path88.dirname)(process.execPath), "npm", "bin", "npm-cli.js");
|
|
83856
84120
|
const providerToolchain = config2.providerToolchain ?? (process.platform === "win32" && (0, import_node_fs27.existsSync)(bundledNpm) ? { node: process.execPath, npmCli: bundledNpm } : null);
|
|
83857
84121
|
const npmPath = providerToolchain?.node ?? await resolveCommandOnPath("npm", providerEnv, process.platform);
|
|
83858
84122
|
const npmOptions = npmPath === null || process.platform === "win32" && providerToolchain === null ? null : {
|
|
@@ -83860,7 +84124,7 @@ async function openManagedProviders(config2, paths) {
|
|
|
83860
84124
|
...providerToolchain === null ? {} : { argsBeforeNpm: [providerToolchain.npmCli] },
|
|
83861
84125
|
env: providerEnv
|
|
83862
84126
|
};
|
|
83863
|
-
const providerNodeDir = providerToolchain?.node === void 0 ? void 0 : (0,
|
|
84127
|
+
const providerNodeDir = providerToolchain?.node === void 0 ? void 0 : (0, import_node_path88.dirname)(providerToolchain.node);
|
|
83864
84128
|
const probeEnv = providerNodeDir === void 0 ? providerEnv : {
|
|
83865
84129
|
...providerEnv,
|
|
83866
84130
|
PATH: `${providerNodeDir}${pathDelimiter(process.platform)}${envValue(providerEnv, "PATH")}`
|
|
@@ -83870,10 +84134,10 @@ async function openManagedProviders(config2, paths) {
|
|
|
83870
84134
|
throw new Error("Provider installer is unavailable on this computer");
|
|
83871
84135
|
};
|
|
83872
84136
|
const managed = createManagedProviderClis({
|
|
83873
|
-
root: (0,
|
|
84137
|
+
root: (0, import_node_path88.join)(paths.stateDir, "provider-clis"),
|
|
83874
84138
|
resolveVersion: npmOptions === null ? unavailable : createNpmVersionResolver(npmOptions),
|
|
83875
84139
|
installPackage: npmOptions === null ? unavailable : createNpmPackageInstaller(npmOptions),
|
|
83876
|
-
probe: (executable, backendKind) => probeManagedProvider(executable, backendKind, canonicalProbeEnv)
|
|
84140
|
+
probe: (executable, backendKind, signal) => probeManagedProvider(executable, backendKind, canonicalProbeEnv, signal)
|
|
83877
84141
|
});
|
|
83878
84142
|
await managed.load();
|
|
83879
84143
|
return { managed, providerNodeDir };
|
|
@@ -83902,7 +84166,7 @@ async function runService(argv, stop, restart = new AbortController().signal) {
|
|
|
83902
84166
|
waitMs: lockWaitMs(argv),
|
|
83903
84167
|
signal: stop
|
|
83904
84168
|
}));
|
|
83905
|
-
const log = __using(_stack, openFileLog((0,
|
|
84169
|
+
const log = __using(_stack, openFileLog((0, import_node_path88.join)(paths.logs, "runtime.jsonl"), config2.logLevel, clock));
|
|
83906
84170
|
const lifecycle = createLifecycleQueue({ clock, log });
|
|
83907
84171
|
const install2 = installLayout(config2.installDir, config2.profile);
|
|
83908
84172
|
const bundlePath = process.argv[1] ?? "";
|
|
@@ -83936,7 +84200,7 @@ async function runService(argv, stop, restart = new AbortController().signal) {
|
|
|
83936
84200
|
openCliEnvironment({
|
|
83937
84201
|
env: readCliEnvironment(),
|
|
83938
84202
|
platform: process.platform,
|
|
83939
|
-
lastKnownGoodFile: (0,
|
|
84203
|
+
lastKnownGoodFile: (0, import_node_path88.join)(paths.stateDir, "login-path.json"),
|
|
83940
84204
|
clock,
|
|
83941
84205
|
decorate: (env) => withPackagedAlanCodeEngine(env, bundlePath, process.platform)
|
|
83942
84206
|
})
|
|
@@ -84113,17 +84377,17 @@ async function runServiceCommand(argv, ctx = cliContext()) {
|
|
|
84113
84377
|
}
|
|
84114
84378
|
|
|
84115
84379
|
// src/cli/commands/upgrade.ts
|
|
84116
|
-
var
|
|
84117
|
-
var
|
|
84380
|
+
var import_promises85 = require("fs/promises");
|
|
84381
|
+
var import_node_path89 = require("path");
|
|
84118
84382
|
function isNotNewer(version2, installed) {
|
|
84119
84383
|
return installed !== null && isReleaseVersion(version2) && isReleaseVersion(installed) && compareVersions(version2, installed) <= 0;
|
|
84120
84384
|
}
|
|
84121
84385
|
async function installFromSource(source) {
|
|
84122
84386
|
const { layout, from, ifNewer } = source;
|
|
84123
|
-
const isTarball = (await (0,
|
|
84124
|
-
const downloads = (0,
|
|
84125
|
-
if (isTarball) await (0,
|
|
84126
|
-
const scratch = isTarball ? await (0,
|
|
84387
|
+
const isTarball = (await (0, import_promises85.stat)(from)).isFile();
|
|
84388
|
+
const downloads = (0, import_node_path89.join)(layout.root, ".downloads");
|
|
84389
|
+
if (isTarball) await (0, import_promises85.mkdir)(downloads, { recursive: true, mode: 448 });
|
|
84390
|
+
const scratch = isTarball ? await (0, import_promises85.mkdtemp)((0, import_node_path89.join)(downloads, "upgrade-")) : null;
|
|
84127
84391
|
try {
|
|
84128
84392
|
const sourceDir = scratch === null ? from : await extractPackageTarball(from, scratch);
|
|
84129
84393
|
const version2 = await readPackageVersion(sourceDir);
|
|
@@ -84131,7 +84395,7 @@ async function installFromSource(source) {
|
|
|
84131
84395
|
if (ifNewer && isNotNewer(version2, installed)) return { kind: "skipped", version: version2, installed };
|
|
84132
84396
|
return { kind: "installed", ...await installVersion(layout, sourceDir) };
|
|
84133
84397
|
} finally {
|
|
84134
|
-
if (scratch !== null) await (0,
|
|
84398
|
+
if (scratch !== null) await (0, import_promises85.rm)(scratch, { recursive: true, force: true });
|
|
84135
84399
|
}
|
|
84136
84400
|
}
|
|
84137
84401
|
async function runUpgrade(argv) {
|
|
@@ -84143,7 +84407,7 @@ async function runUpgrade(argv) {
|
|
|
84143
84407
|
const layout = installLayout(config2.installDir, config2.profile);
|
|
84144
84408
|
const outcome2 = await installFromSource({
|
|
84145
84409
|
layout,
|
|
84146
|
-
from: (0,
|
|
84410
|
+
from: (0, import_node_path89.resolve)(from),
|
|
84147
84411
|
ifNewer: hasFlag(argv, "--if-newer")
|
|
84148
84412
|
});
|
|
84149
84413
|
if (outcome2.kind === "skipped") {
|