@alan-ai-hq/agent-manager-linux-arm64 0.1.161 → 0.1.163
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 +123 -172
- package/alan-holder.cjs +62 -90
- package/package.json +1 -1
package/alan-agent.cjs
CHANGED
|
@@ -47275,8 +47275,9 @@ var init_driver = __esm({
|
|
|
47275
47275
|
});
|
|
47276
47276
|
|
|
47277
47277
|
// src/holder/drivers/persistent.ts
|
|
47278
|
-
function sessionContextFor(opened, inputs) {
|
|
47279
|
-
|
|
47278
|
+
async function sessionContextFor(opened, inputs) {
|
|
47279
|
+
const text3 = await inputs.agentContext;
|
|
47280
|
+
return opened.fresh ? text3?.full : text3?.update;
|
|
47280
47281
|
}
|
|
47281
47282
|
function steerEcho(request2) {
|
|
47282
47283
|
return {
|
|
@@ -47525,7 +47526,7 @@ function createPersistentDriver(provider4, options) {
|
|
|
47525
47526
|
};
|
|
47526
47527
|
signal.addEventListener("abort", onAbort, { once: true });
|
|
47527
47528
|
try {
|
|
47528
|
-
const contextPrefix = [sessionContextFor(opened, inputs), opened.contextPrefix].filter((part) => part !== void 0).join("\n\n");
|
|
47529
|
+
const contextPrefix = [await sessionContextFor(opened, inputs), opened.contextPrefix].filter((part) => part !== void 0).join("\n\n");
|
|
47529
47530
|
const input2 = await provider4.turnInput(spec, inputs, contextPrefix || void 0);
|
|
47530
47531
|
if (signal.aborted) return { outcome: "aborted" };
|
|
47531
47532
|
const timeoutMs = options.firstOutputTimeoutMs ?? FIRST_OUTPUT_TIMEOUT_MS;
|
|
@@ -57829,7 +57830,7 @@ var require_websocket_server = __commonJS({
|
|
|
57829
57830
|
// package.json
|
|
57830
57831
|
var package_default = {
|
|
57831
57832
|
name: "@alan-ai-hq/agent-manager",
|
|
57832
|
-
version: "0.1.
|
|
57833
|
+
version: "0.1.163",
|
|
57833
57834
|
private: true,
|
|
57834
57835
|
type: "module",
|
|
57835
57836
|
description: "Alan machine runtime (alan-agent): identity, link, reconciler, session holders, run log, uploader, local API",
|
|
@@ -60290,6 +60291,20 @@ async function checkOne(path4, deps, signal) {
|
|
|
60290
60291
|
);
|
|
60291
60292
|
return fetched.exitCode === 0 ? write({ state: "behind", path: path4, snapshot, tip, fetched: true }) : write({ state: "failed", path: path4, snapshot, reason: gitError(fetched, "fetch") });
|
|
60292
60293
|
}
|
|
60294
|
+
async function currentBranch(git, cwd, signal) {
|
|
60295
|
+
const output2 = await git.run(
|
|
60296
|
+
{ cwd, args: ["symbolic-ref", "--quiet", "--short", "HEAD"], readOnly: true },
|
|
60297
|
+
signal
|
|
60298
|
+
);
|
|
60299
|
+
return output2.exitCode === 0 ? output2.stdout.trim() || null : null;
|
|
60300
|
+
}
|
|
60301
|
+
async function moveSnapshotTo(git, cwd, snapshot, tip, signal) {
|
|
60302
|
+
const run2 = (args) => git.run({ cwd, args }, signal);
|
|
60303
|
+
if ((await run2(["switch", "--quiet", "--detach", tip])).exitCode !== 0) return false;
|
|
60304
|
+
const moved = await run2(["update-ref", `refs/heads/${snapshot.branch}`, tip, snapshot.head]);
|
|
60305
|
+
const back = await run2(["switch", "--quiet", snapshot.branch]);
|
|
60306
|
+
return moved.exitCode === 0 && back.exitCode === 0;
|
|
60307
|
+
}
|
|
60293
60308
|
async function isCheckout(path4) {
|
|
60294
60309
|
return (0, import_promises11.stat)((0, import_node_path7.join)(path4, ".git")).then(
|
|
60295
60310
|
() => true,
|
|
@@ -61309,7 +61324,6 @@ function runtimePaths(stateDir) {
|
|
|
61309
61324
|
|
|
61310
61325
|
// src/platform/process-memory.ts
|
|
61311
61326
|
var import_node_child_process4 = require("child_process");
|
|
61312
|
-
var import_node_fs7 = require("fs");
|
|
61313
61327
|
var import_promises16 = require("fs/promises");
|
|
61314
61328
|
var import_node_os2 = require("os");
|
|
61315
61329
|
var import_node_util3 = require("util");
|
|
@@ -61377,52 +61391,9 @@ function readMemoryPressure() {
|
|
|
61377
61391
|
if (process.platform === "linux") return linuxPressure();
|
|
61378
61392
|
return Promise.resolve("normal");
|
|
61379
61393
|
}
|
|
61380
|
-
function
|
|
61381
|
-
const pageSize = Number(/page size of (\d+) bytes/.exec(output2)?.[1]);
|
|
61382
|
-
if (!Number.isFinite(pageSize) || pageSize <= 0) return null;
|
|
61383
|
-
const pages = (name) => {
|
|
61384
|
-
const match = new RegExp(`^Pages ${name}:\\s+(\\d+)\\.?$`, "m").exec(output2);
|
|
61385
|
-
return match ? Number(match[1]) : null;
|
|
61386
|
-
};
|
|
61387
|
-
const free = pages("free");
|
|
61388
|
-
if (free === null) return null;
|
|
61389
|
-
return (free + (pages("inactive") ?? 0) + (pages("speculative") ?? 0)) * pageSize;
|
|
61390
|
-
}
|
|
61391
|
-
function parseLinuxMemInfo(output2) {
|
|
61392
|
-
const kilobytes = /^MemAvailable:\s+(\d+)\s+kB$/m.exec(output2)?.[1];
|
|
61393
|
-
return kilobytes === void 0 ? null : Number(kilobytes) * 1024;
|
|
61394
|
-
}
|
|
61395
|
-
var CAPACITY_PROBE_TTL_MS = 2e3;
|
|
61396
|
-
var AvailableMemoryProbe = class {
|
|
61397
|
-
cached = null;
|
|
61398
|
-
read(now) {
|
|
61399
|
-
if (this.cached !== null && now - this.cached.at < CAPACITY_PROBE_TTL_MS) {
|
|
61400
|
-
return this.cached.bytes;
|
|
61401
|
-
}
|
|
61402
|
-
let bytes = null;
|
|
61403
|
-
try {
|
|
61404
|
-
if (process.platform === "darwin") {
|
|
61405
|
-
bytes = parseDarwinVmStat(
|
|
61406
|
-
(0, import_node_child_process4.execFileSync)("vm_stat", { encoding: "utf8", timeout: PROBE_TIMEOUT_MS })
|
|
61407
|
-
);
|
|
61408
|
-
} else if (process.platform === "linux") {
|
|
61409
|
-
bytes = parseLinuxMemInfo((0, import_node_fs7.readFileSync)("/proc/meminfo", "utf8"));
|
|
61410
|
-
}
|
|
61411
|
-
} catch {
|
|
61412
|
-
bytes = null;
|
|
61413
|
-
}
|
|
61414
|
-
this.cached = { at: now, bytes };
|
|
61415
|
-
return bytes;
|
|
61416
|
-
}
|
|
61417
|
-
};
|
|
61418
|
-
var availableMemoryProbe = new AvailableMemoryProbe();
|
|
61419
|
-
function readMemoryCapacity() {
|
|
61394
|
+
function readTotalMemoryBytes() {
|
|
61420
61395
|
const constrained = process.constrainedMemory();
|
|
61421
|
-
|
|
61422
|
-
const reported = typeof process.availableMemory === "function" ? process.availableMemory() : (0, import_node_os2.freemem)();
|
|
61423
|
-
const probed = constrained > 0 && process.platform === "linux" ? null : availableMemoryProbe.read(Date.now());
|
|
61424
|
-
const availableBytes = Math.min(totalBytes, Math.max(reported, probed ?? reported));
|
|
61425
|
-
return { totalBytes, availableBytes };
|
|
61396
|
+
return constrained > 0 ? Math.min((0, import_node_os2.totalmem)(), constrained) : (0, import_node_os2.totalmem)();
|
|
61426
61397
|
}
|
|
61427
61398
|
async function processMemoryRows() {
|
|
61428
61399
|
if (process.platform === "win32") {
|
|
@@ -61902,7 +61873,7 @@ var import_promises20 = require("fs/promises");
|
|
|
61902
61873
|
var import_node_path17 = require("path");
|
|
61903
61874
|
|
|
61904
61875
|
// src/platform/service/windows-service.ts
|
|
61905
|
-
var
|
|
61876
|
+
var import_node_fs7 = require("fs");
|
|
61906
61877
|
var import_promises19 = require("fs/promises");
|
|
61907
61878
|
var import_node_path16 = require("path");
|
|
61908
61879
|
|
|
@@ -62132,7 +62103,7 @@ function windowsManager(host, profile) {
|
|
|
62132
62103
|
name: files.runValue,
|
|
62133
62104
|
definitionPath: files.config,
|
|
62134
62105
|
install: async (spec, { restart }) => {
|
|
62135
|
-
if (process.platform === "win32" && !(0,
|
|
62106
|
+
if (process.platform === "win32" && !(0, import_node_fs7.existsSync)(files.helper)) {
|
|
62136
62107
|
throw new RuntimeFault("io_failed", `Windows helper is missing: ${files.helper}`);
|
|
62137
62108
|
}
|
|
62138
62109
|
await (0, import_promises19.mkdir)((0, import_node_path16.dirname)(spec.logPath), { recursive: true });
|
|
@@ -62827,7 +62798,7 @@ function systemAssertionSpawner(log) {
|
|
|
62827
62798
|
// src/platform/spawn-detached.ts
|
|
62828
62799
|
var import_node_child_process8 = require("child_process");
|
|
62829
62800
|
var import_node_crypto12 = require("crypto");
|
|
62830
|
-
var
|
|
62801
|
+
var import_node_fs8 = require("fs");
|
|
62831
62802
|
var import_node_path21 = require("path");
|
|
62832
62803
|
var WINDOWS_UNSAFE_ENV = "NODE_PENDING_PIPE_INSTANCES";
|
|
62833
62804
|
var SYSTEMD_RUN = "systemd-run";
|
|
@@ -62882,8 +62853,8 @@ function isolatedCommand(request2, isolation) {
|
|
|
62882
62853
|
};
|
|
62883
62854
|
}
|
|
62884
62855
|
function spawnDetached(request2, isolation) {
|
|
62885
|
-
(0,
|
|
62886
|
-
const output2 = (0,
|
|
62856
|
+
(0, import_node_fs8.mkdirSync)((0, import_node_path21.dirname)(request2.outputPath), { recursive: true, mode: 448 });
|
|
62857
|
+
const output2 = (0, import_node_fs8.openSync)(request2.outputPath, "a", 384);
|
|
62887
62858
|
const { command, args } = isolatedCommand(request2, isolation);
|
|
62888
62859
|
try {
|
|
62889
62860
|
const child = (0, import_node_child_process8.spawn)(command, args, {
|
|
@@ -62899,7 +62870,7 @@ function spawnDetached(request2, isolation) {
|
|
|
62899
62870
|
child.unref();
|
|
62900
62871
|
return { pid: child.pid };
|
|
62901
62872
|
} finally {
|
|
62902
|
-
(0,
|
|
62873
|
+
(0, import_node_fs8.closeSync)(output2);
|
|
62903
62874
|
}
|
|
62904
62875
|
}
|
|
62905
62876
|
|
|
@@ -62939,7 +62910,7 @@ function createUpdateGate(deps) {
|
|
|
62939
62910
|
|
|
62940
62911
|
// src/platform/wake-clock.ts
|
|
62941
62912
|
var import_node_child_process9 = require("child_process");
|
|
62942
|
-
var
|
|
62913
|
+
var import_node_fs9 = require("fs");
|
|
62943
62914
|
var import_node_readline = require("readline");
|
|
62944
62915
|
var PTP_DEVICE = "/dev/ptp0";
|
|
62945
62916
|
var RESPAWN_BASE_MS = 1e3;
|
|
@@ -63023,7 +62994,7 @@ function systemWakeClockSpawner(log) {
|
|
|
63023
62994
|
function startWakeClock(options) {
|
|
63024
62995
|
const { clock, log } = options;
|
|
63025
62996
|
const platform3 = options.platform ?? process.platform;
|
|
63026
|
-
const hasPtpDevice = options.hasPtpDevice ?? (() => (0,
|
|
62997
|
+
const hasPtpDevice = options.hasPtpDevice ?? (() => (0, import_node_fs9.existsSync)(PTP_DEVICE));
|
|
63027
62998
|
if (platform3 !== "linux" || !hasPtpDevice()) return { [Symbol.dispose]: () => {
|
|
63028
62999
|
} };
|
|
63029
63000
|
const spawner = options.spawner ?? systemWakeClockSpawner(log);
|
|
@@ -65157,7 +65128,7 @@ function fingerprintWholeText(fingerprint) {
|
|
|
65157
65128
|
}
|
|
65158
65129
|
|
|
65159
65130
|
// src/capabilities/native-ingest/hook-config.ts
|
|
65160
|
-
var
|
|
65131
|
+
var import_node_fs10 = require("fs");
|
|
65161
65132
|
var import_node_path28 = require("path");
|
|
65162
65133
|
|
|
65163
65134
|
// src/capabilities/native-ingest/provider-paths.ts
|
|
@@ -65235,9 +65206,9 @@ function hookHandler(provider4, event, options) {
|
|
|
65235
65206
|
return { type: "command", command: posixCommand(argv, environment), timeout: 5 };
|
|
65236
65207
|
}
|
|
65237
65208
|
function readSettings(path4, backupWhenMalformed, now) {
|
|
65238
|
-
if (!(0,
|
|
65209
|
+
if (!(0, import_node_fs10.existsSync)(path4)) return {};
|
|
65239
65210
|
try {
|
|
65240
|
-
const value2 = JSON.parse((0,
|
|
65211
|
+
const value2 = JSON.parse((0, import_node_fs10.readFileSync)(path4, "utf8"));
|
|
65241
65212
|
if (!isRecord4(value2)) throw new Error("settings root must be an object");
|
|
65242
65213
|
if (value2.hooks !== void 0 && !isRecord4(value2.hooks)) {
|
|
65243
65214
|
throw new Error("settings `hooks` must be an object");
|
|
@@ -65247,7 +65218,7 @@ function readSettings(path4, backupWhenMalformed, now) {
|
|
|
65247
65218
|
const reason = error62 instanceof Error ? error62.message : String(error62);
|
|
65248
65219
|
if (!backupWhenMalformed) throw new Error(`${path4} is malformed: ${reason}`);
|
|
65249
65220
|
const backup = `${path4}.malformed-${now}.bak`;
|
|
65250
|
-
(0,
|
|
65221
|
+
(0, import_node_fs10.copyFileSync)(path4, backup);
|
|
65251
65222
|
throw new Error(`${path4} is malformed and was copied to ${backup}: ${reason}`);
|
|
65252
65223
|
}
|
|
65253
65224
|
}
|
|
@@ -65255,14 +65226,14 @@ function hooksOf(settings2) {
|
|
|
65255
65226
|
return isRecord4(settings2.hooks) ? settings2.hooks : {};
|
|
65256
65227
|
}
|
|
65257
65228
|
function writeSettings(path4, settings2) {
|
|
65258
|
-
(0,
|
|
65229
|
+
(0, import_node_fs10.mkdirSync)((0, import_node_path28.dirname)(path4), { recursive: true, mode: 448 });
|
|
65259
65230
|
const temporary = `${path4}.${process.pid}.tmp`;
|
|
65260
65231
|
try {
|
|
65261
|
-
(0,
|
|
65232
|
+
(0, import_node_fs10.writeFileSync)(temporary, `${JSON.stringify(settings2, null, 2)}
|
|
65262
65233
|
`, { mode: 384 });
|
|
65263
|
-
(0,
|
|
65234
|
+
(0, import_node_fs10.renameSync)(temporary, path4);
|
|
65264
65235
|
} finally {
|
|
65265
|
-
(0,
|
|
65236
|
+
(0, import_node_fs10.rmSync)(temporary, { force: true });
|
|
65266
65237
|
}
|
|
65267
65238
|
}
|
|
65268
65239
|
function isIngestionHandler(handler) {
|
|
@@ -65307,7 +65278,7 @@ function installIngestionHooks(provider4, options, now) {
|
|
|
65307
65278
|
}
|
|
65308
65279
|
function removeIngestionHooks(provider4, where, now) {
|
|
65309
65280
|
const path4 = providerHookSettingsPath(provider4, where);
|
|
65310
|
-
if (!(0,
|
|
65281
|
+
if (!(0, import_node_fs10.existsSync)(path4)) return { provider: provider4, path: path4, changed: false };
|
|
65311
65282
|
const settings2 = readSettings(path4, true, now);
|
|
65312
65283
|
const hooks = hooksOf(settings2);
|
|
65313
65284
|
const nextHooks = {};
|
|
@@ -65344,7 +65315,7 @@ function ingestionHookStatus(provider4, options) {
|
|
|
65344
65315
|
}
|
|
65345
65316
|
|
|
65346
65317
|
// src/capabilities/native-ingest/hook-input.ts
|
|
65347
|
-
var
|
|
65318
|
+
var import_node_fs11 = require("fs");
|
|
65348
65319
|
var import_node_path29 = require("path");
|
|
65349
65320
|
var ALAN_MANAGED_SESSION_ENV = "ALAN_MANAGED_SESSION";
|
|
65350
65321
|
var MAX_HOOK_STDIN_BYTES = 256 * 1024 * 1024;
|
|
@@ -65444,10 +65415,10 @@ function hookPayload(input2) {
|
|
|
65444
65415
|
}
|
|
65445
65416
|
function realpathOrSelf(path4) {
|
|
65446
65417
|
try {
|
|
65447
|
-
return (0,
|
|
65418
|
+
return (0, import_node_fs11.realpathSync)(path4);
|
|
65448
65419
|
} catch {
|
|
65449
65420
|
try {
|
|
65450
|
-
return (0, import_node_path29.join)((0,
|
|
65421
|
+
return (0, import_node_path29.join)((0, import_node_fs11.realpathSync)((0, import_node_path29.dirname)(path4)), (0, import_node_path29.basename)(path4));
|
|
65451
65422
|
} catch {
|
|
65452
65423
|
return path4;
|
|
65453
65424
|
}
|
|
@@ -65478,7 +65449,7 @@ function parseHookSignal(input2) {
|
|
|
65478
65449
|
}
|
|
65479
65450
|
|
|
65480
65451
|
// src/capabilities/native-ingest/ingest.ts
|
|
65481
|
-
var
|
|
65452
|
+
var import_node_fs12 = require("fs");
|
|
65482
65453
|
|
|
65483
65454
|
// ../shared/dist/types/native-agent-session.js
|
|
65484
65455
|
var nativeAgentProviderBackendKinds = {
|
|
@@ -66248,7 +66219,7 @@ function workerKey(provider4, externalSessionId) {
|
|
|
66248
66219
|
return `${provider4}\0${externalSessionId}`;
|
|
66249
66220
|
}
|
|
66250
66221
|
function holdFor(entry) {
|
|
66251
|
-
const stats = (0,
|
|
66222
|
+
const stats = (0, import_node_fs12.statSync)(entry.transcriptPath, { bigint: true, throwIfNoEntry: false });
|
|
66252
66223
|
if (!stats) return [];
|
|
66253
66224
|
return [
|
|
66254
66225
|
{
|
|
@@ -66449,7 +66420,7 @@ async function startNativeIngest(deps) {
|
|
|
66449
66420
|
return "accepted";
|
|
66450
66421
|
};
|
|
66451
66422
|
const hasUnreadBytes = (entry, now) => {
|
|
66452
|
-
const stats = (0,
|
|
66423
|
+
const stats = (0, import_node_fs12.statSync)(entry.transcriptPath, { bigint: true, throwIfNoEntry: false });
|
|
66453
66424
|
if (!stats || now - Number(stats.mtimeMs) > timing.sweepRecencyMs) return false;
|
|
66454
66425
|
const replaced = String(stats.dev) !== entry.device || String(stats.ino) !== entry.inode;
|
|
66455
66426
|
return replaced || Number(stats.size) > entry.cursor.offset;
|
|
@@ -66493,7 +66464,7 @@ async function startNativeIngest(deps) {
|
|
|
66493
66464
|
const recordAlanRun = async (hold, runId) => {
|
|
66494
66465
|
const entry = store.get(hold.provider, hold.externalSessionId);
|
|
66495
66466
|
if (!entry || entry.dead) return;
|
|
66496
|
-
const stats = (0,
|
|
66467
|
+
const stats = (0, import_node_fs12.statSync)(entry.transcriptPath, { bigint: true, throwIfNoEntry: false });
|
|
66497
66468
|
if (!stats) return;
|
|
66498
66469
|
const identity = { device: String(stats.dev), inode: String(stats.ino) };
|
|
66499
66470
|
const size = Number(stats.size);
|
|
@@ -66567,7 +66538,7 @@ async function startNativeIngest(deps) {
|
|
|
66567
66538
|
init_alan_code();
|
|
66568
66539
|
|
|
66569
66540
|
// src/capabilities/providers/commands.ts
|
|
66570
|
-
var
|
|
66541
|
+
var import_node_fs13 = require("fs");
|
|
66571
66542
|
var import_promises35 = require("fs/promises");
|
|
66572
66543
|
var import_node_path32 = require("path");
|
|
66573
66544
|
var PROVIDER_COMMANDS = [
|
|
@@ -66605,7 +66576,7 @@ function pathDelimiter(platform3) {
|
|
|
66605
66576
|
async function isRunnable(path4, platform3) {
|
|
66606
66577
|
try {
|
|
66607
66578
|
if (!(await (0, import_promises35.stat)(path4)).isFile()) return false;
|
|
66608
|
-
if (platform3 !== "win32") await (0, import_promises35.access)(path4,
|
|
66579
|
+
if (platform3 !== "win32") await (0, import_promises35.access)(path4, import_node_fs13.constants.X_OK);
|
|
66609
66580
|
return true;
|
|
66610
66581
|
} catch {
|
|
66611
66582
|
return false;
|
|
@@ -66788,7 +66759,7 @@ init_runtime_v2();
|
|
|
66788
66759
|
|
|
66789
66760
|
// src/capabilities/providers/account-label.ts
|
|
66790
66761
|
var import_node_child_process12 = require("child_process");
|
|
66791
|
-
var
|
|
66762
|
+
var import_node_fs14 = require("fs");
|
|
66792
66763
|
var import_node_path33 = require("path");
|
|
66793
66764
|
var import_node_url3 = require("url");
|
|
66794
66765
|
var ACCOUNT_TIMEOUT_MS = 2e4;
|
|
@@ -66891,7 +66862,7 @@ async function claudeLabel(executable, env) {
|
|
|
66891
66862
|
const childEnv = { ...env };
|
|
66892
66863
|
delete childEnv.FORCE_CODE_TERMINAL;
|
|
66893
66864
|
const bundledSdk = typeof __dirname === "string" ? (0, import_node_path33.join)(__dirname, "claude-sdk.mjs") : "";
|
|
66894
|
-
const sdkSpecifier = (0,
|
|
66865
|
+
const sdkSpecifier = (0, import_node_fs14.existsSync)(bundledSdk) ? (0, import_node_url3.pathToFileURL)(bundledSdk).href : "@anthropic-ai/claude-agent-sdk";
|
|
66895
66866
|
const { query } = await import(sdkSpecifier);
|
|
66896
66867
|
const session = query({
|
|
66897
66868
|
prompt: idlePrompt(abort.signal),
|
|
@@ -67301,7 +67272,7 @@ var import_node_path37 = require("path");
|
|
|
67301
67272
|
// ../shared/dist/node/shell-environment.js
|
|
67302
67273
|
var import_node_child_process13 = require("child_process");
|
|
67303
67274
|
var import_node_crypto16 = require("crypto");
|
|
67304
|
-
var
|
|
67275
|
+
var import_node_fs16 = require("fs");
|
|
67305
67276
|
var import_node_os6 = require("os");
|
|
67306
67277
|
var import_node_path36 = require("path");
|
|
67307
67278
|
|
|
@@ -67310,7 +67281,7 @@ var import_node_os5 = require("os");
|
|
|
67310
67281
|
var import_node_path35 = require("path");
|
|
67311
67282
|
|
|
67312
67283
|
// ../shared/dist/node/version-manager-paths.js
|
|
67313
|
-
var
|
|
67284
|
+
var import_node_fs15 = require("fs");
|
|
67314
67285
|
var import_node_path34 = require("path");
|
|
67315
67286
|
function compareNodeVersionsDesc(a, b) {
|
|
67316
67287
|
const parse7 = (value2) => value2.replace(/^v/, "").split(".").map((part) => Number.parseInt(part, 10) || 0);
|
|
@@ -67325,19 +67296,19 @@ function compareNodeVersionsDesc(a, b) {
|
|
|
67325
67296
|
}
|
|
67326
67297
|
function resolveNvmDefaultBin(home) {
|
|
67327
67298
|
const versionsDir = (0, import_node_path34.join)(home, ".nvm", "versions", "node");
|
|
67328
|
-
if (!(0,
|
|
67299
|
+
if (!(0, import_node_fs15.existsSync)(versionsDir))
|
|
67329
67300
|
return null;
|
|
67330
67301
|
let alias = null;
|
|
67331
67302
|
try {
|
|
67332
67303
|
const aliasFile = (0, import_node_path34.join)(home, ".nvm", "alias", "default");
|
|
67333
|
-
if ((0,
|
|
67334
|
-
alias = (0,
|
|
67304
|
+
if ((0, import_node_fs15.existsSync)(aliasFile))
|
|
67305
|
+
alias = (0, import_node_fs15.readFileSync)(aliasFile, "utf8").trim();
|
|
67335
67306
|
} catch {
|
|
67336
67307
|
alias = null;
|
|
67337
67308
|
}
|
|
67338
67309
|
let installed;
|
|
67339
67310
|
try {
|
|
67340
|
-
installed = (0,
|
|
67311
|
+
installed = (0, import_node_fs15.readdirSync)(versionsDir).filter((entry) => entry.startsWith("v"));
|
|
67341
67312
|
} catch {
|
|
67342
67313
|
return null;
|
|
67343
67314
|
}
|
|
@@ -67348,7 +67319,7 @@ function resolveNvmDefaultBin(home) {
|
|
|
67348
67319
|
if (!chosen)
|
|
67349
67320
|
return null;
|
|
67350
67321
|
const bin = (0, import_node_path34.join)(versionsDir, chosen, "bin");
|
|
67351
|
-
return (0,
|
|
67322
|
+
return (0, import_node_fs15.existsSync)(bin) ? bin : null;
|
|
67352
67323
|
}
|
|
67353
67324
|
function resolveVersionManagerBinDirs(home, platform3 = process.platform) {
|
|
67354
67325
|
if (platform3 === "win32")
|
|
@@ -67367,7 +67338,7 @@ function resolveVersionManagerBinDirs(home, platform3 = process.platform) {
|
|
|
67367
67338
|
if (!dir || seen.has(dir))
|
|
67368
67339
|
continue;
|
|
67369
67340
|
seen.add(dir);
|
|
67370
|
-
if ((0,
|
|
67341
|
+
if ((0, import_node_fs15.existsSync)(dir))
|
|
67371
67342
|
resolved.push(dir);
|
|
67372
67343
|
}
|
|
67373
67344
|
return resolved;
|
|
@@ -67409,7 +67380,7 @@ function promoteUserBinDirs(path4, home, versionManagerDirs) {
|
|
|
67409
67380
|
// ../shared/dist/node/shell-environment.js
|
|
67410
67381
|
function isExecutableFile(path4) {
|
|
67411
67382
|
try {
|
|
67412
|
-
(0,
|
|
67383
|
+
(0, import_node_fs16.accessSync)(path4, import_node_fs16.constants.X_OK);
|
|
67413
67384
|
return true;
|
|
67414
67385
|
} catch {
|
|
67415
67386
|
return false;
|
|
@@ -69319,7 +69290,7 @@ async function publishLocalSkill(options) {
|
|
|
69319
69290
|
|
|
69320
69291
|
// src/capabilities/skills/native-index.ts
|
|
69321
69292
|
var import_node_crypto23 = require("crypto");
|
|
69322
|
-
var
|
|
69293
|
+
var import_node_fs17 = require("fs");
|
|
69323
69294
|
var import_promises45 = require("fs/promises");
|
|
69324
69295
|
var import_node_path45 = require("path");
|
|
69325
69296
|
var ALAN_SKILLS_PLUGIN_NAME = "alan";
|
|
@@ -69470,7 +69441,7 @@ async function reconcileNativeIndex(layout, installed, options) {
|
|
|
69470
69441
|
};
|
|
69471
69442
|
}
|
|
69472
69443
|
function installedSkillFolders(layout) {
|
|
69473
|
-
return (0,
|
|
69444
|
+
return (0, import_node_fs17.existsSync)((0, import_node_path45.join)(layout.pluginDir, ".claude-plugin", "plugin.json")) ? { pluginDir: layout.pluginDir, skillsDir: layout.pluginSkillsDir } : null;
|
|
69474
69445
|
}
|
|
69475
69446
|
|
|
69476
69447
|
// src/capabilities/skills/sync.ts
|
|
@@ -71359,10 +71330,10 @@ async function reapLeftoverEngines(path4, options) {
|
|
|
71359
71330
|
}
|
|
71360
71331
|
|
|
71361
71332
|
// src/holder/launch-command.ts
|
|
71362
|
-
var
|
|
71333
|
+
var import_node_fs18 = require("fs");
|
|
71363
71334
|
var import_node_path53 = require("path");
|
|
71364
71335
|
var HOLDER_BUNDLE = "alan-holder.cjs";
|
|
71365
|
-
function holderArguments(runtimeArgs, nodeFlags, exists6 =
|
|
71336
|
+
function holderArguments(runtimeArgs, nodeFlags, exists6 = import_node_fs18.existsSync) {
|
|
71366
71337
|
const bundle = runtimeArgs.at(-1);
|
|
71367
71338
|
const lean = bundle === void 0 ? void 0 : (0, import_node_path53.join)((0, import_node_path53.dirname)(bundle), HOLDER_BUNDLE);
|
|
71368
71339
|
const script = lean !== void 0 && exists6(lean) ? [...runtimeArgs.slice(0, -1), lean] : runtimeArgs;
|
|
@@ -71501,20 +71472,20 @@ async function prepareRunInputs(spec, { source, tmpDir, signal, skills = [] }) {
|
|
|
71501
71472
|
|
|
71502
71473
|
// src/holder/serve.ts
|
|
71503
71474
|
var import_node_crypto30 = require("crypto");
|
|
71504
|
-
var
|
|
71475
|
+
var import_node_fs23 = require("fs");
|
|
71505
71476
|
var import_node_net3 = require("net");
|
|
71506
71477
|
var import_node_path66 = require("path");
|
|
71507
71478
|
init_runtime_v2();
|
|
71508
71479
|
|
|
71509
71480
|
// src/holder/admission.ts
|
|
71510
|
-
var
|
|
71481
|
+
var import_node_fs20 = require("fs");
|
|
71511
71482
|
var import_promises61 = require("fs/promises");
|
|
71512
71483
|
var import_node_os10 = require("os");
|
|
71513
71484
|
var import_node_path60 = require("path");
|
|
71514
71485
|
init_constants();
|
|
71515
71486
|
|
|
71516
71487
|
// ../shared/dist/node/local-workspace.js
|
|
71517
|
-
var
|
|
71488
|
+
var import_node_fs19 = require("fs");
|
|
71518
71489
|
var import_node_os9 = require("os");
|
|
71519
71490
|
var import_node_path55 = require("path");
|
|
71520
71491
|
function resolveAlanDefaultWorkspacePath(homeDirectory = (0, import_node_os9.homedir)()) {
|
|
@@ -71742,18 +71713,16 @@ async function switchTo(checkout, current, operationId, deps, signal) {
|
|
|
71742
71713
|
async function applyRequestedCheckout(checkout, spec, deps, signal) {
|
|
71743
71714
|
try {
|
|
71744
71715
|
if (!await isCheckout(checkout.path)) return await clone2(checkout, deps, signal);
|
|
71745
|
-
const
|
|
71746
|
-
if (
|
|
71747
|
-
if (status.branch === checkout.branch) return { kind: "on_branch" };
|
|
71748
|
-
if (status.dirty) return notSwitched(checkout, status.branch, "it has uncommitted changes");
|
|
71716
|
+
const branch = await currentBranch(deps.git, checkout.path, signal);
|
|
71717
|
+
if (branch === checkout.branch) return { kind: "on_branch" };
|
|
71749
71718
|
if (!await claimFirstLease(deps.dir, checkout.path)) {
|
|
71750
71719
|
return notSwitched(
|
|
71751
71720
|
checkout,
|
|
71752
|
-
|
|
71721
|
+
branch,
|
|
71753
71722
|
"an earlier conversation on this machine already uses it"
|
|
71754
71723
|
);
|
|
71755
71724
|
}
|
|
71756
|
-
return await switchTo(checkout,
|
|
71725
|
+
return await switchTo(checkout, branch, `checkout-${spec.runId}`, deps, signal);
|
|
71757
71726
|
} catch (error62) {
|
|
71758
71727
|
return noted(
|
|
71759
71728
|
`could not be put on ${checkout.branch}, the branch picked for this chat`,
|
|
@@ -71784,15 +71753,13 @@ async function fastForward(freshness, operationId, deps, signal) {
|
|
|
71784
71753
|
const attempt2 = await deps.locks.tryExclusive(snapshot.commonDir, operationId);
|
|
71785
71754
|
if (attempt2.kind === "busy") return false;
|
|
71786
71755
|
const _lock = __using(_stack, attempt2.lock, true);
|
|
71787
|
-
const
|
|
71788
|
-
|
|
71789
|
-
|
|
71790
|
-
|
|
71791
|
-
|
|
71792
|
-
if (
|
|
71793
|
-
|
|
71794
|
-
const back = await git(["switch", "--quiet", snapshot.branch]);
|
|
71795
|
-
return moved.exitCode === 0 && back.exitCode === 0;
|
|
71756
|
+
const head = await deps.git.run(
|
|
71757
|
+
{ cwd, args: ["rev-parse", "--verify", "HEAD"], readOnly: true },
|
|
71758
|
+
signal
|
|
71759
|
+
);
|
|
71760
|
+
if (head.exitCode !== 0 || head.stdout.trim() !== snapshot.head) return false;
|
|
71761
|
+
if (await currentBranch(deps.git, cwd, signal) !== snapshot.branch) return false;
|
|
71762
|
+
return moveSnapshotTo(deps.git, cwd, snapshot, tip, signal);
|
|
71796
71763
|
} catch (_) {
|
|
71797
71764
|
var _error = _, _hasError = true;
|
|
71798
71765
|
} finally {
|
|
@@ -71843,13 +71810,15 @@ async function applyRequestedCheckouts(spec, deps, signal) {
|
|
|
71843
71810
|
const settled2 = /* @__PURE__ */ new Set();
|
|
71844
71811
|
const problems = [];
|
|
71845
71812
|
for (const checkout of requestedCheckoutsOf(spec, deps.log)) {
|
|
71813
|
+
const startedAt = Date.now();
|
|
71846
71814
|
const outcome2 = await applyRequestedCheckout(checkout, spec, deps, signal);
|
|
71847
71815
|
deps.log.info("workspace.requested_checkout", {
|
|
71848
71816
|
runId: spec.runId,
|
|
71849
71817
|
path: checkout.path,
|
|
71850
71818
|
branch: checkout.branch,
|
|
71851
71819
|
outcome: outcome2.kind,
|
|
71852
|
-
...outcome2.kind === "moved" ? { how: outcome2.how } : {}
|
|
71820
|
+
...outcome2.kind === "moved" ? { how: outcome2.how } : {},
|
|
71821
|
+
ms: Date.now() - startedAt
|
|
71853
71822
|
});
|
|
71854
71823
|
if (outcome2.kind === "on_branch") continue;
|
|
71855
71824
|
settled2.add((0, import_node_path59.resolve)(checkout.path));
|
|
@@ -71865,6 +71834,7 @@ async function refreshSnapshotCheckouts(spec, targets, settled2, deps, signal) {
|
|
|
71865
71834
|
if (settled2.has((0, import_node_path59.resolve)(target))) continue;
|
|
71866
71835
|
const freshness = await readCheckoutFreshness(deps.dir, target);
|
|
71867
71836
|
if (freshness === null) continue;
|
|
71837
|
+
const startedAt = Date.now();
|
|
71868
71838
|
const outcome2 = await atFirstLease(freshness, spec, deps, signal).catch(
|
|
71869
71839
|
() => "noted"
|
|
71870
71840
|
);
|
|
@@ -71873,7 +71843,8 @@ async function refreshSnapshotCheckouts(spec, targets, settled2, deps, signal) {
|
|
|
71873
71843
|
runId: spec.runId,
|
|
71874
71844
|
path: freshness.path,
|
|
71875
71845
|
state: freshness.state,
|
|
71876
|
-
outcome: outcome2
|
|
71846
|
+
outcome: outcome2,
|
|
71847
|
+
ms: Date.now() - startedAt
|
|
71877
71848
|
});
|
|
71878
71849
|
}
|
|
71879
71850
|
return problems;
|
|
@@ -71934,7 +71905,7 @@ async function inspectReadiness(path4) {
|
|
|
71934
71905
|
if (!(await (0, import_promises61.stat)(path4)).isDirectory()) {
|
|
71935
71906
|
return { ready: false, missing: true, message: MESSAGES.missing };
|
|
71936
71907
|
}
|
|
71937
|
-
await (0, import_promises61.access)(path4,
|
|
71908
|
+
await (0, import_promises61.access)(path4, import_node_fs20.constants.R_OK | import_node_fs20.constants.W_OK | import_node_fs20.constants.X_OK);
|
|
71938
71909
|
return { ready: true };
|
|
71939
71910
|
} catch (error62) {
|
|
71940
71911
|
const code = errnoCode(error62) ?? "";
|
|
@@ -71979,7 +71950,7 @@ async function admitDefaultWorkspace(spec, context, skills) {
|
|
|
71979
71950
|
const path4 = resolveAlanDefaultWorkspacePath(env.HOME || env.USERPROFILE || (0, import_node_os10.homedir)());
|
|
71980
71951
|
try {
|
|
71981
71952
|
await (0, import_promises61.mkdir)(path4, { recursive: true, mode: 448 });
|
|
71982
|
-
await (0, import_promises61.access)(path4,
|
|
71953
|
+
await (0, import_promises61.access)(path4, import_node_fs20.constants.R_OK | import_node_fs20.constants.W_OK | import_node_fs20.constants.X_OK);
|
|
71983
71954
|
return { kind: "admitted", spec: { ...spec, projectPath: path4 }, skills };
|
|
71984
71955
|
} catch (error62) {
|
|
71985
71956
|
const code = errnoCode(error62);
|
|
@@ -72228,7 +72199,7 @@ ${added.join("\n")}
|
|
|
72228
72199
|
|
|
72229
72200
|
// src/run-log/complete.ts
|
|
72230
72201
|
var import_node_crypto29 = require("crypto");
|
|
72231
|
-
var
|
|
72202
|
+
var import_node_fs21 = require("fs");
|
|
72232
72203
|
var import_node_path63 = require("path");
|
|
72233
72204
|
|
|
72234
72205
|
// src/run-log/directory.ts
|
|
@@ -72279,23 +72250,23 @@ async function isRunClaimed(runsDir, runId) {
|
|
|
72279
72250
|
// src/run-log/complete.ts
|
|
72280
72251
|
function writeLogFile(path4, dir, text3) {
|
|
72281
72252
|
const temp = (0, import_node_path63.join)(dir, `.log.${(0, import_node_crypto29.randomUUID)()}.tmp`);
|
|
72282
|
-
const fd = (0,
|
|
72253
|
+
const fd = (0, import_node_fs21.openSync)(temp, "wx", 384);
|
|
72283
72254
|
try {
|
|
72284
|
-
(0,
|
|
72285
|
-
(0,
|
|
72255
|
+
(0, import_node_fs21.writeSync)(fd, text3);
|
|
72256
|
+
(0, import_node_fs21.fsyncSync)(fd);
|
|
72286
72257
|
} finally {
|
|
72287
|
-
(0,
|
|
72258
|
+
(0, import_node_fs21.closeSync)(fd);
|
|
72288
72259
|
}
|
|
72289
72260
|
try {
|
|
72290
|
-
(0,
|
|
72261
|
+
(0, import_node_fs21.renameSync)(temp, path4);
|
|
72291
72262
|
} finally {
|
|
72292
|
-
(0,
|
|
72263
|
+
(0, import_node_fs21.rmSync)(temp, { force: true });
|
|
72293
72264
|
}
|
|
72294
72265
|
}
|
|
72295
72266
|
async function writeCompleteRunLog(runsDir, meta3, records) {
|
|
72296
72267
|
const paths = runDirectory(runsDir, meta3.runId);
|
|
72297
72268
|
if (!await isRunClaimed(runsDir, meta3.runId)) {
|
|
72298
|
-
(0,
|
|
72269
|
+
(0, import_node_fs21.mkdirSync)(paths.dir, { recursive: true, mode: 448 });
|
|
72299
72270
|
const text3 = records.map((record2, index) => {
|
|
72300
72271
|
const line = { seq: index + 1, at: record2.at, update: record2.update };
|
|
72301
72272
|
return `${JSON.stringify(line)}
|
|
@@ -72552,13 +72523,13 @@ function runEnded(input2) {
|
|
|
72552
72523
|
var decoder = new TextDecoder();
|
|
72553
72524
|
|
|
72554
72525
|
// src/run-log/writer.ts
|
|
72555
|
-
var
|
|
72526
|
+
var import_node_fs22 = require("fs");
|
|
72556
72527
|
var import_node_path65 = require("path");
|
|
72557
72528
|
init_runtime_v2();
|
|
72558
72529
|
function lastSeq(fd, size) {
|
|
72559
72530
|
for (const length of tailWindows(size)) {
|
|
72560
72531
|
const buffer = Buffer.alloc(length);
|
|
72561
|
-
(0,
|
|
72532
|
+
(0, import_node_fs22.readSync)(fd, buffer, 0, length, size - length);
|
|
72562
72533
|
const last = lastLine(buffer.toString("utf8").trimEnd(), length === size);
|
|
72563
72534
|
if (last === void 0) continue;
|
|
72564
72535
|
if (last.length === 0) return 0;
|
|
@@ -72569,13 +72540,13 @@ function lastSeq(fd, size) {
|
|
|
72569
72540
|
throw new RuntimeFault("record_too_large", "Run log tail record is larger than any record");
|
|
72570
72541
|
}
|
|
72571
72542
|
function openRunLog(path4, clock) {
|
|
72572
|
-
(0,
|
|
72573
|
-
const fd = (0,
|
|
72574
|
-
let size = (0,
|
|
72543
|
+
(0, import_node_fs22.mkdirSync)((0, import_node_path65.dirname)(path4), { recursive: true, mode: 448 });
|
|
72544
|
+
const fd = (0, import_node_fs22.openSync)(path4, "a+", 384);
|
|
72545
|
+
let size = (0, import_node_fs22.fstatSync)(fd).size;
|
|
72575
72546
|
let seq = lastSeq(fd, size);
|
|
72576
72547
|
let dirty = false;
|
|
72577
72548
|
const sync = () => {
|
|
72578
|
-
(0,
|
|
72549
|
+
(0, import_node_fs22.fsyncSync)(fd);
|
|
72579
72550
|
dirty = false;
|
|
72580
72551
|
};
|
|
72581
72552
|
return {
|
|
@@ -72589,7 +72560,7 @@ function openRunLog(path4, clock) {
|
|
|
72589
72560
|
};
|
|
72590
72561
|
const line = Buffer.from(`${JSON.stringify(record2)}
|
|
72591
72562
|
`, "utf8");
|
|
72592
|
-
(0,
|
|
72563
|
+
(0, import_node_fs22.writeSync)(fd, line);
|
|
72593
72564
|
size += line.length;
|
|
72594
72565
|
dirty = true;
|
|
72595
72566
|
if (isRunLifecycleKind(update.sessionUpdate)) sync();
|
|
@@ -72601,7 +72572,7 @@ function openRunLog(path4, clock) {
|
|
|
72601
72572
|
},
|
|
72602
72573
|
[Symbol.dispose]: () => {
|
|
72603
72574
|
if (dirty) sync();
|
|
72604
|
-
(0,
|
|
72575
|
+
(0, import_node_fs22.closeSync)(fd);
|
|
72605
72576
|
}
|
|
72606
72577
|
};
|
|
72607
72578
|
}
|
|
@@ -72664,20 +72635,17 @@ async function runWithInputs({ spec, skills }, context, sink, signal) {
|
|
|
72664
72635
|
message: `Could not fetch this run's attachments or provider credential: ${error62 instanceof Error ? error62.message : String(error62)}`
|
|
72665
72636
|
};
|
|
72666
72637
|
}
|
|
72667
|
-
const agentContext = await sessionContext;
|
|
72668
72638
|
const prepared = __using(_stack, inputs, true);
|
|
72669
|
-
const result = await context.driver.runTurn(
|
|
72670
|
-
|
|
72671
|
-
|
|
72672
|
-
|
|
72673
|
-
|
|
72674
|
-
|
|
72675
|
-
agentContext: {
|
|
72676
|
-
full: agentContext.full,
|
|
72677
|
-
...agentContext.update ? { update: agentContext.update } : {}
|
|
72639
|
+
const result = await context.driver.runTurn(spec, sink, signal, {
|
|
72640
|
+
...prepared,
|
|
72641
|
+
agentContext: sessionContext.then(
|
|
72642
|
+
(agentContext2) => agentContext2 === void 0 ? void 0 : {
|
|
72643
|
+
full: agentContext2.full,
|
|
72644
|
+
...agentContext2.update ? { update: agentContext2.update } : {}
|
|
72678
72645
|
}
|
|
72679
|
-
|
|
72680
|
-
);
|
|
72646
|
+
)
|
|
72647
|
+
});
|
|
72648
|
+
const agentContext = await sessionContext;
|
|
72681
72649
|
if (agentContext !== void 0 && result.outcome !== "rejected") {
|
|
72682
72650
|
await agentContext.save().catch((error62) => {
|
|
72683
72651
|
context.log.warn("holder.agent_context_save_failed", { runId: spec.runId, error: error62 });
|
|
@@ -73045,7 +73013,7 @@ async function runHolder({
|
|
|
73045
73013
|
for (const client of holder.clients) client.end();
|
|
73046
73014
|
await new Promise((resolve13) => server.close(() => resolve13()));
|
|
73047
73015
|
await statusWrites;
|
|
73048
|
-
(0,
|
|
73016
|
+
(0, import_node_fs23.rmSync)(launch.statusPath, { force: true });
|
|
73049
73017
|
log.info("holder.suspended", { conversationId: launch.conversationId });
|
|
73050
73018
|
} catch (_) {
|
|
73051
73019
|
var _error = _, _hasError = true;
|
|
@@ -73055,14 +73023,6 @@ async function runHolder({
|
|
|
73055
73023
|
}
|
|
73056
73024
|
|
|
73057
73025
|
// src/sessions/admission.ts
|
|
73058
|
-
var GIB = 1024 ** 3;
|
|
73059
|
-
var MIN_RUN_BYTES = 1.25 * GIB;
|
|
73060
|
-
function memoryAllowsStart(capacity, activeRuns, pendingStarts = 0) {
|
|
73061
|
-
if (activeRuns + pendingStarts === 0) return true;
|
|
73062
|
-
const headroom = Math.max(512 * 1024 ** 2, capacity.totalBytes * 0.2);
|
|
73063
|
-
const slots = Math.max(1, Math.floor((capacity.totalBytes - headroom) / MIN_RUN_BYTES));
|
|
73064
|
-
return activeRuns + pendingStarts < slots && capacity.availableBytes >= MIN_RUN_BYTES * (pendingStarts + 1);
|
|
73065
|
-
}
|
|
73066
73026
|
function runOccupancy(held, reserved, exclude = null) {
|
|
73067
73027
|
const active = new Set(
|
|
73068
73028
|
held.filter((run2) => run2.state === "running" && run2.runId !== exclude).map((run2) => run2.runId)
|
|
@@ -73075,11 +73035,11 @@ function runOccupancy(held, reserved, exclude = null) {
|
|
|
73075
73035
|
}
|
|
73076
73036
|
|
|
73077
73037
|
// src/sessions/suspend-policy.ts
|
|
73078
|
-
var
|
|
73079
|
-
var SESSION_MEMORY_CEILING_BYTES = 2.5 *
|
|
73038
|
+
var GIB = 1024 ** 3;
|
|
73039
|
+
var SESSION_MEMORY_CEILING_BYTES = 2.5 * GIB;
|
|
73080
73040
|
var MEMORY_BUDGET_SHARE = 0.15;
|
|
73081
|
-
var MEMORY_BUDGET_MIN_BYTES =
|
|
73082
|
-
var MEMORY_BUDGET_MAX_BYTES = 4 *
|
|
73041
|
+
var MEMORY_BUDGET_MIN_BYTES = GIB;
|
|
73042
|
+
var MEMORY_BUDGET_MAX_BYTES = 4 * GIB;
|
|
73083
73043
|
function memoryBudgetFor(totalMemoryBytes) {
|
|
73084
73044
|
const share = Math.round(totalMemoryBytes * MEMORY_BUDGET_SHARE);
|
|
73085
73045
|
return Math.min(MEMORY_BUDGET_MAX_BYTES, Math.max(MEMORY_BUDGET_MIN_BYTES, share));
|
|
@@ -73192,8 +73152,8 @@ async function openSessions(deps) {
|
|
|
73192
73152
|
const retiring = /* @__PURE__ */ new Map();
|
|
73193
73153
|
const legacy = /* @__PURE__ */ new Map();
|
|
73194
73154
|
const maxActiveRuns = deps.maxActiveRuns ?? DEFAULT_MAX_ACTIVE_RUNS;
|
|
73195
|
-
const
|
|
73196
|
-
const suspendPolicy = deps.suspendPolicy ?? defaultSuspendPolicy(
|
|
73155
|
+
const totalMemoryBytes = deps.totalMemoryBytes ?? readTotalMemoryBytes;
|
|
73156
|
+
const suspendPolicy = deps.suspendPolicy ?? defaultSuspendPolicy(totalMemoryBytes());
|
|
73197
73157
|
const admitted = /* @__PURE__ */ new Set();
|
|
73198
73158
|
let admitting = Promise.resolve();
|
|
73199
73159
|
const memoryPressure = deps.memoryPressure ?? readMemoryPressure;
|
|
@@ -73475,8 +73435,7 @@ async function openSessions(deps) {
|
|
|
73475
73435
|
const claim2 = admitting.then(async () => {
|
|
73476
73436
|
const held = await heldRuns();
|
|
73477
73437
|
const { active, pending } = runOccupancy(held, [...admitted, ...launched.keys()], runId);
|
|
73478
|
-
if (active + pending >= maxActiveRuns
|
|
73479
|
-
return false;
|
|
73438
|
+
if (active + pending >= maxActiveRuns) return false;
|
|
73480
73439
|
admitted.add(runId);
|
|
73481
73440
|
return true;
|
|
73482
73441
|
});
|
|
@@ -73501,20 +73460,12 @@ async function openSessions(deps) {
|
|
|
73501
73460
|
return "started";
|
|
73502
73461
|
}
|
|
73503
73462
|
if (!await claimCapacity(run2.runId)) {
|
|
73504
|
-
const capacity = memoryCapacity();
|
|
73505
73463
|
const { active, pending } = runOccupancy(
|
|
73506
73464
|
await heldRuns(),
|
|
73507
73465
|
[...admitted, ...launched.keys()],
|
|
73508
73466
|
run2.runId
|
|
73509
73467
|
);
|
|
73510
|
-
log.info("sessions.resource_wait", {
|
|
73511
|
-
runId: run2.runId,
|
|
73512
|
-
active,
|
|
73513
|
-
pending,
|
|
73514
|
-
maxActiveRuns,
|
|
73515
|
-
totalMiB: Math.round(capacity.totalBytes / 2 ** 20),
|
|
73516
|
-
availableMiB: Math.round(capacity.availableBytes / 2 ** 20)
|
|
73517
|
-
});
|
|
73468
|
+
log.info("sessions.resource_wait", { runId: run2.runId, active, pending, maxActiveRuns });
|
|
73518
73469
|
return "waiting";
|
|
73519
73470
|
}
|
|
73520
73471
|
try {
|
|
@@ -73547,7 +73498,7 @@ async function openSessions(deps) {
|
|
|
73547
73498
|
heldRuns,
|
|
73548
73499
|
hasFreeSlot: async () => {
|
|
73549
73500
|
const { active, pending } = runOccupancy(await heldRuns(), [...admitted, ...launched.keys()]);
|
|
73550
|
-
return active + pending < maxActiveRuns
|
|
73501
|
+
return active + pending < maxActiveRuns;
|
|
73551
73502
|
},
|
|
73552
73503
|
applySuspendPolicy,
|
|
73553
73504
|
start: (run2) => {
|
|
@@ -75815,7 +75766,7 @@ async function runLogout(argv, signal) {
|
|
|
75815
75766
|
}
|
|
75816
75767
|
|
|
75817
75768
|
// src/cli/commands/run.ts
|
|
75818
|
-
var
|
|
75769
|
+
var import_node_fs25 = require("fs");
|
|
75819
75770
|
var import_node_path82 = require("path");
|
|
75820
75771
|
|
|
75821
75772
|
// src/local-api/app-attachments.ts
|
|
@@ -76370,7 +76321,7 @@ var machineFeatureRoutes = [
|
|
|
76370
76321
|
];
|
|
76371
76322
|
|
|
76372
76323
|
// src/local-api/run-log-routes.ts
|
|
76373
|
-
var
|
|
76324
|
+
var import_node_fs24 = require("fs");
|
|
76374
76325
|
init_runtime_v2();
|
|
76375
76326
|
var RUN_ENDED = "_alan/run.ended";
|
|
76376
76327
|
var decoder2 = new TextDecoder();
|
|
@@ -76387,7 +76338,7 @@ async function openWhenWritten(deps, runId, res, signal) {
|
|
|
76387
76338
|
const path4 = runDirectory(deps.runsDir, runId).log;
|
|
76388
76339
|
while (!signal.aborted) {
|
|
76389
76340
|
const appended = deps.appends.nextAppend(runId, signal);
|
|
76390
|
-
if ((0,
|
|
76341
|
+
if ((0, import_node_fs24.existsSync)(path4) || !await deps.isHeld(runId, signal)) return openReader(res, path4);
|
|
76391
76342
|
await appended;
|
|
76392
76343
|
}
|
|
76393
76344
|
return null;
|
|
@@ -82735,7 +82686,7 @@ function lockWaitMs(argv) {
|
|
|
82735
82686
|
async function openManagedProviders(config2, paths) {
|
|
82736
82687
|
const providerEnv = readCliEnvironment();
|
|
82737
82688
|
const bundledNpm = (0, import_node_path82.join)((0, import_node_path82.dirname)(process.execPath), "npm", "bin", "npm-cli.js");
|
|
82738
|
-
const providerToolchain = config2.providerToolchain ?? (process.platform === "win32" && (0,
|
|
82689
|
+
const providerToolchain = config2.providerToolchain ?? (process.platform === "win32" && (0, import_node_fs25.existsSync)(bundledNpm) ? { node: process.execPath, npmCli: bundledNpm } : null);
|
|
82739
82690
|
const npmPath = providerToolchain?.node ?? await resolveCommandOnPath("npm", providerEnv, process.platform);
|
|
82740
82691
|
const npmOptions = npmPath === null || process.platform === "win32" && providerToolchain === null ? null : {
|
|
82741
82692
|
command: npmPath,
|
package/alan-holder.cjs
CHANGED
|
@@ -42000,8 +42000,9 @@ var init_driver = __esm({
|
|
|
42000
42000
|
});
|
|
42001
42001
|
|
|
42002
42002
|
// src/holder/drivers/persistent.ts
|
|
42003
|
-
function sessionContextFor(opened, inputs) {
|
|
42004
|
-
|
|
42003
|
+
async function sessionContextFor(opened, inputs) {
|
|
42004
|
+
const text2 = await inputs.agentContext;
|
|
42005
|
+
return opened.fresh ? text2?.full : text2?.update;
|
|
42005
42006
|
}
|
|
42006
42007
|
function steerEcho(request2) {
|
|
42007
42008
|
return {
|
|
@@ -42250,7 +42251,7 @@ function createPersistentDriver(provider4, options) {
|
|
|
42250
42251
|
};
|
|
42251
42252
|
signal.addEventListener("abort", onAbort, { once: true });
|
|
42252
42253
|
try {
|
|
42253
|
-
const contextPrefix = [sessionContextFor(opened, inputs), opened.contextPrefix].filter((part) => part !== void 0).join("\n\n");
|
|
42254
|
+
const contextPrefix = [await sessionContextFor(opened, inputs), opened.contextPrefix].filter((part) => part !== void 0).join("\n\n");
|
|
42254
42255
|
const input2 = await provider4.turnInput(spec, inputs, contextPrefix || void 0);
|
|
42255
42256
|
if (signal.aborted) return { outcome: "aborted" };
|
|
42256
42257
|
const timeoutMs = options.firstOutputTimeoutMs ?? FIRST_OUTPUT_TIMEOUT_MS;
|
|
@@ -48505,6 +48506,20 @@ async function readCheckoutStatus(git, cwd, signal) {
|
|
|
48505
48506
|
);
|
|
48506
48507
|
return output2.exitCode === 0 ? parseStatus(output2.stdout) : null;
|
|
48507
48508
|
}
|
|
48509
|
+
async function currentBranch(git, cwd, signal) {
|
|
48510
|
+
const output2 = await git.run(
|
|
48511
|
+
{ cwd, args: ["symbolic-ref", "--quiet", "--short", "HEAD"], readOnly: true },
|
|
48512
|
+
signal
|
|
48513
|
+
);
|
|
48514
|
+
return output2.exitCode === 0 ? output2.stdout.trim() || null : null;
|
|
48515
|
+
}
|
|
48516
|
+
async function moveSnapshotTo(git, cwd, snapshot, tip, signal) {
|
|
48517
|
+
const run = (args) => git.run({ cwd, args }, signal);
|
|
48518
|
+
if ((await run(["switch", "--quiet", "--detach", tip])).exitCode !== 0) return false;
|
|
48519
|
+
const moved = await run(["update-ref", `refs/heads/${snapshot.branch}`, tip, snapshot.head]);
|
|
48520
|
+
const back = await run(["switch", "--quiet", snapshot.branch]);
|
|
48521
|
+
return moved.exitCode === 0 && back.exitCode === 0;
|
|
48522
|
+
}
|
|
48508
48523
|
async function isCheckout(path) {
|
|
48509
48524
|
return (0, import_promises8.stat)((0, import_node_path4.join)(path, ".git")).then(
|
|
48510
48525
|
() => true,
|
|
@@ -48884,7 +48899,6 @@ function runtimePaths(stateDir) {
|
|
|
48884
48899
|
|
|
48885
48900
|
// src/platform/process-memory.ts
|
|
48886
48901
|
var import_node_child_process4 = require("child_process");
|
|
48887
|
-
var import_node_fs6 = require("fs");
|
|
48888
48902
|
var import_promises12 = require("fs/promises");
|
|
48889
48903
|
var import_node_os2 = require("os");
|
|
48890
48904
|
var import_node_util3 = require("util");
|
|
@@ -48924,45 +48938,6 @@ async function readProcessRss(pid) {
|
|
|
48924
48938
|
return null;
|
|
48925
48939
|
}
|
|
48926
48940
|
}
|
|
48927
|
-
function parseDarwinVmStat(output2) {
|
|
48928
|
-
const pageSize = Number(/page size of (\d+) bytes/.exec(output2)?.[1]);
|
|
48929
|
-
if (!Number.isFinite(pageSize) || pageSize <= 0) return null;
|
|
48930
|
-
const pages = (name) => {
|
|
48931
|
-
const match = new RegExp(`^Pages ${name}:\\s+(\\d+)\\.?$`, "m").exec(output2);
|
|
48932
|
-
return match ? Number(match[1]) : null;
|
|
48933
|
-
};
|
|
48934
|
-
const free = pages("free");
|
|
48935
|
-
if (free === null) return null;
|
|
48936
|
-
return (free + (pages("inactive") ?? 0) + (pages("speculative") ?? 0)) * pageSize;
|
|
48937
|
-
}
|
|
48938
|
-
function parseLinuxMemInfo(output2) {
|
|
48939
|
-
const kilobytes = /^MemAvailable:\s+(\d+)\s+kB$/m.exec(output2)?.[1];
|
|
48940
|
-
return kilobytes === void 0 ? null : Number(kilobytes) * 1024;
|
|
48941
|
-
}
|
|
48942
|
-
var CAPACITY_PROBE_TTL_MS = 2e3;
|
|
48943
|
-
var AvailableMemoryProbe = class {
|
|
48944
|
-
cached = null;
|
|
48945
|
-
read(now) {
|
|
48946
|
-
if (this.cached !== null && now - this.cached.at < CAPACITY_PROBE_TTL_MS) {
|
|
48947
|
-
return this.cached.bytes;
|
|
48948
|
-
}
|
|
48949
|
-
let bytes = null;
|
|
48950
|
-
try {
|
|
48951
|
-
if (process.platform === "darwin") {
|
|
48952
|
-
bytes = parseDarwinVmStat(
|
|
48953
|
-
(0, import_node_child_process4.execFileSync)("vm_stat", { encoding: "utf8", timeout: PROBE_TIMEOUT_MS })
|
|
48954
|
-
);
|
|
48955
|
-
} else if (process.platform === "linux") {
|
|
48956
|
-
bytes = parseLinuxMemInfo((0, import_node_fs6.readFileSync)("/proc/meminfo", "utf8"));
|
|
48957
|
-
}
|
|
48958
|
-
} catch {
|
|
48959
|
-
bytes = null;
|
|
48960
|
-
}
|
|
48961
|
-
this.cached = { at: now, bytes };
|
|
48962
|
-
return bytes;
|
|
48963
|
-
}
|
|
48964
|
-
};
|
|
48965
|
-
var availableMemoryProbe = new AvailableMemoryProbe();
|
|
48966
48941
|
async function processMemoryRows() {
|
|
48967
48942
|
if (process.platform === "win32") {
|
|
48968
48943
|
const { stdout: stdout2 } = await execFileAsync3(
|
|
@@ -49063,7 +49038,7 @@ var systemExec = (request2) => new Promise((resolve8) => {
|
|
|
49063
49038
|
init_alan_code();
|
|
49064
49039
|
|
|
49065
49040
|
// src/capabilities/providers/commands.ts
|
|
49066
|
-
var
|
|
49041
|
+
var import_node_fs6 = require("fs");
|
|
49067
49042
|
var import_promises17 = require("fs/promises");
|
|
49068
49043
|
var import_node_path9 = require("path");
|
|
49069
49044
|
var PROVIDER_COMMANDS = [
|
|
@@ -49101,7 +49076,7 @@ function pathDelimiter(platform) {
|
|
|
49101
49076
|
async function isRunnable(path, platform) {
|
|
49102
49077
|
try {
|
|
49103
49078
|
if (!(await (0, import_promises17.stat)(path)).isFile()) return false;
|
|
49104
|
-
if (platform !== "win32") await (0, import_promises17.access)(path,
|
|
49079
|
+
if (platform !== "win32") await (0, import_promises17.access)(path, import_node_fs6.constants.X_OK);
|
|
49105
49080
|
return true;
|
|
49106
49081
|
} catch {
|
|
49107
49082
|
return false;
|
|
@@ -49751,7 +49726,7 @@ async function inspectIndexedSkill(directory, contentHash) {
|
|
|
49751
49726
|
|
|
49752
49727
|
// src/capabilities/skills/native-index.ts
|
|
49753
49728
|
var import_node_crypto10 = require("crypto");
|
|
49754
|
-
var
|
|
49729
|
+
var import_node_fs7 = require("fs");
|
|
49755
49730
|
var import_promises21 = require("fs/promises");
|
|
49756
49731
|
var import_node_path13 = require("path");
|
|
49757
49732
|
var ALAN_SKILLS_PLUGIN_NAME = "alan";
|
|
@@ -49765,7 +49740,7 @@ var PLUGIN_MANIFEST = `${JSON.stringify(
|
|
|
49765
49740
|
)}
|
|
49766
49741
|
`;
|
|
49767
49742
|
function installedSkillFolders(layout) {
|
|
49768
|
-
return (0,
|
|
49743
|
+
return (0, import_node_fs7.existsSync)((0, import_node_path13.join)(layout.pluginDir, ".claude-plugin", "plugin.json")) ? { pluginDir: layout.pluginDir, skillsDir: layout.pluginSkillsDir } : null;
|
|
49769
49744
|
}
|
|
49770
49745
|
|
|
49771
49746
|
// src/capabilities/workspace/index.ts
|
|
@@ -50382,20 +50357,20 @@ async function prepareRunInputs(spec, { source, tmpDir, signal, skills = [] }) {
|
|
|
50382
50357
|
|
|
50383
50358
|
// src/holder/serve.ts
|
|
50384
50359
|
var import_node_crypto15 = require("crypto");
|
|
50385
|
-
var
|
|
50360
|
+
var import_node_fs11 = require("fs");
|
|
50386
50361
|
var import_node_net2 = require("net");
|
|
50387
50362
|
var import_node_path29 = require("path");
|
|
50388
50363
|
init_runtime_v2();
|
|
50389
50364
|
|
|
50390
50365
|
// src/holder/admission.ts
|
|
50391
|
-
var
|
|
50366
|
+
var import_node_fs9 = require("fs");
|
|
50392
50367
|
var import_promises35 = require("fs/promises");
|
|
50393
50368
|
var import_node_os6 = require("os");
|
|
50394
50369
|
var import_node_path25 = require("path");
|
|
50395
50370
|
init_constants();
|
|
50396
50371
|
|
|
50397
50372
|
// ../shared/dist/node/local-workspace.js
|
|
50398
|
-
var
|
|
50373
|
+
var import_node_fs8 = require("fs");
|
|
50399
50374
|
var import_node_os5 = require("os");
|
|
50400
50375
|
var import_node_path20 = require("path");
|
|
50401
50376
|
function resolveAlanDefaultWorkspacePath(homeDirectory = (0, import_node_os5.homedir)()) {
|
|
@@ -50623,18 +50598,16 @@ async function switchTo(checkout, current, operationId, deps, signal) {
|
|
|
50623
50598
|
async function applyRequestedCheckout(checkout, spec, deps, signal) {
|
|
50624
50599
|
try {
|
|
50625
50600
|
if (!await isCheckout(checkout.path)) return await clone2(checkout, deps, signal);
|
|
50626
|
-
const
|
|
50627
|
-
if (
|
|
50628
|
-
if (status.branch === checkout.branch) return { kind: "on_branch" };
|
|
50629
|
-
if (status.dirty) return notSwitched(checkout, status.branch, "it has uncommitted changes");
|
|
50601
|
+
const branch = await currentBranch(deps.git, checkout.path, signal);
|
|
50602
|
+
if (branch === checkout.branch) return { kind: "on_branch" };
|
|
50630
50603
|
if (!await claimFirstLease(deps.dir, checkout.path)) {
|
|
50631
50604
|
return notSwitched(
|
|
50632
50605
|
checkout,
|
|
50633
|
-
|
|
50606
|
+
branch,
|
|
50634
50607
|
"an earlier conversation on this machine already uses it"
|
|
50635
50608
|
);
|
|
50636
50609
|
}
|
|
50637
|
-
return await switchTo(checkout,
|
|
50610
|
+
return await switchTo(checkout, branch, `checkout-${spec.runId}`, deps, signal);
|
|
50638
50611
|
} catch (error62) {
|
|
50639
50612
|
return noted(
|
|
50640
50613
|
`could not be put on ${checkout.branch}, the branch picked for this chat`,
|
|
@@ -50665,15 +50638,13 @@ async function fastForward(freshness, operationId, deps, signal) {
|
|
|
50665
50638
|
const attempt = await deps.locks.tryExclusive(snapshot.commonDir, operationId);
|
|
50666
50639
|
if (attempt.kind === "busy") return false;
|
|
50667
50640
|
const _lock = __using(_stack, attempt.lock, true);
|
|
50668
|
-
const
|
|
50669
|
-
|
|
50670
|
-
|
|
50671
|
-
|
|
50672
|
-
|
|
50673
|
-
if (
|
|
50674
|
-
|
|
50675
|
-
const back = await git(["switch", "--quiet", snapshot.branch]);
|
|
50676
|
-
return moved.exitCode === 0 && back.exitCode === 0;
|
|
50641
|
+
const head = await deps.git.run(
|
|
50642
|
+
{ cwd, args: ["rev-parse", "--verify", "HEAD"], readOnly: true },
|
|
50643
|
+
signal
|
|
50644
|
+
);
|
|
50645
|
+
if (head.exitCode !== 0 || head.stdout.trim() !== snapshot.head) return false;
|
|
50646
|
+
if (await currentBranch(deps.git, cwd, signal) !== snapshot.branch) return false;
|
|
50647
|
+
return moveSnapshotTo(deps.git, cwd, snapshot, tip, signal);
|
|
50677
50648
|
} catch (_) {
|
|
50678
50649
|
var _error = _, _hasError = true;
|
|
50679
50650
|
} finally {
|
|
@@ -50724,13 +50695,15 @@ async function applyRequestedCheckouts(spec, deps, signal) {
|
|
|
50724
50695
|
const settled2 = /* @__PURE__ */ new Set();
|
|
50725
50696
|
const problems = [];
|
|
50726
50697
|
for (const checkout of requestedCheckoutsOf(spec, deps.log)) {
|
|
50698
|
+
const startedAt = Date.now();
|
|
50727
50699
|
const outcome2 = await applyRequestedCheckout(checkout, spec, deps, signal);
|
|
50728
50700
|
deps.log.info("workspace.requested_checkout", {
|
|
50729
50701
|
runId: spec.runId,
|
|
50730
50702
|
path: checkout.path,
|
|
50731
50703
|
branch: checkout.branch,
|
|
50732
50704
|
outcome: outcome2.kind,
|
|
50733
|
-
...outcome2.kind === "moved" ? { how: outcome2.how } : {}
|
|
50705
|
+
...outcome2.kind === "moved" ? { how: outcome2.how } : {},
|
|
50706
|
+
ms: Date.now() - startedAt
|
|
50734
50707
|
});
|
|
50735
50708
|
if (outcome2.kind === "on_branch") continue;
|
|
50736
50709
|
settled2.add((0, import_node_path24.resolve)(checkout.path));
|
|
@@ -50746,6 +50719,7 @@ async function refreshSnapshotCheckouts(spec, targets, settled2, deps, signal) {
|
|
|
50746
50719
|
if (settled2.has((0, import_node_path24.resolve)(target))) continue;
|
|
50747
50720
|
const freshness = await readCheckoutFreshness(deps.dir, target);
|
|
50748
50721
|
if (freshness === null) continue;
|
|
50722
|
+
const startedAt = Date.now();
|
|
50749
50723
|
const outcome2 = await atFirstLease(freshness, spec, deps, signal).catch(
|
|
50750
50724
|
() => "noted"
|
|
50751
50725
|
);
|
|
@@ -50754,7 +50728,8 @@ async function refreshSnapshotCheckouts(spec, targets, settled2, deps, signal) {
|
|
|
50754
50728
|
runId: spec.runId,
|
|
50755
50729
|
path: freshness.path,
|
|
50756
50730
|
state: freshness.state,
|
|
50757
|
-
outcome: outcome2
|
|
50731
|
+
outcome: outcome2,
|
|
50732
|
+
ms: Date.now() - startedAt
|
|
50758
50733
|
});
|
|
50759
50734
|
}
|
|
50760
50735
|
return problems;
|
|
@@ -50815,7 +50790,7 @@ async function inspectReadiness(path) {
|
|
|
50815
50790
|
if (!(await (0, import_promises35.stat)(path)).isDirectory()) {
|
|
50816
50791
|
return { ready: false, missing: true, message: MESSAGES.missing };
|
|
50817
50792
|
}
|
|
50818
|
-
await (0, import_promises35.access)(path,
|
|
50793
|
+
await (0, import_promises35.access)(path, import_node_fs9.constants.R_OK | import_node_fs9.constants.W_OK | import_node_fs9.constants.X_OK);
|
|
50819
50794
|
return { ready: true };
|
|
50820
50795
|
} catch (error62) {
|
|
50821
50796
|
const code = errnoCode(error62) ?? "";
|
|
@@ -50860,7 +50835,7 @@ async function admitDefaultWorkspace(spec, context, skills) {
|
|
|
50860
50835
|
const path = resolveAlanDefaultWorkspacePath(env.HOME || env.USERPROFILE || (0, import_node_os6.homedir)());
|
|
50861
50836
|
try {
|
|
50862
50837
|
await (0, import_promises35.mkdir)(path, { recursive: true, mode: 448 });
|
|
50863
|
-
await (0, import_promises35.access)(path,
|
|
50838
|
+
await (0, import_promises35.access)(path, import_node_fs9.constants.R_OK | import_node_fs9.constants.W_OK | import_node_fs9.constants.X_OK);
|
|
50864
50839
|
return { kind: "admitted", spec: { ...spec, projectPath: path }, skills };
|
|
50865
50840
|
} catch (error62) {
|
|
50866
50841
|
const code = errnoCode(error62);
|
|
@@ -51199,13 +51174,13 @@ function runEnded(input2) {
|
|
|
51199
51174
|
var decoder = new TextDecoder();
|
|
51200
51175
|
|
|
51201
51176
|
// src/run-log/writer.ts
|
|
51202
|
-
var
|
|
51177
|
+
var import_node_fs10 = require("fs");
|
|
51203
51178
|
var import_node_path28 = require("path");
|
|
51204
51179
|
init_runtime_v2();
|
|
51205
51180
|
function lastSeq(fd, size) {
|
|
51206
51181
|
for (const length of tailWindows(size)) {
|
|
51207
51182
|
const buffer = Buffer.alloc(length);
|
|
51208
|
-
(0,
|
|
51183
|
+
(0, import_node_fs10.readSync)(fd, buffer, 0, length, size - length);
|
|
51209
51184
|
const last = lastLine(buffer.toString("utf8").trimEnd(), length === size);
|
|
51210
51185
|
if (last === void 0) continue;
|
|
51211
51186
|
if (last.length === 0) return 0;
|
|
@@ -51216,13 +51191,13 @@ function lastSeq(fd, size) {
|
|
|
51216
51191
|
throw new RuntimeFault("record_too_large", "Run log tail record is larger than any record");
|
|
51217
51192
|
}
|
|
51218
51193
|
function openRunLog(path, clock) {
|
|
51219
|
-
(0,
|
|
51220
|
-
const fd = (0,
|
|
51221
|
-
let size = (0,
|
|
51194
|
+
(0, import_node_fs10.mkdirSync)((0, import_node_path28.dirname)(path), { recursive: true, mode: 448 });
|
|
51195
|
+
const fd = (0, import_node_fs10.openSync)(path, "a+", 384);
|
|
51196
|
+
let size = (0, import_node_fs10.fstatSync)(fd).size;
|
|
51222
51197
|
let seq = lastSeq(fd, size);
|
|
51223
51198
|
let dirty = false;
|
|
51224
51199
|
const sync = () => {
|
|
51225
|
-
(0,
|
|
51200
|
+
(0, import_node_fs10.fsyncSync)(fd);
|
|
51226
51201
|
dirty = false;
|
|
51227
51202
|
};
|
|
51228
51203
|
return {
|
|
@@ -51236,7 +51211,7 @@ function openRunLog(path, clock) {
|
|
|
51236
51211
|
};
|
|
51237
51212
|
const line = Buffer.from(`${JSON.stringify(record2)}
|
|
51238
51213
|
`, "utf8");
|
|
51239
|
-
(0,
|
|
51214
|
+
(0, import_node_fs10.writeSync)(fd, line);
|
|
51240
51215
|
size += line.length;
|
|
51241
51216
|
dirty = true;
|
|
51242
51217
|
if (isRunLifecycleKind(update.sessionUpdate)) sync();
|
|
@@ -51248,7 +51223,7 @@ function openRunLog(path, clock) {
|
|
|
51248
51223
|
},
|
|
51249
51224
|
[Symbol.dispose]: () => {
|
|
51250
51225
|
if (dirty) sync();
|
|
51251
|
-
(0,
|
|
51226
|
+
(0, import_node_fs10.closeSync)(fd);
|
|
51252
51227
|
}
|
|
51253
51228
|
};
|
|
51254
51229
|
}
|
|
@@ -51311,20 +51286,17 @@ async function runWithInputs({ spec, skills }, context, sink, signal) {
|
|
|
51311
51286
|
message: `Could not fetch this run's attachments or provider credential: ${error62 instanceof Error ? error62.message : String(error62)}`
|
|
51312
51287
|
};
|
|
51313
51288
|
}
|
|
51314
|
-
const agentContext = await sessionContext;
|
|
51315
51289
|
const prepared = __using(_stack, inputs, true);
|
|
51316
|
-
const result = await context.driver.runTurn(
|
|
51317
|
-
|
|
51318
|
-
|
|
51319
|
-
|
|
51320
|
-
|
|
51321
|
-
|
|
51322
|
-
agentContext: {
|
|
51323
|
-
full: agentContext.full,
|
|
51324
|
-
...agentContext.update ? { update: agentContext.update } : {}
|
|
51290
|
+
const result = await context.driver.runTurn(spec, sink, signal, {
|
|
51291
|
+
...prepared,
|
|
51292
|
+
agentContext: sessionContext.then(
|
|
51293
|
+
(agentContext2) => agentContext2 === void 0 ? void 0 : {
|
|
51294
|
+
full: agentContext2.full,
|
|
51295
|
+
...agentContext2.update ? { update: agentContext2.update } : {}
|
|
51325
51296
|
}
|
|
51326
|
-
|
|
51327
|
-
);
|
|
51297
|
+
)
|
|
51298
|
+
});
|
|
51299
|
+
const agentContext = await sessionContext;
|
|
51328
51300
|
if (agentContext !== void 0 && result.outcome !== "rejected") {
|
|
51329
51301
|
await agentContext.save().catch((error62) => {
|
|
51330
51302
|
context.log.warn("holder.agent_context_save_failed", { runId: spec.runId, error: error62 });
|
|
@@ -51692,7 +51664,7 @@ async function runHolder({
|
|
|
51692
51664
|
for (const client of holder.clients) client.end();
|
|
51693
51665
|
await new Promise((resolve8) => server.close(() => resolve8()));
|
|
51694
51666
|
await statusWrites;
|
|
51695
|
-
(0,
|
|
51667
|
+
(0, import_node_fs11.rmSync)(launch.statusPath, { force: true });
|
|
51696
51668
|
log.info("holder.suspended", { conversationId: launch.conversationId });
|
|
51697
51669
|
} catch (_) {
|
|
51698
51670
|
var _error = _, _hasError = true;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alan-ai-hq/agent-manager-linux-arm64",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.163",
|
|
4
4
|
"description": "Alan machine runtime (alan-agent) for one platform: the official Node.js binary, the runtime bundle and its launcher. Installed by @alan-ai-hq/agent-manager.",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"homepage": "https://tryalan.ai",
|