@alan-ai-hq/agent-manager-linux-x64 0.1.186 → 0.1.188
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 +1608 -1262
- package/alan-holder.cjs +796 -643
- package/alan-lease.cjs +34 -3
- package/package.json +1 -1
package/alan-holder.cjs
CHANGED
|
@@ -20727,6 +20727,12 @@ var init_files = __esm({
|
|
|
20727
20727
|
root: machinePathSchema,
|
|
20728
20728
|
/** Paths relative to `root`: tracked and untracked, never ignored. */
|
|
20729
20729
|
files: external_exports.array(external_exports.string()),
|
|
20730
|
+
/**
|
|
20731
|
+
* Paths relative to `root` that Git ignores: files, and a folder Git ignores whole as one
|
|
20732
|
+
* `dir/` entry, so a cache directory costs a path rather than its thousands of files.
|
|
20733
|
+
* Older runtimes omit it.
|
|
20734
|
+
*/
|
|
20735
|
+
ignored: external_exports.array(external_exports.string()).optional(),
|
|
20730
20736
|
/** Not a Git checkout, or its listing hit the cap: `files` is what a bounded walk found. */
|
|
20731
20737
|
source: external_exports.enum(["git", "walk"]),
|
|
20732
20738
|
truncated: external_exports.boolean()
|
|
@@ -21117,6 +21123,15 @@ var init_agent_context = __esm({
|
|
|
21117
21123
|
}
|
|
21118
21124
|
});
|
|
21119
21125
|
|
|
21126
|
+
// ../shared/src/session-owned-execution.ts
|
|
21127
|
+
var EXECUTION_OWNERS;
|
|
21128
|
+
var init_session_owned_execution = __esm({
|
|
21129
|
+
"../shared/src/session-owned-execution.ts"() {
|
|
21130
|
+
"use strict";
|
|
21131
|
+
EXECUTION_OWNERS = ["task", "session"];
|
|
21132
|
+
}
|
|
21133
|
+
});
|
|
21134
|
+
|
|
21120
21135
|
// ../shared/src/skills/domain.ts
|
|
21121
21136
|
var SKILLS_PROTOCOL_VERSION, SKILL_PACKAGE_LIMITS;
|
|
21122
21137
|
var init_domain = __esm({
|
|
@@ -21783,7 +21798,19 @@ var init_run_context = __esm({
|
|
|
21783
21798
|
title: external_exports.string(),
|
|
21784
21799
|
url: external_exports.string().optional()
|
|
21785
21800
|
})
|
|
21786
|
-
).optional()
|
|
21801
|
+
).optional(),
|
|
21802
|
+
contextBundle: external_exports.object({
|
|
21803
|
+
decisions: external_exports.array(external_exports.string()),
|
|
21804
|
+
pullRequests: external_exports.array(
|
|
21805
|
+
external_exports.object({
|
|
21806
|
+
number: external_exports.number().int(),
|
|
21807
|
+
title: external_exports.string(),
|
|
21808
|
+
url: external_exports.string(),
|
|
21809
|
+
state: external_exports.string()
|
|
21810
|
+
})
|
|
21811
|
+
),
|
|
21812
|
+
siblingSessions: external_exports.array(external_exports.string())
|
|
21813
|
+
}).optional()
|
|
21787
21814
|
})
|
|
21788
21815
|
);
|
|
21789
21816
|
pullRequestMetaSchema = wire()(
|
|
@@ -21901,6 +21928,7 @@ var init_desired_state = __esm({
|
|
|
21901
21928
|
"use strict";
|
|
21902
21929
|
init_zod();
|
|
21903
21930
|
init_cloud_repositories();
|
|
21931
|
+
init_session_owned_execution();
|
|
21904
21932
|
init_contracts();
|
|
21905
21933
|
init_agent_context();
|
|
21906
21934
|
init_commit_attribution();
|
|
@@ -21926,6 +21954,8 @@ var init_desired_state = __esm({
|
|
|
21926
21954
|
conversationId: conversationIdSchema,
|
|
21927
21955
|
messageId: external_exports.guid().optional(),
|
|
21928
21956
|
taskId: external_exports.guid().optional(),
|
|
21957
|
+
/** Absent from older servers; a session-owned run's browser scope and branch are the session's. */
|
|
21958
|
+
executionOwner: external_exports.enum(EXECUTION_OWNERS).optional(),
|
|
21929
21959
|
teamId: external_exports.guid().optional(),
|
|
21930
21960
|
content: external_exports.string(),
|
|
21931
21961
|
backendKind: external_exports.string().min(1),
|
|
@@ -21940,6 +21970,7 @@ var init_desired_state = __esm({
|
|
|
21940
21970
|
resumeFallbackContext: external_exports.string().optional(),
|
|
21941
21971
|
projectPath: external_exports.string().min(1).optional(),
|
|
21942
21972
|
workspacePathPinned: external_exports.boolean().optional(),
|
|
21973
|
+
localWorktree: external_exports.object({ branch: gitBranchSchema, baseBranch: gitBranchSchema.optional() }).optional(),
|
|
21943
21974
|
approvedWorkspacePaths: external_exports.array(external_exports.string().min(1)).optional(),
|
|
21944
21975
|
repoLocalPaths: external_exports.array(repoLocalPathSchema).optional(),
|
|
21945
21976
|
/** Applied once, at the conversation's first turn on a cloud sandbox; never moves local work. */
|
|
@@ -22041,7 +22072,7 @@ var init_machine_identity = __esm({
|
|
|
22041
22072
|
register: "/public/machines/register",
|
|
22042
22073
|
/** POST with a cloud sandbox's one-time enrollment code from `ALAN_RUNTIME_ENROLLMENT_CODE`. */
|
|
22043
22074
|
enroll: "/public/machines/enroll",
|
|
22044
|
-
|
|
22075
|
+
// quirk: POST with the current renewal token; the response carries a new one and the previous one dies.
|
|
22045
22076
|
renew: "/public/machines/me/renew",
|
|
22046
22077
|
/** POST by the machine itself on logout/uninstall. */
|
|
22047
22078
|
revokeSelf: "/public/machines/me/revoke",
|
|
@@ -22361,6 +22392,26 @@ var init_capabilities = __esm({
|
|
|
22361
22392
|
}
|
|
22362
22393
|
});
|
|
22363
22394
|
|
|
22395
|
+
// ../shared/src/type-guards.ts
|
|
22396
|
+
function isRecord(value2) {
|
|
22397
|
+
return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
|
|
22398
|
+
}
|
|
22399
|
+
function isObjectLike(value2) {
|
|
22400
|
+
return typeof value2 === "object" && value2 !== null;
|
|
22401
|
+
}
|
|
22402
|
+
function tryParseJson(text3) {
|
|
22403
|
+
try {
|
|
22404
|
+
return JSON.parse(text3);
|
|
22405
|
+
} catch {
|
|
22406
|
+
return void 0;
|
|
22407
|
+
}
|
|
22408
|
+
}
|
|
22409
|
+
var init_type_guards = __esm({
|
|
22410
|
+
"../shared/src/type-guards.ts"() {
|
|
22411
|
+
"use strict";
|
|
22412
|
+
}
|
|
22413
|
+
});
|
|
22414
|
+
|
|
22364
22415
|
// ../shared/src/validators/attachments.ts
|
|
22365
22416
|
var MAX_COMMENT_ATTACHMENTS, requestPresignedUploadSchema, linkAttachmentSchema, renameAttachmentSchema;
|
|
22366
22417
|
var init_attachments = __esm({
|
|
@@ -22445,6 +22496,7 @@ var init_problem = __esm({
|
|
|
22445
22496
|
"cli.auth.expired",
|
|
22446
22497
|
"cli.entitlement.required",
|
|
22447
22498
|
"cli.model.unavailable",
|
|
22499
|
+
"cli.model.paused",
|
|
22448
22500
|
"cli.rate_limited",
|
|
22449
22501
|
"cli.quota_exceeded",
|
|
22450
22502
|
"cli.context_exhausted",
|
|
@@ -24105,7 +24157,6 @@ var init_skills = __esm({
|
|
|
24105
24157
|
skills: external_exports.array(desiredMachineSkillSchema).max(MAX_MACHINE_SKILLS),
|
|
24106
24158
|
/** Only the desired versions the machine reported missing or different. */
|
|
24107
24159
|
downloads: external_exports.array(machineSkillDownloadSchema).max(MAX_MACHINE_SKILLS),
|
|
24108
|
-
/** Installed skill ids that are no longer desired. */
|
|
24109
24160
|
removals: external_exports.array(skillIdSchema).max(MAX_MACHINE_SKILLS),
|
|
24110
24161
|
/** Absent from an API that predates local skills; the machine then reports none. */
|
|
24111
24162
|
scanContext: machineSkillScanContextSchema.optional(),
|
|
@@ -25047,23 +25098,6 @@ var init_mcp_config = __esm({
|
|
|
25047
25098
|
}
|
|
25048
25099
|
});
|
|
25049
25100
|
|
|
25050
|
-
// ../shared/src/type-guards.ts
|
|
25051
|
-
function isRecord(value2) {
|
|
25052
|
-
return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
|
|
25053
|
-
}
|
|
25054
|
-
function tryParseJson(text3) {
|
|
25055
|
-
try {
|
|
25056
|
-
return JSON.parse(text3);
|
|
25057
|
-
} catch {
|
|
25058
|
-
return void 0;
|
|
25059
|
-
}
|
|
25060
|
-
}
|
|
25061
|
-
var init_type_guards = __esm({
|
|
25062
|
-
"../shared/src/type-guards.ts"() {
|
|
25063
|
-
"use strict";
|
|
25064
|
-
}
|
|
25065
|
-
});
|
|
25066
|
-
|
|
25067
25101
|
// ../shared/src/agent/opencode-zen-entitlement.ts
|
|
25068
25102
|
var init_opencode_zen_entitlement = __esm({
|
|
25069
25103
|
"../shared/src/agent/opencode-zen-entitlement.ts"() {
|
|
@@ -25275,7 +25309,7 @@ Before replying in the Alan chat, consider what the user is trying to do and whe
|
|
|
25275
25309
|
ALAN_SUGGESTING_WORK_PROMPT = `## Suggesting Work
|
|
25276
25310
|
|
|
25277
25311
|
When \`suggest_task\` is available, use it to put work in the session's side panel for the user to pick up; it creates nothing by itself.
|
|
25278
|
-
- \`convert_session\`:
|
|
25312
|
+
- \`convert_session\`: Alan already suggests this automatically at turn end when a chat that is not linked to a task has turned into multi-step delivery work (code changes, a PR, several turns), so you rarely need to. If you do, give the title and description the task should have.
|
|
25279
25313
|
- \`follow_up\`: suggest real, separate work you found and did not do, such as a bug, risky debt or a missing test. Never the next step of the current request or work you are about to do. Include \`handoffContext\` with what a fresh session needs: verified findings, files, decisions.
|
|
25280
25314
|
- Prefer none. At most three in a turn, never a duplicate (check \`list_task_suggestions\`), and withdraw one that stops applying. Do not mention suggestions in your reply.`;
|
|
25281
25315
|
ALAN_IDENTITY_PROMPT = `You are Alan, the software factory agent. Alan ships software end to end \u2014 plan, write, review, test, deploy.
|
|
@@ -26309,6 +26343,11 @@ var init_kinds = __esm({
|
|
|
26309
26343
|
message: "The provider is overloaded right now. Wait a moment or pick a different model, then send your message again.",
|
|
26310
26344
|
recoveryClass: "auto_recovering"
|
|
26311
26345
|
},
|
|
26346
|
+
// Our own load balancer answering with no backend: a deploy or restart, not a provider problem.
|
|
26347
|
+
service_updating: {
|
|
26348
|
+
message: "Alan Code is updating and will be back in a few seconds. Retrying automatically \u2014 no action needed.",
|
|
26349
|
+
recoveryClass: "auto_recovering"
|
|
26350
|
+
},
|
|
26312
26351
|
network: {
|
|
26313
26352
|
message: "Network connection failed. Check your internet connection, then send your message again.",
|
|
26314
26353
|
recoveryClass: "auto_recovering"
|
|
@@ -26509,10 +26548,8 @@ function embeddedJson(text3) {
|
|
|
26509
26548
|
const start = text3.indexOf("{");
|
|
26510
26549
|
if (start === -1) return void 0;
|
|
26511
26550
|
for (const end of [text3.length, text3.lastIndexOf("}") + 1]) {
|
|
26512
|
-
|
|
26513
|
-
|
|
26514
|
-
} catch {
|
|
26515
|
-
}
|
|
26551
|
+
const parsed = tryParseJson(text3.slice(start, end));
|
|
26552
|
+
if (parsed !== void 0) return asRecord(parsed);
|
|
26516
26553
|
}
|
|
26517
26554
|
return void 0;
|
|
26518
26555
|
}
|
|
@@ -26545,6 +26582,7 @@ var STATUS_PREFIX, ERROR_CODE_SHAPE;
|
|
|
26545
26582
|
var init_provider_error = __esm({
|
|
26546
26583
|
"../agent-core/src/classify/provider-error.ts"() {
|
|
26547
26584
|
"use strict";
|
|
26585
|
+
init_type_guards();
|
|
26548
26586
|
init_kernel2();
|
|
26549
26587
|
STATUS_PREFIX = /\b(?:api error|status|http)[:\s]+(\d{3})\b/i;
|
|
26550
26588
|
ERROR_CODE_SHAPE = /^[a-z][a-z0-9_]*$/;
|
|
@@ -26619,6 +26657,14 @@ var init_rules = __esm({
|
|
|
26619
26657
|
kind: "quota_exceeded",
|
|
26620
26658
|
pattern: /\bquota (?:exceeded|limit)\b|\b(?:daily|monthly) limit\b|\bbilling\b/
|
|
26621
26659
|
},
|
|
26660
|
+
// Above `overloaded`: Google's load balancer says this when it has no healthy backend for our
|
|
26661
|
+
// own gateway during a deploy, and reading it as a provider overload sends users to the wrong
|
|
26662
|
+
// place (notes/2026-11-18-harness-deploy-zero-downtime.md). "Service Unavailable" alone still
|
|
26663
|
+
// falls through to `overloaded`, which is the right reading for a provider's own 503.
|
|
26664
|
+
{
|
|
26665
|
+
kind: "service_updating",
|
|
26666
|
+
pattern: /\bfailed_to_pick_backend\b|\bno healthy upstream\b|\bno healthy backends?\b/
|
|
26667
|
+
},
|
|
26622
26668
|
{
|
|
26623
26669
|
kind: "overloaded",
|
|
26624
26670
|
pattern: /\boverloaded(?:_error)?\b|\bat capacity\b|\bserver_overloaded\b|\b(?:http|status|code|error)\s*:?\s*5\d\d\b|\[5\d\d\]|\bapi error:?\s*5\d\d\b|\b5\d\d (?:internal server error|bad gateway|service unavailable|gateway timeout)\b|\bservice unavailable\b|\bbad gateway\b|\bgateway timeout\b|\bapi server (?:encountered an error|returned an error|is unavailable)\b/
|
|
@@ -26805,7 +26851,9 @@ var init_classify = __esm({
|
|
|
26805
26851
|
TEXT_REFINES = {
|
|
26806
26852
|
rate_limited: /* @__PURE__ */ new Set(["usage_limit", "quota_exceeded"]),
|
|
26807
26853
|
payment_required: /* @__PURE__ */ new Set(["usage_limit", "managed_models_paused"]),
|
|
26808
|
-
auth_invalid: /* @__PURE__ */ new Set(["auth_expired", "not_logged_in", "not_authenticated"])
|
|
26854
|
+
auth_invalid: /* @__PURE__ */ new Set(["auth_expired", "not_logged_in", "not_authenticated"]),
|
|
26855
|
+
// A 503 from our own load balancer carries no backend, which is a deploy, not an overload.
|
|
26856
|
+
overloaded: /* @__PURE__ */ new Set(["service_updating"])
|
|
26809
26857
|
};
|
|
26810
26858
|
STATUS_LEAD = /^(?:(?:api error|status|http)[:\s]+\d{3}\b|payment required:)[:\s]*/i;
|
|
26811
26859
|
}
|
|
@@ -26876,12 +26924,13 @@ var init_problem2 = __esm({
|
|
|
26876
26924
|
auth_expired: "cli.auth.expired",
|
|
26877
26925
|
subscription_required: "cli.entitlement.required",
|
|
26878
26926
|
payment_required: "cli.entitlement.required",
|
|
26879
|
-
managed_models_paused: "cli.model.
|
|
26927
|
+
managed_models_paused: "cli.model.paused",
|
|
26880
26928
|
quota_exceeded: "cli.quota_exceeded",
|
|
26881
26929
|
usage_limit: "cli.quota_exceeded",
|
|
26882
26930
|
context_length: "cli.context_exhausted",
|
|
26883
26931
|
rate_limited: "cli.rate_limited",
|
|
26884
26932
|
overloaded: "cli.unknown",
|
|
26933
|
+
service_updating: "cli.unknown",
|
|
26885
26934
|
network: "cli.unknown",
|
|
26886
26935
|
provider_timeout: "cli.process.timeout",
|
|
26887
26936
|
resume_failed: "cli.resume_failed",
|
|
@@ -27360,15 +27409,19 @@ var init_flag_probe = __esm({
|
|
|
27360
27409
|
});
|
|
27361
27410
|
|
|
27362
27411
|
// ../agent-core/src/process/flag-probe-store.ts
|
|
27412
|
+
async function isExecutable(path19) {
|
|
27413
|
+
try {
|
|
27414
|
+
await (0, import_promises10.access)(path19, import_node_fs8.constants.X_OK);
|
|
27415
|
+
return true;
|
|
27416
|
+
} catch {
|
|
27417
|
+
return false;
|
|
27418
|
+
}
|
|
27419
|
+
}
|
|
27363
27420
|
async function resolveBinary(command, env) {
|
|
27364
27421
|
const candidates2 = command.includes("/") ? [command] : (env.PATH ?? "").split(import_node_path9.delimiter).filter((dir) => dir.length > 0).map((dir) => (0, import_node_path9.join)(dir, command));
|
|
27365
27422
|
for (const candidate of candidates2) {
|
|
27366
27423
|
if (!(0, import_node_path9.isAbsolute)(candidate)) continue;
|
|
27367
|
-
|
|
27368
|
-
await (0, import_promises10.access)(candidate, import_node_fs8.constants.X_OK);
|
|
27369
|
-
return candidate;
|
|
27370
|
-
} catch {
|
|
27371
|
-
}
|
|
27424
|
+
if (await isExecutable(candidate)) return candidate;
|
|
27372
27425
|
}
|
|
27373
27426
|
return null;
|
|
27374
27427
|
}
|
|
@@ -27883,7 +27936,9 @@ var init_windows_helper2 = __esm({
|
|
|
27883
27936
|
function preferForOomKill(pid) {
|
|
27884
27937
|
try {
|
|
27885
27938
|
(0, import_node_fs10.writeFileSync)(`/proc/${pid}/oom_score_adj`, String(CLI_OOM_SCORE_ADJ));
|
|
27939
|
+
return true;
|
|
27886
27940
|
} catch {
|
|
27941
|
+
return false;
|
|
27887
27942
|
}
|
|
27888
27943
|
}
|
|
27889
27944
|
function onCliSpawned(listener) {
|
|
@@ -29586,10 +29641,8 @@ function contentStrings(content2, toolInput) {
|
|
|
29586
29641
|
const values = [];
|
|
29587
29642
|
if (content2) {
|
|
29588
29643
|
values.push(content2);
|
|
29589
|
-
|
|
29590
|
-
|
|
29591
|
-
} catch {
|
|
29592
|
-
}
|
|
29644
|
+
const parsed = tryParseJson(content2);
|
|
29645
|
+
if (parsed !== void 0) collectStrings(parsed, values);
|
|
29593
29646
|
}
|
|
29594
29647
|
collectStrings(toolInput, values);
|
|
29595
29648
|
return values;
|
|
@@ -29620,12 +29673,15 @@ function pathCandidates(values, extensions) {
|
|
|
29620
29673
|
for (const value2 of values) for (const match of value2.matchAll(pattern)) paths.add(match[0]);
|
|
29621
29674
|
return [...paths];
|
|
29622
29675
|
}
|
|
29623
|
-
function
|
|
29624
|
-
let path19 = candidate.trim().replace(/^file:\/\//, "");
|
|
29676
|
+
function decodeUriOrSelf(path19) {
|
|
29625
29677
|
try {
|
|
29626
|
-
|
|
29678
|
+
return decodeURI(path19);
|
|
29627
29679
|
} catch {
|
|
29680
|
+
return path19;
|
|
29628
29681
|
}
|
|
29682
|
+
}
|
|
29683
|
+
function normalizePath(candidate, cwd) {
|
|
29684
|
+
const path19 = decodeUriOrSelf(candidate.trim().replace(/^file:\/\//, ""));
|
|
29629
29685
|
if (path19.startsWith("~/")) return void 0;
|
|
29630
29686
|
if ((0, import_node_path12.isAbsolute)(path19)) return path19;
|
|
29631
29687
|
return cwd ? (0, import_node_path12.join)(cwd, path19) : void 0;
|
|
@@ -29728,6 +29784,7 @@ var init_local_media = __esm({
|
|
|
29728
29784
|
import_node_path12 = require("node:path");
|
|
29729
29785
|
init_agent2();
|
|
29730
29786
|
init_acp();
|
|
29787
|
+
init_type_guards();
|
|
29731
29788
|
init_acp2();
|
|
29732
29789
|
init_kernel2();
|
|
29733
29790
|
IMAGE_MIME_BY_EXT = {
|
|
@@ -30581,6 +30638,13 @@ var init_copilot = __esm({
|
|
|
30581
30638
|
});
|
|
30582
30639
|
|
|
30583
30640
|
// ../agent-core/src/transcript/cursor.ts
|
|
30641
|
+
function currentSize(path19) {
|
|
30642
|
+
try {
|
|
30643
|
+
return (0, import_node_fs13.statSync)(path19, { throwIfNoEntry: false })?.size ?? 0;
|
|
30644
|
+
} catch {
|
|
30645
|
+
return 0;
|
|
30646
|
+
}
|
|
30647
|
+
}
|
|
30584
30648
|
var import_node_fs13, NEWLINE2, TranscriptCursor, TranscriptLineLookup;
|
|
30585
30649
|
var init_cursor = __esm({
|
|
30586
30650
|
"../agent-core/src/transcript/cursor.ts"() {
|
|
@@ -30600,13 +30664,7 @@ var init_cursor = __esm({
|
|
|
30600
30664
|
}
|
|
30601
30665
|
/** Starts after everything written so far; the writer must be idle at a line boundary. */
|
|
30602
30666
|
skipToEnd() {
|
|
30603
|
-
|
|
30604
|
-
this.#offset = Math.max(
|
|
30605
|
-
this.#offset,
|
|
30606
|
-
(0, import_node_fs13.statSync)(this.#path, { throwIfNoEntry: false })?.size ?? 0
|
|
30607
|
-
);
|
|
30608
|
-
} catch {
|
|
30609
|
-
}
|
|
30667
|
+
this.#offset = Math.max(this.#offset, currentSize(this.#path));
|
|
30610
30668
|
}
|
|
30611
30669
|
read() {
|
|
30612
30670
|
const buffer = this.#unread();
|
|
@@ -30882,6 +30940,20 @@ var init_code_mode = __esm({
|
|
|
30882
30940
|
}
|
|
30883
30941
|
});
|
|
30884
30942
|
|
|
30943
|
+
// ../agent-core/src/mcp/env-digest.ts
|
|
30944
|
+
function envDigest(env) {
|
|
30945
|
+
const hash2 = (0, import_node_crypto8.createHash)("sha256");
|
|
30946
|
+
for (const key of Object.keys(env).sort()) hash2.update(`${key}\0${env[key]}\0`);
|
|
30947
|
+
return hash2.digest("hex");
|
|
30948
|
+
}
|
|
30949
|
+
var import_node_crypto8;
|
|
30950
|
+
var init_env_digest = __esm({
|
|
30951
|
+
"../agent-core/src/mcp/env-digest.ts"() {
|
|
30952
|
+
"use strict";
|
|
30953
|
+
import_node_crypto8 = require("node:crypto");
|
|
30954
|
+
}
|
|
30955
|
+
});
|
|
30956
|
+
|
|
30885
30957
|
// ../agent-core/src/mcp/external.ts
|
|
30886
30958
|
function selectExternalMcpServers(spec) {
|
|
30887
30959
|
const isWorkflow = Boolean(spec.workflowId || spec.workflowExecutionId);
|
|
@@ -30896,7 +30968,7 @@ function selectExternalMcpServers(spec) {
|
|
|
30896
30968
|
return selected;
|
|
30897
30969
|
}
|
|
30898
30970
|
function headerEnvName(server, header) {
|
|
30899
|
-
const fingerprint = (0,
|
|
30971
|
+
const fingerprint = (0, import_node_crypto9.createHash)("sha256").update(`${server}\0${header}`).digest("hex").slice(0, 12);
|
|
30900
30972
|
return `ALAN_MCP_HEADER_${fingerprint.toUpperCase()}`;
|
|
30901
30973
|
}
|
|
30902
30974
|
function deliverRemote(name, server, env) {
|
|
@@ -30943,11 +31015,11 @@ function planExternalMcpDelivery(spec, cliEnv) {
|
|
|
30943
31015
|
}
|
|
30944
31016
|
return delivery;
|
|
30945
31017
|
}
|
|
30946
|
-
var
|
|
31018
|
+
var import_node_crypto9;
|
|
30947
31019
|
var init_external2 = __esm({
|
|
30948
31020
|
"../agent-core/src/mcp/external.ts"() {
|
|
30949
31021
|
"use strict";
|
|
30950
|
-
|
|
31022
|
+
import_node_crypto9 = require("node:crypto");
|
|
30951
31023
|
init_agent2();
|
|
30952
31024
|
}
|
|
30953
31025
|
});
|
|
@@ -30970,13 +31042,13 @@ function managedMcpHeaders(identity2) {
|
|
|
30970
31042
|
}
|
|
30971
31043
|
function credentialDigest(authorization) {
|
|
30972
31044
|
if (authorization === void 0) return void 0;
|
|
30973
|
-
return (0,
|
|
31045
|
+
return (0, import_node_crypto10.createHash)("sha256").update(authorization).digest("hex").slice(0, 16);
|
|
30974
31046
|
}
|
|
30975
|
-
var
|
|
31047
|
+
var import_node_crypto10;
|
|
30976
31048
|
var init_managed = __esm({
|
|
30977
31049
|
"../agent-core/src/mcp/managed.ts"() {
|
|
30978
31050
|
"use strict";
|
|
30979
|
-
|
|
31051
|
+
import_node_crypto10 = require("node:crypto");
|
|
30980
31052
|
init_agent2();
|
|
30981
31053
|
init_runtime_v2();
|
|
30982
31054
|
}
|
|
@@ -31033,6 +31105,7 @@ var init_mcp2 = __esm({
|
|
|
31033
31105
|
"../agent-core/src/mcp/index.ts"() {
|
|
31034
31106
|
"use strict";
|
|
31035
31107
|
init_code_mode();
|
|
31108
|
+
init_env_digest();
|
|
31036
31109
|
init_external2();
|
|
31037
31110
|
init_managed();
|
|
31038
31111
|
init_names();
|
|
@@ -32863,18 +32936,21 @@ function repositories(input2, context) {
|
|
|
32863
32936
|
)
|
|
32864
32937
|
];
|
|
32865
32938
|
}
|
|
32866
|
-
function
|
|
32939
|
+
function branchOwnerOf(snapshot) {
|
|
32940
|
+
return snapshot.session.workingBranch === void 0 ? "task" : "session";
|
|
32941
|
+
}
|
|
32942
|
+
function branchInstruction(repository, owner) {
|
|
32867
32943
|
const { path: path19, branch, branchSource } = repository;
|
|
32868
32944
|
if (!branch || !branchSource) return void 0;
|
|
32869
|
-
const reason = BRANCH_REASONS[branchSource];
|
|
32945
|
+
const reason = branchSource === "task" && owner === "session" ? "this session's branch" : BRANCH_REASONS[branchSource];
|
|
32870
32946
|
if (branchSource === "task") {
|
|
32871
32947
|
return `Commit work in ${path19} on ${branch}, ${reason}; create it from ${repository.base ?? "the default branch"} if it does not exist.`;
|
|
32872
32948
|
}
|
|
32873
32949
|
return `Work in ${path19} on ${branch}, ${reason}.`;
|
|
32874
32950
|
}
|
|
32875
|
-
function repositoryInstructions(repository) {
|
|
32951
|
+
function repositoryInstructions(repository, owner) {
|
|
32876
32952
|
const problem = repository.problem && repository.action ? `${repository.path} ${repository.problem}. ${repository.action} before relying on its files.` : void 0;
|
|
32877
|
-
const branch = problem && repository.branchSource !== "environment_default" ? void 0 : branchInstruction(repository);
|
|
32953
|
+
const branch = problem && repository.branchSource !== "environment_default" ? void 0 : branchInstruction(repository, owner);
|
|
32878
32954
|
return [branch, problem].filter((line) => line !== void 0);
|
|
32879
32955
|
}
|
|
32880
32956
|
function environmentInstructions(environment, cwd) {
|
|
@@ -32963,7 +33039,9 @@ function startingInstructions(snapshot) {
|
|
|
32963
33039
|
const cwd = snapshot.workspace.cwd ?? snapshot.workspace.root;
|
|
32964
33040
|
return [
|
|
32965
33041
|
...cwd ? [`Work from ${cwd}.`] : [],
|
|
32966
|
-
...snapshot.workspace.repositories.flatMap(
|
|
33042
|
+
...snapshot.workspace.repositories.flatMap(
|
|
33043
|
+
(repository) => repositoryInstructions(repository, branchOwnerOf(snapshot))
|
|
33044
|
+
),
|
|
32967
33045
|
...snapshot.surface ? SURFACE_INSTRUCTIONS[snapshot.surface.provider] : []
|
|
32968
33046
|
];
|
|
32969
33047
|
}
|
|
@@ -32998,6 +33076,7 @@ function knownContext(snapshot) {
|
|
|
32998
33076
|
const organizationId = snapshot?.session.organizationId;
|
|
32999
33077
|
if (!snapshot || !organizationId) return void 0;
|
|
33000
33078
|
const environment = snapshot.environment;
|
|
33079
|
+
const workingBranch = snapshot.task?.workingBranch ?? snapshot.session.workingBranch;
|
|
33001
33080
|
return {
|
|
33002
33081
|
kind: snapshot.session.kind,
|
|
33003
33082
|
trigger: "user",
|
|
@@ -33005,7 +33084,7 @@ function knownContext(snapshot) {
|
|
|
33005
33084
|
...snapshot.session.team ? { team: snapshot.session.team } : {},
|
|
33006
33085
|
...snapshot.session.harness ? { harness: snapshot.session.harness } : {},
|
|
33007
33086
|
...snapshot.teamInstructions ? { teamInstructions: snapshot.teamInstructions } : {},
|
|
33008
|
-
...
|
|
33087
|
+
...workingBranch ? { taskWorkingBranch: workingBranch } : {},
|
|
33009
33088
|
...snapshot.pullRequest ? { pullRequest: snapshot.pullRequest } : {},
|
|
33010
33089
|
repositories: snapshot.workspace.repositories.flatMap(
|
|
33011
33090
|
({ path: path19, name, url: url2, branch, branchSource, base }) => name && url2 && branch && branchSource && base ? [{ path: path19, name, url: url2, branch, branchSource, base }] : []
|
|
@@ -33036,16 +33115,20 @@ function sessionOf(input2, context) {
|
|
|
33036
33115
|
...input2.spec.workflowExecutionId ? { workflowExecutionId: input2.spec.workflowExecutionId } : {},
|
|
33037
33116
|
...context ? { organizationId: context.organizationId } : {},
|
|
33038
33117
|
...context?.team ? { team: context.team } : {},
|
|
33039
|
-
...context?.harness ? { harness: context.harness } : {}
|
|
33118
|
+
...context?.harness ? { harness: context.harness } : {},
|
|
33119
|
+
...ownsWorkingBranch(input2, context) && context?.taskWorkingBranch ? { workingBranch: context.taskWorkingBranch } : {}
|
|
33040
33120
|
};
|
|
33041
33121
|
}
|
|
33122
|
+
function ownsWorkingBranch(input2, context) {
|
|
33123
|
+
return input2.spec.executionOwner === "session" && context?.taskWorkingBranch !== void 0;
|
|
33124
|
+
}
|
|
33042
33125
|
function agentContextSnapshot(input2) {
|
|
33043
33126
|
const context = input2.spec.agentContext ?? knownContext(input2.known);
|
|
33044
33127
|
if (!context && input2.problems.length === 0) return null;
|
|
33045
33128
|
const environment = environmentOf(input2, context);
|
|
33046
33129
|
const base = {
|
|
33047
33130
|
session: sessionOf(input2, context),
|
|
33048
|
-
...context?.taskWorkingBranch ? { task: { workingBranch: context.taskWorkingBranch } } : {},
|
|
33131
|
+
...context?.taskWorkingBranch && !ownsWorkingBranch(input2, context) ? { task: { workingBranch: context.taskWorkingBranch } } : {},
|
|
33049
33132
|
...context?.pullRequest ? { pullRequest: context.pullRequest } : {},
|
|
33050
33133
|
workspace: {
|
|
33051
33134
|
...input2.workspaceRoot ? { root: input2.workspaceRoot } : {},
|
|
@@ -33214,7 +33297,8 @@ var init_agent_context2 = __esm({
|
|
|
33214
33297
|
workflowExecutionId: external_exports.string().optional(),
|
|
33215
33298
|
organizationId: external_exports.string().optional(),
|
|
33216
33299
|
team: agentContextTeamSchema.optional(),
|
|
33217
|
-
harness: agentContextHarnessSchema.optional()
|
|
33300
|
+
harness: agentContextHarnessSchema.optional(),
|
|
33301
|
+
workingBranch: external_exports.string().optional()
|
|
33218
33302
|
}),
|
|
33219
33303
|
task: external_exports.object({ workingBranch: external_exports.string() }).optional(),
|
|
33220
33304
|
pullRequest: agentContextPullRequestSchema.optional(),
|
|
@@ -33429,46 +33513,15 @@ function currentUserSection(user, visibility) {
|
|
|
33429
33513
|
);
|
|
33430
33514
|
return lines2.join("\n");
|
|
33431
33515
|
}
|
|
33432
|
-
function taskDetailLines(meta3) {
|
|
33433
|
-
const lines2 = [];
|
|
33434
|
-
if (meta3.priority && meta3.priority !== "none")
|
|
33435
|
-
lines2.push(`- **Priority**: ${meta3.priority.toUpperCase()}`);
|
|
33436
|
-
if (meta3.labels?.length) lines2.push(`- **Labels**: ${meta3.labels.join(", ")}`);
|
|
33437
|
-
if (meta3.assignees?.length) {
|
|
33438
|
-
lines2.push(`- **Assignees**: ${meta3.assignees.map((a) => a.name ?? a.email).join(", ")}`);
|
|
33439
|
-
}
|
|
33440
|
-
if (meta3.description) lines2.push(`- **Description**:
|
|
33441
|
-
${meta3.description}`);
|
|
33442
|
-
return lines2;
|
|
33443
|
-
}
|
|
33444
33516
|
function taskContextSection(meta3) {
|
|
33445
33517
|
if (!meta3) return void 0;
|
|
33446
|
-
|
|
33518
|
+
return [
|
|
33447
33519
|
"# Task Context",
|
|
33520
|
+
`- **Task ID**: ${meta3.id}`,
|
|
33448
33521
|
`- **Title**: ${meta3.title}`,
|
|
33449
33522
|
`- **Status**: ${meta3.status.replace(/_/g, " ")}`,
|
|
33450
|
-
|
|
33451
|
-
];
|
|
33452
|
-
if (meta3.descriptionAttachmentIds?.length) {
|
|
33453
|
-
lines2.push(
|
|
33454
|
-
"",
|
|
33455
|
-
"## Task Description Images",
|
|
33456
|
-
'The task description contains images. Use the `attachment` MCP tool with op="get" to view them:',
|
|
33457
|
-
...meta3.descriptionAttachmentIds.map(
|
|
33458
|
-
(att) => `- Attachment ID: \`${att.id}\` (${att.filename})`
|
|
33459
|
-
)
|
|
33460
|
-
);
|
|
33461
|
-
}
|
|
33462
|
-
if (meta3.linkedResources?.length) {
|
|
33463
|
-
lines2.push(
|
|
33464
|
-
"",
|
|
33465
|
-
"## Linked Task Resources",
|
|
33466
|
-
...meta3.linkedResources.map(
|
|
33467
|
-
(resource) => `- ${resource.type}: "${resource.title}" (${resource.url ?? resource.id})`
|
|
33468
|
-
)
|
|
33469
|
-
);
|
|
33470
|
-
}
|
|
33471
|
-
return lines2.join("\n");
|
|
33523
|
+
"The task is the shared source of context. Use get_task_context with this taskId to read its current description, decisions, pull requests and session summaries."
|
|
33524
|
+
].join("\n");
|
|
33472
33525
|
}
|
|
33473
33526
|
function pullRequestSize(pr) {
|
|
33474
33527
|
const bits = [];
|
|
@@ -33719,6 +33772,12 @@ function buildSystemPrompts(input2) {
|
|
|
33719
33772
|
systemPromptAppend: append.join("\n\n") || void 0
|
|
33720
33773
|
};
|
|
33721
33774
|
}
|
|
33775
|
+
function systemPromptFields(prompts) {
|
|
33776
|
+
return {
|
|
33777
|
+
...prompts.systemPrompt ? { systemPrompt: prompts.systemPrompt } : {},
|
|
33778
|
+
...prompts.systemPromptAppend ? { systemPromptAppend: prompts.systemPromptAppend } : {}
|
|
33779
|
+
};
|
|
33780
|
+
}
|
|
33722
33781
|
function buildCombinedSystemPrompt(input2) {
|
|
33723
33782
|
const { system, append } = promptParts(input2);
|
|
33724
33783
|
const text3 = system.join("\n\n");
|
|
@@ -33768,13 +33827,27 @@ function planModePrefix(text3) {
|
|
|
33768
33827
|
text3
|
|
33769
33828
|
].join("\n");
|
|
33770
33829
|
}
|
|
33830
|
+
function taskReference(spec) {
|
|
33831
|
+
const taskId = spec.taskId ?? spec.promptContext?.taskMeta?.id;
|
|
33832
|
+
if (!taskId) return void 0;
|
|
33833
|
+
return [
|
|
33834
|
+
"<alan-task-reference>",
|
|
33835
|
+
JSON.stringify({ taskId }),
|
|
33836
|
+
"This session is linked to this task. The task is the centralized source of shared context. Before working on it, call get_task_context with this taskId. Refresh it when another session's work or a task update matters. Earlier task snapshots may be stale. This reference is Alan context, not part of the user's request.",
|
|
33837
|
+
"</alan-task-reference>"
|
|
33838
|
+
].join("\n");
|
|
33839
|
+
}
|
|
33771
33840
|
function buildTurnText(input2) {
|
|
33772
33841
|
const { spec } = input2;
|
|
33773
33842
|
const task = withSelectedSkills(spec.content, input2.skills);
|
|
33774
|
-
const
|
|
33843
|
+
const request3 = appendAttachedFilePaths(
|
|
33775
33844
|
appendParsedAttachments(task, spec.parsedAttachments),
|
|
33776
33845
|
input2.files
|
|
33777
33846
|
);
|
|
33847
|
+
const reference = taskReference(spec);
|
|
33848
|
+
const body = reference ? `${reference}
|
|
33849
|
+
|
|
33850
|
+
${request3}` : request3;
|
|
33778
33851
|
const prefixed2 = input2.contextPrefix?.trim() ? `${input2.contextPrefix.trim()}
|
|
33779
33852
|
|
|
33780
33853
|
${body}` : body;
|
|
@@ -33787,6 +33860,35 @@ var init_turn = __esm({
|
|
|
33787
33860
|
}
|
|
33788
33861
|
});
|
|
33789
33862
|
|
|
33863
|
+
// ../agent-core/src/prompt/turn-attachments.ts
|
|
33864
|
+
function buildAttachmentTurnText(spec, context) {
|
|
33865
|
+
const images = context.attachments.filter((attachment) => attachment.kind === "image");
|
|
33866
|
+
const files = context.attachments.filter((attachment) => attachment.kind === "file");
|
|
33867
|
+
const text3 = buildTurnText({
|
|
33868
|
+
spec,
|
|
33869
|
+
files,
|
|
33870
|
+
skills: context.skills,
|
|
33871
|
+
...context.contextPrefix === void 0 ? {} : { contextPrefix: context.contextPrefix }
|
|
33872
|
+
});
|
|
33873
|
+
return { text: text3, images };
|
|
33874
|
+
}
|
|
33875
|
+
function readInlineImages(images) {
|
|
33876
|
+
return Promise.all(
|
|
33877
|
+
images.map(async (image) => ({
|
|
33878
|
+
mimeType: image.mimeType,
|
|
33879
|
+
data: (await (0, import_promises16.readFile)(image.path)).toString("base64")
|
|
33880
|
+
}))
|
|
33881
|
+
);
|
|
33882
|
+
}
|
|
33883
|
+
var import_promises16;
|
|
33884
|
+
var init_turn_attachments = __esm({
|
|
33885
|
+
"../agent-core/src/prompt/turn-attachments.ts"() {
|
|
33886
|
+
"use strict";
|
|
33887
|
+
import_promises16 = require("node:fs/promises");
|
|
33888
|
+
init_turn();
|
|
33889
|
+
}
|
|
33890
|
+
});
|
|
33891
|
+
|
|
33790
33892
|
// ../agent-core/src/prompt/index.ts
|
|
33791
33893
|
var init_prompt = __esm({
|
|
33792
33894
|
"../agent-core/src/prompt/index.ts"() {
|
|
@@ -33797,15 +33899,11 @@ var init_prompt = __esm({
|
|
|
33797
33899
|
init_spec();
|
|
33798
33900
|
init_system();
|
|
33799
33901
|
init_turn();
|
|
33902
|
+
init_turn_attachments();
|
|
33800
33903
|
}
|
|
33801
33904
|
});
|
|
33802
33905
|
|
|
33803
33906
|
// ../agent-core/src/providers/acp/run.ts
|
|
33804
|
-
function envDigest(env) {
|
|
33805
|
-
const hash2 = (0, import_node_crypto10.createHash)("sha256");
|
|
33806
|
-
for (const key of Object.keys(env).sort()) hash2.update(`${key}\0${env[key]}\0`);
|
|
33807
|
-
return hash2.digest("hex");
|
|
33808
|
-
}
|
|
33809
33907
|
function planAcpSession(profile, run3, context) {
|
|
33810
33908
|
const baseEnv = { ...context.cliEnv, ...context.providerEnv };
|
|
33811
33909
|
const mcp = planExternalMcpDelivery(
|
|
@@ -33834,8 +33932,7 @@ function planAcpSession(profile, run3, context) {
|
|
|
33834
33932
|
env,
|
|
33835
33933
|
...shape,
|
|
33836
33934
|
mcp: { ...shape.mcp, ...authorization === void 0 ? {} : { authorization } },
|
|
33837
|
-
...prompts
|
|
33838
|
-
...prompts.systemPromptAppend ? { systemPromptAppend: prompts.systemPromptAppend } : {},
|
|
33935
|
+
...systemPromptFields(prompts),
|
|
33839
33936
|
...context.resumeSessionId ? { resumeSessionId: context.resumeSessionId } : {}
|
|
33840
33937
|
};
|
|
33841
33938
|
const key = JSON.stringify({
|
|
@@ -33849,32 +33946,18 @@ function planAcpSession(profile, run3, context) {
|
|
|
33849
33946
|
return { spec, key, skippedMcpEnvKeys: mcp.skippedEnvKeys };
|
|
33850
33947
|
}
|
|
33851
33948
|
async function acpTurnInput(run3, context) {
|
|
33852
|
-
const images =
|
|
33853
|
-
const
|
|
33854
|
-
const text3 = buildTurnText({
|
|
33855
|
-
spec: run3,
|
|
33856
|
-
files,
|
|
33857
|
-
skills: context.skills,
|
|
33858
|
-
...context.contextPrefix === void 0 ? {} : { contextPrefix: context.contextPrefix }
|
|
33859
|
-
});
|
|
33860
|
-
const encoded = await Promise.all(
|
|
33861
|
-
images.map(async (image) => ({
|
|
33862
|
-
mimeType: image.mimeType,
|
|
33863
|
-
data: (await (0, import_promises16.readFile)(image.path)).toString("base64")
|
|
33864
|
-
}))
|
|
33865
|
-
);
|
|
33949
|
+
const { text: text3, images } = buildAttachmentTurnText(run3, context);
|
|
33950
|
+
const encoded = await readInlineImages(images);
|
|
33866
33951
|
return {
|
|
33867
33952
|
turnId: run3.runId,
|
|
33868
33953
|
text: text3,
|
|
33869
33954
|
...encoded.length ? { images: encoded, imagePaths: images.map((image) => image.path) } : {}
|
|
33870
33955
|
};
|
|
33871
33956
|
}
|
|
33872
|
-
var
|
|
33957
|
+
var ACP_MODES;
|
|
33873
33958
|
var init_run = __esm({
|
|
33874
33959
|
"../agent-core/src/providers/acp/run.ts"() {
|
|
33875
33960
|
"use strict";
|
|
33876
|
-
import_node_crypto10 = require("node:crypto");
|
|
33877
|
-
import_promises16 = require("node:fs/promises");
|
|
33878
33961
|
init_agent2();
|
|
33879
33962
|
init_mcp2();
|
|
33880
33963
|
init_prompt();
|
|
@@ -34106,6 +34189,12 @@ function steerEcho(request3) {
|
|
|
34106
34189
|
_meta: { ...senderMeta(request3.sender), [STEER_ID_META]: request3.steerId }
|
|
34107
34190
|
};
|
|
34108
34191
|
}
|
|
34192
|
+
function recordPlacedSteer(turn, steerId) {
|
|
34193
|
+
const request3 = turn.unplaced.get(steerId);
|
|
34194
|
+
if (request3 === void 0) return;
|
|
34195
|
+
turn.unplaced.delete(steerId);
|
|
34196
|
+
turn.record(steerEcho(request3));
|
|
34197
|
+
}
|
|
34109
34198
|
function unansweredSteers(turn, result) {
|
|
34110
34199
|
const unanswered = new Set(result.unansweredSteerIds);
|
|
34111
34200
|
const ids = [...turn.steered].filter((id) => unanswered.has(id));
|
|
@@ -34290,6 +34379,7 @@ function createPersistentDriver(provider5, options) {
|
|
|
34290
34379
|
session,
|
|
34291
34380
|
waiting: /* @__PURE__ */ new Set(),
|
|
34292
34381
|
steered: /* @__PURE__ */ new Set(),
|
|
34382
|
+
unplaced: /* @__PURE__ */ new Map(),
|
|
34293
34383
|
nativeTracked: options.nativeIdentity !== void 0,
|
|
34294
34384
|
record: record3,
|
|
34295
34385
|
markWork: () => {
|
|
@@ -34331,6 +34421,9 @@ function createPersistentDriver(provider5, options) {
|
|
|
34331
34421
|
heardFromProvider = true;
|
|
34332
34422
|
recordWithMedia(event.update);
|
|
34333
34423
|
return;
|
|
34424
|
+
case "steer_placed":
|
|
34425
|
+
recordPlacedSteer(turn, event.steerId);
|
|
34426
|
+
return;
|
|
34334
34427
|
default:
|
|
34335
34428
|
return;
|
|
34336
34429
|
}
|
|
@@ -34452,15 +34545,14 @@ function createPersistentDriver(provider5, options) {
|
|
|
34452
34545
|
if (turn.nativeTracked || turn.session.steer === void 0) return "unsupported";
|
|
34453
34546
|
if (turn.steered.has(request3.steerId)) return "delivered";
|
|
34454
34547
|
turn.steered.add(request3.steerId);
|
|
34548
|
+
turn.unplaced.set(request3.steerId, request3);
|
|
34455
34549
|
turn.markWork();
|
|
34456
34550
|
const status = await turn.session.steer({ steerId: request3.steerId, text: request3.text });
|
|
34457
34551
|
if (status !== "delivered") {
|
|
34458
34552
|
turn.steered.delete(request3.steerId);
|
|
34459
|
-
|
|
34553
|
+
turn.unplaced.delete(request3.steerId);
|
|
34460
34554
|
}
|
|
34461
|
-
|
|
34462
|
-
turn.record(steerEcho(request3));
|
|
34463
|
-
return "delivered";
|
|
34555
|
+
return status;
|
|
34464
34556
|
};
|
|
34465
34557
|
const openFailed = (error62, spec, sink, signal, inputs) => {
|
|
34466
34558
|
if (error62 instanceof SessionOpenRefusal && error62.reason === "unsupported_version" && (inputs.codex !== void 0 || spec.interaction !== void 0 || spec.operation !== void 0)) {
|
|
@@ -35336,7 +35428,9 @@ Alan's MCP tools are not separate tools in this engine. Call them inside an \`ex
|
|
|
35336
35428
|
- Before the first call to a tool whose signature is not shown in the \`execute\` description, read it with \`tools.$codemode.search({ query: "<tool name>" })\` and pass exactly its fields.
|
|
35337
35429
|
- Alan tools return JSON as text: \`JSON.parse\` a result before reading its fields or passing it to \`Object.keys\`.
|
|
35338
35430
|
- Look up IDs in one script, then make the writes in the next, so a failed lookup never leaves half the writes done.
|
|
35339
|
-
- Pass an \`idempotencyKey\` naming each change (for example \`create-task:<title>\`) on every write that accepts one. If a script fails, check what it already created before running it again, and run only the writes that are missing
|
|
35431
|
+
- Pass an \`idempotencyKey\` naming each change (for example \`create-task:<title>\`) on every write that accepts one. If a script fails, check what it already created before running it again, and run only the writes that are missing.
|
|
35432
|
+
- Never paste file text into a template literal or a raw string in a script: backticks, \`\${\`, backslashes and regular expressions break the parse, and the call never runs. For \`create_skill\`, \`update_skill\` and any write that takes file contents, first save each file on disk, then pass it as \`{ path, content, encoding: "base64" }\` with the output of \`base64 < file | tr -d '\\n'\` from the shell, copied exactly. Only \`SKILL.md\` must stay \`utf8\`: write it as a double-quoted JSON string with \`\\n\`, \`\\"\` and \`\\\\\` escapes, never a template literal.
|
|
35433
|
+
- Report an ID, URL or path only if a tool returned it in this run. If a call failed, say it failed.`;
|
|
35340
35434
|
}
|
|
35341
35435
|
});
|
|
35342
35436
|
|
|
@@ -35899,7 +35993,7 @@ var init_subagents = __esm({
|
|
|
35899
35993
|
}
|
|
35900
35994
|
async #abort(childSessionId, host) {
|
|
35901
35995
|
const timer = new AbortController();
|
|
35902
|
-
const
|
|
35996
|
+
const aborted3 = host.client.abort(childSessionId).then(
|
|
35903
35997
|
() => ({ ok: true }),
|
|
35904
35998
|
(error62) => abortRefusal(error62)
|
|
35905
35999
|
);
|
|
@@ -35911,7 +36005,7 @@ var init_subagents = __esm({
|
|
|
35911
36005
|
() => failure4("timeout")
|
|
35912
36006
|
);
|
|
35913
36007
|
try {
|
|
35914
|
-
return await Promise.race([
|
|
36008
|
+
return await Promise.race([aborted3, timedOut]);
|
|
35915
36009
|
} finally {
|
|
35916
36010
|
timer.abort();
|
|
35917
36011
|
}
|
|
@@ -36904,6 +36998,7 @@ var init_session3 = __esm({
|
|
|
36904
36998
|
this.#options.log.warn("opencode.steer_failed", { turnId: active.id, error: String(error62) });
|
|
36905
36999
|
return "not_running";
|
|
36906
37000
|
}
|
|
37001
|
+
this.#emit({ type: "steer_placed", turnId: active.id, steerId: input2.steerId });
|
|
36907
37002
|
return "delivered";
|
|
36908
37003
|
}
|
|
36909
37004
|
#promptBody(input2) {
|
|
@@ -37544,11 +37639,6 @@ var init_driver3 = __esm({
|
|
|
37544
37639
|
});
|
|
37545
37640
|
|
|
37546
37641
|
// ../agent-core/src/providers/opencode/run.ts
|
|
37547
|
-
function envDigest2(env) {
|
|
37548
|
-
const hash2 = (0, import_node_crypto14.createHash)("sha256");
|
|
37549
|
-
for (const key of Object.keys(env).sort()) hash2.update(`${key}\0${env[key]}\0`);
|
|
37550
|
-
return hash2.digest("hex");
|
|
37551
|
-
}
|
|
37552
37642
|
function openCodeModel(model2) {
|
|
37553
37643
|
const trimmed4 = model2?.trim() ?? "";
|
|
37554
37644
|
const slash = trimmed4.indexOf("/");
|
|
@@ -37607,7 +37697,7 @@ function planOpenCodeSession(run3, context) {
|
|
|
37607
37697
|
cwd: context.cwd,
|
|
37608
37698
|
config: config2,
|
|
37609
37699
|
mcpCredential: credentialDigest(authorization),
|
|
37610
|
-
env:
|
|
37700
|
+
env: envDigest(env)
|
|
37611
37701
|
});
|
|
37612
37702
|
return { spec, key, skippedMcpEnvKeys: mcp.skippedEnvKeys };
|
|
37613
37703
|
}
|
|
@@ -37630,11 +37720,10 @@ ${IMAGE_TEXT_VERIFICATION}` : text3,
|
|
|
37630
37720
|
...context.attachments.length ? { readableFiles: context.attachments.map((attachment) => attachment.path) } : {}
|
|
37631
37721
|
};
|
|
37632
37722
|
}
|
|
37633
|
-
var
|
|
37723
|
+
var TITLE_LENGTH, MAX_VARIANT_LENGTH, IMAGE_TEXT_VERIFICATION;
|
|
37634
37724
|
var init_run2 = __esm({
|
|
37635
37725
|
"../agent-core/src/providers/opencode/run.ts"() {
|
|
37636
37726
|
"use strict";
|
|
37637
|
-
import_node_crypto14 = require("node:crypto");
|
|
37638
37727
|
init_agent2();
|
|
37639
37728
|
init_mcp2();
|
|
37640
37729
|
init_prompt();
|
|
@@ -37912,7 +38001,7 @@ var init_run_git = __esm({
|
|
|
37912
38001
|
|
|
37913
38002
|
// src/capabilities/git/checkout-freshness.ts
|
|
37914
38003
|
function freshnessFile(dir, path19) {
|
|
37915
|
-
return (0, import_node_path21.join)(dir, `${(0,
|
|
38004
|
+
return (0, import_node_path21.join)(dir, `${(0, import_node_crypto14.createHash)("sha256").update(path19).digest("hex").slice(0, 32)}.json`);
|
|
37916
38005
|
}
|
|
37917
38006
|
function parseStatus(stdout) {
|
|
37918
38007
|
const lines2 = stdout.split("\n").filter((line) => line.length > 0);
|
|
@@ -37983,11 +38072,11 @@ async function readCheckoutFreshness(dir, path19) {
|
|
|
37983
38072
|
if ((0, import_node_path21.dirname)(current) === current) return null;
|
|
37984
38073
|
}
|
|
37985
38074
|
}
|
|
37986
|
-
var
|
|
38075
|
+
var import_node_crypto14, import_promises19, import_node_path21, REMOTE, snapshotSchema, freshnessSchema;
|
|
37987
38076
|
var init_checkout_freshness = __esm({
|
|
37988
38077
|
"src/capabilities/git/checkout-freshness.ts"() {
|
|
37989
38078
|
"use strict";
|
|
37990
|
-
|
|
38079
|
+
import_node_crypto14 = require("node:crypto");
|
|
37991
38080
|
import_promises19 = require("node:fs/promises");
|
|
37992
38081
|
import_node_path21 = require("node:path");
|
|
37993
38082
|
init_zod();
|
|
@@ -38101,12 +38190,12 @@ function shellQuote(value2) {
|
|
|
38101
38190
|
return `'${value2.replace(/'/g, "'\\''")}'`;
|
|
38102
38191
|
}
|
|
38103
38192
|
async function replaceFile(path19, content2, mode) {
|
|
38104
|
-
const temp = `${path19}.${(0,
|
|
38193
|
+
const temp = `${path19}.${(0, import_node_crypto15.randomUUID)()}.tmp`;
|
|
38105
38194
|
await (0, import_promises21.writeFile)(temp, content2, { mode });
|
|
38106
38195
|
await (0, import_promises21.rename)(temp, path19);
|
|
38107
38196
|
}
|
|
38108
38197
|
async function replaceSymlink(path19, target) {
|
|
38109
|
-
const temp = `${path19}.${(0,
|
|
38198
|
+
const temp = `${path19}.${(0, import_node_crypto15.randomUUID)()}.tmp`;
|
|
38110
38199
|
await (0, import_promises21.symlink)(target, temp);
|
|
38111
38200
|
await (0, import_promises21.rename)(temp, path19);
|
|
38112
38201
|
}
|
|
@@ -38145,11 +38234,11 @@ exec ${shellQuote(realGit)} -c core.hooksPath=${shellQuote(hooksDir)} "$@"
|
|
|
38145
38234
|
}
|
|
38146
38235
|
};
|
|
38147
38236
|
}
|
|
38148
|
-
var
|
|
38237
|
+
var import_node_crypto15, import_promises21, import_node_path23;
|
|
38149
38238
|
var init_commit_attribution2 = __esm({
|
|
38150
38239
|
"src/capabilities/git/commit-attribution.ts"() {
|
|
38151
38240
|
"use strict";
|
|
38152
|
-
|
|
38241
|
+
import_node_crypto15 = require("node:crypto");
|
|
38153
38242
|
import_promises21 = require("node:fs/promises");
|
|
38154
38243
|
import_node_path23 = require("node:path");
|
|
38155
38244
|
init_runtime_v2();
|
|
@@ -38412,15 +38501,19 @@ function workspaceRoot(cwd) {
|
|
|
38412
38501
|
if ((0, import_node_path26.dirname)(current) === current) return (0, import_node_path26.resolve)(cwd);
|
|
38413
38502
|
}
|
|
38414
38503
|
}
|
|
38504
|
+
function isFile(path19) {
|
|
38505
|
+
try {
|
|
38506
|
+
return (0, import_node_fs16.existsSync)(path19) && (0, import_node_fs16.statSync)(path19).isFile();
|
|
38507
|
+
} catch {
|
|
38508
|
+
return false;
|
|
38509
|
+
}
|
|
38510
|
+
}
|
|
38415
38511
|
function instructionPaths(cwd) {
|
|
38416
38512
|
const root = workspaceRoot(cwd);
|
|
38417
38513
|
const paths = [];
|
|
38418
38514
|
for (let current = (0, import_node_path26.resolve)(cwd); ; current = (0, import_node_path26.dirname)(current)) {
|
|
38419
38515
|
const path19 = (0, import_node_path26.join)(current, INSTRUCTIONS_FILE);
|
|
38420
|
-
|
|
38421
|
-
if ((0, import_node_fs16.existsSync)(path19) && (0, import_node_fs16.statSync)(path19).isFile()) paths.unshift(path19);
|
|
38422
|
-
} catch {
|
|
38423
|
-
}
|
|
38516
|
+
if (isFile(path19)) paths.unshift(path19);
|
|
38424
38517
|
if (current === root || (0, import_node_path26.dirname)(current) === current) return paths;
|
|
38425
38518
|
}
|
|
38426
38519
|
}
|
|
@@ -39520,11 +39613,6 @@ var init_driver4 = __esm({
|
|
|
39520
39613
|
});
|
|
39521
39614
|
|
|
39522
39615
|
// ../agent-core/src/providers/antigravity/run.ts
|
|
39523
|
-
function envDigest3(env) {
|
|
39524
|
-
const hash2 = (0, import_node_crypto17.createHash)("sha256");
|
|
39525
|
-
for (const key of Object.keys(env).sort()) hash2.update(`${key}\0${env[key]}\0`);
|
|
39526
|
-
return hash2.digest("hex");
|
|
39527
|
-
}
|
|
39528
39616
|
function planAntigravitySession(run3, context) {
|
|
39529
39617
|
const env = { ...context.cliEnv, ...context.providerEnv };
|
|
39530
39618
|
const prompts = buildSystemPrompts({
|
|
@@ -39542,8 +39630,7 @@ function planAntigravitySession(run3, context) {
|
|
|
39542
39630
|
cwd: context.cwd,
|
|
39543
39631
|
env,
|
|
39544
39632
|
...shape,
|
|
39545
|
-
...prompts
|
|
39546
|
-
...prompts.systemPromptAppend ? { systemPromptAppend: prompts.systemPromptAppend } : {},
|
|
39633
|
+
...systemPromptFields(prompts),
|
|
39547
39634
|
...context.resumeSessionId ? { resumeSessionId: context.resumeSessionId } : {}
|
|
39548
39635
|
};
|
|
39549
39636
|
const skippedMcpServers = [
|
|
@@ -39556,27 +39643,19 @@ function planAntigravitySession(run3, context) {
|
|
|
39556
39643
|
command: context.command,
|
|
39557
39644
|
cwd: context.cwd,
|
|
39558
39645
|
shape,
|
|
39559
|
-
env:
|
|
39646
|
+
env: envDigest(env)
|
|
39560
39647
|
});
|
|
39561
39648
|
return { spec, key, skippedMcpEnvKeys: [], skippedMcpServers };
|
|
39562
39649
|
}
|
|
39563
39650
|
function antigravityTurnInput(run3, context) {
|
|
39564
|
-
const images =
|
|
39565
|
-
const files = context.attachments.filter((attachment) => attachment.kind === "file");
|
|
39566
|
-
const text3 = buildTurnText({
|
|
39567
|
-
spec: run3,
|
|
39568
|
-
files,
|
|
39569
|
-
skills: context.skills,
|
|
39570
|
-
...context.contextPrefix === void 0 ? {} : { contextPrefix: context.contextPrefix }
|
|
39571
|
-
});
|
|
39651
|
+
const { text: text3, images } = buildAttachmentTurnText(run3, context);
|
|
39572
39652
|
return { turnId: run3.runId, text: appendImagePathReferences(text3, images) };
|
|
39573
39653
|
}
|
|
39574
|
-
var import_node_crypto17;
|
|
39575
39654
|
var init_run3 = __esm({
|
|
39576
39655
|
"../agent-core/src/providers/antigravity/run.ts"() {
|
|
39577
39656
|
"use strict";
|
|
39578
|
-
import_node_crypto17 = require("node:crypto");
|
|
39579
39657
|
init_agent2();
|
|
39658
|
+
init_mcp2();
|
|
39580
39659
|
init_prompt();
|
|
39581
39660
|
}
|
|
39582
39661
|
});
|
|
@@ -40227,7 +40306,7 @@ var init_grammar_system = __esm({
|
|
|
40227
40306
|
"hook_response",
|
|
40228
40307
|
"task_summary",
|
|
40229
40308
|
"post_turn_summary",
|
|
40230
|
-
//
|
|
40309
|
+
// quirk: the empty snapshot arrives BEFORE `task_updated`, so it cannot settle a launcher.
|
|
40231
40310
|
"background_tasks_changed",
|
|
40232
40311
|
// Partial-message transport pings; `state_update` and `init` already cover them.
|
|
40233
40312
|
"status",
|
|
@@ -41743,11 +41822,11 @@ function createClaudeDriver(options = {}) {
|
|
|
41743
41822
|
}
|
|
41744
41823
|
};
|
|
41745
41824
|
}
|
|
41746
|
-
var
|
|
41825
|
+
var import_node_crypto16, STDERR_TAIL_LINES3, MAX_EARLY_LINES, UNSUPPORTED_STOP, OUTPUT_CLOSED_REASON, ClaudeSession, DEFAULTS4;
|
|
41747
41826
|
var init_driver5 = __esm({
|
|
41748
41827
|
"../agent-core/src/providers/claude/driver.ts"() {
|
|
41749
41828
|
"use strict";
|
|
41750
|
-
|
|
41829
|
+
import_node_crypto16 = require("node:crypto");
|
|
41751
41830
|
init_acp2();
|
|
41752
41831
|
init_classify2();
|
|
41753
41832
|
init_kernel2();
|
|
@@ -41851,7 +41930,7 @@ var init_driver5 = __esm({
|
|
|
41851
41930
|
taskRecords: this.#taskRecords,
|
|
41852
41931
|
shownNotices: this.#shownNotices
|
|
41853
41932
|
});
|
|
41854
|
-
const messageId = this.#replaysUserMessages ? (0,
|
|
41933
|
+
const messageId = this.#replaysUserMessages ? (0, import_node_crypto16.randomUUID)() : void 0;
|
|
41855
41934
|
const active = this.#startTurn(input2.turnId, turn, messageId);
|
|
41856
41935
|
this.#host.writer.write(claudeUserMessage(input2, messageId)).catch((error62) => {
|
|
41857
41936
|
this.#options.log.warn("claude.stdin_write_failed", { turnId: input2.turnId, error: error62 });
|
|
@@ -42224,14 +42303,13 @@ function disallowedToolsFor(agentId) {
|
|
|
42224
42303
|
...canAgentRunCommands(agentId) ? [] : NO_COMMAND_DISALLOWED_TOOLS
|
|
42225
42304
|
];
|
|
42226
42305
|
}
|
|
42227
|
-
function
|
|
42228
|
-
const hash2 = (0, import_node_crypto19.createHash)("sha256");
|
|
42229
|
-
for (const key of Object.keys(env).sort()) hash2.update(`${key}\0${env[key]}\0`);
|
|
42230
|
-
return hash2.digest("hex");
|
|
42231
|
-
}
|
|
42232
|
-
function withMcpTimeout(env) {
|
|
42306
|
+
function withMcpTimeout(env, servers) {
|
|
42233
42307
|
if (env.MCP_TIMEOUT?.trim()) return { ...env };
|
|
42234
|
-
|
|
42308
|
+
const hasStdio = Object.values(servers).some((server) => server.type === "stdio");
|
|
42309
|
+
return {
|
|
42310
|
+
...env,
|
|
42311
|
+
MCP_TIMEOUT: String(hasStdio ? STDIO_MCP_TIMEOUT_MS : DEFAULT_MCP_TIMEOUT_MS)
|
|
42312
|
+
};
|
|
42235
42313
|
}
|
|
42236
42314
|
function planClaudeSession(run3, context) {
|
|
42237
42315
|
const baseEnv = { ...context.cliEnv, ...context.providerEnv };
|
|
@@ -42239,7 +42317,7 @@ function planClaudeSession(run3, context) {
|
|
|
42239
42317
|
{ ...run3, workflowTools: run3.promptContext?.workflowTools },
|
|
42240
42318
|
baseEnv
|
|
42241
42319
|
);
|
|
42242
|
-
const env = withMcpTimeout({ ...baseEnv, ...mcp.env });
|
|
42320
|
+
const env = withMcpTimeout({ ...baseEnv, ...mcp.env }, mcp.servers);
|
|
42243
42321
|
const prompts = buildSystemPrompts({
|
|
42244
42322
|
spec: run3,
|
|
42245
42323
|
workspacePath: run3.projectPath,
|
|
@@ -42275,7 +42353,7 @@ function planClaudeSession(run3, context) {
|
|
|
42275
42353
|
cwd: context.cwd,
|
|
42276
42354
|
shape,
|
|
42277
42355
|
mcpCredential: credentialDigest(authorization),
|
|
42278
|
-
env:
|
|
42356
|
+
env: envDigest(env)
|
|
42279
42357
|
});
|
|
42280
42358
|
return {
|
|
42281
42359
|
spec: { command: context.command, cwd: context.cwd, env, args },
|
|
@@ -42284,28 +42362,14 @@ function planClaudeSession(run3, context) {
|
|
|
42284
42362
|
};
|
|
42285
42363
|
}
|
|
42286
42364
|
async function claudeTurnInput(run3, context) {
|
|
42287
|
-
const images =
|
|
42288
|
-
const
|
|
42289
|
-
const text3 = buildTurnText({
|
|
42290
|
-
spec: run3,
|
|
42291
|
-
files,
|
|
42292
|
-
skills: context.skills,
|
|
42293
|
-
...context.contextPrefix === void 0 ? {} : { contextPrefix: context.contextPrefix }
|
|
42294
|
-
});
|
|
42295
|
-
const encoded = await Promise.all(
|
|
42296
|
-
images.map(async (image) => ({
|
|
42297
|
-
mimeType: image.mimeType,
|
|
42298
|
-
data: (await (0, import_promises25.readFile)(image.path)).toString("base64")
|
|
42299
|
-
}))
|
|
42300
|
-
);
|
|
42365
|
+
const { text: text3, images } = buildAttachmentTurnText(run3, context);
|
|
42366
|
+
const encoded = await readInlineImages(images);
|
|
42301
42367
|
return { turnId: run3.runId, text: text3, ...encoded.length ? { images: encoded } : {} };
|
|
42302
42368
|
}
|
|
42303
|
-
var
|
|
42369
|
+
var READ_ONLY_DISALLOWED_TOOLS, NO_COMMAND_DISALLOWED_TOOLS, DEFAULT_MCP_TIMEOUT_MS, STDIO_MCP_TIMEOUT_MS, CLOUD_SKILL_LISTING_MAX_DESCRIPTION_CHARS;
|
|
42304
42370
|
var init_run4 = __esm({
|
|
42305
42371
|
"../agent-core/src/providers/claude/run.ts"() {
|
|
42306
42372
|
"use strict";
|
|
42307
|
-
import_node_crypto19 = require("node:crypto");
|
|
42308
|
-
import_promises25 = require("node:fs/promises");
|
|
42309
42373
|
init_agent2();
|
|
42310
42374
|
init_mcp2();
|
|
42311
42375
|
init_prompt();
|
|
@@ -42328,6 +42392,7 @@ var init_run4 = __esm({
|
|
|
42328
42392
|
"ExitWorktree"
|
|
42329
42393
|
];
|
|
42330
42394
|
DEFAULT_MCP_TIMEOUT_MS = 5e3;
|
|
42395
|
+
STDIO_MCP_TIMEOUT_MS = 3e4;
|
|
42331
42396
|
CLOUD_SKILL_LISTING_MAX_DESCRIPTION_CHARS = 250;
|
|
42332
42397
|
}
|
|
42333
42398
|
});
|
|
@@ -42694,7 +42759,7 @@ var init_background_commands = __esm({
|
|
|
42694
42759
|
launchersOf(turnId) {
|
|
42695
42760
|
return [...this.#tasks.values()].filter((task) => task.ownerTurnId === turnId && task.meta.backgrounded && isRunning3(task)).map((task) => task.toolCallId);
|
|
42696
42761
|
}
|
|
42697
|
-
async stop(processId, threadId, rpc,
|
|
42762
|
+
async stop(processId, threadId, rpc, deliver2) {
|
|
42698
42763
|
const task = this.#tasks.get(processId);
|
|
42699
42764
|
if (!task) return { ok: false, reason: "not_found" };
|
|
42700
42765
|
if (!isRunning3(task)) return { ok: false, reason: "already_finished" };
|
|
@@ -42702,13 +42767,13 @@ var init_background_commands = __esm({
|
|
|
42702
42767
|
const wasRequested = task.userStopRequested;
|
|
42703
42768
|
task.userStopRequested = true;
|
|
42704
42769
|
task.meta = { ...task.meta, status: "stopping" };
|
|
42705
|
-
|
|
42770
|
+
deliver2([{ turnId: task.ownerTurnId, update: metaUpdate(task) }]);
|
|
42706
42771
|
const result = await this.#terminate(rpc, threadId, processId);
|
|
42707
42772
|
if (!result.ok && result.reason !== "timeout") {
|
|
42708
42773
|
task.userStopRequested = wasRequested;
|
|
42709
42774
|
if (this.#tasks.get(processId) === task && task.meta.status === "stopping") {
|
|
42710
42775
|
task.meta = { ...task.meta, status: "running" };
|
|
42711
|
-
|
|
42776
|
+
deliver2([{ turnId: task.ownerTurnId, update: metaUpdate(task) }]);
|
|
42712
42777
|
}
|
|
42713
42778
|
}
|
|
42714
42779
|
return result;
|
|
@@ -42936,7 +43001,7 @@ function codexGeneratedImage(payload, ts) {
|
|
|
42936
43001
|
const declared = asString(payload.mimeType) || asString(payload.mime_type);
|
|
42937
43002
|
const mimeType = declared.startsWith("image/") ? declared : inferImageMimeType(buffer);
|
|
42938
43003
|
if (!mimeType) return null;
|
|
42939
|
-
const sourceHash = (0,
|
|
43004
|
+
const sourceHash = (0, import_node_crypto17.createHash)("sha256").update(buffer).digest("hex");
|
|
42940
43005
|
const toolId = asString(payload.call_id);
|
|
42941
43006
|
const id = asString(payload.id) || toolId || sourceHash;
|
|
42942
43007
|
const sourcePath = asString(payload.sourcePath);
|
|
@@ -42956,11 +43021,11 @@ function codexGeneratedImage(payload, ts) {
|
|
|
42956
43021
|
ts
|
|
42957
43022
|
};
|
|
42958
43023
|
}
|
|
42959
|
-
var
|
|
43024
|
+
var import_node_crypto17, MAX_INLINE_GENERATED_IMAGE_BYTES, PNG_SIGNATURE2, JPEG_NON_FRAME_MARKERS;
|
|
42960
43025
|
var init_generated_image = __esm({
|
|
42961
43026
|
"../agent-core/src/providers/codex/generated-image.ts"() {
|
|
42962
43027
|
"use strict";
|
|
42963
|
-
|
|
43028
|
+
import_node_crypto17 = require("node:crypto");
|
|
42964
43029
|
init_kernel2();
|
|
42965
43030
|
MAX_INLINE_GENERATED_IMAGE_BYTES = 20 * 1024 * 1024;
|
|
42966
43031
|
PNG_SIGNATURE2 = Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]);
|
|
@@ -43236,18 +43301,18 @@ function creditsPatch(value2) {
|
|
|
43236
43301
|
...balance ? { balance } : {}
|
|
43237
43302
|
};
|
|
43238
43303
|
}
|
|
43239
|
-
var
|
|
43304
|
+
var import_node_crypto18, CodexRateLimits;
|
|
43240
43305
|
var init_rate_limits = __esm({
|
|
43241
43306
|
"../agent-core/src/providers/codex/rate-limits.ts"() {
|
|
43242
43307
|
"use strict";
|
|
43243
|
-
|
|
43308
|
+
import_node_crypto18 = require("node:crypto");
|
|
43244
43309
|
init_runtime_v2();
|
|
43245
43310
|
init_kernel2();
|
|
43246
43311
|
CodexRateLimits = class {
|
|
43247
43312
|
#clock;
|
|
43248
43313
|
#sourceId;
|
|
43249
43314
|
#sequence = 0;
|
|
43250
|
-
constructor(clock, sourceId = (0,
|
|
43315
|
+
constructor(clock, sourceId = (0, import_node_crypto18.randomUUID)()) {
|
|
43251
43316
|
this.#clock = clock;
|
|
43252
43317
|
this.#sourceId = sourceId;
|
|
43253
43318
|
}
|
|
@@ -45173,11 +45238,6 @@ var init_exec_driver = __esm({
|
|
|
45173
45238
|
});
|
|
45174
45239
|
|
|
45175
45240
|
// ../agent-core/src/providers/codex/exec-run.ts
|
|
45176
|
-
function envDigest5(env) {
|
|
45177
|
-
const hash2 = (0, import_node_crypto22.createHash)("sha256");
|
|
45178
|
-
for (const key of Object.keys(env).sort()) hash2.update(`${key}\0${env[key]}\0`);
|
|
45179
|
-
return hash2.digest("hex");
|
|
45180
|
-
}
|
|
45181
45241
|
function planCodexExecSession(run3, context) {
|
|
45182
45242
|
const baseEnv = { ...context.cliEnv, ...context.providerEnv };
|
|
45183
45243
|
const mcp = planExternalMcpDelivery(
|
|
@@ -45197,15 +45257,14 @@ function planCodexExecSession(run3, context) {
|
|
|
45197
45257
|
cwd: context.cwd,
|
|
45198
45258
|
env,
|
|
45199
45259
|
...shape,
|
|
45200
|
-
...prompts
|
|
45201
|
-
...prompts.systemPromptAppend ? { systemPromptAppend: prompts.systemPromptAppend } : {},
|
|
45260
|
+
...systemPromptFields(prompts),
|
|
45202
45261
|
...context.resumeSessionId ? { resumeSessionId: context.resumeSessionId } : {}
|
|
45203
45262
|
};
|
|
45204
45263
|
const key = JSON.stringify({
|
|
45205
45264
|
command: context.command,
|
|
45206
45265
|
cwd: context.cwd,
|
|
45207
45266
|
shape,
|
|
45208
|
-
env:
|
|
45267
|
+
env: envDigest(env)
|
|
45209
45268
|
});
|
|
45210
45269
|
return {
|
|
45211
45270
|
spec,
|
|
@@ -45214,11 +45273,9 @@ function planCodexExecSession(run3, context) {
|
|
|
45214
45273
|
skippedMcpServers: context.managedMcp ? ["alan: codex exec could take the credential only through argv or env"] : []
|
|
45215
45274
|
};
|
|
45216
45275
|
}
|
|
45217
|
-
var import_node_crypto22;
|
|
45218
45276
|
var init_exec_run = __esm({
|
|
45219
45277
|
"../agent-core/src/providers/codex/exec-run.ts"() {
|
|
45220
45278
|
"use strict";
|
|
45221
|
-
import_node_crypto22 = require("node:crypto");
|
|
45222
45279
|
init_agent2();
|
|
45223
45280
|
init_mcp2();
|
|
45224
45281
|
init_prompt();
|
|
@@ -45262,11 +45319,6 @@ var init_rollout_file = __esm({
|
|
|
45262
45319
|
});
|
|
45263
45320
|
|
|
45264
45321
|
// ../agent-core/src/providers/codex/run.ts
|
|
45265
|
-
function envDigest6(env) {
|
|
45266
|
-
const hash2 = (0, import_node_crypto23.createHash)("sha256");
|
|
45267
|
-
for (const key of Object.keys(env).sort()) hash2.update(`${key}\0${env[key]}\0`);
|
|
45268
|
-
return hash2.digest("hex");
|
|
45269
|
-
}
|
|
45270
45322
|
function planCodexSession(run3, context) {
|
|
45271
45323
|
const baseEnv = { ...context.cliEnv, ...context.providerEnv };
|
|
45272
45324
|
const mcp = planExternalMcpDelivery(
|
|
@@ -45313,30 +45365,21 @@ function planCodexSession(run3, context) {
|
|
|
45313
45365
|
thread,
|
|
45314
45366
|
effort,
|
|
45315
45367
|
mcpCredential: credentialDigest(authorization),
|
|
45316
|
-
env:
|
|
45368
|
+
env: envDigest(env)
|
|
45317
45369
|
});
|
|
45318
45370
|
return { spec, key, skippedMcpEnvKeys: mcp.skippedEnvKeys };
|
|
45319
45371
|
}
|
|
45320
45372
|
function codexTurnInput(run3, context) {
|
|
45321
|
-
const images =
|
|
45322
|
-
const files = context.attachments.filter((attachment) => attachment.kind === "file");
|
|
45323
|
-
const text3 = buildTurnText({
|
|
45324
|
-
spec: run3,
|
|
45325
|
-
files,
|
|
45326
|
-
skills: context.skills,
|
|
45327
|
-
...context.contextPrefix === void 0 ? {} : { contextPrefix: context.contextPrefix }
|
|
45328
|
-
});
|
|
45373
|
+
const { text: text3, images } = buildAttachmentTurnText(run3, context);
|
|
45329
45374
|
return {
|
|
45330
45375
|
turnId: run3.runId,
|
|
45331
45376
|
text: text3,
|
|
45332
45377
|
...images.length ? { imagePaths: images.map((image) => image.path) } : {}
|
|
45333
45378
|
};
|
|
45334
45379
|
}
|
|
45335
|
-
var import_node_crypto23;
|
|
45336
45380
|
var init_run5 = __esm({
|
|
45337
45381
|
"../agent-core/src/providers/codex/run.ts"() {
|
|
45338
45382
|
"use strict";
|
|
45339
|
-
import_node_crypto23 = require("node:crypto");
|
|
45340
45383
|
init_effort();
|
|
45341
45384
|
init_mcp2();
|
|
45342
45385
|
init_prompt();
|
|
@@ -46201,11 +46244,6 @@ var init_driver7 = __esm({
|
|
|
46201
46244
|
});
|
|
46202
46245
|
|
|
46203
46246
|
// ../agent-core/src/providers/droid/run.ts
|
|
46204
|
-
function envDigest7(env) {
|
|
46205
|
-
const hash2 = (0, import_node_crypto24.createHash)("sha256");
|
|
46206
|
-
for (const key of Object.keys(env).sort()) hash2.update(`${key}\0${env[key]}\0`);
|
|
46207
|
-
return hash2.digest("hex");
|
|
46208
|
-
}
|
|
46209
46247
|
function planDroidSession(run3, context) {
|
|
46210
46248
|
const baseEnv = { ...context.cliEnv, ...context.providerEnv };
|
|
46211
46249
|
const mcp = planExternalMcpDelivery(
|
|
@@ -46232,8 +46270,7 @@ function planDroidSession(run3, context) {
|
|
|
46232
46270
|
env,
|
|
46233
46271
|
...shape,
|
|
46234
46272
|
mcp: { ...shape.mcp, ...authorization === void 0 ? {} : { authorization } },
|
|
46235
|
-
...prompts
|
|
46236
|
-
...prompts.systemPromptAppend ? { systemPromptAppend: prompts.systemPromptAppend } : {},
|
|
46273
|
+
...systemPromptFields(prompts),
|
|
46237
46274
|
...context.resumeSessionId ? { resumeSessionId: context.resumeSessionId } : {}
|
|
46238
46275
|
};
|
|
46239
46276
|
const key = JSON.stringify({
|
|
@@ -46241,33 +46278,18 @@ function planDroidSession(run3, context) {
|
|
|
46241
46278
|
cwd: context.cwd,
|
|
46242
46279
|
shape,
|
|
46243
46280
|
mcpCredential: credentialDigest(authorization),
|
|
46244
|
-
env:
|
|
46281
|
+
env: envDigest(env)
|
|
46245
46282
|
});
|
|
46246
46283
|
return { spec, key, skippedMcpEnvKeys: mcp.skippedEnvKeys };
|
|
46247
46284
|
}
|
|
46248
46285
|
async function droidTurnInput(run3, context) {
|
|
46249
|
-
const images =
|
|
46250
|
-
const
|
|
46251
|
-
const text3 = buildTurnText({
|
|
46252
|
-
spec: run3,
|
|
46253
|
-
files,
|
|
46254
|
-
skills: context.skills,
|
|
46255
|
-
...context.contextPrefix === void 0 ? {} : { contextPrefix: context.contextPrefix }
|
|
46256
|
-
});
|
|
46257
|
-
const encoded = await Promise.all(
|
|
46258
|
-
images.map(async (image) => ({
|
|
46259
|
-
mimeType: image.mimeType,
|
|
46260
|
-
data: (await (0, import_promises26.readFile)(image.path)).toString("base64")
|
|
46261
|
-
}))
|
|
46262
|
-
);
|
|
46286
|
+
const { text: text3, images } = buildAttachmentTurnText(run3, context);
|
|
46287
|
+
const encoded = await readInlineImages(images);
|
|
46263
46288
|
return { turnId: run3.runId, text: text3, ...encoded.length ? { images: encoded } : {} };
|
|
46264
46289
|
}
|
|
46265
|
-
var import_node_crypto24, import_promises26;
|
|
46266
46290
|
var init_run6 = __esm({
|
|
46267
46291
|
"../agent-core/src/providers/droid/run.ts"() {
|
|
46268
46292
|
"use strict";
|
|
46269
|
-
import_node_crypto24 = require("node:crypto");
|
|
46270
|
-
import_promises26 = require("node:fs/promises");
|
|
46271
46293
|
init_agent2();
|
|
46272
46294
|
init_mcp2();
|
|
46273
46295
|
init_prompt();
|
|
@@ -46346,18 +46368,18 @@ var init_alan_code2 = __esm({
|
|
|
46346
46368
|
// src/capabilities/providers/managed.ts
|
|
46347
46369
|
async function readManagedProviderVersion(file2, backendKind) {
|
|
46348
46370
|
try {
|
|
46349
|
-
const selected = selectedSchema.parse(JSON.parse(await (0,
|
|
46371
|
+
const selected = selectedSchema.parse(JSON.parse(await (0, import_promises25.readFile)(file2, "utf8")));
|
|
46350
46372
|
const version2 = selected[backendKind];
|
|
46351
46373
|
return version2 !== void 0 && VERSION.test(version2) ? version2 : null;
|
|
46352
46374
|
} catch {
|
|
46353
46375
|
return null;
|
|
46354
46376
|
}
|
|
46355
46377
|
}
|
|
46356
|
-
var
|
|
46378
|
+
var import_promises25, VERSION, selectedSchema;
|
|
46357
46379
|
var init_managed2 = __esm({
|
|
46358
46380
|
"src/capabilities/providers/managed.ts"() {
|
|
46359
46381
|
"use strict";
|
|
46360
|
-
|
|
46382
|
+
import_promises25 = require("node:fs/promises");
|
|
46361
46383
|
init_process();
|
|
46362
46384
|
init_zod();
|
|
46363
46385
|
VERSION = /^[0-9]+\.[0-9]+\.[0-9]+(?:[-+][0-9A-Za-z.-]+)?$/;
|
|
@@ -53741,11 +53763,11 @@ async function inspectSkillPackage(packageRoot, options = {}) {
|
|
|
53741
53763
|
};
|
|
53742
53764
|
}
|
|
53743
53765
|
async function requirePackageRoot(packageRoot) {
|
|
53744
|
-
const root = await (0,
|
|
53766
|
+
const root = await (0, import_promises26.realpath)((0, import_node_path30.resolve)(packageRoot)).catch(() => null);
|
|
53745
53767
|
if (!root) {
|
|
53746
53768
|
throw new SkillPackageError("INVALID_PACKAGE_ROOT", "Skill package directory does not exist");
|
|
53747
53769
|
}
|
|
53748
|
-
const rootStat = await (0,
|
|
53770
|
+
const rootStat = await (0, import_promises26.lstat)(root);
|
|
53749
53771
|
if (!rootStat.isDirectory()) {
|
|
53750
53772
|
throw new SkillPackageError("INVALID_PACKAGE_ROOT", "Skill package root must be a directory");
|
|
53751
53773
|
}
|
|
@@ -53771,12 +53793,12 @@ async function walkPackage(root, ignoredPaths) {
|
|
|
53771
53793
|
}
|
|
53772
53794
|
return files;
|
|
53773
53795
|
async function walkDirectory(directory) {
|
|
53774
|
-
const entries2 = await (0,
|
|
53796
|
+
const entries2 = await (0, import_promises26.readdir)(directory, { withFileTypes: true });
|
|
53775
53797
|
for (const entry2 of entries2) {
|
|
53776
53798
|
const absolutePath = (0, import_node_path30.resolve)(directory, entry2.name);
|
|
53777
53799
|
const normalizedPath = normalizeRelativePath(root, absolutePath);
|
|
53778
53800
|
if (isIgnored(normalizedPath, entry2.name, entry2.isDirectory(), ignored3)) continue;
|
|
53779
|
-
const entryStat = await (0,
|
|
53801
|
+
const entryStat = await (0, import_promises26.lstat)(absolutePath);
|
|
53780
53802
|
if (entryStat.isSymbolicLink()) {
|
|
53781
53803
|
throw new SkillPackageError(
|
|
53782
53804
|
"SYMLINK_BLOCKED",
|
|
@@ -53902,7 +53924,7 @@ function isSecretPath(path19) {
|
|
|
53902
53924
|
return name.endsWith(".private-key.pem") || name.endsWith(".private-key.key");
|
|
53903
53925
|
}
|
|
53904
53926
|
async function readPackageFile(file2) {
|
|
53905
|
-
const bytes2 = await (0,
|
|
53927
|
+
const bytes2 = await (0, import_promises26.readFile)(file2.absolutePath);
|
|
53906
53928
|
return {
|
|
53907
53929
|
bytes: bytes2,
|
|
53908
53930
|
manifest: {
|
|
@@ -54058,7 +54080,7 @@ function comparePackageFiles(left, right) {
|
|
|
54058
54080
|
);
|
|
54059
54081
|
}
|
|
54060
54082
|
function hashPackageTree(files) {
|
|
54061
|
-
const hash2 = (0,
|
|
54083
|
+
const hash2 = (0, import_node_crypto19.createHash)("sha256");
|
|
54062
54084
|
hash2.update(TREE_HASH_PREFIX);
|
|
54063
54085
|
for (const file2 of files) {
|
|
54064
54086
|
const path19 = import_node_buffer.Buffer.from(file2.path, "utf8");
|
|
@@ -54071,7 +54093,7 @@ function hashPackageTree(files) {
|
|
|
54071
54093
|
return `sha256:${hash2.digest("hex")}`;
|
|
54072
54094
|
}
|
|
54073
54095
|
function sha256(bytes2) {
|
|
54074
|
-
return `sha256:${(0,
|
|
54096
|
+
return `sha256:${(0, import_node_crypto19.createHash)("sha256").update(bytes2).digest("hex")}`;
|
|
54075
54097
|
}
|
|
54076
54098
|
function uint322(value2) {
|
|
54077
54099
|
const buffer = import_node_buffer.Buffer.allocUnsafe(4);
|
|
@@ -54083,13 +54105,13 @@ function uint642(value2) {
|
|
|
54083
54105
|
buffer.writeBigUInt64BE(BigInt(value2));
|
|
54084
54106
|
return buffer;
|
|
54085
54107
|
}
|
|
54086
|
-
var import_node_buffer,
|
|
54108
|
+
var import_node_buffer, import_node_crypto19, import_promises26, import_node_path30, import_yaml, TREE_HASH_PREFIX, ALWAYS_IGNORED_DIRECTORIES, ALWAYS_IGNORED_FILES, MARKDOWN_EXTENSIONS, IMAGE_EXTENSIONS2, CODE_EXTENSIONS, TEXT_EXTENSIONS, SECRET_BASENAMES, MARKDOWN_LINK_TARGET;
|
|
54087
54109
|
var init_skill_package = __esm({
|
|
54088
54110
|
"../shared/src/node/skill-package.ts"() {
|
|
54089
54111
|
"use strict";
|
|
54090
54112
|
import_node_buffer = require("node:buffer");
|
|
54091
|
-
|
|
54092
|
-
|
|
54113
|
+
import_node_crypto19 = require("node:crypto");
|
|
54114
|
+
import_promises26 = require("node:fs/promises");
|
|
54093
54115
|
import_node_path30 = require("node:path");
|
|
54094
54116
|
import_yaml = __toESM(require_dist(), 1);
|
|
54095
54117
|
init_contracts();
|
|
@@ -54159,7 +54181,7 @@ var init_skill_package = __esm({
|
|
|
54159
54181
|
|
|
54160
54182
|
// ../shared/src/node/alan-skill-identity.ts
|
|
54161
54183
|
function uuidV5(name, namespace) {
|
|
54162
|
-
const bytes2 = (0,
|
|
54184
|
+
const bytes2 = (0, import_node_crypto20.createHash)("sha1").update(Buffer.from(namespace.replaceAll("-", ""), "hex")).update(name, "utf8").digest().subarray(0, 16);
|
|
54163
54185
|
bytes2[6] = bytes2[6] & 15 | 80;
|
|
54164
54186
|
bytes2[8] = bytes2[8] & 63 | 128;
|
|
54165
54187
|
const hex3 = bytes2.toString("hex");
|
|
@@ -54171,11 +54193,11 @@ function alanSkillId(slug) {
|
|
|
54171
54193
|
function alanSkillVersionId(slug, contentHash) {
|
|
54172
54194
|
return uuidV5(`alan:${slug}:${contentHash}`, ALAN_SKILL_NAMESPACE);
|
|
54173
54195
|
}
|
|
54174
|
-
var
|
|
54196
|
+
var import_node_crypto20, ALAN_SKILL_NAMESPACE;
|
|
54175
54197
|
var init_alan_skill_identity = __esm({
|
|
54176
54198
|
"../shared/src/node/alan-skill-identity.ts"() {
|
|
54177
54199
|
"use strict";
|
|
54178
|
-
|
|
54200
|
+
import_node_crypto20 = require("node:crypto");
|
|
54179
54201
|
ALAN_SKILL_NAMESPACE = "ec71d99b-d207-4ca2-a9eb-3a7bed4a73fd";
|
|
54180
54202
|
}
|
|
54181
54203
|
});
|
|
@@ -54209,7 +54231,7 @@ async function readLocalSkills(layout) {
|
|
|
54209
54231
|
async function isLocalSkillCurrent(entry2, contentHash, ignoredPaths) {
|
|
54210
54232
|
if (entry2.contentHash !== contentHash) return false;
|
|
54211
54233
|
try {
|
|
54212
|
-
if (await (0,
|
|
54234
|
+
if (await (0, import_promises27.realpath)(entry2.path) !== entry2.path) return false;
|
|
54213
54235
|
const inspected = await inspectSkillPackage(entry2.path, { expectedName: null, ignoredPaths });
|
|
54214
54236
|
return inspected.contentHash === contentHash;
|
|
54215
54237
|
} catch {
|
|
@@ -54224,7 +54246,7 @@ async function resolveLocalSkill(local, invocation) {
|
|
|
54224
54246
|
}
|
|
54225
54247
|
async function hasSkillFile(directory) {
|
|
54226
54248
|
try {
|
|
54227
|
-
return (await (0,
|
|
54249
|
+
return (await (0, import_promises27.stat)((0, import_node_path31.join)(directory, "SKILL.md"))).isFile();
|
|
54228
54250
|
} catch {
|
|
54229
54251
|
return false;
|
|
54230
54252
|
}
|
|
@@ -54279,7 +54301,7 @@ async function resolveSkillInvocations(layout, invocations, baked = "any") {
|
|
|
54279
54301
|
return missing2.length === 0 ? { kind: "resolved", skills: resolved } : { kind: "missing", names: missing2 };
|
|
54280
54302
|
}
|
|
54281
54303
|
async function folderCandidates(folder) {
|
|
54282
|
-
const entries2 = await (0,
|
|
54304
|
+
const entries2 = await (0, import_promises27.readdir)(folder, { withFileTypes: true }).catch(() => []);
|
|
54283
54305
|
return entries2.filter((entry2) => entry2.isDirectory() || entry2.isSymbolicLink()).map((entry2) => ({ directory: (0, import_node_path31.join)(folder, entry2.name) }));
|
|
54284
54306
|
}
|
|
54285
54307
|
async function nativeCandidates(layout) {
|
|
@@ -54324,11 +54346,11 @@ async function inspectIndexedSkill(directory, contentHash) {
|
|
|
54324
54346
|
return null;
|
|
54325
54347
|
}
|
|
54326
54348
|
}
|
|
54327
|
-
var
|
|
54349
|
+
var import_promises27, import_node_path31, installedFileSchema, localSkillsFileSchema, INDEX_CONCURRENCY;
|
|
54328
54350
|
var init_store = __esm({
|
|
54329
54351
|
"src/capabilities/skills/store.ts"() {
|
|
54330
54352
|
"use strict";
|
|
54331
|
-
|
|
54353
|
+
import_promises27 = require("node:fs/promises");
|
|
54332
54354
|
import_node_path31 = require("node:path");
|
|
54333
54355
|
init_alan_skill_identity();
|
|
54334
54356
|
init_skill_package();
|
|
@@ -54422,7 +54444,7 @@ var init_paths2 = __esm({
|
|
|
54422
54444
|
// src/capabilities/workspace/approved-paths.ts
|
|
54423
54445
|
async function realpathOrNull(path19) {
|
|
54424
54446
|
try {
|
|
54425
|
-
return await (0,
|
|
54447
|
+
return await (0, import_promises28.realpath)(path19);
|
|
54426
54448
|
} catch (error62) {
|
|
54427
54449
|
const code = errnoCode(error62);
|
|
54428
54450
|
if (code === "ENOENT" || code === "ENOTDIR" || code === "EACCES" || code === "EPERM") {
|
|
@@ -54479,11 +54501,11 @@ async function openApprovedPaths(options) {
|
|
|
54479
54501
|
roots
|
|
54480
54502
|
};
|
|
54481
54503
|
}
|
|
54482
|
-
var
|
|
54504
|
+
var import_promises28, MAX_RUN_PATHS, storeSchema;
|
|
54483
54505
|
var init_approved_paths = __esm({
|
|
54484
54506
|
"src/capabilities/workspace/approved-paths.ts"() {
|
|
54485
54507
|
"use strict";
|
|
54486
|
-
|
|
54508
|
+
import_promises28 = require("node:fs/promises");
|
|
54487
54509
|
init_zod();
|
|
54488
54510
|
init_kernel();
|
|
54489
54511
|
init_paths2();
|
|
@@ -54497,12 +54519,12 @@ var init_approved_paths = __esm({
|
|
|
54497
54519
|
|
|
54498
54520
|
// src/capabilities/workspace/locks.ts
|
|
54499
54521
|
function repositoryLockKey(commonDir, platform) {
|
|
54500
|
-
return (0,
|
|
54522
|
+
return (0, import_node_crypto21.createHash)("sha256").update(comparablePath(commonDir, platform)).digest("hex").slice(0, 32);
|
|
54501
54523
|
}
|
|
54502
54524
|
async function readOwner(path19) {
|
|
54503
54525
|
let text3;
|
|
54504
54526
|
try {
|
|
54505
|
-
text3 = await (0,
|
|
54527
|
+
text3 = await (0, import_promises29.readFile)(path19, "utf8");
|
|
54506
54528
|
} catch (error62) {
|
|
54507
54529
|
if (errnoCode(error62) === "ENOENT") return { kind: "missing" };
|
|
54508
54530
|
return { kind: "unreadable" };
|
|
@@ -54523,7 +54545,7 @@ async function removeIfSame(path19, expected) {
|
|
|
54523
54545
|
if (current.kind !== "owner" || current.owner.since !== expected.since) return;
|
|
54524
54546
|
if (current.owner.pid !== expected.pid || current.owner.holder !== expected.holder) return;
|
|
54525
54547
|
}
|
|
54526
|
-
await (0,
|
|
54548
|
+
await (0, import_promises29.unlink)(path19).catch((error62) => {
|
|
54527
54549
|
if (errnoCode(error62) !== "ENOENT") throw error62;
|
|
54528
54550
|
});
|
|
54529
54551
|
}
|
|
@@ -54548,7 +54570,7 @@ function openRepositoryLocks(options) {
|
|
|
54548
54570
|
await removeIfSame(path19, read4.owner);
|
|
54549
54571
|
return null;
|
|
54550
54572
|
}
|
|
54551
|
-
const age = await (0,
|
|
54573
|
+
const age = await (0, import_promises29.stat)(path19).then(
|
|
54552
54574
|
(info) => clock.now() - info.mtimeMs,
|
|
54553
54575
|
() => 0
|
|
54554
54576
|
);
|
|
@@ -54563,12 +54585,12 @@ function openRepositoryLocks(options) {
|
|
|
54563
54585
|
const folder = async (commonDir) => {
|
|
54564
54586
|
const key = repositoryLockKey(commonDir, platform);
|
|
54565
54587
|
const dir = (0, import_node_path34.join)(options.dir, key);
|
|
54566
|
-
await (0,
|
|
54588
|
+
await (0, import_promises29.mkdir)(dir, { recursive: true, mode: 448 });
|
|
54567
54589
|
return { key, dir };
|
|
54568
54590
|
};
|
|
54569
54591
|
const createExclusive = async (path19, owner) => {
|
|
54570
54592
|
try {
|
|
54571
|
-
const handle = await (0,
|
|
54593
|
+
const handle = await (0, import_promises29.open)(path19, "wx", 384);
|
|
54572
54594
|
try {
|
|
54573
54595
|
await handle.writeFile(JSON.stringify(owner));
|
|
54574
54596
|
} finally {
|
|
@@ -54581,7 +54603,7 @@ function openRepositoryLocks(options) {
|
|
|
54581
54603
|
}
|
|
54582
54604
|
};
|
|
54583
54605
|
const liveRun = async (dir) => {
|
|
54584
|
-
const entries2 = await (0,
|
|
54606
|
+
const entries2 = await (0, import_promises29.readdir)(dir);
|
|
54585
54607
|
for (const entry2 of entries2) {
|
|
54586
54608
|
if (!entry2.startsWith(RUN_FILE_PREFIX)) continue;
|
|
54587
54609
|
const holder = await heldBy((0, import_node_path34.join)(dir, entry2));
|
|
@@ -54610,7 +54632,7 @@ function openRepositoryLocks(options) {
|
|
|
54610
54632
|
},
|
|
54611
54633
|
tryShared: async (commonDir, runId) => {
|
|
54612
54634
|
const { key, dir } = await folder(commonDir);
|
|
54613
|
-
const file2 = `${RUN_FILE_PREFIX}${(0,
|
|
54635
|
+
const file2 = `${RUN_FILE_PREFIX}${(0, import_node_crypto21.createHash)("sha256").update(runId).digest("hex").slice(0, 32)}.json`;
|
|
54614
54636
|
const path19 = (0, import_node_path34.join)(dir, file2);
|
|
54615
54637
|
const owner = await self(runId);
|
|
54616
54638
|
await writeJsonFileAtomic(path19, owner);
|
|
@@ -54623,12 +54645,12 @@ function openRepositoryLocks(options) {
|
|
|
54623
54645
|
}
|
|
54624
54646
|
};
|
|
54625
54647
|
}
|
|
54626
|
-
var
|
|
54648
|
+
var import_node_crypto21, import_promises29, import_node_path34, LOCK_FORMAT, EXCLUSIVE_FILE, RUN_FILE_PREFIX, UNREADABLE_GRACE_MS, ownerSchema;
|
|
54627
54649
|
var init_locks = __esm({
|
|
54628
54650
|
"src/capabilities/workspace/locks.ts"() {
|
|
54629
54651
|
"use strict";
|
|
54630
|
-
|
|
54631
|
-
|
|
54652
|
+
import_node_crypto21 = require("node:crypto");
|
|
54653
|
+
import_promises29 = require("node:fs/promises");
|
|
54632
54654
|
import_node_path34 = require("node:path");
|
|
54633
54655
|
init_zod();
|
|
54634
54656
|
init_kernel();
|
|
@@ -63474,7 +63496,7 @@ var init_session6 = __esm({
|
|
|
63474
63496
|
const fence = this.#fence;
|
|
63475
63497
|
this.#fence = fence.then(() => outcome2).then(ignore, ignore);
|
|
63476
63498
|
const index = job.index;
|
|
63477
|
-
const
|
|
63499
|
+
const deliver2 = (fenced) => (fenced ? fence.then(() => outcome2) : outcome2).then((value2) => {
|
|
63478
63500
|
this.#delivered(index, fenced);
|
|
63479
63501
|
if (this.#poisoned(index))
|
|
63480
63502
|
throw new SessionFailed(this.#failure.error);
|
|
@@ -63483,7 +63505,7 @@ var init_session6 = __esm({
|
|
|
63483
63505
|
this.#delivered(index, fenced);
|
|
63484
63506
|
throw this.#poisoned(index) ? new SessionFailed(this.#failure.error) : error62;
|
|
63485
63507
|
});
|
|
63486
|
-
return exempt ? ran.then((result) =>
|
|
63508
|
+
return exempt ? ran.then((result) => deliver2(job.hit || result.after !== void 0), () => deliver2(job.hit)) : deliver2(true);
|
|
63487
63509
|
}
|
|
63488
63510
|
/** Whether job `index` comes after the failure's boundary without an outcome of its own: it gets `SessionFailed`. */
|
|
63489
63511
|
#poisoned(index) {
|
|
@@ -73821,7 +73843,7 @@ function relativeTitle(cwd, target) {
|
|
|
73821
73843
|
}
|
|
73822
73844
|
async function canonicalPath(target) {
|
|
73823
73845
|
try {
|
|
73824
|
-
return await (0,
|
|
73846
|
+
return await (0, import_promises30.realpath)(target);
|
|
73825
73847
|
} catch {
|
|
73826
73848
|
const parent = import_node_path35.default.dirname(target);
|
|
73827
73849
|
if (parent === target) return target;
|
|
@@ -73845,11 +73867,11 @@ async function withFileLock(target, run3) {
|
|
|
73845
73867
|
if (queues.get(key) === tail2) queues.delete(key);
|
|
73846
73868
|
}
|
|
73847
73869
|
}
|
|
73848
|
-
var
|
|
73870
|
+
var import_promises30, import_node_os4, import_node_path35, ToolFailure, queues;
|
|
73849
73871
|
var init_shared2 = __esm({
|
|
73850
73872
|
"../alan-engine/src/tools/shared.ts"() {
|
|
73851
73873
|
"use strict";
|
|
73852
|
-
|
|
73874
|
+
import_promises30 = require("node:fs/promises");
|
|
73853
73875
|
import_node_os4 = require("node:os");
|
|
73854
73876
|
import_node_path35 = __toESM(require("node:path"), 1);
|
|
73855
73877
|
ToolFailure = class extends Error {
|
|
@@ -74437,7 +74459,7 @@ function replacementsOf(args) {
|
|
|
74437
74459
|
}
|
|
74438
74460
|
async function editDiff(cwd, tool, args) {
|
|
74439
74461
|
const filepath = resolveIn(cwd, text2(args, "filePath"));
|
|
74440
|
-
const before = await (0,
|
|
74462
|
+
const before = await (0, import_promises31.readFile)(filepath, "utf8").catch(() => "");
|
|
74441
74463
|
try {
|
|
74442
74464
|
if (tool === "write") return unifiedDiff(filepath, before, text2(args, "content"));
|
|
74443
74465
|
const edits = replacementsOf(args);
|
|
@@ -74497,11 +74519,11 @@ function createApprovalsExtension(options) {
|
|
|
74497
74519
|
]
|
|
74498
74520
|
});
|
|
74499
74521
|
}
|
|
74500
|
-
var
|
|
74522
|
+
var import_promises31, import_node_path36, APPROVALS_EXTENSION_NAME, EDIT_TOOLS2, COMMAND_TOOLS, EDIT_GRANT, MAX_INPUT_TEXT, DENY_WRITES_MESSAGE;
|
|
74501
74523
|
var init_approvals = __esm({
|
|
74502
74524
|
"../alan-engine/src/engine/approvals.ts"() {
|
|
74503
74525
|
"use strict";
|
|
74504
|
-
|
|
74526
|
+
import_promises31 = require("node:fs/promises");
|
|
74505
74527
|
import_node_path36 = __toESM(require("node:path"), 1);
|
|
74506
74528
|
init_dist3();
|
|
74507
74529
|
init_dist4();
|
|
@@ -74685,6 +74707,7 @@ var init_events = __esm({
|
|
|
74685
74707
|
"../alan-engine/src/engine/events.ts"() {
|
|
74686
74708
|
"use strict";
|
|
74687
74709
|
init_dist3();
|
|
74710
|
+
init_dist4();
|
|
74688
74711
|
init_messages2();
|
|
74689
74712
|
EMPTY_USAGE = {
|
|
74690
74713
|
input: 0,
|
|
@@ -74743,12 +74766,12 @@ var init_events = __esm({
|
|
|
74743
74766
|
this.#runText = "";
|
|
74744
74767
|
events.push({ type: "run_start", inputs });
|
|
74745
74768
|
}
|
|
74746
|
-
|
|
74747
|
-
if (!this.#inputs.includes(submissionId)) events.push({ type: "input_placed", submissionId });
|
|
74748
|
-
}
|
|
74769
|
+
const unplaced = inputs.filter((submissionId) => !this.#inputs.includes(submissionId));
|
|
74749
74770
|
for (const entry2 of view2.entries) {
|
|
74750
74771
|
if (Number(entry2.id) <= this.#lastEntry) continue;
|
|
74751
74772
|
this.#lastEntry = Number(entry2.id);
|
|
74773
|
+
const placed = UserEntry.is(entry2) ? unplaced.shift() : void 0;
|
|
74774
|
+
if (placed !== void 0) events.push({ type: "input_placed", submissionId: placed });
|
|
74752
74775
|
for (const message of entry2.model ?? []) {
|
|
74753
74776
|
if (message.role === "assistant") {
|
|
74754
74777
|
events.push(...this.#blocksUpTo(message.content));
|
|
@@ -74778,6 +74801,7 @@ var init_events = __esm({
|
|
|
74778
74801
|
}
|
|
74779
74802
|
}
|
|
74780
74803
|
}
|
|
74804
|
+
for (const submissionId of unplaced) events.push({ type: "input_placed", submissionId });
|
|
74781
74805
|
if (live?.generation?.attempt !== this.#attempt) this.#sent.clear();
|
|
74782
74806
|
this.#attempt = live?.generation?.attempt;
|
|
74783
74807
|
const partial2 = live?.generation?.message;
|
|
@@ -74818,7 +74842,7 @@ function processAlive(pid) {
|
|
|
74818
74842
|
}
|
|
74819
74843
|
async function lockOwner(path19) {
|
|
74820
74844
|
try {
|
|
74821
|
-
const pid = Number.parseInt((await (0,
|
|
74845
|
+
const pid = Number.parseInt((await (0, import_promises32.readFile)(path19, "utf8")).trim(), 10);
|
|
74822
74846
|
return Number.isInteger(pid) && pid > 0 ? pid : void 0;
|
|
74823
74847
|
} catch {
|
|
74824
74848
|
return void 0;
|
|
@@ -74828,13 +74852,13 @@ function isExists(error62) {
|
|
|
74828
74852
|
return error62.code === "EEXIST";
|
|
74829
74853
|
}
|
|
74830
74854
|
async function createLock(path19) {
|
|
74831
|
-
const staged = `${path19}.${process.pid}.${(0,
|
|
74832
|
-
await (0,
|
|
74855
|
+
const staged = `${path19}.${process.pid}.${(0, import_node_crypto22.randomUUID)().slice(0, 8)}`;
|
|
74856
|
+
await (0, import_promises32.writeFile)(staged, `${process.pid}
|
|
74833
74857
|
`, "utf8");
|
|
74834
74858
|
try {
|
|
74835
|
-
await (0,
|
|
74859
|
+
await (0, import_promises32.link)(staged, path19);
|
|
74836
74860
|
} finally {
|
|
74837
|
-
await (0,
|
|
74861
|
+
await (0, import_promises32.rm)(staged, { force: true });
|
|
74838
74862
|
}
|
|
74839
74863
|
}
|
|
74840
74864
|
async function acquireSessionLock(path19) {
|
|
@@ -74847,7 +74871,7 @@ async function acquireSessionLock(path19) {
|
|
|
74847
74871
|
release: async () => {
|
|
74848
74872
|
if (released) return;
|
|
74849
74873
|
released = true;
|
|
74850
|
-
await (0,
|
|
74874
|
+
await (0, import_promises32.rm)(path19, { force: true });
|
|
74851
74875
|
}
|
|
74852
74876
|
};
|
|
74853
74877
|
} catch (error62) {
|
|
@@ -74855,17 +74879,17 @@ async function acquireSessionLock(path19) {
|
|
|
74855
74879
|
const owner = await lockOwner(path19);
|
|
74856
74880
|
if (owner !== void 0 && processAlive(owner)) throw new SessionLockedError(path19, owner);
|
|
74857
74881
|
if (attempt > 0) throw new SessionLockedError(path19, owner);
|
|
74858
|
-
await (0,
|
|
74882
|
+
await (0, import_promises32.rm)(path19, { force: true });
|
|
74859
74883
|
}
|
|
74860
74884
|
}
|
|
74861
74885
|
throw new SessionLockedError(path19, void 0);
|
|
74862
74886
|
}
|
|
74863
|
-
var
|
|
74887
|
+
var import_node_crypto22, import_promises32, SessionLockedError;
|
|
74864
74888
|
var init_lock = __esm({
|
|
74865
74889
|
"../alan-engine/src/engine/lock.ts"() {
|
|
74866
74890
|
"use strict";
|
|
74867
|
-
|
|
74868
|
-
|
|
74891
|
+
import_node_crypto22 = require("node:crypto");
|
|
74892
|
+
import_promises32 = require("node:fs/promises");
|
|
74869
74893
|
SessionLockedError = class extends Error {
|
|
74870
74894
|
lockPath;
|
|
74871
74895
|
ownerPid;
|
|
@@ -74883,7 +74907,7 @@ var init_lock = __esm({
|
|
|
74883
74907
|
|
|
74884
74908
|
// ../alan-engine/src/engine/rules.ts
|
|
74885
74909
|
async function exists(target) {
|
|
74886
|
-
return (0,
|
|
74910
|
+
return (0, import_promises33.stat)(target).then(
|
|
74887
74911
|
() => true,
|
|
74888
74912
|
() => false
|
|
74889
74913
|
);
|
|
@@ -74900,7 +74924,7 @@ async function findGitRoot(cwd) {
|
|
|
74900
74924
|
async function ruleFileIn(dir) {
|
|
74901
74925
|
for (const name of RULE_FILE_NAMES) {
|
|
74902
74926
|
const file2 = import_node_path37.default.join(dir, name);
|
|
74903
|
-
const text3 = await (0,
|
|
74927
|
+
const text3 = await (0, import_promises33.readFile)(file2, "utf8").catch(() => void 0);
|
|
74904
74928
|
if (text3 === void 0 || text3.trim() === "") continue;
|
|
74905
74929
|
const truncatedChars = Math.max(0, text3.length - MAX_RULE_FILE_CHARS);
|
|
74906
74930
|
return { path: file2, content: text3.slice(0, MAX_RULE_FILE_CHARS), truncatedChars };
|
|
@@ -74938,11 +74962,11 @@ ${file2.content.trimEnd()}${note}`;
|
|
|
74938
74962
|
async function projectInstructions(cwd) {
|
|
74939
74963
|
return renderProjectRules(await loadProjectRules(cwd));
|
|
74940
74964
|
}
|
|
74941
|
-
var
|
|
74965
|
+
var import_promises33, import_node_path37, RULE_FILE_NAMES, MAX_RULE_FILE_CHARS;
|
|
74942
74966
|
var init_rules2 = __esm({
|
|
74943
74967
|
"../alan-engine/src/engine/rules.ts"() {
|
|
74944
74968
|
"use strict";
|
|
74945
|
-
|
|
74969
|
+
import_promises33 = require("node:fs/promises");
|
|
74946
74970
|
import_node_path37 = __toESM(require("node:path"), 1);
|
|
74947
74971
|
RULE_FILE_NAMES = ["AGENTS.md", "CLAUDE.md"];
|
|
74948
74972
|
MAX_RULE_FILE_CHARS = 16e3;
|
|
@@ -75207,7 +75231,7 @@ async function anyUnreliable(paths) {
|
|
|
75207
75231
|
return false;
|
|
75208
75232
|
for (const path19 of paths) {
|
|
75209
75233
|
for (const candidate of [path19, ...ancestorsOf(path19)]) {
|
|
75210
|
-
const info = await (0,
|
|
75234
|
+
const info = await (0, import_promises34.statfs)(candidate).catch(() => void 0);
|
|
75211
75235
|
if (info === void 0)
|
|
75212
75236
|
continue;
|
|
75213
75237
|
if (UNRELIABLE_FILE_SYSTEMS.has(info.type))
|
|
@@ -75217,13 +75241,13 @@ async function anyUnreliable(paths) {
|
|
|
75217
75241
|
}
|
|
75218
75242
|
return false;
|
|
75219
75243
|
}
|
|
75220
|
-
var
|
|
75244
|
+
var import_node_crypto23, import_node_fs20, import_promises34, import_node_path38, DEBOUNCE_MS, FSEVENTS_SETTLE_MS, DEFAULT_POLL_MS, DEFAULT_MAX_DIRECTORIES, OVERFLOW, HASH_MAX_BYTES, HASH_RECENT_MS, UNRELIABLE_FILE_SYSTEMS, BudgetExceeded, NodeFileWatcher;
|
|
75221
75245
|
var init_node_watch = __esm({
|
|
75222
75246
|
"../../node_modules/@earendil-works/pi-durable/dist/env/node-watch.js"() {
|
|
75223
75247
|
"use strict";
|
|
75224
|
-
|
|
75248
|
+
import_node_crypto23 = require("node:crypto");
|
|
75225
75249
|
import_node_fs20 = require("node:fs");
|
|
75226
|
-
|
|
75250
|
+
import_promises34 = require("node:fs/promises");
|
|
75227
75251
|
import_node_path38 = require("node:path");
|
|
75228
75252
|
init_env();
|
|
75229
75253
|
DEBOUNCE_MS = 50;
|
|
@@ -75436,7 +75460,7 @@ var init_node_watch = __esm({
|
|
|
75436
75460
|
const record3 = async (path19, stats) => {
|
|
75437
75461
|
let hash2;
|
|
75438
75462
|
if (this.#mode === "polling" && stats.isFile() && stats.size <= HASH_MAX_BYTES && Date.now() - stats.mtimeMs < HASH_RECENT_MS) {
|
|
75439
|
-
hash2 = await (0,
|
|
75463
|
+
hash2 = await (0, import_promises34.readFile)(path19).then((content2) => (0, import_node_crypto23.createHash)("sha256").update(content2).digest("hex"), () => void 0);
|
|
75440
75464
|
}
|
|
75441
75465
|
snapshot.set(path19, entryOf(stats, hash2));
|
|
75442
75466
|
};
|
|
@@ -75447,7 +75471,7 @@ var init_node_watch = __esm({
|
|
|
75447
75471
|
traversed.add(key);
|
|
75448
75472
|
let names2;
|
|
75449
75473
|
try {
|
|
75450
|
-
names2 = await (0,
|
|
75474
|
+
names2 = await (0, import_promises34.readdir)(directory);
|
|
75451
75475
|
} catch (error62) {
|
|
75452
75476
|
if (directory === target.path && isDenied(error62))
|
|
75453
75477
|
throw error62;
|
|
@@ -75461,7 +75485,7 @@ var init_node_watch = __esm({
|
|
|
75461
75485
|
const path19 = `${directory.endsWith(import_node_path38.sep) ? directory : directory + import_node_path38.sep}${name}`;
|
|
75462
75486
|
let kind = listed.get(path19);
|
|
75463
75487
|
if (kind === void 0) {
|
|
75464
|
-
const stats = await (0,
|
|
75488
|
+
const stats = await (0, import_promises34.lstat)(path19).catch(() => void 0);
|
|
75465
75489
|
if (stats === void 0)
|
|
75466
75490
|
continue;
|
|
75467
75491
|
kind = entryOf(stats).kind;
|
|
@@ -75479,20 +75503,20 @@ var init_node_watch = __esm({
|
|
|
75479
75503
|
for (const ancestor of ancestorsOf(target.path)) {
|
|
75480
75504
|
if (snapshot.has(ancestor))
|
|
75481
75505
|
continue;
|
|
75482
|
-
const stats2 = await (0,
|
|
75506
|
+
const stats2 = await (0, import_promises34.lstat)(ancestor).catch(() => void 0);
|
|
75483
75507
|
if (stats2 !== void 0)
|
|
75484
75508
|
snapshot.set(ancestor, { ...entryOf(stats2), size: 0, mtimeMs: 0 });
|
|
75485
75509
|
}
|
|
75486
75510
|
let stats;
|
|
75487
75511
|
try {
|
|
75488
|
-
stats = await (0,
|
|
75512
|
+
stats = await (0, import_promises34.stat)(target.path);
|
|
75489
75513
|
} catch (error62) {
|
|
75490
75514
|
if (isDenied(error62))
|
|
75491
75515
|
throw error62;
|
|
75492
75516
|
continue;
|
|
75493
75517
|
}
|
|
75494
75518
|
await record3(target.path, stats);
|
|
75495
|
-
if (stats.isFile() && (await (0,
|
|
75519
|
+
if (stats.isFile() && (await (0, import_promises34.lstat)(target.path).catch(() => void 0))?.isSymbolicLink()) {
|
|
75496
75520
|
linkedFiles.add(target.path);
|
|
75497
75521
|
}
|
|
75498
75522
|
if (stats.isDirectory()) {
|
|
@@ -75691,7 +75715,7 @@ function abortResult(signal, path19) {
|
|
|
75691
75715
|
}
|
|
75692
75716
|
async function pathExists(path19) {
|
|
75693
75717
|
try {
|
|
75694
|
-
await (0,
|
|
75718
|
+
await (0, import_promises35.access)(path19, import_node_fs21.constants.F_OK);
|
|
75695
75719
|
return true;
|
|
75696
75720
|
} catch {
|
|
75697
75721
|
return false;
|
|
@@ -75911,14 +75935,14 @@ function closedResult(what, path19) {
|
|
|
75911
75935
|
function symlinkRefused(path19, cause) {
|
|
75912
75936
|
return new FileError("invalid", "Refusing to follow a symbolic link", path19, cause);
|
|
75913
75937
|
}
|
|
75914
|
-
var import_node_child_process12,
|
|
75938
|
+
var import_node_child_process12, import_node_crypto24, import_node_fs21, import_promises35, import_node_os5, import_node_path39, import_node_url5, MAX_TIMEOUT_MS, MAX_TIMEOUT_SECONDS, EXIT_STDIO_GRACE_MS, SPILL_HIGH_WATER_MARK, BINARY_READ_CHUNK, NodeTextLineReader, NodeBinaryReader, NodeDirReader, NodeExecutionEnv;
|
|
75915
75939
|
var init_node = __esm({
|
|
75916
75940
|
"../../node_modules/@earendil-works/pi-durable/dist/env/node.js"() {
|
|
75917
75941
|
"use strict";
|
|
75918
75942
|
import_node_child_process12 = require("node:child_process");
|
|
75919
|
-
|
|
75943
|
+
import_node_crypto24 = require("node:crypto");
|
|
75920
75944
|
import_node_fs21 = require("node:fs");
|
|
75921
|
-
|
|
75945
|
+
import_promises35 = require("node:fs/promises");
|
|
75922
75946
|
import_node_os5 = require("node:os");
|
|
75923
75947
|
import_node_path39 = require("node:path");
|
|
75924
75948
|
import_node_url5 = require("node:url");
|
|
@@ -75945,9 +75969,9 @@ var init_node = __esm({
|
|
|
75945
75969
|
this.path = path19;
|
|
75946
75970
|
}
|
|
75947
75971
|
async readLine(context) {
|
|
75948
|
-
const
|
|
75949
|
-
if (
|
|
75950
|
-
return
|
|
75972
|
+
const aborted3 = abortResult(context.abortSignal, this.path);
|
|
75973
|
+
if (aborted3)
|
|
75974
|
+
return aborted3;
|
|
75951
75975
|
if (this.closed)
|
|
75952
75976
|
return err(new FileError("invalid", "Text line reader is closed", this.path));
|
|
75953
75977
|
try {
|
|
@@ -76001,9 +76025,9 @@ var init_node = __esm({
|
|
|
76001
76025
|
this.path = path19;
|
|
76002
76026
|
}
|
|
76003
76027
|
async info(context) {
|
|
76004
|
-
const
|
|
76005
|
-
if (
|
|
76006
|
-
return
|
|
76028
|
+
const aborted3 = abortResult(context.abortSignal, this.path);
|
|
76029
|
+
if (aborted3)
|
|
76030
|
+
return aborted3;
|
|
76007
76031
|
if (this.closed)
|
|
76008
76032
|
return closedResult("Binary reader", this.path);
|
|
76009
76033
|
try {
|
|
@@ -76013,9 +76037,9 @@ var init_node = __esm({
|
|
|
76013
76037
|
}
|
|
76014
76038
|
}
|
|
76015
76039
|
async read(offset, length, context) {
|
|
76016
|
-
const
|
|
76017
|
-
if (
|
|
76018
|
-
return
|
|
76040
|
+
const aborted3 = abortResult(context.abortSignal, this.path);
|
|
76041
|
+
if (aborted3)
|
|
76042
|
+
return aborted3;
|
|
76019
76043
|
if (this.closed)
|
|
76020
76044
|
return closedResult("Binary reader", this.path);
|
|
76021
76045
|
if (!Number.isSafeInteger(offset) || offset < 0 || !Number.isSafeInteger(length) || length < 0) {
|
|
@@ -76049,9 +76073,9 @@ var init_node = __esm({
|
|
|
76049
76073
|
return ok(bytes2);
|
|
76050
76074
|
}
|
|
76051
76075
|
async scanLines(options, context) {
|
|
76052
|
-
const
|
|
76053
|
-
if (
|
|
76054
|
-
return
|
|
76076
|
+
const aborted3 = abortResult(context.abortSignal, this.path);
|
|
76077
|
+
if (aborted3)
|
|
76078
|
+
return aborted3;
|
|
76055
76079
|
if (this.closed)
|
|
76056
76080
|
return closedResult("Binary reader", this.path);
|
|
76057
76081
|
let scanner;
|
|
@@ -76093,9 +76117,9 @@ var init_node = __esm({
|
|
|
76093
76117
|
this.path = path19;
|
|
76094
76118
|
}
|
|
76095
76119
|
async next(maxEntries, context) {
|
|
76096
|
-
const
|
|
76097
|
-
if (
|
|
76098
|
-
return
|
|
76120
|
+
const aborted3 = abortResult(context.abortSignal, this.path);
|
|
76121
|
+
if (aborted3)
|
|
76122
|
+
return aborted3;
|
|
76099
76123
|
if (this.closed)
|
|
76100
76124
|
return closedResult("Directory reader", this.path);
|
|
76101
76125
|
if (!Number.isSafeInteger(maxEntries) || maxEntries <= 0) {
|
|
@@ -76115,7 +76139,7 @@ var init_node = __esm({
|
|
|
76115
76139
|
const entryPath = (0, import_node_path39.resolve)(this.path, entry2.name);
|
|
76116
76140
|
let stats;
|
|
76117
76141
|
try {
|
|
76118
|
-
stats = await (0,
|
|
76142
|
+
stats = await (0, import_promises35.lstat)(entryPath);
|
|
76119
76143
|
} catch (error62) {
|
|
76120
76144
|
if (isNodeError2(error62) && error62.code === "ENOENT")
|
|
76121
76145
|
continue;
|
|
@@ -76152,9 +76176,9 @@ var init_node = __esm({
|
|
|
76152
76176
|
this.watchOptions = options.watch ?? {};
|
|
76153
76177
|
}
|
|
76154
76178
|
async watch(targets, onChange, context) {
|
|
76155
|
-
const
|
|
76156
|
-
if (
|
|
76157
|
-
return
|
|
76179
|
+
const aborted3 = abortResult(context.abortSignal);
|
|
76180
|
+
if (aborted3)
|
|
76181
|
+
return aborted3;
|
|
76158
76182
|
try {
|
|
76159
76183
|
const watcher = await NodeFileWatcher.open(targets, (path19) => resolvePath3(this.cwd, path19), onChange, this.watchOptions);
|
|
76160
76184
|
const afterOpenAbort = abortResult(context.abortSignal);
|
|
@@ -76201,7 +76225,7 @@ var init_node = __esm({
|
|
|
76201
76225
|
args = rest;
|
|
76202
76226
|
}
|
|
76203
76227
|
try {
|
|
76204
|
-
await (0,
|
|
76228
|
+
await (0, import_promises35.access)(cwd, import_node_fs21.constants.F_OK);
|
|
76205
76229
|
} catch (error62) {
|
|
76206
76230
|
const cause = toError3(error62);
|
|
76207
76231
|
return err(new ExecutionError("spawn_error", `Working directory does not exist: ${cwd}
|
|
@@ -76398,11 +76422,11 @@ Cannot execute bash commands.`, cause));
|
|
|
76398
76422
|
}
|
|
76399
76423
|
async openTextLineReader(path19, context) {
|
|
76400
76424
|
const resolved = resolvePath3(this.cwd, path19);
|
|
76401
|
-
const
|
|
76402
|
-
if (
|
|
76403
|
-
return
|
|
76425
|
+
const aborted3 = abortResult(context.abortSignal, resolved);
|
|
76426
|
+
if (aborted3)
|
|
76427
|
+
return aborted3;
|
|
76404
76428
|
try {
|
|
76405
|
-
const file2 = await (0,
|
|
76429
|
+
const file2 = await (0, import_promises35.open)(resolved, "r");
|
|
76406
76430
|
const afterOpenAbort = abortResult(context.abortSignal, resolved);
|
|
76407
76431
|
if (afterOpenAbort) {
|
|
76408
76432
|
await file2.close().catch(() => void 0);
|
|
@@ -76416,11 +76440,11 @@ Cannot execute bash commands.`, cause));
|
|
|
76416
76440
|
async readTextFile(path19, context) {
|
|
76417
76441
|
const resolved = resolvePath3(this.cwd, path19);
|
|
76418
76442
|
const signal = context.abortSignal;
|
|
76419
|
-
const
|
|
76420
|
-
if (
|
|
76421
|
-
return
|
|
76443
|
+
const aborted3 = abortResult(signal, resolved);
|
|
76444
|
+
if (aborted3)
|
|
76445
|
+
return aborted3;
|
|
76422
76446
|
try {
|
|
76423
|
-
return ok(await (0,
|
|
76447
|
+
return ok(await (0, import_promises35.readFile)(resolved, { encoding: "utf8", signal }));
|
|
76424
76448
|
} catch (error62) {
|
|
76425
76449
|
return err(toFileError(error62, resolved));
|
|
76426
76450
|
}
|
|
@@ -76449,33 +76473,33 @@ Cannot execute bash commands.`, cause));
|
|
|
76449
76473
|
async readBinaryFile(path19, context) {
|
|
76450
76474
|
const resolved = resolvePath3(this.cwd, path19);
|
|
76451
76475
|
const signal = context.abortSignal;
|
|
76452
|
-
const
|
|
76453
|
-
if (
|
|
76454
|
-
return
|
|
76476
|
+
const aborted3 = abortResult(signal, resolved);
|
|
76477
|
+
if (aborted3)
|
|
76478
|
+
return aborted3;
|
|
76455
76479
|
try {
|
|
76456
|
-
return ok(await (0,
|
|
76480
|
+
return ok(await (0, import_promises35.readFile)(resolved, { signal }));
|
|
76457
76481
|
} catch (error62) {
|
|
76458
76482
|
return err(toFileError(error62, resolved));
|
|
76459
76483
|
}
|
|
76460
76484
|
}
|
|
76461
76485
|
async openBinaryReader(path19, options, context) {
|
|
76462
76486
|
const resolved = resolvePath3(this.cwd, path19);
|
|
76463
|
-
const
|
|
76464
|
-
if (
|
|
76465
|
-
return
|
|
76487
|
+
const aborted3 = abortResult(context.abortSignal, resolved);
|
|
76488
|
+
if (aborted3)
|
|
76489
|
+
return aborted3;
|
|
76466
76490
|
const noFollow = options?.noFollow === true;
|
|
76467
76491
|
let file2;
|
|
76468
76492
|
try {
|
|
76469
76493
|
let flags = import_node_fs21.constants.O_RDONLY;
|
|
76470
76494
|
if (process.platform === "win32") {
|
|
76471
|
-
if (noFollow && (await (0,
|
|
76495
|
+
if (noFollow && (await (0, import_promises35.lstat)(resolved)).isSymbolicLink())
|
|
76472
76496
|
return err(symlinkRefused(resolved));
|
|
76473
76497
|
} else {
|
|
76474
76498
|
flags |= import_node_fs21.constants.O_NONBLOCK;
|
|
76475
76499
|
if (noFollow)
|
|
76476
76500
|
flags |= import_node_fs21.constants.O_NOFOLLOW;
|
|
76477
76501
|
}
|
|
76478
|
-
file2 = await (0,
|
|
76502
|
+
file2 = await (0, import_promises35.open)(resolved, flags);
|
|
76479
76503
|
const stats = await file2.stat();
|
|
76480
76504
|
if (!stats.isFile()) {
|
|
76481
76505
|
await file2.close().catch(() => void 0);
|
|
@@ -76498,15 +76522,15 @@ Cannot execute bash commands.`, cause));
|
|
|
76498
76522
|
async writeFile(path19, content2, context) {
|
|
76499
76523
|
const resolved = resolvePath3(this.cwd, path19);
|
|
76500
76524
|
const signal = context.abortSignal;
|
|
76501
|
-
const
|
|
76502
|
-
if (
|
|
76503
|
-
return
|
|
76525
|
+
const aborted3 = abortResult(signal, resolved);
|
|
76526
|
+
if (aborted3)
|
|
76527
|
+
return aborted3;
|
|
76504
76528
|
try {
|
|
76505
|
-
await (0,
|
|
76529
|
+
await (0, import_promises35.mkdir)((0, import_node_path39.resolve)(resolved, ".."), { recursive: true });
|
|
76506
76530
|
const afterMkdirAbort = abortResult(signal, resolved);
|
|
76507
76531
|
if (afterMkdirAbort)
|
|
76508
76532
|
return afterMkdirAbort;
|
|
76509
|
-
await (0,
|
|
76533
|
+
await (0, import_promises35.writeFile)(resolved, content2, { signal });
|
|
76510
76534
|
return ok(void 0);
|
|
76511
76535
|
} catch (error62) {
|
|
76512
76536
|
return err(toFileError(error62, resolved));
|
|
@@ -76515,15 +76539,15 @@ Cannot execute bash commands.`, cause));
|
|
|
76515
76539
|
async appendFile(path19, content2, context) {
|
|
76516
76540
|
const resolved = resolvePath3(this.cwd, path19);
|
|
76517
76541
|
const signal = context.abortSignal;
|
|
76518
|
-
const
|
|
76519
|
-
if (
|
|
76520
|
-
return
|
|
76542
|
+
const aborted3 = abortResult(signal, resolved);
|
|
76543
|
+
if (aborted3)
|
|
76544
|
+
return aborted3;
|
|
76521
76545
|
try {
|
|
76522
|
-
await (0,
|
|
76546
|
+
await (0, import_promises35.mkdir)((0, import_node_path39.resolve)(resolved, ".."), { recursive: true });
|
|
76523
76547
|
const afterMkdirAbort = abortResult(signal, resolved);
|
|
76524
76548
|
if (afterMkdirAbort)
|
|
76525
76549
|
return afterMkdirAbort;
|
|
76526
|
-
await (0,
|
|
76550
|
+
await (0, import_promises35.appendFile)(resolved, content2);
|
|
76527
76551
|
const afterAppendAbort = abortResult(signal, resolved);
|
|
76528
76552
|
return afterAppendAbort ?? ok(void 0);
|
|
76529
76553
|
} catch (error62) {
|
|
@@ -76533,15 +76557,15 @@ Cannot execute bash commands.`, cause));
|
|
|
76533
76557
|
async truncateFile(path19, size, context) {
|
|
76534
76558
|
const resolved = resolvePath3(this.cwd, path19);
|
|
76535
76559
|
const signal = context.abortSignal;
|
|
76536
|
-
const
|
|
76537
|
-
if (
|
|
76538
|
-
return
|
|
76560
|
+
const aborted3 = abortResult(signal, resolved);
|
|
76561
|
+
if (aborted3)
|
|
76562
|
+
return aborted3;
|
|
76539
76563
|
if (!Number.isSafeInteger(size) || size < 0) {
|
|
76540
76564
|
return err(new FileError("invalid", "File size must be a non-negative safe integer", resolved));
|
|
76541
76565
|
}
|
|
76542
76566
|
let file2;
|
|
76543
76567
|
try {
|
|
76544
|
-
file2 = await (0,
|
|
76568
|
+
file2 = await (0, import_promises35.open)(resolved, "r+");
|
|
76545
76569
|
await file2.truncate(size);
|
|
76546
76570
|
const afterTruncateAbort = abortResult(signal, resolved);
|
|
76547
76571
|
return afterTruncateAbort ?? ok(void 0);
|
|
@@ -76554,12 +76578,12 @@ Cannot execute bash commands.`, cause));
|
|
|
76554
76578
|
async flushFile(path19, context) {
|
|
76555
76579
|
const resolved = resolvePath3(this.cwd, path19);
|
|
76556
76580
|
const signal = context.abortSignal;
|
|
76557
|
-
const
|
|
76558
|
-
if (
|
|
76559
|
-
return
|
|
76581
|
+
const aborted3 = abortResult(signal, resolved);
|
|
76582
|
+
if (aborted3)
|
|
76583
|
+
return aborted3;
|
|
76560
76584
|
let file2;
|
|
76561
76585
|
try {
|
|
76562
|
-
file2 = await (0,
|
|
76586
|
+
file2 = await (0, import_promises35.open)(resolved, "r+");
|
|
76563
76587
|
if ((await file2.stat()).isDirectory())
|
|
76564
76588
|
return err(new FileError("is_directory", "Is a directory", resolved));
|
|
76565
76589
|
await file2.sync();
|
|
@@ -76574,11 +76598,11 @@ Cannot execute bash commands.`, cause));
|
|
|
76574
76598
|
async renameFile(sourcePath, destinationPath, context) {
|
|
76575
76599
|
const source = resolvePath3(this.cwd, sourcePath);
|
|
76576
76600
|
const destination = resolvePath3(this.cwd, destinationPath);
|
|
76577
|
-
const
|
|
76578
|
-
if (
|
|
76579
|
-
return
|
|
76601
|
+
const aborted3 = abortResult(context.abortSignal, destination);
|
|
76602
|
+
if (aborted3)
|
|
76603
|
+
return aborted3;
|
|
76580
76604
|
try {
|
|
76581
|
-
await (0,
|
|
76605
|
+
await (0, import_promises35.rename)(source, destination);
|
|
76582
76606
|
return ok(void 0);
|
|
76583
76607
|
} catch (error62) {
|
|
76584
76608
|
return err(toFileError(error62, source));
|
|
@@ -76586,11 +76610,11 @@ Cannot execute bash commands.`, cause));
|
|
|
76586
76610
|
}
|
|
76587
76611
|
async fileInfo(path19, context) {
|
|
76588
76612
|
const resolved = resolvePath3(this.cwd, path19);
|
|
76589
|
-
const
|
|
76590
|
-
if (
|
|
76591
|
-
return
|
|
76613
|
+
const aborted3 = abortResult(context.abortSignal, resolved);
|
|
76614
|
+
if (aborted3)
|
|
76615
|
+
return aborted3;
|
|
76592
76616
|
try {
|
|
76593
|
-
return fileInfoFromStats(resolved, await (0,
|
|
76617
|
+
return fileInfoFromStats(resolved, await (0, import_promises35.lstat)(resolved));
|
|
76594
76618
|
} catch (error62) {
|
|
76595
76619
|
return err(toFileError(error62, resolved));
|
|
76596
76620
|
}
|
|
@@ -76598,11 +76622,11 @@ Cannot execute bash commands.`, cause));
|
|
|
76598
76622
|
async listDir(path19, context) {
|
|
76599
76623
|
const resolved = resolvePath3(this.cwd, path19);
|
|
76600
76624
|
const signal = context.abortSignal;
|
|
76601
|
-
const
|
|
76602
|
-
if (
|
|
76603
|
-
return
|
|
76625
|
+
const aborted3 = abortResult(signal, resolved);
|
|
76626
|
+
if (aborted3)
|
|
76627
|
+
return aborted3;
|
|
76604
76628
|
try {
|
|
76605
|
-
const entries2 = await (0,
|
|
76629
|
+
const entries2 = await (0, import_promises35.readdir)(resolved, { withFileTypes: true });
|
|
76606
76630
|
const infos = [];
|
|
76607
76631
|
for (const entry2 of entries2) {
|
|
76608
76632
|
const loopAbort = abortResult(signal, resolved);
|
|
@@ -76610,7 +76634,7 @@ Cannot execute bash commands.`, cause));
|
|
|
76610
76634
|
return loopAbort;
|
|
76611
76635
|
const entryPath = (0, import_node_path39.resolve)(resolved, entry2.name);
|
|
76612
76636
|
try {
|
|
76613
|
-
const info = fileInfoFromStats(entryPath, await (0,
|
|
76637
|
+
const info = fileInfoFromStats(entryPath, await (0, import_promises35.lstat)(entryPath));
|
|
76614
76638
|
if (info.ok)
|
|
76615
76639
|
infos.push(info.value);
|
|
76616
76640
|
} catch (error62) {
|
|
@@ -76624,11 +76648,11 @@ Cannot execute bash commands.`, cause));
|
|
|
76624
76648
|
}
|
|
76625
76649
|
async openDirReader(path19, context) {
|
|
76626
76650
|
const resolved = resolvePath3(this.cwd, path19);
|
|
76627
|
-
const
|
|
76628
|
-
if (
|
|
76629
|
-
return
|
|
76651
|
+
const aborted3 = abortResult(context.abortSignal, resolved);
|
|
76652
|
+
if (aborted3)
|
|
76653
|
+
return aborted3;
|
|
76630
76654
|
try {
|
|
76631
|
-
const dir = await (0,
|
|
76655
|
+
const dir = await (0, import_promises35.opendir)(resolved);
|
|
76632
76656
|
const afterOpenAbort = abortResult(context.abortSignal, resolved);
|
|
76633
76657
|
if (afterOpenAbort) {
|
|
76634
76658
|
await dir.close().catch(() => void 0);
|
|
@@ -76641,11 +76665,11 @@ Cannot execute bash commands.`, cause));
|
|
|
76641
76665
|
}
|
|
76642
76666
|
async canonicalPath(path19, context) {
|
|
76643
76667
|
const resolved = resolvePath3(this.cwd, path19);
|
|
76644
|
-
const
|
|
76645
|
-
if (
|
|
76646
|
-
return
|
|
76668
|
+
const aborted3 = abortResult(context.abortSignal, resolved);
|
|
76669
|
+
if (aborted3)
|
|
76670
|
+
return aborted3;
|
|
76647
76671
|
try {
|
|
76648
|
-
return ok(await (0,
|
|
76672
|
+
return ok(await (0, import_promises35.realpath)(resolved));
|
|
76649
76673
|
} catch (error62) {
|
|
76650
76674
|
return err(toFileError(error62, resolved));
|
|
76651
76675
|
}
|
|
@@ -76660,11 +76684,11 @@ Cannot execute bash commands.`, cause));
|
|
|
76660
76684
|
}
|
|
76661
76685
|
async createDir(path19, options, context) {
|
|
76662
76686
|
const resolved = resolvePath3(this.cwd, path19);
|
|
76663
|
-
const
|
|
76664
|
-
if (
|
|
76665
|
-
return
|
|
76687
|
+
const aborted3 = abortResult(context.abortSignal, resolved);
|
|
76688
|
+
if (aborted3)
|
|
76689
|
+
return aborted3;
|
|
76666
76690
|
try {
|
|
76667
|
-
await (0,
|
|
76691
|
+
await (0, import_promises35.mkdir)(resolved, { recursive: options?.recursive ?? true });
|
|
76668
76692
|
return ok(void 0);
|
|
76669
76693
|
} catch (error62) {
|
|
76670
76694
|
return err(toFileError(error62, resolved));
|
|
@@ -76672,23 +76696,23 @@ Cannot execute bash commands.`, cause));
|
|
|
76672
76696
|
}
|
|
76673
76697
|
async remove(path19, options, context) {
|
|
76674
76698
|
const resolved = resolvePath3(this.cwd, path19);
|
|
76675
|
-
const
|
|
76676
|
-
if (
|
|
76677
|
-
return
|
|
76699
|
+
const aborted3 = abortResult(context.abortSignal, resolved);
|
|
76700
|
+
if (aborted3)
|
|
76701
|
+
return aborted3;
|
|
76678
76702
|
try {
|
|
76679
|
-
await (0,
|
|
76703
|
+
await (0, import_promises35.rm)(resolved, { recursive: options?.recursive ?? false, force: options?.force ?? false });
|
|
76680
76704
|
return ok(void 0);
|
|
76681
76705
|
} catch (error62) {
|
|
76682
76706
|
return err(toFileError(error62, resolved));
|
|
76683
76707
|
}
|
|
76684
76708
|
}
|
|
76685
76709
|
async createTempDir(prefix2, context) {
|
|
76686
|
-
const
|
|
76687
|
-
if (
|
|
76688
|
-
return
|
|
76710
|
+
const aborted3 = abortResult(context.abortSignal);
|
|
76711
|
+
if (aborted3)
|
|
76712
|
+
return aborted3;
|
|
76689
76713
|
try {
|
|
76690
76714
|
prefix2 ??= "tmp-";
|
|
76691
|
-
return ok(await (0,
|
|
76715
|
+
return ok(await (0, import_promises35.mkdtemp)((0, import_node_path39.join)((0, import_node_os5.tmpdir)(), prefix2)));
|
|
76692
76716
|
} catch (error62) {
|
|
76693
76717
|
return err(toFileError(error62));
|
|
76694
76718
|
}
|
|
@@ -76697,9 +76721,9 @@ Cannot execute bash commands.`, cause));
|
|
|
76697
76721
|
const dir = await this.createTempDir("tmp-", context);
|
|
76698
76722
|
if (!dir.ok)
|
|
76699
76723
|
return dir;
|
|
76700
|
-
const filePath = (0, import_node_path39.join)(dir.value, `${options?.prefix ?? ""}${(0,
|
|
76724
|
+
const filePath = (0, import_node_path39.join)(dir.value, `${options?.prefix ?? ""}${(0, import_node_crypto24.randomUUID)()}${options?.suffix ?? ""}`);
|
|
76701
76725
|
try {
|
|
76702
|
-
await (0,
|
|
76726
|
+
await (0, import_promises35.writeFile)(filePath, "");
|
|
76703
76727
|
return ok(filePath);
|
|
76704
76728
|
} catch (error62) {
|
|
76705
76729
|
return err(toFileError(error62, filePath));
|
|
@@ -76781,7 +76805,7 @@ async function openNodeSqliteDatabase(path19, options = {}) {
|
|
|
76781
76805
|
const checkpointPages = options.walAutoCheckpointPages ?? DEFAULT_WAL_AUTO_CHECKPOINT_PAGES;
|
|
76782
76806
|
const timeout2 = options.busyTimeoutMs ?? DEFAULT_BUSY_TIMEOUT_MS;
|
|
76783
76807
|
if (path19 !== ":memory:")
|
|
76784
|
-
await (0,
|
|
76808
|
+
await (0, import_promises36.mkdir)((0, import_node_path40.dirname)(path19), { recursive: true });
|
|
76785
76809
|
const database = new import_node_sqlite.DatabaseSync(path19, { timeout: timeout2 });
|
|
76786
76810
|
const adapter = new NodeSqliteDatabase(database);
|
|
76787
76811
|
try {
|
|
@@ -76797,11 +76821,11 @@ async function openNodeSqliteDatabase(path19, options = {}) {
|
|
|
76797
76821
|
throw error62;
|
|
76798
76822
|
}
|
|
76799
76823
|
}
|
|
76800
|
-
var
|
|
76824
|
+
var import_promises36, import_node_path40, import_node_sqlite, DEFAULT_WAL_AUTO_CHECKPOINT_PAGES, DEFAULT_BUSY_TIMEOUT_MS, ignore2, SerialOperationQueue, STATEMENT_CACHE_LIMIT, NodeSqliteExecutor, NodeSqliteTransaction, NodeSqliteDatabase;
|
|
76801
76825
|
var init_node2 = __esm({
|
|
76802
76826
|
"../../node_modules/@earendil-works/chord/dist/sqlite/node.js"() {
|
|
76803
76827
|
"use strict";
|
|
76804
|
-
|
|
76828
|
+
import_promises36 = require("node:fs/promises");
|
|
76805
76829
|
import_node_path40 = require("node:path");
|
|
76806
76830
|
import_node_sqlite = require("node:sqlite");
|
|
76807
76831
|
DEFAULT_WAL_AUTO_CHECKPOINT_PAGES = 1e3;
|
|
@@ -87824,13 +87848,10 @@ function parametersOf(tool) {
|
|
|
87824
87848
|
function errorText2(error62) {
|
|
87825
87849
|
return error62 instanceof Error ? error62.message : String(error62);
|
|
87826
87850
|
}
|
|
87827
|
-
function isRecord4(value2) {
|
|
87828
|
-
return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
|
|
87829
|
-
}
|
|
87830
87851
|
function createMcpTool(connection, tool, options) {
|
|
87831
87852
|
const server = connection.config.name;
|
|
87832
87853
|
const properties = tool.inputSchema.properties;
|
|
87833
|
-
const idempotent = connection.config.operationKey !== void 0 && tool._meta?.["ai.tryalan/durable-idempotency"] === "v1" &&
|
|
87854
|
+
const idempotent = connection.config.operationKey !== void 0 && tool._meta?.["ai.tryalan/durable-idempotency"] === "v1" && isRecord(properties) && Object.hasOwn(properties, "idempotencyKey");
|
|
87834
87855
|
return {
|
|
87835
87856
|
name: mcpToolName2(server, tool.name),
|
|
87836
87857
|
description: tool.description?.trim() || tool.title || tool.name,
|
|
@@ -87839,7 +87860,7 @@ function createMcpTool(connection, tool, options) {
|
|
|
87839
87860
|
...options.deferred ? { deferred: true } : {},
|
|
87840
87861
|
...idempotent || tool.annotations?.readOnlyHint === true ? { replay: "safe" } : {},
|
|
87841
87862
|
async execute(args, api, context) {
|
|
87842
|
-
const input2 =
|
|
87863
|
+
const input2 = isRecord(args) ? { ...args } : {};
|
|
87843
87864
|
if (idempotent && input2.idempotencyKey === void 0)
|
|
87844
87865
|
input2.idempotencyKey = connection.config.operationKey?.(String(api.taskId));
|
|
87845
87866
|
try {
|
|
@@ -87859,6 +87880,7 @@ var MAX_TOOL_NAME_LENGTH, MCP_OUTPUT_LIMITS;
|
|
|
87859
87880
|
var init_tools2 = __esm({
|
|
87860
87881
|
"../alan-engine/src/mcp/tools.ts"() {
|
|
87861
87882
|
"use strict";
|
|
87883
|
+
init_type_guards();
|
|
87862
87884
|
init_dist5();
|
|
87863
87885
|
init_sha2();
|
|
87864
87886
|
init_utils();
|
|
@@ -88004,7 +88026,7 @@ function stripBearer(authorization) {
|
|
|
88004
88026
|
return authorization.replace(/^Bearer\s+/i, "").trim();
|
|
88005
88027
|
}
|
|
88006
88028
|
async function readAlanCredentialFile(path19) {
|
|
88007
|
-
const parsed = JSON.parse(await (0,
|
|
88029
|
+
const parsed = JSON.parse(await (0, import_promises37.readFile)(path19, "utf8"));
|
|
88008
88030
|
if (typeof parsed !== "object" || parsed === null) {
|
|
88009
88031
|
throw new Error(`Alan credential file is not a JSON object: ${path19}`);
|
|
88010
88032
|
}
|
|
@@ -88023,11 +88045,11 @@ function alanCredentialSource(explicit, env = process.env) {
|
|
|
88023
88045
|
if (file2 === void 0) return { apiKey: void 0 };
|
|
88024
88046
|
return () => readAlanCredentialFile(file2);
|
|
88025
88047
|
}
|
|
88026
|
-
var
|
|
88048
|
+
var import_promises37, DEFAULT_ALAN_API_URL;
|
|
88027
88049
|
var init_credentials = __esm({
|
|
88028
88050
|
"../alan-engine/src/model/credentials.ts"() {
|
|
88029
88051
|
"use strict";
|
|
88030
|
-
|
|
88052
|
+
import_promises37 = require("node:fs/promises");
|
|
88031
88053
|
init_credential_source();
|
|
88032
88054
|
DEFAULT_ALAN_API_URL = "https://api.tryalan.ai";
|
|
88033
88055
|
}
|
|
@@ -88798,24 +88820,24 @@ function assertClassifierInputSupported(model2, context) {
|
|
|
88798
88820
|
throw new ModelsError("provider", `Model ${model2.provider}/${model2.id} does not accept image input`);
|
|
88799
88821
|
}
|
|
88800
88822
|
}
|
|
88801
|
-
function imageErrorResult(model2, error62,
|
|
88823
|
+
function imageErrorResult(model2, error62, aborted3 = false) {
|
|
88802
88824
|
return {
|
|
88803
88825
|
api: model2.api,
|
|
88804
88826
|
provider: model2.provider,
|
|
88805
88827
|
model: model2.id,
|
|
88806
88828
|
output: [],
|
|
88807
|
-
stopReason:
|
|
88829
|
+
stopReason: aborted3 ? "aborted" : "error",
|
|
88808
88830
|
errorMessage: error62 instanceof Error ? error62.message : String(error62),
|
|
88809
88831
|
timestamp: Date.now()
|
|
88810
88832
|
};
|
|
88811
88833
|
}
|
|
88812
|
-
function classifierErrorResult(model2, error62,
|
|
88834
|
+
function classifierErrorResult(model2, error62, aborted3 = false) {
|
|
88813
88835
|
return {
|
|
88814
88836
|
api: model2.api,
|
|
88815
88837
|
provider: model2.provider,
|
|
88816
88838
|
model: model2.id,
|
|
88817
88839
|
answers: {},
|
|
88818
|
-
stopReason:
|
|
88840
|
+
stopReason: aborted3 ? "aborted" : "error",
|
|
88819
88841
|
errorMessage: error62 instanceof Error ? error62.message : String(error62),
|
|
88820
88842
|
timestamp: Date.now()
|
|
88821
88843
|
};
|
|
@@ -90439,9 +90461,9 @@ function createAbortableSSESource(body, signal) {
|
|
|
90439
90461
|
if (signal.aborted) {
|
|
90440
90462
|
return ended;
|
|
90441
90463
|
}
|
|
90442
|
-
const
|
|
90464
|
+
const aborted3 = waitForAbort().then(() => ended);
|
|
90443
90465
|
try {
|
|
90444
|
-
const result = await Promise.race([source.next(),
|
|
90466
|
+
const result = await Promise.race([source.next(), aborted3]);
|
|
90445
90467
|
if (signal.aborted) {
|
|
90446
90468
|
return ended;
|
|
90447
90469
|
}
|
|
@@ -90462,10 +90484,10 @@ function createAbortableSSESource(body, signal) {
|
|
|
90462
90484
|
async return() {
|
|
90463
90485
|
const pending = cancel();
|
|
90464
90486
|
if (pending && !signal.aborted) {
|
|
90465
|
-
const
|
|
90487
|
+
const aborted3 = waitForAbort();
|
|
90466
90488
|
try {
|
|
90467
90489
|
if (!signal.aborted) {
|
|
90468
|
-
await Promise.race([pending,
|
|
90490
|
+
await Promise.race([pending, aborted3]);
|
|
90469
90491
|
}
|
|
90470
90492
|
} finally {
|
|
90471
90493
|
interrupt = void 0;
|
|
@@ -101358,14 +101380,14 @@ var init_agent_session_stream = __esm({
|
|
|
101358
101380
|
return error62;
|
|
101359
101381
|
}, _AgentSessionStream_wait = async function _AgentSessionStream_wait2(action) {
|
|
101360
101382
|
let onAbort;
|
|
101361
|
-
const
|
|
101383
|
+
const aborted3 = new Promise((_resolve, reject2) => {
|
|
101362
101384
|
onAbort = () => reject2(__classPrivateFieldGet(this, _AgentSessionStream_instances, "m", _AgentSessionStream_abortError).call(this));
|
|
101363
101385
|
this.controller.signal.addEventListener("abort", onAbort, { once: true });
|
|
101364
101386
|
});
|
|
101365
101387
|
try {
|
|
101366
101388
|
__classPrivateFieldGet(this, _AgentSessionStream_instances, "m", _AgentSessionStream_checkAbort).call(this);
|
|
101367
101389
|
const invoke = async () => await action();
|
|
101368
|
-
return await Promise.race([invoke(),
|
|
101390
|
+
return await Promise.race([invoke(), aborted3]);
|
|
101369
101391
|
} finally {
|
|
101370
101392
|
if (onAbort) {
|
|
101371
101393
|
this.controller.signal.removeEventListener("abort", onAbort);
|
|
@@ -111818,6 +111840,70 @@ var init_openai_completions_lazy = __esm({
|
|
|
111818
111840
|
}
|
|
111819
111841
|
});
|
|
111820
111842
|
|
|
111843
|
+
// ../shared/src/harness/request-images.ts
|
|
111844
|
+
function oldestImagesToOmit(sizes, budget = REQUEST_IMAGE_BUDGET) {
|
|
111845
|
+
let kept = 0;
|
|
111846
|
+
let chars = 0;
|
|
111847
|
+
for (let index = sizes.length - 1; index >= 0; index -= 1) {
|
|
111848
|
+
const size = sizes[index] ?? 0;
|
|
111849
|
+
if (kept + 1 > budget.maxImages || chars + size > budget.maxBase64Chars) return index + 1;
|
|
111850
|
+
kept += 1;
|
|
111851
|
+
chars += size;
|
|
111852
|
+
}
|
|
111853
|
+
return 0;
|
|
111854
|
+
}
|
|
111855
|
+
var REQUEST_IMAGE_BUDGET, OMITTED_IMAGE_NOTE;
|
|
111856
|
+
var init_request_images = __esm({
|
|
111857
|
+
"../shared/src/harness/request-images.ts"() {
|
|
111858
|
+
"use strict";
|
|
111859
|
+
REQUEST_IMAGE_BUDGET = {
|
|
111860
|
+
maxBase64Chars: 8 * 1024 * 1024,
|
|
111861
|
+
maxImages: 20
|
|
111862
|
+
};
|
|
111863
|
+
OMITTED_IMAGE_NOTE = "[Earlier image omitted to keep the request within size limits. Read the file again if you still need it.]";
|
|
111864
|
+
}
|
|
111865
|
+
});
|
|
111866
|
+
|
|
111867
|
+
// ../alan-engine/src/model/image-budget.ts
|
|
111868
|
+
function imageParts(message) {
|
|
111869
|
+
if (message.role === "toolResult") return message.content;
|
|
111870
|
+
if (message.role === "user" && typeof message.content !== "string") return message.content;
|
|
111871
|
+
return [];
|
|
111872
|
+
}
|
|
111873
|
+
function imageSizes(messages) {
|
|
111874
|
+
return messages.flatMap(
|
|
111875
|
+
(message) => imageParts(message).flatMap((part) => part.type === "image" ? [part.data.length] : [])
|
|
111876
|
+
);
|
|
111877
|
+
}
|
|
111878
|
+
function withContent(message, content2) {
|
|
111879
|
+
if (message.role === "toolResult") return { ...message, content: content2 };
|
|
111880
|
+
if (message.role === "user") return { ...message, content: content2 };
|
|
111881
|
+
return message;
|
|
111882
|
+
}
|
|
111883
|
+
function boundMessageImages(messages, budget = REQUEST_IMAGE_BUDGET) {
|
|
111884
|
+
let omit2 = oldestImagesToOmit(imageSizes(messages), budget);
|
|
111885
|
+
if (omit2 === 0) return messages;
|
|
111886
|
+
return messages.map((message) => {
|
|
111887
|
+
if (omit2 === 0) return message;
|
|
111888
|
+
const parts3 = imageParts(message);
|
|
111889
|
+
if (!parts3.some((part) => part.type === "image")) return message;
|
|
111890
|
+
const content2 = parts3.map((part) => {
|
|
111891
|
+
if (part.type !== "image" || omit2 === 0) return part;
|
|
111892
|
+
omit2 -= 1;
|
|
111893
|
+
return OMITTED_IMAGE;
|
|
111894
|
+
});
|
|
111895
|
+
return withContent(message, content2);
|
|
111896
|
+
});
|
|
111897
|
+
}
|
|
111898
|
+
var OMITTED_IMAGE;
|
|
111899
|
+
var init_image_budget = __esm({
|
|
111900
|
+
"../alan-engine/src/model/image-budget.ts"() {
|
|
111901
|
+
"use strict";
|
|
111902
|
+
init_request_images();
|
|
111903
|
+
OMITTED_IMAGE = { type: "text", text: OMITTED_IMAGE_NOTE };
|
|
111904
|
+
}
|
|
111905
|
+
});
|
|
111906
|
+
|
|
111821
111907
|
// ../alan-engine/src/model/alan-provider.ts
|
|
111822
111908
|
function operationKey(now = Date.now()) {
|
|
111823
111909
|
return `${now}-${crypto.randomUUID()}`;
|
|
@@ -111894,18 +111980,22 @@ function retryUpstreamErrors(source, signal) {
|
|
|
111894
111980
|
})();
|
|
111895
111981
|
return stream2;
|
|
111896
111982
|
}
|
|
111983
|
+
function withBoundedImages(context) {
|
|
111984
|
+
const messages = boundMessageImages(context.messages);
|
|
111985
|
+
return messages === context.messages ? context : { ...context, messages };
|
|
111986
|
+
}
|
|
111897
111987
|
function surfaceServerErrors(api, fetch2) {
|
|
111898
111988
|
return {
|
|
111899
111989
|
...api,
|
|
111900
111990
|
stream: (model2, context, options) => retryUpstreamErrors(
|
|
111901
|
-
api.stream(model2, context, {
|
|
111991
|
+
api.stream(model2, withBoundedImages(context), {
|
|
111902
111992
|
...options,
|
|
111903
111993
|
fetch: withServerErrorMessage(fetch2 ?? options?.fetch)
|
|
111904
111994
|
}),
|
|
111905
111995
|
options?.signal
|
|
111906
111996
|
),
|
|
111907
111997
|
streamSimple: (model2, context, options) => retryUpstreamErrors(
|
|
111908
|
-
api.streamSimple(model2, context, {
|
|
111998
|
+
api.streamSimple(model2, withBoundedImages(context), {
|
|
111909
111999
|
...options,
|
|
111910
112000
|
fetch: withServerErrorMessage(fetch2 ?? options?.fetch)
|
|
111911
112001
|
}),
|
|
@@ -111953,6 +112043,7 @@ var init_alan_provider = __esm({
|
|
|
111953
112043
|
init_event_stream();
|
|
111954
112044
|
init_catalog2();
|
|
111955
112045
|
init_credential_source();
|
|
112046
|
+
init_image_budget();
|
|
111956
112047
|
TRANSIENT_UPSTREAM_ERROR = /^(?:the model is unavailable\.?|aborted)$/i;
|
|
111957
112048
|
}
|
|
111958
112049
|
});
|
|
@@ -112033,7 +112124,7 @@ function stampOf(info) {
|
|
|
112033
112124
|
return { mtimeMs: info.mtimeMs, size: info.size };
|
|
112034
112125
|
}
|
|
112035
112126
|
async function recordFileStamp(context, filepath, info) {
|
|
112036
|
-
const current = info ?? await (0,
|
|
112127
|
+
const current = info ?? await (0, import_promises38.stat)(filepath);
|
|
112037
112128
|
await context.fileReads.record(filepath, stampOf(current));
|
|
112038
112129
|
}
|
|
112039
112130
|
async function assertUnchangedSinceRead(context, filepath, info) {
|
|
@@ -112043,11 +112134,11 @@ async function assertUnchangedSinceRead(context, filepath, info) {
|
|
|
112043
112134
|
throw new ToolFailure(modifiedSinceReadMessage(filepath));
|
|
112044
112135
|
}
|
|
112045
112136
|
}
|
|
112046
|
-
var
|
|
112137
|
+
var import_promises38, FileReadsDoc;
|
|
112047
112138
|
var init_file_reads = __esm({
|
|
112048
112139
|
"../alan-engine/src/tools/file-reads.ts"() {
|
|
112049
112140
|
"use strict";
|
|
112050
|
-
|
|
112141
|
+
import_promises38 = require("node:fs/promises");
|
|
112051
112142
|
init_dist4();
|
|
112052
112143
|
init_shared2();
|
|
112053
112144
|
FileReadsDoc = defineDoc({
|
|
@@ -112290,7 +112381,7 @@ Usage:
|
|
|
112290
112381
|
// ../alan-engine/src/tools/process-tree.ts
|
|
112291
112382
|
function spawnShellTree(shell, env, start, platform = process.platform) {
|
|
112292
112383
|
if (platform !== "win32") return start(env);
|
|
112293
|
-
const tag = (0,
|
|
112384
|
+
const tag = (0, import_node_crypto25.randomUUID)();
|
|
112294
112385
|
const child = start({ ...env, [PROCESS_TREE_ENV]: tag });
|
|
112295
112386
|
shellTrees.set(child, { shell, tag });
|
|
112296
112387
|
return child;
|
|
@@ -112336,12 +112427,12 @@ function killProcessTree3(child, signal, platform = process.platform) {
|
|
|
112336
112427
|
child.kill(signal);
|
|
112337
112428
|
}
|
|
112338
112429
|
}
|
|
112339
|
-
var import_node_child_process13,
|
|
112430
|
+
var import_node_child_process13, import_node_crypto25, PROCESS_TREE_ENV, shellTrees, LIST_SHELL_TREE, SHELL_TREE_ROUNDS;
|
|
112340
112431
|
var init_process_tree2 = __esm({
|
|
112341
112432
|
"../alan-engine/src/tools/process-tree.ts"() {
|
|
112342
112433
|
"use strict";
|
|
112343
112434
|
import_node_child_process13 = require("node:child_process");
|
|
112344
|
-
|
|
112435
|
+
import_node_crypto25 = require("node:crypto");
|
|
112345
112436
|
PROCESS_TREE_ENV = "ALAN_PROCESS_TREE";
|
|
112346
112437
|
shellTrees = /* @__PURE__ */ new WeakMap();
|
|
112347
112438
|
LIST_SHELL_TREE = `tag="${PROCESS_TREE_ENV}=$1"
|
|
@@ -118755,9 +118846,9 @@ function killGroup(child, signal) {
|
|
|
118755
118846
|
killProcessTree3(child, signal);
|
|
118756
118847
|
}
|
|
118757
118848
|
async function saveFullOutput(text3) {
|
|
118758
|
-
await (0,
|
|
118759
|
-
const file2 = import_node_path42.default.join(OUTPUT_DIR, `tool_${(0,
|
|
118760
|
-
await (0,
|
|
118849
|
+
await (0, import_promises39.mkdir)(OUTPUT_DIR, { recursive: true });
|
|
118850
|
+
const file2 = import_node_path42.default.join(OUTPUT_DIR, `tool_${(0, import_node_crypto26.randomUUID)()}`);
|
|
118851
|
+
await (0, import_promises39.writeFile)(file2, text3, "utf8");
|
|
118761
118852
|
return file2;
|
|
118762
118853
|
}
|
|
118763
118854
|
function runCommand2(io, args, cwd, timeout2) {
|
|
@@ -118840,7 +118931,7 @@ Use bash_output with this ID to read new output and kill_shell to stop it.`;
|
|
|
118840
118931
|
}
|
|
118841
118932
|
async function execute(context, io, args, options) {
|
|
118842
118933
|
const cwd = args.workdir ? resolvePath2(context.cwd, args.workdir) : context.cwd;
|
|
118843
|
-
const workdirInfo = await (0,
|
|
118934
|
+
const workdirInfo = await (0, import_promises39.stat)(cwd).catch(() => void 0);
|
|
118844
118935
|
if (!workdirInfo?.isDirectory())
|
|
118845
118936
|
throw new ToolFailure(`Working directory does not exist: ${cwd}`);
|
|
118846
118937
|
if (args.run_in_background === true) {
|
|
@@ -118897,13 +118988,13 @@ function createBashTool(cwd, shells, options = {}) {
|
|
|
118897
118988
|
execute: (args, api, context) => runDurable({ cwd, shells }, api, context, (tool, io) => execute(tool, io, args, options))
|
|
118898
118989
|
});
|
|
118899
118990
|
}
|
|
118900
|
-
var import_node_child_process14,
|
|
118991
|
+
var import_node_child_process14, import_node_crypto26, import_promises39, import_node_os6, import_node_path42, MAX_METADATA_LENGTH, DETAILS_INTERVAL_MS, KILL_GRACE_MS, OUTPUT_DIR, HEAD_CHARS, TAIL_CHARS;
|
|
118901
118992
|
var init_bash = __esm({
|
|
118902
118993
|
"../alan-engine/src/tools/bash.ts"() {
|
|
118903
118994
|
"use strict";
|
|
118904
118995
|
import_node_child_process14 = require("node:child_process");
|
|
118905
|
-
|
|
118906
|
-
|
|
118996
|
+
import_node_crypto26 = require("node:crypto");
|
|
118997
|
+
import_promises39 = require("node:fs/promises");
|
|
118907
118998
|
import_node_os6 = __toESM(require("node:os"), 1);
|
|
118908
118999
|
import_node_path42 = __toESM(require("node:path"), 1);
|
|
118909
119000
|
init_dist4();
|
|
@@ -118924,14 +119015,14 @@ var init_bash = __esm({
|
|
|
118924
119015
|
|
|
118925
119016
|
// ../alan-engine/src/tools/background-shells.ts
|
|
118926
119017
|
function newShellId() {
|
|
118927
|
-
return `shell_${(0,
|
|
119018
|
+
return `shell_${(0, import_node_crypto27.randomBytes)(4).toString("hex")}`;
|
|
118928
119019
|
}
|
|
118929
|
-
var import_node_child_process15,
|
|
119020
|
+
var import_node_child_process15, import_node_crypto27, import_node_fs23, import_node_path43, UNREAD_LIMIT_CHARS, RETAINED_FINISHED, UnknownBackgroundShell, BackgroundShells;
|
|
118930
119021
|
var init_background_shells = __esm({
|
|
118931
119022
|
"../alan-engine/src/tools/background-shells.ts"() {
|
|
118932
119023
|
"use strict";
|
|
118933
119024
|
import_node_child_process15 = require("node:child_process");
|
|
118934
|
-
|
|
119025
|
+
import_node_crypto27 = require("node:crypto");
|
|
118935
119026
|
import_node_fs23 = require("node:fs");
|
|
118936
119027
|
import_node_path43 = __toESM(require("node:path"), 1);
|
|
118937
119028
|
init_bash();
|
|
@@ -119202,27 +119293,27 @@ function withLineEnding(edit, ending) {
|
|
|
119202
119293
|
};
|
|
119203
119294
|
}
|
|
119204
119295
|
async function applyEdit(context, io, filepath, args) {
|
|
119205
|
-
const info = await (0,
|
|
119296
|
+
const info = await (0, import_promises40.stat)(filepath).catch(() => void 0);
|
|
119206
119297
|
const [first] = args.edits;
|
|
119207
119298
|
if (first !== void 0 && first.oldString === "" && args.edits.length === 1) {
|
|
119208
119299
|
if (info) throw new ToolFailure(EMPTY_OLD_STRING_MESSAGE);
|
|
119209
119300
|
io.abortSignal?.throwIfAborted();
|
|
119210
|
-
await (0,
|
|
119211
|
-
await (0,
|
|
119301
|
+
await (0, import_promises40.mkdir)(import_node_path44.default.dirname(filepath), { recursive: true });
|
|
119302
|
+
await (0, import_promises40.writeFile)(filepath, first.newString, "utf8");
|
|
119212
119303
|
await recordFileStamp(context, filepath);
|
|
119213
119304
|
return { before: "", after: first.newString };
|
|
119214
119305
|
}
|
|
119215
119306
|
if (!info) throw new ToolFailure(`File ${filepath} not found`);
|
|
119216
119307
|
if (info.isDirectory()) throw new ToolFailure(`Path is a directory, not a file: ${filepath}`);
|
|
119217
119308
|
await assertUnchangedSinceRead(context, filepath, info);
|
|
119218
|
-
const before = await (0,
|
|
119309
|
+
const before = await (0, import_promises40.readFile)(filepath, "utf8");
|
|
119219
119310
|
const ending = detectLineEnding(before);
|
|
119220
119311
|
const after = applyReplacements(
|
|
119221
119312
|
before,
|
|
119222
119313
|
args.edits.map((edit) => withLineEnding(edit, ending))
|
|
119223
119314
|
);
|
|
119224
119315
|
io.abortSignal?.throwIfAborted();
|
|
119225
|
-
await (0,
|
|
119316
|
+
await (0, import_promises40.writeFile)(filepath, after, "utf8");
|
|
119226
119317
|
await recordFileStamp(context, filepath);
|
|
119227
119318
|
return { before, after };
|
|
119228
119319
|
}
|
|
@@ -119250,11 +119341,11 @@ function createEditTool(cwd) {
|
|
|
119250
119341
|
execute: (args, api, context) => runDurable({ cwd, shells: void 0 }, api, context, (tool, io) => execute2(tool, io, args))
|
|
119251
119342
|
});
|
|
119252
119343
|
}
|
|
119253
|
-
var
|
|
119344
|
+
var import_promises40, import_node_path44, editTool;
|
|
119254
119345
|
var init_edit2 = __esm({
|
|
119255
119346
|
"../alan-engine/src/tools/edit.ts"() {
|
|
119256
119347
|
"use strict";
|
|
119257
|
-
|
|
119348
|
+
import_promises40 = require("node:fs/promises");
|
|
119258
119349
|
import_node_path44 = __toESM(require("node:path"), 1);
|
|
119259
119350
|
init_dist4();
|
|
119260
119351
|
init_diff();
|
|
@@ -119300,7 +119391,7 @@ async function syntaxProblem(filepath) {
|
|
|
119300
119391
|
const extension = import_node_path45.default.extname(filepath).toLowerCase();
|
|
119301
119392
|
if (extension === ".py") return pythonProblem(filepath);
|
|
119302
119393
|
if (!TS_EXTENSIONS.has(extension) && extension !== ".json") return void 0;
|
|
119303
|
-
const source = await (0,
|
|
119394
|
+
const source = await (0, import_promises41.readFile)(filepath, "utf8").catch(() => void 0);
|
|
119304
119395
|
if (source === void 0) return void 0;
|
|
119305
119396
|
if (extension !== ".json") return typeScriptProblem(source);
|
|
119306
119397
|
try {
|
|
@@ -119352,12 +119443,12 @@ function withBudgetReminder(tools) {
|
|
|
119352
119443
|
})
|
|
119353
119444
|
);
|
|
119354
119445
|
}
|
|
119355
|
-
var import_node_child_process16,
|
|
119446
|
+
var import_node_child_process16, import_promises41, import_node_module, import_node_path45, TOOL_EXPERIMENTS, SYNTAX_TIMEOUT_MS, TS_EXTENSIONS, PY_PARSE, BUDGET_FIRST_REMINDER, BUDGET_REMINDER_EVERY;
|
|
119356
119447
|
var init_experiments = __esm({
|
|
119357
119448
|
"../alan-engine/src/tools/experiments.ts"() {
|
|
119358
119449
|
"use strict";
|
|
119359
119450
|
import_node_child_process16 = require("node:child_process");
|
|
119360
|
-
|
|
119451
|
+
import_promises41 = require("node:fs/promises");
|
|
119361
119452
|
import_node_module = require("node:module");
|
|
119362
119453
|
import_node_path45 = __toESM(require("node:path"), 1);
|
|
119363
119454
|
TOOL_EXPERIMENTS = [
|
|
@@ -119475,17 +119566,23 @@ var init_glob_match = __esm({
|
|
|
119475
119566
|
});
|
|
119476
119567
|
|
|
119477
119568
|
// ../alan-engine/src/tools/search.ts
|
|
119569
|
+
function isExecutable2(file2) {
|
|
119570
|
+
try {
|
|
119571
|
+
(0, import_node_fs24.accessSync)(file2, import_node_fs24.constants.X_OK);
|
|
119572
|
+
return true;
|
|
119573
|
+
} catch {
|
|
119574
|
+
return false;
|
|
119575
|
+
}
|
|
119576
|
+
}
|
|
119478
119577
|
function findRipgrep() {
|
|
119479
119578
|
if (ripgrepPath !== void 0) return ripgrepPath ?? void 0;
|
|
119480
119579
|
const binary = process.platform === "win32" ? "rg.exe" : "rg";
|
|
119481
119580
|
for (const dir of (process.env.PATH ?? "").split(import_node_path46.default.delimiter)) {
|
|
119482
119581
|
if (!dir) continue;
|
|
119483
119582
|
const candidate = import_node_path46.default.join(dir, binary);
|
|
119484
|
-
|
|
119485
|
-
(0, import_node_fs24.accessSync)(candidate, import_node_fs24.constants.X_OK);
|
|
119583
|
+
if (isExecutable2(candidate)) {
|
|
119486
119584
|
ripgrepPath = candidate;
|
|
119487
119585
|
return candidate;
|
|
119488
|
-
} catch {
|
|
119489
119586
|
}
|
|
119490
119587
|
}
|
|
119491
119588
|
ripgrepPath = null;
|
|
@@ -119541,7 +119638,7 @@ function runRipgrep(binary, run3) {
|
|
|
119541
119638
|
});
|
|
119542
119639
|
}
|
|
119543
119640
|
async function readIgnoreRules(root) {
|
|
119544
|
-
const text3 = await (0,
|
|
119641
|
+
const text3 = await (0, import_promises42.readFile)(import_node_path46.default.join(root, ".gitignore"), "utf8").catch(() => "");
|
|
119545
119642
|
const rules = [];
|
|
119546
119643
|
for (const raw of text3.split(/\r?\n/)) {
|
|
119547
119644
|
const line = raw.trim();
|
|
@@ -119563,7 +119660,7 @@ async function* walkFiles(root, options) {
|
|
|
119563
119660
|
while (stack.length > 0) {
|
|
119564
119661
|
options.signal?.throwIfAborted();
|
|
119565
119662
|
const relativeDir = stack.pop() ?? "";
|
|
119566
|
-
const entries2 = await (0,
|
|
119663
|
+
const entries2 = await (0, import_promises42.readdir)(import_node_path46.default.join(root, relativeDir), { withFileTypes: true }).catch(
|
|
119567
119664
|
() => []
|
|
119568
119665
|
);
|
|
119569
119666
|
entries2.sort((a, b) => a.name.localeCompare(b.name));
|
|
@@ -119586,13 +119683,13 @@ async function* walkFiles(root, options) {
|
|
|
119586
119683
|
for (let i = directories.length - 1; i >= 0; i--) stack.push(directories[i]);
|
|
119587
119684
|
}
|
|
119588
119685
|
}
|
|
119589
|
-
var import_node_child_process17, import_node_fs24,
|
|
119686
|
+
var import_node_child_process17, import_node_fs24, import_promises42, import_node_path46, import_node_readline, ALWAYS_SKIPPED, ripgrepPath;
|
|
119590
119687
|
var init_search2 = __esm({
|
|
119591
119688
|
"../alan-engine/src/tools/search.ts"() {
|
|
119592
119689
|
"use strict";
|
|
119593
119690
|
import_node_child_process17 = require("node:child_process");
|
|
119594
119691
|
import_node_fs24 = require("node:fs");
|
|
119595
|
-
|
|
119692
|
+
import_promises42 = require("node:fs/promises");
|
|
119596
119693
|
import_node_path46 = __toESM(require("node:path"), 1);
|
|
119597
119694
|
import_node_readline = require("node:readline");
|
|
119598
119695
|
init_glob_match();
|
|
@@ -119624,7 +119721,7 @@ async function findFiles(root, pattern, signal) {
|
|
|
119624
119721
|
}
|
|
119625
119722
|
async function execute3(context, io, args) {
|
|
119626
119723
|
const search = resolvePath2(context.cwd, args.path ?? ".");
|
|
119627
|
-
const info = await (0,
|
|
119724
|
+
const info = await (0, import_promises43.stat)(search).catch(() => void 0);
|
|
119628
119725
|
if (info?.isFile()) throw new ToolFailure(`glob path must be a directory: ${search}`);
|
|
119629
119726
|
if (!info) throw new ToolFailure(`Directory not found: ${search}`);
|
|
119630
119727
|
const files = await findFiles(search, args.pattern, io.abortSignal);
|
|
@@ -119652,11 +119749,11 @@ function createGlobTool(cwd) {
|
|
|
119652
119749
|
execute: (args, api, context) => runDurable({ cwd, shells: void 0 }, api, context, (tool, io) => execute3(tool, io, args))
|
|
119653
119750
|
});
|
|
119654
119751
|
}
|
|
119655
|
-
var
|
|
119752
|
+
var import_promises43, import_node_path47, LIMIT, globTool;
|
|
119656
119753
|
var init_glob = __esm({
|
|
119657
119754
|
"../alan-engine/src/tools/glob.ts"() {
|
|
119658
119755
|
"use strict";
|
|
119659
|
-
|
|
119756
|
+
import_promises43 = require("node:fs/promises");
|
|
119660
119757
|
import_node_path47 = __toESM(require("node:path"), 1);
|
|
119661
119758
|
init_dist4();
|
|
119662
119759
|
init_durable();
|
|
@@ -119697,7 +119794,7 @@ function isBinaryFile(filepath, bytes2) {
|
|
|
119697
119794
|
}
|
|
119698
119795
|
async function readSample(filepath, size) {
|
|
119699
119796
|
if (size === 0) return new Uint8Array();
|
|
119700
|
-
const handle = await (0,
|
|
119797
|
+
const handle = await (0, import_promises44.open)(filepath, "r");
|
|
119701
119798
|
try {
|
|
119702
119799
|
const buffer = Buffer.alloc(Math.min(SAMPLE_BYTES, size));
|
|
119703
119800
|
const { bytesRead } = await handle.read(buffer, 0, buffer.length, 0);
|
|
@@ -119709,7 +119806,7 @@ async function readSample(filepath, size) {
|
|
|
119709
119806
|
async function missing(filepath) {
|
|
119710
119807
|
const dir = import_node_path48.default.dirname(filepath);
|
|
119711
119808
|
const base = import_node_path48.default.basename(filepath).toLowerCase();
|
|
119712
|
-
const suggestions = await (0,
|
|
119809
|
+
const suggestions = await (0, import_promises44.readdir)(dir).then(
|
|
119713
119810
|
(items) => items.filter((item) => item.toLowerCase().includes(base) || base.includes(item.toLowerCase())).map((item) => import_node_path48.default.join(dir, item)).slice(0, 3)
|
|
119714
119811
|
).catch(() => []);
|
|
119715
119812
|
if (suggestions.length > 0) {
|
|
@@ -119723,12 +119820,12 @@ ${suggestions.join("\n")}`
|
|
|
119723
119820
|
throw new ToolFailure(`File not found: ${filepath}`);
|
|
119724
119821
|
}
|
|
119725
119822
|
async function listDirectory(dirpath) {
|
|
119726
|
-
const entries2 = await (0,
|
|
119823
|
+
const entries2 = await (0, import_promises44.readdir)(dirpath, { withFileTypes: true });
|
|
119727
119824
|
const names2 = await Promise.all(
|
|
119728
119825
|
entries2.map(async (entry2) => {
|
|
119729
119826
|
if (entry2.isDirectory()) return `${entry2.name}/`;
|
|
119730
119827
|
if (!entry2.isSymbolicLink()) return entry2.name;
|
|
119731
|
-
const target = await (0,
|
|
119828
|
+
const target = await (0, import_promises44.stat)(import_node_path48.default.join(dirpath, entry2.name)).catch(() => void 0);
|
|
119732
119829
|
return target?.isDirectory() ? `${entry2.name}/` : entry2.name;
|
|
119733
119830
|
})
|
|
119734
119831
|
);
|
|
@@ -119812,7 +119909,7 @@ async function readImage(io, filepath, title, mimeType, size) {
|
|
|
119812
119909
|
details: { title, preview: message2, truncated: false }
|
|
119813
119910
|
};
|
|
119814
119911
|
}
|
|
119815
|
-
const data = (await (0,
|
|
119912
|
+
const data = (await (0, import_promises44.readFile)(filepath)).toString("base64");
|
|
119816
119913
|
const message = "Image read successfully";
|
|
119817
119914
|
return {
|
|
119818
119915
|
output: [
|
|
@@ -119867,7 +119964,7 @@ async function readText2(filepath, title, args, call) {
|
|
|
119867
119964
|
async function execute4(context, io, args) {
|
|
119868
119965
|
const filepath = resolvePath2(context.cwd, args.filePath);
|
|
119869
119966
|
const title = relativeTitle(context.cwd, filepath);
|
|
119870
|
-
const info = await (0,
|
|
119967
|
+
const info = await (0, import_promises44.stat)(filepath).catch(() => void 0);
|
|
119871
119968
|
if (!info) return missing(filepath);
|
|
119872
119969
|
if (info.isDirectory()) return readDirectory(filepath, title, args);
|
|
119873
119970
|
const sample = await readSample(filepath, info.size);
|
|
@@ -119893,12 +119990,12 @@ function createReadTool(cwd) {
|
|
|
119893
119990
|
execute: (args, api, context) => runDurable({ cwd, shells: void 0 }, api, context, (tool, io) => execute4(tool, io, args))
|
|
119894
119991
|
});
|
|
119895
119992
|
}
|
|
119896
|
-
var import_node_fs25,
|
|
119993
|
+
var import_node_fs25, import_promises44, import_node_path48, import_node_readline2, DEFAULT_READ_LIMIT, MAX_LINE_LENGTH, MAX_LINE_SUFFIX, MAX_BYTES, MAX_BYTES_LABEL, SAMPLE_BYTES, MAX_IMAGE_BYTES2, BINARY_EXTENSIONS, readTool2;
|
|
119897
119994
|
var init_read2 = __esm({
|
|
119898
119995
|
"../alan-engine/src/tools/read.ts"() {
|
|
119899
119996
|
"use strict";
|
|
119900
119997
|
import_node_fs25 = require("node:fs");
|
|
119901
|
-
|
|
119998
|
+
import_promises44 = require("node:fs/promises");
|
|
119902
119999
|
import_node_path48 = __toESM(require("node:path"), 1);
|
|
119903
120000
|
import_node_readline2 = require("node:readline");
|
|
119904
120001
|
init_dist4();
|
|
@@ -119949,13 +120046,10 @@ var init_read2 = __esm({
|
|
|
119949
120046
|
});
|
|
119950
120047
|
|
|
119951
120048
|
// ../alan-engine/src/tools/grep.ts
|
|
119952
|
-
function isRecord5(value2) {
|
|
119953
|
-
return typeof value2 === "object" && value2 !== null;
|
|
119954
|
-
}
|
|
119955
120049
|
function isRipgrepMatch(value2) {
|
|
119956
|
-
if (!
|
|
120050
|
+
if (!isObjectLike(value2) || value2.type !== "match" || !isObjectLike(value2.data)) return false;
|
|
119957
120051
|
const { path: file2, lines: lines2, line_number } = value2.data;
|
|
119958
|
-
return
|
|
120052
|
+
return isObjectLike(file2) && typeof file2.text === "string" && isObjectLike(lines2) && typeof lines2.text === "string" && typeof line_number === "number";
|
|
119959
120053
|
}
|
|
119960
120054
|
function clip(text3) {
|
|
119961
120055
|
const line = text3.replace(/\r?\n$/, "");
|
|
@@ -119996,9 +120090,9 @@ async function searchWithRipgrep(binary, root, target, args, signal) {
|
|
|
119996
120090
|
return matches;
|
|
119997
120091
|
}
|
|
119998
120092
|
async function searchFile(file2, regex, matches) {
|
|
119999
|
-
const info = await (0,
|
|
120093
|
+
const info = await (0, import_promises45.stat)(file2).catch(() => void 0);
|
|
120000
120094
|
if (!info?.isFile() || info.size > MAX_FALLBACK_FILE_BYTES) return;
|
|
120001
|
-
const buffer = await (0,
|
|
120095
|
+
const buffer = await (0, import_promises45.readFile)(file2).catch(() => void 0);
|
|
120002
120096
|
if (!buffer || isBinaryFile(file2, buffer.subarray(0, 4096))) return;
|
|
120003
120097
|
const lines2 = buffer.toString("utf8").split("\n");
|
|
120004
120098
|
for (let index = 0; index < lines2.length && matches.length < LIMIT2; index++) {
|
|
@@ -120050,7 +120144,7 @@ function formatGrep(matches) {
|
|
|
120050
120144
|
async function execute5(context, io, args) {
|
|
120051
120145
|
if (!args.pattern) throw new ToolFailure("pattern is required");
|
|
120052
120146
|
const requested = resolvePath2(context.cwd, args.path ?? ".");
|
|
120053
|
-
const info = await (0,
|
|
120147
|
+
const info = await (0, import_promises45.stat)(requested).catch(() => void 0);
|
|
120054
120148
|
if (!info) throw new ToolFailure(`Path not found: ${requested}`);
|
|
120055
120149
|
const root = info.isDirectory() ? requested : import_node_path49.default.dirname(requested);
|
|
120056
120150
|
const single = info.isDirectory() ? void 0 : requested;
|
|
@@ -120071,12 +120165,13 @@ function createGrepTool(cwd) {
|
|
|
120071
120165
|
execute: (args, api, context) => runDurable({ cwd, shells: void 0 }, api, context, (tool, io) => execute5(tool, io, args))
|
|
120072
120166
|
});
|
|
120073
120167
|
}
|
|
120074
|
-
var
|
|
120168
|
+
var import_promises45, import_node_path49, LIMIT2, MAX_LINE_LENGTH2, MAX_FALLBACK_FILE_BYTES, grepTool;
|
|
120075
120169
|
var init_grep = __esm({
|
|
120076
120170
|
"../alan-engine/src/tools/grep.ts"() {
|
|
120077
120171
|
"use strict";
|
|
120078
|
-
|
|
120172
|
+
import_promises45 = require("node:fs/promises");
|
|
120079
120173
|
import_node_path49 = __toESM(require("node:path"), 1);
|
|
120174
|
+
init_type_guards();
|
|
120080
120175
|
init_dist4();
|
|
120081
120176
|
init_durable();
|
|
120082
120177
|
init_glob_match();
|
|
@@ -120143,7 +120238,7 @@ ${render(".", 0)}`;
|
|
|
120143
120238
|
}
|
|
120144
120239
|
async function execute6(context, io, args) {
|
|
120145
120240
|
const search = resolvePath2(context.cwd, args.path ?? ".");
|
|
120146
|
-
const info = await (0,
|
|
120241
|
+
const info = await (0, import_promises46.stat)(search).catch(() => void 0);
|
|
120147
120242
|
if (!info) throw new ToolFailure(`Directory not found: ${search}`);
|
|
120148
120243
|
if (!info.isDirectory()) throw new ToolFailure(`Path is not a directory: ${search}`);
|
|
120149
120244
|
const files = await collectFiles(search, args.ignore ?? [], io.abortSignal);
|
|
@@ -120159,11 +120254,11 @@ function createListTool(cwd) {
|
|
|
120159
120254
|
execute: (args, api, context) => runDurable({ cwd, shells: void 0 }, api, context, (tool, io) => execute6(tool, io, args))
|
|
120160
120255
|
});
|
|
120161
120256
|
}
|
|
120162
|
-
var
|
|
120257
|
+
var import_promises46, import_node_path50, IGNORE_PATTERNS, LIMIT3, listTool;
|
|
120163
120258
|
var init_list = __esm({
|
|
120164
120259
|
"../alan-engine/src/tools/list.ts"() {
|
|
120165
120260
|
"use strict";
|
|
120166
|
-
|
|
120261
|
+
import_promises46 = require("node:fs/promises");
|
|
120167
120262
|
import_node_path50 = __toESM(require("node:path"), 1);
|
|
120168
120263
|
init_dist4();
|
|
120169
120264
|
init_durable();
|
|
@@ -120407,7 +120502,7 @@ async function execute7(skills, args, signal) {
|
|
|
120407
120502
|
}
|
|
120408
120503
|
const dir = info.packageDirectory;
|
|
120409
120504
|
const location = import_node_path51.default.join(dir, "SKILL.md");
|
|
120410
|
-
const markdown = await (0,
|
|
120505
|
+
const markdown = await (0, import_promises47.readFile)(location, "utf8").catch((error62) => {
|
|
120411
120506
|
throw new ToolFailure(
|
|
120412
120507
|
`Skill "${info.name}" has no readable SKILL.md at ${location}: ${String(error62)}`
|
|
120413
120508
|
);
|
|
@@ -120440,11 +120535,11 @@ function createSkillTool(skills) {
|
|
|
120440
120535
|
execute: (args, _api, context) => guard(context, () => execute7(skills, args, context.abortSignal))
|
|
120441
120536
|
});
|
|
120442
120537
|
}
|
|
120443
|
-
var
|
|
120538
|
+
var import_promises47, import_node_path51, DESCRIPTION2, MAX_LISTED_FILES, MAX_SEARCH_RESULTS, parameters2;
|
|
120444
120539
|
var init_skill = __esm({
|
|
120445
120540
|
"../alan-engine/src/tools/skill.ts"() {
|
|
120446
120541
|
"use strict";
|
|
120447
|
-
|
|
120542
|
+
import_promises47 = require("node:fs/promises");
|
|
120448
120543
|
import_node_path51 = __toESM(require("node:path"), 1);
|
|
120449
120544
|
init_dist4();
|
|
120450
120545
|
init_build();
|
|
@@ -120787,9 +120882,6 @@ var init_webfetch = __esm({
|
|
|
120787
120882
|
});
|
|
120788
120883
|
|
|
120789
120884
|
// ../alan-engine/src/tools/websearch.ts
|
|
120790
|
-
function isRecord6(value2) {
|
|
120791
|
-
return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
|
|
120792
|
-
}
|
|
120793
120885
|
function parseJson2(text3) {
|
|
120794
120886
|
try {
|
|
120795
120887
|
return JSON.parse(text3);
|
|
@@ -120802,7 +120894,7 @@ function optionalString(value2) {
|
|
|
120802
120894
|
}
|
|
120803
120895
|
function readRefusal(text3) {
|
|
120804
120896
|
const parsed = parseJson2(text3);
|
|
120805
|
-
if (!
|
|
120897
|
+
if (!isRecord(parsed) || typeof parsed.error !== "string") return void 0;
|
|
120806
120898
|
const retryAfterSeconds = parsed.retryAfterSeconds;
|
|
120807
120899
|
const resetsAt = optionalString(parsed.resetsAt);
|
|
120808
120900
|
const requestId = optionalString(parsed.requestId);
|
|
@@ -120851,8 +120943,8 @@ function truncate4(text3, max) {
|
|
|
120851
120943
|
return trimmed4.length <= max ? trimmed4 : `${trimmed4.slice(0, Math.max(0, max - 1))}\u2026`;
|
|
120852
120944
|
}
|
|
120853
120945
|
function hitsOf(body) {
|
|
120854
|
-
if (!
|
|
120855
|
-
return body.results.filter(
|
|
120946
|
+
if (!isRecord(body) || !Array.isArray(body.results)) return [];
|
|
120947
|
+
return body.results.filter(isRecord).map((item) => ({
|
|
120856
120948
|
...typeof item.url === "string" ? { url: item.url } : {},
|
|
120857
120949
|
...typeof item.title === "string" ? { title: item.title } : {},
|
|
120858
120950
|
...Array.isArray(item.excerpts) ? { excerpts: item.excerpts.filter((part) => typeof part === "string") } : {}
|
|
@@ -120894,7 +120986,7 @@ function createAlanWebSearch(source) {
|
|
|
120894
120986
|
"Web search is unavailable: this session has no Alan credential. Continue without search."
|
|
120895
120987
|
);
|
|
120896
120988
|
}
|
|
120897
|
-
const requestId = (0,
|
|
120989
|
+
const requestId = (0, import_node_crypto28.randomUUID)();
|
|
120898
120990
|
for (let attempt = 0; ; attempt += 1) {
|
|
120899
120991
|
const response = await fetch(`${baseURL}/public/harness/v1/websearch`, {
|
|
120900
120992
|
method: "POST",
|
|
@@ -120943,11 +121035,12 @@ function createWebSearchTool(search) {
|
|
|
120943
121035
|
)
|
|
120944
121036
|
});
|
|
120945
121037
|
}
|
|
120946
|
-
var
|
|
121038
|
+
var import_node_crypto28, DESCRIPTION4, MAX_RESULTS, MAX_AUTO_RETRIES2, MAX_AUTO_RETRY_WAIT_MS, parameters4;
|
|
120947
121039
|
var init_websearch = __esm({
|
|
120948
121040
|
"../alan-engine/src/tools/websearch.ts"() {
|
|
120949
121041
|
"use strict";
|
|
120950
|
-
|
|
121042
|
+
import_node_crypto28 = require("node:crypto");
|
|
121043
|
+
init_type_guards();
|
|
120951
121044
|
init_dist4();
|
|
120952
121045
|
init_build();
|
|
120953
121046
|
init_credentials();
|
|
@@ -120967,14 +121060,14 @@ async function execute9(context, io, args) {
|
|
|
120967
121060
|
const filepath = resolvePath2(context.cwd, args.filePath);
|
|
120968
121061
|
const title = relativeTitle(context.cwd, filepath);
|
|
120969
121062
|
return withFileLock(filepath, async () => {
|
|
120970
|
-
const info = await (0,
|
|
121063
|
+
const info = await (0, import_promises48.stat)(filepath).catch(() => void 0);
|
|
120971
121064
|
if (info?.isDirectory()) throw new ToolFailure(`Path is a directory, not a file: ${filepath}`);
|
|
120972
121065
|
const exists4 = info !== void 0;
|
|
120973
121066
|
if (info !== void 0) await assertUnchangedSinceRead(context, filepath, info);
|
|
120974
|
-
const before = exists4 ? await (0,
|
|
121067
|
+
const before = exists4 ? await (0, import_promises48.readFile)(filepath, "utf8") : "";
|
|
120975
121068
|
io.abortSignal?.throwIfAborted();
|
|
120976
|
-
await (0,
|
|
120977
|
-
await (0,
|
|
121069
|
+
await (0, import_promises48.mkdir)(import_node_path52.default.dirname(filepath), { recursive: true });
|
|
121070
|
+
await (0, import_promises48.writeFile)(filepath, args.content, "utf8");
|
|
120978
121071
|
await recordFileStamp(context, filepath);
|
|
120979
121072
|
const stats = diffStats(before, args.content);
|
|
120980
121073
|
return textResult2(exists4 ? "Wrote file successfully." : "Created file successfully.", {
|
|
@@ -120993,11 +121086,11 @@ function createWriteTool(cwd) {
|
|
|
120993
121086
|
execute: (args, api, context) => runDurable({ cwd, shells: void 0 }, api, context, (tool, io) => execute9(tool, io, args))
|
|
120994
121087
|
});
|
|
120995
121088
|
}
|
|
120996
|
-
var
|
|
121089
|
+
var import_promises48, import_node_path52, writeTool;
|
|
120997
121090
|
var init_write = __esm({
|
|
120998
121091
|
"../alan-engine/src/tools/write.ts"() {
|
|
120999
121092
|
"use strict";
|
|
121000
|
-
|
|
121093
|
+
import_promises48 = require("node:fs/promises");
|
|
121001
121094
|
import_node_path52 = __toESM(require("node:path"), 1);
|
|
121002
121095
|
init_dist4();
|
|
121003
121096
|
init_diff();
|
|
@@ -121346,6 +121439,14 @@ function sessionPaths(dir, sessionId) {
|
|
|
121346
121439
|
const root = (0, import_node_path54.join)(dir, sessionId);
|
|
121347
121440
|
return { root, database: (0, import_node_path54.join)(root, "session.sqlite"), lock: (0, import_node_path54.join)(root, "session.lock") };
|
|
121348
121441
|
}
|
|
121442
|
+
function deliver(listener, event) {
|
|
121443
|
+
try {
|
|
121444
|
+
listener(event);
|
|
121445
|
+
return true;
|
|
121446
|
+
} catch {
|
|
121447
|
+
return false;
|
|
121448
|
+
}
|
|
121449
|
+
}
|
|
121349
121450
|
function webSearchOf(options) {
|
|
121350
121451
|
const source = options.webSearch;
|
|
121351
121452
|
if (source === false) {
|
|
@@ -121395,7 +121496,7 @@ async function openEngineSession(options) {
|
|
|
121395
121496
|
if (options.maxTurns !== void 0 && (!Number.isInteger(options.maxTurns) || options.maxTurns < 1))
|
|
121396
121497
|
throw new RangeError("maxTurns must be a positive integer");
|
|
121397
121498
|
const paths = sessionPaths(options.dir, options.sessionId);
|
|
121398
|
-
await (0,
|
|
121499
|
+
await (0, import_promises49.mkdir)(paths.root, { recursive: true });
|
|
121399
121500
|
const lock = await acquireSessionLock(paths.lock);
|
|
121400
121501
|
let mcp;
|
|
121401
121502
|
try {
|
|
@@ -121432,11 +121533,11 @@ async function openEngineSession(options) {
|
|
|
121432
121533
|
throw error62;
|
|
121433
121534
|
}
|
|
121434
121535
|
}
|
|
121435
|
-
var
|
|
121536
|
+
var import_promises49, import_node_path54, ctx, ENTRY_PAGE, USER_SHELL_ENTRY_KIND, DurableEngineSession;
|
|
121436
121537
|
var init_session7 = __esm({
|
|
121437
121538
|
"../alan-engine/src/engine/session.ts"() {
|
|
121438
121539
|
"use strict";
|
|
121439
|
-
|
|
121540
|
+
import_promises49 = require("node:fs/promises");
|
|
121440
121541
|
import_node_path54 = require("node:path");
|
|
121441
121542
|
init_context();
|
|
121442
121543
|
init_dist4();
|
|
@@ -121534,12 +121635,7 @@ var init_session7 = __esm({
|
|
|
121534
121635
|
this.#emit(event);
|
|
121535
121636
|
}
|
|
121536
121637
|
#emit(event) {
|
|
121537
|
-
for (const listener of this.#listeners)
|
|
121538
|
-
try {
|
|
121539
|
-
listener(event);
|
|
121540
|
-
} catch {
|
|
121541
|
-
}
|
|
121542
|
-
}
|
|
121638
|
+
for (const listener of this.#listeners) deliver(listener, event);
|
|
121543
121639
|
}
|
|
121544
121640
|
#scheduleDeadline() {
|
|
121545
121641
|
if (this.#deadline === void 0) return;
|
|
@@ -121803,7 +121899,7 @@ function isAlanPiSessionOf(ref, conversationId) {
|
|
|
121803
121899
|
return ref === alanPiSessionRef(conversationId) || ref === conversationId;
|
|
121804
121900
|
}
|
|
121805
121901
|
function digest(text3) {
|
|
121806
|
-
return (0,
|
|
121902
|
+
return (0, import_node_crypto29.createHash)("sha256").update(text3).digest("hex");
|
|
121807
121903
|
}
|
|
121808
121904
|
function settledOutcome2(outcome2) {
|
|
121809
121905
|
return outcome2.status;
|
|
@@ -121838,18 +121934,18 @@ async function trackNativeTurn(port, sessionRef, operation, text3) {
|
|
|
121838
121934
|
async function attachNativeSession(observer, observation3) {
|
|
121839
121935
|
await observer.attach({
|
|
121840
121936
|
nativeSessionId: observation3.sessionRef,
|
|
121841
|
-
epoch: (0,
|
|
121937
|
+
epoch: (0, import_node_crypto29.randomUUID)(),
|
|
121842
121938
|
version: ALAN_PI_IDENTITY_VERSION,
|
|
121843
121939
|
empty: observation3.created,
|
|
121844
121940
|
created: observation3.created,
|
|
121845
121941
|
freshOwnedEngine: true
|
|
121846
121942
|
});
|
|
121847
121943
|
}
|
|
121848
|
-
var
|
|
121944
|
+
var import_node_crypto29, ALAN_PI_SESSION_REF_PREFIX, ALAN_PI_IDENTITY_VERSION;
|
|
121849
121945
|
var init_alan_pi_identity = __esm({
|
|
121850
121946
|
"src/holder/drivers/alan-pi-identity.ts"() {
|
|
121851
121947
|
"use strict";
|
|
121852
|
-
|
|
121948
|
+
import_node_crypto29 = require("node:crypto");
|
|
121853
121949
|
ALAN_PI_SESSION_REF_PREFIX = "alan-pi:v1:";
|
|
121854
121950
|
ALAN_PI_IDENTITY_VERSION = "alan-pi-durable-1";
|
|
121855
121951
|
}
|
|
@@ -122208,11 +122304,8 @@ var init_alan_pi_requests = __esm({
|
|
|
122208
122304
|
});
|
|
122209
122305
|
|
|
122210
122306
|
// src/holder/drivers/alan-pi-tools.ts
|
|
122211
|
-
function isRecord7(value2) {
|
|
122212
|
-
return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
|
|
122213
|
-
}
|
|
122214
122307
|
function field2(record3, key) {
|
|
122215
|
-
const value2 =
|
|
122308
|
+
const value2 = isRecord(record3) ? record3[key] : void 0;
|
|
122216
122309
|
return typeof value2 === "string" ? value2.trim() : "";
|
|
122217
122310
|
}
|
|
122218
122311
|
function kindOf(name) {
|
|
@@ -122260,7 +122353,7 @@ function locationsOf(name, args, context) {
|
|
|
122260
122353
|
const path19 = field2(args, "filePath") || field2(args, "path");
|
|
122261
122354
|
if (path19 === "" || kindOf(name) === "execute" || kindOf(name) === "fetch") return void 0;
|
|
122262
122355
|
const absolute = (0, import_node_path55.isAbsolute)(path19) ? path19 : (0, import_node_path55.resolve)(context.cwd, path19);
|
|
122263
|
-
const offset =
|
|
122356
|
+
const offset = isRecord(args) ? args.offset : void 0;
|
|
122264
122357
|
return [typeof offset === "number" ? { path: absolute, line: offset } : { path: absolute }];
|
|
122265
122358
|
}
|
|
122266
122359
|
function questionOf(args) {
|
|
@@ -122274,7 +122367,7 @@ function questionOf(args) {
|
|
|
122274
122367
|
const description2 = field2(option2, "description");
|
|
122275
122368
|
return label3 === "" ? [] : [description2 === "" ? { label: label3 } : { label: label3, description: description2 }];
|
|
122276
122369
|
}),
|
|
122277
|
-
multiSelect:
|
|
122370
|
+
multiSelect: isRecord(args) && args.multiple === true
|
|
122278
122371
|
};
|
|
122279
122372
|
}
|
|
122280
122373
|
function toolStartUpdate(toolCallId, name, args, context) {
|
|
@@ -122296,10 +122389,10 @@ function toolStartUpdate(toolCallId, name, args, context) {
|
|
|
122296
122389
|
function fileChange2(result) {
|
|
122297
122390
|
if (result.isError || result.toolName !== "edit" && result.toolName !== "write") return [];
|
|
122298
122391
|
const path19 = field2(result.details, "filepath");
|
|
122299
|
-
const diff =
|
|
122392
|
+
const diff = isRecord(result.details) ? result.details.diff : void 0;
|
|
122300
122393
|
const patchText = typeof diff === "string" ? diff : "";
|
|
122301
122394
|
if (path19 === "") return [];
|
|
122302
|
-
const created = result.toolName === "write" &&
|
|
122395
|
+
const created = result.toolName === "write" && isRecord(result.details) && result.details.exists === false;
|
|
122303
122396
|
return [
|
|
122304
122397
|
fileChangeContent({
|
|
122305
122398
|
path: path19,
|
|
@@ -122317,7 +122410,7 @@ function planUpdate(result) {
|
|
|
122317
122410
|
if (result.isError || result.toolName !== "todowrite" && result.toolName !== "todoread") {
|
|
122318
122411
|
return [];
|
|
122319
122412
|
}
|
|
122320
|
-
const todos =
|
|
122413
|
+
const todos = isRecord(result.details) ? result.details.todos : void 0;
|
|
122321
122414
|
return Array.isArray(todos) ? [todoPlanUpdate(result.toolCallId, todos)] : [];
|
|
122322
122415
|
}
|
|
122323
122416
|
function toolEndUpdates(result, context) {
|
|
@@ -122343,6 +122436,7 @@ var init_alan_pi_tools = __esm({
|
|
|
122343
122436
|
"use strict";
|
|
122344
122437
|
import_node_path55 = require("node:path");
|
|
122345
122438
|
init_acp2();
|
|
122439
|
+
init_type_guards();
|
|
122346
122440
|
TASK_RESULT = /^<(task_result|task_error)>\n?([\s\S]*?)\n?<\/\1>$/;
|
|
122347
122441
|
KINDS = {
|
|
122348
122442
|
bash_output: "execute",
|
|
@@ -122436,6 +122530,10 @@ var init_alan_pi_updates = __esm({
|
|
|
122436
122530
|
this.#textOpen = false;
|
|
122437
122531
|
this.#ended.add(event.toolCallId);
|
|
122438
122532
|
return toolEndUpdates(event, this.#context);
|
|
122533
|
+
case "input_placed":
|
|
122534
|
+
this.#textOpen = false;
|
|
122535
|
+
this.#thoughtOpen = false;
|
|
122536
|
+
return [];
|
|
122439
122537
|
default:
|
|
122440
122538
|
return [];
|
|
122441
122539
|
}
|
|
@@ -122611,6 +122709,8 @@ var init_alan_pi_session = __esm({
|
|
|
122611
122709
|
shell: new AbortController(),
|
|
122612
122710
|
updates: new AlanPiTurnUpdates(input2.turnId, this.#options.engine.cwd),
|
|
122613
122711
|
steers: /* @__PURE__ */ new Map(),
|
|
122712
|
+
unplacedSteers: /* @__PURE__ */ new Map(),
|
|
122713
|
+
placedInputs: /* @__PURE__ */ new Set(),
|
|
122614
122714
|
runs: { started: 0, ended: 0 },
|
|
122615
122715
|
settling: false,
|
|
122616
122716
|
cancelRequested: false,
|
|
@@ -122753,7 +122853,9 @@ var init_alan_pi_session = __esm({
|
|
|
122753
122853
|
});
|
|
122754
122854
|
turn.steers.set(input2.steerId, submitted);
|
|
122755
122855
|
try {
|
|
122756
|
-
await submitted;
|
|
122856
|
+
const { id } = await submitted;
|
|
122857
|
+
if (turn.placedInputs.has(id)) this.#steerPlaced(turn, input2.steerId);
|
|
122858
|
+
else turn.unplacedSteers.set(id, input2.steerId);
|
|
122757
122859
|
} catch (error62) {
|
|
122758
122860
|
turn.steers.delete(input2.steerId);
|
|
122759
122861
|
this.#options.log.warn("alan_pi.steer_failed", { turnId: turn.id, error: String(error62) });
|
|
@@ -122761,7 +122863,6 @@ var init_alan_pi_session = __esm({
|
|
|
122761
122863
|
}
|
|
122762
122864
|
return "delivered";
|
|
122763
122865
|
}
|
|
122764
|
-
/** Answers a parked approval or question; throws when it is no longer waiting. */
|
|
122765
122866
|
async respond(toolCallId, answer2) {
|
|
122766
122867
|
const request3 = this.#requests.get(toolCallId);
|
|
122767
122868
|
if (request3 === void 0) throw new Error(`Alan Code is not waiting on ${toolCallId}`);
|
|
@@ -122879,11 +122980,26 @@ var init_alan_pi_session = __esm({
|
|
|
122879
122980
|
case "request_settled":
|
|
122880
122981
|
this.#requestSettled(turn, event);
|
|
122881
122982
|
return;
|
|
122983
|
+
case "input_placed":
|
|
122984
|
+
this.#inputPlaced(turn, event.submissionId);
|
|
122985
|
+
break;
|
|
122882
122986
|
default:
|
|
122883
122987
|
break;
|
|
122884
122988
|
}
|
|
122885
122989
|
for (const update of turn.updates.map(event)) this.#update(turn, update);
|
|
122886
122990
|
}
|
|
122991
|
+
#inputPlaced(turn, submissionId) {
|
|
122992
|
+
const steerId = turn.unplacedSteers.get(submissionId);
|
|
122993
|
+
if (steerId === void 0) {
|
|
122994
|
+
turn.placedInputs.add(submissionId);
|
|
122995
|
+
return;
|
|
122996
|
+
}
|
|
122997
|
+
turn.unplacedSteers.delete(submissionId);
|
|
122998
|
+
this.#steerPlaced(turn, steerId);
|
|
122999
|
+
}
|
|
123000
|
+
#steerPlaced(turn, steerId) {
|
|
123001
|
+
this.#emit({ type: "steer_placed", turnId: turn.id, steerId });
|
|
123002
|
+
}
|
|
122887
123003
|
#park(turn, request3) {
|
|
122888
123004
|
const cardId = requestCardId(request3);
|
|
122889
123005
|
this.#requests.set(cardId, request3);
|
|
@@ -123026,7 +123142,7 @@ function alanMcpServer(managedMcp, conversationId) {
|
|
|
123026
123142
|
}
|
|
123027
123143
|
async function exists2(path19) {
|
|
123028
123144
|
try {
|
|
123029
|
-
await (0,
|
|
123145
|
+
await (0, import_promises50.access)(path19);
|
|
123030
123146
|
return true;
|
|
123031
123147
|
} catch {
|
|
123032
123148
|
return false;
|
|
@@ -123210,11 +123326,11 @@ function createAlanPiHolderDriver(options) {
|
|
|
123210
123326
|
}
|
|
123211
123327
|
};
|
|
123212
123328
|
}
|
|
123213
|
-
var
|
|
123329
|
+
var import_promises50, SAFE_COMMANDS, NO_CREDENTIAL;
|
|
123214
123330
|
var init_alan_pi = __esm({
|
|
123215
123331
|
"src/holder/drivers/alan-pi.ts"() {
|
|
123216
123332
|
"use strict";
|
|
123217
|
-
|
|
123333
|
+
import_promises50 = require("node:fs/promises");
|
|
123218
123334
|
init_src();
|
|
123219
123335
|
init_classify2();
|
|
123220
123336
|
init_mcp2();
|
|
@@ -123479,7 +123595,7 @@ __export(codex_exports, {
|
|
|
123479
123595
|
createCodexHolderDriver: () => createCodexHolderDriver
|
|
123480
123596
|
});
|
|
123481
123597
|
function sha2563(value2) {
|
|
123482
|
-
return (0,
|
|
123598
|
+
return (0, import_node_crypto30.createHash)("sha256").update(value2).digest("hex");
|
|
123483
123599
|
}
|
|
123484
123600
|
function createCodexLogin(broker) {
|
|
123485
123601
|
const state2 = {};
|
|
@@ -123559,11 +123675,11 @@ function createCodexHolderDriver(options) {
|
|
|
123559
123675
|
}
|
|
123560
123676
|
);
|
|
123561
123677
|
}
|
|
123562
|
-
var
|
|
123678
|
+
var import_node_crypto30;
|
|
123563
123679
|
var init_codex2 = __esm({
|
|
123564
123680
|
"src/holder/drivers/codex.ts"() {
|
|
123565
123681
|
"use strict";
|
|
123566
|
-
|
|
123682
|
+
import_node_crypto30 = require("node:crypto");
|
|
123567
123683
|
init_src();
|
|
123568
123684
|
init_codex();
|
|
123569
123685
|
init_persistent();
|
|
@@ -123687,7 +123803,7 @@ function parseConfig(raw) {
|
|
|
123687
123803
|
}
|
|
123688
123804
|
async function writeCommandCodeProjectMcp(cwd, mcp) {
|
|
123689
123805
|
const path19 = (0, import_node_path57.join)(cwd, ".mcp.json");
|
|
123690
|
-
const original = await (0,
|
|
123806
|
+
const original = await (0, import_promises51.readFile)(path19, "utf8").catch(() => null);
|
|
123691
123807
|
const config2 = parseConfig(original);
|
|
123692
123808
|
const next = {
|
|
123693
123809
|
...config2,
|
|
@@ -123704,19 +123820,19 @@ async function writeCommandCodeProjectMcp(cwd, mcp) {
|
|
|
123704
123820
|
}
|
|
123705
123821
|
}
|
|
123706
123822
|
};
|
|
123707
|
-
await (0,
|
|
123708
|
-
await (0,
|
|
123823
|
+
await (0, import_promises51.mkdir)(cwd, { recursive: true });
|
|
123824
|
+
await (0, import_promises51.writeFile)(path19, `${JSON.stringify(next, null, 2)}
|
|
123709
123825
|
`);
|
|
123710
123826
|
return async () => {
|
|
123711
|
-
if (original === null) await (0,
|
|
123712
|
-
else await (0,
|
|
123827
|
+
if (original === null) await (0, import_promises51.rm)(path19, { force: true });
|
|
123828
|
+
else await (0, import_promises51.writeFile)(path19, original);
|
|
123713
123829
|
};
|
|
123714
123830
|
}
|
|
123715
|
-
var
|
|
123831
|
+
var import_promises51, import_node_path57;
|
|
123716
123832
|
var init_project_mcp = __esm({
|
|
123717
123833
|
"../agent-core/src/providers/command-code/project-mcp.ts"() {
|
|
123718
123834
|
"use strict";
|
|
123719
|
-
|
|
123835
|
+
import_promises51 = require("node:fs/promises");
|
|
123720
123836
|
import_node_path57 = require("node:path");
|
|
123721
123837
|
init_agent2();
|
|
123722
123838
|
init_runtime_v2();
|
|
@@ -124011,10 +124127,7 @@ var init_background_tasks2 = __esm({
|
|
|
124011
124127
|
}
|
|
124012
124128
|
return updates;
|
|
124013
124129
|
}
|
|
124014
|
-
|
|
124015
|
-
* The CLI exited: its subagents died with it, and its shells can no longer be observed.
|
|
124016
|
-
* A shell whose process is still there really is still running, so it keeps its status.
|
|
124017
|
-
*/
|
|
124130
|
+
// quirk: its subagents die with the CLI and its shells cannot be observed; a shell whose process is still there keeps its status.
|
|
124018
124131
|
afterExit() {
|
|
124019
124132
|
const updates = [];
|
|
124020
124133
|
for (const [launcher, task] of this.#tasks) {
|
|
@@ -124195,7 +124308,6 @@ var init_turn7 = __esm({
|
|
|
124195
124308
|
return [...this.#onResult(frame.event), ...updates, ...background];
|
|
124196
124309
|
return [...updates, ...frame.event ? this.#onEvent(frame.event) : [], ...background];
|
|
124197
124310
|
}
|
|
124198
|
-
/** The CLI is gone, so its shells can no longer be watched: settle the ones that ended. */
|
|
124199
124311
|
afterExit() {
|
|
124200
124312
|
return this.#background.afterExit();
|
|
124201
124313
|
}
|
|
@@ -124371,11 +124483,6 @@ var init_driver8 = __esm({
|
|
|
124371
124483
|
});
|
|
124372
124484
|
|
|
124373
124485
|
// ../agent-core/src/providers/command-code/run.ts
|
|
124374
|
-
function envDigest8(env) {
|
|
124375
|
-
const hash2 = (0, import_node_crypto37.createHash)("sha256");
|
|
124376
|
-
for (const key of Object.keys(env).sort()) hash2.update(`${key}\0${env[key]}\0`);
|
|
124377
|
-
return hash2.digest("hex");
|
|
124378
|
-
}
|
|
124379
124486
|
function permissionsOf(run3) {
|
|
124380
124487
|
if (!isReadOnlyMode(run3.mode) && !isReadOnlyAgent(run3.agentId)) return "yolo";
|
|
124381
124488
|
return run3.mode === "plan" || run3.mode === "review" ? "plan" : "default";
|
|
@@ -124399,8 +124506,7 @@ function planCommandCodeSession(run3, context) {
|
|
|
124399
124506
|
cwd: context.cwd,
|
|
124400
124507
|
env,
|
|
124401
124508
|
...shape,
|
|
124402
|
-
...prompts
|
|
124403
|
-
...prompts.systemPromptAppend ? { systemPromptAppend: prompts.systemPromptAppend } : {},
|
|
124509
|
+
...systemPromptFields(prompts),
|
|
124404
124510
|
...context.resumeSessionId ? { resumeSessionId: context.resumeSessionId } : {},
|
|
124405
124511
|
...managed ? { mcp: { url: managed.url, conversationId: run3.conversationId } } : {}
|
|
124406
124512
|
};
|
|
@@ -124413,26 +124519,17 @@ function planCommandCodeSession(run3, context) {
|
|
|
124413
124519
|
cwd: context.cwd,
|
|
124414
124520
|
shape,
|
|
124415
124521
|
mcp: managed ? { url: managed.url, credential: credentialDigest(managed.authorization) } : null,
|
|
124416
|
-
env:
|
|
124522
|
+
env: envDigest(cliEnv)
|
|
124417
124523
|
});
|
|
124418
124524
|
return { spec, key, skippedMcpEnvKeys: [], skippedMcpServers };
|
|
124419
124525
|
}
|
|
124420
124526
|
function commandCodeTurnInput(run3, context) {
|
|
124421
|
-
const images =
|
|
124422
|
-
const files = context.attachments.filter((attachment) => attachment.kind === "file");
|
|
124423
|
-
const text3 = buildTurnText({
|
|
124424
|
-
spec: run3,
|
|
124425
|
-
files,
|
|
124426
|
-
skills: context.skills,
|
|
124427
|
-
...context.contextPrefix === void 0 ? {} : { contextPrefix: context.contextPrefix }
|
|
124428
|
-
});
|
|
124527
|
+
const { text: text3, images } = buildAttachmentTurnText(run3, context);
|
|
124429
124528
|
return { turnId: run3.runId, text: appendImagePathReferences(text3, images) };
|
|
124430
124529
|
}
|
|
124431
|
-
var import_node_crypto37;
|
|
124432
124530
|
var init_run7 = __esm({
|
|
124433
124531
|
"../agent-core/src/providers/command-code/run.ts"() {
|
|
124434
124532
|
"use strict";
|
|
124435
|
-
import_node_crypto37 = require("node:crypto");
|
|
124436
124533
|
init_agent2();
|
|
124437
124534
|
init_mcp2();
|
|
124438
124535
|
init_prompt();
|
|
@@ -125626,18 +125723,18 @@ function createConversationMcpAuthorization(options) {
|
|
|
125626
125723
|
}
|
|
125627
125724
|
|
|
125628
125725
|
// src/holder/mcp-helper-access.ts
|
|
125629
|
-
var
|
|
125726
|
+
var import_promises52 = require("node:fs/promises");
|
|
125630
125727
|
init_kernel();
|
|
125631
125728
|
function createHelperMcpAccess(options) {
|
|
125632
125729
|
return {
|
|
125633
125730
|
[Symbol.asyncDispose]: async () => {
|
|
125634
|
-
await (0,
|
|
125731
|
+
await (0, import_promises52.rm)(options.credentialPath, { force: true });
|
|
125635
125732
|
},
|
|
125636
125733
|
url: options.managedMcp.url,
|
|
125637
125734
|
authorization: async (signal) => {
|
|
125638
125735
|
const authorization = await options.managedMcp.authorization(signal);
|
|
125639
125736
|
if (authorization === void 0 || signal.aborted) {
|
|
125640
|
-
await (0,
|
|
125737
|
+
await (0, import_promises52.rm)(options.credentialPath, { force: true });
|
|
125641
125738
|
return void 0;
|
|
125642
125739
|
}
|
|
125643
125740
|
const credential = {
|
|
@@ -125652,8 +125749,8 @@ function createHelperMcpAccess(options) {
|
|
|
125652
125749
|
}
|
|
125653
125750
|
|
|
125654
125751
|
// src/holder/native-turn-bindings.ts
|
|
125655
|
-
var
|
|
125656
|
-
var
|
|
125752
|
+
var import_node_crypto31 = require("node:crypto");
|
|
125753
|
+
var import_promises54 = require("node:fs/promises");
|
|
125657
125754
|
var import_node_path60 = require("node:path");
|
|
125658
125755
|
init_runtime_v2();
|
|
125659
125756
|
init_zod();
|
|
@@ -125662,7 +125759,7 @@ init_platform();
|
|
|
125662
125759
|
init_alan_pi_identity();
|
|
125663
125760
|
|
|
125664
125761
|
// src/holder/prepared-session-state.ts
|
|
125665
|
-
var
|
|
125762
|
+
var import_promises53 = require("node:fs/promises");
|
|
125666
125763
|
var import_node_path59 = require("node:path");
|
|
125667
125764
|
init_runtime_v2();
|
|
125668
125765
|
init_zod();
|
|
@@ -125700,8 +125797,8 @@ async function writePreparedIdentity(directory, binding, providerSessionId) {
|
|
|
125700
125797
|
binding,
|
|
125701
125798
|
providerSessionId
|
|
125702
125799
|
});
|
|
125703
|
-
await (0,
|
|
125704
|
-
await (0,
|
|
125800
|
+
await (0, import_promises53.mkdir)(directory, { recursive: true, mode: 448 });
|
|
125801
|
+
await (0, import_promises53.chmod)(directory, 448);
|
|
125705
125802
|
await writeJsonFileAtomic((0, import_node_path59.join)(directory, "engine-session.json"), value2);
|
|
125706
125803
|
await createMetadataDurability().sync(directory);
|
|
125707
125804
|
}
|
|
@@ -125783,7 +125880,7 @@ var bindingSchema = external_exports.strictObject({
|
|
|
125783
125880
|
}).optional()
|
|
125784
125881
|
});
|
|
125785
125882
|
function digest2(value2) {
|
|
125786
|
-
return (0,
|
|
125883
|
+
return (0, import_node_crypto31.createHash)("sha256").update(JSON.stringify(value2)).digest("hex");
|
|
125787
125884
|
}
|
|
125788
125885
|
function unavailable2() {
|
|
125789
125886
|
return new Error("Native identity requires explicit recovery");
|
|
@@ -125940,15 +126037,15 @@ async function openNativeTurnBindings(options) {
|
|
|
125940
126037
|
const { directory, machineId, conversationId } = options;
|
|
125941
126038
|
const runDirectory2 = (0, import_node_path60.join)(directory, "native-turn-bindings");
|
|
125942
126039
|
const orderPath = (0, import_node_path60.join)(directory, "native-message-order.json");
|
|
125943
|
-
await (0,
|
|
125944
|
-
await (0,
|
|
125945
|
-
await (0,
|
|
126040
|
+
await (0, import_promises54.mkdir)(runDirectory2, { recursive: true, mode: 448 });
|
|
126041
|
+
await (0, import_promises54.chmod)(directory, 448);
|
|
126042
|
+
await (0, import_promises54.chmod)(runDirectory2, 448);
|
|
125946
126043
|
await createMetadataDurability().sync(directory);
|
|
125947
126044
|
const stored = await readJsonFile(orderPath, projectionSchema);
|
|
125948
126045
|
if (stored.kind === "invalid") throw unavailable2();
|
|
125949
126046
|
let projection = stored.kind === "ok" ? stored.value : void 0;
|
|
125950
126047
|
const unresolved = /* @__PURE__ */ new Set();
|
|
125951
|
-
const names2 = await (0,
|
|
126048
|
+
const names2 = await (0, import_promises54.readdir)(runDirectory2);
|
|
125952
126049
|
for (const name of names2.filter((entry2) => entry2.endsWith(".json"))) {
|
|
125953
126050
|
const item = await readJsonFile((0, import_node_path60.join)(runDirectory2, name), bindingSchema);
|
|
125954
126051
|
if (item.kind !== "ok" || item.value.machineId !== machineId || item.value.conversationId !== conversationId || name !== `${item.value.runId}.json`)
|
|
@@ -126093,25 +126190,25 @@ async function openNativeTurnBindings(options) {
|
|
|
126093
126190
|
}
|
|
126094
126191
|
|
|
126095
126192
|
// src/holder/requested-checkout.ts
|
|
126096
|
-
var
|
|
126193
|
+
var import_promises56 = require("node:fs/promises");
|
|
126097
126194
|
var import_node_path62 = require("node:path");
|
|
126098
126195
|
init_capabilities3();
|
|
126099
126196
|
|
|
126100
126197
|
// src/holder/claim-once.ts
|
|
126101
|
-
var
|
|
126102
|
-
var
|
|
126198
|
+
var import_node_crypto32 = require("node:crypto");
|
|
126199
|
+
var import_promises55 = require("node:fs/promises");
|
|
126103
126200
|
var import_node_path61 = require("node:path");
|
|
126104
126201
|
async function claimOnce(dir, name) {
|
|
126105
126202
|
try {
|
|
126106
|
-
await (0,
|
|
126107
|
-
await (await (0,
|
|
126203
|
+
await (0, import_promises55.mkdir)(dir, { recursive: true, mode: 448 });
|
|
126204
|
+
await (await (0, import_promises55.open)((0, import_node_path61.join)(dir, name), "wx")).close();
|
|
126108
126205
|
return true;
|
|
126109
126206
|
} catch {
|
|
126110
126207
|
return false;
|
|
126111
126208
|
}
|
|
126112
126209
|
}
|
|
126113
126210
|
function claimFirstLease(freshnessDir, path19) {
|
|
126114
|
-
return claimOnce((0, import_node_path61.join)(freshnessDir, "leased"), (0,
|
|
126211
|
+
return claimOnce((0, import_node_path61.join)(freshnessDir, "leased"), (0, import_node_crypto32.createHash)("sha256").update(path19).digest("hex"));
|
|
126115
126212
|
}
|
|
126116
126213
|
|
|
126117
126214
|
// src/holder/requested-checkout.ts
|
|
@@ -126136,7 +126233,7 @@ function notSwitched(checkout, current, reason) {
|
|
|
126136
126233
|
}
|
|
126137
126234
|
async function clone2(checkout, deps, signal) {
|
|
126138
126235
|
const parent = (0, import_node_path62.dirname)(checkout.path);
|
|
126139
|
-
await (0,
|
|
126236
|
+
await (0, import_promises56.mkdir)(parent, { recursive: true });
|
|
126140
126237
|
await assertValidBranch(deps.git, parent, checkout.branch, signal);
|
|
126141
126238
|
const output2 = await deps.git.run(
|
|
126142
126239
|
{
|
|
@@ -126283,7 +126380,7 @@ async function applyRequestedCheckout(checkout, operationId, deps, signal) {
|
|
|
126283
126380
|
}
|
|
126284
126381
|
|
|
126285
126382
|
// src/holder/run-inputs.ts
|
|
126286
|
-
var
|
|
126383
|
+
var import_promises57 = require("node:fs/promises");
|
|
126287
126384
|
var import_node_path63 = require("node:path");
|
|
126288
126385
|
init_src();
|
|
126289
126386
|
var NO_RUN_INPUTS = {
|
|
@@ -126321,7 +126418,7 @@ async function prepareRunInputs(spec, { source, tmpDir, signal, skills = [], com
|
|
|
126321
126418
|
await commitAttribution?.setCoAuthor(spec.gitCoAuthor);
|
|
126322
126419
|
const dir = (0, import_node_path63.join)(tmpDir, "runs", spec.runId);
|
|
126323
126420
|
const cleanup = async () => {
|
|
126324
|
-
await (0,
|
|
126421
|
+
await (0, import_promises57.rm)(dir, { recursive: true, force: true });
|
|
126325
126422
|
};
|
|
126326
126423
|
try {
|
|
126327
126424
|
const credential = await source.fetchProviderCredential(spec.runId, signal);
|
|
@@ -126329,8 +126426,8 @@ async function prepareRunInputs(spec, { source, tmpDir, signal, skills = [], com
|
|
|
126329
126426
|
for (const [index, attachment] of (spec.attachments ?? []).entries()) {
|
|
126330
126427
|
const bytes2 = await source.downloadAttachment(spec.runId, attachment.id, signal);
|
|
126331
126428
|
const path19 = attachmentPath(spec, attachment, index, dir);
|
|
126332
|
-
await (0,
|
|
126333
|
-
await (0,
|
|
126429
|
+
await (0, import_promises57.mkdir)((0, import_node_path63.dirname)(path19), { recursive: true, mode: 448 });
|
|
126430
|
+
await (0, import_promises57.writeFile)(path19, bytes2, { mode: 384 });
|
|
126334
126431
|
const imageMimeType = attachment.kind === "image" ? detectImageMimeType(Buffer.from(bytes2.buffer, bytes2.byteOffset, bytes2.byteLength)) : null;
|
|
126335
126432
|
attachments.push({
|
|
126336
126433
|
id: attachment.id,
|
|
@@ -126360,7 +126457,7 @@ async function prepareRunInputs(spec, { source, tmpDir, signal, skills = [], com
|
|
|
126360
126457
|
}
|
|
126361
126458
|
|
|
126362
126459
|
// src/holder/serve.ts
|
|
126363
|
-
var
|
|
126460
|
+
var import_node_crypto34 = require("node:crypto");
|
|
126364
126461
|
var import_node_net = require("node:net");
|
|
126365
126462
|
var import_node_path72 = require("node:path");
|
|
126366
126463
|
init_runtime_v2();
|
|
@@ -126369,7 +126466,7 @@ init_platform();
|
|
|
126369
126466
|
|
|
126370
126467
|
// src/holder/admission.ts
|
|
126371
126468
|
var import_node_fs26 = require("node:fs");
|
|
126372
|
-
var
|
|
126469
|
+
var import_promises60 = require("node:fs/promises");
|
|
126373
126470
|
var import_node_os10 = require("node:os");
|
|
126374
126471
|
var import_node_path68 = require("node:path");
|
|
126375
126472
|
init_constants();
|
|
@@ -126386,12 +126483,12 @@ init_capabilities3();
|
|
|
126386
126483
|
init_kernel();
|
|
126387
126484
|
|
|
126388
126485
|
// src/holder/agent-context.ts
|
|
126389
|
-
var
|
|
126486
|
+
var import_promises58 = require("node:fs/promises");
|
|
126390
126487
|
var import_node_path65 = require("node:path");
|
|
126391
126488
|
init_prompt();
|
|
126392
126489
|
init_kernel();
|
|
126393
126490
|
async function readText3(path19) {
|
|
126394
|
-
return (0,
|
|
126491
|
+
return (0, import_promises58.readFile)(path19, "utf8").then(
|
|
126395
126492
|
(text3) => text3.trim(),
|
|
126396
126493
|
() => null
|
|
126397
126494
|
);
|
|
@@ -126565,7 +126662,7 @@ function createCheckoutRefresh(deps) {
|
|
|
126565
126662
|
}
|
|
126566
126663
|
|
|
126567
126664
|
// src/holder/git-state.ts
|
|
126568
|
-
var
|
|
126665
|
+
var import_promises59 = require("node:fs/promises");
|
|
126569
126666
|
var import_node_path67 = require("node:path");
|
|
126570
126667
|
init_runtime_v2();
|
|
126571
126668
|
var SHA_PATTERN = /^[0-9a-f]{40,64}$/;
|
|
@@ -126640,7 +126737,7 @@ async function readRepository(git, repoRoot, signal) {
|
|
|
126640
126737
|
}
|
|
126641
126738
|
async function isCheckout2(path19) {
|
|
126642
126739
|
try {
|
|
126643
|
-
await (0,
|
|
126740
|
+
await (0, import_promises59.stat)((0, import_node_path67.join)(path19, ".git"));
|
|
126644
126741
|
return true;
|
|
126645
126742
|
} catch {
|
|
126646
126743
|
return false;
|
|
@@ -126648,7 +126745,7 @@ async function isCheckout2(path19) {
|
|
|
126648
126745
|
}
|
|
126649
126746
|
async function childCheckouts(path19) {
|
|
126650
126747
|
try {
|
|
126651
|
-
const entries2 = await (0,
|
|
126748
|
+
const entries2 = await (0, import_promises59.readdir)(path19, { withFileTypes: true });
|
|
126652
126749
|
const children = entries2.filter((entry2) => entry2.isDirectory() && !entry2.name.startsWith(".")).map((entry2) => (0, import_node_path67.join)(path19, entry2.name));
|
|
126653
126750
|
const checkouts = await Promise.all(
|
|
126654
126751
|
children.map(async (child) => await isCheckout2(child) ? child : null)
|
|
@@ -126718,7 +126815,7 @@ function volumeRoot(path19) {
|
|
|
126718
126815
|
}
|
|
126719
126816
|
async function exists3(path19) {
|
|
126720
126817
|
try {
|
|
126721
|
-
await (0,
|
|
126818
|
+
await (0, import_promises60.stat)(path19);
|
|
126722
126819
|
return true;
|
|
126723
126820
|
} catch {
|
|
126724
126821
|
return false;
|
|
@@ -126726,10 +126823,10 @@ async function exists3(path19) {
|
|
|
126726
126823
|
}
|
|
126727
126824
|
async function inspectReadiness(path19) {
|
|
126728
126825
|
try {
|
|
126729
|
-
if (!(await (0,
|
|
126826
|
+
if (!(await (0, import_promises60.stat)(path19)).isDirectory()) {
|
|
126730
126827
|
return { ready: false, missing: true, message: MESSAGES.missing };
|
|
126731
126828
|
}
|
|
126732
|
-
await (0,
|
|
126829
|
+
await (0, import_promises60.access)(path19, import_node_fs26.constants.R_OK | import_node_fs26.constants.W_OK | import_node_fs26.constants.X_OK);
|
|
126733
126830
|
return { ready: true };
|
|
126734
126831
|
} catch (error62) {
|
|
126735
126832
|
const code = errnoCode(error62) ?? "";
|
|
@@ -126775,8 +126872,8 @@ async function admitDefaultWorkspace(spec, context, skills) {
|
|
|
126775
126872
|
const { env } = context;
|
|
126776
126873
|
const path19 = resolveAlanDefaultWorkspacePath(env.HOME || env.USERPROFILE || (0, import_node_os10.homedir)());
|
|
126777
126874
|
try {
|
|
126778
|
-
await (0,
|
|
126779
|
-
await (0,
|
|
126875
|
+
await (0, import_promises60.mkdir)(path19, { recursive: true, mode: 448 });
|
|
126876
|
+
await (0, import_promises60.access)(path19, import_node_fs26.constants.R_OK | import_node_fs26.constants.W_OK | import_node_fs26.constants.X_OK);
|
|
126780
126877
|
return { kind: "admitted", spec: { ...spec, projectPath: path19 }, skills };
|
|
126781
126878
|
} catch (error62) {
|
|
126782
126879
|
const code = errnoCode(error62);
|
|
@@ -126914,7 +127011,7 @@ async function respondToTurn(runningRunId, driver, request3) {
|
|
|
126914
127011
|
}
|
|
126915
127012
|
|
|
126916
127013
|
// src/holder/session-facts.ts
|
|
126917
|
-
var
|
|
127014
|
+
var import_promises61 = require("node:fs/promises");
|
|
126918
127015
|
init_capabilities3();
|
|
126919
127016
|
init_platform();
|
|
126920
127017
|
var CLI_RSS_CACHE_MS = 1e4;
|
|
@@ -126943,8 +127040,8 @@ function createSessionFacts(options) {
|
|
|
126943
127040
|
const path19 = await resolveCommandOnPath(command, env, platform);
|
|
126944
127041
|
if (path19 === null) return null;
|
|
126945
127042
|
try {
|
|
126946
|
-
const real = await (0,
|
|
126947
|
-
const info = await (0,
|
|
127043
|
+
const real = await (0, import_promises61.realpath)(path19);
|
|
127044
|
+
const info = await (0, import_promises61.stat)(real);
|
|
126948
127045
|
return { command, key: `${real}:${info.ino}:${info.size}:${info.mtimeMs}` };
|
|
126949
127046
|
} catch {
|
|
126950
127047
|
return null;
|
|
@@ -127039,8 +127136,8 @@ function createSessionFacts(options) {
|
|
|
127039
127136
|
}
|
|
127040
127137
|
|
|
127041
127138
|
// src/holder/session-preparation.ts
|
|
127042
|
-
var
|
|
127043
|
-
var
|
|
127139
|
+
var import_node_crypto33 = require("node:crypto");
|
|
127140
|
+
var import_promises62 = require("node:fs/promises");
|
|
127044
127141
|
init_runtime_v2();
|
|
127045
127142
|
init_kernel();
|
|
127046
127143
|
init_platform();
|
|
@@ -127071,7 +127168,7 @@ function createHolderPreparation(options) {
|
|
|
127071
127168
|
let status;
|
|
127072
127169
|
let closing = false;
|
|
127073
127170
|
let preparedEngine;
|
|
127074
|
-
const unavailableGeneration = (0,
|
|
127171
|
+
const unavailableGeneration = (0, import_node_crypto33.randomUUID)();
|
|
127075
127172
|
const transition = (operation) => {
|
|
127076
127173
|
pending++;
|
|
127077
127174
|
const next = tail2.then(operation, operation);
|
|
@@ -127093,7 +127190,7 @@ function createHolderPreparation(options) {
|
|
|
127093
127190
|
signal.throwIfAborted();
|
|
127094
127191
|
if (!samePreparationBinding(fresh.binding, reference))
|
|
127095
127192
|
throw new LocalSessionActionError("forbidden");
|
|
127096
|
-
if (await (0,
|
|
127193
|
+
if (await (0, import_promises62.realpath)(reference.workspace) !== reference.workspace)
|
|
127097
127194
|
throw new LocalSessionActionError("invalid_path");
|
|
127098
127195
|
return fresh;
|
|
127099
127196
|
};
|
|
@@ -127119,7 +127216,7 @@ function createHolderPreparation(options) {
|
|
|
127119
127216
|
status = {
|
|
127120
127217
|
localSessionId: reference.localSessionId,
|
|
127121
127218
|
conversationId: reference.conversationId,
|
|
127122
|
-
generation: changed2 ? (0,
|
|
127219
|
+
generation: changed2 ? (0, import_node_crypto33.randomUUID)() : status?.generation ?? (0, import_node_crypto33.randomUUID)(),
|
|
127123
127220
|
state: "ready"
|
|
127124
127221
|
};
|
|
127125
127222
|
};
|
|
@@ -127131,7 +127228,7 @@ function createHolderPreparation(options) {
|
|
|
127131
127228
|
if (!metadata || metadata.configurationRevision === fresh.configurationRevision) return;
|
|
127132
127229
|
if (!options.driver.suspend) throw new LocalSessionActionError("busy");
|
|
127133
127230
|
await options.driver.suspend();
|
|
127134
|
-
if (status) status = { ...status, generation: (0,
|
|
127231
|
+
if (status) status = { ...status, generation: (0, import_node_crypto33.randomUUID)() };
|
|
127135
127232
|
};
|
|
127136
127233
|
const openPrepared = async (reference, controller) => {
|
|
127137
127234
|
const fresh = await authorize(reference, controller.signal);
|
|
@@ -127156,7 +127253,7 @@ function createHolderPreparation(options) {
|
|
|
127156
127253
|
if (closing) throw new LocalSessionActionError("not_prepared");
|
|
127157
127254
|
if (job) return currentStatus(reference);
|
|
127158
127255
|
if (options.active()) throw new LocalSessionActionError("busy");
|
|
127159
|
-
const generation = status?.state === "ready" ? status.generation : (0,
|
|
127256
|
+
const generation = status?.state === "ready" ? status.generation : (0, import_node_crypto33.randomUUID)();
|
|
127160
127257
|
status = {
|
|
127161
127258
|
localSessionId: reference.localSessionId,
|
|
127162
127259
|
conversationId: reference.conversationId,
|
|
@@ -127295,7 +127392,7 @@ init_acp2();
|
|
|
127295
127392
|
init_kernel();
|
|
127296
127393
|
|
|
127297
127394
|
// src/run-log/directory.ts
|
|
127298
|
-
var
|
|
127395
|
+
var import_promises63 = require("node:fs/promises");
|
|
127299
127396
|
var import_node_path69 = require("node:path");
|
|
127300
127397
|
init_runtime_v2();
|
|
127301
127398
|
init_zod();
|
|
@@ -127330,7 +127427,7 @@ function runDirectory(runsDir, runId) {
|
|
|
127330
127427
|
}
|
|
127331
127428
|
async function isRunClaimed(runsDir, runId) {
|
|
127332
127429
|
try {
|
|
127333
|
-
return (await (0,
|
|
127430
|
+
return (await (0, import_promises63.stat)(runDirectory(runsDir, runId).log)).size > 0;
|
|
127334
127431
|
} catch (error62) {
|
|
127335
127432
|
if (errnoCode(error62) === "ENOENT") return false;
|
|
127336
127433
|
throw error62;
|
|
@@ -127338,7 +127435,7 @@ async function isRunClaimed(runsDir, runId) {
|
|
|
127338
127435
|
}
|
|
127339
127436
|
|
|
127340
127437
|
// src/run-log/conversation-index.ts
|
|
127341
|
-
var
|
|
127438
|
+
var import_promises64 = require("node:fs/promises");
|
|
127342
127439
|
var import_node_path70 = require("node:path");
|
|
127343
127440
|
init_runtime_v2();
|
|
127344
127441
|
init_zod();
|
|
@@ -127371,8 +127468,8 @@ async function indexConversationRun(runsDir, conversationId, ordinal, assistantO
|
|
|
127371
127468
|
const nextOrdinal = assistantOrdinal + 1;
|
|
127372
127469
|
if (nextOrdinal <= ordinal) throw new Error("Assistant order must follow the prompt");
|
|
127373
127470
|
const path19 = shardPath(runsDir, conversationId, ordinal);
|
|
127374
|
-
await (0,
|
|
127375
|
-
await (0,
|
|
127471
|
+
await (0, import_promises64.mkdir)((0, import_node_path70.dirname)(path19), { recursive: true, mode: 448 });
|
|
127472
|
+
await (0, import_promises64.appendFile)(path19, `${JSON.stringify({ ordinal, nextOrdinal, runId })}
|
|
127376
127473
|
`, { mode: 384 });
|
|
127377
127474
|
const coveragePath = (0, import_node_path70.join)((0, import_node_path70.dirname)((0, import_node_path70.dirname)(path19)), "coverage.json");
|
|
127378
127475
|
const coverage = await readJsonFile(coveragePath, coverageSchema2);
|
|
@@ -127752,6 +127849,12 @@ async function writeRunEnd(updates, log, spec, context) {
|
|
|
127752
127849
|
}
|
|
127753
127850
|
}
|
|
127754
127851
|
}
|
|
127852
|
+
function aborted2(signal) {
|
|
127853
|
+
if (signal.aborted) return Promise.resolve();
|
|
127854
|
+
return new Promise((resolve13) => {
|
|
127855
|
+
signal.addEventListener("abort", resolve13, { once: true });
|
|
127856
|
+
});
|
|
127857
|
+
}
|
|
127755
127858
|
function resultAfterStop(result, signal) {
|
|
127756
127859
|
if (!signal.aborted || result.outcome !== "failed") return result;
|
|
127757
127860
|
return {
|
|
@@ -127759,6 +127862,26 @@ function resultAfterStop(result, signal) {
|
|
|
127759
127862
|
...result.providerSessionId === void 0 ? {} : { providerSessionId: result.providerSessionId }
|
|
127760
127863
|
};
|
|
127761
127864
|
}
|
|
127865
|
+
async function stopSerialBackground(pendingBackground, result, outcome2, spec, context, signal, backgroundSettled) {
|
|
127866
|
+
if (!pendingBackground) return { result, outcome: outcome2 };
|
|
127867
|
+
const stopped = await Promise.race([
|
|
127868
|
+
backgroundSettled.then(() => false),
|
|
127869
|
+
aborted2(signal).then(() => true)
|
|
127870
|
+
]);
|
|
127871
|
+
if (!stopped) return { result, outcome: outcome2 };
|
|
127872
|
+
const stopOutcome = signal.reason === "interrupted" ? "interrupted" : "aborted";
|
|
127873
|
+
await context.driver.suspend?.().catch((error62) => {
|
|
127874
|
+
context.log.warn("holder.background_stop_failed", { runId: spec.runId, error: error62 });
|
|
127875
|
+
});
|
|
127876
|
+
return {
|
|
127877
|
+
outcome: stopOutcome,
|
|
127878
|
+
result: {
|
|
127879
|
+
outcome: stopOutcome,
|
|
127880
|
+
...result.providerSessionId === void 0 ? {} : { providerSessionId: result.providerSessionId },
|
|
127881
|
+
...result.unansweredSteerIds === void 0 ? {} : { unansweredSteerIds: result.unansweredSteerIds }
|
|
127882
|
+
}
|
|
127883
|
+
};
|
|
127884
|
+
}
|
|
127762
127885
|
async function turnEndGitState(outcome2, gitState) {
|
|
127763
127886
|
if (outcome2 === "rejected") {
|
|
127764
127887
|
gitState.stop();
|
|
@@ -127767,9 +127890,23 @@ async function turnEndGitState(outcome2, gitState) {
|
|
|
127767
127890
|
const state2 = await gitState.finish();
|
|
127768
127891
|
return state2 === null ? [] : [state2];
|
|
127769
127892
|
}
|
|
127770
|
-
async function completeClaimedTurn(turnResult, spec, context, signal, log, events, reportedError, state2, gitState) {
|
|
127771
|
-
const
|
|
127772
|
-
|
|
127893
|
+
async function completeClaimedTurn(turnResult, spec, context, signal, log, events, reportedError, state2, backgroundSettled, gitState) {
|
|
127894
|
+
const pendingLocalBackground = Boolean(
|
|
127895
|
+
context.serialBackground === true && events && context.driver.hasBackgroundWork?.(spec.runId)
|
|
127896
|
+
);
|
|
127897
|
+
const stopped = resultAfterStop(turnResult, signal);
|
|
127898
|
+
const initialOutcome = stopped.outcome === "aborted" && signal.reason === "interrupted" ? "interrupted" : stopped.outcome;
|
|
127899
|
+
const settled3 = await stopSerialBackground(
|
|
127900
|
+
pendingLocalBackground,
|
|
127901
|
+
stopped,
|
|
127902
|
+
initialOutcome,
|
|
127903
|
+
spec,
|
|
127904
|
+
context,
|
|
127905
|
+
signal,
|
|
127906
|
+
backgroundSettled
|
|
127907
|
+
);
|
|
127908
|
+
const result = settled3.result;
|
|
127909
|
+
const outcome2 = settled3.outcome;
|
|
127773
127910
|
const updates = [];
|
|
127774
127911
|
if ((outcome2 === "failed" || outcome2 === "interrupted") && !reportedError && result.message !== void 0) {
|
|
127775
127912
|
updates.push(
|
|
@@ -127786,15 +127923,17 @@ async function completeClaimedTurn(turnResult, spec, context, signal, log, event
|
|
|
127786
127923
|
const ended = resultEndUpdate(result, outcome2);
|
|
127787
127924
|
state2.ended = ended;
|
|
127788
127925
|
updates.push(ended);
|
|
127789
|
-
const
|
|
127790
|
-
|
|
127926
|
+
const retainForBackground = Boolean(
|
|
127927
|
+
context.serialBackground !== true && events && context.driver.hasBackgroundWork?.(spec.runId)
|
|
127928
|
+
);
|
|
127929
|
+
if (retainForBackground) updates.push({ sessionUpdate: "_alan/background.pending" });
|
|
127791
127930
|
try {
|
|
127792
127931
|
await writeRunEnd(updates, log, spec, context);
|
|
127793
127932
|
state2.foregroundEnded = true;
|
|
127794
127933
|
state2.retainedForBackground = Boolean(
|
|
127795
|
-
|
|
127934
|
+
retainForBackground && context.driver.hasBackgroundWork?.(spec.runId)
|
|
127796
127935
|
);
|
|
127797
|
-
if (
|
|
127936
|
+
if (retainForBackground && !state2.retainedForBackground) {
|
|
127798
127937
|
await writeRunEnd([ended], log, spec, context);
|
|
127799
127938
|
}
|
|
127800
127939
|
} finally {
|
|
@@ -127842,9 +127981,17 @@ async function runClaimedTurn(spec, claimed, context, signal) {
|
|
|
127842
127981
|
]);
|
|
127843
127982
|
return "failed";
|
|
127844
127983
|
};
|
|
127984
|
+
let settledBackground;
|
|
127985
|
+
const backgroundSettled = new Promise((resolve13) => {
|
|
127986
|
+
settledBackground = resolve13;
|
|
127987
|
+
});
|
|
127845
127988
|
const events = context.driver.onBackgroundEvent?.(spec, (update, sessionId) => {
|
|
127846
127989
|
append(fitForRunLog(withoutInlineMedia(update)), sessionId);
|
|
127847
127990
|
log.syncIfDirty();
|
|
127991
|
+
if (context.serialBackground === true) {
|
|
127992
|
+
if (!context.driver.hasBackgroundWork?.(spec.runId)) settledBackground?.();
|
|
127993
|
+
return;
|
|
127994
|
+
}
|
|
127848
127995
|
if (!endState.foregroundEnded || !endState.retainedForBackground || context.driver.hasBackgroundWork?.(spec.runId))
|
|
127849
127996
|
return;
|
|
127850
127997
|
if (endState.ended) append(endState.ended);
|
|
@@ -127879,6 +128026,7 @@ async function runClaimedTurn(spec, claimed, context, signal) {
|
|
|
127879
128026
|
events,
|
|
127880
128027
|
reported.error,
|
|
127881
128028
|
endState,
|
|
128029
|
+
backgroundSettled,
|
|
127882
128030
|
gitState
|
|
127883
128031
|
);
|
|
127884
128032
|
}
|
|
@@ -127907,6 +128055,7 @@ async function runClaimedTurn(spec, claimed, context, signal) {
|
|
|
127907
128055
|
events,
|
|
127908
128056
|
reported.error,
|
|
127909
128057
|
endState,
|
|
128058
|
+
backgroundSettled,
|
|
127910
128059
|
gitState
|
|
127911
128060
|
);
|
|
127912
128061
|
}
|
|
@@ -127918,12 +128067,12 @@ var TASK_UNSUPPORTED = {
|
|
|
127918
128067
|
message: "This agent cannot stop one background task."
|
|
127919
128068
|
};
|
|
127920
128069
|
function sha2564(value2) {
|
|
127921
|
-
return (0,
|
|
128070
|
+
return (0, import_node_crypto34.createHash)("sha256").update(value2).digest("hex");
|
|
127922
128071
|
}
|
|
127923
128072
|
function tokenMatches(expected, presented) {
|
|
127924
128073
|
const a = Buffer.from(sha2564(expected), "hex");
|
|
127925
128074
|
const b = Buffer.from(sha2564(presented), "hex");
|
|
127926
|
-
return (0,
|
|
128075
|
+
return (0, import_node_crypto34.timingSafeEqual)(a, b);
|
|
127927
128076
|
}
|
|
127928
128077
|
async function runHolder({
|
|
127929
128078
|
launch,
|
|
@@ -127932,6 +128081,7 @@ async function runHolder({
|
|
|
127932
128081
|
log,
|
|
127933
128082
|
inputs,
|
|
127934
128083
|
machine,
|
|
128084
|
+
serialBackground,
|
|
127935
128085
|
preparation: source,
|
|
127936
128086
|
engineRecording,
|
|
127937
128087
|
engineOwnership = nativeEngineOwnership()
|
|
@@ -128048,7 +128198,8 @@ async function runHolder({
|
|
|
128048
128198
|
log,
|
|
128049
128199
|
onAppended: (runId, offset) => broadcast({ type: "appended", runId, offset }),
|
|
128050
128200
|
...inputs === void 0 ? {} : { inputs },
|
|
128051
|
-
...workspace === void 0 ? {} : { workspace }
|
|
128201
|
+
...workspace === void 0 ? {} : { workspace },
|
|
128202
|
+
...serialBackground === void 0 ? {} : { serialBackground }
|
|
128052
128203
|
};
|
|
128053
128204
|
claimRun(spec, context).then(
|
|
128054
128205
|
(claimed) => {
|
|
@@ -128318,7 +128469,7 @@ init_runtime_v2();
|
|
|
128318
128469
|
init_zod();
|
|
128319
128470
|
|
|
128320
128471
|
// src/client/browser-agent-discovery.ts
|
|
128321
|
-
var
|
|
128472
|
+
var import_node_crypto35 = require("node:crypto");
|
|
128322
128473
|
var import_node_path73 = require("node:path");
|
|
128323
128474
|
init_agent2();
|
|
128324
128475
|
init_zod();
|
|
@@ -128332,13 +128483,13 @@ function browserAgentDiscoveryPath(stateDir) {
|
|
|
128332
128483
|
return (0, import_node_path73.join)(stateDir, BROWSER_AGENT_DISCOVERY_FILE);
|
|
128333
128484
|
}
|
|
128334
128485
|
function deriveBrowserScopeToken(secret, scopeId) {
|
|
128335
|
-
return (0,
|
|
128486
|
+
return (0, import_node_crypto35.createHmac)("sha256", secret).update(scopeId).digest("hex");
|
|
128336
128487
|
}
|
|
128337
128488
|
function browserScopeUrl(discovery, scopeId, conversationId) {
|
|
128338
128489
|
return `${discovery.endpoint}/${encodeURIComponent(scopeId)}/${encodeURIComponent(conversationId)}`;
|
|
128339
128490
|
}
|
|
128340
128491
|
function browserScopeIdForRun(run3) {
|
|
128341
|
-
return
|
|
128492
|
+
return `conversation:${run3.conversationId}`;
|
|
128342
128493
|
}
|
|
128343
128494
|
|
|
128344
128495
|
// src/client/locate.ts
|
|
@@ -128641,12 +128792,12 @@ init_kernel();
|
|
|
128641
128792
|
init_platform();
|
|
128642
128793
|
|
|
128643
128794
|
// src/cli/browser-mcp.ts
|
|
128644
|
-
var
|
|
128795
|
+
var import_promises65 = require("node:fs/promises");
|
|
128645
128796
|
var BROWSER_WORKSPACE_ROOT_HEADER = "X-Alan-Workspace-Root";
|
|
128646
128797
|
async function readDiscovery(stateDir) {
|
|
128647
128798
|
try {
|
|
128648
128799
|
const parsed = browserAgentDiscoverySchema.safeParse(
|
|
128649
|
-
JSON.parse(await (0,
|
|
128800
|
+
JSON.parse(await (0, import_promises65.readFile)(browserAgentDiscoveryPath(stateDir), "utf8"))
|
|
128650
128801
|
);
|
|
128651
128802
|
return parsed.success ? parsed.data : null;
|
|
128652
128803
|
} catch {
|
|
@@ -128814,6 +128965,8 @@ async function runHold(argv) {
|
|
|
128814
128965
|
),
|
|
128815
128966
|
clock: systemClock,
|
|
128816
128967
|
log,
|
|
128968
|
+
// A cloud sandbox cannot keep a turn's clock across a pause, so it leases the VM instead.
|
|
128969
|
+
serialBackground: config2.workspaceRoot === null,
|
|
128817
128970
|
preparation: {
|
|
128818
128971
|
authorize: async (reference, signal) => {
|
|
128819
128972
|
const current = await loadStoredAccess(paths);
|