@alan-ai-hq/agent-manager-linux-x64 0.1.166 → 0.1.168
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 +897 -665
- package/alan-holder.cjs +230 -140
- package/package.json +1 -1
package/alan-agent.cjs
CHANGED
|
@@ -4633,7 +4633,7 @@ function isRef(value2) {
|
|
|
4633
4633
|
function cloneIssues(issues) {
|
|
4634
4634
|
return issues.map((iss) => iss.path ? { ...iss, path: iss.path.slice() } : { ...iss });
|
|
4635
4635
|
}
|
|
4636
|
-
function isRecursive(inst, stack,
|
|
4636
|
+
function isRecursive(inst, stack, resolve14) {
|
|
4637
4637
|
const cached2 = recursive.get(inst);
|
|
4638
4638
|
if (cached2 !== void 0)
|
|
4639
4639
|
return cached2 ? PROVEN : NONE;
|
|
@@ -4643,7 +4643,7 @@ function isRecursive(inst, stack, resolve13) {
|
|
|
4643
4643
|
let result = NONE;
|
|
4644
4644
|
const check3 = (child) => {
|
|
4645
4645
|
if (result !== PROVEN && child?._zod) {
|
|
4646
|
-
const answer = isRecursive(child, stack,
|
|
4646
|
+
const answer = isRecursive(child, stack, resolve14);
|
|
4647
4647
|
if (answer > result)
|
|
4648
4648
|
result = answer;
|
|
4649
4649
|
}
|
|
@@ -4654,7 +4654,7 @@ function isRecursive(inst, stack, resolve13) {
|
|
|
4654
4654
|
const desc = Object.getOwnPropertyDescriptor(sh, key);
|
|
4655
4655
|
if (spread && !desc.enumerable)
|
|
4656
4656
|
continue;
|
|
4657
|
-
const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack,
|
|
4657
|
+
const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack, resolve14) : NONE;
|
|
4658
4658
|
if (child > answer)
|
|
4659
4659
|
answer = child;
|
|
4660
4660
|
}
|
|
@@ -4718,7 +4718,7 @@ function isRecursive(inst, stack, resolve13) {
|
|
|
4718
4718
|
break;
|
|
4719
4719
|
// `$ZodLazy` caches its inner on the def, so a resolved edge is followed exactly
|
|
4720
4720
|
case "lazy": {
|
|
4721
|
-
const inner = def._cachedInner ?? (
|
|
4721
|
+
const inner = def._cachedInner ?? (resolve14 ? inst._zod.innerType : void 0);
|
|
4722
4722
|
merge2(inner ? isRecursive(inner, stack, false) : ASSUMED);
|
|
4723
4723
|
break;
|
|
4724
4724
|
}
|
|
@@ -23018,7 +23018,7 @@ You are a product UI designer and frontend interaction specialist. When identify
|
|
|
23018
23018
|
|
|
23019
23019
|
## Taste Skill (premium frontends)
|
|
23020
23020
|
|
|
23021
|
-
For any UI or design work, read and follow the \`uiux\` skill in \`.agents/skills/\` before writing UI. Its internal procedures retain the mandatory design
|
|
23021
|
+
For any UI or design work, read and follow the \`uiux\` skill in \`.agents/skills/\` before writing UI. Its internal procedures retain the mandatory design-system audit, reuse, skeleton-loading, and surface-rework gates; its bundled references cover visual redesigns and premium frontends. Sync bundled upstream material with \`scripts/sync-taste-skills.sh\`.
|
|
23022
23022
|
|
|
23023
23023
|
## How to approach the work
|
|
23024
23024
|
|
|
@@ -24817,10 +24817,26 @@ function pullRequestFromResult(result) {
|
|
|
24817
24817
|
return {
|
|
24818
24818
|
key: url3,
|
|
24819
24819
|
kind: "pull-request",
|
|
24820
|
-
title: text(result.title) ?? `Pull request ${reference}`,
|
|
24820
|
+
title: text(result.title) ?? text(result.titleSnapshot) ?? `Pull request ${reference}`,
|
|
24821
24821
|
pullRequest: { url: url3, reference }
|
|
24822
24822
|
};
|
|
24823
24823
|
}
|
|
24824
|
+
function linkedPullRequest(node2) {
|
|
24825
|
+
if (!/^(?:github|azure)_pr_link_(?:session|task)$/.test(bareToolName(node2)))
|
|
24826
|
+
return null;
|
|
24827
|
+
const result = parseRecord(resultText(node2));
|
|
24828
|
+
if (!result || !isRecord3(result.overlay))
|
|
24829
|
+
return null;
|
|
24830
|
+
const overlay = result.overlay;
|
|
24831
|
+
const artifact = pullRequestFromResult(overlay);
|
|
24832
|
+
if (!artifact)
|
|
24833
|
+
return null;
|
|
24834
|
+
const repository = text(overlay.repoFullName);
|
|
24835
|
+
if (repository && artifact.pullRequest) {
|
|
24836
|
+
artifact.pullRequest.reference = `${repository}${artifact.pullRequest.reference}`;
|
|
24837
|
+
}
|
|
24838
|
+
return artifact;
|
|
24839
|
+
}
|
|
24824
24840
|
function alanArtifact(result, kind) {
|
|
24825
24841
|
const id = text(result.id);
|
|
24826
24842
|
const title = text(result.title);
|
|
@@ -24846,17 +24862,19 @@ function alanArtifact(result, kind) {
|
|
|
24846
24862
|
}
|
|
24847
24863
|
function shellPullRequest(node2) {
|
|
24848
24864
|
const input2 = node2.event.update.rawInput;
|
|
24849
|
-
const command = isRecord3(input2)
|
|
24865
|
+
const command = isRecord3(input2) ? text(input2.command) ?? text(input2.cmd) ?? "" : "";
|
|
24850
24866
|
if (!/\bgh\s+pr\s+create\b/.test(command))
|
|
24851
24867
|
return null;
|
|
24852
24868
|
const match = GITHUB_PULL_REQUEST.exec(resultText(node2));
|
|
24853
24869
|
if (!match)
|
|
24854
24870
|
return null;
|
|
24855
24871
|
const [url3, repository, number4] = match;
|
|
24872
|
+
const titleMatch = /(?:^|\s)--title(?:=|\s+)(?:"([^"]+)"|'([^']+)'|([^\s]+))/.exec(command);
|
|
24873
|
+
const title = titleMatch?.[1] ?? titleMatch?.[2] ?? titleMatch?.[3];
|
|
24856
24874
|
return {
|
|
24857
24875
|
key: url3,
|
|
24858
24876
|
kind: "pull-request",
|
|
24859
|
-
title: `Pull request #${number4}`,
|
|
24877
|
+
title: title ?? `Pull request #${number4}`,
|
|
24860
24878
|
pullRequest: { url: url3, reference: `${repository}#${number4}` }
|
|
24861
24879
|
};
|
|
24862
24880
|
}
|
|
@@ -24871,6 +24889,7 @@ function turnArtifact(node2) {
|
|
|
24871
24889
|
}
|
|
24872
24890
|
function collectTurnArtifacts(nodes) {
|
|
24873
24891
|
const artifacts = /* @__PURE__ */ new Map();
|
|
24892
|
+
const linked = /* @__PURE__ */ new Map();
|
|
24874
24893
|
const seen = /* @__PURE__ */ new Set();
|
|
24875
24894
|
function visit2(node2) {
|
|
24876
24895
|
if (seen.has(node2.key))
|
|
@@ -24881,10 +24900,23 @@ function collectTurnArtifacts(nodes) {
|
|
|
24881
24900
|
const artifact = turnArtifact(node2);
|
|
24882
24901
|
if (artifact)
|
|
24883
24902
|
artifacts.set(artifact.key, artifact);
|
|
24903
|
+
const linkedArtifact = linkedPullRequest(node2);
|
|
24904
|
+
if (linkedArtifact)
|
|
24905
|
+
linked.set(linkedArtifact.key, linkedArtifact);
|
|
24884
24906
|
}
|
|
24885
24907
|
node2.children.forEach(visit2);
|
|
24886
24908
|
}
|
|
24887
24909
|
nodes.forEach(visit2);
|
|
24910
|
+
for (const [key, linkedArtifact] of linked) {
|
|
24911
|
+
const created = artifacts.get(key);
|
|
24912
|
+
if (created?.pullRequest && linkedArtifact.pullRequest) {
|
|
24913
|
+
artifacts.set(key, {
|
|
24914
|
+
...created,
|
|
24915
|
+
title: linkedArtifact.title,
|
|
24916
|
+
pullRequest: linkedArtifact.pullRequest
|
|
24917
|
+
});
|
|
24918
|
+
}
|
|
24919
|
+
}
|
|
24888
24920
|
return [...artifacts.values()];
|
|
24889
24921
|
}
|
|
24890
24922
|
var CREATED_KINDS, GITHUB_PULL_REQUEST;
|
|
@@ -26649,7 +26681,7 @@ var init_chunk_AF3IPGDT = __esm({
|
|
|
26649
26681
|
}
|
|
26650
26682
|
});
|
|
26651
26683
|
|
|
26652
|
-
// ../agent-core/dist/chunk-
|
|
26684
|
+
// ../agent-core/dist/chunk-WYNUYKKN.js
|
|
26653
26685
|
function readCapReset(text3) {
|
|
26654
26686
|
const epoch = EPOCH_RESET.exec(text3);
|
|
26655
26687
|
if (epoch) return { resetsAt: new Date(Number(epoch[1]) * 1e3).toISOString() };
|
|
@@ -26690,7 +26722,8 @@ function prefixStatus(text3) {
|
|
|
26690
26722
|
return match ? Number(match[1]) : void 0;
|
|
26691
26723
|
}
|
|
26692
26724
|
function errorType(outer, inner) {
|
|
26693
|
-
const
|
|
26725
|
+
const flatCode = asString(outer.error);
|
|
26726
|
+
const type = asString(inner.type) || asString(outer.type) || (ERROR_CODE_SHAPE.test(flatCode) ? flatCode : "");
|
|
26694
26727
|
return type && type !== "error" ? type : void 0;
|
|
26695
26728
|
}
|
|
26696
26729
|
function readProviderErrorDetail(text3) {
|
|
@@ -26775,7 +26808,8 @@ function statusKind(status) {
|
|
|
26775
26808
|
}
|
|
26776
26809
|
function mapProviderApiError(errorCode3, apiStatus) {
|
|
26777
26810
|
if (apiStatus === 403) return "access_denied";
|
|
26778
|
-
if (apiStatus === 402)
|
|
26811
|
+
if (apiStatus === 402)
|
|
26812
|
+
return GATEWAY_402_KINDS.get(errorCode3?.trim().toLowerCase() ?? "") ?? "payment_required";
|
|
26779
26813
|
if (apiStatus === 401) return "auth_invalid";
|
|
26780
26814
|
const code = errorCode3?.trim().toLowerCase();
|
|
26781
26815
|
const byCode = code ? CODE_RULES.find((rule) => rule.pattern.test(code))?.kind : void 0;
|
|
@@ -26789,8 +26823,8 @@ function classifyProviderApiError(input2) {
|
|
|
26789
26823
|
if (fromText && TEXT_REFINES[structured]?.has(fromText.errorKind)) return fromText;
|
|
26790
26824
|
return specForErrorKind(structured);
|
|
26791
26825
|
}
|
|
26792
|
-
function withPaymentRemedy(classified, message2) {
|
|
26793
|
-
if (classified.errorKind !== "payment_required") return classified;
|
|
26826
|
+
function withPaymentRemedy(classified, message2, status) {
|
|
26827
|
+
if (classified.errorKind !== "payment_required" && status !== 402) return classified;
|
|
26794
26828
|
const remedy = message2.replace(STATUS_LEAD, "").trim();
|
|
26795
26829
|
return remedy ? { ...classified, message: remedy.slice(0, 300) } : classified;
|
|
26796
26830
|
}
|
|
@@ -26803,7 +26837,7 @@ function classifyProviderError(text3, hints = {}) {
|
|
|
26803
26837
|
...status === void 0 ? {} : { status },
|
|
26804
26838
|
text: detail.message
|
|
26805
26839
|
}) ?? classifyProviderTerminalText(text3);
|
|
26806
|
-
if (classified) return withPaymentRemedy(classified, detail.message);
|
|
26840
|
+
if (classified) return withPaymentRemedy(classified, detail.message, status);
|
|
26807
26841
|
const message2 = detail.message.slice(0, 200);
|
|
26808
26842
|
return message2 ? { message: message2, errorKind: "unknown_cli_error", recoveryClass: "unknown" } : specForErrorKind("unknown_cli_error");
|
|
26809
26843
|
}
|
|
@@ -26855,9 +26889,9 @@ function createCliProblem(observed, options) {
|
|
|
26855
26889
|
...classified.resetsAt ? { resetsAt: classified.resetsAt } : {}
|
|
26856
26890
|
});
|
|
26857
26891
|
}
|
|
26858
|
-
var import_crypto, EPOCH_RESET, WORDED_RESET, CODEX_RESET, ERROR_SPECS, AGENT_ERROR_KINDS, AGENT_SIGN_IN_BY_HARNESS, STATUS_PREFIX, TEXT_RULES, CODEX_TIMEOUT_MESSAGE, CODEX_EXPIRED_MESSAGE, COMMAND_NOT_FOUND, CODE_RULES, TEXT_REFINES, STATUS_LEAD, CLI_PROBLEM_CODE_BY_ERROR_KIND, KEY_REJECTION_KINDS;
|
|
26859
|
-
var
|
|
26860
|
-
"../agent-core/dist/chunk-
|
|
26892
|
+
var import_crypto, EPOCH_RESET, WORDED_RESET, CODEX_RESET, ERROR_SPECS, AGENT_ERROR_KINDS, AGENT_SIGN_IN_BY_HARNESS, STATUS_PREFIX, ERROR_CODE_SHAPE, TEXT_RULES, CODEX_TIMEOUT_MESSAGE, CODEX_EXPIRED_MESSAGE, COMMAND_NOT_FOUND, CODE_RULES, GATEWAY_402_KINDS, TEXT_REFINES, STATUS_LEAD, CLI_PROBLEM_CODE_BY_ERROR_KIND, KEY_REJECTION_KINDS;
|
|
26893
|
+
var init_chunk_WYNUYKKN = __esm({
|
|
26894
|
+
"../agent-core/dist/chunk-WYNUYKKN.js"() {
|
|
26861
26895
|
"use strict";
|
|
26862
26896
|
init_chunk_YXWJW7I5();
|
|
26863
26897
|
import_crypto = require("crypto");
|
|
@@ -26898,6 +26932,10 @@ var init_chunk_ZCTKXKYY = __esm({
|
|
|
26898
26932
|
message: "The account behind this model has no active plan or credits. Ask an admin to check billing, or switch to a model from your own provider, then retry.",
|
|
26899
26933
|
recoveryClass: "user_fixable"
|
|
26900
26934
|
},
|
|
26935
|
+
managed_models_paused: {
|
|
26936
|
+
message: "Alan-managed models are paused by Alan. Switch to a model from your own provider to keep working.",
|
|
26937
|
+
recoveryClass: "user_fixable"
|
|
26938
|
+
},
|
|
26901
26939
|
quota_exceeded: {
|
|
26902
26940
|
message: "API quota exceeded. Wait for it to reset or check your billing, then retry.",
|
|
26903
26941
|
recoveryClass: "user_fixable"
|
|
@@ -26984,6 +27022,7 @@ var init_chunk_ZCTKXKYY = __esm({
|
|
|
26984
27022
|
["command_code_cli", { name: "Command Code" }]
|
|
26985
27023
|
]);
|
|
26986
27024
|
STATUS_PREFIX = /\b(?:api error|status|http)[:\s]+(\d{3})\b/i;
|
|
27025
|
+
ERROR_CODE_SHAPE = /^[a-z][a-z0-9_]*$/;
|
|
26987
27026
|
TEXT_RULES = [
|
|
26988
27027
|
{ kind: "auth_expired", pattern: /\bcodex cli connection expired\b|\breconnect openai codex\b/ },
|
|
26989
27028
|
{ kind: "provider_timeout", pattern: /\bcodex connection to openai timed out\b/ },
|
|
@@ -27011,6 +27050,7 @@ var init_chunk_ZCTKXKYY = __esm({
|
|
|
27011
27050
|
kind: "quota_exceeded",
|
|
27012
27051
|
pattern: /\bcredit balance is too low\b|\binsufficient_quota\b/
|
|
27013
27052
|
},
|
|
27053
|
+
{ kind: "managed_models_paused", pattern: /\balan-managed models are paused\b/ },
|
|
27014
27054
|
{ kind: "subscription_required", pattern: /creditserror|\bno payment method\b/ },
|
|
27015
27055
|
{ kind: "model_mismatch", pattern: /datapolicyerror|\brequires explicit opt in\b/ },
|
|
27016
27056
|
// A cancelled turn can leave history the provider refuses on every later request: empty
|
|
@@ -27081,11 +27121,16 @@ var init_chunk_ZCTKXKYY = __esm({
|
|
|
27081
27121
|
kind: "context_length"
|
|
27082
27122
|
}
|
|
27083
27123
|
];
|
|
27124
|
+
GATEWAY_402_KINDS = /* @__PURE__ */ new Map([
|
|
27125
|
+
["quota_exceeded", "quota_exceeded"],
|
|
27126
|
+
["managed_models_paused", "managed_models_paused"]
|
|
27127
|
+
]);
|
|
27084
27128
|
TEXT_REFINES = {
|
|
27085
27129
|
rate_limited: /* @__PURE__ */ new Set(["usage_limit", "quota_exceeded"]),
|
|
27130
|
+
payment_required: /* @__PURE__ */ new Set(["usage_limit", "managed_models_paused"]),
|
|
27086
27131
|
auth_invalid: /* @__PURE__ */ new Set(["auth_expired", "not_logged_in", "not_authenticated"])
|
|
27087
27132
|
};
|
|
27088
|
-
STATUS_LEAD = /^(?:api error|status|http)[:\s]+\d{3}\b[:\s]*/i;
|
|
27133
|
+
STATUS_LEAD = /^(?:(?:api error|status|http)[:\s]+\d{3}\b|payment required:)[:\s]*/i;
|
|
27089
27134
|
CLI_PROBLEM_CODE_BY_ERROR_KIND = {
|
|
27090
27135
|
model_mismatch: "cli.model.unavailable",
|
|
27091
27136
|
auth_invalid: "cli.auth.invalid",
|
|
@@ -27095,6 +27140,7 @@ var init_chunk_ZCTKXKYY = __esm({
|
|
|
27095
27140
|
auth_expired: "cli.auth.expired",
|
|
27096
27141
|
subscription_required: "cli.entitlement.required",
|
|
27097
27142
|
payment_required: "cli.entitlement.required",
|
|
27143
|
+
managed_models_paused: "cli.model.unavailable",
|
|
27098
27144
|
quota_exceeded: "cli.quota_exceeded",
|
|
27099
27145
|
usage_limit: "cli.quota_exceeded",
|
|
27100
27146
|
context_length: "cli.context_exhausted",
|
|
@@ -27343,7 +27389,7 @@ function plan(command, args, options) {
|
|
|
27343
27389
|
function captureOutput(command, args, options) {
|
|
27344
27390
|
const launch = plan(command, args, options);
|
|
27345
27391
|
if (launch === void 0) return Promise.resolve(NEVER_STARTED);
|
|
27346
|
-
return new Promise((
|
|
27392
|
+
return new Promise((resolve14) => {
|
|
27347
27393
|
(0, import_child_process.execFile)(
|
|
27348
27394
|
launch.file,
|
|
27349
27395
|
[...launch.args],
|
|
@@ -27357,7 +27403,7 @@ function captureOutput(command, args, options) {
|
|
|
27357
27403
|
},
|
|
27358
27404
|
(error62, stdout, stderr) => {
|
|
27359
27405
|
const code = error62 && typeof error62.code === "number" ? error62.code : error62 ? void 0 : 0;
|
|
27360
|
-
|
|
27406
|
+
resolve14({ stdout, stderr, exitCode: code });
|
|
27361
27407
|
}
|
|
27362
27408
|
);
|
|
27363
27409
|
});
|
|
@@ -27407,10 +27453,10 @@ async function linuxStartTicks(pid) {
|
|
|
27407
27453
|
}
|
|
27408
27454
|
}
|
|
27409
27455
|
function psStartTime(pid) {
|
|
27410
|
-
return new Promise((
|
|
27456
|
+
return new Promise((resolve14) => {
|
|
27411
27457
|
(0, import_child_process2.execFile)("ps", ["-o", "lstart=", "-p", String(pid)], { timeout: 2e3 }, (error62, stdout) => {
|
|
27412
27458
|
const text3 = stdout.trim();
|
|
27413
|
-
|
|
27459
|
+
resolve14(error62 || !text3 ? void 0 : text3);
|
|
27414
27460
|
});
|
|
27415
27461
|
});
|
|
27416
27462
|
}
|
|
@@ -27439,12 +27485,12 @@ function parseProcessList(text3) {
|
|
|
27439
27485
|
}
|
|
27440
27486
|
function listProcesses2(platform3 = process.platform) {
|
|
27441
27487
|
if (platform3 === "win32") return Promise.resolve([]);
|
|
27442
|
-
return new Promise((
|
|
27488
|
+
return new Promise((resolve14) => {
|
|
27443
27489
|
(0, import_child_process3.execFile)(
|
|
27444
27490
|
"ps",
|
|
27445
27491
|
["-A", "-o", "pid=,ppid=,pgid=,lstart="],
|
|
27446
27492
|
{ timeout: 5e3, maxBuffer: 8 * 1024 * 1024 },
|
|
27447
|
-
(error62, stdout) =>
|
|
27493
|
+
(error62, stdout) => resolve14(error62 ? [] : parseProcessList(stdout))
|
|
27448
27494
|
);
|
|
27449
27495
|
});
|
|
27450
27496
|
}
|
|
@@ -27484,11 +27530,11 @@ async function taskkill(pid, options) {
|
|
|
27484
27530
|
stdio: "ignore",
|
|
27485
27531
|
windowsHide: true
|
|
27486
27532
|
});
|
|
27487
|
-
const exited = new Promise((
|
|
27488
|
-
killer.once("error", (error210) =>
|
|
27533
|
+
const exited = new Promise((resolve14) => {
|
|
27534
|
+
killer.once("error", (error210) => resolve14(error210));
|
|
27489
27535
|
killer.once(
|
|
27490
27536
|
"exit",
|
|
27491
|
-
(code, signal) =>
|
|
27537
|
+
(code, signal) => resolve14(code === 0 ? void 0 : new Error(`taskkill failed: exit ${code}, signal ${signal}`))
|
|
27492
27538
|
);
|
|
27493
27539
|
});
|
|
27494
27540
|
const timedOut = clock.sleep(options.timeoutMs ?? DEFAULT_TASKKILL_TIMEOUT_MS, timeout.signal).then(() => new Error("taskkill timed out")).catch(() => void 0);
|
|
@@ -27751,10 +27797,10 @@ function spawnCli(options) {
|
|
|
27751
27797
|
function waitForSpawn(child, command) {
|
|
27752
27798
|
if (isWindowsJob(child)) return waitForWindowsJob(child, command);
|
|
27753
27799
|
if (child.pid !== void 0) return Promise.resolve();
|
|
27754
|
-
return new Promise((
|
|
27800
|
+
return new Promise((resolve14, reject) => {
|
|
27755
27801
|
const onSpawn = () => {
|
|
27756
27802
|
child.off("error", onError);
|
|
27757
|
-
|
|
27803
|
+
resolve14();
|
|
27758
27804
|
};
|
|
27759
27805
|
const onError = (error62) => {
|
|
27760
27806
|
child.off("spawn", onSpawn);
|
|
@@ -27944,7 +27990,7 @@ var init_chunk_KVTSAS2T = __esm({
|
|
|
27944
27990
|
}
|
|
27945
27991
|
});
|
|
27946
27992
|
|
|
27947
|
-
// ../agent-core/dist/chunk-
|
|
27993
|
+
// ../agent-core/dist/chunk-U4RQE7JS.js
|
|
27948
27994
|
function detectImageMimeType(buffer) {
|
|
27949
27995
|
if (buffer.length >= 8 && buffer.subarray(0, 8).equals(PNG_SIGNATURE)) return "image/png";
|
|
27950
27996
|
if (buffer.length >= 3 && buffer[0] === 255 && buffer[1] === 216 && buffer[2] === 255) {
|
|
@@ -28164,8 +28210,8 @@ function createJsonRpcPeer(writer, handlers) {
|
|
|
28164
28210
|
},
|
|
28165
28211
|
request: (method, params = {}) => {
|
|
28166
28212
|
const id = counter.next++;
|
|
28167
|
-
return new Promise((
|
|
28168
|
-
pending.set(id, { method, resolve:
|
|
28213
|
+
return new Promise((resolve14, reject) => {
|
|
28214
|
+
pending.set(id, { method, resolve: resolve14, reject });
|
|
28169
28215
|
writer.write({ id, method, params }).catch((error62) => {
|
|
28170
28216
|
pending.delete(id);
|
|
28171
28217
|
reject(error62 instanceof Error ? error62 : new Error(String(error62)));
|
|
@@ -28278,7 +28324,7 @@ function createNdjsonWriter(stream) {
|
|
|
28278
28324
|
get writable() {
|
|
28279
28325
|
return stream.writable && !stream.destroyed && failure7.error === void 0;
|
|
28280
28326
|
},
|
|
28281
|
-
write: (value2) => new Promise((
|
|
28327
|
+
write: (value2) => new Promise((resolve14, reject) => {
|
|
28282
28328
|
if (failure7.error) {
|
|
28283
28329
|
reject(failure7.error);
|
|
28284
28330
|
return;
|
|
@@ -28290,7 +28336,7 @@ function createNdjsonWriter(stream) {
|
|
|
28290
28336
|
stream.write(`${JSON.stringify(value2)}
|
|
28291
28337
|
`, (error62) => {
|
|
28292
28338
|
if (error62) reject(error62);
|
|
28293
|
-
else
|
|
28339
|
+
else resolve14();
|
|
28294
28340
|
});
|
|
28295
28341
|
}),
|
|
28296
28342
|
end: () => {
|
|
@@ -28322,11 +28368,11 @@ function hostProcess(child, tree, options, handlers) {
|
|
|
28322
28368
|
});
|
|
28323
28369
|
child.stderr.on("data", (chunk) => stderr.push(chunk));
|
|
28324
28370
|
child.stderr.once("end", () => stderr.flush());
|
|
28325
|
-
const processExit = new Promise((
|
|
28326
|
-
child.once("exit", (code, signal) =>
|
|
28371
|
+
const processExit = new Promise((resolve14) => {
|
|
28372
|
+
child.once("exit", (code, signal) => resolve14({ code, signal }));
|
|
28327
28373
|
});
|
|
28328
|
-
const outputEnded = new Promise((
|
|
28329
|
-
child.stdout.once("close", () =>
|
|
28374
|
+
const outputEnded = new Promise((resolve14) => {
|
|
28375
|
+
child.stdout.once("close", () => resolve14());
|
|
28330
28376
|
});
|
|
28331
28377
|
const watch = async () => {
|
|
28332
28378
|
const { clock, stdoutDrainMs, log, name } = options;
|
|
@@ -28385,11 +28431,11 @@ function silentStartError(name, timeoutMs) {
|
|
|
28385
28431
|
};
|
|
28386
28432
|
}
|
|
28387
28433
|
var import_crypto4, import_fs5, import_path4, PNG_SIGNATURE, IMAGE_MIME_BY_EXT, VIDEO_MIME_BY_EXT, IMAGE_EXTENSIONS, VIDEO_EXTENSIONS, MAX_IMAGE_BYTES, MAX_VIDEO_BYTES, MAX_TURN_MEDIA_DATA_CHARS, MTIME_SLACK_MS, AGENT_BROWSER_MENTION, AGENT_BROWSER_CAPTURE_COMMAND, LocalMediaReader, SessionOpenRefusal, JsonRpcError, ACP_PROTOCOL_VERSION, ACP_ERROR, STDERR_TAIL_LINES, RESULT_EXIT_GRACE_MS, PerTurnSession;
|
|
28388
|
-
var
|
|
28389
|
-
"../agent-core/dist/chunk-
|
|
28434
|
+
var init_chunk_U4RQE7JS = __esm({
|
|
28435
|
+
"../agent-core/dist/chunk-U4RQE7JS.js"() {
|
|
28390
28436
|
"use strict";
|
|
28391
28437
|
init_chunk_AF3IPGDT();
|
|
28392
|
-
|
|
28438
|
+
init_chunk_WYNUYKKN();
|
|
28393
28439
|
init_chunk_KVTSAS2T();
|
|
28394
28440
|
init_chunk_YXWJW7I5();
|
|
28395
28441
|
import_crypto4 = require("crypto");
|
|
@@ -28654,13 +28700,13 @@ var init_chunk_4LDW3FJB = __esm({
|
|
|
28654
28700
|
const turnId = input2.turnId;
|
|
28655
28701
|
let finish = () => {
|
|
28656
28702
|
};
|
|
28657
|
-
const done = new Promise((
|
|
28703
|
+
const done = new Promise((resolve14) => {
|
|
28658
28704
|
finish = (outcome2) => {
|
|
28659
28705
|
if (this.#current?.id !== turnId) return;
|
|
28660
28706
|
this.#current = void 0;
|
|
28661
28707
|
if (this.#state === "busy") this.#state = "idle";
|
|
28662
28708
|
this.#emit({ type: "turn_ended", turnId, outcome: outcome2 });
|
|
28663
|
-
|
|
28709
|
+
resolve14({ turnId, outcome: outcome2, providerSessionId: this.#sessionId });
|
|
28664
28710
|
};
|
|
28665
28711
|
});
|
|
28666
28712
|
const pending = {
|
|
@@ -28771,15 +28817,15 @@ var init_chunk_4LDW3FJB = __esm({
|
|
|
28771
28817
|
var init_dist = __esm({
|
|
28772
28818
|
"../agent-core/dist/index.js"() {
|
|
28773
28819
|
"use strict";
|
|
28774
|
-
|
|
28820
|
+
init_chunk_U4RQE7JS();
|
|
28775
28821
|
init_chunk_AF3IPGDT();
|
|
28776
|
-
|
|
28822
|
+
init_chunk_WYNUYKKN();
|
|
28777
28823
|
init_chunk_KVTSAS2T();
|
|
28778
28824
|
init_chunk_YXWJW7I5();
|
|
28779
28825
|
}
|
|
28780
28826
|
});
|
|
28781
28827
|
|
|
28782
|
-
// ../agent-core/dist/chunk-
|
|
28828
|
+
// ../agent-core/dist/chunk-7FJ7QKFN.js
|
|
28783
28829
|
function repositories(input2, context) {
|
|
28784
28830
|
const problems = new Map(input2.problems.map((problem) => [problem.path, problem]));
|
|
28785
28831
|
const listed = context?.repositories ?? [];
|
|
@@ -29386,24 +29432,51 @@ function cloudExecutionSection(spec) {
|
|
|
29386
29432
|
"If a required delivery step is blocked, complete remaining independent work and report the precise blocker and what remains unfinished. Never describe local-only work as fully delivered."
|
|
29387
29433
|
);
|
|
29388
29434
|
}
|
|
29389
|
-
const skills = spec.promptContext?.availableSkills ?? [];
|
|
29390
29435
|
lines2.push(
|
|
29391
29436
|
"## Installed skills",
|
|
29392
29437
|
"Use a matching installed skill when it helps the request. Read its SKILL.md before acting; the index is discovery metadata, not instructions. Follow repository instructions and project skills within the cloud workflow boundaries above."
|
|
29393
29438
|
);
|
|
29394
|
-
|
|
29439
|
+
const skills = spec.promptContext?.availableSkills;
|
|
29440
|
+
if (skills === void 0) {
|
|
29441
|
+
lines2.push(
|
|
29442
|
+
"No installed skill inventory was supplied. Inspect the provider's skill index; do not assume a named package is installed."
|
|
29443
|
+
);
|
|
29444
|
+
} else if (skills.length === 0) {
|
|
29395
29445
|
lines2.push(
|
|
29396
|
-
|
|
29446
|
+
"No other installed skills were found. Do not assume a named skill is available unless your skill index lists it."
|
|
29397
29447
|
);
|
|
29398
29448
|
} else {
|
|
29399
|
-
|
|
29400
|
-
lines2.push(
|
|
29401
|
-
`- ${JSON.stringify(skill.name)}: ${JSON.stringify(skill.description)} \u2014 ${JSON.stringify(`${skill.packageDirectory}/SKILL.md`)}`
|
|
29402
|
-
);
|
|
29403
|
-
}
|
|
29449
|
+
lines2.push(...installedSkillLines(skills));
|
|
29404
29450
|
}
|
|
29405
29451
|
return lines2.join("\n");
|
|
29406
29452
|
}
|
|
29453
|
+
function truncate2(text3, max) {
|
|
29454
|
+
return text3.length > max ? `${text3.slice(0, max - 1)}\u2026` : text3;
|
|
29455
|
+
}
|
|
29456
|
+
function byListingPriority(left, right) {
|
|
29457
|
+
const platform3 = Number(right.name.startsWith("alan-")) - Number(left.name.startsWith("alan-"));
|
|
29458
|
+
return platform3 !== 0 ? platform3 : left.name.localeCompare(right.name);
|
|
29459
|
+
}
|
|
29460
|
+
function overflowLine(omitted) {
|
|
29461
|
+
const folders = [...new Set(omitted.map((skill) => (0, import_path5.dirname)(skill.packageDirectory)))].sort();
|
|
29462
|
+
return `${omitted.length} more installed skills are not listed. Each is a folder holding a SKILL.md under ${folders.map((folder) => JSON.stringify(folder)).join(" or ")}; look there before assuming a named skill is unavailable.`;
|
|
29463
|
+
}
|
|
29464
|
+
function installedSkillLines(skills) {
|
|
29465
|
+
const ordered = [...skills].sort(byListingPriority);
|
|
29466
|
+
const lines2 = [];
|
|
29467
|
+
let used = 0;
|
|
29468
|
+
for (const [index, skill] of ordered.entries()) {
|
|
29469
|
+
const description = truncate2(skill.description, INSTALLED_SKILL_DESCRIPTION_MAX_CHARS);
|
|
29470
|
+
const line = `- ${JSON.stringify(skill.name)}: ${JSON.stringify(description)} \u2014 ${JSON.stringify(`${skill.packageDirectory}/SKILL.md`)}`;
|
|
29471
|
+
if (used + line.length + 1 > INSTALLED_SKILLS_MAX_CHARS) {
|
|
29472
|
+
lines2.push(overflowLine(ordered.slice(index)));
|
|
29473
|
+
break;
|
|
29474
|
+
}
|
|
29475
|
+
lines2.push(line);
|
|
29476
|
+
used += line.length + 1;
|
|
29477
|
+
}
|
|
29478
|
+
return lines2;
|
|
29479
|
+
}
|
|
29407
29480
|
function promptParts(input2) {
|
|
29408
29481
|
const { spec } = input2;
|
|
29409
29482
|
const overlay = teamOverlay(spec);
|
|
@@ -29481,12 +29554,13 @@ function buildTurnText(input2) {
|
|
|
29481
29554
|
${body}` : body;
|
|
29482
29555
|
return spec.mode === "plan" ? planModePrefix(prefixed) : prefixed;
|
|
29483
29556
|
}
|
|
29484
|
-
var startCommandStateSchema, repositorySnapshotSchema, environmentSnapshotSchema, agentContextSnapshotSchema, BRANCH_REASONS, SLACK_SURFACE_INSTRUCTIONS, PLAIN_SCALAR, COMMAND_PREVIEW_CHARS, MAX_PARSED_ATTACHMENTS, MAX_PARSED_ATTACHMENT_CHARS, MAX_METADATA_CHARS, UNAVAILABLE, READ_ONLY_MODES, AGENT_MODES;
|
|
29485
|
-
var
|
|
29486
|
-
"../agent-core/dist/chunk-
|
|
29557
|
+
var import_path5, startCommandStateSchema, repositorySnapshotSchema, environmentSnapshotSchema, agentContextSnapshotSchema, BRANCH_REASONS, SLACK_SURFACE_INSTRUCTIONS, PLAIN_SCALAR, COMMAND_PREVIEW_CHARS, MAX_PARSED_ATTACHMENTS, MAX_PARSED_ATTACHMENT_CHARS, MAX_METADATA_CHARS, UNAVAILABLE, READ_ONLY_MODES, AGENT_MODES, INSTALLED_SKILLS_MAX_CHARS, INSTALLED_SKILL_DESCRIPTION_MAX_CHARS;
|
|
29558
|
+
var init_chunk_7FJ7QKFN = __esm({
|
|
29559
|
+
"../agent-core/dist/chunk-7FJ7QKFN.js"() {
|
|
29487
29560
|
"use strict";
|
|
29488
29561
|
init_runtime_v2();
|
|
29489
29562
|
init_zod();
|
|
29563
|
+
import_path5 = require("path");
|
|
29490
29564
|
init_agent2();
|
|
29491
29565
|
startCommandStateSchema = external_exports.discriminatedUnion("state", [
|
|
29492
29566
|
external_exports.object({ state: external_exports.literal("not_configured") }),
|
|
@@ -29586,6 +29660,8 @@ var init_chunk_DLVRNIY5 = __esm({
|
|
|
29586
29660
|
"ask",
|
|
29587
29661
|
"review"
|
|
29588
29662
|
]);
|
|
29663
|
+
INSTALLED_SKILLS_MAX_CHARS = 8e3;
|
|
29664
|
+
INSTALLED_SKILL_DESCRIPTION_MAX_CHARS = 200;
|
|
29589
29665
|
}
|
|
29590
29666
|
});
|
|
29591
29667
|
|
|
@@ -29679,8 +29755,8 @@ function canonicalizeManagedMcpToolName(toolName2) {
|
|
|
29679
29755
|
return flattened ? `mcp__${MANAGED_MCP_SERVER_NAME}__${flattened[1]}` : toolName2;
|
|
29680
29756
|
}
|
|
29681
29757
|
async function writeSecretFile(name, contents) {
|
|
29682
|
-
const dir = await (0, import_promises21.mkdtemp)((0,
|
|
29683
|
-
const path4 = (0,
|
|
29758
|
+
const dir = await (0, import_promises21.mkdtemp)((0, import_path6.join)((0, import_os2.tmpdir)(), "alan-mcp-"));
|
|
29759
|
+
const path4 = (0, import_path6.join)(dir, name);
|
|
29684
29760
|
const remove = async () => {
|
|
29685
29761
|
await (0, import_promises21.rm)(dir, { recursive: true, force: true });
|
|
29686
29762
|
};
|
|
@@ -29692,7 +29768,7 @@ async function writeSecretFile(name, contents) {
|
|
|
29692
29768
|
}
|
|
29693
29769
|
return { path: path4, remove, [Symbol.asyncDispose]: remove };
|
|
29694
29770
|
}
|
|
29695
|
-
var import_crypto5, import_crypto6, import_promises21, import_os2,
|
|
29771
|
+
var import_crypto5, import_crypto6, import_promises21, import_os2, import_path6, OPENCODE_CODE_MODE_ENV, OPENCODE_CODE_MODE_TOOL, CODE_MODE_CALLS_META, MANAGED_MCP_SERVER_NAME, RUN_SCOPED_SERVER, NAMESPACED_RUN_TOOL, FLATTENED_RUN_TOOL;
|
|
29696
29772
|
var init_chunk_OSECDZA5 = __esm({
|
|
29697
29773
|
"../agent-core/dist/chunk-OSECDZA5.js"() {
|
|
29698
29774
|
"use strict";
|
|
@@ -29703,7 +29779,7 @@ var init_chunk_OSECDZA5 = __esm({
|
|
|
29703
29779
|
init_runtime_v2();
|
|
29704
29780
|
import_promises21 = require("fs/promises");
|
|
29705
29781
|
import_os2 = require("os");
|
|
29706
|
-
|
|
29782
|
+
import_path6 = require("path");
|
|
29707
29783
|
OPENCODE_CODE_MODE_ENV = "OPENCODE_EXPERIMENTAL_CODE_MODE";
|
|
29708
29784
|
OPENCODE_CODE_MODE_TOOL = "execute";
|
|
29709
29785
|
CODE_MODE_CALLS_META = "alanToolCalls";
|
|
@@ -29949,16 +30025,16 @@ function classifyAcpError(error62) {
|
|
|
29949
30025
|
return classifyAcpText(acpErrorText(error62));
|
|
29950
30026
|
}
|
|
29951
30027
|
function within(root, path4) {
|
|
29952
|
-
const rel = (0,
|
|
29953
|
-
return rel === "" || !rel.startsWith(`..${
|
|
30028
|
+
const rel = (0, import_path7.relative)(root, path4);
|
|
30029
|
+
return rel === "" || !rel.startsWith(`..${import_path7.sep}`) && rel !== ".." && !(0, import_path7.isAbsolute)(rel);
|
|
29954
30030
|
}
|
|
29955
30031
|
async function resolveReal(path4) {
|
|
29956
30032
|
try {
|
|
29957
30033
|
return await (0, import_promises22.realpath)(path4);
|
|
29958
30034
|
} catch {
|
|
29959
|
-
const parent = (0,
|
|
30035
|
+
const parent = (0, import_path7.dirname)(path4);
|
|
29960
30036
|
if (parent === path4) return path4;
|
|
29961
|
-
return (0,
|
|
30037
|
+
return (0, import_path7.join)(await resolveReal(parent), (0, import_path7.basename)(path4));
|
|
29962
30038
|
}
|
|
29963
30039
|
}
|
|
29964
30040
|
function sliceLines(text3, params) {
|
|
@@ -29973,7 +30049,7 @@ function createWorkspaceFs(roots, writable) {
|
|
|
29973
30049
|
const realRoots = Promise.all(roots.map((root) => resolveReal(root)));
|
|
29974
30050
|
const confined = async (params) => {
|
|
29975
30051
|
const path4 = asString(params.path);
|
|
29976
|
-
if (!(0,
|
|
30052
|
+
if (!(0, import_path7.isAbsolute)(path4)) throw new FsDenied(`fs path must be absolute: ${path4 || "(empty)"}`);
|
|
29977
30053
|
const real = await resolveReal(path4);
|
|
29978
30054
|
if (!(await realRoots).some((root) => within(root, real))) {
|
|
29979
30055
|
throw new FsDenied(`${path4} is outside the session's workspace`);
|
|
@@ -30602,19 +30678,19 @@ async function acpTurnInput(run2, context) {
|
|
|
30602
30678
|
...encoded.length ? { images: encoded, imagePaths: images.map((image) => image.path) } : {}
|
|
30603
30679
|
};
|
|
30604
30680
|
}
|
|
30605
|
-
var import_promises22,
|
|
30681
|
+
var import_promises22, import_path7, import_crypto7, import_promises23, CURSOR_ASK_QUESTION, copilotAcpProfile, cursorAcpProfile, MODEL_REJECTED, MAX_READ_BYTES, FsDenied, ENV_REFERENCE, AcpBackgroundTasks, CURSOR_CREATE_PLAN, STATUSES2, READ_KINDS, ALLOW_KINDS, REJECT_KINDS, CANCELLED_PERMISSION, STOP_REASONS, CHUNKS, ECHOES, AcpTurn, STDERR_TAIL_LINES2, MAX_BETWEEN_UPDATES, AcpSession, DEFAULTS, CLIENT_INFO, TASK_BACKGROUNDED, TASK_COMPLETED, SESSION_NOTIFICATION, KILLED_STATUSES, SUCCESS_STATUSES, SUBAGENT_ID, grokTaskDialect, grokAcpProfile, kimiAcpProfile, ACP_PROFILES, ACP_MODES;
|
|
30606
30682
|
var init_acp2 = __esm({
|
|
30607
30683
|
"../agent-core/dist/providers/acp.js"() {
|
|
30608
30684
|
"use strict";
|
|
30609
|
-
|
|
30685
|
+
init_chunk_U4RQE7JS();
|
|
30610
30686
|
init_chunk_AF3IPGDT();
|
|
30611
|
-
|
|
30687
|
+
init_chunk_WYNUYKKN();
|
|
30612
30688
|
init_chunk_KVTSAS2T();
|
|
30613
|
-
|
|
30689
|
+
init_chunk_7FJ7QKFN();
|
|
30614
30690
|
init_chunk_OSECDZA5();
|
|
30615
30691
|
init_chunk_YXWJW7I5();
|
|
30616
30692
|
import_promises22 = require("fs/promises");
|
|
30617
|
-
|
|
30693
|
+
import_path7 = require("path");
|
|
30618
30694
|
init_effort();
|
|
30619
30695
|
init_acp();
|
|
30620
30696
|
import_crypto7 = require("crypto");
|
|
@@ -30855,8 +30931,8 @@ var init_acp2 = __esm({
|
|
|
30855
30931
|
/** Resolves on the next `usage_update`, or after `ms`. */
|
|
30856
30932
|
async nextContext(ms, sleep) {
|
|
30857
30933
|
await Promise.race([
|
|
30858
|
-
new Promise((
|
|
30859
|
-
this.#onContext =
|
|
30934
|
+
new Promise((resolve14) => {
|
|
30935
|
+
this.#onContext = resolve14;
|
|
30860
30936
|
}),
|
|
30861
30937
|
sleep(ms)
|
|
30862
30938
|
]);
|
|
@@ -31183,7 +31259,7 @@ var init_acp2 = __esm({
|
|
|
31183
31259
|
const turn = new AcpTurn(`acp-${this.#turns}-${id}`, this.#profile);
|
|
31184
31260
|
let finish = () => {
|
|
31185
31261
|
};
|
|
31186
|
-
const done = new Promise((
|
|
31262
|
+
const done = new Promise((resolve14) => {
|
|
31187
31263
|
finish = (outcome2) => {
|
|
31188
31264
|
if (this.#current?.id !== id) return;
|
|
31189
31265
|
this.#current = void 0;
|
|
@@ -31191,7 +31267,7 @@ var init_acp2 = __esm({
|
|
|
31191
31267
|
if (this.#state === "busy") this.#state = "idle";
|
|
31192
31268
|
this.#host.scanDescendants(true);
|
|
31193
31269
|
this.#emit({ type: "turn_ended", turnId: id, outcome: outcome2 });
|
|
31194
|
-
|
|
31270
|
+
resolve14({ turnId: id, outcome: outcome2, providerSessionId: this.#sessionId });
|
|
31195
31271
|
};
|
|
31196
31272
|
});
|
|
31197
31273
|
const active = { id, turn, done, finish, cancelRequested: false };
|
|
@@ -31485,7 +31561,7 @@ var init_acp3 = __esm({
|
|
|
31485
31561
|
var init_classify = __esm({
|
|
31486
31562
|
"../agent-core/dist/classify.js"() {
|
|
31487
31563
|
"use strict";
|
|
31488
|
-
|
|
31564
|
+
init_chunk_WYNUYKKN();
|
|
31489
31565
|
init_chunk_YXWJW7I5();
|
|
31490
31566
|
}
|
|
31491
31567
|
});
|
|
@@ -32141,7 +32217,7 @@ function alanCodeConfigContent(existing, input2) {
|
|
|
32141
32217
|
});
|
|
32142
32218
|
}
|
|
32143
32219
|
function readBody2(response) {
|
|
32144
|
-
return new Promise((
|
|
32220
|
+
return new Promise((resolve14, reject) => {
|
|
32145
32221
|
const chunks = [];
|
|
32146
32222
|
let size = 0;
|
|
32147
32223
|
response.on("data", (chunk) => {
|
|
@@ -32149,7 +32225,7 @@ function readBody2(response) {
|
|
|
32149
32225
|
if (size > MAX_CATALOG_BYTES) response.destroy(new Error("catalog too large"));
|
|
32150
32226
|
else chunks.push(chunk);
|
|
32151
32227
|
});
|
|
32152
|
-
response.on("end", () =>
|
|
32228
|
+
response.on("end", () => resolve14(Buffer.concat(chunks).toString("utf8")));
|
|
32153
32229
|
response.on("error", reject);
|
|
32154
32230
|
});
|
|
32155
32231
|
}
|
|
@@ -32165,13 +32241,13 @@ function parseResponseBody(text3, status) {
|
|
|
32165
32241
|
}
|
|
32166
32242
|
function getJson(url3, headers, timeout, signal) {
|
|
32167
32243
|
const request2 = url3.protocol === "https:" ? import_https.request : import_http9.request;
|
|
32168
|
-
return new Promise((
|
|
32244
|
+
return new Promise((resolve14, reject) => {
|
|
32169
32245
|
const outgoing = request2(url3, { method: "GET", headers, timeout, signal }, (response) => {
|
|
32170
32246
|
const status = response.statusCode ?? 0;
|
|
32171
32247
|
readBody2(response).then((text3) => {
|
|
32172
32248
|
const body = parseResponseBody(text3, status);
|
|
32173
32249
|
if (status < 200 || status >= 300) reject(new CatalogResponseError(status, body));
|
|
32174
|
-
else
|
|
32250
|
+
else resolve14(body);
|
|
32175
32251
|
}).catch(reject);
|
|
32176
32252
|
});
|
|
32177
32253
|
outgoing.on("timeout", () => outgoing.destroy(new Error("catalog timed out")));
|
|
@@ -32210,7 +32286,7 @@ function alanCodeEngineBinary(platform3) {
|
|
|
32210
32286
|
return platform3 === "win32" ? "opencode.exe" : "opencode";
|
|
32211
32287
|
}
|
|
32212
32288
|
function packagedAlanCodeEnginePath(bundle, platform3) {
|
|
32213
|
-
return (0,
|
|
32289
|
+
return (0, import_path8.join)((0, import_path8.dirname)(bundle), "..", "engine", alanCodeEngineBinary(platform3));
|
|
32214
32290
|
}
|
|
32215
32291
|
function isRunnableFile(path4, platform3) {
|
|
32216
32292
|
try {
|
|
@@ -32412,13 +32488,13 @@ export const AlanEnginePlugin = async () => ({
|
|
|
32412
32488
|
`;
|
|
32413
32489
|
}
|
|
32414
32490
|
function alanCodeEngineRoot(home) {
|
|
32415
|
-
return (0,
|
|
32491
|
+
return (0, import_path9.join)(home, ".alan", "alan-code", "engine");
|
|
32416
32492
|
}
|
|
32417
32493
|
function alanCodeEngineDirectories(root) {
|
|
32418
32494
|
return {
|
|
32419
|
-
XDG_DATA_HOME: (0,
|
|
32420
|
-
XDG_STATE_HOME: (0,
|
|
32421
|
-
XDG_CACHE_HOME: (0,
|
|
32495
|
+
XDG_DATA_HOME: (0, import_path9.join)(root, "share"),
|
|
32496
|
+
XDG_STATE_HOME: (0, import_path9.join)(root, "state"),
|
|
32497
|
+
XDG_CACHE_HOME: (0, import_path9.join)(root, "cache")
|
|
32422
32498
|
};
|
|
32423
32499
|
}
|
|
32424
32500
|
function bearerToken(authorization) {
|
|
@@ -32434,8 +32510,8 @@ function alanCodeEngineEnv(input2) {
|
|
|
32434
32510
|
};
|
|
32435
32511
|
}
|
|
32436
32512
|
function openCodeGlobalConfigDirectory(env, home) {
|
|
32437
|
-
const configHome = env.XDG_CONFIG_HOME?.trim() || (0,
|
|
32438
|
-
return (0,
|
|
32513
|
+
const configHome = env.XDG_CONFIG_HOME?.trim() || (0, import_path9.join)(home, ".config");
|
|
32514
|
+
return (0, import_path9.join)(configHome, "opencode");
|
|
32439
32515
|
}
|
|
32440
32516
|
function stripJsonc(text3) {
|
|
32441
32517
|
let out = "";
|
|
@@ -32494,7 +32570,7 @@ function parseJsonc(text3) {
|
|
|
32494
32570
|
async function inheritedMcpServerNames(configDirectory) {
|
|
32495
32571
|
const names = /* @__PURE__ */ new Set();
|
|
32496
32572
|
for (const file2 of ["config.json", "opencode.json", "opencode.jsonc"]) {
|
|
32497
|
-
const text3 = await (0, import_promises24.readFile)((0,
|
|
32573
|
+
const text3 = await (0, import_promises24.readFile)((0, import_path9.join)(configDirectory, file2), "utf8").catch(() => null);
|
|
32498
32574
|
if (text3 === null) continue;
|
|
32499
32575
|
const parsed = parseJsonc(text3);
|
|
32500
32576
|
const mcp = parsed !== null && typeof parsed === "object" ? parsed.mcp : void 0;
|
|
@@ -32506,7 +32582,7 @@ async function inheritedMcpServerNames(configDirectory) {
|
|
|
32506
32582
|
}
|
|
32507
32583
|
async function writePlugin(directory, apiOrigin) {
|
|
32508
32584
|
const origin = (0, import_crypto8.createHash)("sha256").update(apiOrigin).digest("hex").slice(0, 12);
|
|
32509
|
-
const target = (0,
|
|
32585
|
+
const target = (0, import_path9.join)(directory, `engine-plugin-v${ALAN_CODE_ENGINE_PLUGIN_VERSION}-${origin}.mjs`);
|
|
32510
32586
|
const temporary = `${target}.${(0, import_crypto8.randomUUID)()}.tmp`;
|
|
32511
32587
|
await (0, import_promises24.mkdir)(directory, { recursive: true, mode: 448 });
|
|
32512
32588
|
await (0, import_promises24.writeFile)(temporary, alanCodeEnginePluginSource(apiOrigin), { mode: 384 });
|
|
@@ -32519,7 +32595,7 @@ async function prepareAlanCodeProfile(input2) {
|
|
|
32519
32595
|
directories.map((directory) => (0, import_promises24.mkdir)(directory, { recursive: true, mode: 448 }))
|
|
32520
32596
|
);
|
|
32521
32597
|
const [pluginUrl, models, inheritedMcpServers] = await Promise.all([
|
|
32522
|
-
writePlugin((0,
|
|
32598
|
+
writePlugin((0, import_path9.join)(input2.engineRoot, "plugin"), input2.access.apiOrigin),
|
|
32523
32599
|
(input2.loadModels ?? fetchAlanCodeModels)(input2.access),
|
|
32524
32600
|
input2.globalConfigDirectory === void 0 ? Promise.resolve([]) : inheritedMcpServerNames(input2.globalConfigDirectory)
|
|
32525
32601
|
]);
|
|
@@ -32541,7 +32617,7 @@ function alanCodeSystemPrompt(alanSystemPrompt) {
|
|
|
32541
32617
|
|
|
32542
32618
|
${instructions}` : ALAN_CODE_TOOL_NAMING_PROMPT;
|
|
32543
32619
|
}
|
|
32544
|
-
var import_http9, import_https, import_fs6,
|
|
32620
|
+
var import_http9, import_https, import_fs6, import_path8, import_crypto8, import_promises24, import_path9, import_url, ALAN_CODE_BASELINE_PROMPT, ALAN_CODE_ENGINE_PROVIDER_ID, DEFAULT_CONTEXT_WINDOW, DEFAULT_MAX_OUTPUT_TOKENS, ALAN_CODE_API_KEY_ENV, ALAN_CODE_CONVERSATION_ID_ENV, ALAN_CODE_PROXY_PATH, ALAN_CODE_WEBSEARCH_PATH, ALAN_CODE_CATALOG_PATH, ALAN_CODE_CHUNK_TIMEOUT_MS, CATALOG_TIMEOUT_MS, MAX_CATALOG_BYTES, ACTIVATION_WAIT_MS, ACTIVATION_POLL_MS, CatalogResponseError, ALAN_CODE_ENGINE_PATH_ENV, ALAN_CODE_ENGINE_COMMAND, ALAN_CODE_ENGINE_NAME, WINDOWS_RUNNABLE_EXTENSION, ALAN_CODE_ENGINE_PLUGIN_VERSION, ALAN_CODE_TOOL_NAMING_PROMPT;
|
|
32545
32621
|
var init_alan_code = __esm({
|
|
32546
32622
|
"../agent-core/dist/providers/alan-code.js"() {
|
|
32547
32623
|
"use strict";
|
|
@@ -32553,11 +32629,11 @@ var init_alan_code = __esm({
|
|
|
32553
32629
|
init_runtime_v2();
|
|
32554
32630
|
init_models();
|
|
32555
32631
|
import_fs6 = require("fs");
|
|
32556
|
-
|
|
32632
|
+
import_path8 = require("path");
|
|
32557
32633
|
init_runtime_v2();
|
|
32558
32634
|
import_crypto8 = require("crypto");
|
|
32559
32635
|
import_promises24 = require("fs/promises");
|
|
32560
|
-
|
|
32636
|
+
import_path9 = require("path");
|
|
32561
32637
|
import_url = require("url");
|
|
32562
32638
|
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";
|
|
32563
32639
|
ALAN_CODE_ENGINE_PROVIDER_ID = "alan";
|
|
@@ -32929,7 +33005,7 @@ function notice(kind, message2) {
|
|
|
32929
33005
|
function promptParts2(input2) {
|
|
32930
33006
|
const files = (input2.imagePaths ?? []).map((path4, index) => ({
|
|
32931
33007
|
type: "file",
|
|
32932
|
-
mime: input2.images?.[index]?.mimeType ?? IMAGE_TYPES[(0,
|
|
33008
|
+
mime: input2.images?.[index]?.mimeType ?? IMAGE_TYPES[(0, import_path11.extname)(path4).toLowerCase()] ?? "application/octet-stream",
|
|
32933
33009
|
filename: path4.split(/[\\/]/).at(-1) ?? path4,
|
|
32934
33010
|
url: (0, import_url2.pathToFileURL)(path4).href
|
|
32935
33011
|
}));
|
|
@@ -33052,7 +33128,7 @@ async function canonicalDirectory(directory) {
|
|
|
33052
33128
|
try {
|
|
33053
33129
|
return await (0, import_promises25.realpath)(directory);
|
|
33054
33130
|
} catch {
|
|
33055
|
-
return (0,
|
|
33131
|
+
return (0, import_path10.resolve)(directory);
|
|
33056
33132
|
}
|
|
33057
33133
|
}
|
|
33058
33134
|
async function openSession(session, client, spec, log) {
|
|
@@ -33152,9 +33228,9 @@ function createOpenCodeDriver(options = {}) {
|
|
|
33152
33228
|
const spec = { ...planned, env: launchEnv(planned, authorization) };
|
|
33153
33229
|
const password = options.password?.() ?? (0, import_crypto10.randomBytes)(24).toString("base64url");
|
|
33154
33230
|
try {
|
|
33155
|
-
const data = spec.env.XDG_DATA_HOME ?? (0,
|
|
33231
|
+
const data = spec.env.XDG_DATA_HOME ?? (0, import_path10.join)(spec.env.HOME ?? spec.env.USERPROFILE ?? spec.cwd, ".local", "share");
|
|
33156
33232
|
const session = await withStartupLock(
|
|
33157
|
-
(0,
|
|
33233
|
+
(0, import_path10.join)(data, "opencode", ".alan-startup.lock"),
|
|
33158
33234
|
resolved.clock,
|
|
33159
33235
|
() => openWithRetries(spec, password, resolved)
|
|
33160
33236
|
);
|
|
@@ -33252,15 +33328,15 @@ function openCodeTurnInput(run2, context) {
|
|
|
33252
33328
|
...context.attachments.length ? { readableFiles: context.attachments.map((attachment) => attachment.path) } : {}
|
|
33253
33329
|
};
|
|
33254
33330
|
}
|
|
33255
|
-
var import_crypto9, import_http10, import_crypto10, import_promises25,
|
|
33331
|
+
var import_crypto9, import_http10, import_crypto10, import_promises25, import_path10, import_path11, import_url2, import_path12, import_crypto11, IDLE_SOCKET_MS3, OpenCodeHttpError, BASE62, messageIdClock, OpenCodeClient, OPENCODE_CONFIG_ENV, OPENCODE_ENGINE, TEXT_PARTS, STEP_PARTS, STOPPED_BY_USER, OpenCodeSubagents, NAMED_KINDS, OPENCODE_ABORTED_ERROR, PROVIDER_EVENT_META, TASK_TOOL_NAME, TASK_RESULT_TAG, TASK_ERROR_TAG, PERMISSION_DENIED, FILE_OPERATIONS, NO_USAGE, PartReader, NOTHING, NON_INTERACTIVE_PERMISSIONS, CONTENT_FILTER_FINISHES, TRUNCATED_FINISHES, OUTPUT_PARTS, OpenCodeTurn, LISTENING, OUTPUT_TAIL_LINES, IMAGE_TYPES, OpenCodeSession, OPENCODE_MIN_VERSION, OPENCODE_REQUIREMENT, OPENCODE_TESTED_LINE, OPENCODE_SUPPORTED_MAJOR, DEFAULTS2, STORE_LOCKED, NON_INTERACTIVE_RULES, TITLE_LENGTH, MAX_VARIANT_LENGTH;
|
|
33256
33332
|
var init_opencode = __esm({
|
|
33257
33333
|
"../agent-core/dist/providers/opencode.js"() {
|
|
33258
33334
|
"use strict";
|
|
33259
|
-
|
|
33335
|
+
init_chunk_U4RQE7JS();
|
|
33260
33336
|
init_chunk_AF3IPGDT();
|
|
33261
|
-
|
|
33337
|
+
init_chunk_WYNUYKKN();
|
|
33262
33338
|
init_chunk_KVTSAS2T();
|
|
33263
|
-
|
|
33339
|
+
init_chunk_7FJ7QKFN();
|
|
33264
33340
|
init_chunk_OSECDZA5();
|
|
33265
33341
|
init_chunk_YXWJW7I5();
|
|
33266
33342
|
import_crypto9 = require("crypto");
|
|
@@ -33268,12 +33344,12 @@ var init_opencode = __esm({
|
|
|
33268
33344
|
init_runtime_v2();
|
|
33269
33345
|
import_crypto10 = require("crypto");
|
|
33270
33346
|
import_promises25 = require("fs/promises");
|
|
33271
|
-
import_path9 = require("path");
|
|
33272
|
-
init_agent2();
|
|
33273
33347
|
import_path10 = require("path");
|
|
33348
|
+
init_agent2();
|
|
33349
|
+
import_path11 = require("path");
|
|
33274
33350
|
import_url2 = require("url");
|
|
33275
33351
|
init_acp();
|
|
33276
|
-
|
|
33352
|
+
import_path12 = require("path");
|
|
33277
33353
|
init_acp();
|
|
33278
33354
|
init_constants();
|
|
33279
33355
|
import_crypto11 = require("crypto");
|
|
@@ -33911,7 +33987,7 @@ var init_opencode = __esm({
|
|
|
33911
33987
|
this.#readOnly = readOnly;
|
|
33912
33988
|
this.#memory = memory;
|
|
33913
33989
|
this.#engine = engine;
|
|
33914
|
-
this.#readableFiles = new Set(readableFiles.map((path4) => (0,
|
|
33990
|
+
this.#readableFiles = new Set(readableFiles.map((path4) => (0, import_path12.normalize)(path4)));
|
|
33915
33991
|
}
|
|
33916
33992
|
get childSessionIds() {
|
|
33917
33993
|
return [...this.#children.keys()];
|
|
@@ -34151,7 +34227,7 @@ var init_opencode = __esm({
|
|
|
34151
34227
|
#opensAttachment(kind, properties) {
|
|
34152
34228
|
if (kind !== "external_directory") return false;
|
|
34153
34229
|
const filepath = asString(asRecord(properties.metadata)?.filepath);
|
|
34154
|
-
return (0,
|
|
34230
|
+
return (0, import_path12.isAbsolute)(filepath) && this.#readableFiles.has((0, import_path12.normalize)(filepath));
|
|
34155
34231
|
}
|
|
34156
34232
|
#question(properties) {
|
|
34157
34233
|
const requestId = asString(properties.id).trim();
|
|
@@ -35110,6 +35186,14 @@ function modelArgs(input2) {
|
|
|
35110
35186
|
effort: option("--effort", effort)
|
|
35111
35187
|
};
|
|
35112
35188
|
}
|
|
35189
|
+
function skillListingArgs(input2) {
|
|
35190
|
+
const chars = input2.skillListingMaxDescChars;
|
|
35191
|
+
const ownSettings = (input2.extraArgs ?? []).some(
|
|
35192
|
+
(arg) => arg === "--settings" || arg.startsWith("--settings=")
|
|
35193
|
+
);
|
|
35194
|
+
if (chars === void 0 || !input2.capabilities.supportsPluginDir || ownSettings) return [];
|
|
35195
|
+
return ["--settings", JSON.stringify({ skillListingMaxDescChars: chars })];
|
|
35196
|
+
}
|
|
35113
35197
|
function buildClaudeArgs(input2) {
|
|
35114
35198
|
const { capabilities } = input2;
|
|
35115
35199
|
const disallowed = input2.disallowedTools?.length ? input2.disallowedTools.join(",") : void 0;
|
|
@@ -35134,6 +35218,7 @@ function buildClaudeArgs(input2) {
|
|
|
35134
35218
|
// Without it the whole answer lands in one frame at turn end.
|
|
35135
35219
|
...capabilities.supportsPartialMessages ? ["--include-partial-messages"] : [],
|
|
35136
35220
|
...capabilities.supportsPluginDir ? (input2.pluginDirs ?? []).flatMap((dir) => ["--plugin-dir", dir]) : [],
|
|
35221
|
+
...skillListingArgs(input2),
|
|
35137
35222
|
...option("--resume", input2.resumeId),
|
|
35138
35223
|
"--chrome",
|
|
35139
35224
|
...input2.extraArgs ?? []
|
|
@@ -36021,7 +36106,7 @@ function createClaudeDriver(options = {}) {
|
|
|
36021
36106
|
};
|
|
36022
36107
|
}
|
|
36023
36108
|
function claudeHomeFor(env, homeDir) {
|
|
36024
|
-
return env.CLAUDE_CONFIG_DIR || (0,
|
|
36109
|
+
return env.CLAUDE_CONFIG_DIR || (0, import_path13.join)(env.HOME || homeDir, ".claude");
|
|
36025
36110
|
}
|
|
36026
36111
|
function encodeProjectDir(cwd) {
|
|
36027
36112
|
return cwd.replace(/[^a-zA-Z0-9]/g, "-");
|
|
@@ -36042,14 +36127,14 @@ function projectDirs(projectsRoot) {
|
|
|
36042
36127
|
}
|
|
36043
36128
|
function claudeSessionLogExists(query) {
|
|
36044
36129
|
if (!query.sessionId || !query.cwd) return false;
|
|
36045
|
-
const projectsRoot = (0,
|
|
36130
|
+
const projectsRoot = (0, import_path13.join)(query.claudeHome, "projects");
|
|
36046
36131
|
const fileName = `${query.sessionId}.jsonl`;
|
|
36047
36132
|
const here = new Set([query.cwd, realCwd(query.cwd)].map(encodeProjectDir));
|
|
36048
36133
|
for (const dir of here) {
|
|
36049
|
-
if ((0, import_fs8.existsSync)((0,
|
|
36134
|
+
if ((0, import_fs8.existsSync)((0, import_path13.join)(projectsRoot, dir, fileName))) return true;
|
|
36050
36135
|
}
|
|
36051
36136
|
return projectDirs(projectsRoot).some(
|
|
36052
|
-
(dir) => !here.has(dir) && (0, import_fs8.existsSync)((0,
|
|
36137
|
+
(dir) => !here.has(dir) && (0, import_fs8.existsSync)((0, import_path13.join)(projectsRoot, dir, fileName))
|
|
36053
36138
|
);
|
|
36054
36139
|
}
|
|
36055
36140
|
function envDigest3(env) {
|
|
@@ -36078,6 +36163,7 @@ function planClaudeSession(run2, context) {
|
|
|
36078
36163
|
...prompts.systemPrompt === void 0 ? {} : { systemPrompt: prompts.systemPrompt },
|
|
36079
36164
|
...prompts.systemPromptAppend === void 0 ? {} : { appendSystemPrompt: prompts.systemPromptAppend },
|
|
36080
36165
|
...context.pluginDirs?.length ? { pluginDirs: context.pluginDirs } : {},
|
|
36166
|
+
...run2.sandboxId || run2.cloudEnvironmentId ? { skillListingMaxDescChars: CLOUD_SKILL_LISTING_MAX_DESCRIPTION_CHARS } : {},
|
|
36081
36167
|
...context.managedMcp === void 0 ? {} : {
|
|
36082
36168
|
mcp: {
|
|
36083
36169
|
alanMcpUrl: context.managedMcp.url,
|
|
@@ -36320,16 +36406,16 @@ function claudeTurnClosingUpdates(records, state) {
|
|
|
36320
36406
|
function readClaudeTranscriptTurns(chunk, baseOffset, skipped) {
|
|
36321
36407
|
return readTranscriptTurns(claudeTranscriptFile, chunk, baseOffset, skipped);
|
|
36322
36408
|
}
|
|
36323
|
-
var import_crypto12, import_fs8,
|
|
36409
|
+
var import_crypto12, import_fs8, import_path13, import_crypto13, import_promises26, EDIT_TOOLS, ThoughtBlocks, UNDERSTOOD_SYSTEM_SUBTYPES, CLAUDE_MCP_STATUS, RATE_LIMIT_WARN_AT, CLAUDE_GRAMMAR_NAME, SUBAGENT_TOOL_NAMES, controlResponseSchema, STOPPED_STATUSES, TaskRecords, TERMINAL_BACKGROUND_STATUSES, NON_TERMINAL_BACKGROUND_STATUSES, ASYNC_LAUNCH_ACK, BackgroundTasks, FAILED_STATUSES, STOPPED_BY_USER_TEXT, ClaudeTurn, STDERR_TAIL_LINES3, MAX_EARLY_LINES, UNSUPPORTED_STOP, OUTPUT_CLOSED_REASON, ClaudeSession, DEFAULTS3, READ_ONLY_DISALLOWED_TOOLS, DEFAULT_MCP_TIMEOUT_MS, CLOUD_SKILL_LISTING_MAX_DESCRIPTION_CHARS, SYNTHETIC_MODEL, INTERRUPT_MARKER, NON_PROMPT_PREFIXES, PRELUDE_TYPES, claudeTranscriptFile;
|
|
36324
36410
|
var init_claude = __esm({
|
|
36325
36411
|
"../agent-core/dist/providers/claude.js"() {
|
|
36326
36412
|
"use strict";
|
|
36327
36413
|
init_chunk_VUWLTOVK();
|
|
36328
|
-
|
|
36414
|
+
init_chunk_U4RQE7JS();
|
|
36329
36415
|
init_chunk_AF3IPGDT();
|
|
36330
|
-
|
|
36416
|
+
init_chunk_WYNUYKKN();
|
|
36331
36417
|
init_chunk_KVTSAS2T();
|
|
36332
|
-
|
|
36418
|
+
init_chunk_7FJ7QKFN();
|
|
36333
36419
|
init_chunk_OSECDZA5();
|
|
36334
36420
|
init_chunk_YXWJW7I5();
|
|
36335
36421
|
init_effort();
|
|
@@ -36341,7 +36427,7 @@ var init_claude = __esm({
|
|
|
36341
36427
|
init_constants();
|
|
36342
36428
|
init_agent2();
|
|
36343
36429
|
import_fs8 = require("fs");
|
|
36344
|
-
|
|
36430
|
+
import_path13 = require("path");
|
|
36345
36431
|
import_crypto13 = require("crypto");
|
|
36346
36432
|
import_promises26 = require("fs/promises");
|
|
36347
36433
|
init_agent2();
|
|
@@ -37078,8 +37164,8 @@ var init_claude = __esm({
|
|
|
37078
37164
|
}
|
|
37079
37165
|
async #awaitTaskStop(requestId, taskId) {
|
|
37080
37166
|
const timer = new AbortController();
|
|
37081
|
-
const answered = new Promise((
|
|
37082
|
-
this.#taskStops.set(requestId,
|
|
37167
|
+
const answered = new Promise((resolve14) => {
|
|
37168
|
+
this.#taskStops.set(requestId, resolve14);
|
|
37083
37169
|
});
|
|
37084
37170
|
const timeoutMs = this.#options.stopTaskTimeoutMs;
|
|
37085
37171
|
const timedOut = this.#options.clock.sleep(timeoutMs, timer.signal).then(
|
|
@@ -37152,17 +37238,17 @@ var init_claude = __esm({
|
|
|
37152
37238
|
};
|
|
37153
37239
|
let markStarted = () => {
|
|
37154
37240
|
};
|
|
37155
|
-
const whenStarted = new Promise((
|
|
37156
|
-
markStarted =
|
|
37241
|
+
const whenStarted = new Promise((resolve14) => {
|
|
37242
|
+
markStarted = resolve14;
|
|
37157
37243
|
});
|
|
37158
|
-
const done = new Promise((
|
|
37244
|
+
const done = new Promise((resolve14) => {
|
|
37159
37245
|
finish = (outcome2) => {
|
|
37160
37246
|
if (this.#current?.id !== id) return;
|
|
37161
37247
|
this.#current = void 0;
|
|
37162
37248
|
this.#lastTurn = turn;
|
|
37163
37249
|
if (this.#state === "busy") this.#state = "idle";
|
|
37164
37250
|
this.#emit({ type: "turn_ended", turnId: id, outcome: outcome2 });
|
|
37165
|
-
|
|
37251
|
+
resolve14({ turnId: id, outcome: outcome2, providerSessionId: this.#providerSessionId });
|
|
37166
37252
|
};
|
|
37167
37253
|
});
|
|
37168
37254
|
const active = {
|
|
@@ -37280,8 +37366,8 @@ var init_claude = __esm({
|
|
|
37280
37366
|
void removeLaunchFiles(this.#launchFiles).catch((error62) => {
|
|
37281
37367
|
this.#options.log.warn("claude.launch_files_cleanup_failed", { error: error62 });
|
|
37282
37368
|
});
|
|
37283
|
-
for (const
|
|
37284
|
-
|
|
37369
|
+
for (const resolve14 of this.#taskStops.values()) {
|
|
37370
|
+
resolve14({ ok: false, reason: "runtime_unavailable", message: "Claude Code exited." });
|
|
37285
37371
|
}
|
|
37286
37372
|
const active = this.#current;
|
|
37287
37373
|
if (active) {
|
|
@@ -37309,6 +37395,7 @@ var init_claude = __esm({
|
|
|
37309
37395
|
"NotebookEdit"
|
|
37310
37396
|
];
|
|
37311
37397
|
DEFAULT_MCP_TIMEOUT_MS = 5e3;
|
|
37398
|
+
CLOUD_SKILL_LISTING_MAX_DESCRIPTION_CHARS = 250;
|
|
37312
37399
|
SYNTHETIC_MODEL = "<synthetic>";
|
|
37313
37400
|
INTERRUPT_MARKER = "[Request interrupted by user";
|
|
37314
37401
|
NON_PROMPT_PREFIXES = [
|
|
@@ -37489,7 +37576,7 @@ function codexExecArgs(input2) {
|
|
|
37489
37576
|
];
|
|
37490
37577
|
}
|
|
37491
37578
|
function codexHomeOf(env) {
|
|
37492
|
-
return env.CODEX_HOME || (0,
|
|
37579
|
+
return env.CODEX_HOME || (0, import_path14.join)(env.HOME ?? "", ".codex");
|
|
37493
37580
|
}
|
|
37494
37581
|
function namesNewestFirst(dir, isDir) {
|
|
37495
37582
|
try {
|
|
@@ -37505,15 +37592,15 @@ function findCodexRollout(codexHome, sessionId) {
|
|
|
37505
37592
|
const name = namesNewestFirst(dir, false).find(
|
|
37506
37593
|
(file2) => file2.startsWith("rollout-") && file2.endsWith(suffix)
|
|
37507
37594
|
);
|
|
37508
|
-
return name ? (0,
|
|
37595
|
+
return name ? (0, import_path14.join)(dir, name) : void 0;
|
|
37509
37596
|
}
|
|
37510
37597
|
for (const child of namesNewestFirst(dir, true)) {
|
|
37511
|
-
const found = walk((0,
|
|
37598
|
+
const found = walk((0, import_path14.join)(dir, child), depth - 1);
|
|
37512
37599
|
if (found) return found;
|
|
37513
37600
|
}
|
|
37514
37601
|
return void 0;
|
|
37515
37602
|
};
|
|
37516
|
-
return sessionId ? walk((0,
|
|
37603
|
+
return sessionId ? walk((0, import_path14.join)(codexHome, "sessions"), 3) : void 0;
|
|
37517
37604
|
}
|
|
37518
37605
|
function codexRolloutExists(codexHome, sessionId) {
|
|
37519
37606
|
return Promise.resolve(findCodexRollout(codexHome, sessionId) !== void 0);
|
|
@@ -39311,20 +39398,20 @@ function codexTurnInput(run2, context) {
|
|
|
39311
39398
|
...images.length ? { imagePaths: images.map((image) => image.path) } : {}
|
|
39312
39399
|
};
|
|
39313
39400
|
}
|
|
39314
|
-
var import_fs9,
|
|
39401
|
+
var import_fs9, import_path14, import_crypto14, import_crypto15, import_crypto16, import_crypto17, TokenRefresher, MCP_STARTUP_TIMEOUT_SEC, FIELD_TYPES, YES_NO, ACCEPT_DECLINE, MAX_INLINE_GENERATED_IMAGE_BYTES, PNG_SIGNATURE2, JPEG_NON_FRAME_MARKERS, IMAGE_GEN_CALL, PROMPT_LITERAL, RELOCATE_EVERY_MS, CodexImageGenerationFold, CodexRolloutImages, CodexRateLimits, USER_INPUT_METHOD, PERMISSIONS_METHOD, ELICITATION_METHOD, COMMAND_OR_FILE, LEGACY, DECISIONS, COORDINATION_TOOLS, SETTLED_AGENT, STATUS, CHANGE_OPERATIONS, SILENT_ON_START, IGNORED_ITEMS, PLAN_STATUS, CodexTurnTokens, CODEX_MCP_STATUS, WORKER_LIFECYCLE, INFO_KINDS, SILENT, CodexTurn, STDERR_TAIL_LINES4, MAX_BETWEEN_UPDATES2, UNSUPPORTED_REQUEST, DECLINED_ELICITATION, IMAGE_CATCH_UP_MS, IMAGE_POLL_MS, CodexSession, CODEX_MIN_VERSION, CODEX_REQUIREMENT, CODEX_TESTED_LINE, DEFAULTS4, CLIENT_INFO2, STATUS2, EXITED_WITHOUT_RESPONSE, CodexExecTurn, DEFAULTS22, CodexExecSession, INJECTED_USER_PREFIXES, SHELL_TOOL_NAMES, ANNOUNCING_ITEM_TYPES, OUTPUT_MARKER, OPEN_PAGE_ACTIONS, FIND_IN_PAGE_ACTIONS, FILE_OPERATIONS2, UNDERSTOOD_ITEM_TYPES, PRELUDE_TYPES2, PRELUDE_EVENTS, codexRolloutFile;
|
|
39315
39402
|
var init_codex = __esm({
|
|
39316
39403
|
"../agent-core/dist/providers/codex.js"() {
|
|
39317
39404
|
"use strict";
|
|
39318
39405
|
init_chunk_VUWLTOVK();
|
|
39319
|
-
|
|
39406
|
+
init_chunk_U4RQE7JS();
|
|
39320
39407
|
init_chunk_AF3IPGDT();
|
|
39321
|
-
|
|
39408
|
+
init_chunk_WYNUYKKN();
|
|
39322
39409
|
init_chunk_KVTSAS2T();
|
|
39323
|
-
|
|
39410
|
+
init_chunk_7FJ7QKFN();
|
|
39324
39411
|
init_chunk_OSECDZA5();
|
|
39325
39412
|
init_chunk_YXWJW7I5();
|
|
39326
39413
|
import_fs9 = require("fs");
|
|
39327
|
-
|
|
39414
|
+
import_path14 = require("path");
|
|
39328
39415
|
init_effort();
|
|
39329
39416
|
import_crypto14 = require("crypto");
|
|
39330
39417
|
import_crypto15 = require("crypto");
|
|
@@ -40048,10 +40135,10 @@ var init_codex = __esm({
|
|
|
40048
40135
|
};
|
|
40049
40136
|
let identify = () => {
|
|
40050
40137
|
};
|
|
40051
|
-
const identified = new Promise((
|
|
40052
|
-
identify =
|
|
40138
|
+
const identified = new Promise((resolve14) => {
|
|
40139
|
+
identify = resolve14;
|
|
40053
40140
|
});
|
|
40054
|
-
const done = new Promise((
|
|
40141
|
+
const done = new Promise((resolve14) => {
|
|
40055
40142
|
finish = (outcome2) => {
|
|
40056
40143
|
if (this.#current?.id !== id) return;
|
|
40057
40144
|
this.#current = void 0;
|
|
@@ -40059,7 +40146,7 @@ var init_codex = __esm({
|
|
|
40059
40146
|
if (this.#state === "busy") this.#state = "idle";
|
|
40060
40147
|
this.#host.scanDescendants(true);
|
|
40061
40148
|
this.#emit({ type: "turn_ended", turnId: id, outcome: outcome2 });
|
|
40062
|
-
|
|
40149
|
+
resolve14({ turnId: id, outcome: outcome2, providerSessionId: this.#threadId });
|
|
40063
40150
|
};
|
|
40064
40151
|
});
|
|
40065
40152
|
const active = {
|
|
@@ -40717,8 +40804,8 @@ function createDroidPeer(writer, handlers) {
|
|
|
40717
40804
|
},
|
|
40718
40805
|
request: (method, params = {}) => {
|
|
40719
40806
|
const id = `alan-${counter.next++}`;
|
|
40720
|
-
return new Promise((
|
|
40721
|
-
pending.set(id, { method, resolve:
|
|
40807
|
+
return new Promise((resolve14, reject) => {
|
|
40808
|
+
pending.set(id, { method, resolve: resolve14, reject });
|
|
40722
40809
|
writer.write(envelope("request", { id, method, params })).catch((error62) => {
|
|
40723
40810
|
pending.delete(id);
|
|
40724
40811
|
reject(error62 instanceof Error ? error62 : new Error(String(error62)));
|
|
@@ -41062,11 +41149,11 @@ var import_crypto18, import_promises27, FACTORY_API_VERSION, FACTORY_PROTOCOL_VE
|
|
|
41062
41149
|
var init_droid = __esm({
|
|
41063
41150
|
"../agent-core/dist/providers/droid.js"() {
|
|
41064
41151
|
"use strict";
|
|
41065
|
-
|
|
41152
|
+
init_chunk_U4RQE7JS();
|
|
41066
41153
|
init_chunk_AF3IPGDT();
|
|
41067
|
-
|
|
41154
|
+
init_chunk_WYNUYKKN();
|
|
41068
41155
|
init_chunk_KVTSAS2T();
|
|
41069
|
-
|
|
41156
|
+
init_chunk_7FJ7QKFN();
|
|
41070
41157
|
init_chunk_OSECDZA5();
|
|
41071
41158
|
init_chunk_YXWJW7I5();
|
|
41072
41159
|
init_runtime_v2();
|
|
@@ -41355,14 +41442,14 @@ var init_droid = __esm({
|
|
|
41355
41442
|
const turn = new DroidTurn(sessionId, this.#memory);
|
|
41356
41443
|
let finish = () => {
|
|
41357
41444
|
};
|
|
41358
|
-
const done = new Promise((
|
|
41445
|
+
const done = new Promise((resolve14) => {
|
|
41359
41446
|
finish = (outcome2) => {
|
|
41360
41447
|
if (this.#current?.id !== id) return;
|
|
41361
41448
|
this.#current = void 0;
|
|
41362
41449
|
if (this.#state === "busy") this.#state = "idle";
|
|
41363
41450
|
this.#host.scanDescendants(true);
|
|
41364
41451
|
this.#emit({ type: "turn_ended", turnId: id, outcome: outcome2 });
|
|
41365
|
-
|
|
41452
|
+
resolve14({ turnId: id, outcome: outcome2, providerSessionId: this.#sessionId });
|
|
41366
41453
|
};
|
|
41367
41454
|
});
|
|
41368
41455
|
const active = { id, turn, done, finish, cancelRequested: false };
|
|
@@ -41553,7 +41640,7 @@ var init_opencode2 = __esm({
|
|
|
41553
41640
|
// ../agent-core/dist/providers/antigravity.js
|
|
41554
41641
|
function settingsPath(env) {
|
|
41555
41642
|
const home = env.HOME?.trim() || env.USERPROFILE?.trim();
|
|
41556
|
-
return home ? (0,
|
|
41643
|
+
return home ? (0, import_path15.resolve)(home, ".gemini", "antigravity-cli", "settings.json") : void 0;
|
|
41557
41644
|
}
|
|
41558
41645
|
async function readSettings(path4) {
|
|
41559
41646
|
let raw;
|
|
@@ -41576,7 +41663,7 @@ async function selectAntigravityApiKeyMode(env) {
|
|
|
41576
41663
|
const settings2 = await readSettings(path4);
|
|
41577
41664
|
if (settings2 === "malformed") return "malformed";
|
|
41578
41665
|
if (settings2.modelProvider === "gemini") return "already_selected";
|
|
41579
|
-
await (0, import_promises28.mkdir)((0,
|
|
41666
|
+
await (0, import_promises28.mkdir)((0, import_path15.dirname)(path4), { recursive: true });
|
|
41580
41667
|
await (0, import_promises28.writeFile)(path4, JSON.stringify({ ...settings2, modelProvider: "gemini" }), { mode: 384 });
|
|
41581
41668
|
return "selected";
|
|
41582
41669
|
}
|
|
@@ -41620,21 +41707,21 @@ function antigravityArgs(input2, capabilities, prompt) {
|
|
|
41620
41707
|
];
|
|
41621
41708
|
}
|
|
41622
41709
|
function workspaceRoot(cwd) {
|
|
41623
|
-
for (let current = (0,
|
|
41624
|
-
if ((0, import_fs10.existsSync)((0,
|
|
41625
|
-
if ((0,
|
|
41710
|
+
for (let current = (0, import_path16.resolve)(cwd); ; current = (0, import_path16.dirname)(current)) {
|
|
41711
|
+
if ((0, import_fs10.existsSync)((0, import_path16.join)(current, ".git"))) return current;
|
|
41712
|
+
if ((0, import_path16.dirname)(current) === current) return (0, import_path16.resolve)(cwd);
|
|
41626
41713
|
}
|
|
41627
41714
|
}
|
|
41628
41715
|
function instructionPaths(cwd) {
|
|
41629
41716
|
const root = workspaceRoot(cwd);
|
|
41630
41717
|
const paths = [];
|
|
41631
|
-
for (let current = (0,
|
|
41632
|
-
const path4 = (0,
|
|
41718
|
+
for (let current = (0, import_path16.resolve)(cwd); ; current = (0, import_path16.dirname)(current)) {
|
|
41719
|
+
const path4 = (0, import_path16.join)(current, INSTRUCTIONS_FILE);
|
|
41633
41720
|
try {
|
|
41634
41721
|
if ((0, import_fs10.existsSync)(path4) && (0, import_fs10.statSync)(path4).isFile()) paths.unshift(path4);
|
|
41635
41722
|
} catch {
|
|
41636
41723
|
}
|
|
41637
|
-
if (current === root || (0,
|
|
41724
|
+
if (current === root || (0, import_path16.dirname)(current) === current) return paths;
|
|
41638
41725
|
}
|
|
41639
41726
|
}
|
|
41640
41727
|
function antigravityWorkspaceInstructions(cwd, maxChars = MAX_INSTRUCTION_CHARS) {
|
|
@@ -41888,7 +41975,7 @@ function normalizeAntigravityFrame(event) {
|
|
|
41888
41975
|
}
|
|
41889
41976
|
function antigravityBrainRoot(env) {
|
|
41890
41977
|
const home = env.HOME?.trim() || env.USERPROFILE?.trim();
|
|
41891
|
-
return home ? (0,
|
|
41978
|
+
return home ? (0, import_path17.resolve)(home, ".gemini", "antigravity-cli", "brain") : void 0;
|
|
41892
41979
|
}
|
|
41893
41980
|
function parseEntry(text3) {
|
|
41894
41981
|
try {
|
|
@@ -41926,14 +42013,14 @@ function childTranscriptPath(root, frame) {
|
|
|
41926
42013
|
try {
|
|
41927
42014
|
const url3 = new URL(logUri);
|
|
41928
42015
|
if (url3.protocol !== "file:") return void 0;
|
|
41929
|
-
path4 = (0,
|
|
42016
|
+
path4 = (0, import_path17.resolve)((0, import_url3.fileURLToPath)(url3));
|
|
41930
42017
|
} catch {
|
|
41931
42018
|
return void 0;
|
|
41932
42019
|
}
|
|
41933
|
-
const fromRoot = (0,
|
|
41934
|
-
if (!fromRoot || (0,
|
|
42020
|
+
const fromRoot = (0, import_path17.relative)(root, path4);
|
|
42021
|
+
if (!fromRoot || (0, import_path17.isAbsolute)(fromRoot) || fromRoot.split(import_path17.sep).includes("..")) return void 0;
|
|
41935
42022
|
const expected = [conversationId, ...LOG_DIRS, TRANSCRIPT_FILE];
|
|
41936
|
-
const segments = fromRoot.split(
|
|
42023
|
+
const segments = fromRoot.split(import_path17.sep);
|
|
41937
42024
|
const matches = segments.length === expected.length && segments.every((segment, index) => segment === expected[index]);
|
|
41938
42025
|
return matches ? path4 : void 0;
|
|
41939
42026
|
}
|
|
@@ -42195,24 +42282,24 @@ function antigravityTurnInput(run2, context) {
|
|
|
42195
42282
|
});
|
|
42196
42283
|
return { turnId: run2.runId, text: appendImagePathReferences(text3, images) };
|
|
42197
42284
|
}
|
|
42198
|
-
var import_promises28,
|
|
42285
|
+
var import_promises28, import_path15, import_fs10, import_path16, import_path17, import_url3, import_crypto19, NO_ANTIGRAVITY_CAPABILITIES, INSTRUCTIONS_FILE, MAX_INSTRUCTION_CHARS, SHORTENED_NOTE, DIFF_BLOCK_START, DIFF_BLOCK_END, HUNK_HEADER, TRANSCRIPT_FILE, FULL_TRANSCRIPT_FILE, LOG_DIRS, TOOL_RESULT_TYPES, BrainTranscript, AntigravityTranscripts, ANTIGRAVITY_GRAMMAR_NAME, AntigravityGrammar, ignored, HANDLERS, SUCCESSFUL_STATUSES, SESSION_START_TYPES, RESULT_TYPES, SUBAGENT_START_TYPES, RESUME_FORKED, EXITED_WITHOUT_RESULT, AntigravityTurn, DEFAULTS6, AntigravitySession, WINDOWS_LINE_MARGIN;
|
|
42199
42286
|
var init_antigravity = __esm({
|
|
42200
42287
|
"../agent-core/dist/providers/antigravity.js"() {
|
|
42201
42288
|
"use strict";
|
|
42202
42289
|
init_chunk_VUWLTOVK();
|
|
42203
|
-
|
|
42290
|
+
init_chunk_U4RQE7JS();
|
|
42204
42291
|
init_chunk_AF3IPGDT();
|
|
42205
|
-
|
|
42292
|
+
init_chunk_WYNUYKKN();
|
|
42206
42293
|
init_chunk_KVTSAS2T();
|
|
42207
|
-
|
|
42294
|
+
init_chunk_7FJ7QKFN();
|
|
42208
42295
|
init_chunk_YXWJW7I5();
|
|
42209
42296
|
import_promises28 = require("fs/promises");
|
|
42210
|
-
|
|
42297
|
+
import_path15 = require("path");
|
|
42211
42298
|
init_type_guards();
|
|
42212
42299
|
import_fs10 = require("fs");
|
|
42213
|
-
import_path15 = require("path");
|
|
42214
|
-
init_effort();
|
|
42215
42300
|
import_path16 = require("path");
|
|
42301
|
+
init_effort();
|
|
42302
|
+
import_path17 = require("path");
|
|
42216
42303
|
import_url3 = require("url");
|
|
42217
42304
|
import_crypto19 = require("crypto");
|
|
42218
42305
|
init_agent2();
|
|
@@ -42252,7 +42339,7 @@ var init_antigravity = __esm({
|
|
|
42252
42339
|
#full;
|
|
42253
42340
|
constructor(path4) {
|
|
42254
42341
|
this.#cursor = new TranscriptCursor(path4);
|
|
42255
|
-
this.#fullPath = (0,
|
|
42342
|
+
this.#fullPath = (0, import_path17.resolve)((0, import_path17.dirname)(path4), FULL_TRANSCRIPT_FILE);
|
|
42256
42343
|
}
|
|
42257
42344
|
skipExisting() {
|
|
42258
42345
|
this.#cursor.read();
|
|
@@ -42300,7 +42387,7 @@ var init_antigravity = __esm({
|
|
|
42300
42387
|
/** A conversation this turn did not resume was created by it, so it is read whole. */
|
|
42301
42388
|
trackParent(conversationId) {
|
|
42302
42389
|
if (this.#parent?.conversationId === conversationId) return;
|
|
42303
|
-
const path4 = (0,
|
|
42390
|
+
const path4 = (0, import_path17.resolve)(this.#root, conversationId, ...LOG_DIRS, TRANSCRIPT_FILE);
|
|
42304
42391
|
this.#parent = { conversationId, transcript: new BrainTranscript(path4) };
|
|
42305
42392
|
}
|
|
42306
42393
|
/** A launcher keeps the first valid transcript it names; later frames change nothing. */
|
|
@@ -42731,7 +42818,7 @@ function parseConfig(raw) {
|
|
|
42731
42818
|
}
|
|
42732
42819
|
}
|
|
42733
42820
|
async function writeCommandCodeProjectMcp(cwd, mcp) {
|
|
42734
|
-
const path4 = (0,
|
|
42821
|
+
const path4 = (0, import_path18.join)(cwd, ".mcp.json");
|
|
42735
42822
|
const original = await (0, import_promises29.readFile)(path4, "utf8").catch(() => null);
|
|
42736
42823
|
const config2 = parseConfig(original);
|
|
42737
42824
|
const next = {
|
|
@@ -42926,19 +43013,19 @@ function commandCodeTurnInput(run2, context) {
|
|
|
42926
43013
|
});
|
|
42927
43014
|
return { turnId: run2.runId, text: appendImagePathReferences(text3, images) };
|
|
42928
43015
|
}
|
|
42929
|
-
var import_promises29,
|
|
43016
|
+
var import_promises29, import_path18, import_crypto20, COMMAND_CODE_GRAMMAR_NAME, SILENT3, CommandCodeGrammar, SHELL_TOOL, STOP_TOOLS, REPORTED_STATUS, SHELL_STATUS, SWEEP_INTERVAL_MS, CommandCodeBackgroundTasks, EXITED_WITHOUT_RESULT2, CommandCodeTurn, COMMAND_CODE_MAX_TURNS, DEFAULTS7, CommandCodeSession;
|
|
42930
43017
|
var init_command_code = __esm({
|
|
42931
43018
|
"../agent-core/dist/providers/command-code.js"() {
|
|
42932
43019
|
"use strict";
|
|
42933
|
-
|
|
43020
|
+
init_chunk_U4RQE7JS();
|
|
42934
43021
|
init_chunk_AF3IPGDT();
|
|
42935
|
-
|
|
43022
|
+
init_chunk_WYNUYKKN();
|
|
42936
43023
|
init_chunk_KVTSAS2T();
|
|
42937
|
-
|
|
43024
|
+
init_chunk_7FJ7QKFN();
|
|
42938
43025
|
init_chunk_OSECDZA5();
|
|
42939
43026
|
init_chunk_YXWJW7I5();
|
|
42940
43027
|
import_promises29 = require("fs/promises");
|
|
42941
|
-
|
|
43028
|
+
import_path18 = require("path");
|
|
42942
43029
|
init_agent2();
|
|
42943
43030
|
init_runtime_v2();
|
|
42944
43031
|
init_acp();
|
|
@@ -52149,8 +52236,8 @@ var require_streamx = __commonJS({
|
|
|
52149
52236
|
return this;
|
|
52150
52237
|
},
|
|
52151
52238
|
next() {
|
|
52152
|
-
return new Promise(function(
|
|
52153
|
-
promiseResolve =
|
|
52239
|
+
return new Promise(function(resolve14, reject) {
|
|
52240
|
+
promiseResolve = resolve14;
|
|
52154
52241
|
promiseReject = reject;
|
|
52155
52242
|
const data = stream.read();
|
|
52156
52243
|
if (data !== null) ondata(data);
|
|
@@ -52183,11 +52270,11 @@ var require_streamx = __commonJS({
|
|
|
52183
52270
|
}
|
|
52184
52271
|
function destroy(err) {
|
|
52185
52272
|
stream.destroy(err);
|
|
52186
|
-
return new Promise((
|
|
52187
|
-
if (stream._duplexState & DESTROYED) return
|
|
52273
|
+
return new Promise((resolve14, reject) => {
|
|
52274
|
+
if (stream._duplexState & DESTROYED) return resolve14({ value: void 0, done: true });
|
|
52188
52275
|
stream.once("close", function() {
|
|
52189
52276
|
if (err) reject(err);
|
|
52190
|
-
else
|
|
52277
|
+
else resolve14({ value: void 0, done: true });
|
|
52191
52278
|
});
|
|
52192
52279
|
});
|
|
52193
52280
|
}
|
|
@@ -52231,8 +52318,8 @@ var require_streamx = __commonJS({
|
|
|
52231
52318
|
const writes = pending + (ws._duplexState & WRITE_WRITING ? 1 : 0);
|
|
52232
52319
|
if (writes === 0) return Promise.resolve(true);
|
|
52233
52320
|
if (state.drains === null) state.drains = [];
|
|
52234
|
-
return new Promise((
|
|
52235
|
-
state.drains.push({ writes, resolve:
|
|
52321
|
+
return new Promise((resolve14) => {
|
|
52322
|
+
state.drains.push({ writes, resolve: resolve14 });
|
|
52236
52323
|
});
|
|
52237
52324
|
}
|
|
52238
52325
|
write(data) {
|
|
@@ -52337,10 +52424,10 @@ var require_streamx = __commonJS({
|
|
|
52337
52424
|
cb(null);
|
|
52338
52425
|
}
|
|
52339
52426
|
function pipelinePromise(...streams) {
|
|
52340
|
-
return new Promise((
|
|
52427
|
+
return new Promise((resolve14, reject) => {
|
|
52341
52428
|
return pipeline(...streams, (err) => {
|
|
52342
52429
|
if (err) return reject(err);
|
|
52343
|
-
|
|
52430
|
+
resolve14();
|
|
52344
52431
|
});
|
|
52345
52432
|
});
|
|
52346
52433
|
}
|
|
@@ -53012,16 +53099,16 @@ var require_extract = __commonJS({
|
|
|
53012
53099
|
entryCallback = null;
|
|
53013
53100
|
cb(err);
|
|
53014
53101
|
}
|
|
53015
|
-
function onnext(
|
|
53102
|
+
function onnext(resolve14, reject) {
|
|
53016
53103
|
if (error62) {
|
|
53017
53104
|
return reject(error62);
|
|
53018
53105
|
}
|
|
53019
53106
|
if (entryStream) {
|
|
53020
|
-
|
|
53107
|
+
resolve14({ value: entryStream, done: false });
|
|
53021
53108
|
entryStream = null;
|
|
53022
53109
|
return;
|
|
53023
53110
|
}
|
|
53024
|
-
promiseResolve =
|
|
53111
|
+
promiseResolve = resolve14;
|
|
53025
53112
|
promiseReject = reject;
|
|
53026
53113
|
consumeCallback(null);
|
|
53027
53114
|
if (extract2._finished && promiseResolve) {
|
|
@@ -53049,11 +53136,11 @@ var require_extract = __commonJS({
|
|
|
53049
53136
|
function destroy(err) {
|
|
53050
53137
|
extract2.destroy(err);
|
|
53051
53138
|
consumeCallback(err);
|
|
53052
|
-
return new Promise((
|
|
53053
|
-
if (extract2.destroyed) return
|
|
53139
|
+
return new Promise((resolve14, reject) => {
|
|
53140
|
+
if (extract2.destroyed) return resolve14({ value: void 0, done: true });
|
|
53054
53141
|
extract2.once("close", function() {
|
|
53055
53142
|
if (err) reject(err);
|
|
53056
|
-
else
|
|
53143
|
+
else resolve14({ value: void 0, done: true });
|
|
53057
53144
|
});
|
|
53058
53145
|
});
|
|
53059
53146
|
}
|
|
@@ -58122,7 +58209,7 @@ var import_node_worker_threads2 = require("worker_threads");
|
|
|
58122
58209
|
// package.json
|
|
58123
58210
|
var package_default = {
|
|
58124
58211
|
name: "@alan-ai-hq/agent-manager",
|
|
58125
|
-
version: "0.1.
|
|
58212
|
+
version: "0.1.168",
|
|
58126
58213
|
private: true,
|
|
58127
58214
|
type: "module",
|
|
58128
58215
|
description: "Alan machine runtime (alan-agent): identity, link, reconciler, session holders, run log, uploader, local API",
|
|
@@ -58328,8 +58415,8 @@ async function writeJsonFileAtomic(path4, value2) {
|
|
|
58328
58415
|
var LIFECYCLE_DRAIN_MS = 5e3;
|
|
58329
58416
|
function createGate() {
|
|
58330
58417
|
const opened = {};
|
|
58331
|
-
const promise2 = new Promise((
|
|
58332
|
-
opened.resolve =
|
|
58418
|
+
const promise2 = new Promise((resolve14) => {
|
|
58419
|
+
opened.resolve = resolve14;
|
|
58333
58420
|
});
|
|
58334
58421
|
return { promise: promise2, open: () => opened.resolve?.() };
|
|
58335
58422
|
}
|
|
@@ -58556,7 +58643,7 @@ function transportFailure(request2, error62) {
|
|
|
58556
58643
|
});
|
|
58557
58644
|
}
|
|
58558
58645
|
function readBody(incoming, url3, maxBytes) {
|
|
58559
|
-
return new Promise((
|
|
58646
|
+
return new Promise((resolve14, reject) => {
|
|
58560
58647
|
const declared = Number(incoming.headers["content-length"] ?? "0");
|
|
58561
58648
|
if (maxBytes !== void 0 && declared > maxBytes) {
|
|
58562
58649
|
incoming.destroy();
|
|
@@ -58575,7 +58662,7 @@ function readBody(incoming, url3, maxBytes) {
|
|
|
58575
58662
|
chunks.push(chunk);
|
|
58576
58663
|
});
|
|
58577
58664
|
incoming.on("error", reject);
|
|
58578
|
-
incoming.on("end", () =>
|
|
58665
|
+
incoming.on("end", () => resolve14(Buffer.concat(chunks)));
|
|
58579
58666
|
});
|
|
58580
58667
|
}
|
|
58581
58668
|
function isConnectionReset(error62) {
|
|
@@ -58583,7 +58670,7 @@ function isConnectionReset(error62) {
|
|
|
58583
58670
|
}
|
|
58584
58671
|
function exchange(request2, agents, attempt2 = 0) {
|
|
58585
58672
|
const { signal, url: url3 } = request2;
|
|
58586
|
-
return new Promise((
|
|
58673
|
+
return new Promise((resolve14, reject) => {
|
|
58587
58674
|
if (signal.aborted) {
|
|
58588
58675
|
reject(signal.reason);
|
|
58589
58676
|
return;
|
|
@@ -58610,7 +58697,7 @@ function exchange(request2, agents, attempt2 = 0) {
|
|
|
58610
58697
|
const stale = outgoing.reusedSocket && !responded && isConnectionReset(error62);
|
|
58611
58698
|
if (stale && attempt2 < STALE_SOCKET_RETRIES && !signal.aborted) {
|
|
58612
58699
|
settle2();
|
|
58613
|
-
|
|
58700
|
+
resolve14(exchange(request2, agents, attempt2 + 1));
|
|
58614
58701
|
return;
|
|
58615
58702
|
}
|
|
58616
58703
|
fail(error62);
|
|
@@ -58623,7 +58710,7 @@ function exchange(request2, agents, attempt2 = 0) {
|
|
|
58623
58710
|
readBody(incoming, url3, isRedirect(status) ? void 0 : request2.maxBodyBytes).then(
|
|
58624
58711
|
(body) => {
|
|
58625
58712
|
settle2();
|
|
58626
|
-
|
|
58713
|
+
resolve14({ status, headers: incoming.headers, body });
|
|
58627
58714
|
},
|
|
58628
58715
|
fail
|
|
58629
58716
|
);
|
|
@@ -58868,8 +58955,8 @@ function isBodyless(method) {
|
|
|
58868
58955
|
return method === "GET" || method === "HEAD";
|
|
58869
58956
|
}
|
|
58870
58957
|
function exchange2(send2, options, input2) {
|
|
58871
|
-
return new Promise((
|
|
58872
|
-
const outgoing = send2({ ...options, method: input2.method, signal: input2.signal },
|
|
58958
|
+
return new Promise((resolve14, reject) => {
|
|
58959
|
+
const outgoing = send2({ ...options, method: input2.method, signal: input2.signal }, resolve14);
|
|
58873
58960
|
outgoing.on("error", reject);
|
|
58874
58961
|
if (isBodyless(input2.method)) {
|
|
58875
58962
|
input2.body.resume();
|
|
@@ -60767,7 +60854,7 @@ function statusOf(error62) {
|
|
|
60767
60854
|
}
|
|
60768
60855
|
return 1;
|
|
60769
60856
|
}
|
|
60770
|
-
var systemExec = (request2) => new Promise((
|
|
60857
|
+
var systemExec = (request2) => new Promise((resolve14) => {
|
|
60771
60858
|
const child = (0, import_node_child_process5.execFile)(
|
|
60772
60859
|
request2.command,
|
|
60773
60860
|
[...request2.args],
|
|
@@ -60778,7 +60865,7 @@ var systemExec = (request2) => new Promise((resolve13) => {
|
|
|
60778
60865
|
windowsHide: true
|
|
60779
60866
|
},
|
|
60780
60867
|
(error62, stdout, stderr) => {
|
|
60781
|
-
|
|
60868
|
+
resolve14({ status: statusOf(error62), stdout, stderr });
|
|
60782
60869
|
}
|
|
60783
60870
|
);
|
|
60784
60871
|
child.stdin?.on("error", () => {
|
|
@@ -62055,8 +62142,8 @@ function startWakeClock(options) {
|
|
|
62055
62142
|
}
|
|
62056
62143
|
|
|
62057
62144
|
// src/cli/commands/activity-lease-producer.ts
|
|
62058
|
-
var
|
|
62059
|
-
var
|
|
62145
|
+
var import_promises70 = require("fs/promises");
|
|
62146
|
+
var import_node_path68 = require("path");
|
|
62060
62147
|
init_runtime_v2();
|
|
62061
62148
|
|
|
62062
62149
|
// src/holder/activity-file.ts
|
|
@@ -62164,8 +62251,8 @@ function isReply(message2) {
|
|
|
62164
62251
|
async function connectHolder(endpoint, token, onEvent) {
|
|
62165
62252
|
const socket = (0, import_node_net.connect)(endpoint);
|
|
62166
62253
|
const pending = /* @__PURE__ */ new Map();
|
|
62167
|
-
const closed = new Promise((
|
|
62168
|
-
const ready = new Promise((
|
|
62254
|
+
const closed = new Promise((resolve14) => socket.once("close", () => resolve14()));
|
|
62255
|
+
const ready = new Promise((resolve14, reject) => {
|
|
62169
62256
|
socket.once("error", reject);
|
|
62170
62257
|
socket.once(
|
|
62171
62258
|
"close",
|
|
@@ -62173,7 +62260,7 @@ async function connectHolder(endpoint, token, onEvent) {
|
|
|
62173
62260
|
);
|
|
62174
62261
|
readMessages(socket, holderMessageSchema, {
|
|
62175
62262
|
onMessage: (message2) => {
|
|
62176
|
-
if (message2.type === "ready")
|
|
62263
|
+
if (message2.type === "ready") resolve14(message2.pid);
|
|
62177
62264
|
else if (isReply(message2)) {
|
|
62178
62265
|
const id = message2.id;
|
|
62179
62266
|
if (id === null) return;
|
|
@@ -62188,13 +62275,13 @@ async function connectHolder(endpoint, token, onEvent) {
|
|
|
62188
62275
|
const pid = await ready;
|
|
62189
62276
|
const request2 = (body) => {
|
|
62190
62277
|
const id = (0, import_node_crypto11.randomUUID)();
|
|
62191
|
-
return new Promise((
|
|
62278
|
+
return new Promise((resolve14, reject) => {
|
|
62192
62279
|
const timer = AbortSignal.timeout(REQUEST_TIMEOUT_MS7);
|
|
62193
62280
|
timer.addEventListener("abort", () => {
|
|
62194
62281
|
pending.delete(id);
|
|
62195
62282
|
reject(new RuntimeFault("io_failed", "Holder did not answer"));
|
|
62196
62283
|
});
|
|
62197
|
-
pending.set(id,
|
|
62284
|
+
pending.set(id, resolve14);
|
|
62198
62285
|
writeMessage(socket, { ...body, id });
|
|
62199
62286
|
});
|
|
62200
62287
|
};
|
|
@@ -63197,7 +63284,7 @@ function createGitRunner(options) {
|
|
|
63197
63284
|
}
|
|
63198
63285
|
await killProcessTree(child.pid, { signal: "SIGKILL", child, platform: platform3 });
|
|
63199
63286
|
};
|
|
63200
|
-
return new Promise((
|
|
63287
|
+
return new Promise((resolve14, reject) => {
|
|
63201
63288
|
let ending = null;
|
|
63202
63289
|
const stop = (next) => {
|
|
63203
63290
|
if (ending !== null) return;
|
|
@@ -63222,7 +63309,7 @@ function createGitRunner(options) {
|
|
|
63222
63309
|
signal.removeEventListener("abort", onAbort);
|
|
63223
63310
|
const final = ending ?? last;
|
|
63224
63311
|
if (final.kind === "exited") {
|
|
63225
|
-
|
|
63312
|
+
resolve14({ exitCode: final.exitCode, stdout: stdout.text(), stderr: stderr.text() });
|
|
63226
63313
|
} else {
|
|
63227
63314
|
reject(faultFor(final, command));
|
|
63228
63315
|
}
|
|
@@ -63752,11 +63839,11 @@ async function startGitCredentialServer(options) {
|
|
|
63752
63839
|
});
|
|
63753
63840
|
});
|
|
63754
63841
|
removeStaleEndpoint(options.endpoint);
|
|
63755
|
-
await new Promise((
|
|
63842
|
+
await new Promise((resolve14, reject) => {
|
|
63756
63843
|
server.once("error", reject);
|
|
63757
63844
|
server.listen(options.endpoint, () => {
|
|
63758
63845
|
server.off("error", reject);
|
|
63759
|
-
|
|
63846
|
+
resolve14();
|
|
63760
63847
|
});
|
|
63761
63848
|
});
|
|
63762
63849
|
options.log.info("git.credential_server_listening", { endpoint: options.endpoint });
|
|
@@ -63765,7 +63852,7 @@ async function startGitCredentialServer(options) {
|
|
|
63765
63852
|
tokenPath: options.tokenPath,
|
|
63766
63853
|
[Symbol.asyncDispose]: async () => {
|
|
63767
63854
|
closing.abort();
|
|
63768
|
-
await new Promise((
|
|
63855
|
+
await new Promise((resolve14) => server.close(() => resolve14()));
|
|
63769
63856
|
removeStaleEndpoint(options.endpoint);
|
|
63770
63857
|
await (0, import_promises35.rm)(options.tokenPath, { force: true });
|
|
63771
63858
|
}
|
|
@@ -63840,13 +63927,13 @@ authorityKeyIdentifier = keyid
|
|
|
63840
63927
|
`;
|
|
63841
63928
|
}
|
|
63842
63929
|
function openssl(args, cwd) {
|
|
63843
|
-
return new Promise((
|
|
63930
|
+
return new Promise((resolve14, reject) => {
|
|
63844
63931
|
(0, import_node_child_process10.execFile)(
|
|
63845
63932
|
"openssl",
|
|
63846
63933
|
[...args],
|
|
63847
63934
|
{ cwd, timeout: OPENSSL_TIMEOUT_MS },
|
|
63848
63935
|
(error62, _stdout, stderr) => {
|
|
63849
|
-
if (error62 === null)
|
|
63936
|
+
if (error62 === null) resolve14();
|
|
63850
63937
|
else
|
|
63851
63938
|
reject(new Error(`openssl ${args[0] ?? ""} failed: ${stderr.trim() || error62.message}`));
|
|
63852
63939
|
}
|
|
@@ -64023,21 +64110,21 @@ function relayTo(forward, log) {
|
|
|
64023
64110
|
};
|
|
64024
64111
|
}
|
|
64025
64112
|
function listen(server, target) {
|
|
64026
|
-
return new Promise((
|
|
64113
|
+
return new Promise((resolve14, reject) => {
|
|
64027
64114
|
server.once("error", reject);
|
|
64028
64115
|
const done = () => {
|
|
64029
64116
|
server.off("error", reject);
|
|
64030
|
-
|
|
64117
|
+
resolve14();
|
|
64031
64118
|
};
|
|
64032
64119
|
if (typeof target === "string") server.listen(target, done);
|
|
64033
64120
|
else server.listen(target.port, target.host, done);
|
|
64034
64121
|
});
|
|
64035
64122
|
}
|
|
64036
64123
|
function close(server, sockets = /* @__PURE__ */ new Set()) {
|
|
64037
|
-
return new Promise((
|
|
64124
|
+
return new Promise((resolve14) => {
|
|
64038
64125
|
for (const socket of sockets) socket.destroy();
|
|
64039
64126
|
server.closeAllConnections();
|
|
64040
|
-
server.close(() =>
|
|
64127
|
+
server.close(() => resolve14());
|
|
64041
64128
|
});
|
|
64042
64129
|
}
|
|
64043
64130
|
function portOf(server) {
|
|
@@ -66820,7 +66907,7 @@ async function startNativeIngest(deps) {
|
|
|
66820
66907
|
};
|
|
66821
66908
|
const settleIdle = () => {
|
|
66822
66909
|
if (workers.size > 0) return;
|
|
66823
|
-
for (const
|
|
66910
|
+
for (const resolve14 of idleWaiters) resolve14();
|
|
66824
66911
|
idleWaiters.clear();
|
|
66825
66912
|
};
|
|
66826
66913
|
const retryDelay = (worker) => {
|
|
@@ -67063,7 +67150,7 @@ async function startNativeIngest(deps) {
|
|
|
67063
67150
|
sweep: sweep2,
|
|
67064
67151
|
whenIdle: () => {
|
|
67065
67152
|
if (workers.size === 0) return Promise.resolve();
|
|
67066
|
-
return new Promise((
|
|
67153
|
+
return new Promise((resolve14) => idleWaiters.add(resolve14));
|
|
67067
67154
|
},
|
|
67068
67155
|
[Symbol.asyncDispose]: async () => {
|
|
67069
67156
|
shutdown.abort();
|
|
@@ -67211,7 +67298,7 @@ function captureProbe(command, args, options) {
|
|
|
67211
67298
|
const launch = directLaunch(command, args, options);
|
|
67212
67299
|
if (launch === void 0) return Promise.resolve({ stdout: "", stderr: "", exitCode: void 0 });
|
|
67213
67300
|
const env = platform3 === "win32" ? withWindowsHelper(canonicalWindowsEnvironment(options.env)) : options.env;
|
|
67214
|
-
return new Promise((
|
|
67301
|
+
return new Promise((resolve14) => {
|
|
67215
67302
|
const limit = options.maxBufferBytes ?? DEFAULT_MAX_BYTES;
|
|
67216
67303
|
const stdout = [];
|
|
67217
67304
|
const stderr = [];
|
|
@@ -67246,7 +67333,7 @@ function captureProbe(command, args, options) {
|
|
|
67246
67333
|
settled2 = true;
|
|
67247
67334
|
deadlineController.abort();
|
|
67248
67335
|
options.signal?.removeEventListener("abort", abort);
|
|
67249
|
-
|
|
67336
|
+
resolve14({
|
|
67250
67337
|
stdout: Buffer.concat(stdout).toString("utf8"),
|
|
67251
67338
|
stderr: Buffer.concat(stderr).toString("utf8"),
|
|
67252
67339
|
exitCode
|
|
@@ -67379,7 +67466,7 @@ function cursorAccountLabel(output2) {
|
|
|
67379
67466
|
function waitForAbort(signal) {
|
|
67380
67467
|
if (signal.aborted) return Promise.resolve();
|
|
67381
67468
|
return new Promise(
|
|
67382
|
-
(
|
|
67469
|
+
(resolve14) => signal.addEventListener("abort", () => resolve14(), { once: true })
|
|
67383
67470
|
);
|
|
67384
67471
|
}
|
|
67385
67472
|
function idlePrompt(signal) {
|
|
@@ -67457,14 +67544,14 @@ async function codexLabel(executable, env) {
|
|
|
67457
67544
|
windowsVerbatimArguments: launch.windowsVerbatimArguments
|
|
67458
67545
|
});
|
|
67459
67546
|
const timeout = AbortSignal.timeout(ACCOUNT_TIMEOUT_MS);
|
|
67460
|
-
return new Promise((
|
|
67547
|
+
return new Promise((resolve14) => {
|
|
67461
67548
|
let finished = false;
|
|
67462
67549
|
let buffer = "";
|
|
67463
67550
|
const finish = (label) => {
|
|
67464
67551
|
if (finished) return;
|
|
67465
67552
|
finished = true;
|
|
67466
67553
|
child.kill();
|
|
67467
|
-
|
|
67554
|
+
resolve14(label);
|
|
67468
67555
|
};
|
|
67469
67556
|
const send2 = (value2) => {
|
|
67470
67557
|
child.stdin.write(`${JSON.stringify(value2)}
|
|
@@ -67607,7 +67694,7 @@ function createProbeQueue(capture, env, limit) {
|
|
|
67607
67694
|
active += 1;
|
|
67608
67695
|
return Promise.resolve();
|
|
67609
67696
|
}
|
|
67610
|
-
return new Promise((
|
|
67697
|
+
return new Promise((resolve14) => waiting.push(resolve14));
|
|
67611
67698
|
};
|
|
67612
67699
|
const release2 = () => {
|
|
67613
67700
|
const next = waiting.shift();
|
|
@@ -68048,11 +68135,11 @@ async function resolveCliEnvironment(options) {
|
|
|
68048
68135
|
}
|
|
68049
68136
|
async function openCliEnvironment(options) {
|
|
68050
68137
|
const decorate = options.decorate ?? ((env) => env);
|
|
68051
|
-
const
|
|
68138
|
+
const resolve14 = async () => {
|
|
68052
68139
|
const resolved = await resolveCliEnvironmentDetailed(options);
|
|
68053
68140
|
return { env: decorate(resolved.env), source: resolved.source };
|
|
68054
68141
|
};
|
|
68055
|
-
let state = await
|
|
68142
|
+
let state = await resolve14();
|
|
68056
68143
|
let retryAt = options.clock.now() + DEGRADED_RETRY_MS;
|
|
68057
68144
|
return {
|
|
68058
68145
|
current: () => state.env,
|
|
@@ -68061,7 +68148,7 @@ async function openCliEnvironment(options) {
|
|
|
68061
68148
|
if (state.source === "login_shell" || options.platform === "win32") return false;
|
|
68062
68149
|
if (options.clock.now() < retryAt) return false;
|
|
68063
68150
|
retryAt = options.clock.now() + DEGRADED_RETRY_MS;
|
|
68064
|
-
const next = await
|
|
68151
|
+
const next = await resolve14();
|
|
68065
68152
|
const changed2 = envValue(next.env, "PATH") !== envValue(state.env, "PATH");
|
|
68066
68153
|
state = next;
|
|
68067
68154
|
return changed2;
|
|
@@ -68138,11 +68225,11 @@ async function installVersion2(backendKind, requested, options, signal) {
|
|
|
68138
68225
|
}
|
|
68139
68226
|
return exact;
|
|
68140
68227
|
}
|
|
68141
|
-
const
|
|
68142
|
-
if (
|
|
68228
|
+
const resolve14 = options.resolveVersion;
|
|
68229
|
+
if (resolve14 === void 0) throw new Error("Latest version lookup is unavailable");
|
|
68143
68230
|
const packageName = packageFor(backendKind).name;
|
|
68144
68231
|
return checkedVersion(
|
|
68145
|
-
await
|
|
68232
|
+
await resolve14(backendKind === "opencode_serve" ? `${packageName}@1` : packageName, signal)
|
|
68146
68233
|
);
|
|
68147
68234
|
}
|
|
68148
68235
|
function selection(root, backendKind, version2) {
|
|
@@ -68404,15 +68491,101 @@ async function probeManagedProvider(executable, backendKind, env) {
|
|
|
68404
68491
|
${help.stderr}`);
|
|
68405
68492
|
}
|
|
68406
68493
|
|
|
68494
|
+
// src/capabilities/skills/legacy-cleanup.ts
|
|
68495
|
+
var import_promises47 = require("fs/promises");
|
|
68496
|
+
var import_node_path41 = require("path");
|
|
68497
|
+
var LEGACY_FOLDER = /--(?:alan-(?:production|staging|local(?:-[0-9a-f]{12})?)|[0-9a-f]{8})$/;
|
|
68498
|
+
var MANAGED_MARKER = ".alan-managed.json";
|
|
68499
|
+
var COMPATIBILITY_MARKER = ".alan-compatibility.json";
|
|
68500
|
+
async function listEntries(directory) {
|
|
68501
|
+
return (0, import_promises47.readdir)(directory, { withFileTypes: true }).catch(() => []);
|
|
68502
|
+
}
|
|
68503
|
+
async function isRegularFile(path4) {
|
|
68504
|
+
return (0, import_promises47.lstat)(path4).then(
|
|
68505
|
+
(stats) => stats.isFile(),
|
|
68506
|
+
() => false
|
|
68507
|
+
);
|
|
68508
|
+
}
|
|
68509
|
+
async function isMissing(path4) {
|
|
68510
|
+
try {
|
|
68511
|
+
await (0, import_promises47.lstat)(path4);
|
|
68512
|
+
return false;
|
|
68513
|
+
} catch (error62) {
|
|
68514
|
+
return errnoCode(error62) === "ENOENT";
|
|
68515
|
+
}
|
|
68516
|
+
}
|
|
68517
|
+
async function removeLink(path4) {
|
|
68518
|
+
try {
|
|
68519
|
+
await (0, import_promises47.unlink)(path4);
|
|
68520
|
+
} catch (error62) {
|
|
68521
|
+
const code = errnoCode(error62);
|
|
68522
|
+
if (code !== "EPERM" && code !== "EISDIR") throw error62;
|
|
68523
|
+
await (0, import_promises47.rmdir)(path4);
|
|
68524
|
+
}
|
|
68525
|
+
}
|
|
68526
|
+
async function isOrphanedLegacyLink(agentsDir, path4, removed) {
|
|
68527
|
+
const target = await (0, import_promises47.readlink)(path4).catch(() => null);
|
|
68528
|
+
if (target === null) return false;
|
|
68529
|
+
const absolute = (0, import_node_path41.resolve)((0, import_node_path41.dirname)(path4), target);
|
|
68530
|
+
return (0, import_node_path41.dirname)(absolute) === agentsDir && (removed.has(absolute) || LEGACY_FOLDER.test((0, import_node_path41.basename)(absolute))) && await isMissing(absolute);
|
|
68531
|
+
}
|
|
68532
|
+
async function removeLegacyPackages(agentsDir, attempt2) {
|
|
68533
|
+
const removed = [];
|
|
68534
|
+
for (const entry of await listEntries(agentsDir)) {
|
|
68535
|
+
const path4 = (0, import_node_path41.join)(agentsDir, entry.name);
|
|
68536
|
+
if (!entry.isDirectory() || !await isRegularFile((0, import_node_path41.join)(path4, MANAGED_MARKER))) continue;
|
|
68537
|
+
if (await attempt2(path4, () => (0, import_promises47.rm)(path4, { recursive: true, force: true }))) removed.push(path4);
|
|
68538
|
+
}
|
|
68539
|
+
return removed;
|
|
68540
|
+
}
|
|
68541
|
+
async function isLegacyClaudeEntry(agentsDir, path4, entry, removed) {
|
|
68542
|
+
if (entry.isSymbolicLink()) return isOrphanedLegacyLink(agentsDir, path4, removed);
|
|
68543
|
+
return entry.isDirectory() && isRegularFile((0, import_node_path41.join)(path4, COMPATIBILITY_MARKER));
|
|
68544
|
+
}
|
|
68545
|
+
async function removeLegacyClaudeEntries(claudeDir, agentsDir, removedPackages, attempt2) {
|
|
68546
|
+
const removedSet = new Set(removedPackages);
|
|
68547
|
+
const removed = [];
|
|
68548
|
+
for (const entry of await listEntries(claudeDir)) {
|
|
68549
|
+
const path4 = (0, import_node_path41.join)(claudeDir, entry.name);
|
|
68550
|
+
if (!await isLegacyClaudeEntry(agentsDir, path4, entry, removedSet)) continue;
|
|
68551
|
+
const remove = entry.isSymbolicLink() ? () => removeLink(path4) : () => (0, import_promises47.rm)(path4, { recursive: true, force: true });
|
|
68552
|
+
if (await attempt2(path4, remove)) removed.push(path4);
|
|
68553
|
+
}
|
|
68554
|
+
return removed;
|
|
68555
|
+
}
|
|
68556
|
+
async function removeLegacySkillFolders(home) {
|
|
68557
|
+
const failed = [];
|
|
68558
|
+
const attempt2 = async (path4, work) => {
|
|
68559
|
+
try {
|
|
68560
|
+
await work();
|
|
68561
|
+
return true;
|
|
68562
|
+
} catch {
|
|
68563
|
+
failed.push(path4);
|
|
68564
|
+
return false;
|
|
68565
|
+
}
|
|
68566
|
+
};
|
|
68567
|
+
const agentsDir = (0, import_node_path41.join)(home, ".agents", "skills");
|
|
68568
|
+
const packages = await removeLegacyPackages(agentsDir, attempt2);
|
|
68569
|
+
const links = await removeLegacyClaudeEntries(
|
|
68570
|
+
(0, import_node_path41.join)(home, ".claude", "skills"),
|
|
68571
|
+
agentsDir,
|
|
68572
|
+
packages,
|
|
68573
|
+
attempt2
|
|
68574
|
+
);
|
|
68575
|
+
const profiles = (0, import_node_path41.join)(home, ".alan", "skills", "profiles");
|
|
68576
|
+
const profilesRemoved = !await isMissing(profiles) && await attempt2(profiles, () => (0, import_promises47.rm)(profiles, { recursive: true, force: true }));
|
|
68577
|
+
return { packages, links, profilesRemoved, failed };
|
|
68578
|
+
}
|
|
68579
|
+
|
|
68407
68580
|
// src/capabilities/skills/local-preview.ts
|
|
68408
|
-
var
|
|
68409
|
-
var
|
|
68581
|
+
var import_promises52 = require("fs/promises");
|
|
68582
|
+
var import_node_path46 = __toESM(require("path"));
|
|
68410
68583
|
|
|
68411
68584
|
// ../shared/dist/node/skill-package.js
|
|
68412
68585
|
var import_node_buffer = require("buffer");
|
|
68413
68586
|
var import_node_crypto21 = require("crypto");
|
|
68414
|
-
var
|
|
68415
|
-
var
|
|
68587
|
+
var import_promises48 = require("fs/promises");
|
|
68588
|
+
var import_node_path42 = require("path");
|
|
68416
68589
|
var import_yaml = __toESM(require_dist(), 1);
|
|
68417
68590
|
init_contracts();
|
|
68418
68591
|
init_domain();
|
|
@@ -68483,7 +68656,7 @@ async function inspectSkillPackage(packageRoot, options = {}) {
|
|
|
68483
68656
|
}
|
|
68484
68657
|
const inspectedFiles = await Promise.all(files.map(readPackageFile));
|
|
68485
68658
|
inspectedFiles.sort(comparePackageFiles);
|
|
68486
|
-
const parsedMetadata = parseSkillMetadata(inspectedFiles.find((file2) => file2.manifest.path === "SKILL.md")?.bytes, options.expectedName === void 0 ? (0,
|
|
68659
|
+
const parsedMetadata = parseSkillMetadata(inspectedFiles.find((file2) => file2.manifest.path === "SKILL.md")?.bytes, options.expectedName === void 0 ? (0, import_node_path42.basename)(root) : options.expectedName);
|
|
68487
68660
|
const manifestFiles = inspectedFiles.map((file2) => file2.manifest);
|
|
68488
68661
|
const diagnostics = [
|
|
68489
68662
|
...parsedMetadata.conformance,
|
|
@@ -68507,11 +68680,11 @@ async function readSkillPackageFile(packageRoot, path4, expectedSha256) {
|
|
|
68507
68680
|
if (!normalizedPath || normalizedPath !== path4 || normalizedPath.includes("\\") || components.some((component) => !component || component === "." || component === "..")) {
|
|
68508
68681
|
throw new SkillPackageError("INVALID_PATH", `Invalid Skill package path: ${path4}`, path4);
|
|
68509
68682
|
}
|
|
68510
|
-
const absolutePath = await (0,
|
|
68683
|
+
const absolutePath = await (0, import_promises48.realpath)((0, import_node_path42.resolve)(root, ...components)).catch(() => null);
|
|
68511
68684
|
if (!absolutePath || normalizeRelativePath(root, absolutePath) !== normalizedPath) {
|
|
68512
68685
|
throw new SkillPackageError("INVALID_PATH", `Skill package file was not found: ${path4}`, path4);
|
|
68513
68686
|
}
|
|
68514
|
-
const entryStat = await (0,
|
|
68687
|
+
const entryStat = await (0, import_promises48.lstat)(absolutePath);
|
|
68515
68688
|
if (!entryStat.isFile()) {
|
|
68516
68689
|
throw new SkillPackageError("SPECIAL_FILE_BLOCKED", `Only regular files are allowed in Skill packages: ${path4}`, path4);
|
|
68517
68690
|
}
|
|
@@ -68528,11 +68701,11 @@ async function readSkillPackageFile(packageRoot, path4, expectedSha256) {
|
|
|
68528
68701
|
return { file: read.manifest, bytes: read.bytes };
|
|
68529
68702
|
}
|
|
68530
68703
|
async function requirePackageRoot(packageRoot) {
|
|
68531
|
-
const root = await (0,
|
|
68704
|
+
const root = await (0, import_promises48.realpath)((0, import_node_path42.resolve)(packageRoot)).catch(() => null);
|
|
68532
68705
|
if (!root) {
|
|
68533
68706
|
throw new SkillPackageError("INVALID_PACKAGE_ROOT", "Skill package directory does not exist");
|
|
68534
68707
|
}
|
|
68535
|
-
const rootStat = await (0,
|
|
68708
|
+
const rootStat = await (0, import_promises48.lstat)(root);
|
|
68536
68709
|
if (!rootStat.isDirectory()) {
|
|
68537
68710
|
throw new SkillPackageError("INVALID_PACKAGE_ROOT", "Skill package root must be a directory");
|
|
68538
68711
|
}
|
|
@@ -68552,13 +68725,13 @@ async function walkPackage(root, ignoredPaths) {
|
|
|
68552
68725
|
}
|
|
68553
68726
|
return files;
|
|
68554
68727
|
async function walkDirectory(directory) {
|
|
68555
|
-
const entries = await (0,
|
|
68728
|
+
const entries = await (0, import_promises48.readdir)(directory, { withFileTypes: true });
|
|
68556
68729
|
for (const entry of entries) {
|
|
68557
|
-
const absolutePath = (0,
|
|
68730
|
+
const absolutePath = (0, import_node_path42.resolve)(directory, entry.name);
|
|
68558
68731
|
const normalizedPath = normalizeRelativePath(root, absolutePath);
|
|
68559
68732
|
if (isIgnored(normalizedPath, entry.name, entry.isDirectory(), ignored2))
|
|
68560
68733
|
continue;
|
|
68561
|
-
const entryStat = await (0,
|
|
68734
|
+
const entryStat = await (0, import_promises48.lstat)(absolutePath);
|
|
68562
68735
|
if (entryStat.isSymbolicLink()) {
|
|
68563
68736
|
throw new SkillPackageError("SYMLINK_BLOCKED", `Nested symbolic links are not allowed in Skill packages: ${normalizedPath}`, normalizedPath);
|
|
68564
68737
|
}
|
|
@@ -68591,10 +68764,10 @@ function createIgnoreMatcher(path4) {
|
|
|
68591
68764
|
const expression = globToRegExp(pattern);
|
|
68592
68765
|
return (candidate) => expression.test(candidate) || expression.test(`${candidate}/`);
|
|
68593
68766
|
}
|
|
68594
|
-
function isIgnored(normalizedPath,
|
|
68595
|
-
if (isDirectory5 && ALWAYS_IGNORED_DIRECTORIES.has(
|
|
68767
|
+
function isIgnored(normalizedPath, basename12, isDirectory5, configured) {
|
|
68768
|
+
if (isDirectory5 && ALWAYS_IGNORED_DIRECTORIES.has(basename12))
|
|
68596
68769
|
return true;
|
|
68597
|
-
if (!isDirectory5 && ALWAYS_IGNORED_FILES.has(
|
|
68770
|
+
if (!isDirectory5 && ALWAYS_IGNORED_FILES.has(basename12))
|
|
68598
68771
|
return true;
|
|
68599
68772
|
return configured.some((matches) => matches(normalizedPath));
|
|
68600
68773
|
}
|
|
@@ -68621,12 +68794,12 @@ function globToRegExp(pattern) {
|
|
|
68621
68794
|
return new RegExp(`${source}(?:/.*)?$`);
|
|
68622
68795
|
}
|
|
68623
68796
|
function normalizeRelativePath(root, absolutePath) {
|
|
68624
|
-
const nativeRelativePath = (0,
|
|
68625
|
-
if (!nativeRelativePath || nativeRelativePath.startsWith(`..${
|
|
68797
|
+
const nativeRelativePath = (0, import_node_path42.relative)(root, absolutePath);
|
|
68798
|
+
if (!nativeRelativePath || nativeRelativePath.startsWith(`..${import_node_path42.sep}`) || nativeRelativePath === "..") {
|
|
68626
68799
|
throw new SkillPackageError("INVALID_PATH", "Skill package path escapes its root");
|
|
68627
68800
|
}
|
|
68628
|
-
const normalized2 = nativeRelativePath.split(
|
|
68629
|
-
if (normalized2.includes("\0") || normalized2.includes("\uFFFD") ||
|
|
68801
|
+
const normalized2 = nativeRelativePath.split(import_node_path42.sep).join("/").normalize("NFC");
|
|
68802
|
+
if (normalized2.includes("\0") || normalized2.includes("\uFFFD") || import_node_path42.posix.isAbsolute(normalized2)) {
|
|
68630
68803
|
throw new SkillPackageError("INVALID_PATH", `Invalid Skill package path: ${normalized2}`);
|
|
68631
68804
|
}
|
|
68632
68805
|
return normalized2;
|
|
@@ -68661,13 +68834,13 @@ function requireSafeFile(path4, size, normalizedPaths) {
|
|
|
68661
68834
|
}
|
|
68662
68835
|
}
|
|
68663
68836
|
function isSecretPath(path4) {
|
|
68664
|
-
const name =
|
|
68837
|
+
const name = import_node_path42.posix.basename(path4).toLowerCase();
|
|
68665
68838
|
if (SECRET_BASENAMES.has(name) || name.startsWith(".env."))
|
|
68666
68839
|
return true;
|
|
68667
68840
|
return name.endsWith(".private-key.pem") || name.endsWith(".private-key.key");
|
|
68668
68841
|
}
|
|
68669
68842
|
async function readPackageFile(file2) {
|
|
68670
|
-
const bytes = await (0,
|
|
68843
|
+
const bytes = await (0, import_promises48.readFile)(file2.absolutePath);
|
|
68671
68844
|
return {
|
|
68672
68845
|
bytes,
|
|
68673
68846
|
manifest: {
|
|
@@ -68689,12 +68862,12 @@ function classifyFileKind(path4) {
|
|
|
68689
68862
|
return "reference";
|
|
68690
68863
|
if (path4.startsWith("assets/"))
|
|
68691
68864
|
return "asset";
|
|
68692
|
-
if (/^(?:licen[cs]e|copying|notice)(?:\.|$)/i.test(
|
|
68865
|
+
if (/^(?:licen[cs]e|copying|notice)(?:\.|$)/i.test(import_node_path42.posix.basename(path4)))
|
|
68693
68866
|
return "license";
|
|
68694
68867
|
return "other";
|
|
68695
68868
|
}
|
|
68696
68869
|
function classifyPreview(path4, bytes) {
|
|
68697
|
-
const extension =
|
|
68870
|
+
const extension = import_node_path42.posix.extname(path4).toLowerCase();
|
|
68698
68871
|
if (IMAGE_EXTENSIONS2.has(extension))
|
|
68699
68872
|
return "image";
|
|
68700
68873
|
if (bytes.includes(0))
|
|
@@ -68764,13 +68937,14 @@ function decodeUtf8(bytes, path4) {
|
|
|
68764
68937
|
throw new SkillPackageError("INVALID_FRONTMATTER", `${path4} must be valid UTF-8`, path4);
|
|
68765
68938
|
}
|
|
68766
68939
|
}
|
|
68940
|
+
var MARKDOWN_LINK_TARGET = /\]\(<?([^\s)>\]]+)>?(?=[\s)])/g;
|
|
68767
68941
|
function collectDiagnostics(skillMarkdown, license, packagePaths) {
|
|
68768
68942
|
if (!skillMarkdown)
|
|
68769
68943
|
return [];
|
|
68770
68944
|
const diagnostics = [];
|
|
68771
68945
|
const markdown = decodeUtf8(skillMarkdown, "SKILL.md");
|
|
68772
68946
|
const references = /* @__PURE__ */ new Set();
|
|
68773
|
-
for (const match of markdown.matchAll(
|
|
68947
|
+
for (const match of markdown.matchAll(MARKDOWN_LINK_TARGET)) {
|
|
68774
68948
|
const reference = normalizePackageReference(match[1]);
|
|
68775
68949
|
if (reference && looksLikeFileReference(reference))
|
|
68776
68950
|
references.add(reference);
|
|
@@ -68798,7 +68972,7 @@ function normalizePackageReference(value2) {
|
|
|
68798
68972
|
const withoutSuffix = trimmed4.split(/[?#]/, 1)[0];
|
|
68799
68973
|
if (!withoutSuffix)
|
|
68800
68974
|
return null;
|
|
68801
|
-
const normalized2 =
|
|
68975
|
+
const normalized2 = import_node_path42.posix.normalize(withoutSuffix).replace(/^\.\//, "").normalize("NFC");
|
|
68802
68976
|
if (normalized2 === ".." || normalized2.startsWith("../"))
|
|
68803
68977
|
return null;
|
|
68804
68978
|
return normalized2;
|
|
@@ -68838,14 +69012,14 @@ function uint642(value2) {
|
|
|
68838
69012
|
|
|
68839
69013
|
// src/capabilities/skills/local-sources.ts
|
|
68840
69014
|
var import_node_crypto23 = require("crypto");
|
|
68841
|
-
var
|
|
68842
|
-
var
|
|
69015
|
+
var import_promises50 = require("fs/promises");
|
|
69016
|
+
var import_node_path44 = __toESM(require("path"));
|
|
68843
69017
|
init_type_guards();
|
|
68844
69018
|
|
|
68845
69019
|
// src/capabilities/skills/local-scan.ts
|
|
68846
69020
|
var import_node_crypto22 = require("crypto");
|
|
68847
|
-
var
|
|
68848
|
-
var
|
|
69021
|
+
var import_promises49 = require("fs/promises");
|
|
69022
|
+
var import_node_path43 = __toESM(require("path"));
|
|
68849
69023
|
var MAX_CANDIDATES = 2e3;
|
|
68850
69024
|
var MAX_DIAGNOSTICS = 100;
|
|
68851
69025
|
function createLocalSkillScanCache() {
|
|
@@ -68964,8 +69138,8 @@ function invalid(resolvedRoot, name, error62) {
|
|
|
68964
69138
|
};
|
|
68965
69139
|
}
|
|
68966
69140
|
async function scanRootAsPackage(pass, resolvedRoot) {
|
|
68967
|
-
if (!await exists3(
|
|
68968
|
-
const canonical = await (0,
|
|
69141
|
+
if (!await exists3(import_node_path43.default.join(resolvedRoot.directory, "SKILL.md"))) return null;
|
|
69142
|
+
const canonical = await (0, import_promises49.realpath)(resolvedRoot.directory).catch(() => resolvedRoot.directory);
|
|
68969
69143
|
if (isManaged(pass, canonical)) return { candidates: [], diagnostics: [], incomplete: false };
|
|
68970
69144
|
try {
|
|
68971
69145
|
const inspected = await inspectCached(pass, canonical, null);
|
|
@@ -68973,7 +69147,7 @@ async function scanRootAsPackage(pass, resolvedRoot) {
|
|
|
68973
69147
|
candidates: [
|
|
68974
69148
|
locate(
|
|
68975
69149
|
resolvedRoot,
|
|
68976
|
-
{ key: inspected.metadata.name, order:
|
|
69150
|
+
{ key: inspected.metadata.name, order: import_node_path43.default.basename(canonical) },
|
|
68977
69151
|
canonical,
|
|
68978
69152
|
canonical,
|
|
68979
69153
|
inspected
|
|
@@ -68985,7 +69159,7 @@ async function scanRootAsPackage(pass, resolvedRoot) {
|
|
|
68985
69159
|
} catch (error62) {
|
|
68986
69160
|
return {
|
|
68987
69161
|
candidates: [],
|
|
68988
|
-
diagnostics: [invalid(resolvedRoot,
|
|
69162
|
+
diagnostics: [invalid(resolvedRoot, import_node_path43.default.basename(canonical), error62)],
|
|
68989
69163
|
incomplete: false
|
|
68990
69164
|
};
|
|
68991
69165
|
}
|
|
@@ -68995,7 +69169,7 @@ async function scanRoot(pass, resolvedRoot) {
|
|
|
68995
69169
|
if (asPackage !== null) return asPackage;
|
|
68996
69170
|
let entries;
|
|
68997
69171
|
try {
|
|
68998
|
-
entries = await (0,
|
|
69172
|
+
entries = await (0, import_promises49.readdir)(resolvedRoot.directory, { withFileTypes: true });
|
|
68999
69173
|
} catch (error62) {
|
|
69000
69174
|
const code = errnoCode(error62);
|
|
69001
69175
|
if (code === "ENOENT" || code === "ENOTDIR") {
|
|
@@ -69013,7 +69187,7 @@ async function scanRoot(pass, resolvedRoot) {
|
|
|
69013
69187
|
incomplete: true
|
|
69014
69188
|
};
|
|
69015
69189
|
}
|
|
69016
|
-
const canonicalRoot = await (0,
|
|
69190
|
+
const canonicalRoot = await (0, import_promises49.realpath)(resolvedRoot.directory).catch(() => resolvedRoot.directory);
|
|
69017
69191
|
const scan = { candidates: [], diagnostics: [], incomplete: false };
|
|
69018
69192
|
for (const entry of entries) {
|
|
69019
69193
|
if (!entry.isDirectory() && !entry.isSymbolicLink()) continue;
|
|
@@ -69025,7 +69199,7 @@ async function scanRoot(pass, resolvedRoot) {
|
|
|
69025
69199
|
}
|
|
69026
69200
|
async function scanEntry(pass, resolvedRoot, canonicalRoot, name) {
|
|
69027
69201
|
const rootLabel = resolvedRoot.root.label;
|
|
69028
|
-
const canonical = await (0,
|
|
69202
|
+
const canonical = await (0, import_promises49.realpath)(import_node_path43.default.join(resolvedRoot.directory, name)).catch(() => null);
|
|
69029
69203
|
if (canonical === null) {
|
|
69030
69204
|
const message2 = `Could not resolve Skill ${name}`;
|
|
69031
69205
|
return { kind: "diagnostic", diagnostic: { code: "SOURCE_UNREADABLE", message: message2, rootLabel } };
|
|
@@ -69041,7 +69215,7 @@ async function scanEntry(pass, resolvedRoot, canonicalRoot, name) {
|
|
|
69041
69215
|
}
|
|
69042
69216
|
if (!await isDirectory3(canonical) || pass.visited.has(canonical)) return null;
|
|
69043
69217
|
pass.visited.add(canonical);
|
|
69044
|
-
if (await exists3(
|
|
69218
|
+
if (await exists3(import_node_path43.default.join(canonical, ".alan-managed.json"))) return null;
|
|
69045
69219
|
try {
|
|
69046
69220
|
const inspected = await inspectCached(pass, canonical, void 0);
|
|
69047
69221
|
const names = { key: name, order: name };
|
|
@@ -69062,7 +69236,7 @@ function resolveScanRoots(roots, enabledProviderKinds) {
|
|
|
69062
69236
|
).entries()) {
|
|
69063
69237
|
resolved.push({
|
|
69064
69238
|
root,
|
|
69065
|
-
directory:
|
|
69239
|
+
directory: import_node_path43.default.join(root.path, relative6),
|
|
69066
69240
|
order: `1:${root.repositoryId}:${String(index).padStart(2, "0")}`
|
|
69067
69241
|
});
|
|
69068
69242
|
}
|
|
@@ -69110,12 +69284,12 @@ function deduplicateByContent(candidates2) {
|
|
|
69110
69284
|
async function fingerprintPackage(root) {
|
|
69111
69285
|
const hash2 = (0, import_node_crypto22.createHash)("sha256").update("alan-skill-stat-fingerprint-v1\0");
|
|
69112
69286
|
const visit2 = async (directory, relativeDirectory) => {
|
|
69113
|
-
const entries = await (0,
|
|
69287
|
+
const entries = await (0, import_promises49.readdir)(directory, { withFileTypes: true });
|
|
69114
69288
|
entries.sort((left, right) => Buffer.compare(Buffer.from(left.name), Buffer.from(right.name)));
|
|
69115
69289
|
for (const entry of entries) {
|
|
69116
69290
|
const relative6 = relativeDirectory ? `${relativeDirectory}/${entry.name}` : entry.name;
|
|
69117
|
-
const absolute =
|
|
69118
|
-
const metadata = await (0,
|
|
69291
|
+
const absolute = import_node_path43.default.join(directory, entry.name);
|
|
69292
|
+
const metadata = await (0, import_promises49.lstat)(absolute);
|
|
69119
69293
|
const kind = entryKind(entry);
|
|
69120
69294
|
hash2.update(relative6.normalize("NFC")).update(`\0${kind}\0${metadata.size}\0${metadata.mtimeMs}\0${metadata.mode & 511}\0`);
|
|
69121
69295
|
if (entry.isDirectory()) await visit2(absolute, relative6);
|
|
@@ -69131,7 +69305,7 @@ function entryKind(entry) {
|
|
|
69131
69305
|
}
|
|
69132
69306
|
async function canonicalDirectories(directories) {
|
|
69133
69307
|
const canonical = await Promise.all(
|
|
69134
|
-
directories.map((directory) => (0,
|
|
69308
|
+
directories.map((directory) => (0, import_promises49.realpath)(directory).catch(() => directory))
|
|
69135
69309
|
);
|
|
69136
69310
|
return [...new Set(canonical)];
|
|
69137
69311
|
}
|
|
@@ -69139,12 +69313,12 @@ function isManaged(pass, canonical) {
|
|
|
69139
69313
|
return pass.managedRoots.some((root) => isWithinDirectory2(root, canonical));
|
|
69140
69314
|
}
|
|
69141
69315
|
function isWithinDirectory2(parent, candidate) {
|
|
69142
|
-
const relative6 =
|
|
69143
|
-
return relative6 !== ".." && !relative6.startsWith(`..${
|
|
69316
|
+
const relative6 = import_node_path43.default.relative(parent, candidate);
|
|
69317
|
+
return relative6 !== ".." && !relative6.startsWith(`..${import_node_path43.default.sep}`) && !import_node_path43.default.isAbsolute(relative6);
|
|
69144
69318
|
}
|
|
69145
69319
|
async function exists3(candidate) {
|
|
69146
69320
|
try {
|
|
69147
|
-
await (0,
|
|
69321
|
+
await (0, import_promises49.access)(candidate);
|
|
69148
69322
|
return true;
|
|
69149
69323
|
} catch {
|
|
69150
69324
|
return false;
|
|
@@ -69152,7 +69326,7 @@ async function exists3(candidate) {
|
|
|
69152
69326
|
}
|
|
69153
69327
|
async function isDirectory3(candidate) {
|
|
69154
69328
|
try {
|
|
69155
|
-
return (await (0,
|
|
69329
|
+
return (await (0, import_promises49.lstat)(candidate)).isDirectory();
|
|
69156
69330
|
} catch {
|
|
69157
69331
|
return false;
|
|
69158
69332
|
}
|
|
@@ -69200,7 +69374,7 @@ label = "OpenCode skills"
|
|
|
69200
69374
|
providers = ["opencode_serve"]
|
|
69201
69375
|
`;
|
|
69202
69376
|
function skillSourceConfigPath(home) {
|
|
69203
|
-
return
|
|
69377
|
+
return import_node_path44.default.join(home, ".alan", "config.toml");
|
|
69204
69378
|
}
|
|
69205
69379
|
async function resolveLocalScanInput(home, context, mode) {
|
|
69206
69380
|
const loaded = await readSkillSourceConfig(home);
|
|
@@ -69212,13 +69386,13 @@ async function resolveLocalScanInput(home, context, mode) {
|
|
|
69212
69386
|
}
|
|
69213
69387
|
const enabledProviderKinds = context?.enabledProviderKinds ?? [];
|
|
69214
69388
|
const enabled = new Set(enabledProviderKinds);
|
|
69215
|
-
const drafts =
|
|
69389
|
+
const drafts = import_node_path44.default.resolve(import_node_path44.default.join(home, ".alan", "skill-sources"));
|
|
69216
69390
|
const roots = [];
|
|
69217
69391
|
for (const source of config2.sources) {
|
|
69218
69392
|
const owners = source.providerKinds;
|
|
69219
69393
|
if (owners !== void 0 && !owners.some((provider4) => enabled.has(provider4))) continue;
|
|
69220
69394
|
roots.push(
|
|
69221
|
-
|
|
69395
|
+
import_node_path44.default.resolve(source.path) === drafts ? { kind: "drafts", path: source.path, label: "Alan drafts" } : {
|
|
69222
69396
|
kind: "configured",
|
|
69223
69397
|
declarationId: source.declarationId,
|
|
69224
69398
|
path: source.path,
|
|
@@ -69240,7 +69414,7 @@ async function resolveLocalScanInput(home, context, mode) {
|
|
|
69240
69414
|
async function readSkillSourceConfig(home) {
|
|
69241
69415
|
let content;
|
|
69242
69416
|
try {
|
|
69243
|
-
content = await (0,
|
|
69417
|
+
content = await (0, import_promises50.readFile)(skillSourceConfigPath(home), "utf8");
|
|
69244
69418
|
} catch (error62) {
|
|
69245
69419
|
if (errnoCode(error62) !== "ENOENT") {
|
|
69246
69420
|
return { kind: "invalid_config", diagnostic: "~/.alan/config.toml could not be read" };
|
|
@@ -69282,7 +69456,7 @@ function parseSkillSourceConfig(content, home) {
|
|
|
69282
69456
|
const label = value2.label.trim();
|
|
69283
69457
|
if (!label) throw new Error(`skills.sources entry ${index + 1} has an empty label`);
|
|
69284
69458
|
const declarationId = value2.id === void 0 ? stableSourceDeclarationId(sourcePath) : requiredSourceId(value2.id, `skills.sources[${index}].id`);
|
|
69285
|
-
const relativeDirectory =
|
|
69459
|
+
const relativeDirectory = import_node_path44.default.relative(home, sourcePath);
|
|
69286
69460
|
const inferred = providerKindsForUserDirectory(relativeDirectory);
|
|
69287
69461
|
const declared = value2.providers === void 0 ? inferred : [
|
|
69288
69462
|
...new Set(
|
|
@@ -69325,12 +69499,12 @@ function requiredSourceId(value2, field3) {
|
|
|
69325
69499
|
}
|
|
69326
69500
|
function resolveSkillSourcePath(sourcePath, home) {
|
|
69327
69501
|
const trimmed4 = sourcePath.trim();
|
|
69328
|
-
if (trimmed4 === "~") return
|
|
69502
|
+
if (trimmed4 === "~") return import_node_path44.default.resolve(home);
|
|
69329
69503
|
if (trimmed4.startsWith("~/") || trimmed4.startsWith("~\\")) {
|
|
69330
69504
|
const components = trimmed4.slice(2).split(/[\\/]+/).filter(Boolean);
|
|
69331
|
-
return
|
|
69505
|
+
return import_node_path44.default.resolve(import_node_path44.default.join(home, ...components));
|
|
69332
69506
|
}
|
|
69333
|
-
return
|
|
69507
|
+
return import_node_path44.default.isAbsolute(trimmed4) ? import_node_path44.default.resolve(trimmed4) : import_node_path44.default.resolve(home, trimmed4);
|
|
69334
69508
|
}
|
|
69335
69509
|
function optionalBoolean(value2, fallback, field3) {
|
|
69336
69510
|
if (value2 === void 0) return fallback;
|
|
@@ -69357,8 +69531,8 @@ async function scanLocalSkills(home, context, cache2, mode = "incremental", mana
|
|
|
69357
69531
|
}
|
|
69358
69532
|
|
|
69359
69533
|
// src/capabilities/skills/store.ts
|
|
69360
|
-
var
|
|
69361
|
-
var
|
|
69534
|
+
var import_promises51 = require("fs/promises");
|
|
69535
|
+
var import_node_path45 = require("path");
|
|
69362
69536
|
|
|
69363
69537
|
// ../shared/dist/node/alan-skill-identity.js
|
|
69364
69538
|
var import_node_crypto24 = require("crypto");
|
|
@@ -69381,21 +69555,21 @@ function alanSkillVersionId(slug, contentHash) {
|
|
|
69381
69555
|
init_runtime_v2();
|
|
69382
69556
|
init_zod();
|
|
69383
69557
|
function skillsLayout(stateDir, home) {
|
|
69384
|
-
const root = (0,
|
|
69558
|
+
const root = (0, import_node_path45.join)(stateDir, "skills");
|
|
69385
69559
|
return {
|
|
69386
69560
|
root,
|
|
69387
|
-
installedFile: (0,
|
|
69388
|
-
retiredFile: (0,
|
|
69389
|
-
localFile: (0,
|
|
69390
|
-
versionsDir: (0,
|
|
69391
|
-
tmpDir: (0,
|
|
69392
|
-
pluginDir: (0,
|
|
69393
|
-
pluginSkillsDir: (0,
|
|
69394
|
-
nativeDir: home === void 0 || home === "" ? null : (0,
|
|
69561
|
+
installedFile: (0, import_node_path45.join)(root, "installed.json"),
|
|
69562
|
+
retiredFile: (0, import_node_path45.join)(root, "retired.json"),
|
|
69563
|
+
localFile: (0, import_node_path45.join)(root, "local.json"),
|
|
69564
|
+
versionsDir: (0, import_node_path45.join)(root, "versions"),
|
|
69565
|
+
tmpDir: (0, import_node_path45.join)(root, "tmp"),
|
|
69566
|
+
pluginDir: (0, import_node_path45.join)(root, "alan-plugin"),
|
|
69567
|
+
pluginSkillsDir: (0, import_node_path45.join)(root, "alan-plugin", "skills"),
|
|
69568
|
+
nativeDir: home === void 0 || home === "" ? null : (0, import_node_path45.join)(home, ".agents", "skills")
|
|
69395
69569
|
};
|
|
69396
69570
|
}
|
|
69397
69571
|
function packageDirectory(layout, versionId) {
|
|
69398
|
-
return (0,
|
|
69572
|
+
return (0, import_node_path45.join)(layout.versionsDir, versionId);
|
|
69399
69573
|
}
|
|
69400
69574
|
var installedFileSchema = external_exports.object({ skills: external_exports.array(desiredMachineSkillSchema) });
|
|
69401
69575
|
async function readInstalledSkills(layout) {
|
|
@@ -69428,7 +69602,7 @@ function writeLocalSkills(layout, file2) {
|
|
|
69428
69602
|
async function isLocalSkillCurrent(entry, contentHash, ignoredPaths) {
|
|
69429
69603
|
if (entry.contentHash !== contentHash) return false;
|
|
69430
69604
|
try {
|
|
69431
|
-
if (await (0,
|
|
69605
|
+
if (await (0, import_promises51.realpath)(entry.path) !== entry.path) return false;
|
|
69432
69606
|
const inspected = await inspectSkillPackage(entry.path, { expectedName: null, ignoredPaths });
|
|
69433
69607
|
return inspected.contentHash === contentHash;
|
|
69434
69608
|
} catch {
|
|
@@ -69443,7 +69617,7 @@ async function resolveLocalSkill(local, invocation) {
|
|
|
69443
69617
|
}
|
|
69444
69618
|
async function hasSkillFile(directory) {
|
|
69445
69619
|
try {
|
|
69446
|
-
return (await (0,
|
|
69620
|
+
return (await (0, import_promises51.stat)((0, import_node_path45.join)(directory, "SKILL.md"))).isFile();
|
|
69447
69621
|
} catch {
|
|
69448
69622
|
return false;
|
|
69449
69623
|
}
|
|
@@ -69461,7 +69635,7 @@ async function isIntact(layout, skill) {
|
|
|
69461
69635
|
async function resolveNativeBuiltIn(layout, invocation, baked) {
|
|
69462
69636
|
const slug = invocation.displayName;
|
|
69463
69637
|
if (layout.nativeDir === null || invocation.skillId !== alanSkillId(slug)) return null;
|
|
69464
|
-
const directory = (0,
|
|
69638
|
+
const directory = (0, import_node_path45.join)(layout.nativeDir, slug);
|
|
69465
69639
|
try {
|
|
69466
69640
|
const inspected = await inspectSkillPackage(directory, { expectedName: slug });
|
|
69467
69641
|
if (baked === "exact" && alanSkillVersionId(slug, inspected.contentHash) !== invocation.versionId)
|
|
@@ -69497,22 +69671,21 @@ async function resolveSkillInvocations(layout, invocations, baked = "any") {
|
|
|
69497
69671
|
}
|
|
69498
69672
|
return missing.length === 0 ? { kind: "resolved", skills: resolved } : { kind: "missing", names: missing };
|
|
69499
69673
|
}
|
|
69500
|
-
async function
|
|
69674
|
+
async function nativeCandidates(layout) {
|
|
69675
|
+
const nativeDir = layout.nativeDir;
|
|
69676
|
+
if (nativeDir === null) return [];
|
|
69677
|
+
const entries = await (0, import_promises51.readdir)(nativeDir, { withFileTypes: true }).catch(() => []);
|
|
69678
|
+
return entries.filter((entry) => entry.isDirectory() || entry.isSymbolicLink()).map((entry) => ({ directory: (0, import_node_path45.join)(nativeDir, entry.name) }));
|
|
69679
|
+
}
|
|
69680
|
+
async function availableSkillIndex(layout, sources = { synced: true, native: true }) {
|
|
69501
69681
|
const found = /* @__PURE__ */ new Map();
|
|
69502
|
-
const
|
|
69503
|
-
|
|
69504
|
-
|
|
69505
|
-
|
|
69506
|
-
|
|
69507
|
-
|
|
69508
|
-
|
|
69509
|
-
if (layout.nativeDir !== null) {
|
|
69510
|
-
const entries = await (0, import_promises50.readdir)(layout.nativeDir, { withFileTypes: true }).catch(() => []);
|
|
69511
|
-
for (const entry of entries) {
|
|
69512
|
-
if (entry.isDirectory() || entry.isSymbolicLink())
|
|
69513
|
-
candidates2.push({ directory: (0, import_node_path44.join)(layout.nativeDir, entry.name) });
|
|
69514
|
-
}
|
|
69515
|
-
}
|
|
69682
|
+
const installed = await readInstalledSkills(layout);
|
|
69683
|
+
const synced = sources.synced ? installed.map((skill) => ({
|
|
69684
|
+
directory: packageDirectory(layout, skill.versionId),
|
|
69685
|
+
contentHash: skill.contentHash
|
|
69686
|
+
})) : [];
|
|
69687
|
+
const shadowed = new Set(sources.synced ? [] : installed.map((skill) => skill.slug));
|
|
69688
|
+
const candidates2 = [...synced, ...sources.native ? await nativeCandidates(layout) : []];
|
|
69516
69689
|
const bounded = candidates2.slice(0, 2e3);
|
|
69517
69690
|
for (let start2 = 0; start2 < bounded.length; start2 += INDEX_CONCURRENCY) {
|
|
69518
69691
|
const batch = bounded.slice(start2, start2 + INDEX_CONCURRENCY);
|
|
@@ -69520,7 +69693,8 @@ async function availableSkillIndex(layout) {
|
|
|
69520
69693
|
batch.map((candidate) => inspectIndexedSkill(candidate.directory, candidate.contentHash))
|
|
69521
69694
|
);
|
|
69522
69695
|
for (const skill of inspected) {
|
|
69523
|
-
if (skill !== null && !found.has(skill.name)
|
|
69696
|
+
if (skill !== null && !found.has(skill.name) && !shadowed.has(skill.name))
|
|
69697
|
+
found.set(skill.name, skill);
|
|
69524
69698
|
}
|
|
69525
69699
|
}
|
|
69526
69700
|
return [...found.values()].sort((a, b) => a.name.localeCompare(b.name));
|
|
@@ -69590,7 +69764,7 @@ async function readLocalSkillFile(layout, ref) {
|
|
|
69590
69764
|
mediaType: file2.path.toLowerCase().endsWith(".md") ? "text/markdown; charset=utf-8" : "text/plain; charset=utf-8"
|
|
69591
69765
|
};
|
|
69592
69766
|
}
|
|
69593
|
-
const mediaType = RASTER_MEDIA_TYPES.get(
|
|
69767
|
+
const mediaType = RASTER_MEDIA_TYPES.get(import_node_path46.default.extname(file2.path).toLowerCase());
|
|
69594
69768
|
if (file2.preview === "image" && mediaType !== void 0) {
|
|
69595
69769
|
return bytes.byteLength <= MAX_INLINE_IMAGE_BYTES ? { file: file2, encoding: "base64", content: bytes.toString("base64"), mediaType } : { file: file2, encoding: "metadata", mediaType };
|
|
69596
69770
|
}
|
|
@@ -69598,7 +69772,7 @@ async function readLocalSkillFile(layout, ref) {
|
|
|
69598
69772
|
}
|
|
69599
69773
|
async function isDirectory4(candidate) {
|
|
69600
69774
|
try {
|
|
69601
|
-
return (await (0,
|
|
69775
|
+
return (await (0, import_promises52.stat)(candidate)).isDirectory();
|
|
69602
69776
|
} catch {
|
|
69603
69777
|
return false;
|
|
69604
69778
|
}
|
|
@@ -69611,21 +69785,21 @@ async function addSkillSource(home, input2) {
|
|
|
69611
69785
|
return { state: "invalid", diagnostic: `${sourcePath} is not a folder` };
|
|
69612
69786
|
}
|
|
69613
69787
|
const configPath = skillSourceConfigPath(home);
|
|
69614
|
-
await (0,
|
|
69615
|
-
await (0,
|
|
69788
|
+
await (0, import_promises52.mkdir)(import_node_path46.default.dirname(configPath), { recursive: true, mode: 448 });
|
|
69789
|
+
await (0, import_promises52.writeFile)(configPath, DEFAULT_SKILL_CONFIG, { flag: "wx", mode: 384 }).catch(
|
|
69616
69790
|
(error62) => {
|
|
69617
69791
|
if (errnoCode(error62) !== "EEXIST") throw error62;
|
|
69618
69792
|
}
|
|
69619
69793
|
);
|
|
69620
69794
|
const loaded = await readSkillSourceConfig(home);
|
|
69621
69795
|
if (loaded.kind === "invalid_config") return { state: "invalid", diagnostic: loaded.diagnostic };
|
|
69622
|
-
const canonical = await (0,
|
|
69796
|
+
const canonical = await (0, import_promises52.realpath)(sourcePath).catch(() => sourcePath);
|
|
69623
69797
|
for (const source of loaded.config.sources) {
|
|
69624
|
-
if (await (0,
|
|
69798
|
+
if (await (0, import_promises52.realpath)(source.path).catch(() => source.path) === canonical) {
|
|
69625
69799
|
return { state: "already_present", label: source.label };
|
|
69626
69800
|
}
|
|
69627
69801
|
}
|
|
69628
|
-
const current = await (0,
|
|
69802
|
+
const current = await (0, import_promises52.readFile)(configPath, "utf8");
|
|
69629
69803
|
const block2 = [
|
|
69630
69804
|
"",
|
|
69631
69805
|
"[[skills.sources]]",
|
|
@@ -69633,7 +69807,7 @@ async function addSkillSource(home, input2) {
|
|
|
69633
69807
|
`label = ${JSON.stringify(label)}`,
|
|
69634
69808
|
""
|
|
69635
69809
|
].join("\n");
|
|
69636
|
-
await (0,
|
|
69810
|
+
await (0, import_promises52.writeFile)(configPath, `${current.replace(/\n*$/, "\n")}${block2}`, { mode: 384 });
|
|
69637
69811
|
const reloaded = await readSkillSourceConfig(home);
|
|
69638
69812
|
if (reloaded.kind === "invalid_config") {
|
|
69639
69813
|
return { state: "invalid", diagnostic: reloaded.diagnostic };
|
|
@@ -69642,13 +69816,13 @@ async function addSkillSource(home, input2) {
|
|
|
69642
69816
|
}
|
|
69643
69817
|
|
|
69644
69818
|
// src/capabilities/skills/local-upload.ts
|
|
69645
|
-
var
|
|
69819
|
+
var import_promises54 = require("fs/promises");
|
|
69646
69820
|
|
|
69647
69821
|
// ../shared/dist/node/skill-bundle.js
|
|
69648
69822
|
var import_node_buffer2 = require("buffer");
|
|
69649
69823
|
var import_node_crypto25 = require("crypto");
|
|
69650
|
-
var
|
|
69651
|
-
var
|
|
69824
|
+
var import_promises53 = require("fs/promises");
|
|
69825
|
+
var import_node_path47 = require("path");
|
|
69652
69826
|
var import_node_stream = require("stream");
|
|
69653
69827
|
var import_node_zlib = require("zlib");
|
|
69654
69828
|
var import_tar_stream = __toESM(require_tar_stream(), 1);
|
|
@@ -69658,7 +69832,7 @@ async function createSkillBundle(packageRoot, options = {}) {
|
|
|
69658
69832
|
const archive = (0, import_tar_stream.pack)();
|
|
69659
69833
|
const tarPromise = collectStream(archive);
|
|
69660
69834
|
for (const file2 of before.files) {
|
|
69661
|
-
const bytes2 = await (0,
|
|
69835
|
+
const bytes2 = await (0, import_promises53.readFile)((0, import_node_path47.join)(packageRoot, ...file2.path.split("/")));
|
|
69662
69836
|
await addArchiveEntry(archive, {
|
|
69663
69837
|
name: file2.path,
|
|
69664
69838
|
type: "file",
|
|
@@ -69690,7 +69864,7 @@ async function extractSkillBundle(archiveBytes, destination, expected) {
|
|
|
69690
69864
|
throw new Error("Skill archive hash does not match the expected immutable Version");
|
|
69691
69865
|
}
|
|
69692
69866
|
const tarBytes = await decompressBounded(archiveBytes);
|
|
69693
|
-
await (0,
|
|
69867
|
+
await (0, import_promises53.mkdir)(destination, { recursive: false, mode: 448 });
|
|
69694
69868
|
try {
|
|
69695
69869
|
await extractTar(tarBytes, destination);
|
|
69696
69870
|
const inspected = await inspectSkillPackage(destination, { expectedName: null });
|
|
@@ -69698,7 +69872,7 @@ async function extractSkillBundle(archiveBytes, destination, expected) {
|
|
|
69698
69872
|
throw new Error("Extracted Skill package hash does not match the expected immutable Version");
|
|
69699
69873
|
}
|
|
69700
69874
|
} catch (error62) {
|
|
69701
|
-
await (0,
|
|
69875
|
+
await (0, import_promises53.rm)(destination, { recursive: true, force: true });
|
|
69702
69876
|
throw error62;
|
|
69703
69877
|
}
|
|
69704
69878
|
}
|
|
@@ -69709,8 +69883,8 @@ async function collectStream(stream) {
|
|
|
69709
69883
|
return import_node_buffer2.Buffer.concat(chunks);
|
|
69710
69884
|
}
|
|
69711
69885
|
function addArchiveEntry(archive, header, bytes) {
|
|
69712
|
-
return new Promise((
|
|
69713
|
-
archive.entry(header, bytes, (error62) => error62 ? reject(error62) :
|
|
69886
|
+
return new Promise((resolve14, reject) => {
|
|
69887
|
+
archive.entry(header, bytes, (error62) => error62 ? reject(error62) : resolve14());
|
|
69714
69888
|
});
|
|
69715
69889
|
}
|
|
69716
69890
|
async function decompressBounded(archiveBytes) {
|
|
@@ -69736,7 +69910,7 @@ async function extractTar(tarBytes, destination) {
|
|
|
69736
69910
|
const extractor = (0, import_tar_stream.extract)();
|
|
69737
69911
|
let fileCount = 0;
|
|
69738
69912
|
let totalBytes = 0;
|
|
69739
|
-
const completion = new Promise((
|
|
69913
|
+
const completion = new Promise((resolve14, reject) => {
|
|
69740
69914
|
extractor.on("entry", (header, stream, next) => {
|
|
69741
69915
|
void extractEntry(header, stream, destination, {
|
|
69742
69916
|
addFile(size) {
|
|
@@ -69751,7 +69925,7 @@ async function extractTar(tarBytes, destination) {
|
|
|
69751
69925
|
}
|
|
69752
69926
|
}).then(next, (error62) => extractor.destroy(error62 instanceof Error ? error62 : new Error(String(error62))));
|
|
69753
69927
|
});
|
|
69754
|
-
extractor.once("finish",
|
|
69928
|
+
extractor.once("finish", resolve14);
|
|
69755
69929
|
extractor.once("error", reject);
|
|
69756
69930
|
});
|
|
69757
69931
|
import_node_stream.Readable.from(tarBytes).pipe(extractor);
|
|
@@ -69773,13 +69947,13 @@ async function extractEntry(header, stream, destination, limits) {
|
|
|
69773
69947
|
if (bytes.byteLength !== declaredSize) {
|
|
69774
69948
|
throw new Error(`Skill archive file size is invalid: ${path4}`);
|
|
69775
69949
|
}
|
|
69776
|
-
const outputPath = (0,
|
|
69777
|
-
await (0,
|
|
69778
|
-
await (0,
|
|
69950
|
+
const outputPath = (0, import_node_path47.join)(destination, ...path4.split("/"));
|
|
69951
|
+
await (0, import_promises53.mkdir)((0, import_node_path47.dirname)(outputPath), { recursive: true, mode: 448 });
|
|
69952
|
+
await (0, import_promises53.writeFile)(outputPath, bytes, { mode: (header.mode ?? 420) & 73 ? 493 : 420 });
|
|
69779
69953
|
}
|
|
69780
69954
|
function requireSafeArchivePath(value2) {
|
|
69781
69955
|
const normalized2 = value2.replaceAll("\\", "/").normalize("NFC");
|
|
69782
|
-
if (!normalized2 || normalized2.startsWith("/") || normalized2.includes("\0") ||
|
|
69956
|
+
if (!normalized2 || normalized2.startsWith("/") || normalized2.includes("\0") || import_node_path47.posix.normalize(normalized2) !== normalized2 || normalized2 === ".." || normalized2.startsWith("../")) {
|
|
69783
69957
|
throw new Error(`Skill archive contains an unsafe path: ${value2}`);
|
|
69784
69958
|
}
|
|
69785
69959
|
return normalized2;
|
|
@@ -69801,8 +69975,8 @@ async function publishLocalSkill(options) {
|
|
|
69801
69975
|
if (Date.parse(request2.uploadGrant.expiresAt) <= (options.now ?? Date.now())) {
|
|
69802
69976
|
throw new RuntimeFault("invalid_file", "Skill upload grant expired");
|
|
69803
69977
|
}
|
|
69804
|
-
const folder = await (0,
|
|
69805
|
-
if (!folder.isDirectory() || await (0,
|
|
69978
|
+
const folder = await (0, import_promises54.lstat)(entry.path);
|
|
69979
|
+
if (!folder.isDirectory() || await (0, import_promises54.realpath)(entry.path) !== entry.path) {
|
|
69806
69980
|
throw new RuntimeFault("invalid_file", "Skill folder moved since the last scan");
|
|
69807
69981
|
}
|
|
69808
69982
|
const bundle = await createSkillBundle(entry.path, {
|
|
@@ -69831,8 +70005,8 @@ async function publishLocalSkill(options) {
|
|
|
69831
70005
|
// src/capabilities/skills/native-index.ts
|
|
69832
70006
|
var import_node_crypto26 = require("crypto");
|
|
69833
70007
|
var import_node_fs17 = require("fs");
|
|
69834
|
-
var
|
|
69835
|
-
var
|
|
70008
|
+
var import_promises55 = require("fs/promises");
|
|
70009
|
+
var import_node_path48 = require("path");
|
|
69836
70010
|
var ALAN_SKILLS_PLUGIN_NAME = "alan";
|
|
69837
70011
|
var PLUGIN_MANIFEST = `${JSON.stringify(
|
|
69838
70012
|
{
|
|
@@ -69845,70 +70019,70 @@ var PLUGIN_MANIFEST = `${JSON.stringify(
|
|
|
69845
70019
|
`;
|
|
69846
70020
|
async function entryKind2(path4) {
|
|
69847
70021
|
try {
|
|
69848
|
-
return (await (0,
|
|
70022
|
+
return (await (0, import_promises55.lstat)(path4)).isSymbolicLink() ? "link" : "other";
|
|
69849
70023
|
} catch (error62) {
|
|
69850
70024
|
if (errnoCode(error62) === "ENOENT") return "missing";
|
|
69851
70025
|
throw error62;
|
|
69852
70026
|
}
|
|
69853
70027
|
}
|
|
69854
70028
|
async function linkTarget(path4) {
|
|
69855
|
-
return (0,
|
|
70029
|
+
return (0, import_promises55.readlink)(path4).catch(() => null);
|
|
69856
70030
|
}
|
|
69857
|
-
async function
|
|
70031
|
+
async function removeLink2(path4) {
|
|
69858
70032
|
try {
|
|
69859
|
-
await (0,
|
|
70033
|
+
await (0, import_promises55.unlink)(path4);
|
|
69860
70034
|
} catch (error62) {
|
|
69861
70035
|
const code = errnoCode(error62);
|
|
69862
70036
|
if (code === "ENOENT") return;
|
|
69863
70037
|
if (code !== "EPERM" && code !== "EISDIR") throw error62;
|
|
69864
|
-
await (0,
|
|
70038
|
+
await (0, import_promises55.rmdir)(path4);
|
|
69865
70039
|
}
|
|
69866
70040
|
}
|
|
69867
70041
|
async function placeLink(plan2, platform3) {
|
|
69868
70042
|
if (await linkTarget(plan2.path) === plan2.target) return false;
|
|
69869
|
-
const staged = (0,
|
|
69870
|
-
await (0,
|
|
70043
|
+
const staged = (0, import_node_path48.join)((0, import_node_path48.dirname)(plan2.path), `.${(0, import_node_path48.basename)(plan2.path)}.${(0, import_node_crypto26.randomUUID)()}.tmp`);
|
|
70044
|
+
await (0, import_promises55.symlink)(plan2.target, staged, platform3 === "win32" ? "junction" : "dir");
|
|
69871
70045
|
try {
|
|
69872
|
-
if (platform3 === "win32") await
|
|
69873
|
-
await (0,
|
|
70046
|
+
if (platform3 === "win32") await removeLink2(plan2.path);
|
|
70047
|
+
await (0, import_promises55.rename)(staged, plan2.path);
|
|
69874
70048
|
} catch (error62) {
|
|
69875
|
-
await
|
|
70049
|
+
await removeLink2(staged).catch(() => void 0);
|
|
69876
70050
|
throw error62;
|
|
69877
70051
|
}
|
|
69878
70052
|
return true;
|
|
69879
70053
|
}
|
|
69880
70054
|
function versionTarget(layout, versionId, platform3) {
|
|
69881
|
-
const absolute = (0,
|
|
69882
|
-
return platform3 === "win32" ? absolute : (0,
|
|
70055
|
+
const absolute = (0, import_node_path48.join)(layout.versionsDir, versionId);
|
|
70056
|
+
return platform3 === "win32" ? absolute : (0, import_node_path48.relative)(layout.pluginSkillsDir, absolute);
|
|
69883
70057
|
}
|
|
69884
70058
|
async function writeManifest(layout) {
|
|
69885
|
-
const manifest = (0,
|
|
69886
|
-
if (await (0,
|
|
69887
|
-
await (0,
|
|
70059
|
+
const manifest = (0, import_node_path48.join)(layout.pluginDir, ".claude-plugin", "plugin.json");
|
|
70060
|
+
if (await (0, import_promises55.readFile)(manifest, "utf8").catch(() => null) === PLUGIN_MANIFEST) return;
|
|
70061
|
+
await (0, import_promises55.mkdir)((0, import_node_path48.dirname)(manifest), { recursive: true, mode: 448 });
|
|
69888
70062
|
const staged = `${manifest}.${(0, import_node_crypto26.randomUUID)()}.tmp`;
|
|
69889
|
-
await (0,
|
|
69890
|
-
await (0,
|
|
70063
|
+
await (0, import_promises55.writeFile)(staged, PLUGIN_MANIFEST, { mode: 384 });
|
|
70064
|
+
await (0, import_promises55.rename)(staged, manifest);
|
|
69891
70065
|
}
|
|
69892
70066
|
async function reconcilePluginSkills(layout, installed, platform3) {
|
|
69893
|
-
await (0,
|
|
70067
|
+
await (0, import_promises55.mkdir)(layout.pluginSkillsDir, { recursive: true, mode: 448 });
|
|
69894
70068
|
const wanted = new Map(installed.map((skill) => [skill.slug, skill]));
|
|
69895
70069
|
let linked = 0;
|
|
69896
70070
|
for (const skill of installed) {
|
|
69897
70071
|
const plan2 = {
|
|
69898
|
-
path: (0,
|
|
70072
|
+
path: (0, import_node_path48.join)(layout.pluginSkillsDir, skill.slug),
|
|
69899
70073
|
target: versionTarget(layout, skill.versionId, platform3)
|
|
69900
70074
|
};
|
|
69901
70075
|
if (await entryKind2(plan2.path) === "other") {
|
|
69902
|
-
await (0,
|
|
70076
|
+
await (0, import_promises55.rm)(plan2.path, { recursive: true, force: true });
|
|
69903
70077
|
}
|
|
69904
70078
|
if (await placeLink(plan2, platform3)) linked += 1;
|
|
69905
70079
|
}
|
|
69906
70080
|
let unlinked = 0;
|
|
69907
|
-
for (const name of await (0,
|
|
70081
|
+
for (const name of await (0, import_promises55.readdir)(layout.pluginSkillsDir)) {
|
|
69908
70082
|
if (wanted.has(name)) continue;
|
|
69909
|
-
const path4 = (0,
|
|
69910
|
-
if (await entryKind2(path4) === "link") await
|
|
69911
|
-
else await (0,
|
|
70083
|
+
const path4 = (0, import_node_path48.join)(layout.pluginSkillsDir, name);
|
|
70084
|
+
if (await entryKind2(path4) === "link") await removeLink2(path4);
|
|
70085
|
+
else await (0, import_promises55.rm)(path4, { recursive: true, force: true });
|
|
69912
70086
|
unlinked += 1;
|
|
69913
70087
|
}
|
|
69914
70088
|
return { linked, unlinked };
|
|
@@ -69916,52 +70090,52 @@ async function reconcilePluginSkills(layout, installed, platform3) {
|
|
|
69916
70090
|
async function isOwnCodexLink(layout, path4) {
|
|
69917
70091
|
const target = await linkTarget(path4);
|
|
69918
70092
|
if (target === null) return false;
|
|
69919
|
-
const absolute = (0,
|
|
70093
|
+
const absolute = (0, import_node_path48.isAbsolute)(target) ? target : (0, import_node_path48.resolve)((0, import_node_path48.dirname)(path4), target);
|
|
69920
70094
|
return isWithinDirectory2(layout.pluginSkillsDir, absolute);
|
|
69921
70095
|
}
|
|
69922
70096
|
async function isForeignPackage(layout, path4) {
|
|
69923
|
-
const resolved = await (0,
|
|
70097
|
+
const resolved = await (0, import_promises55.realpath)(path4).catch(() => null);
|
|
69924
70098
|
if (resolved === null) return false;
|
|
69925
|
-
const root = await (0,
|
|
70099
|
+
const root = await (0, import_promises55.realpath)(layout.root).catch(() => layout.root);
|
|
69926
70100
|
return !isWithinDirectory2(root, resolved);
|
|
69927
70101
|
}
|
|
69928
70102
|
async function codexSlot(layout, path4, slug) {
|
|
69929
|
-
const baked = layout.nativeDir !== null && await isForeignPackage(layout, (0,
|
|
70103
|
+
const baked = layout.nativeDir !== null && await isForeignPackage(layout, (0, import_node_path48.join)(layout.nativeDir, slug));
|
|
69930
70104
|
const kind = await entryKind2(path4);
|
|
69931
70105
|
if (kind === "other") return "taken";
|
|
69932
70106
|
const ours = kind === "link" && await isOwnCodexLink(layout, path4);
|
|
69933
70107
|
if (kind === "link" && !ours) return "taken";
|
|
69934
70108
|
if (baked) {
|
|
69935
|
-
if (ours) await
|
|
70109
|
+
if (ours) await removeLink2(path4);
|
|
69936
70110
|
return "taken";
|
|
69937
70111
|
}
|
|
69938
70112
|
return ours ? "ours" : "free";
|
|
69939
70113
|
}
|
|
69940
|
-
async function unlinkStaleCodexEntries(layout,
|
|
70114
|
+
async function unlinkStaleCodexEntries(layout, codexSkillsDir2, wanted) {
|
|
69941
70115
|
let unlinked = 0;
|
|
69942
|
-
for (const name of await (0,
|
|
69943
|
-
const path4 = (0,
|
|
70116
|
+
for (const name of await (0, import_promises55.readdir)(codexSkillsDir2)) {
|
|
70117
|
+
const path4 = (0, import_node_path48.join)(codexSkillsDir2, name);
|
|
69944
70118
|
if (wanted.has(name) && !name.endsWith(".tmp")) continue;
|
|
69945
70119
|
if (await entryKind2(path4) !== "link" || !await isOwnCodexLink(layout, path4)) continue;
|
|
69946
|
-
await
|
|
70120
|
+
await removeLink2(path4);
|
|
69947
70121
|
unlinked += 1;
|
|
69948
70122
|
}
|
|
69949
70123
|
return unlinked;
|
|
69950
70124
|
}
|
|
69951
|
-
async function reconcileCodexSkills(layout, installed,
|
|
69952
|
-
await (0,
|
|
70125
|
+
async function reconcileCodexSkills(layout, installed, codexSkillsDir2, platform3) {
|
|
70126
|
+
await (0, import_promises55.mkdir)(codexSkillsDir2, { recursive: true, mode: 448 });
|
|
69953
70127
|
const report2 = { linked: 0, unlinked: 0, skipped: [] };
|
|
69954
70128
|
for (const skill of installed) {
|
|
69955
|
-
const path4 = (0,
|
|
70129
|
+
const path4 = (0, import_node_path48.join)(codexSkillsDir2, skill.slug);
|
|
69956
70130
|
if (await codexSlot(layout, path4, skill.slug) === "taken") {
|
|
69957
70131
|
report2.skipped.push(skill.slug);
|
|
69958
70132
|
continue;
|
|
69959
70133
|
}
|
|
69960
|
-
const target = (0,
|
|
70134
|
+
const target = (0, import_node_path48.join)(layout.pluginSkillsDir, skill.slug);
|
|
69961
70135
|
if (await placeLink({ path: path4, target }, platform3)) report2.linked += 1;
|
|
69962
70136
|
}
|
|
69963
70137
|
const wanted = new Set(installed.map((skill) => skill.slug));
|
|
69964
|
-
report2.unlinked = await unlinkStaleCodexEntries(layout,
|
|
70138
|
+
report2.unlinked = await unlinkStaleCodexEntries(layout, codexSkillsDir2, wanted);
|
|
69965
70139
|
return report2;
|
|
69966
70140
|
}
|
|
69967
70141
|
async function reconcileNativeIndex(layout, installed, options) {
|
|
@@ -69981,41 +70155,41 @@ async function reconcileNativeIndex(layout, installed, options) {
|
|
|
69981
70155
|
};
|
|
69982
70156
|
}
|
|
69983
70157
|
function installedSkillFolders(layout) {
|
|
69984
|
-
return (0, import_node_fs17.existsSync)((0,
|
|
70158
|
+
return (0, import_node_fs17.existsSync)((0, import_node_path48.join)(layout.pluginDir, ".claude-plugin", "plugin.json")) ? { pluginDir: layout.pluginDir, skillsDir: layout.pluginSkillsDir } : null;
|
|
69985
70159
|
}
|
|
69986
70160
|
|
|
69987
70161
|
// src/capabilities/skills/sync.ts
|
|
69988
70162
|
var import_node_crypto27 = require("crypto");
|
|
69989
|
-
var
|
|
69990
|
-
var
|
|
70163
|
+
var import_promises56 = require("fs/promises");
|
|
70164
|
+
var import_node_path49 = require("path");
|
|
69991
70165
|
init_zod();
|
|
69992
70166
|
var SKILL_PREPARE_WAIT_MS = 15e3;
|
|
69993
70167
|
var FIRST_INSTALL_WAIT_MS = 5e3;
|
|
69994
70168
|
var RETIRED_VERSION_RETENTION_MS = 24 * 60 * 60 * 1e3;
|
|
69995
70169
|
async function makeFilesReadOnly(directory, platform3) {
|
|
69996
70170
|
if (platform3 === "win32") return;
|
|
69997
|
-
for (const entry of await (0,
|
|
69998
|
-
const path4 = (0,
|
|
70171
|
+
for (const entry of await (0, import_promises56.readdir)(directory, { withFileTypes: true })) {
|
|
70172
|
+
const path4 = (0, import_node_path49.join)(directory, entry.name);
|
|
69999
70173
|
if (entry.isDirectory()) await makeFilesReadOnly(path4, platform3);
|
|
70000
70174
|
else if (entry.isFile()) {
|
|
70001
|
-
const executable = ((await (0,
|
|
70002
|
-
await (0,
|
|
70175
|
+
const executable = ((await (0, import_promises56.lstat)(path4)).mode & 64) !== 0;
|
|
70176
|
+
await (0, import_promises56.chmod)(path4, executable ? 365 : 292);
|
|
70003
70177
|
}
|
|
70004
70178
|
}
|
|
70005
70179
|
}
|
|
70006
70180
|
async function install(env, skill, download, signal) {
|
|
70007
70181
|
const { layout, source, platform: platform3 } = env;
|
|
70008
70182
|
const bytes = await source.download(download.url, signal);
|
|
70009
|
-
await (0,
|
|
70010
|
-
const staging = (0,
|
|
70183
|
+
await (0, import_promises56.mkdir)(layout.tmpDir, { recursive: true, mode: 448 });
|
|
70184
|
+
const staging = (0, import_node_path49.join)(layout.tmpDir, (0, import_node_crypto27.randomUUID)());
|
|
70011
70185
|
await extractSkillBundle(Buffer.from(bytes), staging, {
|
|
70012
70186
|
expectedArchiveHash: download.archiveHash,
|
|
70013
70187
|
expectedContentHash: skill.contentHash
|
|
70014
70188
|
});
|
|
70015
70189
|
const target = packageDirectory(layout, skill.versionId);
|
|
70016
|
-
await (0,
|
|
70017
|
-
await (0,
|
|
70018
|
-
await (0,
|
|
70190
|
+
await (0, import_promises56.mkdir)(layout.versionsDir, { recursive: true, mode: 448 });
|
|
70191
|
+
await (0, import_promises56.rm)(target, { recursive: true, force: true });
|
|
70192
|
+
await (0, import_promises56.rename)(staging, target);
|
|
70019
70193
|
await makeFilesReadOnly(target, platform3);
|
|
70020
70194
|
}
|
|
70021
70195
|
var retiredFileSchema = external_exports.record(external_exports.string(), external_exports.number());
|
|
@@ -70027,14 +70201,14 @@ async function sweep(env, keep) {
|
|
|
70027
70201
|
const now = env.now();
|
|
70028
70202
|
const stillRetired = {};
|
|
70029
70203
|
const expired = [];
|
|
70030
|
-
for (const name of await (0,
|
|
70204
|
+
for (const name of await (0, import_promises56.readdir)(layout.versionsDir).catch(() => [])) {
|
|
70031
70205
|
if (kept.has(name)) continue;
|
|
70032
70206
|
const since = retired[name] ?? now;
|
|
70033
70207
|
if (now - since >= RETIRED_VERSION_RETENTION_MS) expired.push(name);
|
|
70034
70208
|
else stillRetired[name] = since;
|
|
70035
70209
|
}
|
|
70036
70210
|
const results = await Promise.allSettled(
|
|
70037
|
-
expired.map((name) => (0,
|
|
70211
|
+
expired.map((name) => (0, import_promises56.rm)((0, import_node_path49.join)(layout.versionsDir, name), { recursive: true, force: true }))
|
|
70038
70212
|
);
|
|
70039
70213
|
results.forEach((result, index) => {
|
|
70040
70214
|
const name = expired[index];
|
|
@@ -70043,15 +70217,20 @@ async function sweep(env, keep) {
|
|
|
70043
70217
|
if (JSON.stringify(stillRetired) !== JSON.stringify(retired)) {
|
|
70044
70218
|
await writeJsonFileAtomic(layout.retiredFile, stillRetired);
|
|
70045
70219
|
}
|
|
70046
|
-
await (0,
|
|
70220
|
+
await (0, import_promises56.rm)(layout.tmpDir, { recursive: true, force: true });
|
|
70047
70221
|
return results.filter((result) => result.status === "fulfilled").length;
|
|
70048
70222
|
}
|
|
70223
|
+
var INSTALL_CONCURRENCY = 4;
|
|
70224
|
+
var VERIFY_CONCURRENCY = 8;
|
|
70049
70225
|
async function intactSkills(layout) {
|
|
70050
70226
|
const installed = await readInstalledSkills(layout);
|
|
70051
|
-
const intact = await
|
|
70227
|
+
const intact = await mapBounded(
|
|
70228
|
+
installed,
|
|
70229
|
+
VERIFY_CONCURRENCY,
|
|
70230
|
+
(skill) => isIntact(layout, skill)
|
|
70231
|
+
);
|
|
70052
70232
|
return installed.filter((_, index) => intact[index]);
|
|
70053
70233
|
}
|
|
70054
|
-
var INSTALL_CONCURRENCY = 4;
|
|
70055
70234
|
async function mapBounded(items, limit, work) {
|
|
70056
70235
|
const results = [];
|
|
70057
70236
|
let next = 0;
|
|
@@ -70235,9 +70414,9 @@ async function syncOnce(env, local, onRecorded, signal) {
|
|
|
70235
70414
|
return report2;
|
|
70236
70415
|
}
|
|
70237
70416
|
function aborted2(signal) {
|
|
70238
|
-
return new Promise((
|
|
70239
|
-
if (signal.aborted)
|
|
70240
|
-
else signal.addEventListener("abort", () =>
|
|
70417
|
+
return new Promise((resolve14) => {
|
|
70418
|
+
if (signal.aborted) resolve14(null);
|
|
70419
|
+
else signal.addEventListener("abort", () => resolve14(null), { once: true });
|
|
70241
70420
|
});
|
|
70242
70421
|
}
|
|
70243
70422
|
function openMachineSkills(options) {
|
|
@@ -70326,11 +70505,11 @@ function openMachineSkills(options) {
|
|
|
70326
70505
|
if ((await resolveSkillInvocations(layout, named, "exact")).kind === "resolved") return;
|
|
70327
70506
|
}
|
|
70328
70507
|
};
|
|
70329
|
-
const recordedUntilResolved = (named, until) => new Promise((
|
|
70508
|
+
const recordedUntilResolved = (named, until) => new Promise((resolve14) => {
|
|
70330
70509
|
const done = () => {
|
|
70331
70510
|
recordWatchers.delete(check3);
|
|
70332
70511
|
until.removeEventListener("abort", done);
|
|
70333
|
-
|
|
70512
|
+
resolve14();
|
|
70334
70513
|
};
|
|
70335
70514
|
const check3 = () => {
|
|
70336
70515
|
void resolveSkillInvocations(layout, named, "exact").then((resolution) => {
|
|
@@ -70338,7 +70517,7 @@ function openMachineSkills(options) {
|
|
|
70338
70517
|
});
|
|
70339
70518
|
};
|
|
70340
70519
|
if (until.aborted) {
|
|
70341
|
-
|
|
70520
|
+
resolve14();
|
|
70342
70521
|
return;
|
|
70343
70522
|
}
|
|
70344
70523
|
recordWatchers.add(check3);
|
|
@@ -70380,15 +70559,15 @@ function openMachineSkills(options) {
|
|
|
70380
70559
|
}
|
|
70381
70560
|
|
|
70382
70561
|
// src/capabilities/workspace/index.ts
|
|
70383
|
-
var
|
|
70562
|
+
var import_node_path52 = require("path");
|
|
70384
70563
|
init_runtime_v2();
|
|
70385
70564
|
|
|
70386
70565
|
// src/capabilities/workspace/approved-paths.ts
|
|
70387
|
-
var
|
|
70566
|
+
var import_promises57 = require("fs/promises");
|
|
70388
70567
|
init_zod();
|
|
70389
70568
|
|
|
70390
70569
|
// src/capabilities/workspace/paths.ts
|
|
70391
|
-
var
|
|
70570
|
+
var import_node_path50 = require("path");
|
|
70392
70571
|
function stripWin32Namespace(path4) {
|
|
70393
70572
|
if (/^\\\\\?\\UNC\\/i.test(path4)) return `\\\\${path4.slice(8)}`;
|
|
70394
70573
|
if (path4.startsWith("\\\\?\\")) return path4.slice(4);
|
|
@@ -70396,15 +70575,15 @@ function stripWin32Namespace(path4) {
|
|
|
70396
70575
|
}
|
|
70397
70576
|
function comparablePath(path4, platform3) {
|
|
70398
70577
|
if (platform3 === "win32") {
|
|
70399
|
-
const normalized3 =
|
|
70578
|
+
const normalized3 = import_node_path50.win32.normalize(stripWin32Namespace(path4).replaceAll("/", "\\"));
|
|
70400
70579
|
const trimmed4 = normalized3.length > 3 || !/^[a-z]:\\$/i.test(normalized3) ? normalized3.replace(/\\+$/, "") : normalized3;
|
|
70401
70580
|
return trimmed4.toLowerCase();
|
|
70402
70581
|
}
|
|
70403
|
-
const normalized2 =
|
|
70582
|
+
const normalized2 = import_node_path50.posix.normalize(path4);
|
|
70404
70583
|
return normalized2.length > 1 ? normalized2.replace(/\/+$/, "") : normalized2;
|
|
70405
70584
|
}
|
|
70406
70585
|
function isAbsoluteFor(path4, platform3) {
|
|
70407
|
-
return platform3 === "win32" ?
|
|
70586
|
+
return platform3 === "win32" ? import_node_path50.win32.isAbsolute(path4) : import_node_path50.posix.isAbsolute(path4);
|
|
70408
70587
|
}
|
|
70409
70588
|
function isWithin(root, candidate, platform3) {
|
|
70410
70589
|
const separator = platform3 === "win32" ? "\\" : "/";
|
|
@@ -70422,7 +70601,7 @@ var storeSchema = external_exports.object({
|
|
|
70422
70601
|
});
|
|
70423
70602
|
async function realpathOrNull(path4) {
|
|
70424
70603
|
try {
|
|
70425
|
-
return await (0,
|
|
70604
|
+
return await (0, import_promises57.realpath)(path4);
|
|
70426
70605
|
} catch (error62) {
|
|
70427
70606
|
const code = errnoCode(error62);
|
|
70428
70607
|
if (code === "ENOENT" || code === "ENOTDIR" || code === "EACCES" || code === "EPERM") {
|
|
@@ -70482,8 +70661,8 @@ async function openApprovedPaths(options) {
|
|
|
70482
70661
|
|
|
70483
70662
|
// src/capabilities/workspace/locks.ts
|
|
70484
70663
|
var import_node_crypto28 = require("crypto");
|
|
70485
|
-
var
|
|
70486
|
-
var
|
|
70664
|
+
var import_promises58 = require("fs/promises");
|
|
70665
|
+
var import_node_path51 = require("path");
|
|
70487
70666
|
init_zod();
|
|
70488
70667
|
var LOCK_FORMAT = 1;
|
|
70489
70668
|
var EXCLUSIVE_FILE = "exclusive.json";
|
|
@@ -70503,7 +70682,7 @@ function repositoryLockKey(commonDir, platform3) {
|
|
|
70503
70682
|
async function readOwner2(path4) {
|
|
70504
70683
|
let text3;
|
|
70505
70684
|
try {
|
|
70506
|
-
text3 = await (0,
|
|
70685
|
+
text3 = await (0, import_promises58.readFile)(path4, "utf8");
|
|
70507
70686
|
} catch (error62) {
|
|
70508
70687
|
if (errnoCode(error62) === "ENOENT") return { kind: "missing" };
|
|
70509
70688
|
return { kind: "unreadable" };
|
|
@@ -70524,7 +70703,7 @@ async function removeIfSame(path4, expected) {
|
|
|
70524
70703
|
if (current.kind !== "owner" || current.owner.since !== expected.since) return;
|
|
70525
70704
|
if (current.owner.pid !== expected.pid || current.owner.holder !== expected.holder) return;
|
|
70526
70705
|
}
|
|
70527
|
-
await (0,
|
|
70706
|
+
await (0, import_promises58.unlink)(path4).catch((error62) => {
|
|
70528
70707
|
if (errnoCode(error62) !== "ENOENT") throw error62;
|
|
70529
70708
|
});
|
|
70530
70709
|
}
|
|
@@ -70549,7 +70728,7 @@ function openRepositoryLocks(options) {
|
|
|
70549
70728
|
await removeIfSame(path4, read.owner);
|
|
70550
70729
|
return null;
|
|
70551
70730
|
}
|
|
70552
|
-
const age = await (0,
|
|
70731
|
+
const age = await (0, import_promises58.stat)(path4).then(
|
|
70553
70732
|
(info) => clock.now() - info.mtimeMs,
|
|
70554
70733
|
() => 0
|
|
70555
70734
|
);
|
|
@@ -70563,13 +70742,13 @@ function openRepositoryLocks(options) {
|
|
|
70563
70742
|
});
|
|
70564
70743
|
const folder = async (commonDir) => {
|
|
70565
70744
|
const key = repositoryLockKey(commonDir, platform3);
|
|
70566
|
-
const dir = (0,
|
|
70567
|
-
await (0,
|
|
70745
|
+
const dir = (0, import_node_path51.join)(options.dir, key);
|
|
70746
|
+
await (0, import_promises58.mkdir)(dir, { recursive: true, mode: 448 });
|
|
70568
70747
|
return { key, dir };
|
|
70569
70748
|
};
|
|
70570
70749
|
const createExclusive = async (path4, owner) => {
|
|
70571
70750
|
try {
|
|
70572
|
-
const handle = await (0,
|
|
70751
|
+
const handle = await (0, import_promises58.open)(path4, "wx", 384);
|
|
70573
70752
|
try {
|
|
70574
70753
|
await handle.writeFile(JSON.stringify(owner));
|
|
70575
70754
|
} finally {
|
|
@@ -70582,10 +70761,10 @@ function openRepositoryLocks(options) {
|
|
|
70582
70761
|
}
|
|
70583
70762
|
};
|
|
70584
70763
|
const liveRun = async (dir) => {
|
|
70585
|
-
const entries = await (0,
|
|
70764
|
+
const entries = await (0, import_promises58.readdir)(dir);
|
|
70586
70765
|
for (const entry of entries) {
|
|
70587
70766
|
if (!entry.startsWith(RUN_FILE_PREFIX)) continue;
|
|
70588
|
-
const holder = await heldBy((0,
|
|
70767
|
+
const holder = await heldBy((0, import_node_path51.join)(dir, entry));
|
|
70589
70768
|
if (holder !== null) return holder;
|
|
70590
70769
|
}
|
|
70591
70770
|
return null;
|
|
@@ -70593,7 +70772,7 @@ function openRepositoryLocks(options) {
|
|
|
70593
70772
|
return {
|
|
70594
70773
|
tryExclusive: async (commonDir, operationId) => {
|
|
70595
70774
|
const { key, dir } = await folder(commonDir);
|
|
70596
|
-
const path4 = (0,
|
|
70775
|
+
const path4 = (0, import_node_path51.join)(dir, EXCLUSIVE_FILE);
|
|
70597
70776
|
const owner = await self(operationId);
|
|
70598
70777
|
if (!await createExclusive(path4, owner)) {
|
|
70599
70778
|
const holder = await heldBy(path4);
|
|
@@ -70612,10 +70791,10 @@ function openRepositoryLocks(options) {
|
|
|
70612
70791
|
tryShared: async (commonDir, runId) => {
|
|
70613
70792
|
const { key, dir } = await folder(commonDir);
|
|
70614
70793
|
const file2 = `${RUN_FILE_PREFIX}${(0, import_node_crypto28.createHash)("sha256").update(runId).digest("hex").slice(0, 32)}.json`;
|
|
70615
|
-
const path4 = (0,
|
|
70794
|
+
const path4 = (0, import_node_path51.join)(dir, file2);
|
|
70616
70795
|
const owner = await self(runId);
|
|
70617
70796
|
await writeJsonFileAtomic(path4, owner);
|
|
70618
|
-
const operation = await heldBy((0,
|
|
70797
|
+
const operation = await heldBy((0, import_node_path51.join)(dir, EXCLUSIVE_FILE));
|
|
70619
70798
|
if (operation !== null) {
|
|
70620
70799
|
await removeIfSame(path4, owner);
|
|
70621
70800
|
return { kind: "busy", holder: operation };
|
|
@@ -70715,18 +70894,18 @@ async function openWorkspaces(options) {
|
|
|
70715
70894
|
const budgetMs = options.budgetMs ?? WORKSPACE_QUERY_BUDGET_MS;
|
|
70716
70895
|
const lifetime = new AbortController();
|
|
70717
70896
|
const approved = await openApprovedPaths({
|
|
70718
|
-
file: (0,
|
|
70897
|
+
file: (0, import_node_path52.join)(options.stateDir, "workspaces.json"),
|
|
70719
70898
|
log: options.log,
|
|
70720
70899
|
platform: platform3
|
|
70721
70900
|
});
|
|
70722
70901
|
const locks = openRepositoryLocks({
|
|
70723
|
-
dir: (0,
|
|
70902
|
+
dir: (0, import_node_path52.join)(options.stateDir, "locks"),
|
|
70724
70903
|
clock: options.clock,
|
|
70725
70904
|
platform: platform3
|
|
70726
70905
|
});
|
|
70727
70906
|
const git = createGit({
|
|
70728
70907
|
env: options.env,
|
|
70729
|
-
tmpDir: (0,
|
|
70908
|
+
tmpDir: (0, import_node_path52.join)(options.stateDir, "tmp", "git"),
|
|
70730
70909
|
platform: platform3,
|
|
70731
70910
|
...options.gitPath === void 0 ? {} : { gitPath: options.gitPath },
|
|
70732
70911
|
...options.localTimeoutMs === void 0 ? {} : { localTimeoutMs: options.localTimeoutMs },
|
|
@@ -70994,7 +71173,7 @@ function createProviderDrivers(options) {
|
|
|
70994
71173
|
}
|
|
70995
71174
|
|
|
70996
71175
|
// src/holder/engine-records.ts
|
|
70997
|
-
var
|
|
71176
|
+
var import_node_path53 = require("path");
|
|
70998
71177
|
init_zod();
|
|
70999
71178
|
var ENGINES_FILE = "engines.json";
|
|
71000
71179
|
var STOP_GRACE_MS = 2e3;
|
|
@@ -71006,7 +71185,7 @@ var engineRecordSchema = external_exports.object({
|
|
|
71006
71185
|
});
|
|
71007
71186
|
var engineRecordsSchema = external_exports.object({ engines: external_exports.array(engineRecordSchema) });
|
|
71008
71187
|
function engineRecordsPath(sessionDir) {
|
|
71009
|
-
return (0,
|
|
71188
|
+
return (0, import_node_path53.join)(sessionDir, ENGINES_FILE);
|
|
71010
71189
|
}
|
|
71011
71190
|
function recordSpawnedEngines(path4, clock, log) {
|
|
71012
71191
|
const live = /* @__PURE__ */ new Map();
|
|
@@ -71067,11 +71246,11 @@ async function reapLeftoverEngines(path4, options) {
|
|
|
71067
71246
|
|
|
71068
71247
|
// src/holder/launch-command.ts
|
|
71069
71248
|
var import_node_fs18 = require("fs");
|
|
71070
|
-
var
|
|
71249
|
+
var import_node_path54 = require("path");
|
|
71071
71250
|
var HOLDER_BUNDLE = "alan-holder.cjs";
|
|
71072
71251
|
function holderArguments(runtimeArgs, nodeFlags, exists6 = import_node_fs18.existsSync) {
|
|
71073
71252
|
const bundle = runtimeArgs.at(-1);
|
|
71074
|
-
const lean = bundle === void 0 ? void 0 : (0,
|
|
71253
|
+
const lean = bundle === void 0 ? void 0 : (0, import_node_path54.join)((0, import_node_path54.dirname)(bundle), HOLDER_BUNDLE);
|
|
71075
71254
|
const script = lean !== void 0 && exists6(lean) ? [...runtimeArgs.slice(0, -1), lean] : runtimeArgs;
|
|
71076
71255
|
return [...nodeFlags, ...script, "hold"];
|
|
71077
71256
|
}
|
|
@@ -71106,17 +71285,17 @@ function createConversationMcpAuthorization(options) {
|
|
|
71106
71285
|
}
|
|
71107
71286
|
|
|
71108
71287
|
// src/holder/mcp-helper-access.ts
|
|
71109
|
-
var
|
|
71288
|
+
var import_promises59 = require("fs/promises");
|
|
71110
71289
|
function createHelperMcpAccess(options) {
|
|
71111
71290
|
return {
|
|
71112
71291
|
[Symbol.asyncDispose]: async () => {
|
|
71113
|
-
await (0,
|
|
71292
|
+
await (0, import_promises59.rm)(options.credentialPath, { force: true });
|
|
71114
71293
|
},
|
|
71115
71294
|
url: options.managedMcp.url,
|
|
71116
71295
|
authorization: async (signal) => {
|
|
71117
71296
|
const authorization = await options.managedMcp.authorization(signal);
|
|
71118
71297
|
if (authorization === void 0 || signal.aborted) {
|
|
71119
|
-
await (0,
|
|
71298
|
+
await (0, import_promises59.rm)(options.credentialPath, { force: true });
|
|
71120
71299
|
return void 0;
|
|
71121
71300
|
}
|
|
71122
71301
|
const credential = {
|
|
@@ -71131,8 +71310,8 @@ function createHelperMcpAccess(options) {
|
|
|
71131
71310
|
}
|
|
71132
71311
|
|
|
71133
71312
|
// src/holder/run-inputs.ts
|
|
71134
|
-
var
|
|
71135
|
-
var
|
|
71313
|
+
var import_promises60 = require("fs/promises");
|
|
71314
|
+
var import_node_path55 = require("path");
|
|
71136
71315
|
init_dist();
|
|
71137
71316
|
var NO_RUN_INPUTS = {
|
|
71138
71317
|
attachments: [],
|
|
@@ -71146,17 +71325,17 @@ function safeFilename(filename) {
|
|
|
71146
71325
|
return safe || "attachment";
|
|
71147
71326
|
}
|
|
71148
71327
|
function persistentAttachmentDir(workspaceRoot2) {
|
|
71149
|
-
return (0,
|
|
71328
|
+
return (0, import_node_path55.join)(workspaceRoot2, ".alan", "attachments");
|
|
71150
71329
|
}
|
|
71151
71330
|
function attachmentPath(spec, attachment, index, runDir) {
|
|
71152
71331
|
const workspaceRoot2 = spec.approvedWorkspacePaths?.[0];
|
|
71153
71332
|
if (attachment.persist && workspaceRoot2) {
|
|
71154
|
-
return (0,
|
|
71333
|
+
return (0, import_node_path55.join)(
|
|
71155
71334
|
persistentAttachmentDir(workspaceRoot2),
|
|
71156
71335
|
`${attachment.id.slice(0, 8)}-${safeFilename(attachment.filename)}`
|
|
71157
71336
|
);
|
|
71158
71337
|
}
|
|
71159
|
-
return (0,
|
|
71338
|
+
return (0, import_node_path55.join)(runDir, `${index}-${safeFilename(attachment.filename)}`);
|
|
71160
71339
|
}
|
|
71161
71340
|
function runMediaUploader(source, runId) {
|
|
71162
71341
|
const upload = source.uploadMedia?.bind(source);
|
|
@@ -71166,9 +71345,9 @@ function runMediaUploader(source, runId) {
|
|
|
71166
71345
|
};
|
|
71167
71346
|
}
|
|
71168
71347
|
async function prepareRunInputs(spec, { source, tmpDir, signal, skills = [] }) {
|
|
71169
|
-
const dir = (0,
|
|
71348
|
+
const dir = (0, import_node_path55.join)(tmpDir, "runs", spec.runId);
|
|
71170
71349
|
const cleanup = async () => {
|
|
71171
|
-
await (0,
|
|
71350
|
+
await (0, import_promises60.rm)(dir, { recursive: true, force: true });
|
|
71172
71351
|
};
|
|
71173
71352
|
try {
|
|
71174
71353
|
const credential = await source.fetchProviderCredential(spec.runId, signal);
|
|
@@ -71176,8 +71355,8 @@ async function prepareRunInputs(spec, { source, tmpDir, signal, skills = [] }) {
|
|
|
71176
71355
|
for (const [index, attachment] of (spec.attachments ?? []).entries()) {
|
|
71177
71356
|
const bytes = await source.downloadAttachment(spec.runId, attachment.id, signal);
|
|
71178
71357
|
const path4 = attachmentPath(spec, attachment, index, dir);
|
|
71179
|
-
await (0,
|
|
71180
|
-
await (0,
|
|
71358
|
+
await (0, import_promises60.mkdir)((0, import_node_path55.dirname)(path4), { recursive: true, mode: 448 });
|
|
71359
|
+
await (0, import_promises60.writeFile)(path4, bytes, { mode: 384 });
|
|
71181
71360
|
const imageMimeType = attachment.kind === "image" ? detectImageMimeType(Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength)) : null;
|
|
71182
71361
|
attachments.push({
|
|
71183
71362
|
id: attachment.id,
|
|
@@ -71210,34 +71389,34 @@ async function prepareRunInputs(spec, { source, tmpDir, signal, skills = [] }) {
|
|
|
71210
71389
|
var import_node_crypto31 = require("crypto");
|
|
71211
71390
|
var import_node_fs23 = require("fs");
|
|
71212
71391
|
var import_node_net3 = require("net");
|
|
71213
|
-
var
|
|
71392
|
+
var import_node_path67 = require("path");
|
|
71214
71393
|
init_runtime_v2();
|
|
71215
71394
|
|
|
71216
71395
|
// src/holder/admission.ts
|
|
71217
71396
|
var import_node_fs20 = require("fs");
|
|
71218
|
-
var
|
|
71397
|
+
var import_promises64 = require("fs/promises");
|
|
71219
71398
|
var import_node_os9 = require("os");
|
|
71220
|
-
var
|
|
71399
|
+
var import_node_path61 = require("path");
|
|
71221
71400
|
init_constants();
|
|
71222
71401
|
|
|
71223
71402
|
// ../shared/dist/node/local-workspace.js
|
|
71224
71403
|
var import_node_fs19 = require("fs");
|
|
71225
71404
|
var import_node_os8 = require("os");
|
|
71226
|
-
var
|
|
71405
|
+
var import_node_path56 = require("path");
|
|
71227
71406
|
function resolveAlanDefaultWorkspacePath(homeDirectory = (0, import_node_os8.homedir)()) {
|
|
71228
|
-
return (0,
|
|
71407
|
+
return (0, import_node_path56.join)(homeDirectory, ".alan", "workspace");
|
|
71229
71408
|
}
|
|
71230
71409
|
|
|
71231
71410
|
// src/holder/agent-context.ts
|
|
71232
|
-
var
|
|
71233
|
-
var
|
|
71411
|
+
var import_promises61 = require("fs/promises");
|
|
71412
|
+
var import_node_path57 = require("path");
|
|
71234
71413
|
|
|
71235
71414
|
// ../agent-core/dist/prompt.js
|
|
71236
|
-
|
|
71415
|
+
init_chunk_7FJ7QKFN();
|
|
71237
71416
|
|
|
71238
71417
|
// src/holder/agent-context.ts
|
|
71239
71418
|
async function readText4(path4) {
|
|
71240
|
-
return (0,
|
|
71419
|
+
return (0, import_promises61.readFile)(path4, "utf8").then(
|
|
71241
71420
|
(text3) => text3.trim(),
|
|
71242
71421
|
() => null
|
|
71243
71422
|
);
|
|
@@ -71252,10 +71431,10 @@ async function startCommandState(statusPath) {
|
|
|
71252
71431
|
return code === 0 ? { state: "exited_ok" } : { state: "failed", exitCode: code };
|
|
71253
71432
|
}
|
|
71254
71433
|
function createAgentContext(deps) {
|
|
71255
|
-
const statusPath = (0,
|
|
71256
|
-
const logPath = (0,
|
|
71434
|
+
const statusPath = (0, import_node_path57.join)(deps.homeDir, ".alan", "start-commands.status");
|
|
71435
|
+
const logPath = (0, import_node_path57.join)(deps.homeDir, ".alan", "start-commands.log");
|
|
71257
71436
|
return async (spec, problems) => {
|
|
71258
|
-
const file2 = (0,
|
|
71437
|
+
const file2 = (0, import_node_path57.join)(deps.dir, `${spec.conversationId}.json`);
|
|
71259
71438
|
const saved = await readJsonFile(file2, agentContextSnapshotSchema);
|
|
71260
71439
|
const known = saved.kind === "ok" ? saved.value : void 0;
|
|
71261
71440
|
const hasEnvironment = (spec.agentContext ?? known)?.environment !== void 0;
|
|
@@ -71279,28 +71458,28 @@ function createAgentContext(deps) {
|
|
|
71279
71458
|
}
|
|
71280
71459
|
|
|
71281
71460
|
// src/holder/checkout-refresh.ts
|
|
71282
|
-
var
|
|
71461
|
+
var import_node_path60 = require("path");
|
|
71283
71462
|
|
|
71284
71463
|
// src/holder/claim-once.ts
|
|
71285
71464
|
var import_node_crypto29 = require("crypto");
|
|
71286
|
-
var
|
|
71287
|
-
var
|
|
71465
|
+
var import_promises62 = require("fs/promises");
|
|
71466
|
+
var import_node_path58 = require("path");
|
|
71288
71467
|
async function claimOnce(dir, name) {
|
|
71289
71468
|
try {
|
|
71290
|
-
await (0,
|
|
71291
|
-
await (await (0,
|
|
71469
|
+
await (0, import_promises62.mkdir)(dir, { recursive: true, mode: 448 });
|
|
71470
|
+
await (await (0, import_promises62.open)((0, import_node_path58.join)(dir, name), "wx")).close();
|
|
71292
71471
|
return true;
|
|
71293
71472
|
} catch {
|
|
71294
71473
|
return false;
|
|
71295
71474
|
}
|
|
71296
71475
|
}
|
|
71297
71476
|
function claimFirstLease(freshnessDir, path4) {
|
|
71298
|
-
return claimOnce((0,
|
|
71477
|
+
return claimOnce((0, import_node_path58.join)(freshnessDir, "leased"), (0, import_node_crypto29.createHash)("sha256").update(path4).digest("hex"));
|
|
71299
71478
|
}
|
|
71300
71479
|
|
|
71301
71480
|
// src/holder/requested-checkout.ts
|
|
71302
|
-
var
|
|
71303
|
-
var
|
|
71481
|
+
var import_promises63 = require("fs/promises");
|
|
71482
|
+
var import_node_path59 = require("path");
|
|
71304
71483
|
var REMOTE2 = "origin";
|
|
71305
71484
|
var REASON_MAX_CHARS = 200;
|
|
71306
71485
|
function firstLine3(text3) {
|
|
@@ -71321,8 +71500,8 @@ function notSwitched(checkout, current, reason) {
|
|
|
71321
71500
|
);
|
|
71322
71501
|
}
|
|
71323
71502
|
async function clone2(checkout, deps, signal) {
|
|
71324
|
-
const parent = (0,
|
|
71325
|
-
await (0,
|
|
71503
|
+
const parent = (0, import_node_path59.dirname)(checkout.path);
|
|
71504
|
+
await (0, import_promises63.mkdir)(parent, { recursive: true });
|
|
71326
71505
|
await assertValidBranch(deps.git, parent, checkout.branch, signal);
|
|
71327
71506
|
const output2 = await deps.git.run(
|
|
71328
71507
|
{
|
|
@@ -71557,7 +71736,7 @@ async function applyRequestedCheckouts(spec, deps, signal) {
|
|
|
71557
71736
|
ms: Date.now() - startedAt
|
|
71558
71737
|
});
|
|
71559
71738
|
if (outcome2.kind === "on_branch") continue;
|
|
71560
|
-
settled2.add((0,
|
|
71739
|
+
settled2.add((0, import_node_path60.resolve)(checkout.path));
|
|
71561
71740
|
if (outcome2.kind === "noted") {
|
|
71562
71741
|
problems.push({ path: checkout.path, problem: outcome2.problem, action: outcome2.action });
|
|
71563
71742
|
}
|
|
@@ -71567,7 +71746,7 @@ async function applyRequestedCheckouts(spec, deps, signal) {
|
|
|
71567
71746
|
async function refreshSnapshotCheckouts(spec, targets, settled2, deps, signal) {
|
|
71568
71747
|
const problems = [];
|
|
71569
71748
|
for (const target of targets) {
|
|
71570
|
-
if (settled2.has((0,
|
|
71749
|
+
if (settled2.has((0, import_node_path60.resolve)(target))) continue;
|
|
71571
71750
|
const freshness = await readCheckoutFreshness(deps.dir, target);
|
|
71572
71751
|
if (freshness === null) continue;
|
|
71573
71752
|
const startedAt = Date.now();
|
|
@@ -71588,7 +71767,7 @@ async function refreshSnapshotCheckouts(spec, targets, settled2, deps, signal) {
|
|
|
71588
71767
|
function createCheckoutRefresh(deps) {
|
|
71589
71768
|
return async (spec, signal) => {
|
|
71590
71769
|
if (spec.providerSessionId !== void 0) return [];
|
|
71591
|
-
if (!await claimOnce((0,
|
|
71770
|
+
if (!await claimOnce((0, import_node_path60.join)(deps.dir, "conversations"), spec.conversationId)) return [];
|
|
71592
71771
|
const requested = await applyRequestedCheckouts(spec, deps, signal);
|
|
71593
71772
|
const targets = await checkoutsOf(spec);
|
|
71594
71773
|
return [
|
|
@@ -71630,7 +71809,7 @@ function volumeRoot(path4) {
|
|
|
71630
71809
|
}
|
|
71631
71810
|
async function exists4(path4) {
|
|
71632
71811
|
try {
|
|
71633
|
-
await (0,
|
|
71812
|
+
await (0, import_promises64.stat)(path4);
|
|
71634
71813
|
return true;
|
|
71635
71814
|
} catch {
|
|
71636
71815
|
return false;
|
|
@@ -71638,10 +71817,10 @@ async function exists4(path4) {
|
|
|
71638
71817
|
}
|
|
71639
71818
|
async function inspectReadiness(path4) {
|
|
71640
71819
|
try {
|
|
71641
|
-
if (!(await (0,
|
|
71820
|
+
if (!(await (0, import_promises64.stat)(path4)).isDirectory()) {
|
|
71642
71821
|
return { ready: false, missing: true, message: MESSAGES.missing };
|
|
71643
71822
|
}
|
|
71644
|
-
await (0,
|
|
71823
|
+
await (0, import_promises64.access)(path4, import_node_fs20.constants.R_OK | import_node_fs20.constants.W_OK | import_node_fs20.constants.X_OK);
|
|
71645
71824
|
return { ready: true };
|
|
71646
71825
|
} catch (error62) {
|
|
71647
71826
|
const code = errnoCode(error62) ?? "";
|
|
@@ -71685,8 +71864,8 @@ async function admitDefaultWorkspace(spec, context, skills) {
|
|
|
71685
71864
|
const { env } = context;
|
|
71686
71865
|
const path4 = resolveAlanDefaultWorkspacePath(env.HOME || env.USERPROFILE || (0, import_node_os9.homedir)());
|
|
71687
71866
|
try {
|
|
71688
|
-
await (0,
|
|
71689
|
-
await (0,
|
|
71867
|
+
await (0, import_promises64.mkdir)(path4, { recursive: true, mode: 448 });
|
|
71868
|
+
await (0, import_promises64.access)(path4, import_node_fs20.constants.R_OK | import_node_fs20.constants.W_OK | import_node_fs20.constants.X_OK);
|
|
71690
71869
|
return { kind: "admitted", spec: { ...spec, projectPath: path4 }, skills };
|
|
71691
71870
|
} catch (error62) {
|
|
71692
71871
|
const code = errnoCode(error62);
|
|
@@ -71696,13 +71875,38 @@ async function admitDefaultWorkspace(spec, context, skills) {
|
|
|
71696
71875
|
);
|
|
71697
71876
|
}
|
|
71698
71877
|
}
|
|
71878
|
+
async function selfListedSkills(spec, context) {
|
|
71879
|
+
const pointed = context.skills !== void 0 && installedSkillFolders(context.skills) !== null;
|
|
71880
|
+
switch (spec.backendKind) {
|
|
71881
|
+
case "claude_cli":
|
|
71882
|
+
return {
|
|
71883
|
+
synced: pointed && await (context.discovery?.claudeLoadsPlugins() ?? false),
|
|
71884
|
+
native: false
|
|
71885
|
+
};
|
|
71886
|
+
case "codex_app_server":
|
|
71887
|
+
return {
|
|
71888
|
+
synced: pointed && context.discovery?.codexLinksSyncedSkills === true,
|
|
71889
|
+
native: true
|
|
71890
|
+
};
|
|
71891
|
+
case ALAN_CODE_BACKEND:
|
|
71892
|
+
case "opencode_serve":
|
|
71893
|
+
return { synced: pointed, native: true };
|
|
71894
|
+
default:
|
|
71895
|
+
return { synced: false, native: false };
|
|
71896
|
+
}
|
|
71897
|
+
}
|
|
71699
71898
|
async function withInstalledCloudSkills(spec, context) {
|
|
71700
71899
|
if (!spec.sandboxId && !spec.cloudEnvironmentId || context.skills === void 0) return spec;
|
|
71900
|
+
const listed = await selfListedSkills(spec, context);
|
|
71901
|
+
if (listed.synced && listed.native) return spec;
|
|
71701
71902
|
return {
|
|
71702
71903
|
...spec,
|
|
71703
71904
|
promptContext: {
|
|
71704
71905
|
...spec.promptContext,
|
|
71705
|
-
availableSkills: await availableSkillIndex(context.skills
|
|
71906
|
+
availableSkills: await availableSkillIndex(context.skills, {
|
|
71907
|
+
synced: !listed.synced,
|
|
71908
|
+
native: !listed.native
|
|
71909
|
+
})
|
|
71706
71910
|
}
|
|
71707
71911
|
};
|
|
71708
71912
|
}
|
|
@@ -71750,12 +71954,13 @@ function createHolderWorkspace(machine, clock, log) {
|
|
|
71750
71954
|
),
|
|
71751
71955
|
approvedRoots: async () => {
|
|
71752
71956
|
const approved = await openApprovedPaths({
|
|
71753
|
-
file: (0,
|
|
71957
|
+
file: (0, import_node_path61.join)(machine.stateDir, "workspaces.json"),
|
|
71754
71958
|
log,
|
|
71755
71959
|
platform: platform3
|
|
71756
71960
|
});
|
|
71757
71961
|
return approved.roots();
|
|
71758
|
-
}
|
|
71962
|
+
},
|
|
71963
|
+
...machine.skillDiscovery === void 0 ? {} : { discovery: machine.skillDiscovery }
|
|
71759
71964
|
},
|
|
71760
71965
|
...machine.refreshesFirstCheckout === true ? {
|
|
71761
71966
|
refreshFirstCheckout: createCheckoutRefresh({
|
|
@@ -71765,12 +71970,12 @@ function createHolderWorkspace(machine, clock, log) {
|
|
|
71765
71970
|
localTimeoutMs: CHECKOUT_LOCAL_TIMEOUT_MS,
|
|
71766
71971
|
networkTimeoutMs: CHECKOUT_NETWORK_TIMEOUT_MS
|
|
71767
71972
|
}),
|
|
71768
|
-
locks: openRepositoryLocks({ dir: (0,
|
|
71973
|
+
locks: openRepositoryLocks({ dir: (0, import_node_path61.join)(machine.stateDir, "locks"), clock, platform: platform3 }),
|
|
71769
71974
|
log,
|
|
71770
|
-
dir: (0,
|
|
71975
|
+
dir: (0, import_node_path61.join)(machine.stateDir, "checkout-freshness")
|
|
71771
71976
|
}),
|
|
71772
71977
|
prepareAgentContext: createAgentContext({
|
|
71773
|
-
dir: (0,
|
|
71978
|
+
dir: (0, import_node_path61.join)(machine.stateDir, "agent-context"),
|
|
71774
71979
|
homeDir: machine.env.HOME || (0, import_node_os9.homedir)()
|
|
71775
71980
|
})
|
|
71776
71981
|
} : {}
|
|
@@ -71788,7 +71993,7 @@ async function respondToTurn(runningRunId, driver, request2) {
|
|
|
71788
71993
|
}
|
|
71789
71994
|
|
|
71790
71995
|
// src/holder/session-facts.ts
|
|
71791
|
-
var
|
|
71996
|
+
var import_promises65 = require("fs/promises");
|
|
71792
71997
|
var CLI_RSS_CACHE_MS = 1e4;
|
|
71793
71998
|
var LOGIN_PROBLEM_PREFIX = "cli.auth.";
|
|
71794
71999
|
function isLoginFailure(result) {
|
|
@@ -71814,8 +72019,8 @@ function createSessionFacts(options) {
|
|
|
71814
72019
|
const path4 = await resolveCommandOnPath(command, env, platform3);
|
|
71815
72020
|
if (path4 === null) return null;
|
|
71816
72021
|
try {
|
|
71817
|
-
const real = await (0,
|
|
71818
|
-
const info = await (0,
|
|
72022
|
+
const real = await (0, import_promises65.realpath)(path4);
|
|
72023
|
+
const info = await (0, import_promises65.stat)(real);
|
|
71819
72024
|
return { command, key: `${real}:${info.ino}:${info.size}:${info.mtimeMs}` };
|
|
71820
72025
|
} catch {
|
|
71821
72026
|
return null;
|
|
@@ -71909,12 +72114,12 @@ async function steerTurn(runningRunId, driver, request2) {
|
|
|
71909
72114
|
init_acp3();
|
|
71910
72115
|
|
|
71911
72116
|
// src/run-log/archive.ts
|
|
71912
|
-
var
|
|
71913
|
-
var
|
|
72117
|
+
var import_promises66 = require("fs/promises");
|
|
72118
|
+
var import_node_path62 = require("path");
|
|
71914
72119
|
init_runtime_v2();
|
|
71915
72120
|
async function openRunArchive(runsDir) {
|
|
71916
|
-
const path4 = (0,
|
|
71917
|
-
const text3 = await (0,
|
|
72121
|
+
const path4 = (0, import_node_path62.join)((0, import_node_path62.dirname)(runsDir), "archived-runs.txt");
|
|
72122
|
+
const text3 = await (0, import_promises66.readFile)(path4, "utf8").catch((error62) => {
|
|
71918
72123
|
if (errnoCode(error62) === "ENOENT") return "";
|
|
71919
72124
|
throw error62;
|
|
71920
72125
|
});
|
|
@@ -71928,7 +72133,7 @@ async function openRunArchive(runsDir) {
|
|
|
71928
72133
|
add: async (runIds) => {
|
|
71929
72134
|
const added = runIds.filter((runId) => !archived.has(runId));
|
|
71930
72135
|
if (added.length === 0) return;
|
|
71931
|
-
await (0,
|
|
72136
|
+
await (0, import_promises66.appendFile)(path4, `
|
|
71932
72137
|
${added.join("\n")}
|
|
71933
72138
|
`, { mode: 384 });
|
|
71934
72139
|
for (const runId of added) archived.add(runId);
|
|
@@ -71939,11 +72144,11 @@ ${added.join("\n")}
|
|
|
71939
72144
|
// src/run-log/complete.ts
|
|
71940
72145
|
var import_node_crypto30 = require("crypto");
|
|
71941
72146
|
var import_node_fs21 = require("fs");
|
|
71942
|
-
var
|
|
72147
|
+
var import_node_path64 = require("path");
|
|
71943
72148
|
|
|
71944
72149
|
// src/run-log/directory.ts
|
|
71945
|
-
var
|
|
71946
|
-
var
|
|
72150
|
+
var import_promises67 = require("fs/promises");
|
|
72151
|
+
var import_node_path63 = require("path");
|
|
71947
72152
|
init_runtime_v2();
|
|
71948
72153
|
init_zod();
|
|
71949
72154
|
var runMetaSchema = external_exports.object({
|
|
@@ -71969,17 +72174,17 @@ async function readRunMeta(path4) {
|
|
|
71969
72174
|
return read.kind === "ok" ? read.value : null;
|
|
71970
72175
|
}
|
|
71971
72176
|
function runDirectory(runsDir, runId) {
|
|
71972
|
-
const dir = (0,
|
|
72177
|
+
const dir = (0, import_node_path63.join)(runsDir, runId);
|
|
71973
72178
|
return {
|
|
71974
72179
|
dir,
|
|
71975
|
-
log: (0,
|
|
71976
|
-
upload: (0,
|
|
71977
|
-
meta: (0,
|
|
72180
|
+
log: (0, import_node_path63.join)(dir, "log.jsonl"),
|
|
72181
|
+
upload: (0, import_node_path63.join)(dir, "upload.json"),
|
|
72182
|
+
meta: (0, import_node_path63.join)(dir, "run.json")
|
|
71978
72183
|
};
|
|
71979
72184
|
}
|
|
71980
72185
|
async function isRunClaimed(runsDir, runId) {
|
|
71981
72186
|
try {
|
|
71982
|
-
return (await (0,
|
|
72187
|
+
return (await (0, import_promises67.stat)(runDirectory(runsDir, runId).log)).size > 0;
|
|
71983
72188
|
} catch (error62) {
|
|
71984
72189
|
if (errnoCode(error62) === "ENOENT") return false;
|
|
71985
72190
|
throw error62;
|
|
@@ -71988,7 +72193,7 @@ async function isRunClaimed(runsDir, runId) {
|
|
|
71988
72193
|
|
|
71989
72194
|
// src/run-log/complete.ts
|
|
71990
72195
|
function writeLogFile(path4, dir, text3) {
|
|
71991
|
-
const temp = (0,
|
|
72196
|
+
const temp = (0, import_node_path64.join)(dir, `.log.${(0, import_node_crypto30.randomUUID)()}.tmp`);
|
|
71992
72197
|
const fd = (0, import_node_fs21.openSync)(temp, "wx", 384);
|
|
71993
72198
|
try {
|
|
71994
72199
|
(0, import_node_fs21.writeSync)(fd, text3);
|
|
@@ -72017,8 +72222,8 @@ async function writeCompleteRunLog(runsDir, meta3, records) {
|
|
|
72017
72222
|
}
|
|
72018
72223
|
|
|
72019
72224
|
// src/run-log/conversation-index.ts
|
|
72020
|
-
var
|
|
72021
|
-
var
|
|
72225
|
+
var import_promises68 = require("fs/promises");
|
|
72226
|
+
var import_node_path65 = require("path");
|
|
72022
72227
|
init_runtime_v2();
|
|
72023
72228
|
init_zod();
|
|
72024
72229
|
var ORDINALS_PER_SHARD = 1e3;
|
|
@@ -72035,13 +72240,13 @@ var coverageSchema = external_exports.object({
|
|
|
72035
72240
|
nextExpectedOrdinal: external_exports.number().int().positive()
|
|
72036
72241
|
});
|
|
72037
72242
|
function conversationsDirectory(runsDir) {
|
|
72038
|
-
return (0,
|
|
72243
|
+
return (0, import_node_path65.join)((0, import_node_path65.dirname)(runsDir), "conversations");
|
|
72039
72244
|
}
|
|
72040
72245
|
function indexDirectory(runsDir, conversationId) {
|
|
72041
|
-
return (0,
|
|
72246
|
+
return (0, import_node_path65.join)(conversationsDirectory(runsDir), conversationId, "turn-index");
|
|
72042
72247
|
}
|
|
72043
72248
|
function shardPath(runsDir, conversationId, ordinal) {
|
|
72044
|
-
return (0,
|
|
72249
|
+
return (0, import_node_path65.join)(
|
|
72045
72250
|
indexDirectory(runsDir, conversationId),
|
|
72046
72251
|
`${Math.floor(ordinal / ORDINALS_PER_SHARD)}.jsonl`
|
|
72047
72252
|
);
|
|
@@ -72050,10 +72255,10 @@ async function indexConversationRun(runsDir, conversationId, ordinal, assistantO
|
|
|
72050
72255
|
const nextOrdinal = assistantOrdinal + 1;
|
|
72051
72256
|
if (nextOrdinal <= ordinal) throw new Error("Assistant order must follow the prompt");
|
|
72052
72257
|
const path4 = shardPath(runsDir, conversationId, ordinal);
|
|
72053
|
-
await (0,
|
|
72054
|
-
await (0,
|
|
72258
|
+
await (0, import_promises68.mkdir)((0, import_node_path65.dirname)(path4), { recursive: true, mode: 448 });
|
|
72259
|
+
await (0, import_promises68.appendFile)(path4, `${JSON.stringify({ ordinal, nextOrdinal, runId })}
|
|
72055
72260
|
`, { mode: 384 });
|
|
72056
|
-
const coveragePath = (0,
|
|
72261
|
+
const coveragePath = (0, import_node_path65.join)((0, import_node_path65.dirname)((0, import_node_path65.dirname)(path4)), "coverage.json");
|
|
72057
72262
|
const coverage = await readJsonFile(coveragePath, coverageSchema);
|
|
72058
72263
|
const current = coverage.kind === "ok" ? coverage.value : null;
|
|
72059
72264
|
const next = nextCoverage(current, ordinal, nextOrdinal);
|
|
@@ -72068,13 +72273,13 @@ function nextCoverage(current, ordinal, nextOrdinal) {
|
|
|
72068
72273
|
return null;
|
|
72069
72274
|
}
|
|
72070
72275
|
async function readConversationIndexCoverage(runsDir, conversationId) {
|
|
72071
|
-
const path4 = (0,
|
|
72276
|
+
const path4 = (0, import_node_path65.join)((0, import_node_path65.dirname)(indexDirectory(runsDir, conversationId)), "coverage.json");
|
|
72072
72277
|
const result = await readJsonFile(path4, coverageSchema);
|
|
72073
72278
|
return result.kind === "ok" ? result.value : null;
|
|
72074
72279
|
}
|
|
72075
72280
|
async function readConversationRunIndex(runsDir, conversationId, before, limit) {
|
|
72076
72281
|
const directory = indexDirectory(runsDir, conversationId);
|
|
72077
|
-
const names = await (0,
|
|
72282
|
+
const names = await (0, import_promises68.readdir)(directory).catch((error62) => {
|
|
72078
72283
|
if (error62.code === "ENOENT") return [];
|
|
72079
72284
|
throw error62;
|
|
72080
72285
|
});
|
|
@@ -72083,7 +72288,7 @@ async function readConversationRunIndex(runsDir, conversationId, before, limit)
|
|
|
72083
72288
|
).sort((left, right) => right - left);
|
|
72084
72289
|
const selected = [];
|
|
72085
72290
|
for (const shard of shards) {
|
|
72086
|
-
const text3 = await (0,
|
|
72291
|
+
const text3 = await (0, import_promises68.readFile)((0, import_node_path65.join)(directory, `${shard}.jsonl`), "utf8");
|
|
72087
72292
|
const records = text3.split("\n").flatMap((line) => {
|
|
72088
72293
|
if (!line) return [];
|
|
72089
72294
|
const parsed = indexRecordSchema.parse(JSON.parse(line));
|
|
@@ -72108,7 +72313,7 @@ async function readIndexableRun(runsDir, name) {
|
|
|
72108
72313
|
return { conversationId: meta3.conversationId, ordinal, assistantOrdinal, runId: runId.data };
|
|
72109
72314
|
}
|
|
72110
72315
|
async function readIndexableRuns(runsDir) {
|
|
72111
|
-
const names = await (0,
|
|
72316
|
+
const names = await (0, import_promises68.readdir)(runsDir).catch(() => []);
|
|
72112
72317
|
const byConversation = /* @__PURE__ */ new Map();
|
|
72113
72318
|
let next = 0;
|
|
72114
72319
|
const worker = async () => {
|
|
@@ -72138,21 +72343,21 @@ async function writeConversationIndex(directory, runs) {
|
|
|
72138
72343
|
else lines2.push(line);
|
|
72139
72344
|
coverage = nextCoverage(coverage, run2.ordinal, nextOrdinal) ?? coverage;
|
|
72140
72345
|
}
|
|
72141
|
-
await (0,
|
|
72346
|
+
await (0, import_promises68.mkdir)((0, import_node_path65.join)(directory, "turn-index"), { recursive: true, mode: 448 });
|
|
72142
72347
|
for (const [shard, lines2] of shards) {
|
|
72143
|
-
await (0,
|
|
72348
|
+
await (0, import_promises68.writeFile)((0, import_node_path65.join)(directory, "turn-index", `${shard}.jsonl`), `${lines2.join("\n")}
|
|
72144
72349
|
`, {
|
|
72145
72350
|
mode: 384
|
|
72146
72351
|
});
|
|
72147
72352
|
}
|
|
72148
|
-
await (0,
|
|
72353
|
+
await (0, import_promises68.writeFile)((0, import_node_path65.join)(directory, "coverage.json"), `${JSON.stringify(coverage)}
|
|
72149
72354
|
`, {
|
|
72150
72355
|
mode: 384
|
|
72151
72356
|
});
|
|
72152
72357
|
}
|
|
72153
72358
|
async function rebuildConversationIndexes(runsDir) {
|
|
72154
72359
|
const root = conversationsDirectory(runsDir);
|
|
72155
|
-
const exists6 = await (0,
|
|
72360
|
+
const exists6 = await (0, import_promises68.stat)(root).then(
|
|
72156
72361
|
() => true,
|
|
72157
72362
|
(error62) => {
|
|
72158
72363
|
if (errnoCode(error62) === "ENOENT") return false;
|
|
@@ -72161,18 +72366,18 @@ async function rebuildConversationIndexes(runsDir) {
|
|
|
72161
72366
|
);
|
|
72162
72367
|
if (exists6) return 0;
|
|
72163
72368
|
const building = `${root}.rebuilding`;
|
|
72164
|
-
await (0,
|
|
72165
|
-
await (0,
|
|
72369
|
+
await (0, import_promises68.rm)(building, { recursive: true, force: true });
|
|
72370
|
+
await (0, import_promises68.mkdir)(building, { recursive: true, mode: 448 });
|
|
72166
72371
|
const byConversation = await readIndexableRuns(runsDir);
|
|
72167
72372
|
for (const [conversationId, runs] of byConversation) {
|
|
72168
|
-
await writeConversationIndex((0,
|
|
72373
|
+
await writeConversationIndex((0, import_node_path65.join)(building, conversationId), runs);
|
|
72169
72374
|
}
|
|
72170
|
-
await (0,
|
|
72375
|
+
await (0, import_promises68.rename)(building, root);
|
|
72171
72376
|
return byConversation.size;
|
|
72172
72377
|
}
|
|
72173
72378
|
|
|
72174
72379
|
// src/run-log/reader.ts
|
|
72175
|
-
var
|
|
72380
|
+
var import_promises69 = require("fs/promises");
|
|
72176
72381
|
init_runtime_v2();
|
|
72177
72382
|
|
|
72178
72383
|
// src/run-log/tail.ts
|
|
@@ -72195,7 +72400,7 @@ function firstRecordLength(bytes) {
|
|
|
72195
72400
|
return bytes.indexOf(RUN_LOG_RECORD_SEPARATOR) + 1;
|
|
72196
72401
|
}
|
|
72197
72402
|
async function openRunLogReader(path4) {
|
|
72198
|
-
const handle = await (0,
|
|
72403
|
+
const handle = await (0, import_promises69.open)(path4, "r");
|
|
72199
72404
|
const readAt = async (position, length) => {
|
|
72200
72405
|
const buffer = Buffer.alloc(length);
|
|
72201
72406
|
const { bytesRead } = await handle.read(buffer, 0, length, position);
|
|
@@ -72229,7 +72434,7 @@ async function openRunLogReader(path4) {
|
|
|
72229
72434
|
};
|
|
72230
72435
|
}
|
|
72231
72436
|
async function readLastRecord(path4) {
|
|
72232
|
-
const handle = await (0,
|
|
72437
|
+
const handle = await (0, import_promises69.open)(path4, "r").catch(() => null);
|
|
72233
72438
|
if (handle === null) return null;
|
|
72234
72439
|
try {
|
|
72235
72440
|
const { size } = await handle.stat();
|
|
@@ -72263,7 +72468,7 @@ var decoder = new TextDecoder();
|
|
|
72263
72468
|
|
|
72264
72469
|
// src/run-log/writer.ts
|
|
72265
72470
|
var import_node_fs22 = require("fs");
|
|
72266
|
-
var
|
|
72471
|
+
var import_node_path66 = require("path");
|
|
72267
72472
|
init_runtime_v2();
|
|
72268
72473
|
function lastSeq(fd, size) {
|
|
72269
72474
|
for (const length of tailWindows(size)) {
|
|
@@ -72279,7 +72484,7 @@ function lastSeq(fd, size) {
|
|
|
72279
72484
|
throw new RuntimeFault("record_too_large", "Run log tail record is larger than any record");
|
|
72280
72485
|
}
|
|
72281
72486
|
function openRunLog(path4, clock) {
|
|
72282
|
-
(0, import_node_fs22.mkdirSync)((0,
|
|
72487
|
+
(0, import_node_fs22.mkdirSync)((0, import_node_path66.dirname)(path4), { recursive: true, mode: 448 });
|
|
72283
72488
|
const fd = (0, import_node_fs22.openSync)(path4, "a+", 384);
|
|
72284
72489
|
let size = (0, import_node_fs22.fstatSync)(fd).size;
|
|
72285
72490
|
let seq = lastSeq(fd, size);
|
|
@@ -72523,7 +72728,7 @@ async function runHolder({
|
|
|
72523
72728
|
try {
|
|
72524
72729
|
const identity = await readProcessIdentity(process.pid);
|
|
72525
72730
|
if (identity === null) throw new RuntimeFault("internal", "Cannot read own process identity");
|
|
72526
|
-
const _engines = __using(_stack, recordSpawnedEngines(engineRecordsPath((0,
|
|
72731
|
+
const _engines = __using(_stack, recordSpawnedEngines(engineRecordsPath((0, import_node_path67.dirname)(launch.statusPath)), clock, log));
|
|
72527
72732
|
const holder = {
|
|
72528
72733
|
state: "idle",
|
|
72529
72734
|
runId: null,
|
|
@@ -72531,7 +72736,7 @@ async function runHolder({
|
|
|
72531
72736
|
clients: /* @__PURE__ */ new Set()
|
|
72532
72737
|
};
|
|
72533
72738
|
const activity = __using(_stack, startActivityFile({
|
|
72534
|
-
path: sessionActivityPath((0,
|
|
72739
|
+
path: sessionActivityPath((0, import_node_path67.dirname)(launch.statusPath)),
|
|
72535
72740
|
read: () => ({
|
|
72536
72741
|
runId: holder.runId,
|
|
72537
72742
|
...driver.activity?.() ?? IDLE_DRIVER_ACTIVITY
|
|
@@ -72752,16 +72957,16 @@ async function runHolder({
|
|
|
72752
72957
|
client.on("error", () => holder.clients.delete(client));
|
|
72753
72958
|
});
|
|
72754
72959
|
removeStaleEndpoint(launch.endpoint);
|
|
72755
|
-
await new Promise((
|
|
72960
|
+
await new Promise((resolve14, reject) => {
|
|
72756
72961
|
server.once("error", reject);
|
|
72757
|
-
server.listen(launch.endpoint, () =>
|
|
72962
|
+
server.listen(launch.endpoint, () => resolve14());
|
|
72758
72963
|
});
|
|
72759
72964
|
await writeStatus();
|
|
72760
72965
|
log.info("holder.ready", { conversationId: launch.conversationId, pid: identity.pid });
|
|
72761
|
-
await new Promise((
|
|
72966
|
+
await new Promise((resolve14) => exit.signal.addEventListener("abort", () => resolve14()));
|
|
72762
72967
|
await driver.suspend?.().catch((error62) => log.warn("holder.driver_suspend_failed", { error: error62 }));
|
|
72763
72968
|
for (const client of holder.clients) client.end();
|
|
72764
|
-
await new Promise((
|
|
72969
|
+
await new Promise((resolve14) => server.close(() => resolve14()));
|
|
72765
72970
|
await statusWrites;
|
|
72766
72971
|
(0, import_node_fs23.rmSync)(launch.statusPath, { force: true });
|
|
72767
72972
|
log.info("holder.suspended", { conversationId: launch.conversationId });
|
|
@@ -72781,16 +72986,16 @@ function delta(current, previous) {
|
|
|
72781
72986
|
return previous === void 0 ? 0 : Math.max(0, Math.round(current - previous));
|
|
72782
72987
|
}
|
|
72783
72988
|
async function lastOutputAtMs(runsDir, run2) {
|
|
72784
|
-
const info = await (0,
|
|
72989
|
+
const info = await (0, import_promises70.stat)(runDirectory(runsDir, run2.runId).log).catch(() => null);
|
|
72785
72990
|
return info === null ? null : Math.floor(info.mtimeMs);
|
|
72786
72991
|
}
|
|
72787
72992
|
async function readHolderActivities(sessionsDir) {
|
|
72788
|
-
const names = await (0,
|
|
72993
|
+
const names = await (0, import_promises70.readdir)(sessionsDir).catch(() => []);
|
|
72789
72994
|
const found = [];
|
|
72790
72995
|
for (const name of names) {
|
|
72791
72996
|
const parsed = conversationIdSchema.safeParse(name);
|
|
72792
72997
|
if (!parsed.success) continue;
|
|
72793
|
-
const activity = await readSessionActivity(sessionActivityPath((0,
|
|
72998
|
+
const activity = await readSessionActivity(sessionActivityPath((0, import_node_path68.join)(sessionsDir, name)));
|
|
72794
72999
|
if (activity !== null) found.push({ conversationId: parsed.data, activity });
|
|
72795
73000
|
}
|
|
72796
73001
|
return found;
|
|
@@ -73068,17 +73273,17 @@ async function runActivityLeaseWorker(rawData, port) {
|
|
|
73068
73273
|
|
|
73069
73274
|
// src/cli/commands/compat.ts
|
|
73070
73275
|
var import_node_crypto33 = require("crypto");
|
|
73071
|
-
var
|
|
73276
|
+
var import_promises74 = require("fs/promises");
|
|
73072
73277
|
init_runtime_v2();
|
|
73073
73278
|
init_zod();
|
|
73074
73279
|
|
|
73075
73280
|
// src/cli/config.ts
|
|
73076
73281
|
var import_node_os10 = require("os");
|
|
73077
|
-
var
|
|
73282
|
+
var import_node_path72 = require("path");
|
|
73078
73283
|
init_zod();
|
|
73079
73284
|
|
|
73080
73285
|
// src/client/contract.ts
|
|
73081
|
-
var
|
|
73286
|
+
var import_node_path69 = require("path");
|
|
73082
73287
|
init_runtime_v2();
|
|
73083
73288
|
init_zod();
|
|
73084
73289
|
var LOCAL_API_PROTOCOL = 1;
|
|
@@ -73251,7 +73456,7 @@ var nativeHookSignalSchema = external_exports.strictObject({
|
|
|
73251
73456
|
provider: external_exports.enum(nativeIngestionProviders),
|
|
73252
73457
|
event: external_exports.enum(nativeIngestionHookEvents),
|
|
73253
73458
|
externalSessionId: external_exports.string().trim().min(1).max(200),
|
|
73254
|
-
transcriptPath: external_exports.string().min(1).max(4096).refine(
|
|
73459
|
+
transcriptPath: external_exports.string().min(1).max(4096).refine(import_node_path69.isAbsolute, "transcriptPath must be absolute"),
|
|
73255
73460
|
cwd: external_exports.string().max(4096).nullable(),
|
|
73256
73461
|
providerTurnId: external_exports.string().max(200).nullable(),
|
|
73257
73462
|
assistantFingerprint: assistantFingerprintSchema.nullable(),
|
|
@@ -73287,19 +73492,19 @@ var localApiErrorSchema = external_exports.object({
|
|
|
73287
73492
|
});
|
|
73288
73493
|
|
|
73289
73494
|
// src/client/locate.ts
|
|
73290
|
-
var
|
|
73495
|
+
var import_node_path70 = require("path");
|
|
73291
73496
|
var RUNTIME_PROFILES = ["production", "staging", "development", "local"];
|
|
73292
73497
|
function defaultStateDir({ profile, platform: platform3, home, env }) {
|
|
73293
73498
|
if (platform3 === "win32") {
|
|
73294
|
-
return (0,
|
|
73499
|
+
return (0, import_node_path70.join)(env.LOCALAPPDATA ?? (0, import_node_path70.join)(home, "AppData", "Local"), "Alan", profile);
|
|
73295
73500
|
}
|
|
73296
|
-
return (0,
|
|
73501
|
+
return (0, import_node_path70.join)(env.XDG_STATE_HOME ?? (0, import_node_path70.join)(home, ".local", "state"), "alan", profile);
|
|
73297
73502
|
}
|
|
73298
73503
|
function defaultInstallDir({ platform: platform3, home, env }) {
|
|
73299
73504
|
if (platform3 === "win32") {
|
|
73300
|
-
return (0,
|
|
73505
|
+
return (0, import_node_path70.join)(env.LOCALAPPDATA ?? (0, import_node_path70.join)(home, "AppData", "Local"), "Alan", "runtime");
|
|
73301
73506
|
}
|
|
73302
|
-
return (0,
|
|
73507
|
+
return (0, import_node_path70.join)(env.XDG_DATA_HOME ?? (0, import_node_path70.join)(home, ".local", "share"), "alan", "runtime");
|
|
73303
73508
|
}
|
|
73304
73509
|
|
|
73305
73510
|
// src/client/machine-features-contract.ts
|
|
@@ -73358,7 +73563,7 @@ var mcpConfigResultSchema = external_exports.object({
|
|
|
73358
73563
|
});
|
|
73359
73564
|
|
|
73360
73565
|
// src/client/runtime-client.ts
|
|
73361
|
-
var
|
|
73566
|
+
var import_promises71 = require("fs/promises");
|
|
73362
73567
|
init_acp();
|
|
73363
73568
|
init_runtime_v2();
|
|
73364
73569
|
|
|
@@ -73419,7 +73624,7 @@ var DEFAULT_BACKOFF = { initialMs: 250, maxMs: 3e4 };
|
|
|
73419
73624
|
async function readDiscovery(path4) {
|
|
73420
73625
|
let text3;
|
|
73421
73626
|
try {
|
|
73422
|
-
text3 = await (0,
|
|
73627
|
+
text3 = await (0, import_promises71.readFile)(path4, "utf8");
|
|
73423
73628
|
} catch (error62) {
|
|
73424
73629
|
throw new RuntimeClientError("unavailable", "The runtime is not running", { cause: error62 });
|
|
73425
73630
|
}
|
|
@@ -73492,8 +73697,8 @@ function nextOffsetOf(response) {
|
|
|
73492
73697
|
async function pause(ms, signal) {
|
|
73493
73698
|
const either = AbortSignal.any([signal, AbortSignal.timeout(ms)]);
|
|
73494
73699
|
if (either.aborted) return;
|
|
73495
|
-
await new Promise((
|
|
73496
|
-
either.addEventListener("abort", () =>
|
|
73700
|
+
await new Promise((resolve14) => {
|
|
73701
|
+
either.addEventListener("abort", () => resolve14(), { once: true });
|
|
73497
73702
|
});
|
|
73498
73703
|
}
|
|
73499
73704
|
function jittered(backoff, failures) {
|
|
@@ -73802,8 +74007,8 @@ async function sendNativeHookSignal(discoveryPath, hookSignal, signal) {
|
|
|
73802
74007
|
|
|
73803
74008
|
// src/sessions/index.ts
|
|
73804
74009
|
var import_node_crypto32 = require("crypto");
|
|
73805
|
-
var
|
|
73806
|
-
var
|
|
74010
|
+
var import_promises72 = require("fs/promises");
|
|
74011
|
+
var import_node_path71 = require("path");
|
|
73807
74012
|
init_runtime_v2();
|
|
73808
74013
|
|
|
73809
74014
|
// src/sessions/admission.ts
|
|
@@ -73849,7 +74054,7 @@ var DEFAULT_MAX_ACTIVE_RUNS = 32;
|
|
|
73849
74054
|
var HOLDER_BUSY = "busy";
|
|
73850
74055
|
async function listIds(dir, schema) {
|
|
73851
74056
|
const ids = [];
|
|
73852
|
-
for (const name of await (0,
|
|
74057
|
+
for (const name of await (0, import_promises72.readdir)(dir).catch(() => [])) {
|
|
73853
74058
|
const parsed = schema.safeParse(name);
|
|
73854
74059
|
if (parsed.success) ids.push(parsed.data);
|
|
73855
74060
|
}
|
|
@@ -73863,8 +74068,8 @@ function holderIdentity(status) {
|
|
|
73863
74068
|
return command === void 0 ? { pid, startedAt } : { pid, startedAt, command };
|
|
73864
74069
|
}
|
|
73865
74070
|
function sessionFiles(paths, conversationId) {
|
|
73866
|
-
const dir = (0,
|
|
73867
|
-
return { dir, launch: (0,
|
|
74071
|
+
const dir = (0, import_node_path71.join)(paths.sessions, conversationId);
|
|
74072
|
+
return { dir, launch: (0, import_node_path71.join)(dir, "launch.json"), status: (0, import_node_path71.join)(dir, "holder.json") };
|
|
73868
74073
|
}
|
|
73869
74074
|
async function removeHolderFiles(files) {
|
|
73870
74075
|
const holderWritten = [
|
|
@@ -73874,9 +74079,9 @@ async function removeHolderFiles(files) {
|
|
|
73874
74079
|
sessionActivityPath(files.dir)
|
|
73875
74080
|
];
|
|
73876
74081
|
for (const path4 of holderWritten) {
|
|
73877
|
-
await (0,
|
|
74082
|
+
await (0, import_promises72.rm)(path4, { force: true });
|
|
73878
74083
|
}
|
|
73879
|
-
await (0,
|
|
74084
|
+
await (0, import_promises72.rmdir)(files.dir).catch((error62) => {
|
|
73880
74085
|
if (!["ENOENT", "ENOTEMPTY", "EEXIST"].includes(errnoCode(error62) ?? "")) throw error62;
|
|
73881
74086
|
});
|
|
73882
74087
|
}
|
|
@@ -74072,7 +74277,7 @@ async function openSessions(deps) {
|
|
|
74072
74277
|
const meta3 = await readRunMeta(dir.meta);
|
|
74073
74278
|
const last = await readLastRecord(dir.log);
|
|
74074
74279
|
if (meta3 === null || last === null) return null;
|
|
74075
|
-
const logged = await (0,
|
|
74280
|
+
const logged = await (0, import_promises72.stat)(dir.log).catch((error62) => {
|
|
74076
74281
|
if (errnoCode(error62) === "ENOENT") return null;
|
|
74077
74282
|
throw error62;
|
|
74078
74283
|
});
|
|
@@ -74363,6 +74568,9 @@ var SECRET_VARIABLES = /* @__PURE__ */ new Set([
|
|
|
74363
74568
|
ENROLLMENT_CODE_VARIABLE
|
|
74364
74569
|
]);
|
|
74365
74570
|
var ALAN_CODE_ENGINE_VARIABLE = "ALAN_CODE_ENGINE_PATH";
|
|
74571
|
+
function codexSkillsDir(config2) {
|
|
74572
|
+
return config2.gitGatewayUrl === null ? null : (0, import_node_path72.join)(config2.codexHome, "skills");
|
|
74573
|
+
}
|
|
74366
74574
|
function loadRuntimeConfig(env = process.env) {
|
|
74367
74575
|
const parsed = envSchema.safeParse(env);
|
|
74368
74576
|
if (!parsed.success) {
|
|
@@ -74422,7 +74630,7 @@ function loadRuntimeConfig(env = process.env) {
|
|
|
74422
74630
|
providerProbes: ALAN_RUNTIME_PROVIDER_PROBES === "on",
|
|
74423
74631
|
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,
|
|
74424
74632
|
home,
|
|
74425
|
-
configHome: XDG_CONFIG_HOME ?? (0,
|
|
74633
|
+
configHome: XDG_CONFIG_HOME ?? (0, import_node_path72.join)(home, ".config"),
|
|
74426
74634
|
codexHome: resolveCodexHome(CODEX_HOME, home),
|
|
74427
74635
|
...githubProxyConfig({ ALAN_RUNTIME_GITHUB_PROXY, XDG_CONFIG_HOME, GH_CONFIG_DIR }, home),
|
|
74428
74636
|
gitGatewayUrl: ALAN_RUNTIME_GIT_GATEWAY_URL ?? null,
|
|
@@ -74433,13 +74641,13 @@ function loadRuntimeConfig(env = process.env) {
|
|
|
74433
74641
|
};
|
|
74434
74642
|
}
|
|
74435
74643
|
function resolveCodexHome(configuredHome, home) {
|
|
74436
|
-
return configuredHome ?? (0,
|
|
74644
|
+
return configuredHome ?? (0, import_node_path72.join)(home, ".codex");
|
|
74437
74645
|
}
|
|
74438
74646
|
function githubProxyConfig(env, home) {
|
|
74439
|
-
const configHome = env.XDG_CONFIG_HOME ?? (0,
|
|
74647
|
+
const configHome = env.XDG_CONFIG_HOME ?? (0, import_node_path72.join)(home, ".config");
|
|
74440
74648
|
return {
|
|
74441
74649
|
githubProxy: env.ALAN_RUNTIME_GITHUB_PROXY === "on",
|
|
74442
|
-
ghConfigDir: env.GH_CONFIG_DIR ?? (0,
|
|
74650
|
+
ghConfigDir: env.GH_CONFIG_DIR ?? (0, import_node_path72.join)(configHome, "gh")
|
|
74443
74651
|
};
|
|
74444
74652
|
}
|
|
74445
74653
|
function serviceEnvironment2(env, profile) {
|
|
@@ -74497,9 +74705,9 @@ function takeEnrollmentCodeFromEnv(env = process.env) {
|
|
|
74497
74705
|
}
|
|
74498
74706
|
|
|
74499
74707
|
// src/cli/context.ts
|
|
74500
|
-
var
|
|
74708
|
+
var import_promises73 = require("fs/promises");
|
|
74501
74709
|
var import_node_os11 = require("os");
|
|
74502
|
-
var
|
|
74710
|
+
var import_node_path73 = require("path");
|
|
74503
74711
|
var DESKTOP_BUNDLE_IDS = {
|
|
74504
74712
|
production: ["com.alan-ai.desktop"],
|
|
74505
74713
|
staging: ["com.alan-ai.desktop.staging"],
|
|
@@ -74539,7 +74747,7 @@ function serviceSpec({ config: config2, paths, self }) {
|
|
|
74539
74747
|
profile: config2.profile,
|
|
74540
74748
|
program: serviceCommand(config2.host, self, launcher),
|
|
74541
74749
|
environment: config2.serviceEnvironment,
|
|
74542
|
-
logPath: (0,
|
|
74750
|
+
logPath: (0, import_node_path73.join)(paths.logs, "service.log"),
|
|
74543
74751
|
associatedBundleIds: DESKTOP_BUNDLE_IDS[config2.profile]
|
|
74544
74752
|
};
|
|
74545
74753
|
}
|
|
@@ -74547,7 +74755,7 @@ async function installedServiceSpec(ctx) {
|
|
|
74547
74755
|
const spec = serviceSpec(ctx);
|
|
74548
74756
|
if (ctx.config.host === "app") return spec;
|
|
74549
74757
|
const layout = installLayout(ctx.config.installDir, ctx.config.profile);
|
|
74550
|
-
const installed = await (0,
|
|
74758
|
+
const installed = await (0, import_promises73.access)(layout.launcher).then(
|
|
74551
74759
|
() => true,
|
|
74552
74760
|
() => false
|
|
74553
74761
|
);
|
|
@@ -74675,7 +74883,7 @@ var manifestRevisionSchema = external_exports.object({ revision: external_export
|
|
|
74675
74883
|
async function manifestRevision(path4) {
|
|
74676
74884
|
let raw;
|
|
74677
74885
|
try {
|
|
74678
|
-
raw = JSON.parse(await (0,
|
|
74886
|
+
raw = JSON.parse(await (0, import_promises74.readFile)(path4, "utf8"));
|
|
74679
74887
|
} catch (error62) {
|
|
74680
74888
|
throw new RuntimeFault("invalid_file", `Cannot read the skill manifest at ${path4}`, {
|
|
74681
74889
|
cause: error62
|
|
@@ -74729,8 +74937,8 @@ async function runSkills(argv) {
|
|
|
74729
74937
|
}
|
|
74730
74938
|
|
|
74731
74939
|
// src/cli/commands/doctor.ts
|
|
74732
|
-
var
|
|
74733
|
-
var
|
|
74940
|
+
var import_promises77 = require("fs/promises");
|
|
74941
|
+
var import_node_path77 = require("path");
|
|
74734
74942
|
init_runtime_v2();
|
|
74735
74943
|
|
|
74736
74944
|
// src/identity/credential.ts
|
|
@@ -74739,7 +74947,7 @@ init_zod();
|
|
|
74739
74947
|
|
|
74740
74948
|
// src/identity/installation.ts
|
|
74741
74949
|
var import_node_crypto34 = require("crypto");
|
|
74742
|
-
var
|
|
74950
|
+
var import_node_path74 = require("path");
|
|
74743
74951
|
init_runtime_v2();
|
|
74744
74952
|
init_zod();
|
|
74745
74953
|
var installationFileSchema = external_exports.object({
|
|
@@ -74747,7 +74955,7 @@ var installationFileSchema = external_exports.object({
|
|
|
74747
74955
|
machineId: machineIdSchema.optional()
|
|
74748
74956
|
});
|
|
74749
74957
|
function installationPath(paths) {
|
|
74750
|
-
return (0,
|
|
74958
|
+
return (0, import_node_path74.join)(paths.stateDir, "installation.json");
|
|
74751
74959
|
}
|
|
74752
74960
|
async function readInstallation(paths) {
|
|
74753
74961
|
const result = await readJsonFile(installationPath(paths), installationFileSchema);
|
|
@@ -74938,7 +75146,7 @@ async function authorizeDevice(input2) {
|
|
|
74938
75146
|
}
|
|
74939
75147
|
|
|
74940
75148
|
// src/identity/enroll.ts
|
|
74941
|
-
var
|
|
75149
|
+
var import_promises75 = require("fs/promises");
|
|
74942
75150
|
init_runtime_v2();
|
|
74943
75151
|
async function enrollMachine(input2) {
|
|
74944
75152
|
const machineId = input2.machineId ?? (await readMachineFile(input2.paths))?.machineId ?? (await readInstallation(input2.paths))?.machineId;
|
|
@@ -75021,13 +75229,13 @@ async function enrollFromGrantFile(input2) {
|
|
|
75021
75229
|
clock: input2.clock,
|
|
75022
75230
|
access: input2.access
|
|
75023
75231
|
});
|
|
75024
|
-
await (0,
|
|
75232
|
+
await (0, import_promises75.rm)(input2.grantPath, { force: true });
|
|
75025
75233
|
return machine;
|
|
75026
75234
|
}
|
|
75027
75235
|
|
|
75028
75236
|
// src/identity/migrate-v1.ts
|
|
75029
|
-
var
|
|
75030
|
-
var
|
|
75237
|
+
var import_promises76 = require("fs/promises");
|
|
75238
|
+
var import_node_path75 = require("path");
|
|
75031
75239
|
init_runtime_v2();
|
|
75032
75240
|
init_zod();
|
|
75033
75241
|
var EXIT_POLL_MS = 200;
|
|
@@ -75050,11 +75258,11 @@ var ownerLeaseSchema = external_exports.looseObject({ pid: external_exports.numb
|
|
|
75050
75258
|
function legacyConfigPath(home, profile) {
|
|
75051
75259
|
switch (profile) {
|
|
75052
75260
|
case "production":
|
|
75053
|
-
return (0,
|
|
75261
|
+
return (0, import_node_path75.join)(home, ".alan", "agent", "config.json");
|
|
75054
75262
|
case "staging":
|
|
75055
|
-
return (0,
|
|
75263
|
+
return (0, import_node_path75.join)(home, ".alan-staging", "agent", "config.json");
|
|
75056
75264
|
default:
|
|
75057
|
-
return (0,
|
|
75265
|
+
return (0, import_node_path75.join)(home, ".alan-dev", "agent", "config.json");
|
|
75058
75266
|
}
|
|
75059
75267
|
}
|
|
75060
75268
|
async function findLegacyInstall(home, profile) {
|
|
@@ -75112,8 +75320,8 @@ async function scrubLegacyInstall(install2) {
|
|
|
75112
75320
|
const scrubbed = { ...install2.config, migratedToRuntimeV2: true };
|
|
75113
75321
|
for (const key of SCRUBBED_KEYS) delete scrubbed[key];
|
|
75114
75322
|
await writeJsonFileAtomic(`${install2.configPath}.migrated-v1`, scrubbed);
|
|
75115
|
-
await (0,
|
|
75116
|
-
await (0,
|
|
75323
|
+
await (0, import_promises76.rm)(install2.configPath, { force: true });
|
|
75324
|
+
await (0, import_promises76.rm)(install2.ownerLeasePath, { force: true });
|
|
75117
75325
|
}
|
|
75118
75326
|
async function exchangeCredential(deps) {
|
|
75119
75327
|
const { config: config2 } = deps.install;
|
|
@@ -75227,7 +75435,7 @@ async function loadIdentity(paths, options = {}) {
|
|
|
75227
75435
|
}
|
|
75228
75436
|
|
|
75229
75437
|
// src/cli/commands/status.ts
|
|
75230
|
-
var
|
|
75438
|
+
var import_node_path76 = require("path");
|
|
75231
75439
|
async function serviceStatus(ctx) {
|
|
75232
75440
|
try {
|
|
75233
75441
|
return await createServiceManager(ctx.host, ctx.config.profile).status();
|
|
@@ -75254,7 +75462,7 @@ async function runtimeState(ctx) {
|
|
|
75254
75462
|
const running = await readRunningRuntime(ctx.paths.lock);
|
|
75255
75463
|
if (running === null) return { state: "offline", pid: null, localApi: null };
|
|
75256
75464
|
const discovery = await readJsonFile(
|
|
75257
|
-
(0,
|
|
75465
|
+
(0, import_node_path76.join)(ctx.paths.stateDir, LOCAL_API_DISCOVERY_FILE),
|
|
75258
75466
|
localApiDiscoverySchema
|
|
75259
75467
|
);
|
|
75260
75468
|
const localApi = discovery.kind === "ok" && discovery.value.pid === running.pid ? {
|
|
@@ -75475,7 +75683,7 @@ async function runtimeCheck(ctx, status) {
|
|
|
75475
75683
|
return check2("runtime", "warn", "No runtime is running for this profile");
|
|
75476
75684
|
}
|
|
75477
75685
|
const client = createRuntimeClient({
|
|
75478
|
-
discoveryPath: (0,
|
|
75686
|
+
discoveryPath: (0, import_node_path77.join)(ctx.paths.stateDir, LOCAL_API_DISCOVERY_FILE)
|
|
75479
75687
|
});
|
|
75480
75688
|
try {
|
|
75481
75689
|
const live = await client.status(AbortSignal.timeout(LOCAL_TIMEOUT_MS));
|
|
@@ -75502,7 +75710,7 @@ async function runtimeCheck(ctx, status) {
|
|
|
75502
75710
|
}
|
|
75503
75711
|
}
|
|
75504
75712
|
async function probeHolder(dir, conversationId) {
|
|
75505
|
-
const launch = await readJsonFile((0,
|
|
75713
|
+
const launch = await readJsonFile((0, import_node_path77.join)(dir, "launch.json"), holderLaunchSchema);
|
|
75506
75714
|
if (launch.kind !== "ok") return null;
|
|
75507
75715
|
try {
|
|
75508
75716
|
const reply2 = await withTimeout(
|
|
@@ -75527,8 +75735,8 @@ async function probeHolder(dir, conversationId) {
|
|
|
75527
75735
|
}
|
|
75528
75736
|
}
|
|
75529
75737
|
async function holdersCheck(ctx) {
|
|
75530
|
-
const names = await (0,
|
|
75531
|
-
const holders = (await Promise.all(names.map((name) => probeHolder((0,
|
|
75738
|
+
const names = await (0, import_promises77.readdir)(ctx.paths.sessions).catch(() => []);
|
|
75739
|
+
const holders = (await Promise.all(names.map((name) => probeHolder((0, import_node_path77.join)(ctx.paths.sessions, name), name)))).filter((facts) => facts !== null);
|
|
75532
75740
|
const dead = holders.filter((holder) => !holder.alive).length;
|
|
75533
75741
|
return check2(
|
|
75534
75742
|
"holders",
|
|
@@ -75539,10 +75747,10 @@ async function holdersCheck(ctx) {
|
|
|
75539
75747
|
}
|
|
75540
75748
|
async function freeBytesAt(path4) {
|
|
75541
75749
|
try {
|
|
75542
|
-
const stats = await (0,
|
|
75750
|
+
const stats = await (0, import_promises77.statfs)(path4);
|
|
75543
75751
|
return { path: path4, freeBytes: stats.bavail * stats.bsize };
|
|
75544
75752
|
} catch (error62) {
|
|
75545
|
-
const parent = (0,
|
|
75753
|
+
const parent = (0, import_node_path77.dirname)(path4);
|
|
75546
75754
|
if (parent === path4) throw error62;
|
|
75547
75755
|
return freeBytesAt(parent);
|
|
75548
75756
|
}
|
|
@@ -75560,9 +75768,9 @@ async function diskCheck(ctx) {
|
|
|
75560
75768
|
}
|
|
75561
75769
|
}
|
|
75562
75770
|
var resolveFromLoginShell = (own2) => resolveCliEnvironment({ env: own2, platform: process.platform });
|
|
75563
|
-
async function cliDiscoveryCheck(
|
|
75771
|
+
async function cliDiscoveryCheck(resolve14) {
|
|
75564
75772
|
const own2 = readCliEnvironment();
|
|
75565
|
-
const env = await
|
|
75773
|
+
const env = await resolve14(own2);
|
|
75566
75774
|
const delimiter = process.platform === "win32" ? ";" : ":";
|
|
75567
75775
|
const ownDirs = new Set((own2.PATH ?? "").split(delimiter));
|
|
75568
75776
|
const added = (env.PATH ?? "").split(delimiter).filter((dir) => dir.length > 0 && !ownDirs.has(dir));
|
|
@@ -75678,7 +75886,7 @@ async function runDoctor(argv, context = cliContext) {
|
|
|
75678
75886
|
}
|
|
75679
75887
|
|
|
75680
75888
|
// src/cli/commands/git-credential.ts
|
|
75681
|
-
var
|
|
75889
|
+
var import_promises78 = require("fs/promises");
|
|
75682
75890
|
var import_node_net4 = require("net");
|
|
75683
75891
|
var MAX_RESPONSE_BYTES = 64 * 1024;
|
|
75684
75892
|
async function readAll(stream) {
|
|
@@ -75696,7 +75904,7 @@ function processIo() {
|
|
|
75696
75904
|
};
|
|
75697
75905
|
}
|
|
75698
75906
|
function askGitCredentialSocket(endpoint, request2, signal) {
|
|
75699
|
-
return new Promise((
|
|
75907
|
+
return new Promise((resolve14, reject) => {
|
|
75700
75908
|
const socket = (0, import_node_net4.createConnection)(endpoint);
|
|
75701
75909
|
let buffered = "";
|
|
75702
75910
|
const fail = (error62) => {
|
|
@@ -75723,7 +75931,7 @@ function askGitCredentialSocket(endpoint, request2, signal) {
|
|
|
75723
75931
|
signal.removeEventListener("abort", onAbort);
|
|
75724
75932
|
try {
|
|
75725
75933
|
const line = buffered.split("\n", 1)[0] ?? "";
|
|
75726
|
-
|
|
75934
|
+
resolve14(gitCredentialSocketResponseSchema.parse(JSON.parse(line)));
|
|
75727
75935
|
} catch (error62) {
|
|
75728
75936
|
reject(
|
|
75729
75937
|
new RuntimeFault("io_failed", "the Alan runtime sent an invalid reply", { cause: error62 })
|
|
@@ -75795,7 +76003,7 @@ async function configure(argv) {
|
|
|
75795
76003
|
}
|
|
75796
76004
|
async function configureGitGateway(config2, gatewayUrl, signal) {
|
|
75797
76005
|
const { launcher } = installLayout(config2.installDir, config2.profile);
|
|
75798
|
-
const installed = await (0,
|
|
76006
|
+
const installed = await (0, import_promises78.access)(launcher).then(
|
|
75799
76007
|
() => true,
|
|
75800
76008
|
() => false
|
|
75801
76009
|
);
|
|
@@ -75824,7 +76032,7 @@ async function runGitCredential(argv) {
|
|
|
75824
76032
|
}
|
|
75825
76033
|
|
|
75826
76034
|
// src/cli/commands/hold.ts
|
|
75827
|
-
var
|
|
76035
|
+
var import_node_path78 = require("path");
|
|
75828
76036
|
init_agent2();
|
|
75829
76037
|
init_runtime_v2();
|
|
75830
76038
|
async function machineAccess(paths, log, conversationId, transport) {
|
|
@@ -75883,7 +76091,7 @@ async function runHold(argv) {
|
|
|
75883
76091
|
const config2 = loadRuntimeConfig();
|
|
75884
76092
|
const paths = runtimePaths(config2.stateDir);
|
|
75885
76093
|
const log = __using(_stack, openFileLog(
|
|
75886
|
-
(0,
|
|
76094
|
+
(0, import_node_path78.join)(paths.logs, `holder-${launch.value.conversationId}.jsonl`),
|
|
75887
76095
|
config2.logLevel,
|
|
75888
76096
|
systemClock
|
|
75889
76097
|
));
|
|
@@ -75894,7 +76102,7 @@ async function runHold(argv) {
|
|
|
75894
76102
|
);
|
|
75895
76103
|
const transport = __using(_stack, createHttpTransport());
|
|
75896
76104
|
const access7 = await machineAccess(paths, log, launch.value.conversationId, transport);
|
|
75897
|
-
const credentialPath = (0,
|
|
76105
|
+
const credentialPath = (0, import_node_path78.join)(paths.tmp, "mcp", `${launch.value.conversationId}.json`);
|
|
75898
76106
|
const managedMcp = __using(_stack, access7.managedMcp === void 0 ? void 0 : createHelperMcpAccess({
|
|
75899
76107
|
managedMcp: access7.managedMcp,
|
|
75900
76108
|
conversationId: launch.value.conversationId,
|
|
@@ -75905,6 +76113,7 @@ async function runHold(argv) {
|
|
|
75905
76113
|
[ALAN_MCP_URL_ENV]: access7.managedMcp.url,
|
|
75906
76114
|
[ALAN_MCP_CREDENTIAL_FILE_ENV]: credentialPath
|
|
75907
76115
|
};
|
|
76116
|
+
const flags = createFlagProbe();
|
|
75908
76117
|
await runHolder({
|
|
75909
76118
|
launch: launch.value,
|
|
75910
76119
|
driver: createProviderDrivers({
|
|
@@ -75923,7 +76132,11 @@ async function runHold(argv) {
|
|
|
75923
76132
|
env: cliEnvironment,
|
|
75924
76133
|
stateDir: paths.stateDir,
|
|
75925
76134
|
// Only a cloud sandbox's runtime has a git gateway.
|
|
75926
|
-
refreshesFirstCheckout: config2.gitGatewayUrl !== null
|
|
76135
|
+
refreshesFirstCheckout: config2.gitGatewayUrl !== null,
|
|
76136
|
+
skillDiscovery: {
|
|
76137
|
+
codexLinksSyncedSkills: codexSkillsDir(config2) !== null,
|
|
76138
|
+
claudeLoadsPlugins: () => flags.supportsFlag("claude", "--plugin-dir", cliEnvironment)
|
|
76139
|
+
}
|
|
75927
76140
|
}
|
|
75928
76141
|
});
|
|
75929
76142
|
} catch (_) {
|
|
@@ -75935,7 +76148,7 @@ async function runHold(argv) {
|
|
|
75935
76148
|
}
|
|
75936
76149
|
|
|
75937
76150
|
// src/cli/commands/hook.ts
|
|
75938
|
-
var
|
|
76151
|
+
var import_node_path79 = require("path");
|
|
75939
76152
|
var RUNTIME_ANSWER_MS = 2e3;
|
|
75940
76153
|
var DEBUG_VARIABLE = "ALAN_HOOK_DEBUG";
|
|
75941
76154
|
function flag(argv, name) {
|
|
@@ -75967,7 +76180,7 @@ async function forwardHook(argv, io) {
|
|
|
75967
76180
|
return "transcript outside provider root";
|
|
75968
76181
|
}
|
|
75969
76182
|
const verdict = await io.send(
|
|
75970
|
-
(0,
|
|
76183
|
+
(0, import_node_path79.join)(io.stateDir, LOCAL_API_DISCOVERY_FILE),
|
|
75971
76184
|
hookSignal,
|
|
75972
76185
|
AbortSignal.timeout(RUNTIME_ANSWER_MS)
|
|
75973
76186
|
);
|
|
@@ -76003,7 +76216,7 @@ async function runHook(argv, overrides = {}) {
|
|
|
76003
76216
|
}
|
|
76004
76217
|
|
|
76005
76218
|
// src/cli/commands/ingestion-hooks.ts
|
|
76006
|
-
var
|
|
76219
|
+
var import_promises79 = require("fs/promises");
|
|
76007
76220
|
var CODEX_TRUST_NOTE = "Codex runs new hooks only after you review them: open /hooks in Codex.";
|
|
76008
76221
|
function isAction(value2) {
|
|
76009
76222
|
return value2 === "enable" || value2 === "disable" || value2 === "status";
|
|
@@ -76026,7 +76239,7 @@ function errorMessage2(error62) {
|
|
|
76026
76239
|
return error62 instanceof Error ? error62.message : String(error62);
|
|
76027
76240
|
}
|
|
76028
76241
|
async function exists5(path4) {
|
|
76029
|
-
return (0,
|
|
76242
|
+
return (0, import_promises79.access)(path4).then(
|
|
76030
76243
|
() => true,
|
|
76031
76244
|
() => false
|
|
76032
76245
|
);
|
|
@@ -76129,10 +76342,10 @@ async function runIntegrationsCommand(argv) {
|
|
|
76129
76342
|
}
|
|
76130
76343
|
|
|
76131
76344
|
// src/cli/commands/legacy.ts
|
|
76132
|
-
var
|
|
76345
|
+
var import_node_path81 = require("path");
|
|
76133
76346
|
|
|
76134
76347
|
// src/cli/commands/setup.ts
|
|
76135
|
-
var
|
|
76348
|
+
var import_node_path80 = require("path");
|
|
76136
76349
|
init_zod();
|
|
76137
76350
|
|
|
76138
76351
|
// src/cli/legacy.ts
|
|
@@ -76216,7 +76429,7 @@ async function grantFileCredential(argv, grantPath, ctx, deps) {
|
|
|
76216
76429
|
return enrollFromGrantFile({
|
|
76217
76430
|
paths: ctx.paths,
|
|
76218
76431
|
storeKind: credentialStoreFlag(argv) ?? ctx.config.credentialStore,
|
|
76219
|
-
grantPath: (0,
|
|
76432
|
+
grantPath: (0, import_node_path80.resolve)(grantPath),
|
|
76220
76433
|
clock: deps.clock,
|
|
76221
76434
|
access: ctx.access
|
|
76222
76435
|
});
|
|
@@ -76292,7 +76505,7 @@ async function runSetup(argv, signal) {
|
|
|
76292
76505
|
var _stack = [];
|
|
76293
76506
|
try {
|
|
76294
76507
|
const ctx = cliContext();
|
|
76295
|
-
const log = __using(_stack, openFileLog((0,
|
|
76508
|
+
const log = __using(_stack, openFileLog((0, import_node_path80.join)(ctx.paths.logs, "cli.jsonl"), ctx.config.logLevel, systemClock));
|
|
76296
76509
|
const result = await setupMachine(argv, ctx, {
|
|
76297
76510
|
enrollment: (apiUrl) => createEnrollmentClient({ apiUrl }),
|
|
76298
76511
|
isProcessAlive,
|
|
@@ -76375,7 +76588,7 @@ async function runToken(argv, signal) {
|
|
|
76375
76588
|
);
|
|
76376
76589
|
}
|
|
76377
76590
|
const ctx = cliContext();
|
|
76378
|
-
const log = __using(_stack, openFileLog((0,
|
|
76591
|
+
const log = __using(_stack, openFileLog((0, import_node_path81.join)(ctx.paths.logs, "cli.jsonl"), ctx.config.logLevel, systemClock));
|
|
76379
76592
|
const result = await rotateMachineCredential(ctx, { clock: systemClock, log, signal });
|
|
76380
76593
|
process.stdout.write(`${rotationMessage(result)}
|
|
76381
76594
|
`);
|
|
@@ -76387,8 +76600,8 @@ async function runToken(argv, signal) {
|
|
|
76387
76600
|
}
|
|
76388
76601
|
|
|
76389
76602
|
// src/cli/commands/logout.ts
|
|
76390
|
-
var
|
|
76391
|
-
var
|
|
76603
|
+
var import_promises80 = require("fs/promises");
|
|
76604
|
+
var import_node_path82 = require("path");
|
|
76392
76605
|
init_runtime_v2();
|
|
76393
76606
|
var RUNTIME_EXIT_WAIT_MS = 35e3;
|
|
76394
76607
|
var TURN_END_WAIT_MS = 3e4;
|
|
@@ -76447,9 +76660,9 @@ async function stopHolder(launch, deps, outcome2) {
|
|
|
76447
76660
|
}
|
|
76448
76661
|
async function stopHeldRuns(ctx, deps, outcome2 = "aborted") {
|
|
76449
76662
|
const stopped = [];
|
|
76450
|
-
for (const name of await (0,
|
|
76663
|
+
for (const name of await (0, import_promises80.readdir)(ctx.paths.sessions).catch(() => [])) {
|
|
76451
76664
|
const launch = await readJsonFile(
|
|
76452
|
-
(0,
|
|
76665
|
+
(0, import_node_path82.join)(ctx.paths.sessions, name, "launch.json"),
|
|
76453
76666
|
holderLaunchSchema
|
|
76454
76667
|
);
|
|
76455
76668
|
if (launch.kind !== "ok") continue;
|
|
@@ -76486,13 +76699,13 @@ async function forgetMachineLocally(ctx) {
|
|
|
76486
76699
|
const machine = await readMachineFile(ctx.paths);
|
|
76487
76700
|
if (machine === null) return;
|
|
76488
76701
|
await credentialStoreFor(ctx.paths, machine.credentialStore, ctx.access).clear();
|
|
76489
|
-
await (0,
|
|
76702
|
+
await (0, import_promises80.rm)(ctx.paths.machine, { force: true });
|
|
76490
76703
|
}
|
|
76491
76704
|
async function runLogout(argv, signal) {
|
|
76492
76705
|
var _stack = [];
|
|
76493
76706
|
try {
|
|
76494
76707
|
const ctx = cliContext();
|
|
76495
|
-
const log = __using(_stack, openFileLog((0,
|
|
76708
|
+
const log = __using(_stack, openFileLog((0, import_node_path82.join)(ctx.paths.logs, "cli.jsonl"), ctx.config.logLevel, systemClock));
|
|
76496
76709
|
const result = await logoutMachine(argv, ctx, {
|
|
76497
76710
|
api: (apiUrl, accessToken) => createApiClient({ apiUrl, accessToken }),
|
|
76498
76711
|
stopHeldRuns,
|
|
@@ -76510,7 +76723,7 @@ async function runLogout(argv, signal) {
|
|
|
76510
76723
|
|
|
76511
76724
|
// src/cli/commands/run.ts
|
|
76512
76725
|
var import_node_fs27 = require("fs");
|
|
76513
|
-
var
|
|
76726
|
+
var import_node_path87 = require("path");
|
|
76514
76727
|
|
|
76515
76728
|
// src/local-api/app-attachments.ts
|
|
76516
76729
|
function createAppAttachments(clock) {
|
|
@@ -76550,7 +76763,7 @@ function createRunAppends() {
|
|
|
76550
76763
|
const pending = waiters.get(runId);
|
|
76551
76764
|
if (pending === void 0) return;
|
|
76552
76765
|
waiters.delete(runId);
|
|
76553
|
-
for (const
|
|
76766
|
+
for (const resolve14 of pending) resolve14();
|
|
76554
76767
|
};
|
|
76555
76768
|
return {
|
|
76556
76769
|
notify: wake,
|
|
@@ -76568,13 +76781,13 @@ function createRunAppends() {
|
|
|
76568
76781
|
},
|
|
76569
76782
|
nextAppend: (runId, signal) => {
|
|
76570
76783
|
if (signal.aborted) return Promise.resolve();
|
|
76571
|
-
return new Promise((
|
|
76784
|
+
return new Promise((resolve14) => {
|
|
76572
76785
|
const done = () => {
|
|
76573
76786
|
signal.removeEventListener("abort", done);
|
|
76574
76787
|
const pending2 = waiters.get(runId);
|
|
76575
76788
|
pending2?.delete(done);
|
|
76576
76789
|
if (pending2?.size === 0) waiters.delete(runId);
|
|
76577
|
-
|
|
76790
|
+
resolve14();
|
|
76578
76791
|
};
|
|
76579
76792
|
const pending = waiters.get(runId) ?? /* @__PURE__ */ new Set();
|
|
76580
76793
|
pending.add(done);
|
|
@@ -76587,9 +76800,9 @@ function createRunAppends() {
|
|
|
76587
76800
|
|
|
76588
76801
|
// src/local-api/server.ts
|
|
76589
76802
|
var import_node_crypto36 = require("crypto");
|
|
76590
|
-
var
|
|
76803
|
+
var import_promises81 = require("fs/promises");
|
|
76591
76804
|
var import_node_http4 = require("http");
|
|
76592
|
-
var
|
|
76805
|
+
var import_node_path83 = require("path");
|
|
76593
76806
|
|
|
76594
76807
|
// src/local-api/guard.ts
|
|
76595
76808
|
var import_node_crypto35 = require("crypto");
|
|
@@ -76666,11 +76879,11 @@ id: ${event.id}
|
|
|
76666
76879
|
${data}
|
|
76667
76880
|
`);
|
|
76668
76881
|
if (accepted || res.destroyed) return;
|
|
76669
|
-
await new Promise((
|
|
76882
|
+
await new Promise((resolve14) => {
|
|
76670
76883
|
const done = () => {
|
|
76671
76884
|
res.off("drain", done);
|
|
76672
76885
|
res.off("close", done);
|
|
76673
|
-
|
|
76886
|
+
resolve14();
|
|
76674
76887
|
};
|
|
76675
76888
|
res.once("drain", done);
|
|
76676
76889
|
res.once("close", done);
|
|
@@ -76898,9 +77111,9 @@ async function readChangedTurn(deps, conversationId, runId, slot) {
|
|
|
76898
77111
|
}
|
|
76899
77112
|
async function nextChangedRuns(bell, signal) {
|
|
76900
77113
|
if (bell.pending.size === 0) {
|
|
76901
|
-
await new Promise((
|
|
76902
|
-
bell.wake =
|
|
76903
|
-
if (signal.aborted || bell.pending.size > 0)
|
|
77114
|
+
await new Promise((resolve14) => {
|
|
77115
|
+
bell.wake = resolve14;
|
|
77116
|
+
if (signal.aborted || bell.pending.size > 0) resolve14();
|
|
76904
77117
|
});
|
|
76905
77118
|
bell.wake = void 0;
|
|
76906
77119
|
}
|
|
@@ -77197,7 +77410,18 @@ var emptyBodySchema = external_exports.object({});
|
|
|
77197
77410
|
function activeRunIds(runs) {
|
|
77198
77411
|
return runs.filter((run2) => run2.state !== "ended").map((run2) => run2.runId);
|
|
77199
77412
|
}
|
|
77200
|
-
|
|
77413
|
+
async function keepStatusStreamAlive(res, clock, signal) {
|
|
77414
|
+
while (!signal.aborted) {
|
|
77415
|
+
try {
|
|
77416
|
+
await clock.sleep(15e3, signal);
|
|
77417
|
+
} catch (error62) {
|
|
77418
|
+
if (signal.aborted) return;
|
|
77419
|
+
throw error62;
|
|
77420
|
+
}
|
|
77421
|
+
if (!res.destroyed && !res.writableNeedDrain) res.write(": keep-alive\n\n");
|
|
77422
|
+
}
|
|
77423
|
+
}
|
|
77424
|
+
var streamStatus = async ({ feed, appAttachments, clock }, { res, signal }) => {
|
|
77201
77425
|
var _stack = [];
|
|
77202
77426
|
try {
|
|
77203
77427
|
const snapshot = await feed.refresh(signal);
|
|
@@ -77217,10 +77441,11 @@ var streamStatus = async ({ feed, appAttachments }, { res, signal }) => {
|
|
|
77217
77441
|
latest = event;
|
|
77218
77442
|
writing = writing.then(flush);
|
|
77219
77443
|
}));
|
|
77220
|
-
|
|
77221
|
-
if (signal.aborted)
|
|
77222
|
-
signal.addEventListener("abort", () =>
|
|
77444
|
+
const closed = new Promise((resolve14) => {
|
|
77445
|
+
if (signal.aborted) resolve14();
|
|
77446
|
+
signal.addEventListener("abort", () => resolve14(), { once: true });
|
|
77223
77447
|
});
|
|
77448
|
+
await Promise.all([closed, keepStatusStreamAlive(res, clock, signal)]);
|
|
77224
77449
|
await writing;
|
|
77225
77450
|
} catch (_) {
|
|
77226
77451
|
var _error = _, _hasError = true;
|
|
@@ -77542,11 +77767,11 @@ function localRequestSignal(path4, closed) {
|
|
|
77542
77767
|
]);
|
|
77543
77768
|
}
|
|
77544
77769
|
async function listenOnLoopback(server) {
|
|
77545
|
-
await new Promise((
|
|
77770
|
+
await new Promise((resolve14, reject) => {
|
|
77546
77771
|
server.once("error", reject);
|
|
77547
77772
|
server.listen(0, "127.0.0.1", () => {
|
|
77548
77773
|
server.off("error", reject);
|
|
77549
|
-
|
|
77774
|
+
resolve14();
|
|
77550
77775
|
});
|
|
77551
77776
|
}).catch((error62) => {
|
|
77552
77777
|
throw new RuntimeFault("io_failed", "The local API could not listen on loopback", {
|
|
@@ -77561,7 +77786,7 @@ async function listenOnLoopback(server) {
|
|
|
77561
77786
|
}
|
|
77562
77787
|
async function closeServer(server) {
|
|
77563
77788
|
server.closeAllConnections();
|
|
77564
|
-
await new Promise((
|
|
77789
|
+
await new Promise((resolve14) => server.close(() => resolve14()));
|
|
77565
77790
|
}
|
|
77566
77791
|
async function serveLocalApi(deps) {
|
|
77567
77792
|
const limits = { ...DEFAULT_LIMITS, ...deps.limits };
|
|
@@ -77589,6 +77814,7 @@ async function serveLocalApi(deps) {
|
|
|
77589
77814
|
const guard = createRequestGuard({ token, port, rateLimit: limits.rateLimit, clock });
|
|
77590
77815
|
const appAttachments = createAppAttachments(clock);
|
|
77591
77816
|
const routeDeps = {
|
|
77817
|
+
clock,
|
|
77592
77818
|
feed,
|
|
77593
77819
|
readFacts: deps.readFacts,
|
|
77594
77820
|
appAttachments,
|
|
@@ -77632,7 +77858,7 @@ async function serveLocalApi(deps) {
|
|
|
77632
77858
|
startedAtMs,
|
|
77633
77859
|
runtimeVersion: deps.runtimeVersion
|
|
77634
77860
|
};
|
|
77635
|
-
const discoveryPath = (0,
|
|
77861
|
+
const discoveryPath = (0, import_node_path83.join)(deps.stateDir, LOCAL_API_DISCOVERY_FILE);
|
|
77636
77862
|
await writeJsonFileAtomic(discoveryPath, discovery);
|
|
77637
77863
|
const followers = startMaintenance({
|
|
77638
77864
|
everyMs: limits.refreshEveryMs,
|
|
@@ -77666,7 +77892,7 @@ async function serveLocalApi(deps) {
|
|
|
77666
77892
|
await watchedStatus[Symbol.asyncDispose]();
|
|
77667
77893
|
const current = await readJsonFile(discoveryPath, localApiDiscoverySchema);
|
|
77668
77894
|
if (current.kind === "ok" && current.value.token === token) {
|
|
77669
|
-
await (0,
|
|
77895
|
+
await (0, import_promises81.rm)(discoveryPath, { force: true });
|
|
77670
77896
|
}
|
|
77671
77897
|
await closeServer(server);
|
|
77672
77898
|
log.info("local_api.closed", {});
|
|
@@ -77751,7 +77977,7 @@ function machineFeatureActions(deps) {
|
|
|
77751
77977
|
}
|
|
77752
77978
|
|
|
77753
77979
|
// src/cli/commands/machine-plane.ts
|
|
77754
|
-
var
|
|
77980
|
+
var import_node_path86 = require("path");
|
|
77755
77981
|
|
|
77756
77982
|
// src/link/index.ts
|
|
77757
77983
|
init_runtime_v2();
|
|
@@ -80318,9 +80544,9 @@ var Socket2 = class extends Emitter {
|
|
|
80318
80544
|
* @return a Promise that will be fulfilled when the server acknowledges the event
|
|
80319
80545
|
*/
|
|
80320
80546
|
emitWithAck(ev, ...args) {
|
|
80321
|
-
return new Promise((
|
|
80547
|
+
return new Promise((resolve14, reject) => {
|
|
80322
80548
|
const fn = (arg1, arg2) => {
|
|
80323
|
-
return arg1 ? reject(arg1) :
|
|
80549
|
+
return arg1 ? reject(arg1) : resolve14(arg2);
|
|
80324
80550
|
};
|
|
80325
80551
|
fn.withError = true;
|
|
80326
80552
|
args.push(fn);
|
|
@@ -81419,7 +81645,7 @@ function refusalFailure(refusal2) {
|
|
|
81419
81645
|
}
|
|
81420
81646
|
|
|
81421
81647
|
// src/link/probe.ts
|
|
81422
|
-
var
|
|
81648
|
+
var import_promises82 = require("dns/promises");
|
|
81423
81649
|
var import_node_net5 = require("net");
|
|
81424
81650
|
var import_node_tls2 = require("tls");
|
|
81425
81651
|
var PROBE_TIMEOUT_MS3 = 5e3;
|
|
@@ -81439,9 +81665,9 @@ async function connectOnce(url3, clock) {
|
|
|
81439
81665
|
const timer = new AbortController();
|
|
81440
81666
|
try {
|
|
81441
81667
|
return await Promise.race([
|
|
81442
|
-
new Promise((
|
|
81443
|
-
socket.once(ready, () =>
|
|
81444
|
-
socket.once("error", (error62) =>
|
|
81668
|
+
new Promise((resolve14) => {
|
|
81669
|
+
socket.once(ready, () => resolve14(null));
|
|
81670
|
+
socket.once("error", (error62) => resolve14(classifyTransportFailure(error62)));
|
|
81445
81671
|
}),
|
|
81446
81672
|
clock.sleep(PROBE_TIMEOUT_MS3, timer.signal).then(
|
|
81447
81673
|
() => "connection_timeout",
|
|
@@ -81455,7 +81681,7 @@ async function connectOnce(url3, clock) {
|
|
|
81455
81681
|
}
|
|
81456
81682
|
async function probeEndpoint(url3, clock) {
|
|
81457
81683
|
try {
|
|
81458
|
-
await (0,
|
|
81684
|
+
await (0, import_promises82.lookup)(url3.hostname);
|
|
81459
81685
|
} catch (error62) {
|
|
81460
81686
|
const reason = classifyTransportFailure(error62);
|
|
81461
81687
|
return reason === "other" ? "dns" : reason;
|
|
@@ -81778,13 +82004,13 @@ function connectLink(options) {
|
|
|
81778
82004
|
socket.disconnect();
|
|
81779
82005
|
socket.connect();
|
|
81780
82006
|
};
|
|
81781
|
-
const hearsServer = (timeoutMs) => new Promise((
|
|
82007
|
+
const hearsServer = (timeoutMs) => new Promise((resolve14) => {
|
|
81782
82008
|
const waiting = new AbortController();
|
|
81783
82009
|
const settle2 = (alive) => {
|
|
81784
82010
|
waiting.abort();
|
|
81785
82011
|
socket.io.off("ping", onPing);
|
|
81786
82012
|
socket.off("disconnect", onDrop);
|
|
81787
|
-
|
|
82013
|
+
resolve14(alive);
|
|
81788
82014
|
};
|
|
81789
82015
|
const onPing = () => settle2(true);
|
|
81790
82016
|
const onDrop = () => settle2(false);
|
|
@@ -81982,7 +82208,7 @@ function createReconciler(host, lifecycle, log, signal) {
|
|
|
81982
82208
|
}
|
|
81983
82209
|
|
|
81984
82210
|
// src/uploader/index.ts
|
|
81985
|
-
var
|
|
82211
|
+
var import_promises83 = require("fs/promises");
|
|
81986
82212
|
init_runtime_v2();
|
|
81987
82213
|
init_zod();
|
|
81988
82214
|
var RETRY_DELAYS_MS = [250, 500, 1e3, 2e3, 5e3, 1e4, 3e4];
|
|
@@ -82272,13 +82498,13 @@ function startUploader({
|
|
|
82272
82498
|
const isDone = (runId) => sealed.has(runId) || archive?.has(runId) === true;
|
|
82273
82499
|
const unsealedRunIds = async () => {
|
|
82274
82500
|
const runIds = [];
|
|
82275
|
-
for (const name of await (0,
|
|
82501
|
+
for (const name of await (0, import_promises83.readdir)(runsDir).catch(() => [])) {
|
|
82276
82502
|
const runId = runIdSchema.safeParse(name);
|
|
82277
82503
|
if (runId.success && !isDone(runId.data)) runIds.push(runId.data);
|
|
82278
82504
|
}
|
|
82279
82505
|
return runIds;
|
|
82280
82506
|
};
|
|
82281
|
-
const hasProgress = async (runId) => await (0,
|
|
82507
|
+
const hasProgress = async (runId) => await (0, import_promises83.stat)(runDirectory(runsDir, runId).upload).catch(() => null) !== null;
|
|
82282
82508
|
const sweep2 = async () => {
|
|
82283
82509
|
for (const runId of await unsealedRunIds()) {
|
|
82284
82510
|
if (!await hasProgress(runId)) run2(runId);
|
|
@@ -82294,13 +82520,13 @@ function startUploader({
|
|
|
82294
82520
|
const dir = runDirectory(runsDir, runId);
|
|
82295
82521
|
const progress = await readJsonFile(dir.upload, uploadProgressSchema);
|
|
82296
82522
|
if (progress.kind !== "ok" || !progress.value.sealed) return false;
|
|
82297
|
-
const sealedAt = (await (0,
|
|
82523
|
+
const sealedAt = (await (0, import_promises83.stat)(dir.upload)).mtimeMs;
|
|
82298
82524
|
if (clock.now() - sealedAt < options.sealedForMs) return false;
|
|
82299
82525
|
return (await readLastRecord(dir.log))?.update.sessionUpdate === "_alan/run.ended";
|
|
82300
82526
|
};
|
|
82301
82527
|
const archivable = async (options) => {
|
|
82302
82528
|
const found = [];
|
|
82303
|
-
for (const name of await (0,
|
|
82529
|
+
for (const name of await (0, import_promises83.readdir)(runsDir).catch(() => [])) {
|
|
82304
82530
|
const runId = runIdSchema.safeParse(name);
|
|
82305
82531
|
if (!runId.success || archive?.has(runId.data)) continue;
|
|
82306
82532
|
try {
|
|
@@ -82337,7 +82563,7 @@ function startUploader({
|
|
|
82337
82563
|
|
|
82338
82564
|
// src/cli/commands/activity-lease.ts
|
|
82339
82565
|
var import_node_fs26 = require("fs");
|
|
82340
|
-
var
|
|
82566
|
+
var import_node_path84 = require("path");
|
|
82341
82567
|
var import_node_worker_threads = require("worker_threads");
|
|
82342
82568
|
init_runtime_v2();
|
|
82343
82569
|
var LEASE_BUNDLE = "alan-lease.cjs";
|
|
@@ -82361,7 +82587,7 @@ function spawnThread(script, data) {
|
|
|
82361
82587
|
};
|
|
82362
82588
|
}
|
|
82363
82589
|
function leaseWorkerScript(bundlePath, exists6 = import_node_fs26.existsSync) {
|
|
82364
|
-
const lean = (0,
|
|
82590
|
+
const lean = (0, import_node_path84.join)((0, import_node_path84.dirname)(bundlePath), LEASE_BUNDLE);
|
|
82365
82591
|
return exists6(lean) ? lean : bundlePath;
|
|
82366
82592
|
}
|
|
82367
82593
|
function leasedRuns(held) {
|
|
@@ -82381,7 +82607,7 @@ function startActivityLeases(deps) {
|
|
|
82381
82607
|
epoch: Math.floor(clock.now()),
|
|
82382
82608
|
sessionsDir: deps.paths.sessions,
|
|
82383
82609
|
runsDir: deps.paths.runs,
|
|
82384
|
-
logPath: (0,
|
|
82610
|
+
logPath: (0, import_node_path84.join)(deps.paths.logs, "runtime.jsonl"),
|
|
82385
82611
|
logLevel: deps.logLevel,
|
|
82386
82612
|
intervalMs: ACTIVITY_LEASE_INTERVAL_MS,
|
|
82387
82613
|
watchdogMs: deps.watchdogMs,
|
|
@@ -82621,12 +82847,12 @@ async function startMachineNativeIngest(deps) {
|
|
|
82621
82847
|
}
|
|
82622
82848
|
|
|
82623
82849
|
// src/cli/commands/run-updates.ts
|
|
82624
|
-
var
|
|
82850
|
+
var import_node_path85 = require("path");
|
|
82625
82851
|
init_runtime_v2();
|
|
82626
82852
|
var UPDATE_CHECK_EVERY_MS = 6 * 60 * 60 * 1e3;
|
|
82627
82853
|
var DEFERRED_RETRY_MS = 5 * 60 * 1e3;
|
|
82628
82854
|
function isInstalledBundle(layout, bundlePath) {
|
|
82629
|
-
return (0,
|
|
82855
|
+
return (0, import_node_path85.resolve)((0, import_node_path85.dirname)((0, import_node_path85.dirname)(bundlePath))) === (0, import_node_path85.resolve)(layout.versions);
|
|
82630
82856
|
}
|
|
82631
82857
|
async function settleUpgradeOnStart({
|
|
82632
82858
|
layout,
|
|
@@ -82733,7 +82959,7 @@ function startRuntimeUpdates(options) {
|
|
|
82733
82959
|
layout,
|
|
82734
82960
|
release: npmRelease,
|
|
82735
82961
|
tarball: await options.downloader.download(npmRelease.dist.tarball, signal),
|
|
82736
|
-
tmpDir: (0,
|
|
82962
|
+
tmpDir: (0, import_node_path85.join)(layout.root, ".downloads")
|
|
82737
82963
|
});
|
|
82738
82964
|
await lifecycle.exclusive("upgrade", async () => {
|
|
82739
82965
|
await recordPendingUpgrade(layout, currentVersion2, version2, clock.now());
|
|
@@ -82988,7 +83214,7 @@ async function startMachinePlane(deps) {
|
|
|
82988
83214
|
[ALAN_MANAGED_SESSION_ENV]: "1"
|
|
82989
83215
|
},
|
|
82990
83216
|
cwd: paths.stateDir,
|
|
82991
|
-
outputPath: (0,
|
|
83217
|
+
outputPath: (0, import_node_path86.join)(paths.logs, "holders.log")
|
|
82992
83218
|
},
|
|
82993
83219
|
deps.holderIsolation
|
|
82994
83220
|
);
|
|
@@ -83040,6 +83266,13 @@ async function startMachinePlane(deps) {
|
|
|
83040
83266
|
);
|
|
83041
83267
|
leaseDoorbell.changed = () => leases.changed();
|
|
83042
83268
|
}
|
|
83269
|
+
const legacySkills = await removeLegacySkillFolders(config2.home);
|
|
83270
|
+
if (legacySkills.profilesRemoved || legacySkills.failed.length > 0) {
|
|
83271
|
+
log.warn("skills.legacy_removed", { ...legacySkills });
|
|
83272
|
+
} else if (legacySkills.packages.length + legacySkills.links.length > 0) {
|
|
83273
|
+
log.info("skills.legacy_removed", { ...legacySkills });
|
|
83274
|
+
}
|
|
83275
|
+
const codexSkills = codexSkillsDir(config2);
|
|
83043
83276
|
const skills = stack.use(
|
|
83044
83277
|
openMachineSkills({
|
|
83045
83278
|
stateDir: paths.stateDir,
|
|
@@ -83049,8 +83282,7 @@ async function startMachinePlane(deps) {
|
|
|
83049
83282
|
transport
|
|
83050
83283
|
}),
|
|
83051
83284
|
local: { home: config2.home, machineId: identity.machineId },
|
|
83052
|
-
|
|
83053
|
-
...config2.gitGatewayUrl === null ? {} : { codexSkillsDir: (0, import_node_path85.join)(config2.codexHome, "skills") },
|
|
83285
|
+
...codexSkills === null ? {} : { codexSkillsDir: codexSkills },
|
|
83054
83286
|
log
|
|
83055
83287
|
})
|
|
83056
83288
|
);
|
|
@@ -83254,7 +83486,7 @@ async function startMachinePlane(deps) {
|
|
|
83254
83486
|
git: createGitRunner({ env: cliEnvironment }),
|
|
83255
83487
|
clock,
|
|
83256
83488
|
log,
|
|
83257
|
-
dir: (0,
|
|
83489
|
+
dir: (0, import_node_path86.join)(paths.stateDir, "checkout-freshness")
|
|
83258
83490
|
},
|
|
83259
83491
|
stopped.signal
|
|
83260
83492
|
);
|
|
@@ -83532,11 +83764,11 @@ function createMachineSlot(deps) {
|
|
|
83532
83764
|
|
|
83533
83765
|
// src/cli/commands/run-exit.ts
|
|
83534
83766
|
function firstAborted(signals) {
|
|
83535
|
-
return new Promise((
|
|
83767
|
+
return new Promise((resolve14) => {
|
|
83536
83768
|
for (const reason of ["stop", "restart"]) {
|
|
83537
83769
|
const signal = signals[reason];
|
|
83538
|
-
if (signal.aborted)
|
|
83539
|
-
signal.addEventListener("abort", () =>
|
|
83770
|
+
if (signal.aborted) resolve14(reason);
|
|
83771
|
+
signal.addEventListener("abort", () => resolve14(reason), { once: true });
|
|
83540
83772
|
}
|
|
83541
83773
|
});
|
|
83542
83774
|
}
|
|
@@ -83564,7 +83796,7 @@ function lockWaitMs(argv) {
|
|
|
83564
83796
|
}
|
|
83565
83797
|
async function openManagedProviders(config2, paths) {
|
|
83566
83798
|
const providerEnv = readCliEnvironment();
|
|
83567
|
-
const bundledNpm = (0,
|
|
83799
|
+
const bundledNpm = (0, import_node_path87.join)((0, import_node_path87.dirname)(process.execPath), "npm", "bin", "npm-cli.js");
|
|
83568
83800
|
const providerToolchain = config2.providerToolchain ?? (process.platform === "win32" && (0, import_node_fs27.existsSync)(bundledNpm) ? { node: process.execPath, npmCli: bundledNpm } : null);
|
|
83569
83801
|
const npmPath = providerToolchain?.node ?? await resolveCommandOnPath("npm", providerEnv, process.platform);
|
|
83570
83802
|
const npmOptions = npmPath === null || process.platform === "win32" && providerToolchain === null ? null : {
|
|
@@ -83572,7 +83804,7 @@ async function openManagedProviders(config2, paths) {
|
|
|
83572
83804
|
...providerToolchain === null ? {} : { argsBeforeNpm: [providerToolchain.npmCli] },
|
|
83573
83805
|
env: providerEnv
|
|
83574
83806
|
};
|
|
83575
|
-
const providerNodeDir = providerToolchain?.node === void 0 ? void 0 : (0,
|
|
83807
|
+
const providerNodeDir = providerToolchain?.node === void 0 ? void 0 : (0, import_node_path87.dirname)(providerToolchain.node);
|
|
83576
83808
|
const probeEnv = providerNodeDir === void 0 ? providerEnv : {
|
|
83577
83809
|
...providerEnv,
|
|
83578
83810
|
PATH: `${providerNodeDir}${pathDelimiter(process.platform)}${envValue(providerEnv, "PATH")}`
|
|
@@ -83582,7 +83814,7 @@ async function openManagedProviders(config2, paths) {
|
|
|
83582
83814
|
throw new Error("Provider installer is unavailable on this computer");
|
|
83583
83815
|
};
|
|
83584
83816
|
const managed = createManagedProviderClis({
|
|
83585
|
-
root: (0,
|
|
83817
|
+
root: (0, import_node_path87.join)(paths.stateDir, "provider-clis"),
|
|
83586
83818
|
resolveVersion: npmOptions === null ? unavailable : createNpmVersionResolver(npmOptions),
|
|
83587
83819
|
installPackage: npmOptions === null ? unavailable : createNpmPackageInstaller(npmOptions),
|
|
83588
83820
|
probe: (executable, backendKind) => probeManagedProvider(executable, backendKind, canonicalProbeEnv)
|
|
@@ -83614,7 +83846,7 @@ async function runService(argv, stop, restart = new AbortController().signal) {
|
|
|
83614
83846
|
waitMs: lockWaitMs(argv),
|
|
83615
83847
|
signal: stop
|
|
83616
83848
|
}));
|
|
83617
|
-
const log = __using(_stack, openFileLog((0,
|
|
83849
|
+
const log = __using(_stack, openFileLog((0, import_node_path87.join)(paths.logs, "runtime.jsonl"), config2.logLevel, clock));
|
|
83618
83850
|
const lifecycle = createLifecycleQueue({ clock, log });
|
|
83619
83851
|
const install2 = installLayout(config2.installDir, config2.profile);
|
|
83620
83852
|
const bundlePath = process.argv[1] ?? "";
|
|
@@ -83648,7 +83880,7 @@ async function runService(argv, stop, restart = new AbortController().signal) {
|
|
|
83648
83880
|
openCliEnvironment({
|
|
83649
83881
|
env: readCliEnvironment(),
|
|
83650
83882
|
platform: process.platform,
|
|
83651
|
-
lastKnownGoodFile: (0,
|
|
83883
|
+
lastKnownGoodFile: (0, import_node_path87.join)(paths.stateDir, "login-path.json"),
|
|
83652
83884
|
clock,
|
|
83653
83885
|
decorate: (env) => withPackagedAlanCodeEngine(env, bundlePath, process.platform)
|
|
83654
83886
|
})
|
|
@@ -83825,17 +84057,17 @@ async function runServiceCommand(argv, ctx = cliContext()) {
|
|
|
83825
84057
|
}
|
|
83826
84058
|
|
|
83827
84059
|
// src/cli/commands/upgrade.ts
|
|
83828
|
-
var
|
|
83829
|
-
var
|
|
84060
|
+
var import_promises84 = require("fs/promises");
|
|
84061
|
+
var import_node_path88 = require("path");
|
|
83830
84062
|
function isNotNewer(version2, installed) {
|
|
83831
84063
|
return installed !== null && isReleaseVersion(version2) && isReleaseVersion(installed) && compareVersions(version2, installed) <= 0;
|
|
83832
84064
|
}
|
|
83833
84065
|
async function installFromSource(source) {
|
|
83834
84066
|
const { layout, from, ifNewer } = source;
|
|
83835
|
-
const isTarball = (await (0,
|
|
83836
|
-
const downloads = (0,
|
|
83837
|
-
if (isTarball) await (0,
|
|
83838
|
-
const scratch = isTarball ? await (0,
|
|
84067
|
+
const isTarball = (await (0, import_promises84.stat)(from)).isFile();
|
|
84068
|
+
const downloads = (0, import_node_path88.join)(layout.root, ".downloads");
|
|
84069
|
+
if (isTarball) await (0, import_promises84.mkdir)(downloads, { recursive: true, mode: 448 });
|
|
84070
|
+
const scratch = isTarball ? await (0, import_promises84.mkdtemp)((0, import_node_path88.join)(downloads, "upgrade-")) : null;
|
|
83839
84071
|
try {
|
|
83840
84072
|
const sourceDir = scratch === null ? from : await extractPackageTarball(from, scratch);
|
|
83841
84073
|
const version2 = await readPackageVersion(sourceDir);
|
|
@@ -83843,7 +84075,7 @@ async function installFromSource(source) {
|
|
|
83843
84075
|
if (ifNewer && isNotNewer(version2, installed)) return { kind: "skipped", version: version2, installed };
|
|
83844
84076
|
return { kind: "installed", ...await installVersion(layout, sourceDir) };
|
|
83845
84077
|
} finally {
|
|
83846
|
-
if (scratch !== null) await (0,
|
|
84078
|
+
if (scratch !== null) await (0, import_promises84.rm)(scratch, { recursive: true, force: true });
|
|
83847
84079
|
}
|
|
83848
84080
|
}
|
|
83849
84081
|
async function runUpgrade(argv) {
|
|
@@ -83855,7 +84087,7 @@ async function runUpgrade(argv) {
|
|
|
83855
84087
|
const layout = installLayout(config2.installDir, config2.profile);
|
|
83856
84088
|
const outcome2 = await installFromSource({
|
|
83857
84089
|
layout,
|
|
83858
|
-
from: (0,
|
|
84090
|
+
from: (0, import_node_path88.resolve)(from),
|
|
83859
84091
|
ifNewer: hasFlag(argv, "--if-newer")
|
|
83860
84092
|
});
|
|
83861
84093
|
if (outcome2.kind === "skipped") {
|