@alan-ai-hq/agent-manager-linux-x64 0.1.129 → 0.1.130
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 +453 -480
- package/alan-holder.cjs +271 -319
- package/package.json +1 -1
package/alan-agent.cjs
CHANGED
|
@@ -21358,11 +21358,8 @@ var init_workflow_tools_filter = __esm({
|
|
|
21358
21358
|
"create_test_report",
|
|
21359
21359
|
"create_plan",
|
|
21360
21360
|
"create_document_artifact",
|
|
21361
|
-
"upsert_prototype_version",
|
|
21362
21361
|
"list_artifacts",
|
|
21363
|
-
"get_artifact"
|
|
21364
|
-
"list_prototypes",
|
|
21365
|
-
"get_prototype"
|
|
21362
|
+
"get_artifact"
|
|
21366
21363
|
];
|
|
21367
21364
|
LEGACY_WORKFLOW_BUILTIN_TOOLS = {
|
|
21368
21365
|
list_document_comments: "get_document",
|
|
@@ -22352,7 +22349,7 @@ var init_chunk_YXWJW7I5 = __esm({
|
|
|
22352
22349
|
}
|
|
22353
22350
|
});
|
|
22354
22351
|
|
|
22355
|
-
// ../agent-core/dist/chunk-
|
|
22352
|
+
// ../agent-core/dist/chunk-NDAB5G24.js
|
|
22356
22353
|
function windowsEnvValue(env, name) {
|
|
22357
22354
|
const wanted = name.toLowerCase();
|
|
22358
22355
|
for (const [key, value2] of Object.entries(env)) {
|
|
@@ -22476,6 +22473,12 @@ function planSpawn({ command, args, env, platform: platform3, files }) {
|
|
|
22476
22473
|
if (launch === void 0) {
|
|
22477
22474
|
throw new CoreFault("spawn_failed", `Could not start ${command} (not found on PATH)`);
|
|
22478
22475
|
}
|
|
22476
|
+
if (launch.kind === "batch") {
|
|
22477
|
+
throw new CoreFault(
|
|
22478
|
+
"spawn_failed",
|
|
22479
|
+
`${command} resolves to a batch file that cannot run as a managed Windows agent; install its native executable or supported npm shim`
|
|
22480
|
+
);
|
|
22481
|
+
}
|
|
22479
22482
|
return { file: launch.file, args: launch.args, commandLine: windowsCommandLine(launch, env) };
|
|
22480
22483
|
}
|
|
22481
22484
|
function planDirectLaunch({
|
|
@@ -22807,45 +22810,90 @@ function createProcessTree(child, options = {}) {
|
|
|
22807
22810
|
}
|
|
22808
22811
|
};
|
|
22809
22812
|
}
|
|
22810
|
-
function
|
|
22811
|
-
|
|
22812
|
-
|
|
22813
|
-
|
|
22814
|
-
|
|
22815
|
-
|
|
22816
|
-
|
|
22817
|
-
|
|
22818
|
-
].join("\n");
|
|
22813
|
+
function providerEnvironment(env) {
|
|
22814
|
+
const unique2 = /* @__PURE__ */ new Map();
|
|
22815
|
+
for (const [name, value2] of Object.entries(env)) {
|
|
22816
|
+
if (/^ALAN_JOB_(FILE|COMMAND|STATUS)$/i.test(name) || /^ALAN_WINHELPER_PATH$/i.test(name))
|
|
22817
|
+
continue;
|
|
22818
|
+
unique2.set(name.toLowerCase(), [name, value2]);
|
|
22819
|
+
}
|
|
22820
|
+
return Object.fromEntries(unique2.values());
|
|
22819
22821
|
}
|
|
22820
|
-
function
|
|
22821
|
-
|
|
22822
|
-
|
|
22823
|
-
|
|
22824
|
-
|
|
22825
|
-
|
|
22826
|
-
|
|
22827
|
-
|
|
22828
|
-
|
|
22829
|
-
|
|
22830
|
-
|
|
22831
|
-
|
|
22832
|
-
|
|
22833
|
-
|
|
22834
|
-
|
|
22835
|
-
|
|
22822
|
+
function requireStartedProvider(response, command) {
|
|
22823
|
+
if (response.startsWith("error:")) {
|
|
22824
|
+
throw new CoreFault("spawn_failed", `Could not start ${command} (${response.slice(6)})`);
|
|
22825
|
+
}
|
|
22826
|
+
if (!/^\d+$/.test(response)) {
|
|
22827
|
+
throw new CoreFault("spawn_failed", `Could not start ${command} (invalid helper response)`);
|
|
22828
|
+
}
|
|
22829
|
+
}
|
|
22830
|
+
function isWindowsJob(child) {
|
|
22831
|
+
return statuses.has(child);
|
|
22832
|
+
}
|
|
22833
|
+
function helperFile(env) {
|
|
22834
|
+
const override = Object.entries(env).find(([name]) => /^ALAN_WINHELPER_PATH$/i.test(name))?.[1];
|
|
22835
|
+
if (override) return override;
|
|
22836
|
+
const entry = process.argv[1];
|
|
22837
|
+
if (!entry) throw new CoreFault("spawn_failed", "Cannot locate the Windows agent helper");
|
|
22838
|
+
return (0, import_path2.join)((0, import_path2.dirname)(entry), "alan-winhelper.exe");
|
|
22836
22839
|
}
|
|
22837
22840
|
function spawnInWindowsJob(plan2, options) {
|
|
22838
22841
|
if (plan2.commandLine === null) {
|
|
22839
22842
|
throw new CoreFault("internal", `No Windows command line was planned for ${plan2.file}`);
|
|
22840
22843
|
}
|
|
22841
|
-
const
|
|
22842
|
-
|
|
22844
|
+
const file2 = helperFile(options.env);
|
|
22845
|
+
const directory = (0, import_fs2.mkdtempSync)((0, import_path2.join)((0, import_os.tmpdir)(), `alan-job-${(0, import_crypto.randomUUID)()}-`));
|
|
22846
|
+
const path4 = (0, import_path2.join)(directory, "started");
|
|
22847
|
+
const child = (0, import_child_process6.spawn)(file2, [String(process.pid)], {
|
|
22843
22848
|
cwd: options.cwd,
|
|
22844
|
-
env: {
|
|
22849
|
+
env: {
|
|
22850
|
+
...providerEnvironment(options.env),
|
|
22851
|
+
ALAN_JOB_FILE: plan2.file,
|
|
22852
|
+
ALAN_JOB_COMMAND: plan2.commandLine,
|
|
22853
|
+
ALAN_JOB_STATUS: path4
|
|
22854
|
+
},
|
|
22845
22855
|
stdio: ["pipe", "pipe", "pipe"],
|
|
22846
22856
|
shell: false,
|
|
22847
22857
|
windowsHide: true
|
|
22848
22858
|
});
|
|
22859
|
+
const status = { directory, path: path4 };
|
|
22860
|
+
child.once("error", (error61) => {
|
|
22861
|
+
status.error = error61;
|
|
22862
|
+
});
|
|
22863
|
+
statuses.set(child, status);
|
|
22864
|
+
return child;
|
|
22865
|
+
}
|
|
22866
|
+
async function waitForWindowsJob(child, command) {
|
|
22867
|
+
const status = statuses.get(child);
|
|
22868
|
+
if (!status) throw new CoreFault("internal", "Missing Windows helper startup state");
|
|
22869
|
+
const deadline = systemClock2.monotonic() + START_TIMEOUT_MS;
|
|
22870
|
+
try {
|
|
22871
|
+
while (systemClock2.monotonic() < deadline) {
|
|
22872
|
+
const providerPid = await (0, import_promises10.readFile)(status.path, "utf8").catch(() => void 0);
|
|
22873
|
+
if (providerPid !== void 0) {
|
|
22874
|
+
requireStartedProvider(providerPid, command);
|
|
22875
|
+
return;
|
|
22876
|
+
}
|
|
22877
|
+
if (status.error) {
|
|
22878
|
+
throw new CoreFault(
|
|
22879
|
+
"spawn_failed",
|
|
22880
|
+
`Could not start ${command} (${status.error.message})`,
|
|
22881
|
+
{
|
|
22882
|
+
cause: status.error
|
|
22883
|
+
}
|
|
22884
|
+
);
|
|
22885
|
+
}
|
|
22886
|
+
if (child.exitCode !== null || child.signalCode !== null) {
|
|
22887
|
+
throw new CoreFault("spawn_failed", `Could not start ${command} (Windows helper exited)`);
|
|
22888
|
+
}
|
|
22889
|
+
await systemClock2.sleep(25);
|
|
22890
|
+
}
|
|
22891
|
+
child.kill("SIGKILL");
|
|
22892
|
+
throw new CoreFault("spawn_failed", `Could not start ${command} (Windows helper timed out)`);
|
|
22893
|
+
} finally {
|
|
22894
|
+
statuses.delete(child);
|
|
22895
|
+
await (0, import_promises10.rm)(status.directory, { recursive: true, force: true });
|
|
22896
|
+
}
|
|
22849
22897
|
}
|
|
22850
22898
|
function spawnCli(options) {
|
|
22851
22899
|
const platform3 = options.platform ?? process.platform;
|
|
@@ -22860,6 +22908,7 @@ function spawnCli(options) {
|
|
|
22860
22908
|
});
|
|
22861
22909
|
}
|
|
22862
22910
|
function waitForSpawn(child, command) {
|
|
22911
|
+
if (isWindowsJob(child)) return waitForWindowsJob(child, command);
|
|
22863
22912
|
if (child.pid !== void 0) return Promise.resolve();
|
|
22864
22913
|
return new Promise((resolve10, reject) => {
|
|
22865
22914
|
const onSpawn = () => {
|
|
@@ -22877,9 +22926,9 @@ function waitForSpawn(child, command) {
|
|
|
22877
22926
|
child.once("error", onError);
|
|
22878
22927
|
});
|
|
22879
22928
|
}
|
|
22880
|
-
var import_child_process, import_fs, import_path, import_child_process2, import_promises9, import_child_process3, import_child_process4, import_child_process5, import_child_process6, import_path2, SHIM_MAX_BYTES, CMD_MAX_COMMAND_LINE, MAX_COMMAND_LINE, DEFAULT_PATHEXT, nodeWindowsFiles, NODE_SHIM_ENTRY, CMD_META, NEVER_STARTED, HIDDEN_FLAG_PROBE_VALUE, NEWLINE, CARRIAGE_RETURN, EMPTY, MAX_LINE_BYTES, LineSplitter, PS_LINE, POLL_MS, DEFAULT_GRACE_MS, DEFAULT_KILL_WAIT_MS, DEFAULT_TASKKILL_TIMEOUT_MS,
|
|
22881
|
-
var
|
|
22882
|
-
"../agent-core/dist/chunk-
|
|
22929
|
+
var import_child_process, import_fs, import_path, import_child_process2, import_promises9, import_child_process3, import_child_process4, import_child_process5, import_child_process6, import_crypto, import_fs2, import_promises10, import_os, import_path2, SHIM_MAX_BYTES, CMD_MAX_COMMAND_LINE, MAX_COMMAND_LINE, DEFAULT_PATHEXT, nodeWindowsFiles, NODE_SHIM_ENTRY, CMD_META, NEVER_STARTED, HIDDEN_FLAG_PROBE_VALUE, NEWLINE, CARRIAGE_RETURN, EMPTY, MAX_LINE_BYTES, LineSplitter, PS_LINE, POLL_MS, DEFAULT_GRACE_MS, DEFAULT_KILL_WAIT_MS, DEFAULT_TASKKILL_TIMEOUT_MS, statuses, START_TIMEOUT_MS;
|
|
22930
|
+
var init_chunk_NDAB5G24 = __esm({
|
|
22931
|
+
"../agent-core/dist/chunk-NDAB5G24.js"() {
|
|
22883
22932
|
"use strict";
|
|
22884
22933
|
init_chunk_YXWJW7I5();
|
|
22885
22934
|
import_child_process = require("child_process");
|
|
@@ -22891,6 +22940,10 @@ var init_chunk_VZIZDY3T = __esm({
|
|
|
22891
22940
|
import_child_process4 = require("child_process");
|
|
22892
22941
|
import_child_process5 = require("child_process");
|
|
22893
22942
|
import_child_process6 = require("child_process");
|
|
22943
|
+
import_crypto = require("crypto");
|
|
22944
|
+
import_fs2 = require("fs");
|
|
22945
|
+
import_promises10 = require("fs/promises");
|
|
22946
|
+
import_os = require("os");
|
|
22894
22947
|
import_path2 = require("path");
|
|
22895
22948
|
SHIM_MAX_BYTES = 64 * 1024;
|
|
22896
22949
|
CMD_MAX_COMMAND_LINE = 8191;
|
|
@@ -22962,87 +23015,8 @@ var init_chunk_VZIZDY3T = __esm({
|
|
|
22962
23015
|
DEFAULT_GRACE_MS = 3e3;
|
|
22963
23016
|
DEFAULT_KILL_WAIT_MS = 2e3;
|
|
22964
23017
|
DEFAULT_TASKKILL_TIMEOUT_MS = 5e3;
|
|
22965
|
-
|
|
22966
|
-
|
|
22967
|
-
using System;
|
|
22968
|
-
using System.Text;
|
|
22969
|
-
using System.Runtime.InteropServices;
|
|
22970
|
-
using System.ComponentModel;
|
|
22971
|
-
public static class AlanProviderJob {
|
|
22972
|
-
[StructLayout(LayoutKind.Sequential)] struct IO { public ulong a,b,c,d,e,f; }
|
|
22973
|
-
[StructLayout(LayoutKind.Sequential)] struct Limits {
|
|
22974
|
-
public long perProcess, perJob; public uint flags;
|
|
22975
|
-
public UIntPtr minWorkingSet, maxWorkingSet; public uint activeProcesses;
|
|
22976
|
-
public UIntPtr affinity; public uint priority, scheduling;
|
|
22977
|
-
}
|
|
22978
|
-
[StructLayout(LayoutKind.Sequential)] struct ExtendedLimits {
|
|
22979
|
-
public Limits basic; public IO io;
|
|
22980
|
-
public UIntPtr processMemory, jobMemory, peakProcessMemory, peakJobMemory;
|
|
22981
|
-
}
|
|
22982
|
-
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)] struct Startup {
|
|
22983
|
-
public uint cb; public string reserved, desktop, title;
|
|
22984
|
-
public uint x,y,xSize,ySize,xChars,yChars,fill,flags;
|
|
22985
|
-
public ushort show,reservedSize; public IntPtr reserved2, stdin, stdout, stderr;
|
|
22986
|
-
}
|
|
22987
|
-
[StructLayout(LayoutKind.Sequential)] struct ProcessInfo {
|
|
22988
|
-
public IntPtr process, thread; public uint pid, tid;
|
|
22989
|
-
}
|
|
22990
|
-
[DllImport("kernel32.dll", SetLastError=true)] static extern IntPtr CreateJobObject(IntPtr security, string name);
|
|
22991
|
-
[DllImport("kernel32.dll", SetLastError=true)] static extern bool SetInformationJobObject(IntPtr job, int kind, ref ExtendedLimits limits, uint size);
|
|
22992
|
-
[DllImport("kernel32.dll", SetLastError=true)] static extern bool AssignProcessToJobObject(IntPtr job, IntPtr process);
|
|
22993
|
-
[DllImport("kernel32.dll", SetLastError=true)] static extern bool TerminateJobObject(IntPtr job, uint code);
|
|
22994
|
-
[DllImport("kernel32.dll", SetLastError=true)] static extern bool TerminateProcess(IntPtr process, uint code);
|
|
22995
|
-
[DllImport("kernel32.dll", CharSet=CharSet.Unicode, SetLastError=true)] static extern bool CreateProcess(string app, StringBuilder command, IntPtr ps, IntPtr ts, bool inherit, uint flags, IntPtr env, string cwd, ref Startup si, out ProcessInfo pi);
|
|
22996
|
-
[DllImport("kernel32.dll")] static extern IntPtr GetStdHandle(int id);
|
|
22997
|
-
[DllImport("kernel32.dll")] static extern IntPtr GetCurrentProcess();
|
|
22998
|
-
[DllImport("kernel32.dll", SetLastError=true)] static extern bool DuplicateHandle(IntPtr sourceProcess, IntPtr source, IntPtr targetProcess, out IntPtr target, uint access, bool inherit, uint options);
|
|
22999
|
-
[DllImport("kernel32.dll", SetLastError=true)] static extern uint ResumeThread(IntPtr thread);
|
|
23000
|
-
[DllImport("kernel32.dll", SetLastError=true)] static extern IntPtr OpenProcess(uint access, bool inherit, int pid);
|
|
23001
|
-
[DllImport("kernel32.dll", SetLastError=true)] static extern uint WaitForMultipleObjects(uint count, IntPtr[] handles, bool all, uint ms);
|
|
23002
|
-
[DllImport("kernel32.dll")] static extern bool GetExitCodeProcess(IntPtr process, out uint code);
|
|
23003
|
-
[DllImport("kernel32.dll")] static extern bool CloseHandle(IntPtr handle);
|
|
23004
|
-
static void Check(bool ok) { if (!ok) throw new Win32Exception(Marshal.GetLastWin32Error()); }
|
|
23005
|
-
static IntPtr CopyStd(int id) {
|
|
23006
|
-
IntPtr result; var self = GetCurrentProcess();
|
|
23007
|
-
Check(DuplicateHandle(self, GetStdHandle(id), self, out result, 0, true, 2));
|
|
23008
|
-
return result;
|
|
23009
|
-
}
|
|
23010
|
-
public static int Run(string command, int ownerPid) {
|
|
23011
|
-
Environment.SetEnvironmentVariable("${JOB_COMMAND_VARIABLE}", null);
|
|
23012
|
-
IntPtr owner = OpenProcess(0x100000, false, ownerPid);
|
|
23013
|
-
if (owner == IntPtr.Zero) throw new Win32Exception(Marshal.GetLastWin32Error());
|
|
23014
|
-
IntPtr job = CreateJobObject(IntPtr.Zero, null);
|
|
23015
|
-
if (job == IntPtr.Zero) { CloseHandle(owner); throw new Win32Exception(Marshal.GetLastWin32Error()); }
|
|
23016
|
-
ProcessInfo pi = new ProcessInfo(); Startup si = new Startup();
|
|
23017
|
-
try {
|
|
23018
|
-
var limits = new ExtendedLimits(); limits.basic.flags = 0x2000;
|
|
23019
|
-
Check(SetInformationJobObject(job, 9, ref limits, (uint)Marshal.SizeOf(limits)));
|
|
23020
|
-
si.cb = (uint)Marshal.SizeOf(si); si.flags = 0x100;
|
|
23021
|
-
si.stdin = CopyStd(-10); si.stdout = CopyStd(-11); si.stderr = CopyStd(-12);
|
|
23022
|
-
Check(CreateProcess(null, new StringBuilder(command), IntPtr.Zero, IntPtr.Zero, true, 0x08000004, IntPtr.Zero, null, ref si, out pi));
|
|
23023
|
-
if (!AssignProcessToJobObject(job, pi.process)) {
|
|
23024
|
-
int error = Marshal.GetLastWin32Error(); TerminateProcess(pi.process, 1);
|
|
23025
|
-
throw new Win32Exception(error);
|
|
23026
|
-
}
|
|
23027
|
-
if (ResumeThread(pi.thread) == 0xffffffff) throw new Win32Exception(Marshal.GetLastWin32Error());
|
|
23028
|
-
uint wait = WaitForMultipleObjects(2, new IntPtr[] { pi.process, owner }, false, 0xffffffff);
|
|
23029
|
-
if (wait == 1) return 1;
|
|
23030
|
-
if (wait != 0) throw new Win32Exception(Marshal.GetLastWin32Error());
|
|
23031
|
-
uint code; Check(GetExitCodeProcess(pi.process, out code));
|
|
23032
|
-
Check(TerminateJobObject(job, code));
|
|
23033
|
-
return unchecked((int)code);
|
|
23034
|
-
} finally {
|
|
23035
|
-
CloseHandle(job);
|
|
23036
|
-
CloseHandle(owner);
|
|
23037
|
-
if (pi.thread != IntPtr.Zero) CloseHandle(pi.thread);
|
|
23038
|
-
if (pi.process != IntPtr.Zero) CloseHandle(pi.process);
|
|
23039
|
-
if (si.stdin != IntPtr.Zero) CloseHandle(si.stdin);
|
|
23040
|
-
if (si.stdout != IntPtr.Zero) CloseHandle(si.stdout);
|
|
23041
|
-
if (si.stderr != IntPtr.Zero) CloseHandle(si.stderr);
|
|
23042
|
-
}
|
|
23043
|
-
}
|
|
23044
|
-
}
|
|
23045
|
-
`;
|
|
23018
|
+
statuses = /* @__PURE__ */ new WeakMap();
|
|
23019
|
+
START_TIMEOUT_MS = 1e4;
|
|
23046
23020
|
}
|
|
23047
23021
|
});
|
|
23048
23022
|
|
|
@@ -24329,13 +24303,13 @@ function readTranscriptTurns(transcript, chunk, baseOffset, skipped = []) {
|
|
|
24329
24303
|
});
|
|
24330
24304
|
return { turns, consumedBytes: consumedEnd - baseOffset };
|
|
24331
24305
|
}
|
|
24332
|
-
var
|
|
24306
|
+
var import_fs3, NEWLINE2, TranscriptCursor, TranscriptLineLookup, CONTENT_UPDATES;
|
|
24333
24307
|
var init_chunk_LR52JUGL = __esm({
|
|
24334
24308
|
"../agent-core/dist/chunk-LR52JUGL.js"() {
|
|
24335
24309
|
"use strict";
|
|
24336
24310
|
init_chunk_OUQ7HMD3();
|
|
24337
24311
|
init_chunk_YXWJW7I5();
|
|
24338
|
-
|
|
24312
|
+
import_fs3 = require("fs");
|
|
24339
24313
|
NEWLINE2 = 10;
|
|
24340
24314
|
TranscriptCursor = class {
|
|
24341
24315
|
#path;
|
|
@@ -24353,7 +24327,7 @@ var init_chunk_LR52JUGL = __esm({
|
|
|
24353
24327
|
try {
|
|
24354
24328
|
this.#offset = Math.max(
|
|
24355
24329
|
this.#offset,
|
|
24356
|
-
(0,
|
|
24330
|
+
(0, import_fs3.statSync)(this.#path, { throwIfNoEntry: false })?.size ?? 0
|
|
24357
24331
|
);
|
|
24358
24332
|
} catch {
|
|
24359
24333
|
}
|
|
@@ -24375,15 +24349,15 @@ var init_chunk_LR52JUGL = __esm({
|
|
|
24375
24349
|
/** Runs on the CLI's stdout path, so an unreadable file reads as no new lines. */
|
|
24376
24350
|
#unread() {
|
|
24377
24351
|
try {
|
|
24378
|
-
const size = (0,
|
|
24352
|
+
const size = (0, import_fs3.statSync)(this.#path, { throwIfNoEntry: false })?.size ?? 0;
|
|
24379
24353
|
if (size <= this.#offset) return void 0;
|
|
24380
24354
|
const buffer = Buffer.alloc(size - this.#offset);
|
|
24381
|
-
const fd = (0,
|
|
24355
|
+
const fd = (0, import_fs3.openSync)(this.#path, "r");
|
|
24382
24356
|
try {
|
|
24383
|
-
const read = (0,
|
|
24357
|
+
const read = (0, import_fs3.readSync)(fd, buffer, 0, buffer.length, this.#offset);
|
|
24384
24358
|
return buffer.subarray(0, read);
|
|
24385
24359
|
} finally {
|
|
24386
|
-
(0,
|
|
24360
|
+
(0, import_fs3.closeSync)(fd);
|
|
24387
24361
|
}
|
|
24388
24362
|
} catch {
|
|
24389
24363
|
return void 0;
|
|
@@ -24581,7 +24555,7 @@ function createCliProblem(classified, options) {
|
|
|
24581
24555
|
return createAlanProblem({
|
|
24582
24556
|
domain: "agent_cli",
|
|
24583
24557
|
code: problemCodeFor(classified, options),
|
|
24584
|
-
id: options.id ?? (0,
|
|
24558
|
+
id: options.id ?? (0, import_crypto2.randomUUID)(),
|
|
24585
24559
|
title: terminal2 ? "Agent CLI run failed" : "Agent CLI problem observed",
|
|
24586
24560
|
detail: classified.message,
|
|
24587
24561
|
occurredAt: options.occurredAt,
|
|
@@ -24602,12 +24576,12 @@ function createCliProblem(classified, options) {
|
|
|
24602
24576
|
...classified.resetsAt ? { resetsAt: classified.resetsAt } : {}
|
|
24603
24577
|
});
|
|
24604
24578
|
}
|
|
24605
|
-
var
|
|
24579
|
+
var import_crypto2, ERROR_SPECS, AGENT_ERROR_KINDS, STATUS_PREFIX, TEXT_RULES, CODEX_TIMEOUT_MESSAGE, CODEX_EXPIRED_MESSAGE, EPOCH_RESET, WORDED_RESET, COMMAND_NOT_FOUND, CODE_RULES, TEXT_REFINES, CLI_PROBLEM_CODE_BY_ERROR_KIND, KEY_REJECTION_KINDS;
|
|
24606
24580
|
var init_chunk_R32NAS3B = __esm({
|
|
24607
24581
|
"../agent-core/dist/chunk-R32NAS3B.js"() {
|
|
24608
24582
|
"use strict";
|
|
24609
24583
|
init_chunk_YXWJW7I5();
|
|
24610
|
-
|
|
24584
|
+
import_crypto2 = require("crypto");
|
|
24611
24585
|
init_agent2();
|
|
24612
24586
|
ERROR_SPECS = {
|
|
24613
24587
|
model_mismatch: {
|
|
@@ -24842,7 +24816,7 @@ var init_chunk_R32NAS3B = __esm({
|
|
|
24842
24816
|
}
|
|
24843
24817
|
});
|
|
24844
24818
|
|
|
24845
|
-
// ../agent-core/dist/chunk-
|
|
24819
|
+
// ../agent-core/dist/chunk-BVWCFGFG.js
|
|
24846
24820
|
function collectStrings(value2, out) {
|
|
24847
24821
|
if (typeof value2 === "string") out.push(value2);
|
|
24848
24822
|
else if (Array.isArray(value2)) for (const item of value2) collectStrings(item, out);
|
|
@@ -24930,13 +24904,13 @@ function readMediaFiles(candidates2, cwd, mimeByExt, maxBytes) {
|
|
|
24930
24904
|
const files = [];
|
|
24931
24905
|
for (const candidate of candidates2) {
|
|
24932
24906
|
const path4 = normalizePath(candidate, cwd);
|
|
24933
|
-
if (!path4 || seen.has(path4) || !(0,
|
|
24907
|
+
if (!path4 || seen.has(path4) || !(0, import_fs4.existsSync)(path4)) continue;
|
|
24934
24908
|
seen.add(path4);
|
|
24935
24909
|
const mimeType = mimeByExt[(0, import_path3.extname)(path4).toLowerCase()];
|
|
24936
24910
|
if (!mimeType) continue;
|
|
24937
|
-
const stat19 = (0,
|
|
24911
|
+
const stat19 = (0, import_fs4.statSync)(path4);
|
|
24938
24912
|
if (!stat19.isFile() || stat19.size <= 0 || stat19.size > maxBytes) continue;
|
|
24939
|
-
files.push({ path: path4, mimeType, buffer: (0,
|
|
24913
|
+
files.push({ path: path4, mimeType, buffer: (0, import_fs4.readFileSync)(path4) });
|
|
24940
24914
|
}
|
|
24941
24915
|
return files;
|
|
24942
24916
|
}
|
|
@@ -25211,16 +25185,16 @@ function silentStartError(name, timeoutMs) {
|
|
|
25211
25185
|
message: `${name} printed nothing for ${seconds}s after it started and was stopped. Send your message again.`
|
|
25212
25186
|
};
|
|
25213
25187
|
}
|
|
25214
|
-
var
|
|
25215
|
-
var
|
|
25216
|
-
"../agent-core/dist/chunk-
|
|
25188
|
+
var import_crypto3, import_fs4, import_path3, IMAGE_MIME_BY_EXT, VIDEO_MIME_BY_EXT, IMAGE_EXTENSIONS, VIDEO_EXTENSIONS, MAX_IMAGE_BYTES, MAX_VIDEO_BYTES, AGENT_BROWSER_MENTION, LocalMediaReader, SessionOpenRefusal, JsonRpcError, ACP_PROTOCOL_VERSION, ACP_ERROR, STDERR_TAIL_LINES, RESULT_EXIT_GRACE_MS, PerTurnSession;
|
|
25189
|
+
var init_chunk_BVWCFGFG = __esm({
|
|
25190
|
+
"../agent-core/dist/chunk-BVWCFGFG.js"() {
|
|
25217
25191
|
"use strict";
|
|
25218
25192
|
init_chunk_OUQ7HMD3();
|
|
25219
25193
|
init_chunk_R32NAS3B();
|
|
25220
|
-
|
|
25194
|
+
init_chunk_NDAB5G24();
|
|
25221
25195
|
init_chunk_YXWJW7I5();
|
|
25222
|
-
|
|
25223
|
-
|
|
25196
|
+
import_crypto3 = require("crypto");
|
|
25197
|
+
import_fs4 = require("fs");
|
|
25224
25198
|
import_path3 = require("path");
|
|
25225
25199
|
init_agent2();
|
|
25226
25200
|
init_acp();
|
|
@@ -25281,13 +25255,13 @@ var init_chunk_2KE6BVIX = __esm({
|
|
|
25281
25255
|
}
|
|
25282
25256
|
#payloadFields(file2, toolId) {
|
|
25283
25257
|
return {
|
|
25284
|
-
id: (0,
|
|
25258
|
+
id: (0, import_crypto3.randomUUID)(),
|
|
25285
25259
|
filename: (0, import_path3.basename)(file2.path),
|
|
25286
25260
|
mimeType: file2.mimeType,
|
|
25287
25261
|
size: file2.buffer.length,
|
|
25288
25262
|
data: file2.buffer.toString("base64"),
|
|
25289
25263
|
sourcePath: file2.path,
|
|
25290
|
-
sourceHash: (0,
|
|
25264
|
+
sourceHash: (0, import_crypto3.createHash)("sha256").update(file2.buffer).digest("hex"),
|
|
25291
25265
|
toolId,
|
|
25292
25266
|
ts: this.#clock.now()
|
|
25293
25267
|
};
|
|
@@ -25571,7 +25545,7 @@ function selectExternalMcpServers(spec) {
|
|
|
25571
25545
|
return selected;
|
|
25572
25546
|
}
|
|
25573
25547
|
function headerEnvName(server, header) {
|
|
25574
|
-
const fingerprint = (0,
|
|
25548
|
+
const fingerprint = (0, import_crypto4.createHash)("sha256").update(`${server}\0${header}`).digest("hex").slice(0, 12);
|
|
25575
25549
|
return `ALAN_MCP_HEADER_${fingerprint.toUpperCase()}`;
|
|
25576
25550
|
}
|
|
25577
25551
|
function deliverRemote(name, server, env) {
|
|
@@ -25635,7 +25609,7 @@ function managedMcpHeaders(identity) {
|
|
|
25635
25609
|
}
|
|
25636
25610
|
function credentialDigest(authorization) {
|
|
25637
25611
|
if (authorization === void 0) return void 0;
|
|
25638
|
-
return (0,
|
|
25612
|
+
return (0, import_crypto5.createHash)("sha256").update(authorization).digest("hex").slice(0, 16);
|
|
25639
25613
|
}
|
|
25640
25614
|
function canonicalizeManagedMcpServerName(serverName) {
|
|
25641
25615
|
return RUN_SCOPED_SERVER.test(serverName) ? MANAGED_MCP_SERVER_NAME : serverName;
|
|
@@ -25647,30 +25621,30 @@ function canonicalizeManagedMcpToolName(toolName2) {
|
|
|
25647
25621
|
return flattened ? `mcp__${MANAGED_MCP_SERVER_NAME}__${flattened[1]}` : toolName2;
|
|
25648
25622
|
}
|
|
25649
25623
|
async function writeSecretFile(name, contents) {
|
|
25650
|
-
const dir = await (0,
|
|
25624
|
+
const dir = await (0, import_promises29.mkdtemp)((0, import_path4.join)((0, import_os2.tmpdir)(), "alan-mcp-"));
|
|
25651
25625
|
const path4 = (0, import_path4.join)(dir, name);
|
|
25652
25626
|
const remove = async () => {
|
|
25653
|
-
await (0,
|
|
25627
|
+
await (0, import_promises29.rm)(dir, { recursive: true, force: true });
|
|
25654
25628
|
};
|
|
25655
25629
|
try {
|
|
25656
|
-
await (0,
|
|
25630
|
+
await (0, import_promises29.writeFile)(path4, contents, { mode: 384, flag: "wx" });
|
|
25657
25631
|
} catch (error61) {
|
|
25658
25632
|
await remove();
|
|
25659
25633
|
throw error61;
|
|
25660
25634
|
}
|
|
25661
25635
|
return { path: path4, remove, [Symbol.asyncDispose]: remove };
|
|
25662
25636
|
}
|
|
25663
|
-
var
|
|
25637
|
+
var import_crypto4, import_crypto5, import_promises29, import_os2, import_path4, MANAGED_MCP_SERVER_NAME, RUN_SCOPED_SERVER, NAMESPACED_RUN_TOOL, FLATTENED_RUN_TOOL;
|
|
25664
25638
|
var init_chunk_J2KTV5FP = __esm({
|
|
25665
25639
|
"../agent-core/dist/chunk-J2KTV5FP.js"() {
|
|
25666
25640
|
"use strict";
|
|
25667
|
-
import_crypto3 = require("crypto");
|
|
25668
|
-
init_agent2();
|
|
25669
25641
|
import_crypto4 = require("crypto");
|
|
25670
25642
|
init_agent2();
|
|
25643
|
+
import_crypto5 = require("crypto");
|
|
25644
|
+
init_agent2();
|
|
25671
25645
|
init_runtime_v2();
|
|
25672
|
-
|
|
25673
|
-
|
|
25646
|
+
import_promises29 = require("fs/promises");
|
|
25647
|
+
import_os2 = require("os");
|
|
25674
25648
|
import_path4 = require("path");
|
|
25675
25649
|
MANAGED_MCP_SERVER_NAME = "alan";
|
|
25676
25650
|
RUN_SCOPED_SERVER = /^alan-run-[a-f0-9]{16}$/;
|
|
@@ -25679,7 +25653,7 @@ var init_chunk_J2KTV5FP = __esm({
|
|
|
25679
25653
|
}
|
|
25680
25654
|
});
|
|
25681
25655
|
|
|
25682
|
-
// ../agent-core/dist/chunk-
|
|
25656
|
+
// ../agent-core/dist/chunk-GXBS4QWA.js
|
|
25683
25657
|
function truncate(value2, limit) {
|
|
25684
25658
|
const normalized2 = Array.from(value2, (character) => {
|
|
25685
25659
|
const code = character.charCodeAt(0);
|
|
@@ -25881,7 +25855,6 @@ function artifactIdsSection(owner) {
|
|
|
25881
25855
|
const ids = artifactIds(owner);
|
|
25882
25856
|
if (ids.length === 0) return void 0;
|
|
25883
25857
|
const tools = ["create_plan", "create_document_artifact", "create_test_report"];
|
|
25884
|
-
if (owner.taskId || owner.isWorkflowSession) tools.push("upsert_prototype_version");
|
|
25885
25858
|
return [
|
|
25886
25859
|
`When creating artifacts using MCP tools (${tools.join(", ")}), always pass these IDs:`,
|
|
25887
25860
|
...ids
|
|
@@ -25893,26 +25866,6 @@ function standaloneChatSection(owner) {
|
|
|
25893
25866
|
}
|
|
25894
25867
|
return "This is a standalone chat. For create_plan, create_document_artifact, and create_test_report, omit taskId and workflowId; conversationId is the artifact owner. Do not use create_document unless the user explicitly asks for a standalone team Document.";
|
|
25895
25868
|
}
|
|
25896
|
-
function prototypeScope(owner) {
|
|
25897
|
-
if (owner.workflowId) {
|
|
25898
|
-
return {
|
|
25899
|
-
ids: "teamId, workflowId, workflowExecutionId, conversationId",
|
|
25900
|
-
lookup: "list_prototypes (with workflowId) or get_prototype"
|
|
25901
|
-
};
|
|
25902
|
-
}
|
|
25903
|
-
return owner.taskId ? { ids: "teamId, taskId, conversationId", lookup: "list_prototypes or get_prototype" } : void 0;
|
|
25904
|
-
}
|
|
25905
|
-
function prototypeSection(owner) {
|
|
25906
|
-
if (!owner.conversationId || !owner.teamId) return void 0;
|
|
25907
|
-
const scope = prototypeScope(owner);
|
|
25908
|
-
if (!scope) return void 0;
|
|
25909
|
-
return [
|
|
25910
|
-
"## Prototype Artifacts",
|
|
25911
|
-
"When the user asks to create, build, modify, or iterate on a prototype, do not create local prototype files such as prototype/index.html.",
|
|
25912
|
-
`Instead, generate a Vite React TypeScript source snapshot and call the Alan MCP tool upsert_prototype_version with ${scope.ids}, title, sourceSnapshot, and packageJson.`,
|
|
25913
|
-
`For follow-up changes to the same prototype, call ${scope.lookup} if needed, then call upsert_prototype_version again with the existing prototypeId and parentVersionId.`
|
|
25914
|
-
].join("\n");
|
|
25915
|
-
}
|
|
25916
25869
|
function contextSections(spec) {
|
|
25917
25870
|
const owner = ownershipOf(spec);
|
|
25918
25871
|
const context = spec.promptContext;
|
|
@@ -25921,8 +25874,7 @@ function contextSections(spec) {
|
|
|
25921
25874
|
taskContextSection(context?.taskMeta),
|
|
25922
25875
|
pullRequestSection(context?.prMeta),
|
|
25923
25876
|
artifactIdsSection(owner),
|
|
25924
|
-
standaloneChatSection(owner)
|
|
25925
|
-
prototypeSection(owner)
|
|
25877
|
+
standaloneChatSection(owner)
|
|
25926
25878
|
].filter((section) => section !== void 0);
|
|
25927
25879
|
}
|
|
25928
25880
|
function taskLifecycleSection(spec) {
|
|
@@ -26028,8 +25980,8 @@ ${body}` : body;
|
|
|
26028
25980
|
return spec.mode === "plan" ? planModePrefix(prefixed) : prefixed;
|
|
26029
25981
|
}
|
|
26030
25982
|
var MAX_PARSED_ATTACHMENTS, MAX_PARSED_ATTACHMENT_CHARS, MAX_METADATA_CHARS, UNAVAILABLE, READ_ONLY_MODES, AGENT_MODES;
|
|
26031
|
-
var
|
|
26032
|
-
"../agent-core/dist/chunk-
|
|
25983
|
+
var init_chunk_GXBS4QWA = __esm({
|
|
25984
|
+
"../agent-core/dist/chunk-GXBS4QWA.js"() {
|
|
26033
25985
|
"use strict";
|
|
26034
25986
|
init_agent2();
|
|
26035
25987
|
MAX_PARSED_ATTACHMENTS = 3;
|
|
@@ -27007,7 +26959,7 @@ function encodeProjectDir(cwd) {
|
|
|
27007
26959
|
}
|
|
27008
26960
|
function realCwd(cwd) {
|
|
27009
26961
|
try {
|
|
27010
|
-
return (0,
|
|
26962
|
+
return (0, import_fs5.realpathSync)(cwd);
|
|
27011
26963
|
} catch {
|
|
27012
26964
|
return cwd;
|
|
27013
26965
|
}
|
|
@@ -27021,12 +26973,12 @@ function claudeSessionLogExists(query) {
|
|
|
27021
26973
|
encodeProjectDir(cwd),
|
|
27022
26974
|
`${query.sessionId}.jsonl`
|
|
27023
26975
|
);
|
|
27024
|
-
if ((0,
|
|
26976
|
+
if ((0, import_fs5.existsSync)(log)) return true;
|
|
27025
26977
|
}
|
|
27026
26978
|
return false;
|
|
27027
26979
|
}
|
|
27028
26980
|
function envDigest(env) {
|
|
27029
|
-
const hash2 = (0,
|
|
26981
|
+
const hash2 = (0, import_crypto7.createHash)("sha256");
|
|
27030
26982
|
for (const key of Object.keys(env).sort()) hash2.update(`${key}\0${env[key]}\0`);
|
|
27031
26983
|
return hash2.digest("hex");
|
|
27032
26984
|
}
|
|
@@ -27089,7 +27041,7 @@ async function claudeTurnInput(run2, context) {
|
|
|
27089
27041
|
const encoded = await Promise.all(
|
|
27090
27042
|
images.map(async (image) => ({
|
|
27091
27043
|
mimeType: image.mimeType,
|
|
27092
|
-
data: (await (0,
|
|
27044
|
+
data: (await (0, import_promises30.readFile)(image.path)).toString("base64")
|
|
27093
27045
|
}))
|
|
27094
27046
|
);
|
|
27095
27047
|
return { turnId: run2.runId, text: text2, ...encoded.length ? { images: encoded } : {} };
|
|
@@ -27288,30 +27240,30 @@ function claudeTurnClosingUpdates(records, state) {
|
|
|
27288
27240
|
function readClaudeTranscriptTurns(chunk, baseOffset, skipped) {
|
|
27289
27241
|
return readTranscriptTurns(claudeTranscriptFile, chunk, baseOffset, skipped);
|
|
27290
27242
|
}
|
|
27291
|
-
var
|
|
27243
|
+
var import_crypto6, import_fs5, import_path5, import_crypto7, import_promises30, EDIT_TOOLS, ThoughtBlocks, UNDERSTOOD_SYSTEM_SUBTYPES, RATE_LIMIT_WARN_AT, CLAUDE_GRAMMAR_NAME, SUBAGENT_TOOL_NAMES, PLAN_ENTRY_STATUSES, controlResponseSchema, STOPPED_STATUSES, TaskRecords, TERMINAL_BACKGROUND_STATUSES, NON_TERMINAL_BACKGROUND_STATUSES, ASYNC_LAUNCH_ACK, BackgroundTasks, FAILED_STATUSES, STOPPED_BY_USER_TEXT, ClaudeTurn, STDERR_TAIL_LINES2, MAX_EARLY_LINES, UNSUPPORTED_STOP, OUTPUT_CLOSED_REASON, ClaudeSession, DEFAULTS, READ_ONLY_DISALLOWED_TOOLS, DEFAULT_MCP_TIMEOUT_MS, SYNTHETIC_MODEL, INTERRUPT_MARKER, NON_PROMPT_PREFIXES, PRELUDE_TYPES, claudeTranscriptFile;
|
|
27292
27244
|
var init_claude = __esm({
|
|
27293
27245
|
"../agent-core/dist/providers/claude.js"() {
|
|
27294
27246
|
"use strict";
|
|
27295
27247
|
init_chunk_LR52JUGL();
|
|
27296
|
-
|
|
27248
|
+
init_chunk_BVWCFGFG();
|
|
27297
27249
|
init_chunk_OUQ7HMD3();
|
|
27298
27250
|
init_chunk_R32NAS3B();
|
|
27299
27251
|
init_chunk_J2KTV5FP();
|
|
27300
|
-
|
|
27301
|
-
|
|
27252
|
+
init_chunk_NDAB5G24();
|
|
27253
|
+
init_chunk_GXBS4QWA();
|
|
27302
27254
|
init_chunk_YXWJW7I5();
|
|
27303
27255
|
init_effort();
|
|
27304
|
-
|
|
27256
|
+
import_crypto6 = require("crypto");
|
|
27305
27257
|
init_constants();
|
|
27306
27258
|
init_zod();
|
|
27307
27259
|
init_acp();
|
|
27308
27260
|
init_acp();
|
|
27309
27261
|
init_constants();
|
|
27310
27262
|
init_agent2();
|
|
27311
|
-
|
|
27263
|
+
import_fs5 = require("fs");
|
|
27312
27264
|
import_path5 = require("path");
|
|
27313
|
-
|
|
27314
|
-
|
|
27265
|
+
import_crypto7 = require("crypto");
|
|
27266
|
+
import_promises30 = require("fs/promises");
|
|
27315
27267
|
init_agent2();
|
|
27316
27268
|
EDIT_TOOLS = /* @__PURE__ */ new Set([
|
|
27317
27269
|
"Edit",
|
|
@@ -27953,7 +27905,7 @@ var init_claude = __esm({
|
|
|
27953
27905
|
sessionId: this.#lastTurn.grammar.sessionId,
|
|
27954
27906
|
taskRecords: this.#taskRecords
|
|
27955
27907
|
});
|
|
27956
|
-
const messageId = this.#replaysUserMessages ? (0,
|
|
27908
|
+
const messageId = this.#replaysUserMessages ? (0, import_crypto6.randomUUID)() : void 0;
|
|
27957
27909
|
const active = this.#startTurn(input2.turnId, turn, messageId);
|
|
27958
27910
|
this.#host.writer.write(claudeUserMessage(input2, messageId)).catch((error61) => {
|
|
27959
27911
|
this.#options.log.warn("claude.stdin_write_failed", { turnId: input2.turnId, error: error61 });
|
|
@@ -28371,7 +28323,7 @@ function codexHomeOf(env) {
|
|
|
28371
28323
|
}
|
|
28372
28324
|
function namesNewestFirst(dir, isDir) {
|
|
28373
28325
|
try {
|
|
28374
|
-
return (0,
|
|
28326
|
+
return (0, import_fs6.readdirSync)(dir, { withFileTypes: true }).filter((entry) => isDir ? entry.isDirectory() : entry.isFile()).map((entry) => entry.name).sort().reverse();
|
|
28375
28327
|
} catch {
|
|
28376
28328
|
return [];
|
|
28377
28329
|
}
|
|
@@ -28551,7 +28503,7 @@ function codexGeneratedImage(payload, ts) {
|
|
|
28551
28503
|
const declared = asString(payload.mimeType) || asString(payload.mime_type);
|
|
28552
28504
|
const mimeType = declared.startsWith("image/") ? declared : inferImageMimeType(buffer);
|
|
28553
28505
|
if (!mimeType) return null;
|
|
28554
|
-
const sourceHash = (0,
|
|
28506
|
+
const sourceHash = (0, import_crypto8.createHash)("sha256").update(buffer).digest("hex");
|
|
28555
28507
|
const toolId = asString(payload.call_id);
|
|
28556
28508
|
const id = asString(payload.id) || toolId || sourceHash;
|
|
28557
28509
|
const sourcePath = asString(payload.sourcePath);
|
|
@@ -29333,7 +29285,7 @@ function createCodexExecDriver(options = {}) {
|
|
|
29333
29285
|
};
|
|
29334
29286
|
}
|
|
29335
29287
|
function envDigest2(env) {
|
|
29336
|
-
const hash2 = (0,
|
|
29288
|
+
const hash2 = (0, import_crypto9.createHash)("sha256");
|
|
29337
29289
|
for (const key of Object.keys(env).sort()) hash2.update(`${key}\0${env[key]}\0`);
|
|
29338
29290
|
return hash2.digest("hex");
|
|
29339
29291
|
}
|
|
@@ -29995,7 +29947,7 @@ function readCodexRolloutTurns(chunk, baseOffset, skipped) {
|
|
|
29995
29947
|
return readTranscriptTurns(codexRolloutFile, chunk, baseOffset, skipped);
|
|
29996
29948
|
}
|
|
29997
29949
|
function envDigest22(env) {
|
|
29998
|
-
const hash2 = (0,
|
|
29950
|
+
const hash2 = (0, import_crypto10.createHash)("sha256");
|
|
29999
29951
|
for (const key of Object.keys(env).sort()) hash2.update(`${key}\0${env[key]}\0`);
|
|
30000
29952
|
return hash2.digest("hex");
|
|
30001
29953
|
}
|
|
@@ -30064,26 +30016,26 @@ function codexTurnInput(run2, context) {
|
|
|
30064
30016
|
...images.length ? { imagePaths: images.map((image) => image.path) } : {}
|
|
30065
30017
|
};
|
|
30066
30018
|
}
|
|
30067
|
-
var
|
|
30019
|
+
var import_fs6, import_path6, import_crypto8, import_crypto9, import_crypto10, TokenRefresher, MCP_STARTUP_TIMEOUT_SEC, FIELD_TYPES, YES_NO, ACCEPT_DECLINE, MAX_INLINE_GENERATED_IMAGE_BYTES, PNG_SIGNATURE, JPEG_NON_FRAME_MARKERS, IMAGE_GEN_CALL, PROMPT_LITERAL, TURN_END_EVENTS, RELOCATE_EVERY_MS, CodexImageGenerationFold, CodexRolloutImages, 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, WORKER_LIFECYCLE, INFO_KINDS, SILENT, CodexTurn, STDERR_TAIL_LINES3, MAX_BETWEEN_UPDATES, UNSUPPORTED_REQUEST, DECLINED_ELICITATION, IMAGE_CATCH_UP_MS, IMAGE_POLL_MS, CodexSession, CODEX_MIN_VERSION, CODEX_REQUIREMENT, CODEX_TESTED_LINE, DEFAULTS2, CLIENT_INFO, 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_OPERATIONS, UNDERSTOOD_ITEM_TYPES, PRELUDE_TYPES2, PRELUDE_EVENTS, codexRolloutFile;
|
|
30068
30020
|
var init_codex = __esm({
|
|
30069
30021
|
"../agent-core/dist/providers/codex.js"() {
|
|
30070
30022
|
"use strict";
|
|
30071
30023
|
init_chunk_LR52JUGL();
|
|
30072
|
-
|
|
30024
|
+
init_chunk_BVWCFGFG();
|
|
30073
30025
|
init_chunk_OUQ7HMD3();
|
|
30074
30026
|
init_chunk_R32NAS3B();
|
|
30075
30027
|
init_chunk_J2KTV5FP();
|
|
30076
|
-
|
|
30077
|
-
|
|
30028
|
+
init_chunk_NDAB5G24();
|
|
30029
|
+
init_chunk_GXBS4QWA();
|
|
30078
30030
|
init_chunk_YXWJW7I5();
|
|
30079
|
-
|
|
30031
|
+
import_fs6 = require("fs");
|
|
30080
30032
|
import_path6 = require("path");
|
|
30081
30033
|
init_effort();
|
|
30082
|
-
import_crypto7 = require("crypto");
|
|
30083
|
-
init_agent2();
|
|
30084
30034
|
import_crypto8 = require("crypto");
|
|
30085
30035
|
init_agent2();
|
|
30086
30036
|
import_crypto9 = require("crypto");
|
|
30037
|
+
init_agent2();
|
|
30038
|
+
import_crypto10 = require("crypto");
|
|
30087
30039
|
init_effort();
|
|
30088
30040
|
TokenRefresher = class {
|
|
30089
30041
|
#auth;
|
|
@@ -31295,9 +31247,9 @@ function packagedAlanCodeEnginePath(bundle, platform3) {
|
|
|
31295
31247
|
}
|
|
31296
31248
|
function isRunnableFile(path4, platform3) {
|
|
31297
31249
|
try {
|
|
31298
|
-
if (!(0,
|
|
31250
|
+
if (!(0, import_fs7.statSync)(path4).isFile()) return false;
|
|
31299
31251
|
if (platform3 === "win32") return WINDOWS_RUNNABLE_EXTENSION.test(path4);
|
|
31300
|
-
(0,
|
|
31252
|
+
(0, import_fs7.accessSync)(path4, import_fs7.constants.X_OK);
|
|
31301
31253
|
return true;
|
|
31302
31254
|
} catch {
|
|
31303
31255
|
return false;
|
|
@@ -31466,18 +31418,18 @@ function alanCodeEngineEnv(input2) {
|
|
|
31466
31418
|
};
|
|
31467
31419
|
}
|
|
31468
31420
|
async function writePlugin(directory, apiOrigin) {
|
|
31469
|
-
const origin = (0,
|
|
31421
|
+
const origin = (0, import_crypto11.createHash)("sha256").update(apiOrigin).digest("hex").slice(0, 12);
|
|
31470
31422
|
const target = (0, import_path8.join)(directory, `engine-plugin-v${ALAN_CODE_ENGINE_PLUGIN_VERSION}-${origin}.mjs`);
|
|
31471
|
-
const temporary = `${target}.${(0,
|
|
31472
|
-
await (0,
|
|
31473
|
-
await (0,
|
|
31474
|
-
await (0,
|
|
31423
|
+
const temporary = `${target}.${(0, import_crypto11.randomUUID)()}.tmp`;
|
|
31424
|
+
await (0, import_promises33.mkdir)(directory, { recursive: true, mode: 448 });
|
|
31425
|
+
await (0, import_promises33.writeFile)(temporary, alanCodeEnginePluginSource(apiOrigin), { mode: 384 });
|
|
31426
|
+
await (0, import_promises33.rename)(temporary, target);
|
|
31475
31427
|
return (0, import_url.pathToFileURL)(target).href;
|
|
31476
31428
|
}
|
|
31477
31429
|
async function prepareAlanCodeProfile(input2) {
|
|
31478
31430
|
const directories = Object.values(alanCodeEngineDirectories(input2.engineRoot));
|
|
31479
31431
|
await Promise.all(
|
|
31480
|
-
directories.map((directory) => (0,
|
|
31432
|
+
directories.map((directory) => (0, import_promises33.mkdir)(directory, { recursive: true, mode: 448 }))
|
|
31481
31433
|
);
|
|
31482
31434
|
const [pluginUrl, models] = await Promise.all([
|
|
31483
31435
|
writePlugin((0, import_path8.join)(input2.engineRoot, "plugin"), input2.access.apiOrigin),
|
|
@@ -31500,7 +31452,7 @@ function alanCodeSystemPrompt(alanSystemPrompt) {
|
|
|
31500
31452
|
|
|
31501
31453
|
${instructions}` : ALAN_CODE_TOOL_NAMING_PROMPT;
|
|
31502
31454
|
}
|
|
31503
|
-
var import_http9, import_https,
|
|
31455
|
+
var import_http9, import_https, import_fs7, import_path7, import_crypto11, import_promises33, import_path8, 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, CATALOG_TIMEOUT_MS, MAX_CATALOG_BYTES, 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;
|
|
31504
31456
|
var init_alan_code = __esm({
|
|
31505
31457
|
"../agent-core/dist/providers/alan-code.js"() {
|
|
31506
31458
|
"use strict";
|
|
@@ -31510,11 +31462,11 @@ var init_alan_code = __esm({
|
|
|
31510
31462
|
init_runtime_v2();
|
|
31511
31463
|
init_runtime_v2();
|
|
31512
31464
|
init_models();
|
|
31513
|
-
|
|
31465
|
+
import_fs7 = require("fs");
|
|
31514
31466
|
import_path7 = require("path");
|
|
31515
31467
|
init_runtime_v2();
|
|
31516
|
-
|
|
31517
|
-
|
|
31468
|
+
import_crypto11 = require("crypto");
|
|
31469
|
+
import_promises33 = require("fs/promises");
|
|
31518
31470
|
import_path8 = require("path");
|
|
31519
31471
|
import_url = require("url");
|
|
31520
31472
|
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\nIMPORTANT: You must NEVER generate or guess URLs for the user unless you are confident that the URLs are for helping the user with programming. You may use URLs provided by the user in their messages or local files.\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\nYou have access to a `todowrite` tool which tracks steps and progress and renders them to the user. Using the tool helps demonstrate that you've understood the task and convey how you're approaching it. Plans can help to make complex, ambiguous, or multi-phase work clearer and more collaborative for the user. A good plan should break the task into meaningful, logically ordered steps that are easy to verify as you go.\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\nDo not repeat the full contents of the plan after a `todowrite` call \u2014 the harness already displays it. Instead, summarize the change made and highlight any important context or next step.\n\nBefore running a command, consider whether or not you have completed the previous step, and make sure to mark it as completed before moving on to the next step. It may be the case that you complete all steps in your plan after a single pass of implementation. If this is the case, you can simply mark all the planned steps as completed. Sometimes, you may need to change plans in the middle of a task: call `todowrite` with the updated plan and make sure to explain the rationale when doing so.\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- For multi-step or risky work, enter plan mode (`/plan` or `--plan`) before editing. Explore read-only, then call `plan_write` with a decision-complete markdown plan (approach, rejected alternatives, verification, assumptions). Wait for user approval before implementing.\n- Prefer the durable plan file path over relying on chat memory after compaction.\n- When requirements are ambiguous, use the `question` tool with concrete options instead of guessing.\n- `todowrite` tracks execution steps (see its Tool Guidelines entry); it is not a substitute for a durable plan file.\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 `edit` tool to modify existing files and the `write` tool to create new ones. This harness has no structured-patch tool \u2014 never try `apply_patch`, `applypatch`, or `apply-patch`.\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- Do not add inline comments within code unless explicitly requested.\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- When working in interactive permission modes like `ask before edits` or `plan`, hold off on running tests or lint commands until the user is ready for you to finalize your output, because these commands take time to run and slow down iteration. Instead suggest what you want to do next, and let the user confirm first.\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\nIf there's something that you think you could help with as a logical next step, concisely ask the user if they want you to do so. Good examples of this are running tests, committing changes, or building out the next logical component. If there's something that you couldn't do (even with approval) but that the user might want to do (such as verifying changes by running the app), include those instructions succinctly.\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- Leave no blank line before the first bullet under a header.\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\nYou may be proactive, but only when the user asks you to do something. 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 over creating new ones. Do not create documentation or markdown files unless asked.\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, prefer a task/subagent tool if one is available to reduce context usage; otherwise use the available search tools.\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\n## `todowrite`\n\nA tool named `todowrite` is available to you. You can use it to keep an up-to-date, step-by-step plan for the task.\n\nTo create a new plan, call `todowrite` with a short list of 1-sentence steps (no more than 5-7 words each) with a `status` for each step (`pending`, `in_progress`, `completed`, or `cancelled`). The call is a full replace \u2014 always send the complete list, not a delta.\n\nWhen steps have been completed, use `todowrite` to mark each finished step as `completed` and the next step you are working on as `in_progress`. There should always be exactly one `in_progress` step until everything is done. You can mark multiple items as complete in a single `todowrite` call.\n\nIf all steps are complete, ensure you call `todowrite` to mark all steps as `completed`.\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";
|
|
@@ -41309,10 +41261,10 @@ var require_tar_stream = __commonJS({
|
|
|
41309
41261
|
var init_dist = __esm({
|
|
41310
41262
|
"../agent-core/dist/index.js"() {
|
|
41311
41263
|
"use strict";
|
|
41312
|
-
|
|
41264
|
+
init_chunk_BVWCFGFG();
|
|
41313
41265
|
init_chunk_OUQ7HMD3();
|
|
41314
41266
|
init_chunk_R32NAS3B();
|
|
41315
|
-
|
|
41267
|
+
init_chunk_NDAB5G24();
|
|
41316
41268
|
init_chunk_YXWJW7I5();
|
|
41317
41269
|
}
|
|
41318
41270
|
});
|
|
@@ -41404,7 +41356,7 @@ function within(root, path4) {
|
|
|
41404
41356
|
}
|
|
41405
41357
|
async function resolveReal(path4) {
|
|
41406
41358
|
try {
|
|
41407
|
-
return await (0,
|
|
41359
|
+
return await (0, import_promises46.realpath)(path4);
|
|
41408
41360
|
} catch {
|
|
41409
41361
|
const parent = (0, import_path9.dirname)(path4);
|
|
41410
41362
|
if (parent === path4) return path4;
|
|
@@ -41433,14 +41385,14 @@ function createWorkspaceFs(roots, writable) {
|
|
|
41433
41385
|
return {
|
|
41434
41386
|
read: async (params) => {
|
|
41435
41387
|
const path4 = await confined(params);
|
|
41436
|
-
const bytes = await (0,
|
|
41388
|
+
const bytes = await (0, import_promises46.readFile)(path4);
|
|
41437
41389
|
if (bytes.byteLength > MAX_READ_BYTES) throw new FsDenied(`${path4} is too large to read`);
|
|
41438
41390
|
return { content: sliceLines(bytes.toString("utf8"), params) };
|
|
41439
41391
|
},
|
|
41440
41392
|
write: async (params) => {
|
|
41441
41393
|
if (!writable) throw new FsDenied("This session is read-only");
|
|
41442
41394
|
const path4 = await confined(params);
|
|
41443
|
-
await (0,
|
|
41395
|
+
await (0, import_promises46.writeFile)(path4, asString(params.content));
|
|
41444
41396
|
return {};
|
|
41445
41397
|
}
|
|
41446
41398
|
};
|
|
@@ -41985,7 +41937,7 @@ function isAcpBackendKind(value2) {
|
|
|
41985
41937
|
return Object.hasOwn(ACP_PROFILES, value2);
|
|
41986
41938
|
}
|
|
41987
41939
|
function envDigest3(env) {
|
|
41988
|
-
const hash2 = (0,
|
|
41940
|
+
const hash2 = (0, import_crypto12.createHash)("sha256");
|
|
41989
41941
|
for (const key of Object.keys(env).sort()) hash2.update(`${key}\0${env[key]}\0`);
|
|
41990
41942
|
return hash2.digest("hex");
|
|
41991
41943
|
}
|
|
@@ -42043,7 +41995,7 @@ async function acpTurnInput(run2, context) {
|
|
|
42043
41995
|
const encoded = await Promise.all(
|
|
42044
41996
|
images.map(async (image) => ({
|
|
42045
41997
|
mimeType: image.mimeType,
|
|
42046
|
-
data: (await (0,
|
|
41998
|
+
data: (await (0, import_promises47.readFile)(image.path)).toString("base64")
|
|
42047
41999
|
}))
|
|
42048
42000
|
);
|
|
42049
42001
|
return {
|
|
@@ -42052,23 +42004,23 @@ async function acpTurnInput(run2, context) {
|
|
|
42052
42004
|
...encoded.length ? { images: encoded, imagePaths: images.map((image) => image.path) } : {}
|
|
42053
42005
|
};
|
|
42054
42006
|
}
|
|
42055
|
-
var
|
|
42007
|
+
var import_promises46, import_path9, import_crypto12, import_promises47, CURSOR_ASK_QUESTION, copilotAcpProfile, cursorAcpProfile, MODEL_REJECTED, MAX_READ_BYTES, FsDenied, ENV_REFERENCE, AcpBackgroundTasks, CURSOR_CREATE_PLAN, STATUSES, READ_KINDS, ALLOW_KINDS, REJECT_KINDS, CANCELLED_PERMISSION, STOP_REASONS, CHUNKS, ECHOES, AcpTurn, STDERR_TAIL_LINES4, MAX_BETWEEN_UPDATES2, AcpSession, DEFAULTS3, CLIENT_INFO2, TASK_BACKGROUNDED, TASK_COMPLETED, SESSION_NOTIFICATION, KILLED_STATUSES, SUCCESS_STATUSES, SUBAGENT_ID, grokTaskDialect, grokAcpProfile, kimiAcpProfile, ACP_PROFILES, ACP_MODES;
|
|
42056
42008
|
var init_acp3 = __esm({
|
|
42057
42009
|
"../agent-core/dist/providers/acp.js"() {
|
|
42058
42010
|
"use strict";
|
|
42059
|
-
|
|
42011
|
+
init_chunk_BVWCFGFG();
|
|
42060
42012
|
init_chunk_OUQ7HMD3();
|
|
42061
42013
|
init_chunk_R32NAS3B();
|
|
42062
42014
|
init_chunk_J2KTV5FP();
|
|
42063
|
-
|
|
42064
|
-
|
|
42015
|
+
init_chunk_NDAB5G24();
|
|
42016
|
+
init_chunk_GXBS4QWA();
|
|
42065
42017
|
init_chunk_YXWJW7I5();
|
|
42066
|
-
|
|
42018
|
+
import_promises46 = require("fs/promises");
|
|
42067
42019
|
import_path9 = require("path");
|
|
42068
42020
|
init_effort();
|
|
42069
42021
|
init_acp();
|
|
42070
|
-
|
|
42071
|
-
|
|
42022
|
+
import_crypto12 = require("crypto");
|
|
42023
|
+
import_promises47 = require("fs/promises");
|
|
42072
42024
|
init_agent2();
|
|
42073
42025
|
CURSOR_ASK_QUESTION = "cursor/ask_question";
|
|
42074
42026
|
copilotAcpProfile = {
|
|
@@ -43592,7 +43544,7 @@ function createOpenCodeDriver(options = {}) {
|
|
|
43592
43544
|
await authorization?.remove();
|
|
43593
43545
|
};
|
|
43594
43546
|
const spec = { ...planned, env: launchEnv(planned, authorization) };
|
|
43595
|
-
const password = options.password?.() ?? (0,
|
|
43547
|
+
const password = options.password?.() ?? (0, import_crypto13.randomBytes)(24).toString("base64url");
|
|
43596
43548
|
const attempt2 = { abandoned: false };
|
|
43597
43549
|
const { session, url: url3 } = await withDeadline3(
|
|
43598
43550
|
startServer(spec, password, resolved, attempt2),
|
|
@@ -43636,7 +43588,7 @@ function createOpenCodeDriver(options = {}) {
|
|
|
43636
43588
|
};
|
|
43637
43589
|
}
|
|
43638
43590
|
function envDigest4(env) {
|
|
43639
|
-
const hash2 = (0,
|
|
43591
|
+
const hash2 = (0, import_crypto14.createHash)("sha256");
|
|
43640
43592
|
for (const key of Object.keys(env).sort()) hash2.update(`${key}\0${env[key]}\0`);
|
|
43641
43593
|
return hash2.digest("hex");
|
|
43642
43594
|
}
|
|
@@ -43716,25 +43668,25 @@ function openCodeTurnInput(run2, context) {
|
|
|
43716
43668
|
...images.length ? { imagePaths: images.map((image) => image.path) } : {}
|
|
43717
43669
|
};
|
|
43718
43670
|
}
|
|
43719
|
-
var import_http10,
|
|
43671
|
+
var import_http10, import_crypto13, import_path10, import_url2, import_crypto14, IDLE_SOCKET_MS3, OpenCodeHttpError, 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_OPERATIONS2, PartReader, NOTHING, NON_INTERACTIVE_PERMISSIONS, CONTENT_FILTER_FINISHES, OUTPUT_PARTS, OpenCodeTurn, LISTENING, OUTPUT_TAIL_LINES, IMAGE_TYPES, OpenCodeSession, OPENCODE_MIN_VERSION, OPENCODE_REQUIREMENT, OPENCODE_TESTED_LINE, OPENCODE_SUPPORTED_MAJOR, DEFAULTS4, STORE_LOCKED, NON_INTERACTIVE_RULES, TITLE_LENGTH, MAX_VARIANT_LENGTH;
|
|
43720
43672
|
var init_opencode = __esm({
|
|
43721
43673
|
"../agent-core/dist/providers/opencode.js"() {
|
|
43722
43674
|
"use strict";
|
|
43723
|
-
|
|
43675
|
+
init_chunk_BVWCFGFG();
|
|
43724
43676
|
init_chunk_OUQ7HMD3();
|
|
43725
43677
|
init_chunk_R32NAS3B();
|
|
43726
43678
|
init_chunk_J2KTV5FP();
|
|
43727
|
-
|
|
43728
|
-
|
|
43679
|
+
init_chunk_NDAB5G24();
|
|
43680
|
+
init_chunk_GXBS4QWA();
|
|
43729
43681
|
init_chunk_YXWJW7I5();
|
|
43730
43682
|
import_http10 = require("http");
|
|
43731
43683
|
init_runtime_v2();
|
|
43732
|
-
|
|
43684
|
+
import_crypto13 = require("crypto");
|
|
43733
43685
|
init_agent2();
|
|
43734
43686
|
import_path10 = require("path");
|
|
43735
43687
|
import_url2 = require("url");
|
|
43736
43688
|
init_acp();
|
|
43737
|
-
|
|
43689
|
+
import_crypto14 = require("crypto");
|
|
43738
43690
|
init_agent2();
|
|
43739
43691
|
IDLE_SOCKET_MS3 = 4e3;
|
|
43740
43692
|
OpenCodeHttpError = class extends Error {
|
|
@@ -45415,7 +45367,7 @@ function createDroidDriver(options = {}) {
|
|
|
45415
45367
|
};
|
|
45416
45368
|
}
|
|
45417
45369
|
function envDigest5(env) {
|
|
45418
|
-
const hash2 = (0,
|
|
45370
|
+
const hash2 = (0, import_crypto15.createHash)("sha256");
|
|
45419
45371
|
for (const key of Object.keys(env).sort()) hash2.update(`${key}\0${env[key]}\0`);
|
|
45420
45372
|
return hash2.digest("hex");
|
|
45421
45373
|
}
|
|
@@ -45470,25 +45422,25 @@ async function droidTurnInput(run2, context) {
|
|
|
45470
45422
|
const encoded = await Promise.all(
|
|
45471
45423
|
images.map(async (image) => ({
|
|
45472
45424
|
mimeType: image.mimeType,
|
|
45473
|
-
data: (await (0,
|
|
45425
|
+
data: (await (0, import_promises48.readFile)(image.path)).toString("base64")
|
|
45474
45426
|
}))
|
|
45475
45427
|
);
|
|
45476
45428
|
return { turnId: run2.runId, text: text2, ...encoded.length ? { images: encoded } : {} };
|
|
45477
45429
|
}
|
|
45478
|
-
var
|
|
45430
|
+
var import_crypto15, import_promises48, 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;
|
|
45479
45431
|
var init_droid = __esm({
|
|
45480
45432
|
"../agent-core/dist/providers/droid.js"() {
|
|
45481
45433
|
"use strict";
|
|
45482
|
-
|
|
45434
|
+
init_chunk_BVWCFGFG();
|
|
45483
45435
|
init_chunk_OUQ7HMD3();
|
|
45484
45436
|
init_chunk_R32NAS3B();
|
|
45485
45437
|
init_chunk_J2KTV5FP();
|
|
45486
|
-
|
|
45487
|
-
|
|
45438
|
+
init_chunk_NDAB5G24();
|
|
45439
|
+
init_chunk_GXBS4QWA();
|
|
45488
45440
|
init_chunk_YXWJW7I5();
|
|
45489
45441
|
init_runtime_v2();
|
|
45490
|
-
|
|
45491
|
-
|
|
45442
|
+
import_crypto15 = require("crypto");
|
|
45443
|
+
import_promises48 = require("fs/promises");
|
|
45492
45444
|
init_agent2();
|
|
45493
45445
|
FACTORY_API_VERSION = "1.0.0";
|
|
45494
45446
|
FACTORY_PROTOCOL_VERSION = "1.187.0";
|
|
@@ -45993,7 +45945,7 @@ function antigravityArgs(input2, capabilities, prompt) {
|
|
|
45993
45945
|
}
|
|
45994
45946
|
function workspaceRoot(cwd) {
|
|
45995
45947
|
for (let current = (0, import_path11.resolve)(cwd); ; current = (0, import_path11.dirname)(current)) {
|
|
45996
|
-
if ((0,
|
|
45948
|
+
if ((0, import_fs8.existsSync)((0, import_path11.join)(current, ".git"))) return current;
|
|
45997
45949
|
if ((0, import_path11.dirname)(current) === current) return (0, import_path11.resolve)(cwd);
|
|
45998
45950
|
}
|
|
45999
45951
|
}
|
|
@@ -46003,7 +45955,7 @@ function instructionPaths(cwd) {
|
|
|
46003
45955
|
for (let current = (0, import_path11.resolve)(cwd); ; current = (0, import_path11.dirname)(current)) {
|
|
46004
45956
|
const path4 = (0, import_path11.join)(current, INSTRUCTIONS_FILE);
|
|
46005
45957
|
try {
|
|
46006
|
-
if ((0,
|
|
45958
|
+
if ((0, import_fs8.existsSync)(path4) && (0, import_fs8.statSync)(path4).isFile()) paths.unshift(path4);
|
|
46007
45959
|
} catch {
|
|
46008
45960
|
}
|
|
46009
45961
|
if (current === root || (0, import_path11.dirname)(current) === current) return paths;
|
|
@@ -46017,7 +45969,7 @@ function antigravityWorkspaceInstructions(cwd, maxChars = MAX_INSTRUCTION_CHARS)
|
|
|
46017
45969
|
if (remaining <= 0) break;
|
|
46018
45970
|
let content;
|
|
46019
45971
|
try {
|
|
46020
|
-
content = (0,
|
|
45972
|
+
content = (0, import_fs8.readFileSync)(path4, "utf8").trim();
|
|
46021
45973
|
} catch {
|
|
46022
45974
|
continue;
|
|
46023
45975
|
}
|
|
@@ -46498,7 +46450,7 @@ ${output2.stderr}`).join("\n")
|
|
|
46498
46450
|
};
|
|
46499
46451
|
}
|
|
46500
46452
|
function envDigest6(env) {
|
|
46501
|
-
const hash2 = (0,
|
|
46453
|
+
const hash2 = (0, import_crypto16.createHash)("sha256");
|
|
46502
46454
|
for (const key of Object.keys(env).sort()) hash2.update(`${key}\0${env[key]}\0`);
|
|
46503
46455
|
return hash2.digest("hex");
|
|
46504
46456
|
}
|
|
@@ -46544,23 +46496,23 @@ function antigravityTurnInput(run2, context) {
|
|
|
46544
46496
|
});
|
|
46545
46497
|
return { turnId: run2.runId, text: appendImagePathReferences(text2, images) };
|
|
46546
46498
|
}
|
|
46547
|
-
var
|
|
46499
|
+
var import_fs8, import_path11, import_path12, import_url3, import_crypto16, 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, AntigravityTurn, DEFAULTS6, AntigravitySession, WINDOWS_LINE_MARGIN;
|
|
46548
46500
|
var init_antigravity = __esm({
|
|
46549
46501
|
"../agent-core/dist/providers/antigravity.js"() {
|
|
46550
46502
|
"use strict";
|
|
46551
46503
|
init_chunk_LR52JUGL();
|
|
46552
|
-
|
|
46504
|
+
init_chunk_BVWCFGFG();
|
|
46553
46505
|
init_chunk_OUQ7HMD3();
|
|
46554
46506
|
init_chunk_R32NAS3B();
|
|
46555
|
-
|
|
46556
|
-
|
|
46507
|
+
init_chunk_NDAB5G24();
|
|
46508
|
+
init_chunk_GXBS4QWA();
|
|
46557
46509
|
init_chunk_YXWJW7I5();
|
|
46558
|
-
|
|
46510
|
+
import_fs8 = require("fs");
|
|
46559
46511
|
import_path11 = require("path");
|
|
46560
46512
|
init_effort();
|
|
46561
46513
|
import_path12 = require("path");
|
|
46562
46514
|
import_url3 = require("url");
|
|
46563
|
-
|
|
46515
|
+
import_crypto16 = require("crypto");
|
|
46564
46516
|
init_agent2();
|
|
46565
46517
|
NO_ANTIGRAVITY_CAPABILITIES = {
|
|
46566
46518
|
structuredPrint: false,
|
|
@@ -47046,7 +46998,7 @@ function parseConfig(raw) {
|
|
|
47046
46998
|
}
|
|
47047
46999
|
async function writeCommandCodeProjectMcp(cwd, mcp) {
|
|
47048
47000
|
const path4 = (0, import_path13.join)(cwd, ".mcp.json");
|
|
47049
|
-
const original = await (0,
|
|
47001
|
+
const original = await (0, import_promises49.readFile)(path4, "utf8").catch(() => null);
|
|
47050
47002
|
const config2 = parseConfig(original);
|
|
47051
47003
|
const next = {
|
|
47052
47004
|
...config2,
|
|
@@ -47063,12 +47015,12 @@ async function writeCommandCodeProjectMcp(cwd, mcp) {
|
|
|
47063
47015
|
}
|
|
47064
47016
|
}
|
|
47065
47017
|
};
|
|
47066
|
-
await (0,
|
|
47067
|
-
await (0,
|
|
47018
|
+
await (0, import_promises49.mkdir)(cwd, { recursive: true });
|
|
47019
|
+
await (0, import_promises49.writeFile)(path4, `${JSON.stringify(next, null, 2)}
|
|
47068
47020
|
`);
|
|
47069
47021
|
return async () => {
|
|
47070
|
-
if (original === null) await (0,
|
|
47071
|
-
else await (0,
|
|
47022
|
+
if (original === null) await (0, import_promises49.rm)(path4, { force: true });
|
|
47023
|
+
else await (0, import_promises49.writeFile)(path4, original);
|
|
47072
47024
|
};
|
|
47073
47025
|
}
|
|
47074
47026
|
function commandCodeString(value2) {
|
|
@@ -47177,7 +47129,7 @@ function createCommandCodeDriver(options = {}) {
|
|
|
47177
47129
|
};
|
|
47178
47130
|
}
|
|
47179
47131
|
function envDigest7(env) {
|
|
47180
|
-
const hash2 = (0,
|
|
47132
|
+
const hash2 = (0, import_crypto17.createHash)("sha256");
|
|
47181
47133
|
for (const key of Object.keys(env).sort()) hash2.update(`${key}\0${env[key]}\0`);
|
|
47182
47134
|
return hash2.digest("hex");
|
|
47183
47135
|
}
|
|
@@ -47229,22 +47181,22 @@ function commandCodeTurnInput(run2, context) {
|
|
|
47229
47181
|
});
|
|
47230
47182
|
return { turnId: run2.runId, text: appendImagePathReferences(text2, images) };
|
|
47231
47183
|
}
|
|
47232
|
-
var
|
|
47184
|
+
var import_promises49, import_path13, import_crypto17, COMMAND_CODE_GRAMMAR_NAME, SILENT3, CommandCodeGrammar, CommandCodeTurn, COMMAND_CODE_MAX_TURNS, DEFAULTS7, CommandCodeSession;
|
|
47233
47185
|
var init_command_code = __esm({
|
|
47234
47186
|
"../agent-core/dist/providers/command-code.js"() {
|
|
47235
47187
|
"use strict";
|
|
47236
|
-
|
|
47188
|
+
init_chunk_BVWCFGFG();
|
|
47237
47189
|
init_chunk_OUQ7HMD3();
|
|
47238
47190
|
init_chunk_R32NAS3B();
|
|
47239
47191
|
init_chunk_J2KTV5FP();
|
|
47240
|
-
|
|
47241
|
-
|
|
47192
|
+
init_chunk_NDAB5G24();
|
|
47193
|
+
init_chunk_GXBS4QWA();
|
|
47242
47194
|
init_chunk_YXWJW7I5();
|
|
47243
|
-
|
|
47195
|
+
import_promises49 = require("fs/promises");
|
|
47244
47196
|
import_path13 = require("path");
|
|
47245
47197
|
init_agent2();
|
|
47246
47198
|
init_runtime_v2();
|
|
47247
|
-
|
|
47199
|
+
import_crypto17 = require("crypto");
|
|
47248
47200
|
init_agent2();
|
|
47249
47201
|
COMMAND_CODE_GRAMMAR_NAME = "command_code_cli";
|
|
47250
47202
|
SILENT3 = /* @__PURE__ */ new Set([
|
|
@@ -52433,7 +52385,7 @@ var require_websocket_server = __commonJS({
|
|
|
52433
52385
|
// package.json
|
|
52434
52386
|
var package_default = {
|
|
52435
52387
|
name: "@alan-ai-hq/agent-manager",
|
|
52436
|
-
version: "0.1.
|
|
52388
|
+
version: "0.1.130",
|
|
52437
52389
|
private: true,
|
|
52438
52390
|
type: "module",
|
|
52439
52391
|
description: "Alan machine runtime (alan-agent): identity, link, reconciler, session holders, run log, uploader, local API",
|
|
@@ -52480,7 +52432,7 @@ var package_default = {
|
|
|
52480
52432
|
|
|
52481
52433
|
// src/cli/commands/compat.ts
|
|
52482
52434
|
var import_node_crypto25 = require("crypto");
|
|
52483
|
-
var
|
|
52435
|
+
var import_promises59 = require("fs/promises");
|
|
52484
52436
|
init_runtime_v2();
|
|
52485
52437
|
init_zod();
|
|
52486
52438
|
|
|
@@ -54495,7 +54447,7 @@ async function push(context, request2) {
|
|
|
54495
54447
|
var import_node_child_process = require("child_process");
|
|
54496
54448
|
|
|
54497
54449
|
// ../agent-core/dist/process.js
|
|
54498
|
-
|
|
54450
|
+
init_chunk_NDAB5G24();
|
|
54499
54451
|
init_chunk_YXWJW7I5();
|
|
54500
54452
|
|
|
54501
54453
|
// src/capabilities/git/run-git.ts
|
|
@@ -54781,7 +54733,7 @@ var import_node_net = require("net");
|
|
|
54781
54733
|
|
|
54782
54734
|
// src/platform/credential-store/credential-store.ts
|
|
54783
54735
|
var import_node_crypto4 = require("crypto");
|
|
54784
|
-
var
|
|
54736
|
+
var import_promises11 = require("fs/promises");
|
|
54785
54737
|
|
|
54786
54738
|
// src/platform/credential-store/parse.ts
|
|
54787
54739
|
function parseStoredJson(text2, schema) {
|
|
@@ -54930,7 +54882,7 @@ function createFileCredentialStore(path4) {
|
|
|
54930
54882
|
kind: "file",
|
|
54931
54883
|
read: (schema) => readJsonFile(path4, schema),
|
|
54932
54884
|
write: (value2) => writeJsonFileAtomic(path4, value2),
|
|
54933
|
-
clear: () => (0,
|
|
54885
|
+
clear: () => (0, import_promises11.rm)(path4, { force: true })
|
|
54934
54886
|
};
|
|
54935
54887
|
}
|
|
54936
54888
|
var KEYCHAIN_SERVICE = "ai.tryalan.runtime";
|
|
@@ -55025,14 +54977,14 @@ function defaultCredentialStoreKind(platform3) {
|
|
|
55025
54977
|
var import_node_child_process3 = require("child_process");
|
|
55026
54978
|
var import_node_crypto5 = require("crypto");
|
|
55027
54979
|
var import_node_fs3 = require("fs");
|
|
55028
|
-
var
|
|
54980
|
+
var import_promises13 = require("fs/promises");
|
|
55029
54981
|
var import_node_path7 = require("path");
|
|
55030
54982
|
var import_node_util2 = require("util");
|
|
55031
54983
|
init_zod();
|
|
55032
54984
|
|
|
55033
54985
|
// src/platform/process-identity.ts
|
|
55034
54986
|
var import_node_child_process2 = require("child_process");
|
|
55035
|
-
var
|
|
54987
|
+
var import_promises12 = require("fs/promises");
|
|
55036
54988
|
var import_node_util = require("util");
|
|
55037
54989
|
var execFileAsync = (0, import_node_util.promisify)(import_node_child_process2.execFile);
|
|
55038
54990
|
function isProcessAlive(pid) {
|
|
@@ -55044,13 +54996,13 @@ function isProcessAlive(pid) {
|
|
|
55044
54996
|
}
|
|
55045
54997
|
}
|
|
55046
54998
|
async function linuxStartTime(pid) {
|
|
55047
|
-
const stat19 = await (0,
|
|
54999
|
+
const stat19 = await (0, import_promises12.readFile)(`/proc/${pid}/stat`, "utf8").catch(() => null);
|
|
55048
55000
|
if (stat19 === null) return null;
|
|
55049
55001
|
const fields = stat19.slice(stat19.lastIndexOf(")") + 2).split(" ");
|
|
55050
55002
|
return fields[19] ?? null;
|
|
55051
55003
|
}
|
|
55052
55004
|
async function linuxCommand(pid) {
|
|
55053
|
-
const raw = await (0,
|
|
55005
|
+
const raw = await (0, import_promises12.readFile)(`/proc/${pid}/cmdline`, "utf8").catch(() => null);
|
|
55054
55006
|
return raw === null ? null : normalizeCommand(raw.replaceAll("\0", " "));
|
|
55055
55007
|
}
|
|
55056
55008
|
async function darwinCommand(pid) {
|
|
@@ -55240,23 +55192,23 @@ async function reportedVersion(versionDir) {
|
|
|
55240
55192
|
return stdout.trim();
|
|
55241
55193
|
}
|
|
55242
55194
|
async function switchLauncher(layout, version2) {
|
|
55243
|
-
await (0,
|
|
55195
|
+
await (0, import_promises13.mkdir)(layout.bin, { recursive: true, mode: 448 });
|
|
55244
55196
|
const staged = (0, import_node_path7.join)(layout.bin, `.${(0, import_node_path7.basename)(layout.launcher)}.${(0, import_node_crypto5.randomUUID)()}`);
|
|
55245
55197
|
if (process.platform === "win32") {
|
|
55246
55198
|
(0, import_node_fs3.writeFileSync)(staged, `@"%~dp0..\\versions\\${version2}\\alan-agent.cmd" %*\r
|
|
55247
55199
|
`);
|
|
55248
55200
|
} else {
|
|
55249
|
-
await (0,
|
|
55201
|
+
await (0, import_promises13.symlink)((0, import_node_path7.join)("..", "versions", version2, "alan-agent"), staged);
|
|
55250
55202
|
}
|
|
55251
|
-
await (0,
|
|
55203
|
+
await (0, import_promises13.rename)(staged, layout.launcher);
|
|
55252
55204
|
}
|
|
55253
55205
|
async function launcherVersion(launcher) {
|
|
55254
55206
|
try {
|
|
55255
55207
|
if (process.platform === "win32") {
|
|
55256
|
-
const match = /versions\\([^\\]+)\\/.exec(await (0,
|
|
55208
|
+
const match = /versions\\([^\\]+)\\/.exec(await (0, import_promises13.readFile)(launcher, "utf8"));
|
|
55257
55209
|
return match?.[1] ?? null;
|
|
55258
55210
|
}
|
|
55259
|
-
return (0, import_node_path7.basename)((0, import_node_path7.dirname)(await (0,
|
|
55211
|
+
return (0, import_node_path7.basename)((0, import_node_path7.dirname)(await (0, import_promises13.readlink)(launcher)));
|
|
55260
55212
|
} catch (error61) {
|
|
55261
55213
|
if (errnoCode(error61) === "ENOENT") return null;
|
|
55262
55214
|
throw error61;
|
|
@@ -55267,7 +55219,7 @@ function currentVersion(layout) {
|
|
|
55267
55219
|
}
|
|
55268
55220
|
async function launcherVersions(layout) {
|
|
55269
55221
|
const versions = [];
|
|
55270
|
-
for (const name of await (0,
|
|
55222
|
+
for (const name of await (0, import_promises13.readdir)(layout.bin).catch(() => [])) {
|
|
55271
55223
|
if (!name.startsWith(LAUNCHER_STEM)) continue;
|
|
55272
55224
|
const version2 = await launcherVersion((0, import_node_path7.join)(layout.bin, name)).catch(() => null);
|
|
55273
55225
|
if (version2 !== null) versions.push(version2);
|
|
@@ -55299,7 +55251,7 @@ function assertUsableVersion(version2) {
|
|
|
55299
55251
|
}
|
|
55300
55252
|
}
|
|
55301
55253
|
async function exists(path4) {
|
|
55302
|
-
return (0,
|
|
55254
|
+
return (0, import_promises13.stat)(path4).then(
|
|
55303
55255
|
() => true,
|
|
55304
55256
|
() => false
|
|
55305
55257
|
);
|
|
@@ -55310,7 +55262,7 @@ function isVersionInstalled(layout, version2) {
|
|
|
55310
55262
|
async function stageVersion(layout, sourceDir, expectedVersion) {
|
|
55311
55263
|
var _stack = [];
|
|
55312
55264
|
try {
|
|
55313
|
-
await (0,
|
|
55265
|
+
await (0, import_promises13.mkdir)(layout.versions, { recursive: true, mode: 448 });
|
|
55314
55266
|
const _lock = __using(_stack, takeInstallLock(layout.lock));
|
|
55315
55267
|
const version2 = await readPackageVersion(sourceDir);
|
|
55316
55268
|
if (expectedVersion !== void 0 && version2 !== expectedVersion) {
|
|
@@ -55323,17 +55275,17 @@ async function stageVersion(layout, sourceDir, expectedVersion) {
|
|
|
55323
55275
|
const target = (0, import_node_path7.join)(layout.versions, version2);
|
|
55324
55276
|
if (await exists(target)) return version2;
|
|
55325
55277
|
const staging = (0, import_node_path7.join)(layout.versions, `.${version2}`);
|
|
55326
|
-
await (0,
|
|
55278
|
+
await (0, import_promises13.rm)(staging, { recursive: true, force: true });
|
|
55327
55279
|
try {
|
|
55328
|
-
await (0,
|
|
55280
|
+
await (0, import_promises13.cp)(sourceDir, staging, { recursive: true });
|
|
55329
55281
|
if (await reportedVersion(staging) !== version2) {
|
|
55330
55282
|
throw new RuntimeFault("invalid_file", `Staged runtime ${version2} does not start`);
|
|
55331
55283
|
}
|
|
55332
55284
|
} catch (error61) {
|
|
55333
|
-
await (0,
|
|
55285
|
+
await (0, import_promises13.rm)(staging, { recursive: true, force: true });
|
|
55334
55286
|
throw error61;
|
|
55335
55287
|
}
|
|
55336
|
-
await (0,
|
|
55288
|
+
await (0, import_promises13.rename)(staging, target);
|
|
55337
55289
|
return version2;
|
|
55338
55290
|
} catch (_) {
|
|
55339
55291
|
var _error = _, _hasError = true;
|
|
@@ -55350,19 +55302,19 @@ async function installVersion(layout, sourceDir) {
|
|
|
55350
55302
|
async function hasLiveMarker(versionDir) {
|
|
55351
55303
|
const markers = (0, import_node_path7.join)(versionDir, ".running");
|
|
55352
55304
|
let live = false;
|
|
55353
|
-
for (const name of await (0,
|
|
55305
|
+
for (const name of await (0, import_promises13.readdir)(markers).catch(() => [])) {
|
|
55354
55306
|
if (isProcessAlive(Number(name))) live = true;
|
|
55355
|
-
else await (0,
|
|
55307
|
+
else await (0, import_promises13.rm)((0, import_node_path7.join)(markers, name), { force: true });
|
|
55356
55308
|
}
|
|
55357
55309
|
return live;
|
|
55358
55310
|
}
|
|
55359
55311
|
async function collectOldVersions(layout) {
|
|
55360
|
-
const entries = await (0,
|
|
55312
|
+
const entries = await (0, import_promises13.readdir)(layout.versions, { withFileTypes: true }).catch(() => []);
|
|
55361
55313
|
const versions = await Promise.all(
|
|
55362
55314
|
entries.filter((entry) => entry.isDirectory() && !entry.name.startsWith(".")).map(async (entry) => ({
|
|
55363
55315
|
name: entry.name,
|
|
55364
55316
|
// The launcher, not the directory: `.running` markers touch the directory's mtime.
|
|
55365
|
-
installedAtMs: (await (0,
|
|
55317
|
+
installedAtMs: (await (0, import_promises13.stat)(launcherIn((0, import_node_path7.join)(layout.versions, entry.name)))).mtimeMs
|
|
55366
55318
|
}))
|
|
55367
55319
|
);
|
|
55368
55320
|
const keep = new Set(
|
|
@@ -55373,7 +55325,7 @@ async function collectOldVersions(layout) {
|
|
|
55373
55325
|
for (const { name } of versions) {
|
|
55374
55326
|
const dir = (0, import_node_path7.join)(layout.versions, name);
|
|
55375
55327
|
if (keep.has(name) || await hasLiveMarker(dir)) continue;
|
|
55376
|
-
await (0,
|
|
55328
|
+
await (0, import_promises13.rm)(dir, { recursive: true, force: true });
|
|
55377
55329
|
removed.push(name);
|
|
55378
55330
|
}
|
|
55379
55331
|
return removed;
|
|
@@ -55397,7 +55349,7 @@ function markVersionInUse(bundlePath) {
|
|
|
55397
55349
|
|
|
55398
55350
|
// src/platform/instance-lock.ts
|
|
55399
55351
|
var import_node_fs4 = require("fs");
|
|
55400
|
-
var
|
|
55352
|
+
var import_promises14 = require("fs/promises");
|
|
55401
55353
|
var import_node_path8 = require("path");
|
|
55402
55354
|
init_zod();
|
|
55403
55355
|
var LOCK_POLL_MS = 100;
|
|
@@ -55454,7 +55406,7 @@ async function attempt(path4, self, probe) {
|
|
|
55454
55406
|
return tryCreate(path4, self) ? { kind: "acquired" } : attempt(path4, self, probe);
|
|
55455
55407
|
}
|
|
55456
55408
|
async function acquireInstanceLock(path4, { clock, waitMs, signal, probe = systemProcessProbe }) {
|
|
55457
|
-
await (0,
|
|
55409
|
+
await (0, import_promises14.mkdir)((0, import_node_path8.dirname)(path4), { recursive: true, mode: 448 });
|
|
55458
55410
|
const self = await readProcessIdentity(process.pid);
|
|
55459
55411
|
if (self === null) throw new RuntimeFault("internal", "Cannot read this process's identity");
|
|
55460
55412
|
const deadline = clock.monotonic() + waitMs;
|
|
@@ -55610,13 +55562,13 @@ function runtimePaths(stateDir) {
|
|
|
55610
55562
|
|
|
55611
55563
|
// src/platform/process-memory.ts
|
|
55612
55564
|
var import_node_child_process4 = require("child_process");
|
|
55613
|
-
var
|
|
55565
|
+
var import_promises15 = require("fs/promises");
|
|
55614
55566
|
var import_node_util3 = require("util");
|
|
55615
55567
|
var execFileAsync3 = (0, import_node_util3.promisify)(import_node_child_process4.execFile);
|
|
55616
55568
|
var PROBE_TIMEOUT_MS = 2e3;
|
|
55617
55569
|
async function readProcessRss(pid) {
|
|
55618
55570
|
if (process.platform === "linux") {
|
|
55619
|
-
const status = await (0,
|
|
55571
|
+
const status = await (0, import_promises15.readFile)(`/proc/${pid}/status`, "utf8").catch(() => null);
|
|
55620
55572
|
const kilobytes = status === null ? void 0 : /^VmRSS:\s+(\d+)\s+kB$/m.exec(status)?.[1];
|
|
55621
55573
|
return kilobytes === void 0 ? null : Number(kilobytes) * 1024;
|
|
55622
55574
|
}
|
|
@@ -55648,7 +55600,7 @@ async function darwinPressure() {
|
|
|
55648
55600
|
var PSI_WARN_SOME_AVG10 = 20;
|
|
55649
55601
|
var PSI_CRITICAL_FULL_AVG10 = 10;
|
|
55650
55602
|
async function linuxPressure() {
|
|
55651
|
-
const psi = await (0,
|
|
55603
|
+
const psi = await (0, import_promises15.readFile)("/proc/pressure/memory", "utf8").catch(() => null);
|
|
55652
55604
|
if (psi === null) return "normal";
|
|
55653
55605
|
const avg10 = (kind) => Number(new RegExp(`^${kind} avg10=([\\d.]+)`, "m").exec(psi)?.[1] ?? 0);
|
|
55654
55606
|
if (avg10("full") >= PSI_CRITICAL_FULL_AVG10) return "critical";
|
|
@@ -55735,7 +55687,7 @@ function planUpdate(input2) {
|
|
|
55735
55687
|
// src/platform/release-apply.ts
|
|
55736
55688
|
var import_node_child_process5 = require("child_process");
|
|
55737
55689
|
var import_node_crypto9 = require("crypto");
|
|
55738
|
-
var
|
|
55690
|
+
var import_promises16 = require("fs/promises");
|
|
55739
55691
|
var import_node_path11 = require("path");
|
|
55740
55692
|
var import_node_util4 = require("util");
|
|
55741
55693
|
init_zod();
|
|
@@ -55759,7 +55711,7 @@ function npmReleaseFrom(bytes, request2) {
|
|
|
55759
55711
|
return resolved.release;
|
|
55760
55712
|
}
|
|
55761
55713
|
async function extractPackageTarball(tarballPath, destination) {
|
|
55762
|
-
await (0,
|
|
55714
|
+
await (0, import_promises16.mkdir)(destination, { recursive: true, mode: 448 });
|
|
55763
55715
|
await execFileAsync4("tar", ["-xzf", tarballPath, "-C", destination]);
|
|
55764
55716
|
return (0, import_node_path11.join)(destination, "package");
|
|
55765
55717
|
}
|
|
@@ -55772,14 +55724,14 @@ async function stageNpmTarball({
|
|
|
55772
55724
|
const integrity = verifyNpmIntegrity(tarball, release2.dist);
|
|
55773
55725
|
if (!integrity.ok) throw new RuntimeFault("invalid_file", integrity.reason);
|
|
55774
55726
|
const scratch = (0, import_node_path11.join)(tmpDir, (0, import_node_crypto9.randomUUID)());
|
|
55775
|
-
await (0,
|
|
55727
|
+
await (0, import_promises16.mkdir)(scratch, { recursive: true, mode: 448 });
|
|
55776
55728
|
try {
|
|
55777
55729
|
const tarballPath = (0, import_node_path11.join)(scratch, "package.tgz");
|
|
55778
|
-
await (0,
|
|
55730
|
+
await (0, import_promises16.writeFile)(tarballPath, tarball, { mode: 384 });
|
|
55779
55731
|
const packageDir = await extractPackageTarball(tarballPath, (0, import_node_path11.join)(scratch, "unpacked"));
|
|
55780
55732
|
return await stageVersion(layout, packageDir, release2.version);
|
|
55781
55733
|
} finally {
|
|
55782
|
-
await (0,
|
|
55734
|
+
await (0, import_promises16.rm)(scratch, { recursive: true, force: true });
|
|
55783
55735
|
}
|
|
55784
55736
|
}
|
|
55785
55737
|
var pendingUpgradeSchema = external_exports.object({
|
|
@@ -55804,7 +55756,7 @@ async function recordPendingUpgrade(layout, from, to, now) {
|
|
|
55804
55756
|
await writeJsonFileAtomic(layout.pendingUpgrade, { from, to, startedAt: now, starts: 0 });
|
|
55805
55757
|
}
|
|
55806
55758
|
async function clearPendingUpgrade(layout) {
|
|
55807
|
-
await (0,
|
|
55759
|
+
await (0, import_promises16.rm)(layout.pendingUpgrade, { force: true });
|
|
55808
55760
|
}
|
|
55809
55761
|
async function rollBackUpgrade(layout, pending, now) {
|
|
55810
55762
|
const installed = await currentVersion(layout);
|
|
@@ -55836,7 +55788,7 @@ async function settlePendingUpgrade(layout, runningVersion, now) {
|
|
|
55836
55788
|
}
|
|
55837
55789
|
|
|
55838
55790
|
// src/platform/runtime-host.ts
|
|
55839
|
-
var
|
|
55791
|
+
var import_promises17 = require("fs/promises");
|
|
55840
55792
|
var RUNTIME_HOST_KINDS = ["app", "standalone"];
|
|
55841
55793
|
var APP_HOST_ENVIRONMENT = {
|
|
55842
55794
|
ELECTRON_RUN_AS_NODE: "1"
|
|
@@ -55874,7 +55826,7 @@ function serviceCommand(kind, proc, launcher) {
|
|
|
55874
55826
|
}
|
|
55875
55827
|
async function fileStamp(path4) {
|
|
55876
55828
|
try {
|
|
55877
|
-
const stats = await (0,
|
|
55829
|
+
const stats = await (0, import_promises17.stat)(path4);
|
|
55878
55830
|
return `${stats.dev}:${stats.ino}:${stats.size}:${stats.mtimeMs}`;
|
|
55879
55831
|
} catch {
|
|
55880
55832
|
return null;
|
|
@@ -56068,11 +56020,11 @@ var systemExec = (request2) => new Promise((resolve10) => {
|
|
|
56068
56020
|
});
|
|
56069
56021
|
|
|
56070
56022
|
// src/platform/service/legacy.ts
|
|
56071
|
-
var
|
|
56023
|
+
var import_promises19 = require("fs/promises");
|
|
56072
56024
|
var import_node_path15 = require("path");
|
|
56073
56025
|
|
|
56074
56026
|
// src/platform/service/windows-service.ts
|
|
56075
|
-
var
|
|
56027
|
+
var import_promises18 = require("fs/promises");
|
|
56076
56028
|
var import_node_path14 = require("path");
|
|
56077
56029
|
|
|
56078
56030
|
// src/platform/service/runtime-process.ts
|
|
@@ -56280,7 +56232,7 @@ async function readUserSid(exec) {
|
|
|
56280
56232
|
}
|
|
56281
56233
|
async function readBytes(path4) {
|
|
56282
56234
|
try {
|
|
56283
|
-
return await (0,
|
|
56235
|
+
return await (0, import_promises18.readFile)(path4);
|
|
56284
56236
|
} catch (error61) {
|
|
56285
56237
|
if (errnoCode(error61) === "ENOENT") return null;
|
|
56286
56238
|
throw error61;
|
|
@@ -56288,8 +56240,8 @@ async function readBytes(path4) {
|
|
|
56288
56240
|
}
|
|
56289
56241
|
async function writeIfChanged(path4, contents) {
|
|
56290
56242
|
if ((await readBytes(path4))?.equals(contents) === true) return false;
|
|
56291
|
-
await (0,
|
|
56292
|
-
await (0,
|
|
56243
|
+
await (0, import_promises18.mkdir)((0, import_node_path14.dirname)(path4), { recursive: true });
|
|
56244
|
+
await (0, import_promises18.writeFile)(path4, contents);
|
|
56293
56245
|
return true;
|
|
56294
56246
|
}
|
|
56295
56247
|
async function run(exec, request2) {
|
|
@@ -56371,7 +56323,7 @@ function windowsManager(host, profile) {
|
|
|
56371
56323
|
name: files.runValue,
|
|
56372
56324
|
definitionPath: files.script,
|
|
56373
56325
|
install: async (spec, { restart }) => {
|
|
56374
|
-
await (0,
|
|
56326
|
+
await (0, import_promises18.mkdir)((0, import_node_path14.dirname)(spec.logPath), { recursive: true });
|
|
56375
56327
|
const script = renderWindowsSupervisorScript(spec, files);
|
|
56376
56328
|
const xml2 = renderWindowsTaskXml({ spec, files, userSid: await userSid() });
|
|
56377
56329
|
const scriptChanged = await writeIfChanged(
|
|
@@ -56412,7 +56364,7 @@ function windowsManager(host, profile) {
|
|
|
56412
56364
|
const defined = await readBytes(files.script) !== null;
|
|
56413
56365
|
await Promise.all(
|
|
56414
56366
|
[files.script, files.taskXml, files.supervisorRecord].map(
|
|
56415
|
-
(path4) => (0,
|
|
56367
|
+
(path4) => (0, import_promises18.rm)(path4, { force: true })
|
|
56416
56368
|
)
|
|
56417
56369
|
);
|
|
56418
56370
|
return {
|
|
@@ -56464,7 +56416,7 @@ function legacyServiceNames(profile) {
|
|
|
56464
56416
|
};
|
|
56465
56417
|
}
|
|
56466
56418
|
async function exists2(path4) {
|
|
56467
|
-
return (0,
|
|
56419
|
+
return (0, import_promises19.stat)(path4).then(
|
|
56468
56420
|
() => true,
|
|
56469
56421
|
() => false
|
|
56470
56422
|
);
|
|
@@ -56475,7 +56427,7 @@ async function removeLaunchd(host, label) {
|
|
|
56475
56427
|
const loaded = (await host.exec({ command: "launchctl", args: ["print", target] })).status === 0;
|
|
56476
56428
|
if (loaded) await host.exec({ command: "launchctl", args: ["bootout", target] });
|
|
56477
56429
|
const defined = await exists2(plist);
|
|
56478
|
-
await (0,
|
|
56430
|
+
await (0, import_promises19.rm)(plist, { force: true });
|
|
56479
56431
|
return { found: loaded || defined };
|
|
56480
56432
|
}
|
|
56481
56433
|
async function removeSystemd(exec, configHome, unit) {
|
|
@@ -56484,7 +56436,7 @@ async function removeSystemd(exec, configHome, unit) {
|
|
|
56484
56436
|
const active = (await exec({ command: "systemctl", args: ["--user", "is-active", "--quiet", unit] })).status === 0;
|
|
56485
56437
|
if (!defined && !active) return { found: false };
|
|
56486
56438
|
await exec({ command: "systemctl", args: ["--user", "disable", "--now", unit] });
|
|
56487
|
-
await (0,
|
|
56439
|
+
await (0, import_promises19.rm)(unitPath, { force: true });
|
|
56488
56440
|
await exec({ command: "systemctl", args: ["--user", "daemon-reload"] });
|
|
56489
56441
|
return { found: true };
|
|
56490
56442
|
}
|
|
@@ -56511,15 +56463,15 @@ async function removeLegacyService(host, profile) {
|
|
|
56511
56463
|
}
|
|
56512
56464
|
|
|
56513
56465
|
// src/platform/service/service-manager.ts
|
|
56514
|
-
var
|
|
56466
|
+
var import_promises22 = require("fs/promises");
|
|
56515
56467
|
var import_node_path18 = require("path");
|
|
56516
56468
|
|
|
56517
56469
|
// src/platform/service/service-files.ts
|
|
56518
|
-
var
|
|
56470
|
+
var import_promises20 = require("fs/promises");
|
|
56519
56471
|
var import_node_path16 = require("path");
|
|
56520
56472
|
async function readText(path4) {
|
|
56521
56473
|
try {
|
|
56522
|
-
return await (0,
|
|
56474
|
+
return await (0, import_promises20.readFile)(path4, "utf8");
|
|
56523
56475
|
} catch (error61) {
|
|
56524
56476
|
if (errnoCode(error61) === "ENOENT") return null;
|
|
56525
56477
|
throw error61;
|
|
@@ -56527,15 +56479,15 @@ async function readText(path4) {
|
|
|
56527
56479
|
}
|
|
56528
56480
|
async function writeDefinition(path4, contents, mode = 420) {
|
|
56529
56481
|
if (await readText(path4) === contents) return false;
|
|
56530
|
-
await (0,
|
|
56482
|
+
await (0, import_promises20.mkdir)((0, import_node_path16.dirname)(path4), { recursive: true });
|
|
56531
56483
|
const staged = `${path4}.${process.pid}.tmp`;
|
|
56532
|
-
await (0,
|
|
56533
|
-
await (0,
|
|
56484
|
+
await (0, import_promises20.writeFile)(staged, contents, { mode });
|
|
56485
|
+
await (0, import_promises20.rename)(staged, path4);
|
|
56534
56486
|
return true;
|
|
56535
56487
|
}
|
|
56536
56488
|
async function removeDefinition(path4) {
|
|
56537
56489
|
const existed = await readText(path4) !== null;
|
|
56538
|
-
await (0,
|
|
56490
|
+
await (0, import_promises20.rm)(path4, { force: true });
|
|
56539
56491
|
return existed;
|
|
56540
56492
|
}
|
|
56541
56493
|
async function runChecked(exec, request2) {
|
|
@@ -56663,7 +56615,7 @@ function systemdManager(host, profile) {
|
|
|
56663
56615
|
}
|
|
56664
56616
|
|
|
56665
56617
|
// src/platform/service/xdg-autostart.ts
|
|
56666
|
-
var
|
|
56618
|
+
var import_promises21 = require("fs/promises");
|
|
56667
56619
|
var import_node_path17 = require("path");
|
|
56668
56620
|
var AUTOSTART_PREFIX = "alan-runtime";
|
|
56669
56621
|
var ALREADY_RUNNING_EXIT_STATUS2 = 73;
|
|
@@ -56779,7 +56731,7 @@ function xdgAutostartManager(host, profile) {
|
|
|
56779
56731
|
name: files.name,
|
|
56780
56732
|
definitionPath: files.entry,
|
|
56781
56733
|
install: async (spec, { restart }) => {
|
|
56782
|
-
await (0,
|
|
56734
|
+
await (0, import_promises21.mkdir)((0, import_node_path17.dirname)(spec.logPath), { recursive: true, mode: 448 });
|
|
56783
56735
|
const scriptChanged = await writeDefinition(
|
|
56784
56736
|
files.script,
|
|
56785
56737
|
renderSupervisorScript(spec, files),
|
|
@@ -56806,7 +56758,7 @@ function xdgAutostartManager(host, profile) {
|
|
|
56806
56758
|
removeDefinition(files.entry),
|
|
56807
56759
|
removeDefinition(files.script)
|
|
56808
56760
|
]);
|
|
56809
|
-
await (0,
|
|
56761
|
+
await (0, import_promises21.rm)(files.supervisorRecord, { force: true });
|
|
56810
56762
|
return { manager: "xdg-autostart", name: files.name, removed: entry || script };
|
|
56811
56763
|
},
|
|
56812
56764
|
status: async () => {
|
|
@@ -56850,7 +56802,7 @@ function launchdManager(host, profile) {
|
|
|
56850
56802
|
name: label,
|
|
56851
56803
|
definitionPath: plist,
|
|
56852
56804
|
install: async (spec, { restart }) => {
|
|
56853
|
-
await (0,
|
|
56805
|
+
await (0, import_promises22.mkdir)((0, import_node_path18.dirname)(spec.logPath), { recursive: true, mode: 448 });
|
|
56854
56806
|
const changed = await writeDefinition(plist, renderLaunchdPlist(spec));
|
|
56855
56807
|
const loaded = await isLoaded();
|
|
56856
56808
|
if (loaded && !changed) {
|
|
@@ -56910,7 +56862,7 @@ function linuxManager(host, profile) {
|
|
|
56910
56862
|
if (manager === systemd) {
|
|
56911
56863
|
if (await readText(autostart.definitionPath) !== null) await autostart.uninstall();
|
|
56912
56864
|
} else {
|
|
56913
|
-
await (0,
|
|
56865
|
+
await (0, import_promises22.rm)(staleUnitPath, { force: true });
|
|
56914
56866
|
}
|
|
56915
56867
|
return manager.install(spec, options);
|
|
56916
56868
|
},
|
|
@@ -57384,7 +57336,7 @@ function createGit(options) {
|
|
|
57384
57336
|
// src/capabilities/github-proxy/certificates.ts
|
|
57385
57337
|
var import_node_child_process9 = require("child_process");
|
|
57386
57338
|
var import_node_crypto11 = require("crypto");
|
|
57387
|
-
var
|
|
57339
|
+
var import_promises23 = require("fs/promises");
|
|
57388
57340
|
var import_node_path20 = require("path");
|
|
57389
57341
|
var OPENSSL_TIMEOUT_MS = 1e4;
|
|
57390
57342
|
var VALIDITY_DAYS = "30";
|
|
@@ -57422,13 +57374,13 @@ function openssl(args, cwd) {
|
|
|
57422
57374
|
}
|
|
57423
57375
|
async function createGitHubProxyCertificates(stateDir) {
|
|
57424
57376
|
const work = (0, import_node_path20.join)(stateDir, "github-proxy");
|
|
57425
|
-
await (0,
|
|
57426
|
-
await (0,
|
|
57377
|
+
await (0, import_promises23.rm)(work, { recursive: true, force: true });
|
|
57378
|
+
await (0, import_promises23.mkdir)(work, { recursive: true, mode: 448 });
|
|
57427
57379
|
try {
|
|
57428
|
-
await (0,
|
|
57380
|
+
await (0, import_promises23.writeFile)((0, import_node_path20.join)(work, "ca.cnf"), opensslConfig("Alan sandbox GitHub proxy CA"), {
|
|
57429
57381
|
mode: 384
|
|
57430
57382
|
});
|
|
57431
|
-
await (0,
|
|
57383
|
+
await (0, import_promises23.writeFile)((0, import_node_path20.join)(work, "leaf.cnf"), opensslConfig("github.com"), { mode: 384 });
|
|
57432
57384
|
const curve = ["ecparam", "-name", "prime256v1", "-genkey", "-noout"];
|
|
57433
57385
|
await openssl([...curve, "-out", "ca.key"], work);
|
|
57434
57386
|
await openssl(
|
|
@@ -57452,19 +57404,19 @@ async function createGitHubProxyCertificates(stateDir) {
|
|
|
57452
57404
|
work
|
|
57453
57405
|
);
|
|
57454
57406
|
const caPath = (0, import_node_path20.join)(stateDir, "github-ca.pem");
|
|
57455
|
-
await (0,
|
|
57407
|
+
await (0, import_promises23.writeFile)(caPath, await (0, import_promises23.readFile)((0, import_node_path20.join)(work, "ca.pem")), { mode: 384 });
|
|
57456
57408
|
return {
|
|
57457
57409
|
caPath,
|
|
57458
|
-
leafKeyPem: await (0,
|
|
57459
|
-
leafCertPem: await (0,
|
|
57410
|
+
leafKeyPem: await (0, import_promises23.readFile)((0, import_node_path20.join)(work, "leaf.key"), "utf8"),
|
|
57411
|
+
leafCertPem: await (0, import_promises23.readFile)((0, import_node_path20.join)(work, "leaf.pem"), "utf8")
|
|
57460
57412
|
};
|
|
57461
57413
|
} finally {
|
|
57462
|
-
await (0,
|
|
57414
|
+
await (0, import_promises23.rm)(work, { recursive: true, force: true });
|
|
57463
57415
|
}
|
|
57464
57416
|
}
|
|
57465
57417
|
|
|
57466
57418
|
// src/capabilities/github-proxy/config.ts
|
|
57467
|
-
var
|
|
57419
|
+
var import_promises24 = require("fs/promises");
|
|
57468
57420
|
var import_node_path21 = require("path");
|
|
57469
57421
|
init_runtime_v2();
|
|
57470
57422
|
var GITHUB_URL = "https://github.com/";
|
|
@@ -57481,10 +57433,10 @@ function withGhConfigKey(yaml, key, value2) {
|
|
|
57481
57433
|
`;
|
|
57482
57434
|
}
|
|
57483
57435
|
async function configureGh(ghConfigDir, socketPath) {
|
|
57484
|
-
await (0,
|
|
57436
|
+
await (0, import_promises24.mkdir)(ghConfigDir, { recursive: true, mode: 448 });
|
|
57485
57437
|
const path4 = (0, import_node_path21.join)(ghConfigDir, "config.yml");
|
|
57486
|
-
const current = await (0,
|
|
57487
|
-
await (0,
|
|
57438
|
+
const current = await (0, import_promises24.readFile)(path4, "utf8").catch(() => "");
|
|
57439
|
+
await (0, import_promises24.writeFile)(path4, withGhConfigKey(current, GH_SOCKET_KEY, socketPath), { mode: 384 });
|
|
57488
57440
|
}
|
|
57489
57441
|
async function configureGit(input2, git) {
|
|
57490
57442
|
const run2 = async (args, allowedExitCodes = [0]) => {
|
|
@@ -57514,7 +57466,7 @@ async function configureGitHubProxyClients(input2) {
|
|
|
57514
57466
|
}
|
|
57515
57467
|
|
|
57516
57468
|
// src/capabilities/github-proxy/server.ts
|
|
57517
|
-
var
|
|
57469
|
+
var import_promises25 = require("fs/promises");
|
|
57518
57470
|
var import_node_http3 = require("http");
|
|
57519
57471
|
var import_node_tls = require("tls");
|
|
57520
57472
|
init_runtime_v2();
|
|
@@ -57656,7 +57608,7 @@ async function startGitHubProxy(options) {
|
|
|
57656
57608
|
});
|
|
57657
57609
|
removeStaleEndpoint(options.socketPath);
|
|
57658
57610
|
await listen(gh, options.socketPath);
|
|
57659
|
-
await (0,
|
|
57611
|
+
await (0, import_promises25.chmod)(options.socketPath, 384);
|
|
57660
57612
|
const git = options.certificates === null ? null : await startGitListener(options.certificates, relay);
|
|
57661
57613
|
options.log.info("github_proxy.listening", {
|
|
57662
57614
|
socketPath: options.socketPath,
|
|
@@ -57675,7 +57627,7 @@ async function startGitHubProxy(options) {
|
|
|
57675
57627
|
|
|
57676
57628
|
// src/capabilities/mcp-config/mcp-config.ts
|
|
57677
57629
|
var import_node_crypto12 = require("crypto");
|
|
57678
|
-
var
|
|
57630
|
+
var import_promises26 = require("fs/promises");
|
|
57679
57631
|
var import_node_path22 = require("path");
|
|
57680
57632
|
|
|
57681
57633
|
// ../../node_modules/smol-toml/dist/error.js
|
|
@@ -58517,6 +58469,7 @@ var MCP_CLIS = [
|
|
|
58517
58469
|
guardDir: "",
|
|
58518
58470
|
configPath: ".claude.json",
|
|
58519
58471
|
section: "mcpServers",
|
|
58472
|
+
writesEntry: true,
|
|
58520
58473
|
entry: (url3) => ({ type: "http", url: url3, headers: {} })
|
|
58521
58474
|
},
|
|
58522
58475
|
{
|
|
@@ -58525,6 +58478,9 @@ var MCP_CLIS = [
|
|
|
58525
58478
|
guardDir: ".codex",
|
|
58526
58479
|
configPath: ".codex/config.toml",
|
|
58527
58480
|
section: "mcp_servers",
|
|
58481
|
+
// ChatGPT.app's bundled Codex reads this file too and never completes MCP OAuth, so a
|
|
58482
|
+
// credential-free entry only loops 401s; Alan runs pass their own per-thread config.
|
|
58483
|
+
writesEntry: false,
|
|
58528
58484
|
entry: (url3) => ({ url: url3 })
|
|
58529
58485
|
},
|
|
58530
58486
|
{
|
|
@@ -58533,6 +58489,7 @@ var MCP_CLIS = [
|
|
|
58533
58489
|
guardDir: ".cursor",
|
|
58534
58490
|
configPath: ".cursor/mcp.json",
|
|
58535
58491
|
section: "mcpServers",
|
|
58492
|
+
writesEntry: true,
|
|
58536
58493
|
entry: (url3) => ({ type: "http", url: url3, headers: {} })
|
|
58537
58494
|
},
|
|
58538
58495
|
{
|
|
@@ -58541,6 +58498,7 @@ var MCP_CLIS = [
|
|
|
58541
58498
|
guardDir: ".kimi",
|
|
58542
58499
|
configPath: ".kimi/mcp.json",
|
|
58543
58500
|
section: "mcpServers",
|
|
58501
|
+
writesEntry: true,
|
|
58544
58502
|
entry: (url3) => ({ url: url3, headers: {} })
|
|
58545
58503
|
},
|
|
58546
58504
|
{
|
|
@@ -58549,6 +58507,7 @@ var MCP_CLIS = [
|
|
|
58549
58507
|
guardDir: ".commandcode",
|
|
58550
58508
|
configPath: ".commandcode/mcp.json",
|
|
58551
58509
|
section: "mcpServers",
|
|
58510
|
+
writesEntry: true,
|
|
58552
58511
|
entry: (url3) => ({ transport: "http", enabled: true, url: url3 })
|
|
58553
58512
|
},
|
|
58554
58513
|
{
|
|
@@ -58557,6 +58516,7 @@ var MCP_CLIS = [
|
|
|
58557
58516
|
guardDir: ".config/opencode",
|
|
58558
58517
|
configPath: ".config/opencode/opencode.json",
|
|
58559
58518
|
section: "mcp",
|
|
58519
|
+
writesEntry: true,
|
|
58560
58520
|
entry: (url3) => ({ type: "remote", url: url3, headers: {} })
|
|
58561
58521
|
},
|
|
58562
58522
|
{
|
|
@@ -58565,6 +58525,7 @@ var MCP_CLIS = [
|
|
|
58565
58525
|
guardDir: ".factory",
|
|
58566
58526
|
configPath: ".factory/mcp.json",
|
|
58567
58527
|
section: "mcpServers",
|
|
58528
|
+
writesEntry: true,
|
|
58568
58529
|
entry: (url3) => ({ type: "http", url: url3, disabled: false })
|
|
58569
58530
|
},
|
|
58570
58531
|
{
|
|
@@ -58573,6 +58534,7 @@ var MCP_CLIS = [
|
|
|
58573
58534
|
guardDir: ".copilot",
|
|
58574
58535
|
configPath: ".copilot/mcp-config.json",
|
|
58575
58536
|
section: "mcpServers",
|
|
58537
|
+
writesEntry: true,
|
|
58576
58538
|
entry: (url3) => ({ type: "http", url: url3, tools: ["*"], headers: {} })
|
|
58577
58539
|
},
|
|
58578
58540
|
{
|
|
@@ -58581,6 +58543,7 @@ var MCP_CLIS = [
|
|
|
58581
58543
|
guardDir: ".grok",
|
|
58582
58544
|
configPath: ".grok/config.toml",
|
|
58583
58545
|
section: "mcp_servers",
|
|
58546
|
+
writesEntry: true,
|
|
58584
58547
|
entry: (url3) => ({ url: url3 })
|
|
58585
58548
|
}
|
|
58586
58549
|
];
|
|
@@ -58609,9 +58572,12 @@ function isAlanEntry(entry, endpoint) {
|
|
|
58609
58572
|
if (url3.pathname.replace(/\/+$/, "") !== "/mcp") return false;
|
|
58610
58573
|
return url3.origin === endpoint.origin || url3.hostname.endsWith(ALAN_HOST_SUFFIX);
|
|
58611
58574
|
}
|
|
58575
|
+
function isCredentialFreeAlanEntry(entry, endpoint) {
|
|
58576
|
+
return isAlanEntry(entry, endpoint) && isRecord2(entry) && Object.keys(entry).every((key) => URL_KEYS.includes(key));
|
|
58577
|
+
}
|
|
58612
58578
|
async function isInstalled(cli, home) {
|
|
58613
58579
|
try {
|
|
58614
|
-
return (await (0,
|
|
58580
|
+
return (await (0, import_promises26.stat)((0, import_node_path22.join)(home, cli.guardDir))).isDirectory();
|
|
58615
58581
|
} catch (error61) {
|
|
58616
58582
|
if (errorCode2(error61) === "ENOENT") return false;
|
|
58617
58583
|
throw error61;
|
|
@@ -58619,7 +58585,7 @@ async function isInstalled(cli, home) {
|
|
|
58619
58585
|
}
|
|
58620
58586
|
async function readText2(path4) {
|
|
58621
58587
|
try {
|
|
58622
|
-
return await (0,
|
|
58588
|
+
return await (0, import_promises26.readFile)(path4, "utf8");
|
|
58623
58589
|
} catch (error61) {
|
|
58624
58590
|
if (errorCode2(error61) === "ENOENT") return null;
|
|
58625
58591
|
throw error61;
|
|
@@ -58646,10 +58612,10 @@ async function readConfig(cli, home) {
|
|
|
58646
58612
|
async function writeConfig(path4, text2) {
|
|
58647
58613
|
const temporary = `${path4}.alan-${(0, import_node_crypto12.randomUUID)()}.tmp`;
|
|
58648
58614
|
try {
|
|
58649
|
-
await (0,
|
|
58650
|
-
await (0,
|
|
58615
|
+
await (0, import_promises26.writeFile)(temporary, text2, { encoding: "utf8", mode: 384, flag: "wx" });
|
|
58616
|
+
await (0, import_promises26.rename)(temporary, path4);
|
|
58651
58617
|
} finally {
|
|
58652
|
-
await (0,
|
|
58618
|
+
await (0, import_promises26.rm)(temporary, { force: true });
|
|
58653
58619
|
}
|
|
58654
58620
|
}
|
|
58655
58621
|
async function editCli(cli, home, endpoint, edit) {
|
|
@@ -58677,6 +58643,13 @@ async function editInstalledClis(home, apiUrl, edit) {
|
|
|
58677
58643
|
}
|
|
58678
58644
|
function syncAlanMcp(options) {
|
|
58679
58645
|
return editInstalledClis(options.home, options.apiUrl, (servers, endpoint, cli) => {
|
|
58646
|
+
if (!cli.writesEntry) {
|
|
58647
|
+
const stale = [ALAN_MCP_SERVER_NAME, ...options.legacyServerNames].filter(
|
|
58648
|
+
(name) => isCredentialFreeAlanEntry(servers.get(name), endpoint)
|
|
58649
|
+
);
|
|
58650
|
+
for (const name of stale) servers.delete(name);
|
|
58651
|
+
return stale.length > 0;
|
|
58652
|
+
}
|
|
58680
58653
|
const current = servers.get(ALAN_MCP_SERVER_NAME);
|
|
58681
58654
|
if (current !== void 0 && !isAlanEntry(current, endpoint)) {
|
|
58682
58655
|
throw new Error(`an entry that is not Alan's already uses the name ${ALAN_MCP_SERVER_NAME}`);
|
|
@@ -58720,7 +58693,7 @@ async function inspectAlanMcp(options) {
|
|
|
58720
58693
|
}
|
|
58721
58694
|
|
|
58722
58695
|
// src/capabilities/models/opencode-models.ts
|
|
58723
|
-
var
|
|
58696
|
+
var import_promises27 = require("fs/promises");
|
|
58724
58697
|
var import_node_path23 = require("path");
|
|
58725
58698
|
init_runtime_v2();
|
|
58726
58699
|
init_zod();
|
|
@@ -59036,7 +59009,7 @@ async function readOpenCodeCatalogueCache(env) {
|
|
|
59036
59009
|
const home = env.HOME?.trim();
|
|
59037
59010
|
const cacheHome = env.XDG_CACHE_HOME?.trim() || (home ? (0, import_node_path23.join)(home, ".cache") : "");
|
|
59038
59011
|
if (cacheHome === "") return null;
|
|
59039
|
-
const text2 = await (0,
|
|
59012
|
+
const text2 = await (0, import_promises27.readFile)((0, import_node_path23.join)(cacheHome, ...CATALOGUE_CACHE_SEGMENTS), "utf8").catch(
|
|
59040
59013
|
() => void 0
|
|
59041
59014
|
);
|
|
59042
59015
|
if (text2 === void 0) return null;
|
|
@@ -59155,7 +59128,7 @@ async function discoverModels(backendKind, executable, env, capture) {
|
|
|
59155
59128
|
}
|
|
59156
59129
|
|
|
59157
59130
|
// src/capabilities/models/opencode-entitlement.ts
|
|
59158
|
-
var
|
|
59131
|
+
var import_promises28 = require("fs/promises");
|
|
59159
59132
|
var import_node_os2 = require("os");
|
|
59160
59133
|
var import_node_path24 = require("path");
|
|
59161
59134
|
init_agent2();
|
|
@@ -59165,7 +59138,7 @@ async function readOpenCodeZenCredential(env) {
|
|
|
59165
59138
|
const injected = env.OPENCODE_AUTH_CONTENT?.trim();
|
|
59166
59139
|
if (injected) return readZenCredentialFromAuthDocument(injected);
|
|
59167
59140
|
const dataHome = env.XDG_DATA_HOME?.trim() || (0, import_node_path24.join)(env.HOME?.trim() || (0, import_node_os2.homedir)(), ".local", "share");
|
|
59168
|
-
const document2 = await (0,
|
|
59141
|
+
const document2 = await (0, import_promises28.readFile)((0, import_node_path24.join)(dataHome, "opencode", "auth.json"), "utf8").catch(
|
|
59169
59142
|
() => void 0
|
|
59170
59143
|
);
|
|
59171
59144
|
return readZenCredentialFromAuthDocument(document2);
|
|
@@ -59608,7 +59581,7 @@ function nextAlanBoundary(entry, inFlightFrom) {
|
|
|
59608
59581
|
}
|
|
59609
59582
|
|
|
59610
59583
|
// src/capabilities/native-ingest/pass.ts
|
|
59611
|
-
var
|
|
59584
|
+
var import_promises32 = require("fs/promises");
|
|
59612
59585
|
|
|
59613
59586
|
// src/capabilities/native-ingest/ports.ts
|
|
59614
59587
|
var NativeRequestFailure = class extends Error {
|
|
@@ -59746,7 +59719,7 @@ function reconcileTranscriptIdentity(entry, transcriptPath, identity, size) {
|
|
|
59746
59719
|
|
|
59747
59720
|
// src/capabilities/native-ingest/transcript-window.ts
|
|
59748
59721
|
var import_node_crypto13 = require("crypto");
|
|
59749
|
-
var
|
|
59722
|
+
var import_promises31 = require("fs/promises");
|
|
59750
59723
|
init_acp2();
|
|
59751
59724
|
init_claude();
|
|
59752
59725
|
init_codex();
|
|
@@ -59801,7 +59774,7 @@ async function findRecordEnd(handle, from, size) {
|
|
|
59801
59774
|
return null;
|
|
59802
59775
|
}
|
|
59803
59776
|
async function readTranscriptWindow(path4, offset, limits) {
|
|
59804
|
-
const handle = await (0,
|
|
59777
|
+
const handle = await (0, import_promises31.open)(path4, "r");
|
|
59805
59778
|
try {
|
|
59806
59779
|
const stats = await handle.stat({ bigint: true });
|
|
59807
59780
|
const size = Number(stats.size);
|
|
@@ -60254,7 +60227,7 @@ async function runPass(ctx, worker) {
|
|
|
60254
60227
|
});
|
|
60255
60228
|
if (signal.ending) ctx.log.info("native_ingest.closed", workerFields(worker));
|
|
60256
60229
|
}
|
|
60257
|
-
const current = await (0,
|
|
60230
|
+
const current = await (0, import_promises32.stat)(worker.latest.transcriptPath).catch(() => void 0);
|
|
60258
60231
|
return { grewDuringPass: current !== void 0 && current.size > state.lastSize };
|
|
60259
60232
|
}
|
|
60260
60233
|
|
|
@@ -60611,7 +60584,7 @@ init_alan_code();
|
|
|
60611
60584
|
|
|
60612
60585
|
// src/capabilities/providers/commands.ts
|
|
60613
60586
|
var import_node_fs10 = require("fs");
|
|
60614
|
-
var
|
|
60587
|
+
var import_promises34 = require("fs/promises");
|
|
60615
60588
|
var import_node_path30 = require("path");
|
|
60616
60589
|
var PROVIDER_COMMANDS = [
|
|
60617
60590
|
// The engine, not a CLI of its own: `resolveProviderExecutable` finds the bundled one first.
|
|
@@ -60645,8 +60618,8 @@ function pathDelimiter(platform3) {
|
|
|
60645
60618
|
}
|
|
60646
60619
|
async function isRunnable(path4, platform3) {
|
|
60647
60620
|
try {
|
|
60648
|
-
if (!(await (0,
|
|
60649
|
-
if (platform3 !== "win32") await (0,
|
|
60621
|
+
if (!(await (0, import_promises34.stat)(path4)).isFile()) return false;
|
|
60622
|
+
if (platform3 !== "win32") await (0, import_promises34.access)(path4, import_node_fs10.constants.X_OK);
|
|
60650
60623
|
return true;
|
|
60651
60624
|
} catch {
|
|
60652
60625
|
return false;
|
|
@@ -61189,13 +61162,13 @@ async function openCliEnvironment(options) {
|
|
|
61189
61162
|
}
|
|
61190
61163
|
|
|
61191
61164
|
// src/capabilities/skills/local-preview.ts
|
|
61192
|
-
var
|
|
61165
|
+
var import_promises39 = require("fs/promises");
|
|
61193
61166
|
var import_node_path39 = __toESM(require("path"));
|
|
61194
61167
|
|
|
61195
61168
|
// ../shared/dist/node/skill-package.js
|
|
61196
61169
|
var import_node_buffer = require("buffer");
|
|
61197
61170
|
var import_node_crypto15 = require("crypto");
|
|
61198
|
-
var
|
|
61171
|
+
var import_promises35 = require("fs/promises");
|
|
61199
61172
|
var import_node_path35 = require("path");
|
|
61200
61173
|
var import_yaml = __toESM(require_dist(), 1);
|
|
61201
61174
|
init_contracts();
|
|
@@ -61291,11 +61264,11 @@ async function readSkillPackageFile(packageRoot, path4, expectedSha256) {
|
|
|
61291
61264
|
if (!normalizedPath || normalizedPath !== path4 || normalizedPath.includes("\\") || components.some((component) => !component || component === "." || component === "..")) {
|
|
61292
61265
|
throw new SkillPackageError("INVALID_PATH", `Invalid Skill package path: ${path4}`, path4);
|
|
61293
61266
|
}
|
|
61294
|
-
const absolutePath = await (0,
|
|
61267
|
+
const absolutePath = await (0, import_promises35.realpath)((0, import_node_path35.resolve)(root, ...components)).catch(() => null);
|
|
61295
61268
|
if (!absolutePath || normalizeRelativePath(root, absolutePath) !== normalizedPath) {
|
|
61296
61269
|
throw new SkillPackageError("INVALID_PATH", `Skill package file was not found: ${path4}`, path4);
|
|
61297
61270
|
}
|
|
61298
|
-
const entryStat = await (0,
|
|
61271
|
+
const entryStat = await (0, import_promises35.lstat)(absolutePath);
|
|
61299
61272
|
if (!entryStat.isFile()) {
|
|
61300
61273
|
throw new SkillPackageError("SPECIAL_FILE_BLOCKED", `Only regular files are allowed in Skill packages: ${path4}`, path4);
|
|
61301
61274
|
}
|
|
@@ -61312,11 +61285,11 @@ async function readSkillPackageFile(packageRoot, path4, expectedSha256) {
|
|
|
61312
61285
|
return { file: read.manifest, bytes: read.bytes };
|
|
61313
61286
|
}
|
|
61314
61287
|
async function requirePackageRoot(packageRoot) {
|
|
61315
|
-
const root = await (0,
|
|
61288
|
+
const root = await (0, import_promises35.realpath)((0, import_node_path35.resolve)(packageRoot)).catch(() => null);
|
|
61316
61289
|
if (!root) {
|
|
61317
61290
|
throw new SkillPackageError("INVALID_PACKAGE_ROOT", "Skill package directory does not exist");
|
|
61318
61291
|
}
|
|
61319
|
-
const rootStat = await (0,
|
|
61292
|
+
const rootStat = await (0, import_promises35.lstat)(root);
|
|
61320
61293
|
if (!rootStat.isDirectory()) {
|
|
61321
61294
|
throw new SkillPackageError("INVALID_PACKAGE_ROOT", "Skill package root must be a directory");
|
|
61322
61295
|
}
|
|
@@ -61336,13 +61309,13 @@ async function walkPackage(root, ignoredPaths) {
|
|
|
61336
61309
|
}
|
|
61337
61310
|
return files;
|
|
61338
61311
|
async function walkDirectory(directory) {
|
|
61339
|
-
const entries = await (0,
|
|
61312
|
+
const entries = await (0, import_promises35.readdir)(directory, { withFileTypes: true });
|
|
61340
61313
|
for (const entry of entries) {
|
|
61341
61314
|
const absolutePath = (0, import_node_path35.resolve)(directory, entry.name);
|
|
61342
61315
|
const normalizedPath = normalizeRelativePath(root, absolutePath);
|
|
61343
61316
|
if (isIgnored(normalizedPath, entry.name, entry.isDirectory(), ignored2))
|
|
61344
61317
|
continue;
|
|
61345
|
-
const entryStat = await (0,
|
|
61318
|
+
const entryStat = await (0, import_promises35.lstat)(absolutePath);
|
|
61346
61319
|
if (entryStat.isSymbolicLink()) {
|
|
61347
61320
|
throw new SkillPackageError("SYMLINK_BLOCKED", `Nested symbolic links are not allowed in Skill packages: ${normalizedPath}`, normalizedPath);
|
|
61348
61321
|
}
|
|
@@ -61451,7 +61424,7 @@ function isSecretPath(path4) {
|
|
|
61451
61424
|
return name.endsWith(".private-key.pem") || name.endsWith(".private-key.key");
|
|
61452
61425
|
}
|
|
61453
61426
|
async function readPackageFile(file2) {
|
|
61454
|
-
const bytes = await (0,
|
|
61427
|
+
const bytes = await (0, import_promises35.readFile)(file2.absolutePath);
|
|
61455
61428
|
return {
|
|
61456
61429
|
bytes,
|
|
61457
61430
|
manifest: {
|
|
@@ -61622,13 +61595,13 @@ function uint642(value2) {
|
|
|
61622
61595
|
|
|
61623
61596
|
// src/capabilities/skills/local-sources.ts
|
|
61624
61597
|
var import_node_crypto17 = require("crypto");
|
|
61625
|
-
var
|
|
61598
|
+
var import_promises37 = require("fs/promises");
|
|
61626
61599
|
var import_node_path37 = __toESM(require("path"));
|
|
61627
61600
|
init_type_guards();
|
|
61628
61601
|
|
|
61629
61602
|
// src/capabilities/skills/local-scan.ts
|
|
61630
61603
|
var import_node_crypto16 = require("crypto");
|
|
61631
|
-
var
|
|
61604
|
+
var import_promises36 = require("fs/promises");
|
|
61632
61605
|
var import_node_path36 = __toESM(require("path"));
|
|
61633
61606
|
var MAX_CANDIDATES = 2e3;
|
|
61634
61607
|
var MAX_DIAGNOSTICS = 100;
|
|
@@ -61748,7 +61721,7 @@ function invalid(resolvedRoot, name, error61) {
|
|
|
61748
61721
|
}
|
|
61749
61722
|
async function scanRootAsPackage(pass, resolvedRoot) {
|
|
61750
61723
|
if (!await exists3(import_node_path36.default.join(resolvedRoot.directory, "SKILL.md"))) return null;
|
|
61751
|
-
const canonical = await (0,
|
|
61724
|
+
const canonical = await (0, import_promises36.realpath)(resolvedRoot.directory).catch(() => resolvedRoot.directory);
|
|
61752
61725
|
try {
|
|
61753
61726
|
const inspected = await inspectCached(pass, canonical, null);
|
|
61754
61727
|
return {
|
|
@@ -61777,7 +61750,7 @@ async function scanRoot(pass, resolvedRoot) {
|
|
|
61777
61750
|
if (asPackage !== null) return asPackage;
|
|
61778
61751
|
let entries;
|
|
61779
61752
|
try {
|
|
61780
|
-
entries = await (0,
|
|
61753
|
+
entries = await (0, import_promises36.readdir)(resolvedRoot.directory, { withFileTypes: true });
|
|
61781
61754
|
} catch (error61) {
|
|
61782
61755
|
const code = errnoCode(error61);
|
|
61783
61756
|
if (code === "ENOENT" || code === "ENOTDIR") {
|
|
@@ -61795,7 +61768,7 @@ async function scanRoot(pass, resolvedRoot) {
|
|
|
61795
61768
|
incomplete: true
|
|
61796
61769
|
};
|
|
61797
61770
|
}
|
|
61798
|
-
const canonicalRoot = await (0,
|
|
61771
|
+
const canonicalRoot = await (0, import_promises36.realpath)(resolvedRoot.directory).catch(() => resolvedRoot.directory);
|
|
61799
61772
|
const scan = { candidates: [], diagnostics: [], incomplete: false };
|
|
61800
61773
|
for (const entry of entries) {
|
|
61801
61774
|
if (!entry.isDirectory() && !entry.isSymbolicLink()) continue;
|
|
@@ -61807,7 +61780,7 @@ async function scanRoot(pass, resolvedRoot) {
|
|
|
61807
61780
|
}
|
|
61808
61781
|
async function scanEntry(pass, resolvedRoot, canonicalRoot, name) {
|
|
61809
61782
|
const rootLabel = resolvedRoot.root.label;
|
|
61810
|
-
const canonical = await (0,
|
|
61783
|
+
const canonical = await (0, import_promises36.realpath)(import_node_path36.default.join(resolvedRoot.directory, name)).catch(() => null);
|
|
61811
61784
|
if (canonical === null) {
|
|
61812
61785
|
const message2 = `Could not resolve Skill ${name}`;
|
|
61813
61786
|
return { kind: "diagnostic", diagnostic: { code: "SOURCE_UNREADABLE", message: message2, rootLabel } };
|
|
@@ -61891,12 +61864,12 @@ function deduplicateByContent(candidates2) {
|
|
|
61891
61864
|
async function fingerprintPackage(root) {
|
|
61892
61865
|
const hash2 = (0, import_node_crypto16.createHash)("sha256").update("alan-skill-stat-fingerprint-v1\0");
|
|
61893
61866
|
const visit2 = async (directory, relativeDirectory) => {
|
|
61894
|
-
const entries = await (0,
|
|
61867
|
+
const entries = await (0, import_promises36.readdir)(directory, { withFileTypes: true });
|
|
61895
61868
|
entries.sort((left, right) => Buffer.compare(Buffer.from(left.name), Buffer.from(right.name)));
|
|
61896
61869
|
for (const entry of entries) {
|
|
61897
61870
|
const relative5 = relativeDirectory ? `${relativeDirectory}/${entry.name}` : entry.name;
|
|
61898
61871
|
const absolute = import_node_path36.default.join(directory, entry.name);
|
|
61899
|
-
const metadata = await (0,
|
|
61872
|
+
const metadata = await (0, import_promises36.lstat)(absolute);
|
|
61900
61873
|
const kind = entryKind(entry);
|
|
61901
61874
|
hash2.update(relative5.normalize("NFC")).update(`\0${kind}\0${metadata.size}\0${metadata.mtimeMs}\0${metadata.mode & 511}\0`);
|
|
61902
61875
|
if (entry.isDirectory()) await visit2(absolute, relative5);
|
|
@@ -61912,7 +61885,7 @@ function entryKind(entry) {
|
|
|
61912
61885
|
}
|
|
61913
61886
|
async function canonicalDirectories(directories) {
|
|
61914
61887
|
const canonical = await Promise.all(
|
|
61915
|
-
directories.map((directory) => (0,
|
|
61888
|
+
directories.map((directory) => (0, import_promises36.realpath)(directory).catch(() => directory))
|
|
61916
61889
|
);
|
|
61917
61890
|
return [...new Set(canonical)];
|
|
61918
61891
|
}
|
|
@@ -61922,7 +61895,7 @@ function isWithinDirectory2(parent, candidate) {
|
|
|
61922
61895
|
}
|
|
61923
61896
|
async function exists3(candidate) {
|
|
61924
61897
|
try {
|
|
61925
|
-
await (0,
|
|
61898
|
+
await (0, import_promises36.access)(candidate);
|
|
61926
61899
|
return true;
|
|
61927
61900
|
} catch {
|
|
61928
61901
|
return false;
|
|
@@ -61930,7 +61903,7 @@ async function exists3(candidate) {
|
|
|
61930
61903
|
}
|
|
61931
61904
|
async function isDirectory3(candidate) {
|
|
61932
61905
|
try {
|
|
61933
|
-
return (await (0,
|
|
61906
|
+
return (await (0, import_promises36.lstat)(candidate)).isDirectory();
|
|
61934
61907
|
} catch {
|
|
61935
61908
|
return false;
|
|
61936
61909
|
}
|
|
@@ -62018,7 +61991,7 @@ async function resolveLocalScanInput(home, context, mode) {
|
|
|
62018
61991
|
async function readSkillSourceConfig(home) {
|
|
62019
61992
|
let content;
|
|
62020
61993
|
try {
|
|
62021
|
-
content = await (0,
|
|
61994
|
+
content = await (0, import_promises37.readFile)(skillSourceConfigPath(home), "utf8");
|
|
62022
61995
|
} catch (error61) {
|
|
62023
61996
|
if (errnoCode(error61) !== "ENOENT") {
|
|
62024
61997
|
return { kind: "invalid_config", diagnostic: "~/.alan/config.toml could not be read" };
|
|
@@ -62135,7 +62108,7 @@ async function scanLocalSkills(home, context, cache2, mode = "incremental") {
|
|
|
62135
62108
|
}
|
|
62136
62109
|
|
|
62137
62110
|
// src/capabilities/skills/store.ts
|
|
62138
|
-
var
|
|
62111
|
+
var import_promises38 = require("fs/promises");
|
|
62139
62112
|
var import_node_path38 = require("path");
|
|
62140
62113
|
init_runtime_v2();
|
|
62141
62114
|
init_zod();
|
|
@@ -62183,7 +62156,7 @@ function writeLocalSkills(layout, file2) {
|
|
|
62183
62156
|
async function isLocalSkillCurrent(entry, contentHash, ignoredPaths) {
|
|
62184
62157
|
if (entry.contentHash !== contentHash) return false;
|
|
62185
62158
|
try {
|
|
62186
|
-
if (await (0,
|
|
62159
|
+
if (await (0, import_promises38.realpath)(entry.path) !== entry.path) return false;
|
|
62187
62160
|
const inspected = await inspectSkillPackage(entry.path, { expectedName: null, ignoredPaths });
|
|
62188
62161
|
return inspected.contentHash === contentHash;
|
|
62189
62162
|
} catch {
|
|
@@ -62198,7 +62171,7 @@ async function resolveLocalSkill(local, invocation) {
|
|
|
62198
62171
|
}
|
|
62199
62172
|
async function hasSkillFile(directory) {
|
|
62200
62173
|
try {
|
|
62201
|
-
return (await (0,
|
|
62174
|
+
return (await (0, import_promises38.stat)((0, import_node_path38.join)(directory, "SKILL.md"))).isFile();
|
|
62202
62175
|
} catch {
|
|
62203
62176
|
return false;
|
|
62204
62177
|
}
|
|
@@ -62299,7 +62272,7 @@ async function readLocalSkillFile(layout, ref) {
|
|
|
62299
62272
|
}
|
|
62300
62273
|
async function isDirectory4(candidate) {
|
|
62301
62274
|
try {
|
|
62302
|
-
return (await (0,
|
|
62275
|
+
return (await (0, import_promises39.stat)(candidate)).isDirectory();
|
|
62303
62276
|
} catch {
|
|
62304
62277
|
return false;
|
|
62305
62278
|
}
|
|
@@ -62312,21 +62285,21 @@ async function addSkillSource(home, input2) {
|
|
|
62312
62285
|
return { state: "invalid", diagnostic: `${sourcePath} is not a folder` };
|
|
62313
62286
|
}
|
|
62314
62287
|
const configPath = skillSourceConfigPath(home);
|
|
62315
|
-
await (0,
|
|
62316
|
-
await (0,
|
|
62288
|
+
await (0, import_promises39.mkdir)(import_node_path39.default.dirname(configPath), { recursive: true, mode: 448 });
|
|
62289
|
+
await (0, import_promises39.writeFile)(configPath, DEFAULT_SKILL_CONFIG, { flag: "wx", mode: 384 }).catch(
|
|
62317
62290
|
(error61) => {
|
|
62318
62291
|
if (errnoCode(error61) !== "EEXIST") throw error61;
|
|
62319
62292
|
}
|
|
62320
62293
|
);
|
|
62321
62294
|
const loaded = await readSkillSourceConfig(home);
|
|
62322
62295
|
if (loaded.kind === "invalid_config") return { state: "invalid", diagnostic: loaded.diagnostic };
|
|
62323
|
-
const canonical = await (0,
|
|
62296
|
+
const canonical = await (0, import_promises39.realpath)(sourcePath).catch(() => sourcePath);
|
|
62324
62297
|
for (const source of loaded.config.sources) {
|
|
62325
|
-
if (await (0,
|
|
62298
|
+
if (await (0, import_promises39.realpath)(source.path).catch(() => source.path) === canonical) {
|
|
62326
62299
|
return { state: "already_present", label: source.label };
|
|
62327
62300
|
}
|
|
62328
62301
|
}
|
|
62329
|
-
const current = await (0,
|
|
62302
|
+
const current = await (0, import_promises39.readFile)(configPath, "utf8");
|
|
62330
62303
|
const block = [
|
|
62331
62304
|
"",
|
|
62332
62305
|
"[[skills.sources]]",
|
|
@@ -62334,7 +62307,7 @@ async function addSkillSource(home, input2) {
|
|
|
62334
62307
|
`label = ${JSON.stringify(label)}`,
|
|
62335
62308
|
""
|
|
62336
62309
|
].join("\n");
|
|
62337
|
-
await (0,
|
|
62310
|
+
await (0, import_promises39.writeFile)(configPath, `${current.replace(/\n*$/, "\n")}${block}`, { mode: 384 });
|
|
62338
62311
|
const reloaded = await readSkillSourceConfig(home);
|
|
62339
62312
|
if (reloaded.kind === "invalid_config") {
|
|
62340
62313
|
return { state: "invalid", diagnostic: reloaded.diagnostic };
|
|
@@ -62343,12 +62316,12 @@ async function addSkillSource(home, input2) {
|
|
|
62343
62316
|
}
|
|
62344
62317
|
|
|
62345
62318
|
// src/capabilities/skills/local-upload.ts
|
|
62346
|
-
var
|
|
62319
|
+
var import_promises41 = require("fs/promises");
|
|
62347
62320
|
|
|
62348
62321
|
// ../shared/dist/node/skill-bundle.js
|
|
62349
62322
|
var import_node_buffer2 = require("buffer");
|
|
62350
62323
|
var import_node_crypto18 = require("crypto");
|
|
62351
|
-
var
|
|
62324
|
+
var import_promises40 = require("fs/promises");
|
|
62352
62325
|
var import_node_path40 = require("path");
|
|
62353
62326
|
var import_node_stream = require("stream");
|
|
62354
62327
|
var import_node_zlib = require("zlib");
|
|
@@ -62359,7 +62332,7 @@ async function createSkillBundle(packageRoot, options = {}) {
|
|
|
62359
62332
|
const archive = (0, import_tar_stream.pack)();
|
|
62360
62333
|
const tarPromise = collectStream(archive);
|
|
62361
62334
|
for (const file2 of before.files) {
|
|
62362
|
-
const bytes2 = await (0,
|
|
62335
|
+
const bytes2 = await (0, import_promises40.readFile)((0, import_node_path40.join)(packageRoot, ...file2.path.split("/")));
|
|
62363
62336
|
await addArchiveEntry(archive, {
|
|
62364
62337
|
name: file2.path,
|
|
62365
62338
|
type: "file",
|
|
@@ -62391,7 +62364,7 @@ async function extractSkillBundle(archiveBytes, destination, expected) {
|
|
|
62391
62364
|
throw new Error("Skill archive hash does not match the expected immutable Version");
|
|
62392
62365
|
}
|
|
62393
62366
|
const tarBytes = await decompressBounded(archiveBytes);
|
|
62394
|
-
await (0,
|
|
62367
|
+
await (0, import_promises40.mkdir)(destination, { recursive: false, mode: 448 });
|
|
62395
62368
|
try {
|
|
62396
62369
|
await extractTar(tarBytes, destination);
|
|
62397
62370
|
const inspected = await inspectSkillPackage(destination, { expectedName: null });
|
|
@@ -62399,7 +62372,7 @@ async function extractSkillBundle(archiveBytes, destination, expected) {
|
|
|
62399
62372
|
throw new Error("Extracted Skill package hash does not match the expected immutable Version");
|
|
62400
62373
|
}
|
|
62401
62374
|
} catch (error61) {
|
|
62402
|
-
await (0,
|
|
62375
|
+
await (0, import_promises40.rm)(destination, { recursive: true, force: true });
|
|
62403
62376
|
throw error61;
|
|
62404
62377
|
}
|
|
62405
62378
|
}
|
|
@@ -62475,8 +62448,8 @@ async function extractEntry(header, stream, destination, limits) {
|
|
|
62475
62448
|
throw new Error(`Skill archive file size is invalid: ${path4}`);
|
|
62476
62449
|
}
|
|
62477
62450
|
const outputPath = (0, import_node_path40.join)(destination, ...path4.split("/"));
|
|
62478
|
-
await (0,
|
|
62479
|
-
await (0,
|
|
62451
|
+
await (0, import_promises40.mkdir)((0, import_node_path40.dirname)(outputPath), { recursive: true, mode: 448 });
|
|
62452
|
+
await (0, import_promises40.writeFile)(outputPath, bytes, { mode: (header.mode ?? 420) & 73 ? 493 : 420 });
|
|
62480
62453
|
}
|
|
62481
62454
|
function requireSafeArchivePath(value2) {
|
|
62482
62455
|
const normalized2 = value2.replaceAll("\\", "/").normalize("NFC");
|
|
@@ -62502,8 +62475,8 @@ async function publishLocalSkill(options) {
|
|
|
62502
62475
|
if (Date.parse(request2.uploadGrant.expiresAt) <= (options.now ?? Date.now())) {
|
|
62503
62476
|
throw new RuntimeFault("invalid_file", "Skill upload grant expired");
|
|
62504
62477
|
}
|
|
62505
|
-
const folder = await (0,
|
|
62506
|
-
if (!folder.isDirectory() || await (0,
|
|
62478
|
+
const folder = await (0, import_promises41.lstat)(entry.path);
|
|
62479
|
+
if (!folder.isDirectory() || await (0, import_promises41.realpath)(entry.path) !== entry.path) {
|
|
62507
62480
|
throw new RuntimeFault("invalid_file", "Skill folder moved since the last scan");
|
|
62508
62481
|
}
|
|
62509
62482
|
const bundle = await createSkillBundle(entry.path, {
|
|
@@ -62531,31 +62504,31 @@ async function publishLocalSkill(options) {
|
|
|
62531
62504
|
|
|
62532
62505
|
// src/capabilities/skills/sync.ts
|
|
62533
62506
|
var import_node_crypto19 = require("crypto");
|
|
62534
|
-
var
|
|
62507
|
+
var import_promises42 = require("fs/promises");
|
|
62535
62508
|
var import_node_path41 = require("path");
|
|
62536
62509
|
var SKILL_PREPARE_WAIT_MS = 15e3;
|
|
62537
62510
|
async function install(layout, source, skill, download, signal) {
|
|
62538
62511
|
const bytes = await source.download(download.url, signal);
|
|
62539
|
-
await (0,
|
|
62512
|
+
await (0, import_promises42.mkdir)(layout.tmpDir, { recursive: true, mode: 448 });
|
|
62540
62513
|
const staging = (0, import_node_path41.join)(layout.tmpDir, (0, import_node_crypto19.randomUUID)());
|
|
62541
62514
|
await extractSkillBundle(Buffer.from(bytes), staging, {
|
|
62542
62515
|
expectedArchiveHash: download.archiveHash,
|
|
62543
62516
|
expectedContentHash: skill.contentHash
|
|
62544
62517
|
});
|
|
62545
62518
|
const target = packageDirectory(layout, skill.versionId);
|
|
62546
|
-
await (0,
|
|
62547
|
-
await (0,
|
|
62548
|
-
await (0,
|
|
62519
|
+
await (0, import_promises42.mkdir)(layout.versionsDir, { recursive: true, mode: 448 });
|
|
62520
|
+
await (0, import_promises42.rm)(target, { recursive: true, force: true });
|
|
62521
|
+
await (0, import_promises42.rename)(staging, target);
|
|
62549
62522
|
}
|
|
62550
62523
|
async function sweep(layout, keep) {
|
|
62551
62524
|
const kept = new Set(keep.map((skill) => skill.versionId));
|
|
62552
|
-
const stale = (await (0,
|
|
62525
|
+
const stale = (await (0, import_promises42.readdir)(layout.versionsDir).catch(() => [])).filter(
|
|
62553
62526
|
(name) => !kept.has(name)
|
|
62554
62527
|
);
|
|
62555
62528
|
await Promise.all(
|
|
62556
|
-
stale.map((name) => (0,
|
|
62529
|
+
stale.map((name) => (0, import_promises42.rm)((0, import_node_path41.join)(layout.versionsDir, name), { recursive: true, force: true }))
|
|
62557
62530
|
);
|
|
62558
|
-
await (0,
|
|
62531
|
+
await (0, import_promises42.rm)(layout.tmpDir, { recursive: true, force: true });
|
|
62559
62532
|
return stale.length;
|
|
62560
62533
|
}
|
|
62561
62534
|
async function intactSkills(layout) {
|
|
@@ -62790,7 +62763,7 @@ var import_node_path44 = require("path");
|
|
|
62790
62763
|
init_runtime_v2();
|
|
62791
62764
|
|
|
62792
62765
|
// src/capabilities/workspace/approved-paths.ts
|
|
62793
|
-
var
|
|
62766
|
+
var import_promises43 = require("fs/promises");
|
|
62794
62767
|
init_zod();
|
|
62795
62768
|
|
|
62796
62769
|
// src/capabilities/workspace/paths.ts
|
|
@@ -62828,7 +62801,7 @@ var storeSchema = external_exports.object({
|
|
|
62828
62801
|
});
|
|
62829
62802
|
async function realpathOrNull(path4) {
|
|
62830
62803
|
try {
|
|
62831
|
-
return await (0,
|
|
62804
|
+
return await (0, import_promises43.realpath)(path4);
|
|
62832
62805
|
} catch (error61) {
|
|
62833
62806
|
const code = errnoCode(error61);
|
|
62834
62807
|
if (code === "ENOENT" || code === "ENOTDIR" || code === "EACCES" || code === "EPERM") {
|
|
@@ -62888,7 +62861,7 @@ async function openApprovedPaths(options) {
|
|
|
62888
62861
|
|
|
62889
62862
|
// src/capabilities/workspace/locks.ts
|
|
62890
62863
|
var import_node_crypto20 = require("crypto");
|
|
62891
|
-
var
|
|
62864
|
+
var import_promises44 = require("fs/promises");
|
|
62892
62865
|
var import_node_path43 = require("path");
|
|
62893
62866
|
init_zod();
|
|
62894
62867
|
var LOCK_FORMAT = 1;
|
|
@@ -62909,7 +62882,7 @@ function repositoryLockKey(commonDir, platform3) {
|
|
|
62909
62882
|
async function readOwner2(path4) {
|
|
62910
62883
|
let text2;
|
|
62911
62884
|
try {
|
|
62912
|
-
text2 = await (0,
|
|
62885
|
+
text2 = await (0, import_promises44.readFile)(path4, "utf8");
|
|
62913
62886
|
} catch (error61) {
|
|
62914
62887
|
if (errnoCode(error61) === "ENOENT") return { kind: "missing" };
|
|
62915
62888
|
return { kind: "unreadable" };
|
|
@@ -62930,7 +62903,7 @@ async function removeIfSame(path4, expected) {
|
|
|
62930
62903
|
if (current.kind !== "owner" || current.owner.since !== expected.since) return;
|
|
62931
62904
|
if (current.owner.pid !== expected.pid || current.owner.holder !== expected.holder) return;
|
|
62932
62905
|
}
|
|
62933
|
-
await (0,
|
|
62906
|
+
await (0, import_promises44.unlink)(path4).catch((error61) => {
|
|
62934
62907
|
if (errnoCode(error61) !== "ENOENT") throw error61;
|
|
62935
62908
|
});
|
|
62936
62909
|
}
|
|
@@ -62955,7 +62928,7 @@ function openRepositoryLocks(options) {
|
|
|
62955
62928
|
await removeIfSame(path4, read.owner);
|
|
62956
62929
|
return null;
|
|
62957
62930
|
}
|
|
62958
|
-
const age = await (0,
|
|
62931
|
+
const age = await (0, import_promises44.stat)(path4).then(
|
|
62959
62932
|
(info) => clock.now() - info.mtimeMs,
|
|
62960
62933
|
() => 0
|
|
62961
62934
|
);
|
|
@@ -62970,12 +62943,12 @@ function openRepositoryLocks(options) {
|
|
|
62970
62943
|
const folder = async (commonDir) => {
|
|
62971
62944
|
const key = repositoryLockKey(commonDir, platform3);
|
|
62972
62945
|
const dir = (0, import_node_path43.join)(options.dir, key);
|
|
62973
|
-
await (0,
|
|
62946
|
+
await (0, import_promises44.mkdir)(dir, { recursive: true, mode: 448 });
|
|
62974
62947
|
return { key, dir };
|
|
62975
62948
|
};
|
|
62976
62949
|
const createExclusive = async (path4, owner) => {
|
|
62977
62950
|
try {
|
|
62978
|
-
const handle = await (0,
|
|
62951
|
+
const handle = await (0, import_promises44.open)(path4, "wx", 384);
|
|
62979
62952
|
try {
|
|
62980
62953
|
await handle.writeFile(JSON.stringify(owner));
|
|
62981
62954
|
} finally {
|
|
@@ -62988,7 +62961,7 @@ function openRepositoryLocks(options) {
|
|
|
62988
62961
|
}
|
|
62989
62962
|
};
|
|
62990
62963
|
const liveRun = async (dir) => {
|
|
62991
|
-
const entries = await (0,
|
|
62964
|
+
const entries = await (0, import_promises44.readdir)(dir);
|
|
62992
62965
|
for (const entry of entries) {
|
|
62993
62966
|
if (!entry.startsWith(RUN_FILE_PREFIX)) continue;
|
|
62994
62967
|
const holder = await heldBy((0, import_node_path43.join)(dir, entry));
|
|
@@ -63496,7 +63469,7 @@ var mcpConfigResultSchema = external_exports.object({
|
|
|
63496
63469
|
});
|
|
63497
63470
|
|
|
63498
63471
|
// src/client/runtime-client.ts
|
|
63499
|
-
var
|
|
63472
|
+
var import_promises45 = require("fs/promises");
|
|
63500
63473
|
init_runtime_v2();
|
|
63501
63474
|
|
|
63502
63475
|
// src/client/sse.ts
|
|
@@ -63552,7 +63525,7 @@ var DEFAULT_BACKOFF = { initialMs: 250, maxMs: 3e4 };
|
|
|
63552
63525
|
async function readDiscovery(path4) {
|
|
63553
63526
|
let text2;
|
|
63554
63527
|
try {
|
|
63555
|
-
text2 = await (0,
|
|
63528
|
+
text2 = await (0, import_promises45.readFile)(path4, "utf8");
|
|
63556
63529
|
} catch (error61) {
|
|
63557
63530
|
throw new RuntimeClientError("unavailable", "The runtime is not running", { cause: error61 });
|
|
63558
63531
|
}
|
|
@@ -63857,7 +63830,7 @@ async function sendNativeHookSignal(discoveryPath, hookSignal, signal) {
|
|
|
63857
63830
|
|
|
63858
63831
|
// src/sessions/index.ts
|
|
63859
63832
|
var import_node_crypto24 = require("crypto");
|
|
63860
|
-
var
|
|
63833
|
+
var import_promises57 = require("fs/promises");
|
|
63861
63834
|
var import_node_os10 = require("os");
|
|
63862
63835
|
var import_node_path56 = require("path");
|
|
63863
63836
|
init_runtime_v2();
|
|
@@ -64111,7 +64084,7 @@ function createConversationMcpAuthorization(options) {
|
|
|
64111
64084
|
}
|
|
64112
64085
|
|
|
64113
64086
|
// src/holder/run-inputs.ts
|
|
64114
|
-
var
|
|
64087
|
+
var import_promises50 = require("fs/promises");
|
|
64115
64088
|
var import_node_path48 = require("path");
|
|
64116
64089
|
var NO_RUN_INPUTS = {
|
|
64117
64090
|
attachments: [],
|
|
@@ -64127,16 +64100,16 @@ function safeFilename(filename) {
|
|
|
64127
64100
|
async function prepareRunInputs(spec, { source, tmpDir, signal, skills = [] }) {
|
|
64128
64101
|
const dir = (0, import_node_path48.join)(tmpDir, "runs", spec.runId);
|
|
64129
64102
|
const cleanup = async () => {
|
|
64130
|
-
await (0,
|
|
64103
|
+
await (0, import_promises50.rm)(dir, { recursive: true, force: true });
|
|
64131
64104
|
};
|
|
64132
64105
|
try {
|
|
64133
64106
|
const credential = await source.fetchProviderCredential(spec.runId, signal);
|
|
64134
64107
|
const attachments = [];
|
|
64135
|
-
if (spec.attachments?.length) await (0,
|
|
64108
|
+
if (spec.attachments?.length) await (0, import_promises50.mkdir)(dir, { recursive: true, mode: 448 });
|
|
64136
64109
|
for (const [index, attachment] of (spec.attachments ?? []).entries()) {
|
|
64137
64110
|
const bytes = await source.downloadAttachment(spec.runId, attachment.id, signal);
|
|
64138
64111
|
const path4 = (0, import_node_path48.join)(dir, `${index}-${safeFilename(attachment.filename)}`);
|
|
64139
|
-
await (0,
|
|
64112
|
+
await (0, import_promises50.writeFile)(path4, bytes, { mode: 384 });
|
|
64140
64113
|
attachments.push({
|
|
64141
64114
|
id: attachment.id,
|
|
64142
64115
|
kind: attachment.kind,
|
|
@@ -64164,7 +64137,7 @@ init_runtime_v2();
|
|
|
64164
64137
|
|
|
64165
64138
|
// src/holder/admission.ts
|
|
64166
64139
|
var import_node_fs15 = require("fs");
|
|
64167
|
-
var
|
|
64140
|
+
var import_promises53 = require("fs/promises");
|
|
64168
64141
|
var import_node_os9 = require("os");
|
|
64169
64142
|
var import_node_path52 = require("path");
|
|
64170
64143
|
init_constants();
|
|
@@ -64178,7 +64151,7 @@ function resolveAlanDefaultWorkspacePath(homeDirectory = (0, import_node_os8.hom
|
|
|
64178
64151
|
}
|
|
64179
64152
|
|
|
64180
64153
|
// src/holder/admission-relocation.ts
|
|
64181
|
-
var
|
|
64154
|
+
var import_promises51 = require("fs/promises");
|
|
64182
64155
|
var import_node_path50 = require("path");
|
|
64183
64156
|
var MAX_RELOCATION_CANDIDATES = 200;
|
|
64184
64157
|
var RELOCATION_BUDGET_MS = 2e4;
|
|
@@ -64214,7 +64187,7 @@ async function originIdentity(git, path4, signal) {
|
|
|
64214
64187
|
}
|
|
64215
64188
|
async function childDirectories(parent, limit) {
|
|
64216
64189
|
try {
|
|
64217
|
-
const entries = await (0,
|
|
64190
|
+
const entries = await (0, import_promises51.readdir)(parent, { withFileTypes: true });
|
|
64218
64191
|
return entries.filter((entry) => entry.isDirectory()).slice(0, limit).map((entry) => (0, import_node_path50.join)(parent, entry.name));
|
|
64219
64192
|
} catch {
|
|
64220
64193
|
return [];
|
|
@@ -64250,7 +64223,7 @@ async function discoverRelocatedWorkspace(search) {
|
|
|
64250
64223
|
}
|
|
64251
64224
|
|
|
64252
64225
|
// src/holder/lease.ts
|
|
64253
|
-
var
|
|
64226
|
+
var import_promises52 = require("fs/promises");
|
|
64254
64227
|
var import_node_path51 = require("path");
|
|
64255
64228
|
var LEASE_CHECK_EVERY_MS = 5e3;
|
|
64256
64229
|
var MAX_TRANSIENT_FAILURES = 3;
|
|
@@ -64265,8 +64238,8 @@ function identityFailure(code, workspacePath) {
|
|
|
64265
64238
|
return { code, problemCode: "app.workspace.missing", message: MESSAGES[code], workspacePath };
|
|
64266
64239
|
}
|
|
64267
64240
|
async function fileIdentity(path4) {
|
|
64268
|
-
const canonical = await (0,
|
|
64269
|
-
const info = await (0,
|
|
64241
|
+
const canonical = await (0, import_promises52.realpath)(path4);
|
|
64242
|
+
const info = await (0, import_promises52.stat)(canonical, { bigint: true });
|
|
64270
64243
|
return `${canonical}:${info.dev}:${info.ino}`;
|
|
64271
64244
|
}
|
|
64272
64245
|
async function snapshot(git, path4, signal) {
|
|
@@ -64285,7 +64258,7 @@ async function snapshot(git, path4, signal) {
|
|
|
64285
64258
|
workspace: await fileIdentity(path4),
|
|
64286
64259
|
repository: await fileIdentity(commonDir),
|
|
64287
64260
|
worktree: await fileIdentity(gitDir),
|
|
64288
|
-
commonDir: await (0,
|
|
64261
|
+
commonDir: await (0, import_promises52.realpath)(commonDir)
|
|
64289
64262
|
};
|
|
64290
64263
|
} catch {
|
|
64291
64264
|
return null;
|
|
@@ -64298,7 +64271,7 @@ async function gitValue(git, path4, args, signal) {
|
|
|
64298
64271
|
}
|
|
64299
64272
|
async function pathExists(path4) {
|
|
64300
64273
|
try {
|
|
64301
|
-
await (0,
|
|
64274
|
+
await (0, import_promises52.stat)(path4);
|
|
64302
64275
|
return true;
|
|
64303
64276
|
} catch (error61) {
|
|
64304
64277
|
return errnoCode(error61) !== "ENOENT" && errnoCode(error61) !== "ENOTDIR";
|
|
@@ -64307,13 +64280,13 @@ async function pathExists(path4) {
|
|
|
64307
64280
|
async function hasGitMarker(path4) {
|
|
64308
64281
|
let directory;
|
|
64309
64282
|
try {
|
|
64310
|
-
directory = await (0,
|
|
64283
|
+
directory = await (0, import_promises52.realpath)(path4);
|
|
64311
64284
|
} catch {
|
|
64312
64285
|
return true;
|
|
64313
64286
|
}
|
|
64314
64287
|
for (; ; ) {
|
|
64315
64288
|
try {
|
|
64316
|
-
await (0,
|
|
64289
|
+
await (0, import_promises52.stat)((0, import_node_path51.join)(directory, ".git"));
|
|
64317
64290
|
return true;
|
|
64318
64291
|
} catch (error61) {
|
|
64319
64292
|
const code = errnoCode(error61);
|
|
@@ -64483,7 +64456,7 @@ function volumeRoot(path4) {
|
|
|
64483
64456
|
}
|
|
64484
64457
|
async function exists4(path4) {
|
|
64485
64458
|
try {
|
|
64486
|
-
await (0,
|
|
64459
|
+
await (0, import_promises53.stat)(path4);
|
|
64487
64460
|
return true;
|
|
64488
64461
|
} catch {
|
|
64489
64462
|
return false;
|
|
@@ -64491,10 +64464,10 @@ async function exists4(path4) {
|
|
|
64491
64464
|
}
|
|
64492
64465
|
async function inspectReadiness(path4) {
|
|
64493
64466
|
try {
|
|
64494
|
-
if (!(await (0,
|
|
64467
|
+
if (!(await (0, import_promises53.stat)(path4)).isDirectory()) {
|
|
64495
64468
|
return { ready: false, missing: true, message: MESSAGES2.missing };
|
|
64496
64469
|
}
|
|
64497
|
-
await (0,
|
|
64470
|
+
await (0, import_promises53.access)(path4, import_node_fs15.constants.R_OK | import_node_fs15.constants.W_OK | import_node_fs15.constants.X_OK);
|
|
64498
64471
|
return { ready: true };
|
|
64499
64472
|
} catch (error61) {
|
|
64500
64473
|
const code = errnoCode(error61) ?? "";
|
|
@@ -64572,8 +64545,8 @@ async function admitDefaultWorkspace(spec, context, skills) {
|
|
|
64572
64545
|
const { env } = context;
|
|
64573
64546
|
const path4 = resolveAlanDefaultWorkspacePath(env.HOME || env.USERPROFILE || (0, import_node_os9.homedir)());
|
|
64574
64547
|
try {
|
|
64575
|
-
await (0,
|
|
64576
|
-
await (0,
|
|
64548
|
+
await (0, import_promises53.mkdir)(path4, { recursive: true, mode: 448 });
|
|
64549
|
+
await (0, import_promises53.access)(path4, import_node_fs15.constants.R_OK | import_node_fs15.constants.W_OK | import_node_fs15.constants.X_OK);
|
|
64577
64550
|
return {
|
|
64578
64551
|
kind: "admitted",
|
|
64579
64552
|
spec: { ...spec, projectPath: path4 },
|
|
@@ -64685,7 +64658,7 @@ async function respondToTurn(runningRunId, gate, driver, request2) {
|
|
|
64685
64658
|
}
|
|
64686
64659
|
|
|
64687
64660
|
// src/holder/session-facts.ts
|
|
64688
|
-
var
|
|
64661
|
+
var import_promises54 = require("fs/promises");
|
|
64689
64662
|
var CLI_RSS_CACHE_MS = 1e4;
|
|
64690
64663
|
var LOGIN_PROBLEM_PREFIX = "cli.auth.";
|
|
64691
64664
|
function isLoginFailure(result) {
|
|
@@ -64709,8 +64682,8 @@ function createSessionFacts(options) {
|
|
|
64709
64682
|
const path4 = await resolveCommandOnPath(command, env, platform3);
|
|
64710
64683
|
if (path4 === null) return null;
|
|
64711
64684
|
try {
|
|
64712
|
-
const real = await (0,
|
|
64713
|
-
const info = await (0,
|
|
64685
|
+
const real = await (0, import_promises54.realpath)(path4);
|
|
64686
|
+
const info = await (0, import_promises54.stat)(real);
|
|
64714
64687
|
return { command, key: `${real}:${info.ino}:${info.size}:${info.mtimeMs}` };
|
|
64715
64688
|
} catch {
|
|
64716
64689
|
return null;
|
|
@@ -64791,7 +64764,7 @@ var import_node_fs16 = require("fs");
|
|
|
64791
64764
|
var import_node_path54 = require("path");
|
|
64792
64765
|
|
|
64793
64766
|
// src/run-log/directory.ts
|
|
64794
|
-
var
|
|
64767
|
+
var import_promises55 = require("fs/promises");
|
|
64795
64768
|
var import_node_path53 = require("path");
|
|
64796
64769
|
init_runtime_v2();
|
|
64797
64770
|
init_zod();
|
|
@@ -64811,7 +64784,7 @@ function runDirectory(runsDir, runId) {
|
|
|
64811
64784
|
}
|
|
64812
64785
|
async function isRunClaimed(runsDir, runId) {
|
|
64813
64786
|
try {
|
|
64814
|
-
return (await (0,
|
|
64787
|
+
return (await (0, import_promises55.stat)(runDirectory(runsDir, runId).log)).size > 0;
|
|
64815
64788
|
} catch (error61) {
|
|
64816
64789
|
if (errnoCode(error61) === "ENOENT") return false;
|
|
64817
64790
|
throw error61;
|
|
@@ -64849,7 +64822,7 @@ async function writeCompleteRunLog(runsDir, meta3, records) {
|
|
|
64849
64822
|
}
|
|
64850
64823
|
|
|
64851
64824
|
// src/run-log/reader.ts
|
|
64852
|
-
var
|
|
64825
|
+
var import_promises56 = require("fs/promises");
|
|
64853
64826
|
init_runtime_v2();
|
|
64854
64827
|
|
|
64855
64828
|
// src/run-log/tail.ts
|
|
@@ -64872,7 +64845,7 @@ function firstRecordLength(bytes) {
|
|
|
64872
64845
|
return bytes.indexOf(RUN_LOG_RECORD_SEPARATOR) + 1;
|
|
64873
64846
|
}
|
|
64874
64847
|
async function openRunLogReader(path4) {
|
|
64875
|
-
const handle = await (0,
|
|
64848
|
+
const handle = await (0, import_promises56.open)(path4, "r");
|
|
64876
64849
|
const readAt = async (position, length) => {
|
|
64877
64850
|
const buffer = Buffer.alloc(length);
|
|
64878
64851
|
const { bytesRead } = await handle.read(buffer, 0, length, position);
|
|
@@ -64906,7 +64879,7 @@ async function openRunLogReader(path4) {
|
|
|
64906
64879
|
};
|
|
64907
64880
|
}
|
|
64908
64881
|
async function readLastRecord(path4) {
|
|
64909
|
-
const handle = await (0,
|
|
64882
|
+
const handle = await (0, import_promises56.open)(path4, "r").catch(() => null);
|
|
64910
64883
|
if (handle === null) return null;
|
|
64911
64884
|
try {
|
|
64912
64885
|
const { size } = await handle.stat();
|
|
@@ -65545,7 +65518,7 @@ var DEFAULT_MAX_ACTIVE_RUNS = 32;
|
|
|
65545
65518
|
var HOLDER_BUSY = "busy";
|
|
65546
65519
|
async function listIds(dir, schema) {
|
|
65547
65520
|
const ids = [];
|
|
65548
|
-
for (const name of await (0,
|
|
65521
|
+
for (const name of await (0, import_promises57.readdir)(dir).catch(() => [])) {
|
|
65549
65522
|
const parsed = schema.safeParse(name);
|
|
65550
65523
|
if (parsed.success) ids.push(parsed.data);
|
|
65551
65524
|
}
|
|
@@ -65606,7 +65579,7 @@ async function openSessions(deps) {
|
|
|
65606
65579
|
}
|
|
65607
65580
|
await clock.sleep(HOLDER_READY_POLL_MS, AbortSignal.timeout(HOLDER_EXIT_GRACE_MS));
|
|
65608
65581
|
}
|
|
65609
|
-
await (0,
|
|
65582
|
+
await (0, import_promises57.rm)(files.dir, { recursive: true, force: true });
|
|
65610
65583
|
for (const [runId, owner] of launched) if (owner === conversationId) launched.delete(runId);
|
|
65611
65584
|
for (const runId of await listIds(paths.runs, runIdSchema)) {
|
|
65612
65585
|
const meta3 = await readRunMeta(runDirectory(paths.runs, runId).meta);
|
|
@@ -65655,7 +65628,7 @@ async function openSessions(deps) {
|
|
|
65655
65628
|
if (!await waitForExit2(holder)) return false;
|
|
65656
65629
|
}
|
|
65657
65630
|
legacy.delete(conversationId);
|
|
65658
|
-
await (0,
|
|
65631
|
+
await (0, import_promises57.rm)(sessionFiles(paths, conversationId).dir, { recursive: true, force: true });
|
|
65659
65632
|
for (const runId of await unendedRunsOf(conversationId)) await markInterrupted(runId);
|
|
65660
65633
|
log.info("sessions.legacy_holder_retired", { conversationId });
|
|
65661
65634
|
return true;
|
|
@@ -65681,7 +65654,7 @@ async function openSessions(deps) {
|
|
|
65681
65654
|
log.info("sessions.reattached", { conversationId });
|
|
65682
65655
|
return;
|
|
65683
65656
|
}
|
|
65684
|
-
await (0,
|
|
65657
|
+
await (0, import_promises57.rm)(files.dir, { recursive: true, force: true });
|
|
65685
65658
|
};
|
|
65686
65659
|
const busyRunIds = async () => {
|
|
65687
65660
|
const busy = /* @__PURE__ */ new Set();
|
|
@@ -65735,7 +65708,7 @@ async function openSessions(deps) {
|
|
|
65735
65708
|
const meta3 = await readRunMeta(dir.meta);
|
|
65736
65709
|
const last = await readLastRecord(dir.log);
|
|
65737
65710
|
if (meta3 === null || last === null) return null;
|
|
65738
|
-
const logged = await (0,
|
|
65711
|
+
const logged = await (0, import_promises57.stat)(dir.log).catch((error61) => {
|
|
65739
65712
|
if (errnoCode(error61) === "ENOENT") return null;
|
|
65740
65713
|
throw error61;
|
|
65741
65714
|
});
|
|
@@ -66087,7 +66060,7 @@ function readCliEnvironment(env = process.env) {
|
|
|
66087
66060
|
}
|
|
66088
66061
|
|
|
66089
66062
|
// src/cli/context.ts
|
|
66090
|
-
var
|
|
66063
|
+
var import_promises58 = require("fs/promises");
|
|
66091
66064
|
var import_node_os12 = require("os");
|
|
66092
66065
|
var import_node_path58 = require("path");
|
|
66093
66066
|
var DESKTOP_BUNDLE_IDS = {
|
|
@@ -66137,7 +66110,7 @@ async function installedServiceSpec(ctx) {
|
|
|
66137
66110
|
const spec = serviceSpec(ctx);
|
|
66138
66111
|
if (ctx.config.host === "app") return spec;
|
|
66139
66112
|
const layout = installLayout(ctx.config.installDir, ctx.config.profile);
|
|
66140
|
-
const installed = await (0,
|
|
66113
|
+
const installed = await (0, import_promises58.access)(layout.launcher).then(
|
|
66141
66114
|
() => true,
|
|
66142
66115
|
() => false
|
|
66143
66116
|
);
|
|
@@ -66264,7 +66237,7 @@ var manifestRevisionSchema = external_exports.object({ revision: external_export
|
|
|
66264
66237
|
async function manifestRevision(path4) {
|
|
66265
66238
|
let raw;
|
|
66266
66239
|
try {
|
|
66267
|
-
raw = JSON.parse(await (0,
|
|
66240
|
+
raw = JSON.parse(await (0, import_promises59.readFile)(path4, "utf8"));
|
|
66268
66241
|
} catch (error61) {
|
|
66269
66242
|
throw new RuntimeFault("invalid_file", `Cannot read the skill manifest at ${path4}`, {
|
|
66270
66243
|
cause: error61
|
|
@@ -66318,7 +66291,7 @@ async function runSkills(argv) {
|
|
|
66318
66291
|
}
|
|
66319
66292
|
|
|
66320
66293
|
// src/cli/commands/doctor.ts
|
|
66321
|
-
var
|
|
66294
|
+
var import_promises62 = require("fs/promises");
|
|
66322
66295
|
var import_node_path62 = require("path");
|
|
66323
66296
|
init_runtime_v2();
|
|
66324
66297
|
|
|
@@ -66496,7 +66469,7 @@ async function authorizeDevice(input2) {
|
|
|
66496
66469
|
}
|
|
66497
66470
|
|
|
66498
66471
|
// src/identity/enroll.ts
|
|
66499
|
-
var
|
|
66472
|
+
var import_promises60 = require("fs/promises");
|
|
66500
66473
|
init_runtime_v2();
|
|
66501
66474
|
|
|
66502
66475
|
// src/identity/installation.ts
|
|
@@ -66567,12 +66540,12 @@ async function enrollFromGrantFile(input2) {
|
|
|
66567
66540
|
clock: input2.clock,
|
|
66568
66541
|
access: input2.access
|
|
66569
66542
|
});
|
|
66570
|
-
await (0,
|
|
66543
|
+
await (0, import_promises60.rm)(input2.grantPath, { force: true });
|
|
66571
66544
|
return machine;
|
|
66572
66545
|
}
|
|
66573
66546
|
|
|
66574
66547
|
// src/identity/migrate-v1.ts
|
|
66575
|
-
var
|
|
66548
|
+
var import_promises61 = require("fs/promises");
|
|
66576
66549
|
var import_node_path60 = require("path");
|
|
66577
66550
|
init_runtime_v2();
|
|
66578
66551
|
init_zod();
|
|
@@ -66623,8 +66596,8 @@ async function scrubLegacyInstall(install2) {
|
|
|
66623
66596
|
const scrubbed = { ...install2.config, migratedToRuntimeV2: true };
|
|
66624
66597
|
for (const key of SCRUBBED_KEYS) delete scrubbed[key];
|
|
66625
66598
|
await writeJsonFileAtomic(`${install2.configPath}.migrated-v1`, scrubbed);
|
|
66626
|
-
await (0,
|
|
66627
|
-
await (0,
|
|
66599
|
+
await (0, import_promises61.rm)(install2.configPath, { force: true });
|
|
66600
|
+
await (0, import_promises61.rm)(install2.ownerLeasePath, { force: true });
|
|
66628
66601
|
}
|
|
66629
66602
|
async function exchangeCredential(deps) {
|
|
66630
66603
|
const { config: config2 } = deps.install;
|
|
@@ -67033,7 +67006,7 @@ async function probeHolder(dir, conversationId) {
|
|
|
67033
67006
|
}
|
|
67034
67007
|
}
|
|
67035
67008
|
async function holdersCheck(ctx) {
|
|
67036
|
-
const names = await (0,
|
|
67009
|
+
const names = await (0, import_promises62.readdir)(ctx.paths.sessions).catch(() => []);
|
|
67037
67010
|
const holders = (await Promise.all(names.map((name) => probeHolder((0, import_node_path62.join)(ctx.paths.sessions, name), name)))).filter((facts) => facts !== null);
|
|
67038
67011
|
const dead = holders.filter((holder) => !holder.alive).length;
|
|
67039
67012
|
return check2(
|
|
@@ -67045,7 +67018,7 @@ async function holdersCheck(ctx) {
|
|
|
67045
67018
|
}
|
|
67046
67019
|
async function freeBytesAt(path4) {
|
|
67047
67020
|
try {
|
|
67048
|
-
const stats = await (0,
|
|
67021
|
+
const stats = await (0, import_promises62.statfs)(path4);
|
|
67049
67022
|
return { path: path4, freeBytes: stats.bavail * stats.bsize };
|
|
67050
67023
|
} catch (error61) {
|
|
67051
67024
|
const parent = (0, import_node_path62.dirname)(path4);
|
|
@@ -67184,7 +67157,7 @@ async function runDoctor(argv, context = cliContext) {
|
|
|
67184
67157
|
}
|
|
67185
67158
|
|
|
67186
67159
|
// src/cli/commands/git-credential.ts
|
|
67187
|
-
var
|
|
67160
|
+
var import_promises63 = require("fs/promises");
|
|
67188
67161
|
var import_node_net4 = require("net");
|
|
67189
67162
|
var MAX_RESPONSE_BYTES = 64 * 1024;
|
|
67190
67163
|
async function readAll(stream) {
|
|
@@ -67289,7 +67262,7 @@ async function configure(argv) {
|
|
|
67289
67262
|
}
|
|
67290
67263
|
const config2 = loadRuntimeConfig();
|
|
67291
67264
|
const { launcher } = installLayout(config2.installDir, config2.profile);
|
|
67292
|
-
const installed = await (0,
|
|
67265
|
+
const installed = await (0, import_promises63.access)(launcher).then(
|
|
67293
67266
|
() => true,
|
|
67294
67267
|
() => false
|
|
67295
67268
|
);
|
|
@@ -67466,7 +67439,7 @@ async function runHook(argv, overrides = {}) {
|
|
|
67466
67439
|
}
|
|
67467
67440
|
|
|
67468
67441
|
// src/cli/commands/ingestion-hooks.ts
|
|
67469
|
-
var
|
|
67442
|
+
var import_promises64 = require("fs/promises");
|
|
67470
67443
|
var CODEX_TRUST_NOTE = "Codex runs new hooks only after you review them: open /hooks in Codex.";
|
|
67471
67444
|
function isAction(value2) {
|
|
67472
67445
|
return value2 === "enable" || value2 === "disable" || value2 === "status";
|
|
@@ -67489,7 +67462,7 @@ function errorMessage2(error61) {
|
|
|
67489
67462
|
return error61 instanceof Error ? error61.message : String(error61);
|
|
67490
67463
|
}
|
|
67491
67464
|
async function exists5(path4) {
|
|
67492
|
-
return (0,
|
|
67465
|
+
return (0, import_promises64.access)(path4).then(
|
|
67493
67466
|
() => true,
|
|
67494
67467
|
() => false
|
|
67495
67468
|
);
|
|
@@ -67848,7 +67821,7 @@ async function runToken(argv, signal) {
|
|
|
67848
67821
|
}
|
|
67849
67822
|
|
|
67850
67823
|
// src/cli/commands/logout.ts
|
|
67851
|
-
var
|
|
67824
|
+
var import_promises65 = require("fs/promises");
|
|
67852
67825
|
var import_node_path67 = require("path");
|
|
67853
67826
|
init_runtime_v2();
|
|
67854
67827
|
var RUNTIME_EXIT_WAIT_MS = 35e3;
|
|
@@ -67908,7 +67881,7 @@ async function stopHolder(launch, deps, outcome2) {
|
|
|
67908
67881
|
}
|
|
67909
67882
|
async function stopHeldRuns(ctx, deps, outcome2 = "aborted") {
|
|
67910
67883
|
const stopped = [];
|
|
67911
|
-
for (const name of await (0,
|
|
67884
|
+
for (const name of await (0, import_promises65.readdir)(ctx.paths.sessions).catch(() => [])) {
|
|
67912
67885
|
const launch = await readJsonFile(
|
|
67913
67886
|
(0, import_node_path67.join)(ctx.paths.sessions, name, "launch.json"),
|
|
67914
67887
|
holderLaunchSchema
|
|
@@ -67947,7 +67920,7 @@ async function forgetMachineLocally(ctx) {
|
|
|
67947
67920
|
const machine = await readMachineFile(ctx.paths);
|
|
67948
67921
|
if (machine === null) return;
|
|
67949
67922
|
await credentialStoreFor(ctx.paths, machine.credentialStore, ctx.access).clear();
|
|
67950
|
-
await (0,
|
|
67923
|
+
await (0, import_promises65.rm)(ctx.paths.machine, { force: true });
|
|
67951
67924
|
}
|
|
67952
67925
|
async function runLogout(argv, signal) {
|
|
67953
67926
|
var _stack = [];
|
|
@@ -68036,7 +68009,7 @@ function createRunAppends() {
|
|
|
68036
68009
|
|
|
68037
68010
|
// src/local-api/server.ts
|
|
68038
68011
|
var import_node_crypto28 = require("crypto");
|
|
68039
|
-
var
|
|
68012
|
+
var import_promises66 = require("fs/promises");
|
|
68040
68013
|
var import_node_http4 = require("http");
|
|
68041
68014
|
var import_node_path68 = require("path");
|
|
68042
68015
|
|
|
@@ -68695,7 +68668,7 @@ async function serveLocalApi(deps) {
|
|
|
68695
68668
|
await watchedStatus[Symbol.asyncDispose]();
|
|
68696
68669
|
const current = await readJsonFile(discoveryPath, localApiDiscoverySchema);
|
|
68697
68670
|
if (current.kind === "ok" && current.value.token === token) {
|
|
68698
|
-
await (0,
|
|
68671
|
+
await (0, import_promises66.rm)(discoveryPath, { force: true });
|
|
68699
68672
|
}
|
|
68700
68673
|
await closeServer(server);
|
|
68701
68674
|
log.info("local_api.closed", {});
|
|
@@ -72448,7 +72421,7 @@ function refusalFailure(refusal2) {
|
|
|
72448
72421
|
}
|
|
72449
72422
|
|
|
72450
72423
|
// src/link/probe.ts
|
|
72451
|
-
var
|
|
72424
|
+
var import_promises67 = require("dns/promises");
|
|
72452
72425
|
var import_node_net5 = require("net");
|
|
72453
72426
|
var import_node_tls2 = require("tls");
|
|
72454
72427
|
var PROBE_TIMEOUT_MS4 = 5e3;
|
|
@@ -72484,7 +72457,7 @@ async function connectOnce(url3, clock) {
|
|
|
72484
72457
|
}
|
|
72485
72458
|
async function probeEndpoint(url3, clock) {
|
|
72486
72459
|
try {
|
|
72487
|
-
await (0,
|
|
72460
|
+
await (0, import_promises67.lookup)(url3.hostname);
|
|
72488
72461
|
} catch (error61) {
|
|
72489
72462
|
const reason = classifyTransportFailure(error61);
|
|
72490
72463
|
return reason === "other" ? "dns" : reason;
|
|
@@ -72920,7 +72893,7 @@ function createReconciler(host, lifecycle, log, signal) {
|
|
|
72920
72893
|
}
|
|
72921
72894
|
|
|
72922
72895
|
// src/uploader/index.ts
|
|
72923
|
-
var
|
|
72896
|
+
var import_promises68 = require("fs/promises");
|
|
72924
72897
|
init_runtime_v2();
|
|
72925
72898
|
init_zod();
|
|
72926
72899
|
var RETRY_DELAYS_MS = [250, 500, 1e3, 2e3, 5e3, 1e4, 3e4];
|
|
@@ -73061,7 +73034,7 @@ function startUploader({ api, runsDir, clock, log }) {
|
|
|
73061
73034
|
active.set(runId, task);
|
|
73062
73035
|
};
|
|
73063
73036
|
const sweep2 = async () => {
|
|
73064
|
-
for (const name of await (0,
|
|
73037
|
+
for (const name of await (0, import_promises68.readdir)(runsDir).catch(() => [])) {
|
|
73065
73038
|
const runId = runIdSchema.safeParse(name);
|
|
73066
73039
|
if (runId.success) run2(runId.data);
|
|
73067
73040
|
}
|
|
@@ -73071,18 +73044,18 @@ function startUploader({ api, runsDir, clock, log }) {
|
|
|
73071
73044
|
const dir = runDirectory(runsDir, runId);
|
|
73072
73045
|
const progress = await readJsonFile(dir.upload, uploadProgressSchema);
|
|
73073
73046
|
if (progress.kind !== "ok" || !progress.value.sealed) return false;
|
|
73074
|
-
const sealedAt = (await (0,
|
|
73047
|
+
const sealedAt = (await (0, import_promises68.stat)(dir.upload)).mtimeMs;
|
|
73075
73048
|
if (clock.now() - sealedAt < options.sealedForMs) return false;
|
|
73076
73049
|
return (await readLastRecord(dir.log))?.update.sessionUpdate === "_alan/run.ended";
|
|
73077
73050
|
};
|
|
73078
73051
|
const prune = async (options) => {
|
|
73079
73052
|
let removed = 0;
|
|
73080
|
-
for (const name of await (0,
|
|
73053
|
+
for (const name of await (0, import_promises68.readdir)(runsDir).catch(() => [])) {
|
|
73081
73054
|
const runId = runIdSchema.safeParse(name);
|
|
73082
73055
|
if (!runId.success) continue;
|
|
73083
73056
|
try {
|
|
73084
73057
|
if (!await isPrunable(runId.data, options)) continue;
|
|
73085
|
-
await (0,
|
|
73058
|
+
await (0, import_promises68.rm)(runDirectory(runsDir, runId.data).dir, { recursive: true, force: true });
|
|
73086
73059
|
removed += 1;
|
|
73087
73060
|
} catch (error61) {
|
|
73088
73061
|
log.warn("upload.prune_failed", { runId: runId.data, error: error61 });
|
|
@@ -74232,17 +74205,17 @@ async function runServiceCommand(argv, ctx = cliContext()) {
|
|
|
74232
74205
|
}
|
|
74233
74206
|
|
|
74234
74207
|
// src/cli/commands/upgrade.ts
|
|
74235
|
-
var
|
|
74208
|
+
var import_promises69 = require("fs/promises");
|
|
74236
74209
|
var import_node_path72 = require("path");
|
|
74237
74210
|
function isNotNewer(version2, installed) {
|
|
74238
74211
|
return installed !== null && isReleaseVersion(version2) && isReleaseVersion(installed) && compareVersions(version2, installed) <= 0;
|
|
74239
74212
|
}
|
|
74240
74213
|
async function installFromSource(source) {
|
|
74241
74214
|
const { layout, from, ifNewer } = source;
|
|
74242
|
-
const isTarball = (await (0,
|
|
74215
|
+
const isTarball = (await (0, import_promises69.stat)(from)).isFile();
|
|
74243
74216
|
const downloads = (0, import_node_path72.join)(layout.root, ".downloads");
|
|
74244
|
-
if (isTarball) await (0,
|
|
74245
|
-
const scratch = isTarball ? await (0,
|
|
74217
|
+
if (isTarball) await (0, import_promises69.mkdir)(downloads, { recursive: true, mode: 448 });
|
|
74218
|
+
const scratch = isTarball ? await (0, import_promises69.mkdtemp)((0, import_node_path72.join)(downloads, "upgrade-")) : null;
|
|
74246
74219
|
try {
|
|
74247
74220
|
const sourceDir = scratch === null ? from : await extractPackageTarball(from, scratch);
|
|
74248
74221
|
const version2 = await readPackageVersion(sourceDir);
|
|
@@ -74250,7 +74223,7 @@ async function installFromSource(source) {
|
|
|
74250
74223
|
if (ifNewer && isNotNewer(version2, installed)) return { kind: "skipped", version: version2, installed };
|
|
74251
74224
|
return { kind: "installed", ...await installVersion(layout, sourceDir) };
|
|
74252
74225
|
} finally {
|
|
74253
|
-
if (scratch !== null) await (0,
|
|
74226
|
+
if (scratch !== null) await (0, import_promises69.rm)(scratch, { recursive: true, force: true });
|
|
74254
74227
|
}
|
|
74255
74228
|
}
|
|
74256
74229
|
async function runUpgrade(argv) {
|