@alan-ai-hq/agent-manager-linux-arm64 0.1.146 → 0.1.147
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 +657 -337
- package/alan-holder.cjs +662 -329
- package/package.json +1 -1
package/alan-holder.cjs
CHANGED
|
@@ -12529,7 +12529,7 @@ function compileValidator(schema, parser) {
|
|
|
12529
12529
|
function compile(schema, options) {
|
|
12530
12530
|
try {
|
|
12531
12531
|
const parser = compileFn(schema);
|
|
12532
|
-
const
|
|
12532
|
+
const clone3 = clone(schema);
|
|
12533
12533
|
const liveRun = schema._zod.run;
|
|
12534
12534
|
const originalRun = liveRun.__originalRun ?? liveRun;
|
|
12535
12535
|
const wrapped = (payload, ctx) => {
|
|
@@ -12549,12 +12549,12 @@ function compile(schema, options) {
|
|
|
12549
12549
|
return originalRun(payload, ctx);
|
|
12550
12550
|
};
|
|
12551
12551
|
wrapped.__originalRun = originalRun;
|
|
12552
|
-
|
|
12553
|
-
|
|
12554
|
-
|
|
12552
|
+
clone3._zod.bag.fallbackRun = originalRun;
|
|
12553
|
+
clone3._zod.bag.validator = compileValidator(schema, parser);
|
|
12554
|
+
clone3._zod.run = wrapped;
|
|
12555
12555
|
if (!liveRun.__originalRun)
|
|
12556
|
-
installCompiledUserMethods(
|
|
12557
|
-
return
|
|
12556
|
+
installCompiledUserMethods(clone3, schema, parser);
|
|
12557
|
+
return clone3;
|
|
12558
12558
|
} catch (err) {
|
|
12559
12559
|
if (options?.strict)
|
|
12560
12560
|
throw err;
|
|
@@ -20309,7 +20309,7 @@ var init_workspace = __esm({
|
|
|
20309
20309
|
});
|
|
20310
20310
|
|
|
20311
20311
|
// ../shared/dist/runtime-v2/desired-state.js
|
|
20312
|
-
var repoLocalPathSchema, runSpecSchema, desiredRunSchema, desiredStateSchema;
|
|
20312
|
+
var repoLocalPathSchema, requestedCheckoutSchema, runSpecSchema, desiredRunSchema, desiredStateSchema;
|
|
20313
20313
|
var init_desired_state = __esm({
|
|
20314
20314
|
"../shared/dist/runtime-v2/desired-state.js"() {
|
|
20315
20315
|
"use strict";
|
|
@@ -20324,6 +20324,11 @@ var init_desired_state = __esm({
|
|
|
20324
20324
|
localPath: external_exports.string().min(1),
|
|
20325
20325
|
branch: external_exports.string().min(1).optional()
|
|
20326
20326
|
});
|
|
20327
|
+
requestedCheckoutSchema = external_exports.object({
|
|
20328
|
+
path: machinePathSchema,
|
|
20329
|
+
repoUrl: gitRemoteUrlSchema,
|
|
20330
|
+
branch: gitBranchSchema
|
|
20331
|
+
});
|
|
20327
20332
|
runSpecSchema = external_exports.object({
|
|
20328
20333
|
runId: runIdSchema,
|
|
20329
20334
|
conversationId: conversationIdSchema,
|
|
@@ -20342,6 +20347,8 @@ var init_desired_state = __esm({
|
|
|
20342
20347
|
workspacePathPinned: external_exports.boolean().optional(),
|
|
20343
20348
|
approvedWorkspacePaths: external_exports.array(external_exports.string().min(1)).optional(),
|
|
20344
20349
|
repoLocalPaths: external_exports.array(repoLocalPathSchema).optional(),
|
|
20350
|
+
/** Applied once, at the conversation's first turn on a cloud sandbox; never moves local work. */
|
|
20351
|
+
requestedCheckouts: external_exports.array(requestedCheckoutSchema).max(64).optional(),
|
|
20345
20352
|
workflowId: external_exports.guid().optional(),
|
|
20346
20353
|
workflowExecutionId: external_exports.guid().optional(),
|
|
20347
20354
|
agentId: external_exports.string().min(1).optional(),
|
|
@@ -20933,13 +20940,20 @@ var init_problem = __esm({
|
|
|
20933
20940
|
});
|
|
20934
20941
|
|
|
20935
20942
|
// ../shared/dist/cli-usage.js
|
|
20936
|
-
var usagePercentSchema, usageTimestampSchema, cliUsageWindowPatchSchema, cliUsageWindowSchema, cliUsageBucketSchema, cliUsageSnapshotSchema;
|
|
20943
|
+
var usagePercentSchema, usageTimestampSchema, usageAmountSchema, usageObservationShape, cliUsageWindowPatchSchema, cliUsageWindowSchema, cliUsageSpendPatchSchema, cliUsageSpendSchema, cliUsageCreditsPatchSchema, cliUsageCreditsSchema, cliUsageBucketSchema, cliUsageSnapshotSchema;
|
|
20937
20944
|
var init_cli_usage = __esm({
|
|
20938
20945
|
"../shared/dist/cli-usage.js"() {
|
|
20939
20946
|
"use strict";
|
|
20940
20947
|
init_zod();
|
|
20941
20948
|
usagePercentSchema = external_exports.number().min(0).max(100);
|
|
20942
20949
|
usageTimestampSchema = external_exports.iso.datetime();
|
|
20950
|
+
usageAmountSchema = external_exports.string().min(1);
|
|
20951
|
+
usageObservationShape = {
|
|
20952
|
+
observedAt: usageTimestampSchema,
|
|
20953
|
+
receivedAt: usageTimestampSchema,
|
|
20954
|
+
sourceId: external_exports.string().min(1),
|
|
20955
|
+
sequence: external_exports.number().int().nonnegative()
|
|
20956
|
+
};
|
|
20943
20957
|
cliUsageWindowPatchSchema = external_exports.object({
|
|
20944
20958
|
usedPercent: usagePercentSchema.nullable().optional(),
|
|
20945
20959
|
windowMinutes: external_exports.number().positive().nullable().optional(),
|
|
@@ -20949,14 +20963,41 @@ var init_cli_usage = __esm({
|
|
|
20949
20963
|
usedPercent: usagePercentSchema.optional(),
|
|
20950
20964
|
windowMinutes: external_exports.number().positive().optional(),
|
|
20951
20965
|
resetsAt: usageTimestampSchema.optional(),
|
|
20952
|
-
|
|
20953
|
-
|
|
20954
|
-
|
|
20955
|
-
|
|
20966
|
+
...usageObservationShape
|
|
20967
|
+
});
|
|
20968
|
+
cliUsageSpendPatchSchema = external_exports.object({
|
|
20969
|
+
reached: external_exports.boolean(),
|
|
20970
|
+
limit: usageAmountSchema.nullable().optional(),
|
|
20971
|
+
used: usageAmountSchema.nullable().optional(),
|
|
20972
|
+
remaining: usageAmountSchema.nullable().optional(),
|
|
20973
|
+
usedPercent: usagePercentSchema.nullable().optional(),
|
|
20974
|
+
resetsAt: usageTimestampSchema.nullable().optional()
|
|
20975
|
+
});
|
|
20976
|
+
cliUsageSpendSchema = external_exports.object({
|
|
20977
|
+
reached: external_exports.boolean(),
|
|
20978
|
+
limit: usageAmountSchema.optional(),
|
|
20979
|
+
used: usageAmountSchema.optional(),
|
|
20980
|
+
remaining: usageAmountSchema.optional(),
|
|
20981
|
+
usedPercent: usagePercentSchema.optional(),
|
|
20982
|
+
resetsAt: usageTimestampSchema.optional(),
|
|
20983
|
+
...usageObservationShape
|
|
20984
|
+
});
|
|
20985
|
+
cliUsageCreditsPatchSchema = external_exports.object({
|
|
20986
|
+
hasCredits: external_exports.boolean(),
|
|
20987
|
+
unlimited: external_exports.boolean(),
|
|
20988
|
+
balance: usageAmountSchema.nullable().optional()
|
|
20989
|
+
});
|
|
20990
|
+
cliUsageCreditsSchema = external_exports.object({
|
|
20991
|
+
hasCredits: external_exports.boolean(),
|
|
20992
|
+
unlimited: external_exports.boolean(),
|
|
20993
|
+
balance: usageAmountSchema.optional(),
|
|
20994
|
+
...usageObservationShape
|
|
20956
20995
|
});
|
|
20957
20996
|
cliUsageBucketSchema = external_exports.object({
|
|
20958
20997
|
primary: cliUsageWindowSchema.optional(),
|
|
20959
20998
|
secondary: cliUsageWindowSchema.optional(),
|
|
20999
|
+
spend: cliUsageSpendSchema.optional(),
|
|
21000
|
+
credits: cliUsageCreditsSchema.optional(),
|
|
20960
21001
|
planType: external_exports.string().min(1).nullable().optional()
|
|
20961
21002
|
});
|
|
20962
21003
|
cliUsageSnapshotSchema = external_exports.object({
|
|
@@ -20992,6 +21033,8 @@ var init_run_log = __esm({
|
|
|
20992
21033
|
limitId: external_exports.string().min(1),
|
|
20993
21034
|
primary: cliUsageWindowPatchSchema.nullable().optional(),
|
|
20994
21035
|
secondary: cliUsageWindowPatchSchema.nullable().optional(),
|
|
21036
|
+
spend: cliUsageSpendPatchSchema.nullable().optional(),
|
|
21037
|
+
credits: cliUsageCreditsPatchSchema.nullable().optional(),
|
|
20995
21038
|
planType: external_exports.string().min(1).nullable().optional(),
|
|
20996
21039
|
observedAt: external_exports.iso.datetime(),
|
|
20997
21040
|
sourceId: external_exports.string().min(1),
|
|
@@ -22225,11 +22268,11 @@ function createListeners() {
|
|
|
22225
22268
|
}
|
|
22226
22269
|
};
|
|
22227
22270
|
}
|
|
22228
|
-
var
|
|
22271
|
+
var import_promises5, CoreFault, NANOS_PER_MILLI, systemClock2, silentLog;
|
|
22229
22272
|
var init_chunk_YXWJW7I5 = __esm({
|
|
22230
22273
|
"../agent-core/dist/chunk-YXWJW7I5.js"() {
|
|
22231
22274
|
"use strict";
|
|
22232
|
-
|
|
22275
|
+
import_promises5 = require("timers/promises");
|
|
22233
22276
|
CoreFault = class extends Error {
|
|
22234
22277
|
code;
|
|
22235
22278
|
constructor(code, message, options) {
|
|
@@ -22243,7 +22286,7 @@ var init_chunk_YXWJW7I5 = __esm({
|
|
|
22243
22286
|
now: () => Date.now(),
|
|
22244
22287
|
monotonic: () => Number(process.hrtime.bigint() / NANOS_PER_MILLI),
|
|
22245
22288
|
sleep: async (ms, signal) => {
|
|
22246
|
-
await (0,
|
|
22289
|
+
await (0, import_promises5.setTimeout)(ms, void 0, signal ? { signal } : void 0);
|
|
22247
22290
|
}
|
|
22248
22291
|
};
|
|
22249
22292
|
silentLog = {
|
|
@@ -22450,7 +22493,7 @@ function plan(command, args, options) {
|
|
|
22450
22493
|
function captureOutput(command, args, options) {
|
|
22451
22494
|
const launch = plan(command, args, options);
|
|
22452
22495
|
if (launch === void 0) return Promise.resolve(NEVER_STARTED);
|
|
22453
|
-
return new Promise((
|
|
22496
|
+
return new Promise((resolve9) => {
|
|
22454
22497
|
(0, import_child_process.execFile)(
|
|
22455
22498
|
launch.file,
|
|
22456
22499
|
[...launch.args],
|
|
@@ -22464,7 +22507,7 @@ function captureOutput(command, args, options) {
|
|
|
22464
22507
|
},
|
|
22465
22508
|
(error61, stdout, stderr) => {
|
|
22466
22509
|
const code = error61 && typeof error61.code === "number" ? error61.code : error61 ? void 0 : 0;
|
|
22467
|
-
|
|
22510
|
+
resolve9({ stdout, stderr, exitCode: code });
|
|
22468
22511
|
}
|
|
22469
22512
|
);
|
|
22470
22513
|
});
|
|
@@ -22506,18 +22549,18 @@ function decode3(bytes, start, end) {
|
|
|
22506
22549
|
}
|
|
22507
22550
|
async function linuxStartTicks(pid) {
|
|
22508
22551
|
try {
|
|
22509
|
-
const
|
|
22510
|
-
const fields =
|
|
22552
|
+
const stat16 = await (0, import_promises6.readFile)(`/proc/${pid}/stat`, "utf8");
|
|
22553
|
+
const fields = stat16.slice(stat16.lastIndexOf(")") + 2).split(" ");
|
|
22511
22554
|
return fields[19];
|
|
22512
22555
|
} catch {
|
|
22513
22556
|
return void 0;
|
|
22514
22557
|
}
|
|
22515
22558
|
}
|
|
22516
22559
|
function psStartTime(pid) {
|
|
22517
|
-
return new Promise((
|
|
22560
|
+
return new Promise((resolve9) => {
|
|
22518
22561
|
(0, import_child_process2.execFile)("ps", ["-o", "lstart=", "-p", String(pid)], { timeout: 2e3 }, (error61, stdout) => {
|
|
22519
22562
|
const text2 = stdout.trim();
|
|
22520
|
-
|
|
22563
|
+
resolve9(error61 || !text2 ? void 0 : text2);
|
|
22521
22564
|
});
|
|
22522
22565
|
});
|
|
22523
22566
|
}
|
|
@@ -22546,12 +22589,12 @@ function parseProcessList(text2) {
|
|
|
22546
22589
|
}
|
|
22547
22590
|
function listProcesses(platform = process.platform) {
|
|
22548
22591
|
if (platform === "win32") return Promise.resolve([]);
|
|
22549
|
-
return new Promise((
|
|
22592
|
+
return new Promise((resolve9) => {
|
|
22550
22593
|
(0, import_child_process3.execFile)(
|
|
22551
22594
|
"ps",
|
|
22552
22595
|
["-A", "-o", "pid=,ppid=,pgid=,lstart="],
|
|
22553
22596
|
{ timeout: 5e3, maxBuffer: 8 * 1024 * 1024 },
|
|
22554
|
-
(error61, stdout) =>
|
|
22597
|
+
(error61, stdout) => resolve9(error61 ? [] : parseProcessList(stdout))
|
|
22555
22598
|
);
|
|
22556
22599
|
});
|
|
22557
22600
|
}
|
|
@@ -22591,11 +22634,11 @@ async function taskkill(pid, options) {
|
|
|
22591
22634
|
stdio: "ignore",
|
|
22592
22635
|
windowsHide: true
|
|
22593
22636
|
});
|
|
22594
|
-
const exited = new Promise((
|
|
22595
|
-
killer.once("error", (error210) =>
|
|
22637
|
+
const exited = new Promise((resolve9) => {
|
|
22638
|
+
killer.once("error", (error210) => resolve9(error210));
|
|
22596
22639
|
killer.once(
|
|
22597
22640
|
"exit",
|
|
22598
|
-
(code, signal) =>
|
|
22641
|
+
(code, signal) => resolve9(code === 0 ? void 0 : new Error(`taskkill failed: exit ${code}, signal ${signal}`))
|
|
22599
22642
|
);
|
|
22600
22643
|
});
|
|
22601
22644
|
const timedOut = clock.sleep(options.timeoutMs ?? DEFAULT_TASKKILL_TIMEOUT_MS, timeout.signal).then(() => new Error("taskkill timed out")).catch(() => void 0);
|
|
@@ -22799,7 +22842,7 @@ async function waitForWindowsJob(child, command) {
|
|
|
22799
22842
|
const deadline = systemClock2.monotonic() + START_TIMEOUT_MS;
|
|
22800
22843
|
try {
|
|
22801
22844
|
while (systemClock2.monotonic() < deadline) {
|
|
22802
|
-
const providerPid = await (0,
|
|
22845
|
+
const providerPid = await (0, import_promises7.readFile)(status.path, "utf8").catch(() => void 0);
|
|
22803
22846
|
if (providerPid !== void 0) {
|
|
22804
22847
|
requireStartedProvider(providerPid, command);
|
|
22805
22848
|
return;
|
|
@@ -22822,7 +22865,7 @@ async function waitForWindowsJob(child, command) {
|
|
|
22822
22865
|
throw new CoreFault("spawn_failed", `Could not start ${command} (Windows helper timed out)`);
|
|
22823
22866
|
} finally {
|
|
22824
22867
|
statuses.delete(child);
|
|
22825
|
-
await (0,
|
|
22868
|
+
await (0, import_promises7.rm)(status.directory, { recursive: true, force: true });
|
|
22826
22869
|
}
|
|
22827
22870
|
}
|
|
22828
22871
|
function onCliSpawned(listener) {
|
|
@@ -22851,10 +22894,10 @@ function spawnCli(options) {
|
|
|
22851
22894
|
function waitForSpawn(child, command) {
|
|
22852
22895
|
if (isWindowsJob(child)) return waitForWindowsJob(child, command);
|
|
22853
22896
|
if (child.pid !== void 0) return Promise.resolve();
|
|
22854
|
-
return new Promise((
|
|
22897
|
+
return new Promise((resolve9, reject) => {
|
|
22855
22898
|
const onSpawn = () => {
|
|
22856
22899
|
child.off("error", onError);
|
|
22857
|
-
|
|
22900
|
+
resolve9();
|
|
22858
22901
|
};
|
|
22859
22902
|
const onError = (error61) => {
|
|
22860
22903
|
child.off("spawn", onSpawn);
|
|
@@ -22867,7 +22910,7 @@ function waitForSpawn(child, command) {
|
|
|
22867
22910
|
child.once("error", onError);
|
|
22868
22911
|
});
|
|
22869
22912
|
}
|
|
22870
|
-
var import_child_process, import_fs, import_path, import_child_process2,
|
|
22913
|
+
var import_child_process, import_fs, import_path, import_child_process2, import_promises6, import_child_process3, import_child_process4, import_child_process5, import_child_process6, import_crypto, import_fs2, import_promises7, import_os, import_path2, SHIM_MAX_BYTES, CMD_MAX_COMMAND_LINE, MAX_COMMAND_LINE, DEFAULT_PATHEXT, LAUNCHABLE_EXTENSIONS, nodeWindowsFiles, NODE_SHIM_ENTRY, NATIVE_SHIM_LINES, NATIVE_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, spawnListeners;
|
|
22871
22914
|
var init_chunk_M6YHY2EZ = __esm({
|
|
22872
22915
|
"../agent-core/dist/chunk-M6YHY2EZ.js"() {
|
|
22873
22916
|
"use strict";
|
|
@@ -22876,14 +22919,14 @@ var init_chunk_M6YHY2EZ = __esm({
|
|
|
22876
22919
|
import_fs = require("fs");
|
|
22877
22920
|
import_path = require("path");
|
|
22878
22921
|
import_child_process2 = require("child_process");
|
|
22879
|
-
|
|
22922
|
+
import_promises6 = require("fs/promises");
|
|
22880
22923
|
import_child_process3 = require("child_process");
|
|
22881
22924
|
import_child_process4 = require("child_process");
|
|
22882
22925
|
import_child_process5 = require("child_process");
|
|
22883
22926
|
import_child_process6 = require("child_process");
|
|
22884
22927
|
import_crypto = require("crypto");
|
|
22885
22928
|
import_fs2 = require("fs");
|
|
22886
|
-
|
|
22929
|
+
import_promises7 = require("fs/promises");
|
|
22887
22930
|
import_os = require("os");
|
|
22888
22931
|
import_path2 = require("path");
|
|
22889
22932
|
SHIM_MAX_BYTES = 64 * 1024;
|
|
@@ -24765,8 +24808,8 @@ function readMediaFiles(candidates2, cwd, mimeByExt, maxBytes) {
|
|
|
24765
24808
|
seen.add(path);
|
|
24766
24809
|
const mimeType = mimeByExt[(0, import_path3.extname)(path).toLowerCase()];
|
|
24767
24810
|
if (!mimeType) continue;
|
|
24768
|
-
const
|
|
24769
|
-
if (!
|
|
24811
|
+
const stat16 = (0, import_fs4.statSync)(path);
|
|
24812
|
+
if (!stat16.isFile() || stat16.size <= 0 || stat16.size > maxBytes) continue;
|
|
24770
24813
|
files.push({ path, mimeType, buffer: (0, import_fs4.readFileSync)(path) });
|
|
24771
24814
|
}
|
|
24772
24815
|
return files;
|
|
@@ -24841,8 +24884,8 @@ function createJsonRpcPeer(writer, handlers) {
|
|
|
24841
24884
|
},
|
|
24842
24885
|
request: (method, params = {}) => {
|
|
24843
24886
|
const id = counter.next++;
|
|
24844
|
-
return new Promise((
|
|
24845
|
-
pending.set(id, { method, resolve:
|
|
24887
|
+
return new Promise((resolve9, reject) => {
|
|
24888
|
+
pending.set(id, { method, resolve: resolve9, reject });
|
|
24846
24889
|
writer.write({ id, method, params }).catch((error61) => {
|
|
24847
24890
|
pending.delete(id);
|
|
24848
24891
|
reject(error61 instanceof Error ? error61 : new Error(String(error61)));
|
|
@@ -24955,7 +24998,7 @@ function createNdjsonWriter(stream) {
|
|
|
24955
24998
|
get writable() {
|
|
24956
24999
|
return stream.writable && !stream.destroyed && failure5.error === void 0;
|
|
24957
25000
|
},
|
|
24958
|
-
write: (value) => new Promise((
|
|
25001
|
+
write: (value) => new Promise((resolve9, reject) => {
|
|
24959
25002
|
if (failure5.error) {
|
|
24960
25003
|
reject(failure5.error);
|
|
24961
25004
|
return;
|
|
@@ -24967,7 +25010,7 @@ function createNdjsonWriter(stream) {
|
|
|
24967
25010
|
stream.write(`${JSON.stringify(value)}
|
|
24968
25011
|
`, (error61) => {
|
|
24969
25012
|
if (error61) reject(error61);
|
|
24970
|
-
else
|
|
25013
|
+
else resolve9();
|
|
24971
25014
|
});
|
|
24972
25015
|
}),
|
|
24973
25016
|
end: () => {
|
|
@@ -24983,11 +25026,11 @@ function hostProcess(child, tree, options, handlers) {
|
|
|
24983
25026
|
const stderr = new LineSplitter((line) => handlers.onStderrLine(line));
|
|
24984
25027
|
child.stderr.on("data", (chunk) => stderr.push(chunk));
|
|
24985
25028
|
child.stderr.once("end", () => stderr.flush());
|
|
24986
|
-
const processExit = new Promise((
|
|
24987
|
-
child.once("exit", (code, signal) =>
|
|
25029
|
+
const processExit = new Promise((resolve9) => {
|
|
25030
|
+
child.once("exit", (code, signal) => resolve9({ code, signal }));
|
|
24988
25031
|
});
|
|
24989
|
-
const outputEnded = new Promise((
|
|
24990
|
-
child.stdout.once("close", () =>
|
|
25032
|
+
const outputEnded = new Promise((resolve9) => {
|
|
25033
|
+
child.stdout.once("close", () => resolve9());
|
|
24991
25034
|
});
|
|
24992
25035
|
const watch = async () => {
|
|
24993
25036
|
const { clock, stdoutDrainMs, log, name } = options;
|
|
@@ -25277,13 +25320,13 @@ var init_chunk_4G77APXN = __esm({
|
|
|
25277
25320
|
const turnId = input2.turnId;
|
|
25278
25321
|
let finish = () => {
|
|
25279
25322
|
};
|
|
25280
|
-
const done = new Promise((
|
|
25323
|
+
const done = new Promise((resolve9) => {
|
|
25281
25324
|
finish = (outcome2) => {
|
|
25282
25325
|
if (this.#current?.id !== turnId) return;
|
|
25283
25326
|
this.#current = void 0;
|
|
25284
25327
|
if (this.#state === "busy") this.#state = "idle";
|
|
25285
25328
|
this.#emit({ type: "turn_ended", turnId, outcome: outcome2 });
|
|
25286
|
-
|
|
25329
|
+
resolve9({ turnId, outcome: outcome2, providerSessionId: this.#sessionId });
|
|
25287
25330
|
};
|
|
25288
25331
|
});
|
|
25289
25332
|
const pending = {
|
|
@@ -25479,20 +25522,20 @@ function canonicalizeManagedMcpToolName(toolName) {
|
|
|
25479
25522
|
return flattened ? `mcp__${MANAGED_MCP_SERVER_NAME}__${flattened[1]}` : toolName;
|
|
25480
25523
|
}
|
|
25481
25524
|
async function writeSecretFile(name, contents) {
|
|
25482
|
-
const dir = await (0,
|
|
25525
|
+
const dir = await (0, import_promises14.mkdtemp)((0, import_path4.join)((0, import_os2.tmpdir)(), "alan-mcp-"));
|
|
25483
25526
|
const path = (0, import_path4.join)(dir, name);
|
|
25484
25527
|
const remove = async () => {
|
|
25485
|
-
await (0,
|
|
25528
|
+
await (0, import_promises14.rm)(dir, { recursive: true, force: true });
|
|
25486
25529
|
};
|
|
25487
25530
|
try {
|
|
25488
|
-
await (0,
|
|
25531
|
+
await (0, import_promises14.writeFile)(path, contents, { mode: 384, flag: "wx" });
|
|
25489
25532
|
} catch (error61) {
|
|
25490
25533
|
await remove();
|
|
25491
25534
|
throw error61;
|
|
25492
25535
|
}
|
|
25493
25536
|
return { path, remove, [Symbol.asyncDispose]: remove };
|
|
25494
25537
|
}
|
|
25495
|
-
var import_crypto4, import_crypto5,
|
|
25538
|
+
var import_crypto4, import_crypto5, import_promises14, import_os2, import_path4, MANAGED_MCP_SERVER_NAME, RUN_SCOPED_SERVER, NAMESPACED_RUN_TOOL, FLATTENED_RUN_TOOL;
|
|
25496
25539
|
var init_chunk_J2KTV5FP = __esm({
|
|
25497
25540
|
"../agent-core/dist/chunk-J2KTV5FP.js"() {
|
|
25498
25541
|
"use strict";
|
|
@@ -25501,7 +25544,7 @@ var init_chunk_J2KTV5FP = __esm({
|
|
|
25501
25544
|
import_crypto5 = require("crypto");
|
|
25502
25545
|
init_agent2();
|
|
25503
25546
|
init_runtime_v2();
|
|
25504
|
-
|
|
25547
|
+
import_promises14 = require("fs/promises");
|
|
25505
25548
|
import_os2 = require("os");
|
|
25506
25549
|
import_path4 = require("path");
|
|
25507
25550
|
MANAGED_MCP_SERVER_NAME = "alan";
|
|
@@ -26944,12 +26987,12 @@ async function claudeTurnInput(run, context) {
|
|
|
26944
26987
|
const encoded = await Promise.all(
|
|
26945
26988
|
images.map(async (image) => ({
|
|
26946
26989
|
mimeType: image.mimeType,
|
|
26947
|
-
data: (await (0,
|
|
26990
|
+
data: (await (0, import_promises15.readFile)(image.path)).toString("base64")
|
|
26948
26991
|
}))
|
|
26949
26992
|
);
|
|
26950
26993
|
return { turnId: run.runId, text: text2, ...encoded.length ? { images: encoded } : {} };
|
|
26951
26994
|
}
|
|
26952
|
-
var import_crypto6, import_fs5, import_path5, import_crypto7,
|
|
26995
|
+
var import_crypto6, import_fs5, import_path5, import_crypto7, import_promises15, 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;
|
|
26953
26996
|
var init_claude = __esm({
|
|
26954
26997
|
"../agent-core/dist/providers/claude.js"() {
|
|
26955
26998
|
"use strict";
|
|
@@ -26972,7 +27015,7 @@ var init_claude = __esm({
|
|
|
26972
27015
|
import_fs5 = require("fs");
|
|
26973
27016
|
import_path5 = require("path");
|
|
26974
27017
|
import_crypto7 = require("crypto");
|
|
26975
|
-
|
|
27018
|
+
import_promises15 = require("fs/promises");
|
|
26976
27019
|
init_agent2();
|
|
26977
27020
|
EDIT_TOOLS = /* @__PURE__ */ new Set([
|
|
26978
27021
|
"Edit",
|
|
@@ -27682,8 +27725,8 @@ var init_claude = __esm({
|
|
|
27682
27725
|
}
|
|
27683
27726
|
async #awaitTaskStop(requestId, taskId) {
|
|
27684
27727
|
const timer = new AbortController();
|
|
27685
|
-
const answered = new Promise((
|
|
27686
|
-
this.#taskStops.set(requestId,
|
|
27728
|
+
const answered = new Promise((resolve9) => {
|
|
27729
|
+
this.#taskStops.set(requestId, resolve9);
|
|
27687
27730
|
});
|
|
27688
27731
|
const timeoutMs = this.#options.stopTaskTimeoutMs;
|
|
27689
27732
|
const timedOut = this.#options.clock.sleep(timeoutMs, timer.signal).then(
|
|
@@ -27756,17 +27799,17 @@ var init_claude = __esm({
|
|
|
27756
27799
|
};
|
|
27757
27800
|
let markStarted = () => {
|
|
27758
27801
|
};
|
|
27759
|
-
const whenStarted = new Promise((
|
|
27760
|
-
markStarted =
|
|
27802
|
+
const whenStarted = new Promise((resolve9) => {
|
|
27803
|
+
markStarted = resolve9;
|
|
27761
27804
|
});
|
|
27762
|
-
const done = new Promise((
|
|
27805
|
+
const done = new Promise((resolve9) => {
|
|
27763
27806
|
finish = (outcome2) => {
|
|
27764
27807
|
if (this.#current?.id !== id) return;
|
|
27765
27808
|
this.#current = void 0;
|
|
27766
27809
|
this.#lastTurn = turn;
|
|
27767
27810
|
if (this.#state === "busy") this.#state = "idle";
|
|
27768
27811
|
this.#emit({ type: "turn_ended", turnId: id, outcome: outcome2 });
|
|
27769
|
-
|
|
27812
|
+
resolve9({ turnId: id, outcome: outcome2, providerSessionId: this.#providerSessionId });
|
|
27770
27813
|
};
|
|
27771
27814
|
});
|
|
27772
27815
|
const active = {
|
|
@@ -27884,8 +27927,8 @@ var init_claude = __esm({
|
|
|
27884
27927
|
void removeLaunchFiles(this.#launchFiles).catch((error61) => {
|
|
27885
27928
|
this.#options.log.warn("claude.launch_files_cleanup_failed", { error: error61 });
|
|
27886
27929
|
});
|
|
27887
|
-
for (const
|
|
27888
|
-
|
|
27930
|
+
for (const resolve9 of this.#taskStops.values()) {
|
|
27931
|
+
resolve9({ ok: false, reason: "runtime_unavailable", message: "Claude Code exited." });
|
|
27889
27932
|
}
|
|
27890
27933
|
const active = this.#current;
|
|
27891
27934
|
if (active) {
|
|
@@ -28281,6 +28324,44 @@ function windowPatch(value) {
|
|
|
28281
28324
|
}
|
|
28282
28325
|
return patch;
|
|
28283
28326
|
}
|
|
28327
|
+
function amount(value) {
|
|
28328
|
+
const text2 = asString(value).trim();
|
|
28329
|
+
return text2.length > 0 ? text2 : void 0;
|
|
28330
|
+
}
|
|
28331
|
+
function spendPatch(limit, reached) {
|
|
28332
|
+
const record2 = asRecord(limit);
|
|
28333
|
+
const reachedFlag = reached === true;
|
|
28334
|
+
if (!record2)
|
|
28335
|
+
return limit === null && !reachedFlag ? null : reachedFlag ? { reached: true } : void 0;
|
|
28336
|
+
const patch = { reached: reachedFlag };
|
|
28337
|
+
const limitAmount = amount(record2.limit);
|
|
28338
|
+
const usedAmount = amount(record2.used);
|
|
28339
|
+
if (limitAmount) patch.limit = limitAmount;
|
|
28340
|
+
if (usedAmount) patch.used = usedAmount;
|
|
28341
|
+
const remainingPercent = asFiniteNumber(record2.remainingPercent);
|
|
28342
|
+
if (remainingPercent !== void 0) {
|
|
28343
|
+
patch.usedPercent = Math.min(100, Math.max(0, 100 - remainingPercent));
|
|
28344
|
+
}
|
|
28345
|
+
const seconds = asFiniteNumber(record2.resetsAt);
|
|
28346
|
+
if (seconds !== void 0 && seconds >= 0) {
|
|
28347
|
+
const reset = new Date(seconds * 1e3);
|
|
28348
|
+
if (Number.isFinite(reset.getTime())) patch.resetsAt = reset.toISOString();
|
|
28349
|
+
}
|
|
28350
|
+
return patch;
|
|
28351
|
+
}
|
|
28352
|
+
function creditsPatch(value) {
|
|
28353
|
+
if (value === null) return null;
|
|
28354
|
+
const record2 = asRecord(value);
|
|
28355
|
+
if (!record2 || typeof record2.hasCredits !== "boolean" || typeof record2.unlimited !== "boolean") {
|
|
28356
|
+
return void 0;
|
|
28357
|
+
}
|
|
28358
|
+
const balance = amount(record2.balance);
|
|
28359
|
+
return {
|
|
28360
|
+
hasCredits: record2.hasCredits,
|
|
28361
|
+
unlimited: record2.unlimited,
|
|
28362
|
+
...balance ? { balance } : {}
|
|
28363
|
+
};
|
|
28364
|
+
}
|
|
28284
28365
|
function isApprovalRequest(method) {
|
|
28285
28366
|
return COMMAND_OR_FILE.has(method) || LEGACY.has(method);
|
|
28286
28367
|
}
|
|
@@ -29357,12 +29438,16 @@ var init_codex = __esm({
|
|
|
29357
29438
|
if (!snapshot2) return [];
|
|
29358
29439
|
const primary = windowPatch(snapshot2.primary);
|
|
29359
29440
|
const secondary = windowPatch(snapshot2.secondary);
|
|
29441
|
+
const spend = spendPatch(snapshot2.individualLimit, snapshot2.spendControlReached);
|
|
29442
|
+
const credits = creditsPatch(snapshot2.credits);
|
|
29360
29443
|
const planType = snapshot2.planType === null ? null : asString(snapshot2.planType) || void 0;
|
|
29361
29444
|
const parsed = runCodexRateLimitsUpdateSchema.safeParse({
|
|
29362
29445
|
sessionUpdate: "_alan/codex.rate_limits",
|
|
29363
29446
|
limitId: bucketId ?? (asString(snapshot2.limitId) || "codex"),
|
|
29364
29447
|
...primary === void 0 ? {} : { primary },
|
|
29365
29448
|
...secondary === void 0 ? {} : { secondary },
|
|
29449
|
+
...spend === void 0 ? {} : { spend },
|
|
29450
|
+
...credits === void 0 ? {} : { credits },
|
|
29366
29451
|
...planType === void 0 ? {} : { planType },
|
|
29367
29452
|
observedAt: new Date(this.#clock.now()).toISOString(),
|
|
29368
29453
|
sourceId: this.#sourceId,
|
|
@@ -29801,10 +29886,10 @@ var init_codex = __esm({
|
|
|
29801
29886
|
};
|
|
29802
29887
|
let identify = () => {
|
|
29803
29888
|
};
|
|
29804
|
-
const identified = new Promise((
|
|
29805
|
-
identify =
|
|
29889
|
+
const identified = new Promise((resolve9) => {
|
|
29890
|
+
identify = resolve9;
|
|
29806
29891
|
});
|
|
29807
|
-
const done = new Promise((
|
|
29892
|
+
const done = new Promise((resolve9) => {
|
|
29808
29893
|
finish = (outcome2) => {
|
|
29809
29894
|
if (this.#current?.id !== id) return;
|
|
29810
29895
|
this.#current = void 0;
|
|
@@ -29812,7 +29897,7 @@ var init_codex = __esm({
|
|
|
29812
29897
|
if (this.#state === "busy") this.#state = "idle";
|
|
29813
29898
|
this.#host.scanDescendants(true);
|
|
29814
29899
|
this.#emit({ type: "turn_ended", turnId: id, outcome: outcome2 });
|
|
29815
|
-
|
|
29900
|
+
resolve9({ turnId: id, outcome: outcome2, providerSessionId: this.#threadId });
|
|
29816
29901
|
};
|
|
29817
29902
|
});
|
|
29818
29903
|
const active = {
|
|
@@ -30302,7 +30387,7 @@ function alanCodeConfigContent(existing, input2) {
|
|
|
30302
30387
|
});
|
|
30303
30388
|
}
|
|
30304
30389
|
function readBody2(response) {
|
|
30305
|
-
return new Promise((
|
|
30390
|
+
return new Promise((resolve9, reject) => {
|
|
30306
30391
|
const chunks = [];
|
|
30307
30392
|
let size = 0;
|
|
30308
30393
|
response.on("data", (chunk) => {
|
|
@@ -30310,7 +30395,7 @@ function readBody2(response) {
|
|
|
30310
30395
|
if (size > MAX_CATALOG_BYTES) response.destroy(new Error("catalog too large"));
|
|
30311
30396
|
else chunks.push(chunk);
|
|
30312
30397
|
});
|
|
30313
|
-
response.on("end", () =>
|
|
30398
|
+
response.on("end", () => resolve9(Buffer.concat(chunks).toString("utf8")));
|
|
30314
30399
|
response.on("error", reject);
|
|
30315
30400
|
});
|
|
30316
30401
|
}
|
|
@@ -30326,13 +30411,13 @@ function parseResponseBody(text2, status) {
|
|
|
30326
30411
|
}
|
|
30327
30412
|
function getJson(url2, headers, timeout, signal) {
|
|
30328
30413
|
const request2 = url2.protocol === "https:" ? import_https.request : import_http3.request;
|
|
30329
|
-
return new Promise((
|
|
30414
|
+
return new Promise((resolve9, reject) => {
|
|
30330
30415
|
const outgoing = request2(url2, { method: "GET", headers, timeout, signal }, (response) => {
|
|
30331
30416
|
const status = response.statusCode ?? 0;
|
|
30332
30417
|
readBody2(response).then((text2) => {
|
|
30333
30418
|
const body = parseResponseBody(text2, status);
|
|
30334
30419
|
if (status < 200 || status >= 300) reject(new CatalogResponseError(status, body));
|
|
30335
|
-
else
|
|
30420
|
+
else resolve9(body);
|
|
30336
30421
|
}).catch(reject);
|
|
30337
30422
|
});
|
|
30338
30423
|
outgoing.on("timeout", () => outgoing.destroy(new Error("catalog timed out")));
|
|
@@ -30549,15 +30634,15 @@ async function writePlugin(directory, apiOrigin) {
|
|
|
30549
30634
|
const origin = (0, import_crypto12.createHash)("sha256").update(apiOrigin).digest("hex").slice(0, 12);
|
|
30550
30635
|
const target = (0, import_path8.join)(directory, `engine-plugin-v${ALAN_CODE_ENGINE_PLUGIN_VERSION}-${origin}.mjs`);
|
|
30551
30636
|
const temporary = `${target}.${(0, import_crypto12.randomUUID)()}.tmp`;
|
|
30552
|
-
await (0,
|
|
30553
|
-
await (0,
|
|
30554
|
-
await (0,
|
|
30637
|
+
await (0, import_promises16.mkdir)(directory, { recursive: true, mode: 448 });
|
|
30638
|
+
await (0, import_promises16.writeFile)(temporary, alanCodeEnginePluginSource(apiOrigin), { mode: 384 });
|
|
30639
|
+
await (0, import_promises16.rename)(temporary, target);
|
|
30555
30640
|
return (0, import_url.pathToFileURL)(target).href;
|
|
30556
30641
|
}
|
|
30557
30642
|
async function prepareAlanCodeProfile(input2) {
|
|
30558
30643
|
const directories = Object.values(alanCodeEngineDirectories(input2.engineRoot));
|
|
30559
30644
|
await Promise.all(
|
|
30560
|
-
directories.map((directory) => (0,
|
|
30645
|
+
directories.map((directory) => (0, import_promises16.mkdir)(directory, { recursive: true, mode: 448 }))
|
|
30561
30646
|
);
|
|
30562
30647
|
const [pluginUrl, models] = await Promise.all([
|
|
30563
30648
|
writePlugin((0, import_path8.join)(input2.engineRoot, "plugin"), input2.access.apiOrigin),
|
|
@@ -30580,7 +30665,7 @@ function alanCodeSystemPrompt(alanSystemPrompt) {
|
|
|
30580
30665
|
|
|
30581
30666
|
${instructions}` : ALAN_CODE_TOOL_NAMING_PROMPT;
|
|
30582
30667
|
}
|
|
30583
|
-
var import_http3, import_https, import_fs7, import_path7, import_crypto12,
|
|
30668
|
+
var import_http3, import_https, import_fs7, import_path7, import_crypto12, import_promises16, 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, ACTIVATION_WAIT_MS, ACTIVATION_POLL_MS, CatalogResponseError, ALAN_CODE_ENGINE_PATH_ENV, ALAN_CODE_ENGINE_COMMAND, ALAN_CODE_ENGINE_NAME, WINDOWS_RUNNABLE_EXTENSION, ALAN_CODE_ENGINE_PLUGIN_VERSION, ALAN_CODE_TOOL_NAMING_PROMPT;
|
|
30584
30669
|
var init_alan_code = __esm({
|
|
30585
30670
|
"../agent-core/dist/providers/alan-code.js"() {
|
|
30586
30671
|
"use strict";
|
|
@@ -30594,7 +30679,7 @@ var init_alan_code = __esm({
|
|
|
30594
30679
|
import_path7 = require("path");
|
|
30595
30680
|
init_runtime_v2();
|
|
30596
30681
|
import_crypto12 = require("crypto");
|
|
30597
|
-
|
|
30682
|
+
import_promises16 = require("fs/promises");
|
|
30598
30683
|
import_path8 = require("path");
|
|
30599
30684
|
import_url = require("url");
|
|
30600
30685
|
ALAN_CODE_BASELINE_PROMPT = "You are alan-code, an interactive CLI coding agent that helps users with software engineering tasks. Use the instructions below and the tools available to you to assist the user.\n\nDo not invent URLs. Use verified URLs or ones supplied by the user or project.\n\nIf the user asks for help or wants to give feedback, inform them of the following:\n- `--harness-help` / harness help: learn how to run alan-code\n- For product feedback or bugs, report through the Alan / Supatest issue channels used by this repository\n\nWhen the user directly asks about alan-code capabilities (for example \"can alan-code\u2026\", \"does the harness have\u2026\") or asks in second person about your abilities, answer from the tools and instructions available in this session. If a docs/fetch tool is available and project docs URLs are known, use them; otherwise inspect local README / AGENTS.md rather than inventing product claims.\n\n# Personality\n\nYour default personality and tone is concise, direct, and friendly. You communicate efficiently, always keeping the user clearly informed about ongoing actions without unnecessary detail. You always prioritize actionable guidance, clearly stating assumptions, environment prerequisites, and next steps. Unless explicitly asked, you avoid excessively verbose explanations about your work.\n\n# Tone and style\n\nYou should be concise, direct, and to the point. When you run a non-trivial bash command, you should explain what the command does and why you are running it, so the user understands what you are doing (especially important for commands that change their system).\nRemember that your output will be displayed on a command line interface. Your responses can use GitHub-flavored markdown for formatting, and will be rendered in a monospace font using the CommonMark specification.\nOutput text to communicate with the user; all text you output outside of tool use is displayed to the user. Only use tools to complete tasks. Never use tools like Bash or code comments as means to communicate with the user during the session.\nIf you cannot or will not help the user with something, do not lecture about why. Offer helpful alternatives if possible; otherwise keep the response to 1-2 sentences.\nOnly use emojis if the user explicitly requests it. Avoid emojis in all communication unless asked.\nIMPORTANT: Minimize output tokens while staying helpful, correct, and accurate. Only address the specific query or task. Avoid tangential information unless it is critical to completing the request. If you can answer in 1-3 sentences or a short paragraph, do that.\nAnswer the user's question directly. One-word answers are best when they suffice. Avoid text before/after your response such as \"The answer is <answer>.\", \"Here is the content of the file\u2026\", \"Based on the information provided\u2026\", or \"Here is what I will do next\u2026\". Examples of appropriate verbosity:\n<example>\nuser: what is 2+2?\nassistant: 4\n</example>\n\n<example>\nuser: is 11 a prime number?\nassistant: Yes\n</example>\n\n<example>\nuser: what command should I run to list files in the current directory?\nassistant: ls\n</example>\n\n<example>\nuser: what command should I run to watch files in the current directory?\nassistant: [use tools to inspect the project, then answer]\nnpm run dev\n</example>\n\n<example>\nuser: what files are in the directory src/?\nassistant: [lists files and sees foo.c, bar.c, baz.c]\nuser: which file contains the implementation of foo?\nassistant: src/foo.c\n</example>\n\n<example>\nuser: write tests for new feature\nassistant: [searches for similar tests, reads relevant files concurrently, edits/writes tests]\n</example>\n\n# Responsiveness\n\n## Preamble messages\n\nBefore making tool calls, send a brief preamble to the user explaining what you're about to do. When sending preamble messages, follow these principles and examples:\n\n- **Logically group related actions**: if you're about to run several related commands, describe them together in one preamble rather than sending a separate note for each.\n- **Keep it concise**: be no more than 1-2 sentences, focused on immediate, tangible next steps. (8\u201312 words for quick updates).\n- **Build on prior context**: if this is not your first tool call, use the preamble message to connect the dots with what's been done so far and create a sense of momentum and clarity for the user to understand your next actions.\n- **Keep your tone light, friendly and curious**: add small touches of personality in preambles feel collaborative and engaging.\n- **Exception**: Avoid adding a preamble for every trivial read (e.g., `cat` a single file) unless it's part of a larger grouped action.\n\nExamples:\n\n- \"I've explored the repo; now checking the API route definitions.\"\n- \"Next, I'll patch the config and update the related tests.\"\n- \"I'm about to scaffold the CLI commands and helper functions.\"\n- \"Ok cool, so I've wrapped my head around the repo. Now digging into the API routes.\"\n- \"Config's looking tidy. Next up is patching helpers to keep things in sync.\"\n- \"Finished poking at the DB gateway. I will now chase down error handling.\"\n- \"Alright, build pipeline order is interesting. Checking how it reports failures.\"\n- \"Spotted a clever caching util; now hunting where it gets used.\"\n\n# Planning\n\nIf a planning tool is available, use it when it helps track complex work. Keep the plan brief and update it as work progresses.\n\nNote that plans are not for padding out simple work with filler steps or stating the obvious. The content of your plan should not involve doing anything that you aren't capable of doing (i.e. don't try to test things that you can't test). Do not use plans for simple or single-step queries that you can just do or answer immediately.\n\nWhen a planning tool displays the plan, summarize only what changed or what comes next.\n\nKeep any active plan aligned with the work completed and remaining.\n\nUse a plan when:\n\n- The task is non-trivial and will require multiple actions over a long time horizon.\n- There are logical phases or dependencies where sequencing matters.\n- The work has ambiguity that benefits from outlining high-level goals.\n- You want intermediate checkpoints for feedback and validation.\n- When the user asked you to do more than one thing in a single prompt\n- The user has asked you to use the plan tool (aka \"TODOs\")\n- You generate additional steps while working, and plan to do them before yielding to the user\n\n## Examples\n\n**High-quality plans**\n\nExample 1:\n\n1. Add CLI entry with file args\n2. Parse Markdown via CommonMark library\n3. Apply semantic HTML template\n4. Handle code blocks, images, links\n5. Add error handling for invalid files\n\nExample 2:\n\n1. Define CSS variables for colors\n2. Add toggle with localStorage state\n3. Refactor components to use variables\n4. Verify all views for readability\n5. Add smooth theme-change transition\n\nExample 3:\n\n1. Set up Node.js + WebSocket server\n2. Add join/leave broadcast events\n3. Implement messaging with timestamps\n4. Add usernames + mention highlighting\n5. Persist messages in lightweight DB\n6. Add typing indicators + unread count\n\n**Low-quality plans**\n\nExample 1:\n\n1. Create CLI tool\n2. Add Markdown parser\n3. Convert to HTML\n\nExample 2:\n\n1. Add dark mode toggle\n2. Save preference\n3. Make styles look good\n\nExample 3:\n\n1. Create single-file HTML game\n2. Run quick sanity check\n3. Summarize usage instructions\n\nIf you need to write a plan, only write high quality plans, not low quality ones.\n\n## Plan mode and clarification (harness specifics)\n\n- When the session is in plan mode, inspect without making changes and produce a concrete plan. Outside plan mode, proceed with authorized work and ask for approval only when the action requires it.\n- Prefer the durable plan file path over relying on chat memory after compaction.\n- When requirements are ambiguous, ask a targeted question using an available user-input tool instead of guessing.\n- An execution checklist is not a substitute for a durable plan when the task requires one.\n\n# Task execution\n\nYou are a coding agent. Please keep going until the query is completely resolved, before ending your turn and yielding back to the user. Only terminate your turn when you are sure that the problem is solved. Autonomously resolve the query to the best of your ability, using the tools available to you, before coming back to the user. Do NOT guess or make up an answer.\n\nYou MUST adhere to the following criteria when solving queries:\n\n- Working on the repo(s) in the current environment is allowed, even if they are proprietary.\n- Analyzing code for vulnerabilities is allowed.\n- Showing user code and tool call details is allowed.\n- Use the editing tools available in the current host to modify files. Do not assume a particular tool name.\n\nIf completing the user's task requires writing or modifying files, your code and final answer should follow these coding guidelines, though user instructions (i.e. AGENTS.md) may override these guidelines:\n\n- Fix the problem at the root cause rather than applying surface-level patches, when possible.\n- Avoid unneeded complexity in your solution.\n- Do not attempt to fix unrelated bugs or broken tests. It is not your responsibility to fix them. (You may mention them to the user in your final message though.)\n- Update documentation as necessary.\n- Keep changes consistent with the style of the existing codebase. Changes should be minimal and focused on the task.\n- Use `git log` and `git blame` to search the history of the codebase if additional context is required.\n- NEVER add copyright or license headers unless specifically requested.\n- Do not waste tokens by re-reading files after editing them. The tool call will fail if it didn't work. The same goes for making folders, deleting folders, etc.\n- Do not `git commit` your changes or create new git branches unless explicitly requested.\n- Add comments when they explain a non-obvious invariant or reason for a decision.\n- Do not use one-letter variable names unless explicitly requested.\n- NEVER output inline citations like \"\u3010F:README.md\u2020L5-L14\u3011\" in your outputs. The CLI is not able to render these so they will just be broken in the UI. Instead, if you output valid filepaths, users will be able to click on them to open the files in their editor.\n\n# Validating your work\n\nIf the codebase has tests or the ability to build or run, consider using them to verify that your work is complete.\n\nWhen testing, your philosophy should be to start as specific as possible to the code you changed so that you can catch issues efficiently, then make your way to broader tests as you build confidence. If there's no test for the code you changed, and if the adjacent patterns in the codebases show that there's a logical place for you to add a test, you may do so. However, do not add tests to codebases with no tests.\n\nSimilarly, once you're confident in correctness, you can suggest or use formatting commands to ensure that your code is well formatted. If there are issues you can iterate up to 3 times to get formatting right, but if you still can't manage it's better to save the user time and present them a correct solution where you call out the formatting in your final message. If the codebase does not have a formatter configured, do not add one.\n\nFor all of testing, running, building, and formatting, do not attempt to fix unrelated bugs. It is not your responsibility to fix them. (You may mention them to the user in your final message though.)\n\nBe mindful of whether to run validation commands proactively. In the absence of behavioral guidance:\n\n- When running in a non-interactive mode where edits are auto-approved (print/headless, or the `allow edits` permission mode), proactively run tests, lint and do whatever you need to ensure you've completed the task.\n- In plan mode, stay read-only. Otherwise, run focused checks after changes when the host permits them.\n- When working on test-related tasks, such as adding tests, fixing tests, or reproducing a bug to verify behavior, you may proactively run tests regardless of permission mode. Use your judgement to decide whether this is a test-related task.\n\n# Ambition vs. precision\n\nFor tasks that have no prior context (i.e. the user is starting something brand new), you should feel free to be ambitious and demonstrate creativity with your implementation.\n\nIf you're operating in an existing codebase, you should make sure you do exactly what the user asks with surgical precision. Treat the surrounding codebase with respect, and don't overstep (i.e. changing filenames or variables unnecessarily). You should balance being sufficiently ambitious and proactive when completing tasks of this nature.\n\nYou should use judicious initiative to decide on the right level of detail and complexity to deliver based on the user's needs. This means showing good judgment that you're capable of doing the right extras without gold-plating. This might be demonstrated by high-value, creative touches when scope of the task is vague; while being surgical and targeted when scope is tightly specified.\n\n# Sharing progress updates\n\nFor especially longer tasks that you work on (i.e. requiring many tool calls, or a plan with multiple steps), you should provide progress updates back to the user at reasonable intervals. These updates should be structured as a concise sentence or two (no more than 8-10 words long) recapping progress so far in plain language: this update demonstrates your understanding of what needs to be done, progress so far (i.e. files explores, subtasks complete), and where you're going next.\n\nBefore doing large chunks of work that may incur latency as experienced by the user (i.e. writing a new file), you should send a concise message to the user with an update indicating what you're about to do to ensure they know what you're spending time on. Don't start editing or writing large files before informing the user what you are doing and why.\n\nThe messages you send before tool calls should describe what is immediately about to be done next in very concise language. If there was previous work done, this preamble message should also include a note about the work done so far to bring the user along.\n\n# Presenting your work and final message\n\nYour final message should read naturally, like an update from a concise teammate. For casual conversation, brainstorming tasks, or quick questions from the user, respond in a friendly, conversational tone. You should ask questions, suggest ideas, and adapt to the user's style. If you've finished a large amount of work, when describing what you've done to the user, you should follow the final answer formatting guidelines to communicate substantive changes. You don't need to add structured formatting for one-word answers, greetings, or purely conversational exchanges.\n\nYou can skip heavy formatting for single, simple actions or confirmations. In these cases, respond in plain sentences with any relevant next step or quick option. Reserve multi-section structured responses for results that need grouping or explanation.\n\nThe user is working on the same computer as you, and has access to your work. As such there's no need to show the full contents of large files you have already written unless the user explicitly asks for them. Similarly, if you've created or modified files, there's no need to tell users to \"save the file\" or \"copy the code into a file\"\u2014just reference the file path.\n\nComplete authorized next steps, including relevant tests. Ask before a consequential action that needs approval, and briefly report anything you could not verify.\n\nBrevity is very important as a default. You should be very concise (i.e. no more than 10 lines), but can relax this requirement for tasks where additional detail and comprehensiveness is important for the user's understanding.\n\n## Final answer structure and style guidelines\n\nYou are producing plain text that will later be styled by the CLI. Follow these rules exactly. Formatting should make results easy to scan, but not feel mechanical. Use judgment to decide how much structure adds value.\n\n**Section Headers**\n\n- Use only when they improve clarity \u2014 they are not mandatory for every answer.\n- Choose descriptive names that fit the content\n- Keep headers short (1\u20133 words) and in `**Title Case**`. Always start headers with `**` and end with `**`\n- Use the blank lines required by the renderer for headings and lists.\n- Section headers should only be used where they genuinely improve scanability; avoid fragmenting the answer.\n\n**Bullets**\n\n- Use `-` followed by a space for every bullet.\n- Merge related points when possible; avoid a bullet for every trivial detail.\n- Keep bullets to one line unless breaking for clarity is unavoidable.\n- Group into short lists (4\u20136 bullets) ordered by importance.\n- Use consistent keyword phrasing and formatting across sections.\n\n**Monospace**\n\n- Wrap all commands, file paths, env vars, and code identifiers in backticks (`` `...` ``).\n- Apply to inline examples and to bullet keywords if the keyword itself is a literal file/command.\n- Never mix monospace and bold markers; choose one based on whether it's a keyword (`**`) or inline code/path (`` ` ``).\n\n**File References**\n\nWhen referencing files in your response, make sure to include the relevant start line and always follow the below rules:\n\n- Use inline code to make file paths clickable.\n- Each reference should have a stand alone path. Even if it's the same file.\n- Accepted: absolute, workspace\u2011relative, a/ or b/ diff prefixes, or bare filename/suffix.\n- Line/column (1\u2011based, optional): :line[:column] or #Lline[Ccolumn] (column defaults to 1).\n- Do not use URIs like file://, vscode://, or https://.\n- Do not provide range of lines\n- Examples: src/app.ts, src/app.ts:42, b/server/index.js#L10, C:\\repo\\project\\main.rs:12:5\n\n**Structure**\n\n- Place related bullets together; don't mix unrelated concepts in the same section.\n- Order sections from general \u2192 specific \u2192 supporting info.\n- For subsections (e.g., \"Binaries\" under \"Rust Workspace\"), introduce with a bolded keyword bullet, then list items under it.\n- Match structure to complexity:\n - Multi-part or detailed results \u2192 use clear headers and grouped bullets.\n - Simple results \u2192 minimal headers, possibly just a short list or paragraph.\n\n**Tone**\n\n- Keep the voice collaborative and natural, like a coding partner handing off work.\n- Be concise and factual \u2014 no filler or conversational commentary and avoid unnecessary repetition\n- Use present tense and active voice (e.g., \"Runs tests\" not \"This will run tests\").\n- Keep descriptions self-contained; don't refer to \"above\" or \"below\".\n- Use parallel structure in lists for consistency.\n\n**Don't**\n\n- Don't use literal words \"bold\" or \"monospace\" in the content.\n- Don't nest bullets or create deep hierarchies.\n- Don't output ANSI escape codes directly \u2014 the CLI renderer applies them.\n- Don't cram unrelated keywords into a single bullet; split for clarity.\n- Don't let keyword lists run long \u2014 wrap or reformat for scanability.\n\nGenerally, ensure your final answers adapt their shape and depth to the request. For example, answers to code explanations should have a precise, structured explanation with code references that answer the question directly. For tasks with a simple implementation, lead with the outcome and supplement only with what's needed for clarity. Larger changes can be presented as a logical walkthrough of your approach, grouping related steps, explaining rationale where it adds value, and highlighting next actions to accelerate the user. Your answers should provide the right level of detail while being easily scannable.\n\nFor casual greetings, acknowledgements, or other one-off conversational messages that are not delivering substantive information or structured results, respond naturally without section headers or bullet formatting.\n\n# Professional objectivity\n\nPrioritize technical accuracy and truthfulness over validating the user's beliefs. Focus on facts and problem-solving. Be direct and objective without unnecessary praise or emotional validation. Disagree when needed. When uncertain, investigate before confirming the user's assumptions.\n\n# Proactiveness\n\nProactively complete work that follows from the user's request. Avoid unrelated actions that would surprise the user. Strike a balance between:\n\n1. Doing the right thing when asked, including follow-up actions\n2. Not surprising the user with unrequested actions\n For example, if the user asks how to approach something, answer first; do not immediately jump into edits.\n\n# Following conventions\n\nWhen changing files, first understand the file's conventions. Mimic code style, use existing libraries and utilities, and follow existing patterns.\n\n- NEVER assume a library is available, even if it is well known. Whenever you write code that uses a library or framework, first check that this codebase already uses it (neighboring files, package.json, cargo.toml, go.mod, etc.).\n- When creating a new component, first look at existing components for framework choice, naming, typing, and other conventions.\n- When editing code, first look at surrounding context (especially imports) to understand chosen frameworks/libraries, then make the change idiomatically.\n- Always follow security best practices. Never introduce code that exposes or logs secrets and keys. Never commit secrets or keys to the repository.\n\n# Doing tasks\n\nThe user will primarily request software engineering tasks: bugs, features, refactors, explanations, and more. Recommended steps:\n\n- Use available search/read tools extensively to understand the codebase and the query (in parallel when independent).\n- Implement the solution with the tools available to you.\n- Prefer editing existing files. Create documentation when the task or project instructions require it.\n- Verify when possible with tests. NEVER assume a specific test framework or script \u2014 check README / AGENTS.md or search the repo.\n- Run lint and typecheck commands (for example npm run lint, npm run typecheck, ruff, pnpm lint) if they were provided to you \u2014 see Validating your work for when to run them proactively vs. when to hold off. If you cannot find the correct command, ask the user, and if they supply it, proactively suggest writing it to AGENTS.md so you know next time.\n\n- Tool results and user messages may include <system-reminder> tags. Those tags contain useful reminders. They are NOT part of the user's provided input or the tool result.\n\n# Tool usage policy\n\n- Prefer specialized file tools over shell for reading, editing, writing, listing, and searching when those tools are available. Use the `grep`, `glob`, and `list` tools instead of bash for search and listing \u2014 they are ripgrep-backed and return structured, length-capped results. Use shell for real system commands (git, package managers, builds, tests, process control).\n- When doing broad codebase exploration, use the available search tools and delegate only when the task benefits from independent work.\n- You can call multiple tools in one response. When multiple independent pieces of information are needed, batch tool calls for performance. When making multiple bash tool calls, send a single message with multiple tool calls so they can run in parallel (for example git status and git diff together).\n- Match edit old-text exactly, including whitespace.\n- If a tool call is denied by policy, adapt: use an allowed approach or ask the user. Do not retry the same blocked call in a loop.\n\n## Shell commands\n\nWhen using the shell, you must adhere to the following guidelines:\n\n- When searching for text or files, prefer using `rg` or `rg --files` respectively because `rg` is much faster than alternatives like `grep` and `find`. (If the `rg` command is not found, then use alternatives.) Reach for the shell only when the `grep`/`glob` tools cannot express the query \u2014 for example counting matches, or piping results into another command.\n- Search narrow first: use `rg -l` or `rg -c` to find which files match, then read only those files. Do not dump full match bodies across a repo into context.\n- Never pipe a large file into your context. Do not `cat` a big file; use the `read` tool with an offset/limit, or `sed -n 'START,ENDp'` for a specific range.\n- Do not use python scripts to attempt to output larger chunks of a file.\n\nIMPORTANT: Before you begin work, think about what the code you're editing is supposed to do based on the filenames and directory structure.\n\n# AGENTS.md spec\n\n- Repos often contain AGENTS.md files. These files can appear anywhere within the repository.\n- These files are a way for humans to give you (the agent) instructions or tips for working within the container.\n- Some examples might be: coding conventions, info about how code is organized, or instructions for how to run or test code.\n- Instructions in AGENTS.md files:\n - The scope of an AGENTS.md file is the entire directory tree rooted at the folder that contains it.\n - For every file you touch in the final change, you must obey instructions in any AGENTS.md file whose scope includes that file.\n - Instructions about code style, structure, naming, etc. apply only to code within the AGENTS.md file's scope, unless the file states otherwise.\n - More-deeply-nested AGENTS.md files take precedence in the case of conflicting instructions.\n - Direct system/developer/user instructions (as part of a prompt) take precedence over AGENTS.md instructions.\n- The contents of the AGENTS.md file at the root of the repo and the project directory are loaded into your context automatically and don't need to be re-read. AGENTS.md files in subdirectories are NOT loaded automatically: when working in a subdirectory, or a directory outside the CWD, check for any AGENTS.md files that may be applicable.\n\n# Permissions and safety\n\n- Never commit secrets or keys.\n- Never create a git commit unless the user explicitly asks.\n- Do not run destructive commands (mass delete, force-push, hard reset) unless the user clearly requested them.\n";
|
|
@@ -38058,7 +38143,7 @@ function within(root, path) {
|
|
|
38058
38143
|
}
|
|
38059
38144
|
async function resolveReal(path) {
|
|
38060
38145
|
try {
|
|
38061
|
-
return await (0,
|
|
38146
|
+
return await (0, import_promises24.realpath)(path);
|
|
38062
38147
|
} catch {
|
|
38063
38148
|
const parent = (0, import_path9.dirname)(path);
|
|
38064
38149
|
if (parent === path) return path;
|
|
@@ -38087,14 +38172,14 @@ function createWorkspaceFs(roots, writable) {
|
|
|
38087
38172
|
return {
|
|
38088
38173
|
read: async (params) => {
|
|
38089
38174
|
const path = await confined(params);
|
|
38090
|
-
const bytes = await (0,
|
|
38175
|
+
const bytes = await (0, import_promises24.readFile)(path);
|
|
38091
38176
|
if (bytes.byteLength > MAX_READ_BYTES) throw new FsDenied(`${path} is too large to read`);
|
|
38092
38177
|
return { content: sliceLines(bytes.toString("utf8"), params) };
|
|
38093
38178
|
},
|
|
38094
38179
|
write: async (params) => {
|
|
38095
38180
|
if (!writable) throw new FsDenied("This session is read-only");
|
|
38096
38181
|
const path = await confined(params);
|
|
38097
|
-
await (0,
|
|
38182
|
+
await (0, import_promises24.writeFile)(path, asString(params.content));
|
|
38098
38183
|
return {};
|
|
38099
38184
|
}
|
|
38100
38185
|
};
|
|
@@ -38697,7 +38782,7 @@ async function acpTurnInput(run, context) {
|
|
|
38697
38782
|
const encoded = await Promise.all(
|
|
38698
38783
|
images.map(async (image) => ({
|
|
38699
38784
|
mimeType: image.mimeType,
|
|
38700
|
-
data: (await (0,
|
|
38785
|
+
data: (await (0, import_promises25.readFile)(image.path)).toString("base64")
|
|
38701
38786
|
}))
|
|
38702
38787
|
);
|
|
38703
38788
|
return {
|
|
@@ -38706,7 +38791,7 @@ async function acpTurnInput(run, context) {
|
|
|
38706
38791
|
...encoded.length ? { images: encoded, imagePaths: images.map((image) => image.path) } : {}
|
|
38707
38792
|
};
|
|
38708
38793
|
}
|
|
38709
|
-
var
|
|
38794
|
+
var import_promises24, import_path9, import_crypto13, import_promises25, 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;
|
|
38710
38795
|
var init_acp3 = __esm({
|
|
38711
38796
|
"../agent-core/dist/providers/acp.js"() {
|
|
38712
38797
|
"use strict";
|
|
@@ -38717,12 +38802,12 @@ var init_acp3 = __esm({
|
|
|
38717
38802
|
init_chunk_M6YHY2EZ();
|
|
38718
38803
|
init_chunk_FPGAN4XO();
|
|
38719
38804
|
init_chunk_YXWJW7I5();
|
|
38720
|
-
|
|
38805
|
+
import_promises24 = require("fs/promises");
|
|
38721
38806
|
import_path9 = require("path");
|
|
38722
38807
|
init_effort();
|
|
38723
38808
|
init_acp();
|
|
38724
38809
|
import_crypto13 = require("crypto");
|
|
38725
|
-
|
|
38810
|
+
import_promises25 = require("fs/promises");
|
|
38726
38811
|
init_agent2();
|
|
38727
38812
|
CURSOR_ASK_QUESTION = "cursor/ask_question";
|
|
38728
38813
|
copilotAcpProfile = {
|
|
@@ -39238,7 +39323,7 @@ var init_acp3 = __esm({
|
|
|
39238
39323
|
const turn = new AcpTurn(`acp-${this.#turns}-${id}`, this.#profile);
|
|
39239
39324
|
let finish = () => {
|
|
39240
39325
|
};
|
|
39241
|
-
const done = new Promise((
|
|
39326
|
+
const done = new Promise((resolve9) => {
|
|
39242
39327
|
finish = (outcome2) => {
|
|
39243
39328
|
if (this.#current?.id !== id) return;
|
|
39244
39329
|
this.#current = void 0;
|
|
@@ -39246,7 +39331,7 @@ var init_acp3 = __esm({
|
|
|
39246
39331
|
if (this.#state === "busy") this.#state = "idle";
|
|
39247
39332
|
this.#host.scanDescendants(true);
|
|
39248
39333
|
this.#emit({ type: "turn_ended", turnId: id, outcome: outcome2 });
|
|
39249
|
-
|
|
39334
|
+
resolve9({ turnId: id, outcome: outcome2, providerSessionId: this.#sessionId });
|
|
39250
39335
|
};
|
|
39251
39336
|
});
|
|
39252
39337
|
const active = { id, turn, done, finish, cancelRequested: false };
|
|
@@ -40247,7 +40332,7 @@ async function sameDirectory(left, right) {
|
|
|
40247
40332
|
}
|
|
40248
40333
|
async function canonicalDirectory(directory) {
|
|
40249
40334
|
try {
|
|
40250
|
-
return await (0,
|
|
40335
|
+
return await (0, import_promises26.realpath)(directory);
|
|
40251
40336
|
} catch {
|
|
40252
40337
|
return (0, import_path10.resolve)(directory);
|
|
40253
40338
|
}
|
|
@@ -40443,7 +40528,7 @@ function openCodeTurnInput(run, context) {
|
|
|
40443
40528
|
...images.length ? { imagePaths: images.map((image) => image.path) } : {}
|
|
40444
40529
|
};
|
|
40445
40530
|
}
|
|
40446
|
-
var import_http4, import_crypto14,
|
|
40531
|
+
var import_http4, import_crypto14, import_promises26, import_path10, import_path11, import_url2, import_crypto15, IDLE_SOCKET_MS2, 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_OPERATIONS, 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;
|
|
40447
40532
|
var init_opencode = __esm({
|
|
40448
40533
|
"../agent-core/dist/providers/opencode.js"() {
|
|
40449
40534
|
"use strict";
|
|
@@ -40457,7 +40542,7 @@ var init_opencode = __esm({
|
|
|
40457
40542
|
import_http4 = require("http");
|
|
40458
40543
|
init_runtime_v2();
|
|
40459
40544
|
import_crypto14 = require("crypto");
|
|
40460
|
-
|
|
40545
|
+
import_promises26 = require("fs/promises");
|
|
40461
40546
|
import_path10 = require("path");
|
|
40462
40547
|
init_agent2();
|
|
40463
40548
|
import_path11 = require("path");
|
|
@@ -41922,8 +42007,8 @@ function createDroidPeer(writer, handlers) {
|
|
|
41922
42007
|
},
|
|
41923
42008
|
request: (method, params = {}) => {
|
|
41924
42009
|
const id = `alan-${counter.next++}`;
|
|
41925
|
-
return new Promise((
|
|
41926
|
-
pending.set(id, { method, resolve:
|
|
42010
|
+
return new Promise((resolve9, reject) => {
|
|
42011
|
+
pending.set(id, { method, resolve: resolve9, reject });
|
|
41927
42012
|
writer.write(envelope("request", { id, method, params })).catch((error61) => {
|
|
41928
42013
|
pending.delete(id);
|
|
41929
42014
|
reject(error61 instanceof Error ? error61 : new Error(String(error61)));
|
|
@@ -42258,12 +42343,12 @@ async function droidTurnInput(run, context) {
|
|
|
42258
42343
|
const encoded = await Promise.all(
|
|
42259
42344
|
images.map(async (image) => ({
|
|
42260
42345
|
mimeType: image.mimeType,
|
|
42261
|
-
data: (await (0,
|
|
42346
|
+
data: (await (0, import_promises27.readFile)(image.path)).toString("base64")
|
|
42262
42347
|
}))
|
|
42263
42348
|
);
|
|
42264
42349
|
return { turnId: run.runId, text: text2, ...encoded.length ? { images: encoded } : {} };
|
|
42265
42350
|
}
|
|
42266
|
-
var import_crypto16,
|
|
42351
|
+
var import_crypto16, import_promises27, 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;
|
|
42267
42352
|
var init_droid = __esm({
|
|
42268
42353
|
"../agent-core/dist/providers/droid.js"() {
|
|
42269
42354
|
"use strict";
|
|
@@ -42276,7 +42361,7 @@ var init_droid = __esm({
|
|
|
42276
42361
|
init_chunk_YXWJW7I5();
|
|
42277
42362
|
init_runtime_v2();
|
|
42278
42363
|
import_crypto16 = require("crypto");
|
|
42279
|
-
|
|
42364
|
+
import_promises27 = require("fs/promises");
|
|
42280
42365
|
init_agent2();
|
|
42281
42366
|
FACTORY_API_VERSION = "1.0.0";
|
|
42282
42367
|
FACTORY_PROTOCOL_VERSION = "1.187.0";
|
|
@@ -42548,14 +42633,14 @@ var init_droid = __esm({
|
|
|
42548
42633
|
const turn = new DroidTurn(sessionId, this.#memory);
|
|
42549
42634
|
let finish = () => {
|
|
42550
42635
|
};
|
|
42551
|
-
const done = new Promise((
|
|
42636
|
+
const done = new Promise((resolve9) => {
|
|
42552
42637
|
finish = (outcome2) => {
|
|
42553
42638
|
if (this.#current?.id !== id) return;
|
|
42554
42639
|
this.#current = void 0;
|
|
42555
42640
|
if (this.#state === "busy") this.#state = "idle";
|
|
42556
42641
|
this.#host.scanDescendants(true);
|
|
42557
42642
|
this.#emit({ type: "turn_ended", turnId: id, outcome: outcome2 });
|
|
42558
|
-
|
|
42643
|
+
resolve9({ turnId: id, outcome: outcome2, providerSessionId: this.#sessionId });
|
|
42559
42644
|
};
|
|
42560
42645
|
});
|
|
42561
42646
|
const active = { id, turn, done, finish, cancelRequested: false };
|
|
@@ -42751,7 +42836,7 @@ function settingsPath(env) {
|
|
|
42751
42836
|
async function readSettings(path) {
|
|
42752
42837
|
let raw;
|
|
42753
42838
|
try {
|
|
42754
|
-
raw = (await (0,
|
|
42839
|
+
raw = (await (0, import_promises28.readFile)(path, "utf8")).trim();
|
|
42755
42840
|
} catch {
|
|
42756
42841
|
return {};
|
|
42757
42842
|
}
|
|
@@ -42769,8 +42854,8 @@ async function selectAntigravityApiKeyMode(env) {
|
|
|
42769
42854
|
const settings2 = await readSettings(path);
|
|
42770
42855
|
if (settings2 === "malformed") return "malformed";
|
|
42771
42856
|
if (settings2.modelProvider === "gemini") return "already_selected";
|
|
42772
|
-
await (0,
|
|
42773
|
-
await (0,
|
|
42857
|
+
await (0, import_promises28.mkdir)((0, import_path12.dirname)(path), { recursive: true });
|
|
42858
|
+
await (0, import_promises28.writeFile)(path, JSON.stringify({ ...settings2, modelProvider: "gemini" }), { mode: 384 });
|
|
42774
42859
|
return "selected";
|
|
42775
42860
|
}
|
|
42776
42861
|
function readAntigravityCapabilities(version2, help) {
|
|
@@ -43369,7 +43454,7 @@ function antigravityTurnInput(run, context) {
|
|
|
43369
43454
|
});
|
|
43370
43455
|
return { turnId: run.runId, text: appendImagePathReferences(text2, images) };
|
|
43371
43456
|
}
|
|
43372
|
-
var
|
|
43457
|
+
var import_promises28, import_path12, import_fs8, import_path13, import_path14, import_url3, import_crypto17, NO_ANTIGRAVITY_CAPABILITIES, INSTRUCTIONS_FILE, MAX_INSTRUCTION_CHARS, SHORTENED_NOTE, DIFF_BLOCK_START, DIFF_BLOCK_END, HUNK_HEADER, TRANSCRIPT_FILE, FULL_TRANSCRIPT_FILE, LOG_DIRS, TOOL_RESULT_TYPES, BrainTranscript, AntigravityTranscripts, ANTIGRAVITY_GRAMMAR_NAME, AntigravityGrammar, ignored, HANDLERS, SUCCESSFUL_STATUSES, SESSION_START_TYPES, RESULT_TYPES, SUBAGENT_START_TYPES, RESUME_FORKED, EXITED_WITHOUT_RESULT, AntigravityTurn, DEFAULTS6, AntigravitySession, WINDOWS_LINE_MARGIN;
|
|
43373
43458
|
var init_antigravity = __esm({
|
|
43374
43459
|
"../agent-core/dist/providers/antigravity.js"() {
|
|
43375
43460
|
"use strict";
|
|
@@ -43380,7 +43465,7 @@ var init_antigravity = __esm({
|
|
|
43380
43465
|
init_chunk_M6YHY2EZ();
|
|
43381
43466
|
init_chunk_FPGAN4XO();
|
|
43382
43467
|
init_chunk_YXWJW7I5();
|
|
43383
|
-
|
|
43468
|
+
import_promises28 = require("fs/promises");
|
|
43384
43469
|
import_path12 = require("path");
|
|
43385
43470
|
init_type_guards();
|
|
43386
43471
|
import_fs8 = require("fs");
|
|
@@ -43880,7 +43965,7 @@ function parseConfig(raw) {
|
|
|
43880
43965
|
}
|
|
43881
43966
|
async function writeCommandCodeProjectMcp(cwd, mcp) {
|
|
43882
43967
|
const path = (0, import_path15.join)(cwd, ".mcp.json");
|
|
43883
|
-
const original = await (0,
|
|
43968
|
+
const original = await (0, import_promises29.readFile)(path, "utf8").catch(() => null);
|
|
43884
43969
|
const config2 = parseConfig(original);
|
|
43885
43970
|
const next = {
|
|
43886
43971
|
...config2,
|
|
@@ -43897,12 +43982,12 @@ async function writeCommandCodeProjectMcp(cwd, mcp) {
|
|
|
43897
43982
|
}
|
|
43898
43983
|
}
|
|
43899
43984
|
};
|
|
43900
|
-
await (0,
|
|
43901
|
-
await (0,
|
|
43985
|
+
await (0, import_promises29.mkdir)(cwd, { recursive: true });
|
|
43986
|
+
await (0, import_promises29.writeFile)(path, `${JSON.stringify(next, null, 2)}
|
|
43902
43987
|
`);
|
|
43903
43988
|
return async () => {
|
|
43904
|
-
if (original === null) await (0,
|
|
43905
|
-
else await (0,
|
|
43989
|
+
if (original === null) await (0, import_promises29.rm)(path, { force: true });
|
|
43990
|
+
else await (0, import_promises29.writeFile)(path, original);
|
|
43906
43991
|
};
|
|
43907
43992
|
}
|
|
43908
43993
|
function commandCodeString(value) {
|
|
@@ -44074,7 +44159,7 @@ function commandCodeTurnInput(run, context) {
|
|
|
44074
44159
|
});
|
|
44075
44160
|
return { turnId: run.runId, text: appendImagePathReferences(text2, images) };
|
|
44076
44161
|
}
|
|
44077
|
-
var
|
|
44162
|
+
var import_promises29, import_path15, import_crypto18, COMMAND_CODE_GRAMMAR_NAME, SILENT3, CommandCodeGrammar, SHELL_TOOL, STOP_TOOLS, REPORTED_STATUS, SHELL_STATUS, SWEEP_INTERVAL_MS, CommandCodeBackgroundTasks, EXITED_WITHOUT_RESULT2, CommandCodeTurn, COMMAND_CODE_MAX_TURNS, DEFAULTS7, CommandCodeSession;
|
|
44078
44163
|
var init_command_code = __esm({
|
|
44079
44164
|
"../agent-core/dist/providers/command-code.js"() {
|
|
44080
44165
|
"use strict";
|
|
@@ -44085,7 +44170,7 @@ var init_command_code = __esm({
|
|
|
44085
44170
|
init_chunk_M6YHY2EZ();
|
|
44086
44171
|
init_chunk_FPGAN4XO();
|
|
44087
44172
|
init_chunk_YXWJW7I5();
|
|
44088
|
-
|
|
44173
|
+
import_promises29 = require("fs/promises");
|
|
44089
44174
|
import_path15 = require("path");
|
|
44090
44175
|
init_agent2();
|
|
44091
44176
|
init_runtime_v2();
|
|
@@ -44947,7 +45032,7 @@ function transportFailure(request2, error61) {
|
|
|
44947
45032
|
});
|
|
44948
45033
|
}
|
|
44949
45034
|
function readBody(incoming, url2, maxBytes) {
|
|
44950
|
-
return new Promise((
|
|
45035
|
+
return new Promise((resolve9, reject) => {
|
|
44951
45036
|
const declared = Number(incoming.headers["content-length"] ?? "0");
|
|
44952
45037
|
if (maxBytes !== void 0 && declared > maxBytes) {
|
|
44953
45038
|
incoming.destroy();
|
|
@@ -44966,7 +45051,7 @@ function readBody(incoming, url2, maxBytes) {
|
|
|
44966
45051
|
chunks.push(chunk);
|
|
44967
45052
|
});
|
|
44968
45053
|
incoming.on("error", reject);
|
|
44969
|
-
incoming.on("end", () =>
|
|
45054
|
+
incoming.on("end", () => resolve9(Buffer.concat(chunks)));
|
|
44970
45055
|
});
|
|
44971
45056
|
}
|
|
44972
45057
|
function isConnectionReset(error61) {
|
|
@@ -44974,7 +45059,7 @@ function isConnectionReset(error61) {
|
|
|
44974
45059
|
}
|
|
44975
45060
|
function exchange(request2, agents, attempt = 0) {
|
|
44976
45061
|
const { signal, url: url2 } = request2;
|
|
44977
|
-
return new Promise((
|
|
45062
|
+
return new Promise((resolve9, reject) => {
|
|
44978
45063
|
if (signal.aborted) {
|
|
44979
45064
|
reject(signal.reason);
|
|
44980
45065
|
return;
|
|
@@ -45001,7 +45086,7 @@ function exchange(request2, agents, attempt = 0) {
|
|
|
45001
45086
|
const stale = outgoing.reusedSocket && !responded && isConnectionReset(error61);
|
|
45002
45087
|
if (stale && attempt < STALE_SOCKET_RETRIES && !signal.aborted) {
|
|
45003
45088
|
settle();
|
|
45004
|
-
|
|
45089
|
+
resolve9(exchange(request2, agents, attempt + 1));
|
|
45005
45090
|
return;
|
|
45006
45091
|
}
|
|
45007
45092
|
fail(error61);
|
|
@@ -45014,7 +45099,7 @@ function exchange(request2, agents, attempt = 0) {
|
|
|
45014
45099
|
readBody(incoming, url2, isRedirect(status) ? void 0 : request2.maxBodyBytes).then(
|
|
45015
45100
|
(body) => {
|
|
45016
45101
|
settle();
|
|
45017
|
-
|
|
45102
|
+
resolve9({ status, headers: incoming.headers, body });
|
|
45018
45103
|
},
|
|
45019
45104
|
fail
|
|
45020
45105
|
);
|
|
@@ -45184,6 +45269,19 @@ var GitFault = class extends Error {
|
|
|
45184
45269
|
}
|
|
45185
45270
|
};
|
|
45186
45271
|
|
|
45272
|
+
// src/capabilities/git/repository.ts
|
|
45273
|
+
var import_promises4 = require("fs/promises");
|
|
45274
|
+
var import_node_path3 = require("path");
|
|
45275
|
+
async function assertValidBranch(git, repoRoot, branch, signal) {
|
|
45276
|
+
const output2 = await git.run(
|
|
45277
|
+
{ cwd: repoRoot, args: ["check-ref-format", "--branch", branch], readOnly: true },
|
|
45278
|
+
signal
|
|
45279
|
+
);
|
|
45280
|
+
if (branch.startsWith("-") || output2.exitCode !== 0) {
|
|
45281
|
+
throw new GitFault("invalid_git_request", "branch is not a valid Git ref");
|
|
45282
|
+
}
|
|
45283
|
+
}
|
|
45284
|
+
|
|
45187
45285
|
// src/capabilities/git/run-git.ts
|
|
45188
45286
|
var import_node_child_process = require("child_process");
|
|
45189
45287
|
|
|
@@ -45320,7 +45418,7 @@ function createGitRunner(options) {
|
|
|
45320
45418
|
}
|
|
45321
45419
|
await killProcessTree(child.pid, { signal: "SIGKILL", child, platform });
|
|
45322
45420
|
};
|
|
45323
|
-
return new Promise((
|
|
45421
|
+
return new Promise((resolve9, reject) => {
|
|
45324
45422
|
let ending = null;
|
|
45325
45423
|
const stop = (next) => {
|
|
45326
45424
|
if (ending !== null) return;
|
|
@@ -45345,7 +45443,7 @@ function createGitRunner(options) {
|
|
|
45345
45443
|
signal.removeEventListener("abort", onAbort);
|
|
45346
45444
|
const final = ending ?? last;
|
|
45347
45445
|
if (final.kind === "exited") {
|
|
45348
|
-
|
|
45446
|
+
resolve9({ exitCode: final.exitCode, stdout: stdout.text(), stderr: stderr.text() });
|
|
45349
45447
|
} else {
|
|
45350
45448
|
reject(faultFor(final, command));
|
|
45351
45449
|
}
|
|
@@ -45369,8 +45467,8 @@ function createGitRunner(options) {
|
|
|
45369
45467
|
|
|
45370
45468
|
// src/capabilities/git/checkout-freshness.ts
|
|
45371
45469
|
var import_node_crypto3 = require("crypto");
|
|
45372
|
-
var
|
|
45373
|
-
var
|
|
45470
|
+
var import_promises8 = require("fs/promises");
|
|
45471
|
+
var import_node_path4 = require("path");
|
|
45374
45472
|
init_zod();
|
|
45375
45473
|
var REMOTE = "origin";
|
|
45376
45474
|
var snapshotSchema = external_exports.object({
|
|
@@ -45400,7 +45498,7 @@ var freshnessSchema = external_exports.discriminatedUnion("state", [
|
|
|
45400
45498
|
})
|
|
45401
45499
|
]);
|
|
45402
45500
|
function freshnessFile(dir, path) {
|
|
45403
|
-
return (0,
|
|
45501
|
+
return (0, import_node_path4.join)(dir, `${(0, import_node_crypto3.createHash)("sha256").update(path).digest("hex").slice(0, 32)}.json`);
|
|
45404
45502
|
}
|
|
45405
45503
|
function parseStatus(stdout) {
|
|
45406
45504
|
const lines = stdout.split("\n").filter((line) => line.length > 0);
|
|
@@ -45432,32 +45530,35 @@ async function readCheckoutStatus(git, cwd, signal) {
|
|
|
45432
45530
|
return output2.exitCode === 0 ? parseStatus(output2.stdout) : null;
|
|
45433
45531
|
}
|
|
45434
45532
|
async function isCheckout(path) {
|
|
45435
|
-
return (0,
|
|
45533
|
+
return (0, import_promises8.stat)((0, import_node_path4.join)(path, ".git")).then(
|
|
45436
45534
|
() => true,
|
|
45437
45535
|
() => false
|
|
45438
45536
|
);
|
|
45439
45537
|
}
|
|
45440
45538
|
async function checkoutsUnder(root) {
|
|
45441
45539
|
if (await isCheckout(root)) return [root];
|
|
45442
|
-
const entries = await (0,
|
|
45540
|
+
const entries = await (0, import_promises8.readdir)(root, { withFileTypes: true }).catch(() => []);
|
|
45443
45541
|
const found = await Promise.all(
|
|
45444
45542
|
entries.filter((entry) => entry.isDirectory()).map(
|
|
45445
|
-
async (entry) => await isCheckout((0,
|
|
45543
|
+
async (entry) => await isCheckout((0, import_node_path4.join)(root, entry.name)) ? (0, import_node_path4.join)(root, entry.name) : null
|
|
45446
45544
|
)
|
|
45447
45545
|
);
|
|
45448
45546
|
return found.filter((path) => path !== null);
|
|
45449
45547
|
}
|
|
45548
|
+
async function recordCheckoutKept(dir, path, reason) {
|
|
45549
|
+
await writeJsonFileAtomic(freshnessFile(dir, path), { state: "kept", path, reason });
|
|
45550
|
+
}
|
|
45450
45551
|
async function readCheckoutFreshness(dir, path) {
|
|
45451
|
-
for (let current = path; ; current = (0,
|
|
45552
|
+
for (let current = path; ; current = (0, import_node_path4.dirname)(current)) {
|
|
45452
45553
|
const read = await readJsonFile(freshnessFile(dir, current), freshnessSchema);
|
|
45453
45554
|
if (read.kind === "ok") return read.value;
|
|
45454
|
-
if ((0,
|
|
45555
|
+
if ((0, import_node_path4.dirname)(current) === current) return null;
|
|
45455
45556
|
}
|
|
45456
45557
|
}
|
|
45457
45558
|
|
|
45458
45559
|
// src/platform/credential-store/credential-store.ts
|
|
45459
45560
|
var import_node_crypto4 = require("crypto");
|
|
45460
|
-
var
|
|
45561
|
+
var import_promises9 = require("fs/promises");
|
|
45461
45562
|
|
|
45462
45563
|
// src/platform/credential-store/parse.ts
|
|
45463
45564
|
function parseStoredJson(text2, schema) {
|
|
@@ -45473,16 +45574,16 @@ function parseStoredJson(text2, schema) {
|
|
|
45473
45574
|
|
|
45474
45575
|
// src/platform/windows-helper.ts
|
|
45475
45576
|
var import_node_fs3 = require("fs");
|
|
45476
|
-
var
|
|
45577
|
+
var import_node_path5 = require("path");
|
|
45477
45578
|
var import_node_url = require("url");
|
|
45478
45579
|
var import_meta = {};
|
|
45479
45580
|
function windowsHelperPath(entry = process.argv[1]) {
|
|
45480
|
-
const packaged = entry === void 0 ? null : (0,
|
|
45581
|
+
const packaged = entry === void 0 ? null : (0, import_node_path5.join)((0, import_node_path5.dirname)((0, import_node_path5.resolve)(entry)), "alan-winhelper.exe");
|
|
45481
45582
|
if (entry !== void 0) {
|
|
45482
45583
|
if (packaged !== null && (0, import_node_fs3.existsSync)(packaged)) return packaged;
|
|
45483
45584
|
}
|
|
45484
45585
|
try {
|
|
45485
|
-
const local = (0,
|
|
45586
|
+
const local = (0, import_node_path5.resolve)((0, import_node_path5.dirname)((0, import_node_url.fileURLToPath)(import_meta.url)), "../../dist/alan-winhelper.exe");
|
|
45486
45587
|
return (0, import_node_fs3.existsSync)(local) ? local : packaged;
|
|
45487
45588
|
} catch {
|
|
45488
45589
|
return packaged;
|
|
@@ -45550,7 +45651,7 @@ function createFileCredentialStore(path) {
|
|
|
45550
45651
|
kind: "file",
|
|
45551
45652
|
read: (schema) => readJsonFile(path, schema),
|
|
45552
45653
|
write: (value) => writeJsonFileAtomic(path, value),
|
|
45553
|
-
clear: () => (0,
|
|
45654
|
+
clear: () => (0, import_promises9.rm)(path, { force: true })
|
|
45554
45655
|
};
|
|
45555
45656
|
}
|
|
45556
45657
|
var KEYCHAIN_SERVICE = "ai.tryalan.runtime";
|
|
@@ -45645,14 +45746,14 @@ function defaultCredentialStoreKind(platform) {
|
|
|
45645
45746
|
var import_node_child_process3 = require("child_process");
|
|
45646
45747
|
var import_node_crypto5 = require("crypto");
|
|
45647
45748
|
var import_node_fs4 = require("fs");
|
|
45648
|
-
var
|
|
45649
|
-
var
|
|
45749
|
+
var import_promises11 = require("fs/promises");
|
|
45750
|
+
var import_node_path6 = require("path");
|
|
45650
45751
|
var import_node_util2 = require("util");
|
|
45651
45752
|
init_zod();
|
|
45652
45753
|
|
|
45653
45754
|
// src/platform/process-identity.ts
|
|
45654
45755
|
var import_node_child_process2 = require("child_process");
|
|
45655
|
-
var
|
|
45756
|
+
var import_promises10 = require("fs/promises");
|
|
45656
45757
|
var import_node_util = require("util");
|
|
45657
45758
|
var execFileAsync = (0, import_node_util.promisify)(import_node_child_process2.execFile);
|
|
45658
45759
|
function isProcessAlive(pid) {
|
|
@@ -45664,13 +45765,13 @@ function isProcessAlive(pid) {
|
|
|
45664
45765
|
}
|
|
45665
45766
|
}
|
|
45666
45767
|
async function linuxStartTime(pid) {
|
|
45667
|
-
const
|
|
45668
|
-
if (
|
|
45669
|
-
const fields =
|
|
45768
|
+
const stat16 = await (0, import_promises10.readFile)(`/proc/${pid}/stat`, "utf8").catch(() => null);
|
|
45769
|
+
if (stat16 === null) return null;
|
|
45770
|
+
const fields = stat16.slice(stat16.lastIndexOf(")") + 2).split(" ");
|
|
45670
45771
|
return fields[19] ?? null;
|
|
45671
45772
|
}
|
|
45672
45773
|
async function linuxCommand(pid) {
|
|
45673
|
-
const raw = await (0,
|
|
45774
|
+
const raw = await (0, import_promises10.readFile)(`/proc/${pid}/cmdline`, "utf8").catch(() => null);
|
|
45674
45775
|
return raw === null ? null : normalizeCommand(raw.replaceAll("\0", " "));
|
|
45675
45776
|
}
|
|
45676
45777
|
async function darwinCommand(pid) {
|
|
@@ -45764,11 +45865,11 @@ async function mayBeSameProcess(expected, probe = systemProcessProbe) {
|
|
|
45764
45865
|
var execFileAsync2 = (0, import_node_util2.promisify)(import_node_child_process3.execFile);
|
|
45765
45866
|
var packageJsonSchema = external_exports.object({ version: external_exports.string().min(1) });
|
|
45766
45867
|
function markVersionInUse(bundlePath) {
|
|
45767
|
-
const versionDir = (0,
|
|
45768
|
-
if ((0,
|
|
45868
|
+
const versionDir = (0, import_node_path6.dirname)(bundlePath);
|
|
45869
|
+
if ((0, import_node_path6.basename)((0, import_node_path6.dirname)(versionDir)) !== "versions") return { [Symbol.dispose]: () => {
|
|
45769
45870
|
} };
|
|
45770
|
-
const marker = (0,
|
|
45771
|
-
(0, import_node_fs4.mkdirSync)((0,
|
|
45871
|
+
const marker = (0, import_node_path6.join)(versionDir, ".running", String(process.pid));
|
|
45872
|
+
(0, import_node_fs4.mkdirSync)((0, import_node_path6.dirname)(marker), { recursive: true, mode: 448 });
|
|
45772
45873
|
(0, import_node_fs4.writeFileSync)(marker, "");
|
|
45773
45874
|
const remove = () => (0, import_node_fs4.rmSync)(marker, { force: true });
|
|
45774
45875
|
process.once("exit", remove);
|
|
@@ -45784,36 +45885,36 @@ function markVersionInUse(bundlePath) {
|
|
|
45784
45885
|
var import_node_crypto6 = require("crypto");
|
|
45785
45886
|
var import_node_fs5 = require("fs");
|
|
45786
45887
|
var import_node_os = require("os");
|
|
45787
|
-
var
|
|
45888
|
+
var import_node_path7 = require("path");
|
|
45788
45889
|
function removeStaleEndpoint(endpoint) {
|
|
45789
45890
|
if (!endpoint.startsWith("\\\\.\\pipe\\")) (0, import_node_fs5.rmSync)(endpoint, { force: true });
|
|
45790
45891
|
}
|
|
45791
45892
|
|
|
45792
45893
|
// src/platform/paths.ts
|
|
45793
|
-
var
|
|
45894
|
+
var import_node_path8 = require("path");
|
|
45794
45895
|
function runtimePaths(stateDir) {
|
|
45795
45896
|
return {
|
|
45796
45897
|
stateDir,
|
|
45797
|
-
lock: (0,
|
|
45798
|
-
machine: (0,
|
|
45799
|
-
credential: (0,
|
|
45800
|
-
runs: (0,
|
|
45801
|
-
sessions: (0,
|
|
45802
|
-
sockets: (0,
|
|
45803
|
-
logs: (0,
|
|
45804
|
-
tmp: (0,
|
|
45898
|
+
lock: (0, import_node_path8.join)(stateDir, "runtime.lock"),
|
|
45899
|
+
machine: (0, import_node_path8.join)(stateDir, "machine.json"),
|
|
45900
|
+
credential: (0, import_node_path8.join)(stateDir, "credential.json"),
|
|
45901
|
+
runs: (0, import_node_path8.join)(stateDir, "runs"),
|
|
45902
|
+
sessions: (0, import_node_path8.join)(stateDir, "sessions"),
|
|
45903
|
+
sockets: (0, import_node_path8.join)(stateDir, "s"),
|
|
45904
|
+
logs: (0, import_node_path8.join)(stateDir, "logs"),
|
|
45905
|
+
tmp: (0, import_node_path8.join)(stateDir, "tmp")
|
|
45805
45906
|
};
|
|
45806
45907
|
}
|
|
45807
45908
|
|
|
45808
45909
|
// src/platform/process-memory.ts
|
|
45809
45910
|
var import_node_child_process4 = require("child_process");
|
|
45810
|
-
var
|
|
45911
|
+
var import_promises12 = require("fs/promises");
|
|
45811
45912
|
var import_node_util3 = require("util");
|
|
45812
45913
|
var execFileAsync3 = (0, import_node_util3.promisify)(import_node_child_process4.execFile);
|
|
45813
45914
|
var PROBE_TIMEOUT_MS = 2e3;
|
|
45814
45915
|
async function readProcessRss(pid) {
|
|
45815
45916
|
if (process.platform === "linux") {
|
|
45816
|
-
const status = await (0,
|
|
45917
|
+
const status = await (0, import_promises12.readFile)(`/proc/${pid}/status`, "utf8").catch(() => null);
|
|
45817
45918
|
const kilobytes = status === null ? void 0 : /^VmRSS:\s+(\d+)\s+kB$/m.exec(status)?.[1];
|
|
45818
45919
|
return kilobytes === void 0 ? null : Number(kilobytes) * 1024;
|
|
45819
45920
|
}
|
|
@@ -45830,7 +45931,7 @@ async function readProcessRss(pid) {
|
|
|
45830
45931
|
}
|
|
45831
45932
|
|
|
45832
45933
|
// src/platform/runtime-host.ts
|
|
45833
|
-
var
|
|
45934
|
+
var import_promises13 = require("fs/promises");
|
|
45834
45935
|
var RUNTIME_HOST_KINDS = ["app", "standalone"];
|
|
45835
45936
|
|
|
45836
45937
|
// src/platform/service/exec.ts
|
|
@@ -45845,7 +45946,7 @@ function statusOf(error61) {
|
|
|
45845
45946
|
}
|
|
45846
45947
|
return 1;
|
|
45847
45948
|
}
|
|
45848
|
-
var systemExec = (request2) => new Promise((
|
|
45949
|
+
var systemExec = (request2) => new Promise((resolve9) => {
|
|
45849
45950
|
const child = (0, import_node_child_process5.execFile)(
|
|
45850
45951
|
request2.command,
|
|
45851
45952
|
[...request2.args],
|
|
@@ -45856,7 +45957,7 @@ var systemExec = (request2) => new Promise((resolve7) => {
|
|
|
45856
45957
|
windowsHide: true
|
|
45857
45958
|
},
|
|
45858
45959
|
(error61, stdout, stderr) => {
|
|
45859
|
-
|
|
45960
|
+
resolve9({ status: statusOf(error61), stdout, stderr });
|
|
45860
45961
|
}
|
|
45861
45962
|
);
|
|
45862
45963
|
child.stdin?.on("error", () => {
|
|
@@ -45869,8 +45970,8 @@ init_alan_code();
|
|
|
45869
45970
|
|
|
45870
45971
|
// src/capabilities/providers/commands.ts
|
|
45871
45972
|
var import_node_fs6 = require("fs");
|
|
45872
|
-
var
|
|
45873
|
-
var
|
|
45973
|
+
var import_promises17 = require("fs/promises");
|
|
45974
|
+
var import_node_path9 = require("path");
|
|
45874
45975
|
var PROVIDER_COMMANDS = [
|
|
45875
45976
|
// The engine, not a CLI of its own: `resolveProviderExecutable` finds the bundled one first.
|
|
45876
45977
|
{ backendKind: "alan_code", command: "opencode", name: "Alan Code" },
|
|
@@ -45905,8 +46006,8 @@ function pathDelimiter(platform) {
|
|
|
45905
46006
|
}
|
|
45906
46007
|
async function isRunnable(path, platform) {
|
|
45907
46008
|
try {
|
|
45908
|
-
if (!(await (0,
|
|
45909
|
-
if (platform !== "win32") await (0,
|
|
46009
|
+
if (!(await (0, import_promises17.stat)(path)).isFile()) return false;
|
|
46010
|
+
if (platform !== "win32") await (0, import_promises17.access)(path, import_node_fs6.constants.X_OK);
|
|
45910
46011
|
return true;
|
|
45911
46012
|
} catch {
|
|
45912
46013
|
return false;
|
|
@@ -45923,12 +46024,12 @@ async function resolveCommandOnPath(command, env, platform) {
|
|
|
45923
46024
|
const directories = envValue(env, "PATH").split(pathDelimiter(platform)).map(
|
|
45924
46025
|
(directory) => platform === "win32" ? directory.trim().replace(/^"(.*)"$/, "$1") : directory
|
|
45925
46026
|
).filter(
|
|
45926
|
-
(directory) => platform === "win32" ?
|
|
46027
|
+
(directory) => platform === "win32" ? import_node_path9.win32.isAbsolute(directory) : directory.length > 0
|
|
45927
46028
|
);
|
|
45928
46029
|
const extensions = platform === "win32" ? windowsExtensions(command, env) : [""];
|
|
45929
46030
|
for (const directory of directories) {
|
|
45930
46031
|
for (const extension of extensions) {
|
|
45931
|
-
const candidate = (0,
|
|
46032
|
+
const candidate = (0, import_node_path9.join)(directory, `${command}${extension}`);
|
|
45932
46033
|
if (await isRunnable(candidate, platform)) return candidate;
|
|
45933
46034
|
}
|
|
45934
46035
|
}
|
|
@@ -45963,14 +46064,14 @@ function resolveProviderExecutable(provider4, env, platform) {
|
|
|
45963
46064
|
|
|
45964
46065
|
// src/capabilities/providers/managed.ts
|
|
45965
46066
|
var import_node_crypto7 = require("crypto");
|
|
45966
|
-
var
|
|
45967
|
-
var
|
|
46067
|
+
var import_promises18 = require("fs/promises");
|
|
46068
|
+
var import_node_path10 = require("path");
|
|
45968
46069
|
init_zod();
|
|
45969
46070
|
var VERSION = /^[0-9]+\.[0-9]+\.[0-9]+(?:[-+][0-9A-Za-z.-]+)?$/;
|
|
45970
46071
|
var selectedSchema = external_exports.record(external_exports.string(), external_exports.string());
|
|
45971
46072
|
async function readManagedProviderVersion(file2, backendKind) {
|
|
45972
46073
|
try {
|
|
45973
|
-
const selected = selectedSchema.parse(JSON.parse(await (0,
|
|
46074
|
+
const selected = selectedSchema.parse(JSON.parse(await (0, import_promises18.readFile)(file2, "utf8")));
|
|
45974
46075
|
const version2 = selected[backendKind];
|
|
45975
46076
|
return version2 !== void 0 && VERSION.test(version2) ? version2 : null;
|
|
45976
46077
|
} catch {
|
|
@@ -45981,8 +46082,8 @@ async function readManagedProviderVersion(file2, backendKind) {
|
|
|
45981
46082
|
// ../shared/dist/node/skill-package.js
|
|
45982
46083
|
var import_node_buffer = require("buffer");
|
|
45983
46084
|
var import_node_crypto8 = require("crypto");
|
|
45984
|
-
var
|
|
45985
|
-
var
|
|
46085
|
+
var import_promises19 = require("fs/promises");
|
|
46086
|
+
var import_node_path11 = require("path");
|
|
45986
46087
|
var import_yaml = __toESM(require_dist(), 1);
|
|
45987
46088
|
init_contracts();
|
|
45988
46089
|
init_domain();
|
|
@@ -46053,7 +46154,7 @@ async function inspectSkillPackage(packageRoot, options = {}) {
|
|
|
46053
46154
|
}
|
|
46054
46155
|
const inspectedFiles = await Promise.all(files.map(readPackageFile));
|
|
46055
46156
|
inspectedFiles.sort(comparePackageFiles);
|
|
46056
|
-
const parsedMetadata = parseSkillMetadata(inspectedFiles.find((file2) => file2.manifest.path === "SKILL.md")?.bytes, options.expectedName === void 0 ? (0,
|
|
46157
|
+
const parsedMetadata = parseSkillMetadata(inspectedFiles.find((file2) => file2.manifest.path === "SKILL.md")?.bytes, options.expectedName === void 0 ? (0, import_node_path11.basename)(root) : options.expectedName);
|
|
46057
46158
|
const manifestFiles = inspectedFiles.map((file2) => file2.manifest);
|
|
46058
46159
|
const diagnostics = [
|
|
46059
46160
|
...parsedMetadata.conformance,
|
|
@@ -46071,11 +46172,11 @@ async function inspectSkillPackage(packageRoot, options = {}) {
|
|
|
46071
46172
|
};
|
|
46072
46173
|
}
|
|
46073
46174
|
async function requirePackageRoot(packageRoot) {
|
|
46074
|
-
const root = await (0,
|
|
46175
|
+
const root = await (0, import_promises19.realpath)((0, import_node_path11.resolve)(packageRoot)).catch(() => null);
|
|
46075
46176
|
if (!root) {
|
|
46076
46177
|
throw new SkillPackageError("INVALID_PACKAGE_ROOT", "Skill package directory does not exist");
|
|
46077
46178
|
}
|
|
46078
|
-
const rootStat = await (0,
|
|
46179
|
+
const rootStat = await (0, import_promises19.lstat)(root);
|
|
46079
46180
|
if (!rootStat.isDirectory()) {
|
|
46080
46181
|
throw new SkillPackageError("INVALID_PACKAGE_ROOT", "Skill package root must be a directory");
|
|
46081
46182
|
}
|
|
@@ -46095,13 +46196,13 @@ async function walkPackage(root, ignoredPaths) {
|
|
|
46095
46196
|
}
|
|
46096
46197
|
return files;
|
|
46097
46198
|
async function walkDirectory(directory) {
|
|
46098
|
-
const entries = await (0,
|
|
46199
|
+
const entries = await (0, import_promises19.readdir)(directory, { withFileTypes: true });
|
|
46099
46200
|
for (const entry of entries) {
|
|
46100
|
-
const absolutePath = (0,
|
|
46201
|
+
const absolutePath = (0, import_node_path11.resolve)(directory, entry.name);
|
|
46101
46202
|
const normalizedPath = normalizeRelativePath(root, absolutePath);
|
|
46102
46203
|
if (isIgnored(normalizedPath, entry.name, entry.isDirectory(), ignored2))
|
|
46103
46204
|
continue;
|
|
46104
|
-
const entryStat = await (0,
|
|
46205
|
+
const entryStat = await (0, import_promises19.lstat)(absolutePath);
|
|
46105
46206
|
if (entryStat.isSymbolicLink()) {
|
|
46106
46207
|
throw new SkillPackageError("SYMLINK_BLOCKED", `Nested symbolic links are not allowed in Skill packages: ${normalizedPath}`, normalizedPath);
|
|
46107
46208
|
}
|
|
@@ -46164,12 +46265,12 @@ function globToRegExp(pattern) {
|
|
|
46164
46265
|
return new RegExp(`${source}(?:/.*)?$`);
|
|
46165
46266
|
}
|
|
46166
46267
|
function normalizeRelativePath(root, absolutePath) {
|
|
46167
|
-
const nativeRelativePath = (0,
|
|
46168
|
-
if (!nativeRelativePath || nativeRelativePath.startsWith(`..${
|
|
46268
|
+
const nativeRelativePath = (0, import_node_path11.relative)(root, absolutePath);
|
|
46269
|
+
if (!nativeRelativePath || nativeRelativePath.startsWith(`..${import_node_path11.sep}`) || nativeRelativePath === "..") {
|
|
46169
46270
|
throw new SkillPackageError("INVALID_PATH", "Skill package path escapes its root");
|
|
46170
46271
|
}
|
|
46171
|
-
const normalized2 = nativeRelativePath.split(
|
|
46172
|
-
if (normalized2.includes("\0") || normalized2.includes("\uFFFD") ||
|
|
46272
|
+
const normalized2 = nativeRelativePath.split(import_node_path11.sep).join("/").normalize("NFC");
|
|
46273
|
+
if (normalized2.includes("\0") || normalized2.includes("\uFFFD") || import_node_path11.posix.isAbsolute(normalized2)) {
|
|
46173
46274
|
throw new SkillPackageError("INVALID_PATH", `Invalid Skill package path: ${normalized2}`);
|
|
46174
46275
|
}
|
|
46175
46276
|
return normalized2;
|
|
@@ -46204,13 +46305,13 @@ function requireSafeFile(path, size, normalizedPaths) {
|
|
|
46204
46305
|
}
|
|
46205
46306
|
}
|
|
46206
46307
|
function isSecretPath(path) {
|
|
46207
|
-
const name =
|
|
46308
|
+
const name = import_node_path11.posix.basename(path).toLowerCase();
|
|
46208
46309
|
if (SECRET_BASENAMES.has(name) || name.startsWith(".env."))
|
|
46209
46310
|
return true;
|
|
46210
46311
|
return name.endsWith(".private-key.pem") || name.endsWith(".private-key.key");
|
|
46211
46312
|
}
|
|
46212
46313
|
async function readPackageFile(file2) {
|
|
46213
|
-
const bytes = await (0,
|
|
46314
|
+
const bytes = await (0, import_promises19.readFile)(file2.absolutePath);
|
|
46214
46315
|
return {
|
|
46215
46316
|
bytes,
|
|
46216
46317
|
manifest: {
|
|
@@ -46232,12 +46333,12 @@ function classifyFileKind(path) {
|
|
|
46232
46333
|
return "reference";
|
|
46233
46334
|
if (path.startsWith("assets/"))
|
|
46234
46335
|
return "asset";
|
|
46235
|
-
if (/^(?:licen[cs]e|copying|notice)(?:\.|$)/i.test(
|
|
46336
|
+
if (/^(?:licen[cs]e|copying|notice)(?:\.|$)/i.test(import_node_path11.posix.basename(path)))
|
|
46236
46337
|
return "license";
|
|
46237
46338
|
return "other";
|
|
46238
46339
|
}
|
|
46239
46340
|
function classifyPreview(path, bytes) {
|
|
46240
|
-
const extension =
|
|
46341
|
+
const extension = import_node_path11.posix.extname(path).toLowerCase();
|
|
46241
46342
|
if (IMAGE_EXTENSIONS2.has(extension))
|
|
46242
46343
|
return "image";
|
|
46243
46344
|
if (bytes.includes(0))
|
|
@@ -46341,7 +46442,7 @@ function normalizePackageReference(value) {
|
|
|
46341
46442
|
const withoutSuffix = trimmed4.split(/[?#]/, 1)[0];
|
|
46342
46443
|
if (!withoutSuffix)
|
|
46343
46444
|
return null;
|
|
46344
|
-
const normalized2 =
|
|
46445
|
+
const normalized2 = import_node_path11.posix.normalize(withoutSuffix).replace(/^\.\//, "").normalize("NFC");
|
|
46345
46446
|
if (normalized2 === ".." || normalized2.startsWith("../"))
|
|
46346
46447
|
return null;
|
|
46347
46448
|
return normalized2;
|
|
@@ -46380,8 +46481,8 @@ function uint642(value) {
|
|
|
46380
46481
|
}
|
|
46381
46482
|
|
|
46382
46483
|
// src/capabilities/skills/store.ts
|
|
46383
|
-
var
|
|
46384
|
-
var
|
|
46484
|
+
var import_promises20 = require("fs/promises");
|
|
46485
|
+
var import_node_path12 = require("path");
|
|
46385
46486
|
|
|
46386
46487
|
// ../shared/dist/node/alan-skill-identity.js
|
|
46387
46488
|
var import_node_crypto9 = require("crypto");
|
|
@@ -46404,21 +46505,21 @@ function alanSkillVersionId(slug, contentHash) {
|
|
|
46404
46505
|
init_runtime_v2();
|
|
46405
46506
|
init_zod();
|
|
46406
46507
|
function skillsLayout(stateDir, home) {
|
|
46407
|
-
const root = (0,
|
|
46508
|
+
const root = (0, import_node_path12.join)(stateDir, "skills");
|
|
46408
46509
|
return {
|
|
46409
46510
|
root,
|
|
46410
|
-
installedFile: (0,
|
|
46411
|
-
retiredFile: (0,
|
|
46412
|
-
localFile: (0,
|
|
46413
|
-
versionsDir: (0,
|
|
46414
|
-
tmpDir: (0,
|
|
46415
|
-
pluginDir: (0,
|
|
46416
|
-
pluginSkillsDir: (0,
|
|
46417
|
-
nativeDir: home === void 0 || home === "" ? null : (0,
|
|
46511
|
+
installedFile: (0, import_node_path12.join)(root, "installed.json"),
|
|
46512
|
+
retiredFile: (0, import_node_path12.join)(root, "retired.json"),
|
|
46513
|
+
localFile: (0, import_node_path12.join)(root, "local.json"),
|
|
46514
|
+
versionsDir: (0, import_node_path12.join)(root, "versions"),
|
|
46515
|
+
tmpDir: (0, import_node_path12.join)(root, "tmp"),
|
|
46516
|
+
pluginDir: (0, import_node_path12.join)(root, "alan-plugin"),
|
|
46517
|
+
pluginSkillsDir: (0, import_node_path12.join)(root, "alan-plugin", "skills"),
|
|
46518
|
+
nativeDir: home === void 0 || home === "" ? null : (0, import_node_path12.join)(home, ".agents", "skills")
|
|
46418
46519
|
};
|
|
46419
46520
|
}
|
|
46420
46521
|
function packageDirectory(layout, versionId) {
|
|
46421
|
-
return (0,
|
|
46522
|
+
return (0, import_node_path12.join)(layout.versionsDir, versionId);
|
|
46422
46523
|
}
|
|
46423
46524
|
var installedFileSchema = external_exports.object({ skills: external_exports.array(desiredMachineSkillSchema) });
|
|
46424
46525
|
async function readInstalledSkills(layout) {
|
|
@@ -46445,7 +46546,7 @@ async function readLocalSkills(layout) {
|
|
|
46445
46546
|
async function isLocalSkillCurrent(entry, contentHash, ignoredPaths) {
|
|
46446
46547
|
if (entry.contentHash !== contentHash) return false;
|
|
46447
46548
|
try {
|
|
46448
|
-
if (await (0,
|
|
46549
|
+
if (await (0, import_promises20.realpath)(entry.path) !== entry.path) return false;
|
|
46449
46550
|
const inspected = await inspectSkillPackage(entry.path, { expectedName: null, ignoredPaths });
|
|
46450
46551
|
return inspected.contentHash === contentHash;
|
|
46451
46552
|
} catch {
|
|
@@ -46460,7 +46561,7 @@ async function resolveLocalSkill(local, invocation) {
|
|
|
46460
46561
|
}
|
|
46461
46562
|
async function hasSkillFile(directory) {
|
|
46462
46563
|
try {
|
|
46463
|
-
return (await (0,
|
|
46564
|
+
return (await (0, import_promises20.stat)((0, import_node_path12.join)(directory, "SKILL.md"))).isFile();
|
|
46464
46565
|
} catch {
|
|
46465
46566
|
return false;
|
|
46466
46567
|
}
|
|
@@ -46478,7 +46579,7 @@ async function isIntact(layout, skill) {
|
|
|
46478
46579
|
async function resolveNativeBuiltIn(layout, invocation, baked) {
|
|
46479
46580
|
const slug = invocation.displayName;
|
|
46480
46581
|
if (layout.nativeDir === null || invocation.skillId !== alanSkillId(slug)) return null;
|
|
46481
|
-
const directory = (0,
|
|
46582
|
+
const directory = (0, import_node_path12.join)(layout.nativeDir, slug);
|
|
46482
46583
|
try {
|
|
46483
46584
|
const inspected = await inspectSkillPackage(directory, { expectedName: slug });
|
|
46484
46585
|
if (baked === "exact" && alanSkillVersionId(slug, inspected.contentHash) !== invocation.versionId)
|
|
@@ -46524,10 +46625,10 @@ async function availableSkillIndex(layout) {
|
|
|
46524
46625
|
});
|
|
46525
46626
|
}
|
|
46526
46627
|
if (layout.nativeDir !== null) {
|
|
46527
|
-
const entries = await (0,
|
|
46628
|
+
const entries = await (0, import_promises20.readdir)(layout.nativeDir, { withFileTypes: true }).catch(() => []);
|
|
46528
46629
|
for (const entry of entries) {
|
|
46529
46630
|
if (entry.isDirectory() || entry.isSymbolicLink())
|
|
46530
|
-
candidates2.push({ directory: (0,
|
|
46631
|
+
candidates2.push({ directory: (0, import_node_path12.join)(layout.nativeDir, entry.name) });
|
|
46531
46632
|
}
|
|
46532
46633
|
}
|
|
46533
46634
|
const bounded = candidates2.slice(0, 2e3);
|
|
@@ -46557,8 +46658,8 @@ async function inspectIndexedSkill(directory, contentHash) {
|
|
|
46557
46658
|
// src/capabilities/skills/native-index.ts
|
|
46558
46659
|
var import_node_crypto10 = require("crypto");
|
|
46559
46660
|
var import_node_fs7 = require("fs");
|
|
46560
|
-
var
|
|
46561
|
-
var
|
|
46661
|
+
var import_promises21 = require("fs/promises");
|
|
46662
|
+
var import_node_path13 = require("path");
|
|
46562
46663
|
var ALAN_SKILLS_PLUGIN_NAME = "alan";
|
|
46563
46664
|
var PLUGIN_MANIFEST = `${JSON.stringify(
|
|
46564
46665
|
{
|
|
@@ -46570,18 +46671,18 @@ var PLUGIN_MANIFEST = `${JSON.stringify(
|
|
|
46570
46671
|
)}
|
|
46571
46672
|
`;
|
|
46572
46673
|
function installedSkillFolders(layout) {
|
|
46573
|
-
return (0, import_node_fs7.existsSync)((0,
|
|
46674
|
+
return (0, import_node_fs7.existsSync)((0, import_node_path13.join)(layout.pluginDir, ".claude-plugin", "plugin.json")) ? { pluginDir: layout.pluginDir, skillsDir: layout.pluginSkillsDir } : null;
|
|
46574
46675
|
}
|
|
46575
46676
|
|
|
46576
46677
|
// src/capabilities/workspace/index.ts
|
|
46577
|
-
var
|
|
46678
|
+
var import_node_path16 = require("path");
|
|
46578
46679
|
|
|
46579
46680
|
// src/capabilities/workspace/approved-paths.ts
|
|
46580
|
-
var
|
|
46681
|
+
var import_promises22 = require("fs/promises");
|
|
46581
46682
|
init_zod();
|
|
46582
46683
|
|
|
46583
46684
|
// src/capabilities/workspace/paths.ts
|
|
46584
|
-
var
|
|
46685
|
+
var import_node_path14 = require("path");
|
|
46585
46686
|
function stripWin32Namespace(path) {
|
|
46586
46687
|
if (/^\\\\\?\\UNC\\/i.test(path)) return `\\\\${path.slice(8)}`;
|
|
46587
46688
|
if (path.startsWith("\\\\?\\")) return path.slice(4);
|
|
@@ -46589,15 +46690,15 @@ function stripWin32Namespace(path) {
|
|
|
46589
46690
|
}
|
|
46590
46691
|
function comparablePath(path, platform) {
|
|
46591
46692
|
if (platform === "win32") {
|
|
46592
|
-
const normalized3 =
|
|
46693
|
+
const normalized3 = import_node_path14.win32.normalize(stripWin32Namespace(path).replaceAll("/", "\\"));
|
|
46593
46694
|
const trimmed4 = normalized3.length > 3 || !/^[a-z]:\\$/i.test(normalized3) ? normalized3.replace(/\\+$/, "") : normalized3;
|
|
46594
46695
|
return trimmed4.toLowerCase();
|
|
46595
46696
|
}
|
|
46596
|
-
const normalized2 =
|
|
46697
|
+
const normalized2 = import_node_path14.posix.normalize(path);
|
|
46597
46698
|
return normalized2.length > 1 ? normalized2.replace(/\/+$/, "") : normalized2;
|
|
46598
46699
|
}
|
|
46599
46700
|
function isAbsoluteFor(path, platform) {
|
|
46600
|
-
return platform === "win32" ?
|
|
46701
|
+
return platform === "win32" ? import_node_path14.win32.isAbsolute(path) : import_node_path14.posix.isAbsolute(path);
|
|
46601
46702
|
}
|
|
46602
46703
|
function isWithin(root, candidate, platform) {
|
|
46603
46704
|
const separator = platform === "win32" ? "\\" : "/";
|
|
@@ -46615,7 +46716,7 @@ var storeSchema = external_exports.object({
|
|
|
46615
46716
|
});
|
|
46616
46717
|
async function realpathOrNull(path) {
|
|
46617
46718
|
try {
|
|
46618
|
-
return await (0,
|
|
46719
|
+
return await (0, import_promises22.realpath)(path);
|
|
46619
46720
|
} catch (error61) {
|
|
46620
46721
|
const code = errnoCode(error61);
|
|
46621
46722
|
if (code === "ENOENT" || code === "ENOTDIR" || code === "EACCES" || code === "EPERM") {
|
|
@@ -46675,8 +46776,8 @@ async function openApprovedPaths(options) {
|
|
|
46675
46776
|
|
|
46676
46777
|
// src/capabilities/workspace/locks.ts
|
|
46677
46778
|
var import_node_crypto11 = require("crypto");
|
|
46678
|
-
var
|
|
46679
|
-
var
|
|
46779
|
+
var import_promises23 = require("fs/promises");
|
|
46780
|
+
var import_node_path15 = require("path");
|
|
46680
46781
|
init_zod();
|
|
46681
46782
|
var LOCK_FORMAT = 1;
|
|
46682
46783
|
var EXCLUSIVE_FILE = "exclusive.json";
|
|
@@ -46696,7 +46797,7 @@ function repositoryLockKey(commonDir, platform) {
|
|
|
46696
46797
|
async function readOwner(path) {
|
|
46697
46798
|
let text2;
|
|
46698
46799
|
try {
|
|
46699
|
-
text2 = await (0,
|
|
46800
|
+
text2 = await (0, import_promises23.readFile)(path, "utf8");
|
|
46700
46801
|
} catch (error61) {
|
|
46701
46802
|
if (errnoCode(error61) === "ENOENT") return { kind: "missing" };
|
|
46702
46803
|
return { kind: "unreadable" };
|
|
@@ -46717,7 +46818,7 @@ async function removeIfSame(path, expected) {
|
|
|
46717
46818
|
if (current.kind !== "owner" || current.owner.since !== expected.since) return;
|
|
46718
46819
|
if (current.owner.pid !== expected.pid || current.owner.holder !== expected.holder) return;
|
|
46719
46820
|
}
|
|
46720
|
-
await (0,
|
|
46821
|
+
await (0, import_promises23.unlink)(path).catch((error61) => {
|
|
46721
46822
|
if (errnoCode(error61) !== "ENOENT") throw error61;
|
|
46722
46823
|
});
|
|
46723
46824
|
}
|
|
@@ -46742,7 +46843,7 @@ function openRepositoryLocks(options) {
|
|
|
46742
46843
|
await removeIfSame(path, read.owner);
|
|
46743
46844
|
return null;
|
|
46744
46845
|
}
|
|
46745
|
-
const age = await (0,
|
|
46846
|
+
const age = await (0, import_promises23.stat)(path).then(
|
|
46746
46847
|
(info) => clock.now() - info.mtimeMs,
|
|
46747
46848
|
() => 0
|
|
46748
46849
|
);
|
|
@@ -46756,13 +46857,13 @@ function openRepositoryLocks(options) {
|
|
|
46756
46857
|
});
|
|
46757
46858
|
const folder = async (commonDir) => {
|
|
46758
46859
|
const key = repositoryLockKey(commonDir, platform);
|
|
46759
|
-
const dir = (0,
|
|
46760
|
-
await (0,
|
|
46860
|
+
const dir = (0, import_node_path15.join)(options.dir, key);
|
|
46861
|
+
await (0, import_promises23.mkdir)(dir, { recursive: true, mode: 448 });
|
|
46761
46862
|
return { key, dir };
|
|
46762
46863
|
};
|
|
46763
46864
|
const createExclusive = async (path, owner) => {
|
|
46764
46865
|
try {
|
|
46765
|
-
const handle = await (0,
|
|
46866
|
+
const handle = await (0, import_promises23.open)(path, "wx", 384);
|
|
46766
46867
|
try {
|
|
46767
46868
|
await handle.writeFile(JSON.stringify(owner));
|
|
46768
46869
|
} finally {
|
|
@@ -46775,10 +46876,10 @@ function openRepositoryLocks(options) {
|
|
|
46775
46876
|
}
|
|
46776
46877
|
};
|
|
46777
46878
|
const liveRun = async (dir) => {
|
|
46778
|
-
const entries = await (0,
|
|
46879
|
+
const entries = await (0, import_promises23.readdir)(dir);
|
|
46779
46880
|
for (const entry of entries) {
|
|
46780
46881
|
if (!entry.startsWith(RUN_FILE_PREFIX)) continue;
|
|
46781
|
-
const holder = await heldBy((0,
|
|
46882
|
+
const holder = await heldBy((0, import_node_path15.join)(dir, entry));
|
|
46782
46883
|
if (holder !== null) return holder;
|
|
46783
46884
|
}
|
|
46784
46885
|
return null;
|
|
@@ -46786,7 +46887,7 @@ function openRepositoryLocks(options) {
|
|
|
46786
46887
|
return {
|
|
46787
46888
|
tryExclusive: async (commonDir, operationId) => {
|
|
46788
46889
|
const { key, dir } = await folder(commonDir);
|
|
46789
|
-
const path = (0,
|
|
46890
|
+
const path = (0, import_node_path15.join)(dir, EXCLUSIVE_FILE);
|
|
46790
46891
|
const owner = await self(operationId);
|
|
46791
46892
|
if (!await createExclusive(path, owner)) {
|
|
46792
46893
|
const holder = await heldBy(path);
|
|
@@ -46805,10 +46906,10 @@ function openRepositoryLocks(options) {
|
|
|
46805
46906
|
tryShared: async (commonDir, runId) => {
|
|
46806
46907
|
const { key, dir } = await folder(commonDir);
|
|
46807
46908
|
const file2 = `${RUN_FILE_PREFIX}${(0, import_node_crypto11.createHash)("sha256").update(runId).digest("hex").slice(0, 32)}.json`;
|
|
46808
|
-
const path = (0,
|
|
46909
|
+
const path = (0, import_node_path15.join)(dir, file2);
|
|
46809
46910
|
const owner = await self(runId);
|
|
46810
46911
|
await writeJsonFileAtomic(path, owner);
|
|
46811
|
-
const operation = await heldBy((0,
|
|
46912
|
+
const operation = await heldBy((0, import_node_path15.join)(dir, EXCLUSIVE_FILE));
|
|
46812
46913
|
if (operation !== null) {
|
|
46813
46914
|
await removeIfSame(path, owner);
|
|
46814
46915
|
return { kind: "busy", holder: operation };
|
|
@@ -46820,30 +46921,30 @@ function openRepositoryLocks(options) {
|
|
|
46820
46921
|
|
|
46821
46922
|
// src/cli/config.ts
|
|
46822
46923
|
var import_node_os7 = require("os");
|
|
46823
|
-
var
|
|
46924
|
+
var import_node_path32 = require("path");
|
|
46824
46925
|
init_zod();
|
|
46825
46926
|
|
|
46826
46927
|
// src/client/locate.ts
|
|
46827
|
-
var
|
|
46928
|
+
var import_node_path17 = require("path");
|
|
46828
46929
|
var RUNTIME_PROFILES = ["production", "staging", "development", "local"];
|
|
46829
46930
|
function defaultStateDir({ profile, platform, home, env }) {
|
|
46830
46931
|
if (platform === "win32") {
|
|
46831
|
-
return (0,
|
|
46932
|
+
return (0, import_node_path17.join)(env.LOCALAPPDATA ?? (0, import_node_path17.join)(home, "AppData", "Local"), "Alan", profile);
|
|
46832
46933
|
}
|
|
46833
|
-
return (0,
|
|
46934
|
+
return (0, import_node_path17.join)(env.XDG_STATE_HOME ?? (0, import_node_path17.join)(home, ".local", "state"), "alan", profile);
|
|
46834
46935
|
}
|
|
46835
46936
|
function defaultInstallDir({ platform, home, env }) {
|
|
46836
46937
|
if (platform === "win32") {
|
|
46837
|
-
return (0,
|
|
46938
|
+
return (0, import_node_path17.join)(env.LOCALAPPDATA ?? (0, import_node_path17.join)(home, "AppData", "Local"), "Alan", "runtime");
|
|
46838
46939
|
}
|
|
46839
|
-
return (0,
|
|
46940
|
+
return (0, import_node_path17.join)(env.XDG_DATA_HOME ?? (0, import_node_path17.join)(home, ".local", "share"), "alan", "runtime");
|
|
46840
46941
|
}
|
|
46841
46942
|
|
|
46842
46943
|
// src/sessions/index.ts
|
|
46843
46944
|
var import_node_crypto16 = require("crypto");
|
|
46844
|
-
var
|
|
46945
|
+
var import_promises40 = require("fs/promises");
|
|
46845
46946
|
var import_node_os6 = require("os");
|
|
46846
|
-
var
|
|
46947
|
+
var import_node_path31 = require("path");
|
|
46847
46948
|
|
|
46848
46949
|
// src/holder/control-client.ts
|
|
46849
46950
|
var import_node_crypto12 = require("crypto");
|
|
@@ -47010,7 +47111,7 @@ function createProviderDrivers(options) {
|
|
|
47010
47111
|
}
|
|
47011
47112
|
|
|
47012
47113
|
// src/holder/engine-records.ts
|
|
47013
|
-
var
|
|
47114
|
+
var import_node_path18 = require("path");
|
|
47014
47115
|
init_zod();
|
|
47015
47116
|
var ENGINES_FILE = "engines.json";
|
|
47016
47117
|
var engineRecordSchema = external_exports.object({
|
|
@@ -47020,7 +47121,7 @@ var engineRecordSchema = external_exports.object({
|
|
|
47020
47121
|
});
|
|
47021
47122
|
var engineRecordsSchema = external_exports.object({ engines: external_exports.array(engineRecordSchema) });
|
|
47022
47123
|
function engineRecordsPath(sessionDir) {
|
|
47023
|
-
return (0,
|
|
47124
|
+
return (0, import_node_path18.join)(sessionDir, ENGINES_FILE);
|
|
47024
47125
|
}
|
|
47025
47126
|
function recordSpawnedEngines(path, clock, log) {
|
|
47026
47127
|
const live = /* @__PURE__ */ new Map();
|
|
@@ -47075,17 +47176,17 @@ function createConversationMcpAuthorization(options) {
|
|
|
47075
47176
|
}
|
|
47076
47177
|
|
|
47077
47178
|
// src/holder/mcp-helper-access.ts
|
|
47078
|
-
var
|
|
47179
|
+
var import_promises30 = require("fs/promises");
|
|
47079
47180
|
function createHelperMcpAccess(options) {
|
|
47080
47181
|
return {
|
|
47081
47182
|
[Symbol.asyncDispose]: async () => {
|
|
47082
|
-
await (0,
|
|
47183
|
+
await (0, import_promises30.rm)(options.credentialPath, { force: true });
|
|
47083
47184
|
},
|
|
47084
47185
|
url: options.managedMcp.url,
|
|
47085
47186
|
authorization: async (signal) => {
|
|
47086
47187
|
const authorization = await options.managedMcp.authorization(signal);
|
|
47087
47188
|
if (authorization === void 0 || signal.aborted) {
|
|
47088
|
-
await (0,
|
|
47189
|
+
await (0, import_promises30.rm)(options.credentialPath, { force: true });
|
|
47089
47190
|
return void 0;
|
|
47090
47191
|
}
|
|
47091
47192
|
const credential = {
|
|
@@ -47100,8 +47201,8 @@ function createHelperMcpAccess(options) {
|
|
|
47100
47201
|
}
|
|
47101
47202
|
|
|
47102
47203
|
// src/holder/run-inputs.ts
|
|
47103
|
-
var
|
|
47104
|
-
var
|
|
47204
|
+
var import_promises31 = require("fs/promises");
|
|
47205
|
+
var import_node_path19 = require("path");
|
|
47105
47206
|
init_dist();
|
|
47106
47207
|
var NO_RUN_INPUTS = {
|
|
47107
47208
|
attachments: [],
|
|
@@ -47115,18 +47216,18 @@ function safeFilename(filename) {
|
|
|
47115
47216
|
return safe || "attachment";
|
|
47116
47217
|
}
|
|
47117
47218
|
async function prepareRunInputs(spec, { source, tmpDir, signal, skills = [] }) {
|
|
47118
|
-
const dir = (0,
|
|
47219
|
+
const dir = (0, import_node_path19.join)(tmpDir, "runs", spec.runId);
|
|
47119
47220
|
const cleanup = async () => {
|
|
47120
|
-
await (0,
|
|
47221
|
+
await (0, import_promises31.rm)(dir, { recursive: true, force: true });
|
|
47121
47222
|
};
|
|
47122
47223
|
try {
|
|
47123
47224
|
const credential = await source.fetchProviderCredential(spec.runId, signal);
|
|
47124
47225
|
const attachments = [];
|
|
47125
|
-
if (spec.attachments?.length) await (0,
|
|
47226
|
+
if (spec.attachments?.length) await (0, import_promises31.mkdir)(dir, { recursive: true, mode: 448 });
|
|
47126
47227
|
for (const [index, attachment] of (spec.attachments ?? []).entries()) {
|
|
47127
47228
|
const bytes = await source.downloadAttachment(spec.runId, attachment.id, signal);
|
|
47128
|
-
const path = (0,
|
|
47129
|
-
await (0,
|
|
47229
|
+
const path = (0, import_node_path19.join)(dir, `${index}-${safeFilename(attachment.filename)}`);
|
|
47230
|
+
await (0, import_promises31.writeFile)(path, bytes, { mode: 384 });
|
|
47130
47231
|
const imageMimeType = attachment.kind === "image" ? detectImageMimeType(Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength)) : null;
|
|
47131
47232
|
attachments.push({
|
|
47132
47233
|
id: attachment.id,
|
|
@@ -47157,27 +47258,27 @@ async function prepareRunInputs(spec, { source, tmpDir, signal, skills = [] }) {
|
|
|
47157
47258
|
var import_node_crypto15 = require("crypto");
|
|
47158
47259
|
var import_node_fs11 = require("fs");
|
|
47159
47260
|
var import_node_net2 = require("net");
|
|
47160
|
-
var
|
|
47261
|
+
var import_node_path30 = require("path");
|
|
47161
47262
|
init_runtime_v2();
|
|
47162
47263
|
|
|
47163
47264
|
// src/holder/admission.ts
|
|
47164
47265
|
var import_node_fs9 = require("fs");
|
|
47165
|
-
var
|
|
47266
|
+
var import_promises36 = require("fs/promises");
|
|
47166
47267
|
var import_node_os5 = require("os");
|
|
47167
|
-
var
|
|
47268
|
+
var import_node_path26 = require("path");
|
|
47168
47269
|
init_constants();
|
|
47169
47270
|
|
|
47170
47271
|
// ../shared/dist/node/local-workspace.js
|
|
47171
47272
|
var import_node_fs8 = require("fs");
|
|
47172
47273
|
var import_node_os4 = require("os");
|
|
47173
|
-
var
|
|
47274
|
+
var import_node_path20 = require("path");
|
|
47174
47275
|
function resolveAlanDefaultWorkspacePath(homeDirectory = (0, import_node_os4.homedir)()) {
|
|
47175
|
-
return (0,
|
|
47276
|
+
return (0, import_node_path20.join)(homeDirectory, ".alan", "workspace");
|
|
47176
47277
|
}
|
|
47177
47278
|
|
|
47178
47279
|
// src/holder/admission-relocation.ts
|
|
47179
|
-
var
|
|
47180
|
-
var
|
|
47280
|
+
var import_promises32 = require("fs/promises");
|
|
47281
|
+
var import_node_path21 = require("path");
|
|
47181
47282
|
var MAX_RELOCATION_CANDIDATES = 200;
|
|
47182
47283
|
var RELOCATION_BUDGET_MS = 2e4;
|
|
47183
47284
|
function repositoryIdentity(url2) {
|
|
@@ -47212,8 +47313,8 @@ async function originIdentity(git, path, signal) {
|
|
|
47212
47313
|
}
|
|
47213
47314
|
async function childDirectories(parent, limit) {
|
|
47214
47315
|
try {
|
|
47215
|
-
const entries = await (0,
|
|
47216
|
-
return entries.filter((entry) => entry.isDirectory()).slice(0, limit).map((entry) => (0,
|
|
47316
|
+
const entries = await (0, import_promises32.readdir)(parent, { withFileTypes: true });
|
|
47317
|
+
return entries.filter((entry) => entry.isDirectory()).slice(0, limit).map((entry) => (0, import_node_path21.join)(parent, entry.name));
|
|
47217
47318
|
} catch {
|
|
47218
47319
|
return [];
|
|
47219
47320
|
}
|
|
@@ -47221,7 +47322,7 @@ async function childDirectories(parent, limit) {
|
|
|
47221
47322
|
async function candidateFolders(search) {
|
|
47222
47323
|
const roots = /* @__PURE__ */ new Map();
|
|
47223
47324
|
for (const path of [search.missingPath, ...search.approvedWorkspacePaths]) {
|
|
47224
|
-
const parent = (0,
|
|
47325
|
+
const parent = (0, import_node_path21.dirname)((0, import_node_path21.resolve)(path));
|
|
47225
47326
|
roots.set(comparablePath(parent, search.platform), parent);
|
|
47226
47327
|
}
|
|
47227
47328
|
const candidates2 = /* @__PURE__ */ new Map();
|
|
@@ -47248,9 +47349,205 @@ async function discoverRelocatedWorkspace(search) {
|
|
|
47248
47349
|
}
|
|
47249
47350
|
|
|
47250
47351
|
// src/holder/checkout-refresh.ts
|
|
47352
|
+
var import_node_path24 = require("path");
|
|
47353
|
+
|
|
47354
|
+
// src/holder/claim-once.ts
|
|
47251
47355
|
var import_node_crypto14 = require("crypto");
|
|
47252
|
-
var
|
|
47253
|
-
var
|
|
47356
|
+
var import_promises33 = require("fs/promises");
|
|
47357
|
+
var import_node_path22 = require("path");
|
|
47358
|
+
async function claimOnce(dir, name) {
|
|
47359
|
+
try {
|
|
47360
|
+
await (0, import_promises33.mkdir)(dir, { recursive: true, mode: 448 });
|
|
47361
|
+
await (await (0, import_promises33.open)((0, import_node_path22.join)(dir, name), "wx")).close();
|
|
47362
|
+
return true;
|
|
47363
|
+
} catch {
|
|
47364
|
+
return false;
|
|
47365
|
+
}
|
|
47366
|
+
}
|
|
47367
|
+
function claimFirstLease(freshnessDir, path) {
|
|
47368
|
+
return claimOnce((0, import_node_path22.join)(freshnessDir, "leased"), (0, import_node_crypto14.createHash)("sha256").update(path).digest("hex"));
|
|
47369
|
+
}
|
|
47370
|
+
|
|
47371
|
+
// src/holder/requested-checkout.ts
|
|
47372
|
+
var import_promises34 = require("fs/promises");
|
|
47373
|
+
var import_node_path23 = require("path");
|
|
47374
|
+
var REMOTE2 = "origin";
|
|
47375
|
+
var REASON_MAX_CHARS = 200;
|
|
47376
|
+
function firstLine2(text2) {
|
|
47377
|
+
return (text2.trim().split("\n")[0] ?? "").slice(0, REASON_MAX_CHARS);
|
|
47378
|
+
}
|
|
47379
|
+
function reasonOf(output2, command) {
|
|
47380
|
+
return firstLine2(output2.stderr) || `git ${command} exited ${output2.exitCode}`;
|
|
47381
|
+
}
|
|
47382
|
+
function noted(checkout, situation, reason, action) {
|
|
47383
|
+
return {
|
|
47384
|
+
kind: "noted",
|
|
47385
|
+
line: `Note: ${checkout.path} ${situation}: ${reason}. ${action} before relying on its files.`
|
|
47386
|
+
};
|
|
47387
|
+
}
|
|
47388
|
+
function notSwitched(checkout, current, reason) {
|
|
47389
|
+
const on = current ?? "a detached HEAD";
|
|
47390
|
+
return noted(
|
|
47391
|
+
checkout,
|
|
47392
|
+
`is on ${on}, not ${checkout.branch}, the branch picked for this chat`,
|
|
47393
|
+
reason,
|
|
47394
|
+
`Switch it to ${checkout.branch}`
|
|
47395
|
+
);
|
|
47396
|
+
}
|
|
47397
|
+
async function clone2(checkout, deps, signal) {
|
|
47398
|
+
const parent = (0, import_node_path23.dirname)(checkout.path);
|
|
47399
|
+
await (0, import_promises34.mkdir)(parent, { recursive: true });
|
|
47400
|
+
await assertValidBranch(deps.git, parent, checkout.branch, signal);
|
|
47401
|
+
const output2 = await deps.git.run(
|
|
47402
|
+
{
|
|
47403
|
+
cwd: parent,
|
|
47404
|
+
args: [
|
|
47405
|
+
"clone",
|
|
47406
|
+
"--quiet",
|
|
47407
|
+
"--no-tags",
|
|
47408
|
+
"--depth=1",
|
|
47409
|
+
"--branch",
|
|
47410
|
+
checkout.branch,
|
|
47411
|
+
"--",
|
|
47412
|
+
checkout.repoUrl,
|
|
47413
|
+
checkout.path
|
|
47414
|
+
],
|
|
47415
|
+
network: true
|
|
47416
|
+
},
|
|
47417
|
+
signal
|
|
47418
|
+
);
|
|
47419
|
+
if (output2.exitCode === 0) return { kind: "moved", how: "cloned" };
|
|
47420
|
+
return noted(
|
|
47421
|
+
checkout,
|
|
47422
|
+
`is missing, and cloning it on ${checkout.branch}, the branch picked for this chat, failed`,
|
|
47423
|
+
reasonOf(output2, "clone"),
|
|
47424
|
+
`Clone ${checkout.repoUrl} there`
|
|
47425
|
+
);
|
|
47426
|
+
}
|
|
47427
|
+
var SWITCHED = { kind: "moved", how: "switched" };
|
|
47428
|
+
function coversBranch(fetchConfig, branch) {
|
|
47429
|
+
return fetchConfig.split("\n").some(
|
|
47430
|
+
(refspec) => refspec === `+refs/heads/*:refs/remotes/${REMOTE2}/*` || refspec === `+refs/heads/${branch}:refs/remotes/${REMOTE2}/${branch}`
|
|
47431
|
+
);
|
|
47432
|
+
}
|
|
47433
|
+
async function fetchBranch(checkout, git, shallow, current) {
|
|
47434
|
+
const { branch } = checkout;
|
|
47435
|
+
const tracking = `refs/remotes/${REMOTE2}/${branch}`;
|
|
47436
|
+
const fetchConfig = await git(["config", "--get-all", `remote.${REMOTE2}.fetch`], {
|
|
47437
|
+
readOnly: true
|
|
47438
|
+
});
|
|
47439
|
+
if (!coversBranch(fetchConfig.stdout, branch)) {
|
|
47440
|
+
const added = await git(["remote", "set-branches", "--add", REMOTE2, branch]);
|
|
47441
|
+
if (added.exitCode !== 0) return notSwitched(checkout, current, reasonOf(added, "remote"));
|
|
47442
|
+
}
|
|
47443
|
+
const depth = shallow ? ["--depth=1"] : [];
|
|
47444
|
+
const fetched = await git(
|
|
47445
|
+
["fetch", "--no-tags", "--quiet", ...depth, REMOTE2, `refs/heads/${branch}:${tracking}`],
|
|
47446
|
+
{ network: true }
|
|
47447
|
+
);
|
|
47448
|
+
if (fetched.exitCode !== 0) return notSwitched(checkout, current, reasonOf(fetched, "fetch"));
|
|
47449
|
+
const tip = await git(["rev-parse", "--verify", tracking], { readOnly: true });
|
|
47450
|
+
if (tip.exitCode !== 0) return notSwitched(checkout, current, reasonOf(tip, "rev-parse"));
|
|
47451
|
+
return { kind: "fetched", tip: tip.stdout.trim() };
|
|
47452
|
+
}
|
|
47453
|
+
async function moveOnto(checkout, git, tip, current) {
|
|
47454
|
+
const { branch } = checkout;
|
|
47455
|
+
const local = await git(["rev-parse", "--verify", "-q", `refs/heads/${branch}`], {
|
|
47456
|
+
readOnly: true
|
|
47457
|
+
});
|
|
47458
|
+
if (local.exitCode !== 0) {
|
|
47459
|
+
const created = await git([
|
|
47460
|
+
"switch",
|
|
47461
|
+
"--quiet",
|
|
47462
|
+
"-c",
|
|
47463
|
+
branch,
|
|
47464
|
+
"--track",
|
|
47465
|
+
`${REMOTE2}/${branch}`
|
|
47466
|
+
]);
|
|
47467
|
+
return created.exitCode === 0 ? SWITCHED : notSwitched(checkout, current, reasonOf(created, "switch"));
|
|
47468
|
+
}
|
|
47469
|
+
const localHead = local.stdout.trim();
|
|
47470
|
+
const ancestor = localHead === tip || (await git(["merge-base", "--is-ancestor", localHead, tip], { readOnly: true })).exitCode === 0;
|
|
47471
|
+
if (!ancestor) {
|
|
47472
|
+
return notSwitched(
|
|
47473
|
+
checkout,
|
|
47474
|
+
current,
|
|
47475
|
+
`its local ${branch} has diverged from ${REMOTE2}/${branch}`
|
|
47476
|
+
);
|
|
47477
|
+
}
|
|
47478
|
+
const switched = await git(["switch", "--quiet", branch]);
|
|
47479
|
+
if (switched.exitCode !== 0) return notSwitched(checkout, current, reasonOf(switched, "switch"));
|
|
47480
|
+
if (localHead === tip) return SWITCHED;
|
|
47481
|
+
const merged = await git(["merge", "--quiet", "--ff-only", tip]);
|
|
47482
|
+
return merged.exitCode === 0 ? SWITCHED : noted(
|
|
47483
|
+
checkout,
|
|
47484
|
+
`is on ${branch} but behind ${REMOTE2}/${branch}`,
|
|
47485
|
+
reasonOf(merged, "merge"),
|
|
47486
|
+
"Run `git pull --ff-only` there"
|
|
47487
|
+
);
|
|
47488
|
+
}
|
|
47489
|
+
async function switchTo(checkout, current, operationId, deps, signal) {
|
|
47490
|
+
var _stack = [];
|
|
47491
|
+
try {
|
|
47492
|
+
const cwd = checkout.path;
|
|
47493
|
+
const git = (args, invocation = {}) => deps.git.run({ cwd, args, ...invocation }, signal);
|
|
47494
|
+
await assertValidBranch(deps.git, cwd, checkout.branch, signal);
|
|
47495
|
+
const refs = await git(
|
|
47496
|
+
["rev-parse", "--path-format=absolute", "--git-common-dir", "--is-shallow-repository"],
|
|
47497
|
+
{ readOnly: true }
|
|
47498
|
+
);
|
|
47499
|
+
if (refs.exitCode !== 0) return notSwitched(checkout, current, reasonOf(refs, "rev-parse"));
|
|
47500
|
+
const [commonDir = "", shallow] = refs.stdout.trim().split("\n");
|
|
47501
|
+
const attempt = await deps.locks.tryExclusive(commonDir, operationId);
|
|
47502
|
+
if (attempt.kind === "busy") {
|
|
47503
|
+
return notSwitched(checkout, current, "another git operation holds the checkout");
|
|
47504
|
+
}
|
|
47505
|
+
const _lock = __using(_stack, attempt.lock, true);
|
|
47506
|
+
const now = await readCheckoutStatus(deps.git, cwd, signal);
|
|
47507
|
+
if (now === null || now.dirty) {
|
|
47508
|
+
return notSwitched(checkout, now?.branch ?? current, "it has uncommitted changes");
|
|
47509
|
+
}
|
|
47510
|
+
const fetched = await fetchBranch(checkout, git, shallow === "true", now.branch);
|
|
47511
|
+
if (fetched.kind !== "fetched") return fetched;
|
|
47512
|
+
const outcome2 = await moveOnto(checkout, git, fetched.tip, now.branch);
|
|
47513
|
+
const after = await readCheckoutStatus(deps.git, cwd, signal);
|
|
47514
|
+
if (after?.branch === checkout.branch) {
|
|
47515
|
+
await recordCheckoutKept(deps.dir, cwd, "requested_branch");
|
|
47516
|
+
}
|
|
47517
|
+
return outcome2;
|
|
47518
|
+
} catch (_) {
|
|
47519
|
+
var _error = _, _hasError = true;
|
|
47520
|
+
} finally {
|
|
47521
|
+
var _promise2 = __callDispose(_stack, _error, _hasError);
|
|
47522
|
+
_promise2 && await _promise2;
|
|
47523
|
+
}
|
|
47524
|
+
}
|
|
47525
|
+
async function applyRequestedCheckout(checkout, spec, deps, signal) {
|
|
47526
|
+
try {
|
|
47527
|
+
if (!await isCheckout(checkout.path)) return await clone2(checkout, deps, signal);
|
|
47528
|
+
const status = await readCheckoutStatus(deps.git, checkout.path, signal);
|
|
47529
|
+
if (status === null) return notSwitched(checkout, null, "git status failed");
|
|
47530
|
+
if (status.branch === checkout.branch) return { kind: "on_branch" };
|
|
47531
|
+
if (status.dirty) return notSwitched(checkout, status.branch, "it has uncommitted changes");
|
|
47532
|
+
if (!await claimFirstLease(deps.dir, checkout.path)) {
|
|
47533
|
+
return notSwitched(
|
|
47534
|
+
checkout,
|
|
47535
|
+
status.branch,
|
|
47536
|
+
"an earlier conversation on this machine already uses it"
|
|
47537
|
+
);
|
|
47538
|
+
}
|
|
47539
|
+
return await switchTo(checkout, status.branch, `checkout-${spec.runId}`, deps, signal);
|
|
47540
|
+
} catch (error61) {
|
|
47541
|
+
return noted(
|
|
47542
|
+
checkout,
|
|
47543
|
+
`could not be put on ${checkout.branch}, the branch picked for this chat`,
|
|
47544
|
+
firstLine2(error61 instanceof Error ? error61.message : String(error61)) || "unknown error",
|
|
47545
|
+
"Check it"
|
|
47546
|
+
);
|
|
47547
|
+
}
|
|
47548
|
+
}
|
|
47549
|
+
|
|
47550
|
+
// src/holder/checkout-refresh.ts
|
|
47254
47551
|
function short(sha) {
|
|
47255
47552
|
return sha.slice(0, 12);
|
|
47256
47553
|
}
|
|
@@ -47260,15 +47557,6 @@ function staleLine(path, snapshot2, tip) {
|
|
|
47260
47557
|
const remote = tip === void 0 ? "may be ahead" : `is ahead at ${short(tip)}`;
|
|
47261
47558
|
return `Note: ${path} ${checkout}; ${base} ${remote}. Run \`git pull --ff-only\` there before relying on its files.`;
|
|
47262
47559
|
}
|
|
47263
|
-
async function claimOnce(dir, name) {
|
|
47264
|
-
try {
|
|
47265
|
-
await (0, import_promises32.mkdir)(dir, { recursive: true, mode: 448 });
|
|
47266
|
-
await (await (0, import_promises32.open)((0, import_node_path21.join)(dir, name), "wx")).close();
|
|
47267
|
-
return true;
|
|
47268
|
-
} catch {
|
|
47269
|
-
return false;
|
|
47270
|
-
}
|
|
47271
|
-
}
|
|
47272
47560
|
async function fastForward(freshness, operationId, deps, signal) {
|
|
47273
47561
|
var _stack = [];
|
|
47274
47562
|
try {
|
|
@@ -47293,10 +47581,7 @@ async function fastForward(freshness, operationId, deps, signal) {
|
|
|
47293
47581
|
}
|
|
47294
47582
|
}
|
|
47295
47583
|
async function atFirstLease(freshness, spec, deps, signal) {
|
|
47296
|
-
const first = await
|
|
47297
|
-
(0, import_node_path21.join)(deps.dir, "leased"),
|
|
47298
|
-
(0, import_node_crypto14.createHash)("sha256").update(freshness.path).digest("hex")
|
|
47299
|
-
);
|
|
47584
|
+
const first = await claimFirstLease(deps.dir, freshness.path);
|
|
47300
47585
|
switch (freshness.state) {
|
|
47301
47586
|
case "current":
|
|
47302
47587
|
case "kept":
|
|
@@ -47322,32 +47607,73 @@ async function checkoutsOf(spec, leaseTargets) {
|
|
|
47322
47607
|
if (leaseTargets.length > 0 || spec.projectPath === void 0) return [...leaseTargets];
|
|
47323
47608
|
return checkoutsUnder(spec.projectPath);
|
|
47324
47609
|
}
|
|
47325
|
-
function
|
|
47326
|
-
|
|
47327
|
-
|
|
47328
|
-
|
|
47329
|
-
|
|
47330
|
-
|
|
47331
|
-
const freshness = await readCheckoutFreshness(deps.dir, target);
|
|
47332
|
-
if (freshness === null) continue;
|
|
47333
|
-
const outcome2 = await atFirstLease(freshness, spec, deps, signal).catch(
|
|
47334
|
-
() => "noted"
|
|
47335
|
-
);
|
|
47336
|
-
if (outcome2 === "noted") lines.push(lineFor(freshness));
|
|
47337
|
-
deps.log.info("workspace.refresh", {
|
|
47610
|
+
function requestedCheckoutsOf(spec, log) {
|
|
47611
|
+
const roots = spec.approvedWorkspacePaths ?? [];
|
|
47612
|
+
return (spec.requestedCheckouts ?? []).filter((checkout) => {
|
|
47613
|
+
const approved = roots.some((root) => isWithin(root, checkout.path, process.platform));
|
|
47614
|
+
if (!approved) {
|
|
47615
|
+
log.warn("workspace.requested_checkout_outside_workspace", {
|
|
47338
47616
|
runId: spec.runId,
|
|
47339
|
-
path:
|
|
47340
|
-
state: freshness.state,
|
|
47341
|
-
outcome: outcome2
|
|
47617
|
+
path: checkout.path
|
|
47342
47618
|
});
|
|
47343
47619
|
}
|
|
47620
|
+
return approved;
|
|
47621
|
+
});
|
|
47622
|
+
}
|
|
47623
|
+
async function applyRequestedCheckouts(spec, deps, signal) {
|
|
47624
|
+
const settled2 = /* @__PURE__ */ new Set();
|
|
47625
|
+
const lines = [];
|
|
47626
|
+
for (const checkout of requestedCheckoutsOf(spec, deps.log)) {
|
|
47627
|
+
const outcome2 = await applyRequestedCheckout(checkout, spec, deps, signal);
|
|
47628
|
+
deps.log.info("workspace.requested_checkout", {
|
|
47629
|
+
runId: spec.runId,
|
|
47630
|
+
path: checkout.path,
|
|
47631
|
+
branch: checkout.branch,
|
|
47632
|
+
outcome: outcome2.kind,
|
|
47633
|
+
...outcome2.kind === "moved" ? { how: outcome2.how } : {}
|
|
47634
|
+
});
|
|
47635
|
+
if (outcome2.kind === "on_branch") continue;
|
|
47636
|
+
settled2.add((0, import_node_path24.resolve)(checkout.path));
|
|
47637
|
+
if (outcome2.kind === "noted") lines.push(outcome2.line);
|
|
47638
|
+
}
|
|
47639
|
+
return { settled: settled2, lines };
|
|
47640
|
+
}
|
|
47641
|
+
async function refreshSnapshotCheckouts(spec, targets, settled2, deps, signal) {
|
|
47642
|
+
const lines = [];
|
|
47643
|
+
for (const target of targets) {
|
|
47644
|
+
if (settled2.has((0, import_node_path24.resolve)(target))) continue;
|
|
47645
|
+
const freshness = await readCheckoutFreshness(deps.dir, target);
|
|
47646
|
+
if (freshness === null) continue;
|
|
47647
|
+
const outcome2 = await atFirstLease(freshness, spec, deps, signal).catch(
|
|
47648
|
+
() => "noted"
|
|
47649
|
+
);
|
|
47650
|
+
if (outcome2 === "noted") lines.push(lineFor(freshness));
|
|
47651
|
+
deps.log.info("workspace.refresh", {
|
|
47652
|
+
runId: spec.runId,
|
|
47653
|
+
path: freshness.path,
|
|
47654
|
+
state: freshness.state,
|
|
47655
|
+
outcome: outcome2
|
|
47656
|
+
});
|
|
47657
|
+
}
|
|
47658
|
+
return lines;
|
|
47659
|
+
}
|
|
47660
|
+
function createCheckoutRefresh(deps) {
|
|
47661
|
+
return async (spec, leaseTargets, signal) => {
|
|
47662
|
+
if (spec.providerSessionId !== void 0) return void 0;
|
|
47663
|
+
if (!await claimOnce((0, import_node_path24.join)(deps.dir, "conversations"), spec.conversationId)) return void 0;
|
|
47664
|
+
const requested = await applyRequestedCheckouts(spec, deps, signal);
|
|
47665
|
+
const targets = await checkoutsOf(spec, leaseTargets);
|
|
47666
|
+
const lines = [
|
|
47667
|
+
...requested.lines,
|
|
47668
|
+
...await refreshSnapshotCheckouts(spec, targets, requested.settled, deps, signal)
|
|
47669
|
+
];
|
|
47344
47670
|
return lines.length === 0 ? void 0 : lines.join("\n");
|
|
47345
47671
|
};
|
|
47346
47672
|
}
|
|
47347
47673
|
|
|
47348
47674
|
// src/holder/lease.ts
|
|
47349
|
-
var
|
|
47350
|
-
var
|
|
47675
|
+
var import_promises35 = require("fs/promises");
|
|
47676
|
+
var import_node_path25 = require("path");
|
|
47351
47677
|
var LEASE_CHECK_EVERY_MS = 5e3;
|
|
47352
47678
|
var MAX_TRANSIENT_FAILURES = 3;
|
|
47353
47679
|
var BACKOFF_BASE_MS = 1e3;
|
|
@@ -47361,8 +47687,8 @@ function identityFailure(code, workspacePath) {
|
|
|
47361
47687
|
return { code, problemCode: "app.workspace.missing", message: MESSAGES[code], workspacePath };
|
|
47362
47688
|
}
|
|
47363
47689
|
async function fileIdentity(path) {
|
|
47364
|
-
const canonical = await (0,
|
|
47365
|
-
const info = await (0,
|
|
47690
|
+
const canonical = await (0, import_promises35.realpath)(path);
|
|
47691
|
+
const info = await (0, import_promises35.stat)(canonical, { bigint: true });
|
|
47366
47692
|
return `${canonical}:${info.dev}:${info.ino}`;
|
|
47367
47693
|
}
|
|
47368
47694
|
async function snapshot(git, path, signal) {
|
|
@@ -47381,7 +47707,7 @@ async function snapshot(git, path, signal) {
|
|
|
47381
47707
|
workspace: await fileIdentity(path),
|
|
47382
47708
|
repository: await fileIdentity(commonDir),
|
|
47383
47709
|
worktree: await fileIdentity(gitDir),
|
|
47384
|
-
commonDir: await (0,
|
|
47710
|
+
commonDir: await (0, import_promises35.realpath)(commonDir)
|
|
47385
47711
|
};
|
|
47386
47712
|
} catch {
|
|
47387
47713
|
return null;
|
|
@@ -47394,7 +47720,7 @@ async function gitValue(git, path, args, signal) {
|
|
|
47394
47720
|
}
|
|
47395
47721
|
async function pathExists(path) {
|
|
47396
47722
|
try {
|
|
47397
|
-
await (0,
|
|
47723
|
+
await (0, import_promises35.stat)(path);
|
|
47398
47724
|
return true;
|
|
47399
47725
|
} catch (error61) {
|
|
47400
47726
|
return errnoCode(error61) !== "ENOENT" && errnoCode(error61) !== "ENOTDIR";
|
|
@@ -47403,19 +47729,19 @@ async function pathExists(path) {
|
|
|
47403
47729
|
async function hasGitMarker(path) {
|
|
47404
47730
|
let directory;
|
|
47405
47731
|
try {
|
|
47406
|
-
directory = await (0,
|
|
47732
|
+
directory = await (0, import_promises35.realpath)(path);
|
|
47407
47733
|
} catch {
|
|
47408
47734
|
return true;
|
|
47409
47735
|
}
|
|
47410
47736
|
for (; ; ) {
|
|
47411
47737
|
try {
|
|
47412
|
-
await (0,
|
|
47738
|
+
await (0, import_promises35.stat)((0, import_node_path25.join)(directory, ".git"));
|
|
47413
47739
|
return true;
|
|
47414
47740
|
} catch (error61) {
|
|
47415
47741
|
const code = errnoCode(error61);
|
|
47416
47742
|
if (code !== "ENOENT" && code !== "ENOTDIR") return true;
|
|
47417
47743
|
}
|
|
47418
|
-
const parent = (0,
|
|
47744
|
+
const parent = (0, import_node_path25.dirname)(directory);
|
|
47419
47745
|
if (parent === directory) return false;
|
|
47420
47746
|
directory = parent;
|
|
47421
47747
|
}
|
|
@@ -47579,7 +47905,7 @@ function volumeRoot(path) {
|
|
|
47579
47905
|
}
|
|
47580
47906
|
async function exists(path) {
|
|
47581
47907
|
try {
|
|
47582
|
-
await (0,
|
|
47908
|
+
await (0, import_promises36.stat)(path);
|
|
47583
47909
|
return true;
|
|
47584
47910
|
} catch {
|
|
47585
47911
|
return false;
|
|
@@ -47587,10 +47913,10 @@ async function exists(path) {
|
|
|
47587
47913
|
}
|
|
47588
47914
|
async function inspectReadiness(path) {
|
|
47589
47915
|
try {
|
|
47590
|
-
if (!(await (0,
|
|
47916
|
+
if (!(await (0, import_promises36.stat)(path)).isDirectory()) {
|
|
47591
47917
|
return { ready: false, missing: true, message: MESSAGES2.missing };
|
|
47592
47918
|
}
|
|
47593
|
-
await (0,
|
|
47919
|
+
await (0, import_promises36.access)(path, import_node_fs9.constants.R_OK | import_node_fs9.constants.W_OK | import_node_fs9.constants.X_OK);
|
|
47594
47920
|
return { ready: true };
|
|
47595
47921
|
} catch (error61) {
|
|
47596
47922
|
const code = errnoCode(error61) ?? "";
|
|
@@ -47668,8 +47994,8 @@ async function admitDefaultWorkspace(spec, context, skills) {
|
|
|
47668
47994
|
const { env } = context;
|
|
47669
47995
|
const path = resolveAlanDefaultWorkspacePath(env.HOME || env.USERPROFILE || (0, import_node_os5.homedir)());
|
|
47670
47996
|
try {
|
|
47671
|
-
await (0,
|
|
47672
|
-
await (0,
|
|
47997
|
+
await (0, import_promises36.mkdir)(path, { recursive: true, mode: 448 });
|
|
47998
|
+
await (0, import_promises36.access)(path, import_node_fs9.constants.R_OK | import_node_fs9.constants.W_OK | import_node_fs9.constants.X_OK);
|
|
47673
47999
|
return {
|
|
47674
48000
|
kind: "admitted",
|
|
47675
48001
|
spec: { ...spec, projectPath: path },
|
|
@@ -47742,10 +48068,12 @@ async function admitRun(spec, context, signal) {
|
|
|
47742
48068
|
};
|
|
47743
48069
|
}
|
|
47744
48070
|
var PROBE_TIMEOUT_MS2 = 5e3;
|
|
48071
|
+
var CHECKOUT_LOCAL_TIMEOUT_MS = 6e4;
|
|
48072
|
+
var CHECKOUT_NETWORK_TIMEOUT_MS = 12e4;
|
|
47745
48073
|
function createHolderWorkspace(machine, clock, log) {
|
|
47746
48074
|
const platform = machine.platform ?? process.platform;
|
|
47747
48075
|
const git = createGitRunner({ env: machine.env, platform, localTimeoutMs: PROBE_TIMEOUT_MS2 });
|
|
47748
|
-
const locks = openRepositoryLocks({ dir: (0,
|
|
48076
|
+
const locks = openRepositoryLocks({ dir: (0, import_node_path26.join)(machine.stateDir, "locks"), clock, platform });
|
|
47749
48077
|
return {
|
|
47750
48078
|
admission: {
|
|
47751
48079
|
env: machine.env,
|
|
@@ -47757,7 +48085,7 @@ function createHolderWorkspace(machine, clock, log) {
|
|
|
47757
48085
|
),
|
|
47758
48086
|
approvedRoots: async () => {
|
|
47759
48087
|
const approved = await openApprovedPaths({
|
|
47760
|
-
file: (0,
|
|
48088
|
+
file: (0, import_node_path26.join)(machine.stateDir, "workspaces.json"),
|
|
47761
48089
|
log,
|
|
47762
48090
|
platform
|
|
47763
48091
|
});
|
|
@@ -47767,10 +48095,15 @@ function createHolderWorkspace(machine, clock, log) {
|
|
|
47767
48095
|
lease: { git, locks, clock, log, platform },
|
|
47768
48096
|
...machine.refreshesFirstCheckout === true ? {
|
|
47769
48097
|
refreshFirstCheckout: createCheckoutRefresh({
|
|
47770
|
-
git
|
|
48098
|
+
git: createGitRunner({
|
|
48099
|
+
env: machine.env,
|
|
48100
|
+
platform,
|
|
48101
|
+
localTimeoutMs: CHECKOUT_LOCAL_TIMEOUT_MS,
|
|
48102
|
+
networkTimeoutMs: CHECKOUT_NETWORK_TIMEOUT_MS
|
|
48103
|
+
}),
|
|
47771
48104
|
locks,
|
|
47772
48105
|
log,
|
|
47773
|
-
dir: (0,
|
|
48106
|
+
dir: (0, import_node_path26.join)(machine.stateDir, "checkout-freshness")
|
|
47774
48107
|
})
|
|
47775
48108
|
} : {}
|
|
47776
48109
|
};
|
|
@@ -47798,7 +48131,7 @@ async function respondToTurn(runningRunId, gate, driver, request2) {
|
|
|
47798
48131
|
}
|
|
47799
48132
|
|
|
47800
48133
|
// src/holder/session-facts.ts
|
|
47801
|
-
var
|
|
48134
|
+
var import_promises37 = require("fs/promises");
|
|
47802
48135
|
var CLI_RSS_CACHE_MS = 1e4;
|
|
47803
48136
|
var LOGIN_PROBLEM_PREFIX = "cli.auth.";
|
|
47804
48137
|
function isLoginFailure(result) {
|
|
@@ -47824,8 +48157,8 @@ function createSessionFacts(options) {
|
|
|
47824
48157
|
const path = await resolveCommandOnPath(command, env, platform);
|
|
47825
48158
|
if (path === null) return null;
|
|
47826
48159
|
try {
|
|
47827
|
-
const real = await (0,
|
|
47828
|
-
const info = await (0,
|
|
48160
|
+
const real = await (0, import_promises37.realpath)(path);
|
|
48161
|
+
const info = await (0, import_promises37.stat)(real);
|
|
47829
48162
|
return { command, key: `${real}:${info.ino}:${info.size}:${info.mtimeMs}` };
|
|
47830
48163
|
} catch {
|
|
47831
48164
|
return null;
|
|
@@ -47912,8 +48245,8 @@ function createSessionFacts(options) {
|
|
|
47912
48245
|
init_acp2();
|
|
47913
48246
|
|
|
47914
48247
|
// src/run-log/directory.ts
|
|
47915
|
-
var
|
|
47916
|
-
var
|
|
48248
|
+
var import_promises38 = require("fs/promises");
|
|
48249
|
+
var import_node_path27 = require("path");
|
|
47917
48250
|
init_runtime_v2();
|
|
47918
48251
|
init_zod();
|
|
47919
48252
|
var runMetaSchema = external_exports.object({
|
|
@@ -47935,17 +48268,17 @@ var runMetaSchema = external_exports.object({
|
|
|
47935
48268
|
}).optional()
|
|
47936
48269
|
});
|
|
47937
48270
|
function runDirectory(runsDir, runId) {
|
|
47938
|
-
const dir = (0,
|
|
48271
|
+
const dir = (0, import_node_path27.join)(runsDir, runId);
|
|
47939
48272
|
return {
|
|
47940
48273
|
dir,
|
|
47941
|
-
log: (0,
|
|
47942
|
-
upload: (0,
|
|
47943
|
-
meta: (0,
|
|
48274
|
+
log: (0, import_node_path27.join)(dir, "log.jsonl"),
|
|
48275
|
+
upload: (0, import_node_path27.join)(dir, "upload.json"),
|
|
48276
|
+
meta: (0, import_node_path27.join)(dir, "run.json")
|
|
47944
48277
|
};
|
|
47945
48278
|
}
|
|
47946
48279
|
async function isRunClaimed(runsDir, runId) {
|
|
47947
48280
|
try {
|
|
47948
|
-
return (await (0,
|
|
48281
|
+
return (await (0, import_promises38.stat)(runDirectory(runsDir, runId).log)).size > 0;
|
|
47949
48282
|
} catch (error61) {
|
|
47950
48283
|
if (errnoCode(error61) === "ENOENT") return false;
|
|
47951
48284
|
throw error61;
|
|
@@ -47953,8 +48286,8 @@ async function isRunClaimed(runsDir, runId) {
|
|
|
47953
48286
|
}
|
|
47954
48287
|
|
|
47955
48288
|
// src/run-log/conversation-index.ts
|
|
47956
|
-
var
|
|
47957
|
-
var
|
|
48289
|
+
var import_promises39 = require("fs/promises");
|
|
48290
|
+
var import_node_path28 = require("path");
|
|
47958
48291
|
init_runtime_v2();
|
|
47959
48292
|
init_zod();
|
|
47960
48293
|
var ORDINALS_PER_SHARD = 1e3;
|
|
@@ -47970,13 +48303,13 @@ var coverageSchema = external_exports.object({
|
|
|
47970
48303
|
nextExpectedOrdinal: external_exports.number().int().positive()
|
|
47971
48304
|
});
|
|
47972
48305
|
function conversationsDirectory(runsDir) {
|
|
47973
|
-
return (0,
|
|
48306
|
+
return (0, import_node_path28.join)((0, import_node_path28.dirname)(runsDir), "conversations");
|
|
47974
48307
|
}
|
|
47975
48308
|
function indexDirectory(runsDir, conversationId) {
|
|
47976
|
-
return (0,
|
|
48309
|
+
return (0, import_node_path28.join)(conversationsDirectory(runsDir), conversationId, "turn-index");
|
|
47977
48310
|
}
|
|
47978
48311
|
function shardPath(runsDir, conversationId, ordinal) {
|
|
47979
|
-
return (0,
|
|
48312
|
+
return (0, import_node_path28.join)(
|
|
47980
48313
|
indexDirectory(runsDir, conversationId),
|
|
47981
48314
|
`${Math.floor(ordinal / ORDINALS_PER_SHARD)}.jsonl`
|
|
47982
48315
|
);
|
|
@@ -47985,10 +48318,10 @@ async function indexConversationRun(runsDir, conversationId, ordinal, assistantO
|
|
|
47985
48318
|
const nextOrdinal = assistantOrdinal + 1;
|
|
47986
48319
|
if (nextOrdinal <= ordinal) throw new Error("Assistant order must follow the prompt");
|
|
47987
48320
|
const path = shardPath(runsDir, conversationId, ordinal);
|
|
47988
|
-
await (0,
|
|
47989
|
-
await (0,
|
|
48321
|
+
await (0, import_promises39.mkdir)((0, import_node_path28.dirname)(path), { recursive: true, mode: 448 });
|
|
48322
|
+
await (0, import_promises39.appendFile)(path, `${JSON.stringify({ ordinal, nextOrdinal, runId })}
|
|
47990
48323
|
`, { mode: 384 });
|
|
47991
|
-
const coveragePath = (0,
|
|
48324
|
+
const coveragePath = (0, import_node_path28.join)((0, import_node_path28.dirname)((0, import_node_path28.dirname)(path)), "coverage.json");
|
|
47992
48325
|
const coverage = await readJsonFile(coveragePath, coverageSchema);
|
|
47993
48326
|
const current = coverage.kind === "ok" ? coverage.value : null;
|
|
47994
48327
|
const next = nextCoverage(current, ordinal, nextOrdinal);
|
|
@@ -48032,7 +48365,7 @@ var decoder = new TextDecoder();
|
|
|
48032
48365
|
|
|
48033
48366
|
// src/run-log/writer.ts
|
|
48034
48367
|
var import_node_fs10 = require("fs");
|
|
48035
|
-
var
|
|
48368
|
+
var import_node_path29 = require("path");
|
|
48036
48369
|
init_runtime_v2();
|
|
48037
48370
|
function lastSeq(fd, size) {
|
|
48038
48371
|
for (const length of tailWindows(size)) {
|
|
@@ -48048,7 +48381,7 @@ function lastSeq(fd, size) {
|
|
|
48048
48381
|
throw new RuntimeFault("record_too_large", "Run log tail record is larger than any record");
|
|
48049
48382
|
}
|
|
48050
48383
|
function openRunLog(path, clock) {
|
|
48051
|
-
(0, import_node_fs10.mkdirSync)((0,
|
|
48384
|
+
(0, import_node_fs10.mkdirSync)((0, import_node_path29.dirname)(path), { recursive: true, mode: 448 });
|
|
48052
48385
|
const fd = (0, import_node_fs10.openSync)(path, "a+", 384);
|
|
48053
48386
|
let size = (0, import_node_fs10.fstatSync)(fd).size;
|
|
48054
48387
|
let seq = lastSeq(fd, size);
|
|
@@ -48384,7 +48717,7 @@ async function runHolder({
|
|
|
48384
48717
|
try {
|
|
48385
48718
|
const identity = await readProcessIdentity(process.pid);
|
|
48386
48719
|
if (identity === null) throw new RuntimeFault("internal", "Cannot read own process identity");
|
|
48387
|
-
const _engines = __using(_stack, recordSpawnedEngines(engineRecordsPath((0,
|
|
48720
|
+
const _engines = __using(_stack, recordSpawnedEngines(engineRecordsPath((0, import_node_path30.dirname)(launch.statusPath)), clock, log));
|
|
48388
48721
|
const holder = {
|
|
48389
48722
|
state: "idle",
|
|
48390
48723
|
runId: null,
|
|
@@ -48580,16 +48913,16 @@ async function runHolder({
|
|
|
48580
48913
|
client.on("error", () => holder.clients.delete(client));
|
|
48581
48914
|
});
|
|
48582
48915
|
removeStaleEndpoint(launch.endpoint);
|
|
48583
|
-
await new Promise((
|
|
48916
|
+
await new Promise((resolve9, reject) => {
|
|
48584
48917
|
server.once("error", reject);
|
|
48585
|
-
server.listen(launch.endpoint, () =>
|
|
48918
|
+
server.listen(launch.endpoint, () => resolve9());
|
|
48586
48919
|
});
|
|
48587
48920
|
await writeStatus();
|
|
48588
48921
|
log.info("holder.ready", { conversationId: launch.conversationId, pid: identity.pid });
|
|
48589
|
-
await new Promise((
|
|
48922
|
+
await new Promise((resolve9) => exit.signal.addEventListener("abort", () => resolve9()));
|
|
48590
48923
|
await driver.suspend?.().catch((error61) => log.warn("holder.driver_suspend_failed", { error: error61 }));
|
|
48591
48924
|
for (const client of holder.clients) client.end();
|
|
48592
|
-
await new Promise((
|
|
48925
|
+
await new Promise((resolve9) => server.close(() => resolve9()));
|
|
48593
48926
|
(0, import_node_fs11.rmSync)(launch.statusPath, { force: true });
|
|
48594
48927
|
log.info("holder.suspended", { conversationId: launch.conversationId });
|
|
48595
48928
|
} catch (_) {
|
|
@@ -48729,7 +49062,7 @@ function loadRuntimeConfig(env = process.env, totalMemoryBytes = (0, import_node
|
|
|
48729
49062
|
providerProbes: ALAN_RUNTIME_PROVIDER_PROBES === "on",
|
|
48730
49063
|
providerToolchain: ALAN_RUNTIME_PROVIDER_NODE !== void 0 && ALAN_RUNTIME_PROVIDER_NPM_CLI !== void 0 ? { node: ALAN_RUNTIME_PROVIDER_NODE, npmCli: ALAN_RUNTIME_PROVIDER_NPM_CLI } : null,
|
|
48731
49064
|
home,
|
|
48732
|
-
configHome: XDG_CONFIG_HOME ?? (0,
|
|
49065
|
+
configHome: XDG_CONFIG_HOME ?? (0, import_node_path32.join)(home, ".config"),
|
|
48733
49066
|
codexHome: resolveCodexHome(CODEX_HOME, home),
|
|
48734
49067
|
...githubProxyConfig({ ALAN_RUNTIME_GITHUB_PROXY, XDG_CONFIG_HOME, GH_CONFIG_DIR }, home),
|
|
48735
49068
|
gitGatewayUrl: ALAN_RUNTIME_GIT_GATEWAY_URL ?? null,
|
|
@@ -48739,13 +49072,13 @@ function loadRuntimeConfig(env = process.env, totalMemoryBytes = (0, import_node
|
|
|
48739
49072
|
};
|
|
48740
49073
|
}
|
|
48741
49074
|
function resolveCodexHome(configuredHome, home) {
|
|
48742
|
-
return configuredHome ?? (0,
|
|
49075
|
+
return configuredHome ?? (0, import_node_path32.join)(home, ".codex");
|
|
48743
49076
|
}
|
|
48744
49077
|
function githubProxyConfig(env, home) {
|
|
48745
|
-
const configHome = env.XDG_CONFIG_HOME ?? (0,
|
|
49078
|
+
const configHome = env.XDG_CONFIG_HOME ?? (0, import_node_path32.join)(home, ".config");
|
|
48746
49079
|
return {
|
|
48747
49080
|
githubProxy: env.ALAN_RUNTIME_GITHUB_PROXY === "on",
|
|
48748
|
-
ghConfigDir: env.GH_CONFIG_DIR ?? (0,
|
|
49081
|
+
ghConfigDir: env.GH_CONFIG_DIR ?? (0, import_node_path32.join)(configHome, "gh")
|
|
48749
49082
|
};
|
|
48750
49083
|
}
|
|
48751
49084
|
function serviceEnvironment(env, profile) {
|
|
@@ -48844,7 +49177,7 @@ async function loadStoredAccess(paths, access3 = { exec: systemExec }) {
|
|
|
48844
49177
|
}
|
|
48845
49178
|
|
|
48846
49179
|
// src/cli/commands/hold.ts
|
|
48847
|
-
var
|
|
49180
|
+
var import_node_path33 = require("path");
|
|
48848
49181
|
init_agent2();
|
|
48849
49182
|
init_runtime_v2();
|
|
48850
49183
|
async function machineAccess(paths, log, conversationId, transport) {
|
|
@@ -48902,7 +49235,7 @@ async function runHold(argv) {
|
|
|
48902
49235
|
const config2 = loadRuntimeConfig();
|
|
48903
49236
|
const paths = runtimePaths(config2.stateDir);
|
|
48904
49237
|
const log = __using(_stack, openFileLog(
|
|
48905
|
-
(0,
|
|
49238
|
+
(0, import_node_path33.join)(paths.logs, `holder-${launch.value.conversationId}.jsonl`),
|
|
48906
49239
|
config2.logLevel,
|
|
48907
49240
|
systemClock
|
|
48908
49241
|
));
|
|
@@ -48913,7 +49246,7 @@ async function runHold(argv) {
|
|
|
48913
49246
|
);
|
|
48914
49247
|
const transport = __using(_stack, createHttpTransport());
|
|
48915
49248
|
const access3 = await machineAccess(paths, log, launch.value.conversationId, transport);
|
|
48916
|
-
const credentialPath = (0,
|
|
49249
|
+
const credentialPath = (0, import_node_path33.join)(paths.tmp, "mcp", `${launch.value.conversationId}.json`);
|
|
48917
49250
|
const managedMcp = __using(_stack, access3.managedMcp === void 0 ? void 0 : createHelperMcpAccess({
|
|
48918
49251
|
managedMcp: access3.managedMcp,
|
|
48919
49252
|
conversationId: launch.value.conversationId,
|