@alan-ai-hq/agent-manager-linux-arm64 0.1.133 → 0.1.135
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 +1877 -1194
- package/alan-holder.cjs +927 -583
- package/package.json +1 -1
package/alan-holder.cjs
CHANGED
|
@@ -20379,7 +20379,7 @@ function runProviderCredentialPath(runId) {
|
|
|
20379
20379
|
function runAttachmentPath(runId, attachmentId) {
|
|
20380
20380
|
return `/public/machines/me/runs/${encodeURIComponent(runId)}/attachments/${encodeURIComponent(attachmentId)}`;
|
|
20381
20381
|
}
|
|
20382
|
-
var machineEndpointsSchema, machineCredentialGrantSchema, MACHINE_PATHS, machinePlatformSchema, machineRegisterRequestSchema, machineRenewRequestSchema, machineRenewReusedSchema, deviceAuthorizationSchema, machineDeviceAuthorizationRequestSchema, machineDeviceTokenRequestSchema, machineDeviceTokenSchema, DEVICE_TOKEN_ERRORS, machineDeviceTokenErrorSchema, machineMcpCredentialRequestSchema, machineMcpCredentialSchema, runtimeReleaseSchema, machineSiblingSchema, MACHINE_SIBLINGS_LIMIT, machineSiblingsResponseSchema, runProviderCredentialSchema;
|
|
20382
|
+
var machineEndpointsSchema, machineCredentialGrantSchema, MACHINE_PATHS, machinePlatformSchema, machineRegisterRequestSchema, machineEnrollRequestSchema, machineRenewRequestSchema, machineRenewReusedSchema, deviceAuthorizationSchema, machineDeviceAuthorizationRequestSchema, machineDeviceTokenRequestSchema, machineDeviceTokenSchema, DEVICE_TOKEN_ERRORS, machineDeviceTokenErrorSchema, machineMcpCredentialRequestSchema, machineMcpCredentialSchema, runtimeReleaseSchema, machineSiblingSchema, MACHINE_SIBLINGS_LIMIT, machineSiblingsResponseSchema, runProviderCredentialSchema;
|
|
20383
20383
|
var init_machine_identity = __esm({
|
|
20384
20384
|
"../shared/dist/runtime-v2/machine-identity.js"() {
|
|
20385
20385
|
"use strict";
|
|
@@ -20399,6 +20399,8 @@ var init_machine_identity = __esm({
|
|
|
20399
20399
|
MACHINE_PATHS = {
|
|
20400
20400
|
/** POST with a one-time setup grant (what `install --setup-token` / `setup` send). */
|
|
20401
20401
|
register: "/public/machines/register",
|
|
20402
|
+
/** POST with a cloud sandbox's one-time enrollment code from `ALAN_RUNTIME_ENROLLMENT_CODE`. */
|
|
20403
|
+
enroll: "/public/machines/enroll",
|
|
20402
20404
|
/** POST with the current renewal token; the response carries a new one and the old dies. */
|
|
20403
20405
|
renew: "/public/machines/me/renew",
|
|
20404
20406
|
/** POST by the machine itself on logout/uninstall. */
|
|
@@ -20435,6 +20437,7 @@ var init_machine_identity = __esm({
|
|
|
20435
20437
|
/** Chosen by the install before its first registration, so a credential lost locally still maps to its row. */
|
|
20436
20438
|
installationId: external_exports.guid().optional()
|
|
20437
20439
|
});
|
|
20440
|
+
machineEnrollRequestSchema = external_exports.object({ enrollmentCode: external_exports.string().min(1) });
|
|
20438
20441
|
machineRenewRequestSchema = external_exports.object({ renewalToken: external_exports.string().min(1) });
|
|
20439
20442
|
machineRenewReusedSchema = external_exports.object({
|
|
20440
20443
|
error: external_exports.literal("renewal_token_reused"),
|
|
@@ -21349,11 +21352,12 @@ function isReadOnlyAgent(agentId) {
|
|
|
21349
21352
|
const agent = getBuiltinAgentDefinition(agentId);
|
|
21350
21353
|
return !agent.capabilities.canEditFiles;
|
|
21351
21354
|
}
|
|
21352
|
-
var COORDINATOR_PROMPT, PM_PROMPT, GENERAL_PROMPT, REVIEW_PROMPT, DESIGNER_PROMPT, BUILTIN_AGENT_DEFINITIONS, BUILTIN_AGENT_BY_ID, LEGACY_AGENT_ID_ALIASES;
|
|
21355
|
+
var SETUP_AGENT_ID, COORDINATOR_PROMPT, PM_PROMPT, GENERAL_PROMPT, REVIEW_PROMPT, DESIGNER_PROMPT, BUILTIN_AGENT_DEFINITIONS, BUILTIN_AGENT_BY_ID, LEGACY_AGENT_ID_ALIASES;
|
|
21353
21356
|
var init_agent_definitions = __esm({
|
|
21354
21357
|
"../shared/dist/agent/agent-definitions.js"() {
|
|
21355
21358
|
"use strict";
|
|
21356
21359
|
init_task_duplicate();
|
|
21360
|
+
SETUP_AGENT_ID = "setup";
|
|
21357
21361
|
COORDINATOR_PROMPT = `## You are the Orchestrator
|
|
21358
21362
|
|
|
21359
21363
|
You are the **Orchestrator** for this task or session. When asked "who are you?", "what agent are you?", "are you the coordinator?", "are you the orchestrator?", or anything similar \u2014 identify yourself plainly as the Orchestrator. Do not say "I'm Alan" alone; say "I'm the Orchestrator (an Alan agent profile)."
|
|
@@ -21647,6 +21651,21 @@ For any UI or design work, read and follow the \`uiux\` skill in \`.agents/skill
|
|
|
21647
21651
|
canManageSubtasks: false
|
|
21648
21652
|
},
|
|
21649
21653
|
systemPrompt: DESIGNER_PROMPT
|
|
21654
|
+
},
|
|
21655
|
+
{
|
|
21656
|
+
id: SETUP_AGENT_ID,
|
|
21657
|
+
name: "Setup Agent",
|
|
21658
|
+
description: "Sets up and verifies cloud environments",
|
|
21659
|
+
iconKey: "hard-drive",
|
|
21660
|
+
defaultMode: "agent",
|
|
21661
|
+
capabilities: {
|
|
21662
|
+
canEditFiles: true,
|
|
21663
|
+
canRunCommands: true,
|
|
21664
|
+
canCreateArtifacts: true,
|
|
21665
|
+
canStartSessions: false,
|
|
21666
|
+
canManageSubtasks: false
|
|
21667
|
+
},
|
|
21668
|
+
systemPrompt: ""
|
|
21650
21669
|
}
|
|
21651
21670
|
];
|
|
21652
21671
|
BUILTIN_AGENT_BY_ID = new Map(BUILTIN_AGENT_DEFINITIONS.map((agent) => [agent.id, agent]));
|
|
@@ -21657,9 +21676,7 @@ For any UI or design work, read and follow the \`uiux\` skill in \`.agents/skill
|
|
|
21657
21676
|
implementer: "general",
|
|
21658
21677
|
implementor: "general",
|
|
21659
21678
|
"ui-designer": "designer",
|
|
21660
|
-
verifier: "general"
|
|
21661
|
-
// Former reserved Setup Agent profile \u2014 env setup is now a normal session kickoff.
|
|
21662
|
-
setup: "general"
|
|
21679
|
+
verifier: "general"
|
|
21663
21680
|
};
|
|
21664
21681
|
}
|
|
21665
21682
|
});
|
|
@@ -21679,21 +21696,9 @@ var init_browser_surface = __esm({
|
|
|
21679
21696
|
});
|
|
21680
21697
|
|
|
21681
21698
|
// ../shared/dist/agent/gated-mcp-tools.js
|
|
21682
|
-
var CODE_INDEX_MCP_TOOLS, CONTEXT_GRAPH_MCP_TOOLS, ENTITLEMENT_GATED_MCP_TOOLS;
|
|
21683
21699
|
var init_gated_mcp_tools = __esm({
|
|
21684
21700
|
"../shared/dist/agent/gated-mcp-tools.js"() {
|
|
21685
21701
|
"use strict";
|
|
21686
|
-
CODE_INDEX_MCP_TOOLS = [
|
|
21687
|
-
"search_code_context",
|
|
21688
|
-
"code_context_status",
|
|
21689
|
-
"code_graph_query",
|
|
21690
|
-
"code_lsp_diagnostics"
|
|
21691
|
-
];
|
|
21692
|
-
CONTEXT_GRAPH_MCP_TOOLS = ["search_context"];
|
|
21693
|
-
ENTITLEMENT_GATED_MCP_TOOLS = [
|
|
21694
|
-
...CODE_INDEX_MCP_TOOLS,
|
|
21695
|
-
...CONTEXT_GRAPH_MCP_TOOLS
|
|
21696
|
-
];
|
|
21697
21702
|
}
|
|
21698
21703
|
});
|
|
21699
21704
|
|
|
@@ -22202,7 +22207,7 @@ var init_chunk_YXWJW7I5 = __esm({
|
|
|
22202
22207
|
}
|
|
22203
22208
|
});
|
|
22204
22209
|
|
|
22205
|
-
// ../agent-core/dist/chunk-
|
|
22210
|
+
// ../agent-core/dist/chunk-J4T6L5LX.js
|
|
22206
22211
|
function windowsEnvValue(env, name) {
|
|
22207
22212
|
const wanted = name.toLowerCase();
|
|
22208
22213
|
for (const [key, value] of Object.entries(env)) {
|
|
@@ -22373,7 +22378,7 @@ function plan(command, args, options) {
|
|
|
22373
22378
|
function captureOutput(command, args, options) {
|
|
22374
22379
|
const launch = plan(command, args, options);
|
|
22375
22380
|
if (launch === void 0) return Promise.resolve(NEVER_STARTED);
|
|
22376
|
-
return new Promise((
|
|
22381
|
+
return new Promise((resolve6) => {
|
|
22377
22382
|
(0, import_child_process.execFile)(
|
|
22378
22383
|
launch.file,
|
|
22379
22384
|
[...launch.args],
|
|
@@ -22387,7 +22392,7 @@ function captureOutput(command, args, options) {
|
|
|
22387
22392
|
},
|
|
22388
22393
|
(error61, stdout, stderr) => {
|
|
22389
22394
|
const code = error61 && typeof error61.code === "number" ? error61.code : error61 ? void 0 : 0;
|
|
22390
|
-
|
|
22395
|
+
resolve6({ stdout, stderr, exitCode: code });
|
|
22391
22396
|
}
|
|
22392
22397
|
);
|
|
22393
22398
|
});
|
|
@@ -22429,18 +22434,18 @@ function decode3(bytes, start, end) {
|
|
|
22429
22434
|
}
|
|
22430
22435
|
async function linuxStartTicks(pid) {
|
|
22431
22436
|
try {
|
|
22432
|
-
const
|
|
22433
|
-
const fields =
|
|
22437
|
+
const stat14 = await (0, import_promises5.readFile)(`/proc/${pid}/stat`, "utf8");
|
|
22438
|
+
const fields = stat14.slice(stat14.lastIndexOf(")") + 2).split(" ");
|
|
22434
22439
|
return fields[19];
|
|
22435
22440
|
} catch {
|
|
22436
22441
|
return void 0;
|
|
22437
22442
|
}
|
|
22438
22443
|
}
|
|
22439
22444
|
function psStartTime(pid) {
|
|
22440
|
-
return new Promise((
|
|
22445
|
+
return new Promise((resolve6) => {
|
|
22441
22446
|
(0, import_child_process2.execFile)("ps", ["-o", "lstart=", "-p", String(pid)], { timeout: 2e3 }, (error61, stdout) => {
|
|
22442
22447
|
const text2 = stdout.trim();
|
|
22443
|
-
|
|
22448
|
+
resolve6(error61 || !text2 ? void 0 : text2);
|
|
22444
22449
|
});
|
|
22445
22450
|
});
|
|
22446
22451
|
}
|
|
@@ -22469,12 +22474,12 @@ function parseProcessList(text2) {
|
|
|
22469
22474
|
}
|
|
22470
22475
|
function listProcesses(platform = process.platform) {
|
|
22471
22476
|
if (platform === "win32") return Promise.resolve([]);
|
|
22472
|
-
return new Promise((
|
|
22477
|
+
return new Promise((resolve6) => {
|
|
22473
22478
|
(0, import_child_process3.execFile)(
|
|
22474
22479
|
"ps",
|
|
22475
22480
|
["-A", "-o", "pid=,ppid=,pgid=,lstart="],
|
|
22476
22481
|
{ timeout: 5e3, maxBuffer: 8 * 1024 * 1024 },
|
|
22477
|
-
(error61, stdout) =>
|
|
22482
|
+
(error61, stdout) => resolve6(error61 ? [] : parseProcessList(stdout))
|
|
22478
22483
|
);
|
|
22479
22484
|
});
|
|
22480
22485
|
}
|
|
@@ -22514,11 +22519,11 @@ async function taskkill(pid, options) {
|
|
|
22514
22519
|
stdio: "ignore",
|
|
22515
22520
|
windowsHide: true
|
|
22516
22521
|
});
|
|
22517
|
-
const exited = new Promise((
|
|
22518
|
-
killer.once("error", (error210) =>
|
|
22522
|
+
const exited = new Promise((resolve6) => {
|
|
22523
|
+
killer.once("error", (error210) => resolve6(error210));
|
|
22519
22524
|
killer.once(
|
|
22520
22525
|
"exit",
|
|
22521
|
-
(code, signal) =>
|
|
22526
|
+
(code, signal) => resolve6(code === 0 ? void 0 : new Error(`taskkill failed: exit ${code}, signal ${signal}`))
|
|
22522
22527
|
);
|
|
22523
22528
|
});
|
|
22524
22529
|
const timedOut = clock.sleep(options.timeoutMs ?? DEFAULT_TASKKILL_TIMEOUT_MS, timeout.signal).then(() => new Error("taskkill timed out")).catch(() => void 0);
|
|
@@ -22748,25 +22753,35 @@ async function waitForWindowsJob(child, command) {
|
|
|
22748
22753
|
await (0, import_promises6.rm)(status.directory, { recursive: true, force: true });
|
|
22749
22754
|
}
|
|
22750
22755
|
}
|
|
22756
|
+
function onCliSpawned(listener) {
|
|
22757
|
+
spawnListeners.add(listener);
|
|
22758
|
+
return {
|
|
22759
|
+
[Symbol.dispose]: () => {
|
|
22760
|
+
spawnListeners.delete(listener);
|
|
22761
|
+
}
|
|
22762
|
+
};
|
|
22763
|
+
}
|
|
22751
22764
|
function spawnCli(options) {
|
|
22752
22765
|
const platform = options.platform ?? process.platform;
|
|
22753
22766
|
const plan2 = planSpawn({ ...options, platform });
|
|
22754
22767
|
if (plan2.commandLine !== null) return spawnInWindowsJob(plan2, options);
|
|
22755
|
-
|
|
22768
|
+
const child = (0, import_child_process5.spawn)(plan2.file, [...plan2.args], {
|
|
22756
22769
|
cwd: options.cwd,
|
|
22757
22770
|
env: { ...options.env },
|
|
22758
22771
|
stdio: ["pipe", "pipe", "pipe"],
|
|
22759
22772
|
shell: false,
|
|
22760
22773
|
detached: true
|
|
22761
22774
|
});
|
|
22775
|
+
for (const listener of spawnListeners) listener(child);
|
|
22776
|
+
return child;
|
|
22762
22777
|
}
|
|
22763
22778
|
function waitForSpawn(child, command) {
|
|
22764
22779
|
if (isWindowsJob(child)) return waitForWindowsJob(child, command);
|
|
22765
22780
|
if (child.pid !== void 0) return Promise.resolve();
|
|
22766
|
-
return new Promise((
|
|
22781
|
+
return new Promise((resolve6, reject) => {
|
|
22767
22782
|
const onSpawn = () => {
|
|
22768
22783
|
child.off("error", onError);
|
|
22769
|
-
|
|
22784
|
+
resolve6();
|
|
22770
22785
|
};
|
|
22771
22786
|
const onError = (error61) => {
|
|
22772
22787
|
child.off("spawn", onSpawn);
|
|
@@ -22779,9 +22794,9 @@ function waitForSpawn(child, command) {
|
|
|
22779
22794
|
child.once("error", onError);
|
|
22780
22795
|
});
|
|
22781
22796
|
}
|
|
22782
|
-
var import_child_process, import_fs, import_path, import_child_process2, import_promises5, import_child_process3, import_child_process4, import_child_process5, import_child_process6, import_crypto, import_fs2, import_promises6, import_os, import_path2, SHIM_MAX_BYTES, CMD_MAX_COMMAND_LINE, MAX_COMMAND_LINE, DEFAULT_PATHEXT, nodeWindowsFiles, NODE_SHIM_ENTRY, CMD_META, NEVER_STARTED, HIDDEN_FLAG_PROBE_VALUE, NEWLINE, CARRIAGE_RETURN, EMPTY, MAX_LINE_BYTES, LineSplitter, PS_LINE, POLL_MS, DEFAULT_GRACE_MS, DEFAULT_KILL_WAIT_MS, DEFAULT_TASKKILL_TIMEOUT_MS, statuses, START_TIMEOUT_MS;
|
|
22783
|
-
var
|
|
22784
|
-
"../agent-core/dist/chunk-
|
|
22797
|
+
var import_child_process, import_fs, import_path, import_child_process2, import_promises5, import_child_process3, import_child_process4, import_child_process5, import_child_process6, import_crypto, import_fs2, import_promises6, import_os, import_path2, SHIM_MAX_BYTES, CMD_MAX_COMMAND_LINE, MAX_COMMAND_LINE, DEFAULT_PATHEXT, nodeWindowsFiles, NODE_SHIM_ENTRY, CMD_META, NEVER_STARTED, HIDDEN_FLAG_PROBE_VALUE, NEWLINE, CARRIAGE_RETURN, EMPTY, MAX_LINE_BYTES, LineSplitter, PS_LINE, POLL_MS, DEFAULT_GRACE_MS, DEFAULT_KILL_WAIT_MS, DEFAULT_TASKKILL_TIMEOUT_MS, statuses, START_TIMEOUT_MS, spawnListeners;
|
|
22798
|
+
var init_chunk_J4T6L5LX = __esm({
|
|
22799
|
+
"../agent-core/dist/chunk-J4T6L5LX.js"() {
|
|
22785
22800
|
"use strict";
|
|
22786
22801
|
init_chunk_YXWJW7I5();
|
|
22787
22802
|
import_child_process = require("child_process");
|
|
@@ -22870,6 +22885,7 @@ var init_chunk_6GPS6OKU = __esm({
|
|
|
22870
22885
|
DEFAULT_TASKKILL_TIMEOUT_MS = 5e3;
|
|
22871
22886
|
statuses = /* @__PURE__ */ new WeakMap();
|
|
22872
22887
|
START_TIMEOUT_MS = 1e4;
|
|
22888
|
+
spawnListeners = /* @__PURE__ */ new Set();
|
|
22873
22889
|
}
|
|
22874
22890
|
});
|
|
22875
22891
|
|
|
@@ -23575,26 +23591,26 @@ var init_constants = __esm({
|
|
|
23575
23591
|
}
|
|
23576
23592
|
});
|
|
23577
23593
|
|
|
23578
|
-
// ../shared/dist/agent/acp/
|
|
23579
|
-
var
|
|
23580
|
-
|
|
23581
|
-
"../shared/dist/agent/acp/background-task.js"() {
|
|
23594
|
+
// ../shared/dist/agent/acp/transcript-http.js
|
|
23595
|
+
var init_transcript_http = __esm({
|
|
23596
|
+
"../shared/dist/agent/acp/transcript-http.js"() {
|
|
23582
23597
|
"use strict";
|
|
23583
|
-
BACKGROUND_TASK_META_KEY = "alan.dev/backgroundTask";
|
|
23584
23598
|
}
|
|
23585
23599
|
});
|
|
23586
23600
|
|
|
23587
|
-
// ../shared/dist/agent/acp/
|
|
23588
|
-
var
|
|
23589
|
-
"../shared/dist/agent/acp/
|
|
23601
|
+
// ../shared/dist/agent/acp/ask.js
|
|
23602
|
+
var init_ask = __esm({
|
|
23603
|
+
"../shared/dist/agent/acp/ask.js"() {
|
|
23590
23604
|
"use strict";
|
|
23591
23605
|
}
|
|
23592
23606
|
});
|
|
23593
23607
|
|
|
23594
|
-
// ../shared/dist/agent/acp/
|
|
23595
|
-
var
|
|
23596
|
-
|
|
23608
|
+
// ../shared/dist/agent/acp/background-task.js
|
|
23609
|
+
var BACKGROUND_TASK_META_KEY;
|
|
23610
|
+
var init_background_task = __esm({
|
|
23611
|
+
"../shared/dist/agent/acp/background-task.js"() {
|
|
23597
23612
|
"use strict";
|
|
23613
|
+
BACKGROUND_TASK_META_KEY = "alan.dev/backgroundTask";
|
|
23598
23614
|
}
|
|
23599
23615
|
});
|
|
23600
23616
|
|
|
@@ -23626,9 +23642,9 @@ var init_prepare_conversation_turns = __esm({
|
|
|
23626
23642
|
}
|
|
23627
23643
|
});
|
|
23628
23644
|
|
|
23629
|
-
// ../shared/dist/agent/acp/
|
|
23630
|
-
var
|
|
23631
|
-
"../shared/dist/agent/acp/
|
|
23645
|
+
// ../shared/dist/agent/acp/event.js
|
|
23646
|
+
var init_event = __esm({
|
|
23647
|
+
"../shared/dist/agent/acp/event.js"() {
|
|
23632
23648
|
"use strict";
|
|
23633
23649
|
}
|
|
23634
23650
|
});
|
|
@@ -23637,7 +23653,7 @@ var init_types2 = __esm({
|
|
|
23637
23653
|
function isUpdate(update, kind) {
|
|
23638
23654
|
return update.sessionUpdate === kind;
|
|
23639
23655
|
}
|
|
23640
|
-
var
|
|
23656
|
+
var init_types2 = __esm({
|
|
23641
23657
|
"../shared/dist/agent/acp/types.js"() {
|
|
23642
23658
|
"use strict";
|
|
23643
23659
|
}
|
|
@@ -23650,6 +23666,20 @@ var init_reduce = __esm({
|
|
|
23650
23666
|
}
|
|
23651
23667
|
});
|
|
23652
23668
|
|
|
23669
|
+
// ../shared/dist/agent/acp/conversation-messages.js
|
|
23670
|
+
var init_conversation_messages = __esm({
|
|
23671
|
+
"../shared/dist/agent/acp/conversation-messages.js"() {
|
|
23672
|
+
"use strict";
|
|
23673
|
+
}
|
|
23674
|
+
});
|
|
23675
|
+
|
|
23676
|
+
// ../shared/dist/agent/acp/presentation/types.js
|
|
23677
|
+
var init_types3 = __esm({
|
|
23678
|
+
"../shared/dist/agent/acp/presentation/types.js"() {
|
|
23679
|
+
"use strict";
|
|
23680
|
+
}
|
|
23681
|
+
});
|
|
23682
|
+
|
|
23653
23683
|
// ../shared/dist/agent/acp/read.js
|
|
23654
23684
|
var init_read = __esm({
|
|
23655
23685
|
"../shared/dist/agent/acp/read.js"() {
|
|
@@ -23664,13 +23694,6 @@ var init_transcript_byte_decoder = __esm({
|
|
|
23664
23694
|
}
|
|
23665
23695
|
});
|
|
23666
23696
|
|
|
23667
|
-
// ../shared/dist/agent/acp/transcript-http.js
|
|
23668
|
-
var init_transcript_http = __esm({
|
|
23669
|
-
"../shared/dist/agent/acp/transcript-http.js"() {
|
|
23670
|
-
"use strict";
|
|
23671
|
-
}
|
|
23672
|
-
});
|
|
23673
|
-
|
|
23674
23697
|
// ../shared/dist/agent/acp/transcript-fold.js
|
|
23675
23698
|
var init_transcript_fold = __esm({
|
|
23676
23699
|
"../shared/dist/agent/acp/transcript-fold.js"() {
|
|
@@ -23691,6 +23714,7 @@ var init_transcript_live = __esm({
|
|
|
23691
23714
|
var init_acp = __esm({
|
|
23692
23715
|
"../shared/dist/agent/acp/index.js"() {
|
|
23693
23716
|
"use strict";
|
|
23717
|
+
init_ask();
|
|
23694
23718
|
init_background_task();
|
|
23695
23719
|
init_conversation_messages();
|
|
23696
23720
|
init_event();
|
|
@@ -23698,7 +23722,7 @@ var init_acp = __esm({
|
|
|
23698
23722
|
init_notice_visibility();
|
|
23699
23723
|
init_prepare_conversation_turns();
|
|
23700
23724
|
init_terminal_events();
|
|
23701
|
-
|
|
23725
|
+
init_types3();
|
|
23702
23726
|
init_read();
|
|
23703
23727
|
init_reduce();
|
|
23704
23728
|
init_transcript_byte_decoder();
|
|
@@ -23706,7 +23730,7 @@ var init_acp = __esm({
|
|
|
23706
23730
|
init_transcript_http();
|
|
23707
23731
|
init_transcript_ingestion();
|
|
23708
23732
|
init_transcript_live();
|
|
23709
|
-
|
|
23733
|
+
init_types2();
|
|
23710
23734
|
}
|
|
23711
23735
|
});
|
|
23712
23736
|
|
|
@@ -24078,7 +24102,7 @@ var init_chunk_DALFHI4B = __esm({
|
|
|
24078
24102
|
}
|
|
24079
24103
|
});
|
|
24080
24104
|
|
|
24081
|
-
// ../agent-core/dist/chunk-
|
|
24105
|
+
// ../agent-core/dist/chunk-R6R6ORR2.js
|
|
24082
24106
|
function specForErrorKind(errorKind) {
|
|
24083
24107
|
const spec = ERROR_SPECS[errorKind];
|
|
24084
24108
|
return { message: spec.message, errorKind, recoveryClass: spec.recoveryClass };
|
|
@@ -24192,6 +24216,7 @@ function statusKind(status) {
|
|
|
24192
24216
|
}
|
|
24193
24217
|
function mapProviderApiError(errorCode, apiStatus) {
|
|
24194
24218
|
if (apiStatus === 403) return "access_denied";
|
|
24219
|
+
if (apiStatus === 402) return "payment_required";
|
|
24195
24220
|
if (apiStatus === 401) return "auth_invalid";
|
|
24196
24221
|
const code = errorCode?.trim().toLowerCase();
|
|
24197
24222
|
const byCode = code ? CODE_RULES.find((rule) => rule.pattern.test(code))?.kind : void 0;
|
|
@@ -24205,6 +24230,11 @@ function classifyProviderApiError(input2) {
|
|
|
24205
24230
|
if (fromText && TEXT_REFINES[structured]?.has(fromText.errorKind)) return fromText;
|
|
24206
24231
|
return specForErrorKind(structured);
|
|
24207
24232
|
}
|
|
24233
|
+
function withPaymentRemedy(classified, message) {
|
|
24234
|
+
if (classified.errorKind !== "payment_required") return classified;
|
|
24235
|
+
const remedy = message.replace(STATUS_LEAD, "").trim();
|
|
24236
|
+
return remedy ? { ...classified, message: remedy.slice(0, 300) } : classified;
|
|
24237
|
+
}
|
|
24208
24238
|
function classifyProviderError(text2, hints = {}) {
|
|
24209
24239
|
const detail = readProviderErrorDetail(text2);
|
|
24210
24240
|
const errorCode = hints.errorCode ?? detail.type;
|
|
@@ -24214,7 +24244,7 @@ function classifyProviderError(text2, hints = {}) {
|
|
|
24214
24244
|
...status === void 0 ? {} : { status },
|
|
24215
24245
|
text: detail.message
|
|
24216
24246
|
}) ?? classifyProviderTerminalText(text2);
|
|
24217
|
-
if (classified) return classified;
|
|
24247
|
+
if (classified) return withPaymentRemedy(classified, detail.message);
|
|
24218
24248
|
const message = detail.message.slice(0, 200);
|
|
24219
24249
|
return message ? { message, errorKind: "unknown_cli_error", recoveryClass: "unknown" } : specForErrorKind("unknown_cli_error");
|
|
24220
24250
|
}
|
|
@@ -24265,9 +24295,9 @@ function createCliProblem(classified, options) {
|
|
|
24265
24295
|
...classified.resetsAt ? { resetsAt: classified.resetsAt } : {}
|
|
24266
24296
|
});
|
|
24267
24297
|
}
|
|
24268
|
-
var import_crypto2, ERROR_SPECS, AGENT_ERROR_KINDS, STATUS_PREFIX, TEXT_RULES, CODEX_TIMEOUT_MESSAGE, CODEX_EXPIRED_MESSAGE, EPOCH_RESET, WORDED_RESET, COMMAND_NOT_FOUND, CODE_RULES, TEXT_REFINES, CLI_PROBLEM_CODE_BY_ERROR_KIND, KEY_REJECTION_KINDS;
|
|
24269
|
-
var
|
|
24270
|
-
"../agent-core/dist/chunk-
|
|
24298
|
+
var import_crypto2, ERROR_SPECS, AGENT_ERROR_KINDS, STATUS_PREFIX, TEXT_RULES, CODEX_TIMEOUT_MESSAGE, CODEX_EXPIRED_MESSAGE, EPOCH_RESET, WORDED_RESET, COMMAND_NOT_FOUND, CODE_RULES, TEXT_REFINES, STATUS_LEAD, CLI_PROBLEM_CODE_BY_ERROR_KIND, KEY_REJECTION_KINDS;
|
|
24299
|
+
var init_chunk_R6R6ORR2 = __esm({
|
|
24300
|
+
"../agent-core/dist/chunk-R6R6ORR2.js"() {
|
|
24271
24301
|
"use strict";
|
|
24272
24302
|
init_chunk_YXWJW7I5();
|
|
24273
24303
|
import_crypto2 = require("crypto");
|
|
@@ -24301,6 +24331,10 @@ var init_chunk_BR4I6MQF = __esm({
|
|
|
24301
24331
|
message: "This model requires a paid subscription. Switch to a supported model or upgrade your plan.",
|
|
24302
24332
|
recoveryClass: "user_fixable"
|
|
24303
24333
|
},
|
|
24334
|
+
payment_required: {
|
|
24335
|
+
message: "The account behind this model has no active plan or credits. Ask an admin to check billing, or switch to a model from your own provider, then retry.",
|
|
24336
|
+
recoveryClass: "user_fixable"
|
|
24337
|
+
},
|
|
24304
24338
|
quota_exceeded: {
|
|
24305
24339
|
message: "API quota exceeded. Wait for it to reset or check your billing, then retry.",
|
|
24306
24340
|
recoveryClass: "user_fixable"
|
|
@@ -24477,6 +24511,7 @@ var init_chunk_BR4I6MQF = __esm({
|
|
|
24477
24511
|
rate_limited: /* @__PURE__ */ new Set(["usage_limit", "quota_exceeded"]),
|
|
24478
24512
|
auth_invalid: /* @__PURE__ */ new Set(["auth_expired", "not_logged_in", "not_authenticated"])
|
|
24479
24513
|
};
|
|
24514
|
+
STATUS_LEAD = /^(?:api error|status|http)[:\s]+\d{3}\b[:\s]*/i;
|
|
24480
24515
|
CLI_PROBLEM_CODE_BY_ERROR_KIND = {
|
|
24481
24516
|
model_mismatch: "cli.model.unavailable",
|
|
24482
24517
|
auth_invalid: "cli.auth.invalid",
|
|
@@ -24485,6 +24520,7 @@ var init_chunk_BR4I6MQF = __esm({
|
|
|
24485
24520
|
not_authenticated: "cli.auth.invalid",
|
|
24486
24521
|
auth_expired: "cli.auth.expired",
|
|
24487
24522
|
subscription_required: "cli.entitlement.required",
|
|
24523
|
+
payment_required: "cli.entitlement.required",
|
|
24488
24524
|
quota_exceeded: "cli.quota_exceeded",
|
|
24489
24525
|
usage_limit: "cli.quota_exceeded",
|
|
24490
24526
|
context_length: "cli.context_exhausted",
|
|
@@ -24511,7 +24547,7 @@ var init_chunk_BR4I6MQF = __esm({
|
|
|
24511
24547
|
}
|
|
24512
24548
|
});
|
|
24513
24549
|
|
|
24514
|
-
// ../agent-core/dist/chunk-
|
|
24550
|
+
// ../agent-core/dist/chunk-W3QH4J4A.js
|
|
24515
24551
|
function collectStrings(value, out) {
|
|
24516
24552
|
if (typeof value === "string") out.push(value);
|
|
24517
24553
|
else if (Array.isArray(value)) for (const item of value) collectStrings(item, out);
|
|
@@ -24603,8 +24639,8 @@ function readMediaFiles(candidates2, cwd, mimeByExt, maxBytes) {
|
|
|
24603
24639
|
seen.add(path);
|
|
24604
24640
|
const mimeType = mimeByExt[(0, import_path3.extname)(path).toLowerCase()];
|
|
24605
24641
|
if (!mimeType) continue;
|
|
24606
|
-
const
|
|
24607
|
-
if (!
|
|
24642
|
+
const stat14 = (0, import_fs4.statSync)(path);
|
|
24643
|
+
if (!stat14.isFile() || stat14.size <= 0 || stat14.size > maxBytes) continue;
|
|
24608
24644
|
files.push({ path, mimeType, buffer: (0, import_fs4.readFileSync)(path) });
|
|
24609
24645
|
}
|
|
24610
24646
|
return files;
|
|
@@ -24679,8 +24715,8 @@ function createJsonRpcPeer(writer, handlers) {
|
|
|
24679
24715
|
},
|
|
24680
24716
|
request: (method, params = {}) => {
|
|
24681
24717
|
const id = counter.next++;
|
|
24682
|
-
return new Promise((
|
|
24683
|
-
pending.set(id, { method, resolve:
|
|
24718
|
+
return new Promise((resolve6, reject) => {
|
|
24719
|
+
pending.set(id, { method, resolve: resolve6, reject });
|
|
24684
24720
|
writer.write({ id, method, params }).catch((error61) => {
|
|
24685
24721
|
pending.delete(id);
|
|
24686
24722
|
reject(error61 instanceof Error ? error61 : new Error(String(error61)));
|
|
@@ -24793,7 +24829,7 @@ function createNdjsonWriter(stream) {
|
|
|
24793
24829
|
get writable() {
|
|
24794
24830
|
return stream.writable && !stream.destroyed && failure5.error === void 0;
|
|
24795
24831
|
},
|
|
24796
|
-
write: (value) => new Promise((
|
|
24832
|
+
write: (value) => new Promise((resolve6, reject) => {
|
|
24797
24833
|
if (failure5.error) {
|
|
24798
24834
|
reject(failure5.error);
|
|
24799
24835
|
return;
|
|
@@ -24805,7 +24841,7 @@ function createNdjsonWriter(stream) {
|
|
|
24805
24841
|
stream.write(`${JSON.stringify(value)}
|
|
24806
24842
|
`, (error61) => {
|
|
24807
24843
|
if (error61) reject(error61);
|
|
24808
|
-
else
|
|
24844
|
+
else resolve6();
|
|
24809
24845
|
});
|
|
24810
24846
|
}),
|
|
24811
24847
|
end: () => {
|
|
@@ -24821,11 +24857,11 @@ function hostProcess(child, tree, options, handlers) {
|
|
|
24821
24857
|
const stderr = new LineSplitter((line) => handlers.onStderrLine(line));
|
|
24822
24858
|
child.stderr.on("data", (chunk) => stderr.push(chunk));
|
|
24823
24859
|
child.stderr.once("end", () => stderr.flush());
|
|
24824
|
-
const processExit = new Promise((
|
|
24825
|
-
child.once("exit", (code, signal) =>
|
|
24860
|
+
const processExit = new Promise((resolve6) => {
|
|
24861
|
+
child.once("exit", (code, signal) => resolve6({ code, signal }));
|
|
24826
24862
|
});
|
|
24827
|
-
const outputEnded = new Promise((
|
|
24828
|
-
child.stdout.once("close", () =>
|
|
24863
|
+
const outputEnded = new Promise((resolve6) => {
|
|
24864
|
+
child.stdout.once("close", () => resolve6());
|
|
24829
24865
|
});
|
|
24830
24866
|
const watch = async () => {
|
|
24831
24867
|
const { clock, stdoutDrainMs, log, name } = options;
|
|
@@ -24881,12 +24917,12 @@ function silentStartError(name, timeoutMs) {
|
|
|
24881
24917
|
};
|
|
24882
24918
|
}
|
|
24883
24919
|
var import_crypto3, import_fs4, import_path3, IMAGE_MIME_BY_EXT, VIDEO_MIME_BY_EXT, IMAGE_EXTENSIONS, VIDEO_EXTENSIONS, MAX_IMAGE_BYTES, MAX_VIDEO_BYTES, AGENT_BROWSER_MENTION, LocalMediaReader, SessionOpenRefusal, JsonRpcError, ACP_PROTOCOL_VERSION, ACP_ERROR, STDERR_TAIL_LINES, RESULT_EXIT_GRACE_MS, PerTurnSession;
|
|
24884
|
-
var
|
|
24885
|
-
"../agent-core/dist/chunk-
|
|
24920
|
+
var init_chunk_W3QH4J4A = __esm({
|
|
24921
|
+
"../agent-core/dist/chunk-W3QH4J4A.js"() {
|
|
24886
24922
|
"use strict";
|
|
24887
24923
|
init_chunk_UGRKZTAD();
|
|
24888
|
-
|
|
24889
|
-
|
|
24924
|
+
init_chunk_R6R6ORR2();
|
|
24925
|
+
init_chunk_J4T6L5LX();
|
|
24890
24926
|
init_chunk_YXWJW7I5();
|
|
24891
24927
|
import_crypto3 = require("crypto");
|
|
24892
24928
|
import_fs4 = require("fs");
|
|
@@ -25114,13 +25150,13 @@ var init_chunk_UKUTSW3L = __esm({
|
|
|
25114
25150
|
const turnId = input2.turnId;
|
|
25115
25151
|
let finish = () => {
|
|
25116
25152
|
};
|
|
25117
|
-
const done = new Promise((
|
|
25153
|
+
const done = new Promise((resolve6) => {
|
|
25118
25154
|
finish = (outcome2) => {
|
|
25119
25155
|
if (this.#current?.id !== turnId) return;
|
|
25120
25156
|
this.#current = void 0;
|
|
25121
25157
|
if (this.#state === "busy") this.#state = "idle";
|
|
25122
25158
|
this.#emit({ type: "turn_ended", turnId, outcome: outcome2 });
|
|
25123
|
-
|
|
25159
|
+
resolve6({ turnId, outcome: outcome2, providerSessionId: this.#sessionId });
|
|
25124
25160
|
};
|
|
25125
25161
|
});
|
|
25126
25162
|
const pending = {
|
|
@@ -25316,20 +25352,20 @@ function canonicalizeManagedMcpToolName(toolName) {
|
|
|
25316
25352
|
return flattened ? `mcp__${MANAGED_MCP_SERVER_NAME}__${flattened[1]}` : toolName;
|
|
25317
25353
|
}
|
|
25318
25354
|
async function writeSecretFile(name, contents) {
|
|
25319
|
-
const dir = await (0,
|
|
25355
|
+
const dir = await (0, import_promises13.mkdtemp)((0, import_path4.join)((0, import_os2.tmpdir)(), "alan-mcp-"));
|
|
25320
25356
|
const path = (0, import_path4.join)(dir, name);
|
|
25321
25357
|
const remove = async () => {
|
|
25322
|
-
await (0,
|
|
25358
|
+
await (0, import_promises13.rm)(dir, { recursive: true, force: true });
|
|
25323
25359
|
};
|
|
25324
25360
|
try {
|
|
25325
|
-
await (0,
|
|
25361
|
+
await (0, import_promises13.writeFile)(path, contents, { mode: 384, flag: "wx" });
|
|
25326
25362
|
} catch (error61) {
|
|
25327
25363
|
await remove();
|
|
25328
25364
|
throw error61;
|
|
25329
25365
|
}
|
|
25330
25366
|
return { path, remove, [Symbol.asyncDispose]: remove };
|
|
25331
25367
|
}
|
|
25332
|
-
var import_crypto4, import_crypto5,
|
|
25368
|
+
var import_crypto4, import_crypto5, import_promises13, import_os2, import_path4, MANAGED_MCP_SERVER_NAME, RUN_SCOPED_SERVER, NAMESPACED_RUN_TOOL, FLATTENED_RUN_TOOL;
|
|
25333
25369
|
var init_chunk_J2KTV5FP = __esm({
|
|
25334
25370
|
"../agent-core/dist/chunk-J2KTV5FP.js"() {
|
|
25335
25371
|
"use strict";
|
|
@@ -25338,7 +25374,7 @@ var init_chunk_J2KTV5FP = __esm({
|
|
|
25338
25374
|
import_crypto5 = require("crypto");
|
|
25339
25375
|
init_agent2();
|
|
25340
25376
|
init_runtime_v2();
|
|
25341
|
-
|
|
25377
|
+
import_promises13 = require("fs/promises");
|
|
25342
25378
|
import_os2 = require("os");
|
|
25343
25379
|
import_path4 = require("path");
|
|
25344
25380
|
MANAGED_MCP_SERVER_NAME = "alan";
|
|
@@ -26253,9 +26289,12 @@ function resultMessageId(state) {
|
|
|
26253
26289
|
state.resultMessageId ??= synthId(state, "claude-result");
|
|
26254
26290
|
return state.resultMessageId;
|
|
26255
26291
|
}
|
|
26292
|
+
function isErrorResult(event) {
|
|
26293
|
+
return asString(event.subtype).startsWith("error") || event.is_error === true || event.terminal_reason === "api_error" || typeof event.api_error_status === "number";
|
|
26294
|
+
}
|
|
26256
26295
|
function parseResult(event, state) {
|
|
26257
26296
|
const stopReason = stopReasonFor(asString(event.stop_reason), event.is_error === true);
|
|
26258
|
-
const resultText2 = asString(event.result);
|
|
26297
|
+
const resultText2 = isErrorResult(event) ? "" : asString(event.result);
|
|
26259
26298
|
const updates = [];
|
|
26260
26299
|
const streamed = state.lastForegroundText;
|
|
26261
26300
|
if (resultText2) {
|
|
@@ -26736,21 +26775,21 @@ async function claudeTurnInput(run, context) {
|
|
|
26736
26775
|
const encoded = await Promise.all(
|
|
26737
26776
|
images.map(async (image) => ({
|
|
26738
26777
|
mimeType: image.mimeType,
|
|
26739
|
-
data: (await (0,
|
|
26778
|
+
data: (await (0, import_promises14.readFile)(image.path)).toString("base64")
|
|
26740
26779
|
}))
|
|
26741
26780
|
);
|
|
26742
26781
|
return { turnId: run.runId, text: text2, ...encoded.length ? { images: encoded } : {} };
|
|
26743
26782
|
}
|
|
26744
|
-
var import_crypto6, import_fs5, import_path5, import_crypto7,
|
|
26783
|
+
var import_crypto6, import_fs5, import_path5, import_crypto7, import_promises14, EDIT_TOOLS, ThoughtBlocks, UNDERSTOOD_SYSTEM_SUBTYPES, RATE_LIMIT_WARN_AT, CLAUDE_GRAMMAR_NAME, SUBAGENT_TOOL_NAMES, PLAN_ENTRY_STATUSES, controlResponseSchema, STOPPED_STATUSES, TaskRecords, TERMINAL_BACKGROUND_STATUSES, NON_TERMINAL_BACKGROUND_STATUSES, ASYNC_LAUNCH_ACK, BackgroundTasks, FAILED_STATUSES, STOPPED_BY_USER_TEXT, ClaudeTurn, STDERR_TAIL_LINES2, MAX_EARLY_LINES, UNSUPPORTED_STOP, OUTPUT_CLOSED_REASON, ClaudeSession, DEFAULTS, READ_ONLY_DISALLOWED_TOOLS, DEFAULT_MCP_TIMEOUT_MS;
|
|
26745
26784
|
var init_claude = __esm({
|
|
26746
26785
|
"../agent-core/dist/providers/claude.js"() {
|
|
26747
26786
|
"use strict";
|
|
26748
26787
|
init_chunk_DALFHI4B();
|
|
26749
|
-
|
|
26788
|
+
init_chunk_W3QH4J4A();
|
|
26750
26789
|
init_chunk_UGRKZTAD();
|
|
26751
|
-
|
|
26790
|
+
init_chunk_R6R6ORR2();
|
|
26752
26791
|
init_chunk_J2KTV5FP();
|
|
26753
|
-
|
|
26792
|
+
init_chunk_J4T6L5LX();
|
|
26754
26793
|
init_chunk_6WN2R725();
|
|
26755
26794
|
init_chunk_YXWJW7I5();
|
|
26756
26795
|
init_effort();
|
|
@@ -26764,7 +26803,7 @@ var init_claude = __esm({
|
|
|
26764
26803
|
import_fs5 = require("fs");
|
|
26765
26804
|
import_path5 = require("path");
|
|
26766
26805
|
import_crypto7 = require("crypto");
|
|
26767
|
-
|
|
26806
|
+
import_promises14 = require("fs/promises");
|
|
26768
26807
|
init_agent2();
|
|
26769
26808
|
EDIT_TOOLS = /* @__PURE__ */ new Set([
|
|
26770
26809
|
"Edit",
|
|
@@ -27463,8 +27502,8 @@ var init_claude = __esm({
|
|
|
27463
27502
|
}
|
|
27464
27503
|
async #awaitTaskStop(requestId, taskId) {
|
|
27465
27504
|
const timer = new AbortController();
|
|
27466
|
-
const answered = new Promise((
|
|
27467
|
-
this.#taskStops.set(requestId,
|
|
27505
|
+
const answered = new Promise((resolve6) => {
|
|
27506
|
+
this.#taskStops.set(requestId, resolve6);
|
|
27468
27507
|
});
|
|
27469
27508
|
const timeoutMs = this.#options.stopTaskTimeoutMs;
|
|
27470
27509
|
const timedOut = this.#options.clock.sleep(timeoutMs, timer.signal).then(
|
|
@@ -27537,17 +27576,17 @@ var init_claude = __esm({
|
|
|
27537
27576
|
};
|
|
27538
27577
|
let markStarted = () => {
|
|
27539
27578
|
};
|
|
27540
|
-
const whenStarted = new Promise((
|
|
27541
|
-
markStarted =
|
|
27579
|
+
const whenStarted = new Promise((resolve6) => {
|
|
27580
|
+
markStarted = resolve6;
|
|
27542
27581
|
});
|
|
27543
|
-
const done = new Promise((
|
|
27582
|
+
const done = new Promise((resolve6) => {
|
|
27544
27583
|
finish = (outcome2) => {
|
|
27545
27584
|
if (this.#current?.id !== id) return;
|
|
27546
27585
|
this.#current = void 0;
|
|
27547
27586
|
this.#lastTurn = turn;
|
|
27548
27587
|
if (this.#state === "busy") this.#state = "idle";
|
|
27549
27588
|
this.#emit({ type: "turn_ended", turnId: id, outcome: outcome2 });
|
|
27550
|
-
|
|
27589
|
+
resolve6({ turnId: id, outcome: outcome2, providerSessionId: this.#providerSessionId });
|
|
27551
27590
|
};
|
|
27552
27591
|
});
|
|
27553
27592
|
const active = {
|
|
@@ -27665,8 +27704,8 @@ var init_claude = __esm({
|
|
|
27665
27704
|
void removeLaunchFiles(this.#launchFiles).catch((error61) => {
|
|
27666
27705
|
this.#options.log.warn("claude.launch_files_cleanup_failed", { error: error61 });
|
|
27667
27706
|
});
|
|
27668
|
-
for (const
|
|
27669
|
-
|
|
27707
|
+
for (const resolve6 of this.#taskStops.values()) {
|
|
27708
|
+
resolve6({ ok: false, reason: "runtime_unavailable", message: "Claude Code exited." });
|
|
27670
27709
|
}
|
|
27671
27710
|
const active = this.#current;
|
|
27672
27711
|
if (active) {
|
|
@@ -28878,11 +28917,11 @@ var init_codex = __esm({
|
|
|
28878
28917
|
"../agent-core/dist/providers/codex.js"() {
|
|
28879
28918
|
"use strict";
|
|
28880
28919
|
init_chunk_DALFHI4B();
|
|
28881
|
-
|
|
28920
|
+
init_chunk_W3QH4J4A();
|
|
28882
28921
|
init_chunk_UGRKZTAD();
|
|
28883
|
-
|
|
28922
|
+
init_chunk_R6R6ORR2();
|
|
28884
28923
|
init_chunk_J2KTV5FP();
|
|
28885
|
-
|
|
28924
|
+
init_chunk_J4T6L5LX();
|
|
28886
28925
|
init_chunk_6WN2R725();
|
|
28887
28926
|
init_chunk_YXWJW7I5();
|
|
28888
28927
|
import_fs6 = require("fs");
|
|
@@ -29502,10 +29541,10 @@ var init_codex = __esm({
|
|
|
29502
29541
|
};
|
|
29503
29542
|
let identify = () => {
|
|
29504
29543
|
};
|
|
29505
|
-
const identified = new Promise((
|
|
29506
|
-
identify =
|
|
29544
|
+
const identified = new Promise((resolve6) => {
|
|
29545
|
+
identify = resolve6;
|
|
29507
29546
|
});
|
|
29508
|
-
const done = new Promise((
|
|
29547
|
+
const done = new Promise((resolve6) => {
|
|
29509
29548
|
finish = (outcome2) => {
|
|
29510
29549
|
if (this.#current?.id !== id) return;
|
|
29511
29550
|
this.#current = void 0;
|
|
@@ -29513,7 +29552,7 @@ var init_codex = __esm({
|
|
|
29513
29552
|
if (this.#state === "busy") this.#state = "idle";
|
|
29514
29553
|
this.#host.scanDescendants(true);
|
|
29515
29554
|
this.#emit({ type: "turn_ended", turnId: id, outcome: outcome2 });
|
|
29516
|
-
|
|
29555
|
+
resolve6({ turnId: id, outcome: outcome2, providerSessionId: this.#threadId });
|
|
29517
29556
|
};
|
|
29518
29557
|
});
|
|
29519
29558
|
const active = {
|
|
@@ -29986,7 +30025,7 @@ function alanCodeConfigContent(existing, input2) {
|
|
|
29986
30025
|
});
|
|
29987
30026
|
}
|
|
29988
30027
|
function readBody2(response) {
|
|
29989
|
-
return new Promise((
|
|
30028
|
+
return new Promise((resolve6, reject) => {
|
|
29990
30029
|
const chunks = [];
|
|
29991
30030
|
let size = 0;
|
|
29992
30031
|
response.on("data", (chunk) => {
|
|
@@ -29994,7 +30033,7 @@ function readBody2(response) {
|
|
|
29994
30033
|
if (size > MAX_CATALOG_BYTES) response.destroy(new Error("catalog too large"));
|
|
29995
30034
|
else chunks.push(chunk);
|
|
29996
30035
|
});
|
|
29997
|
-
response.on("end", () =>
|
|
30036
|
+
response.on("end", () => resolve6(Buffer.concat(chunks).toString("utf8")));
|
|
29998
30037
|
response.on("error", reject);
|
|
29999
30038
|
});
|
|
30000
30039
|
}
|
|
@@ -30010,13 +30049,13 @@ function parseResponseBody(text2, status) {
|
|
|
30010
30049
|
}
|
|
30011
30050
|
function getJson(url2, headers, timeout, signal) {
|
|
30012
30051
|
const request2 = url2.protocol === "https:" ? import_https.request : import_http3.request;
|
|
30013
|
-
return new Promise((
|
|
30052
|
+
return new Promise((resolve6, reject) => {
|
|
30014
30053
|
const outgoing = request2(url2, { method: "GET", headers, timeout, signal }, (response) => {
|
|
30015
30054
|
const status = response.statusCode ?? 0;
|
|
30016
30055
|
readBody2(response).then((text2) => {
|
|
30017
30056
|
const body = parseResponseBody(text2, status);
|
|
30018
30057
|
if (status < 200 || status >= 300) reject(new CatalogResponseError(status, body));
|
|
30019
|
-
else
|
|
30058
|
+
else resolve6(body);
|
|
30020
30059
|
}).catch(reject);
|
|
30021
30060
|
});
|
|
30022
30061
|
outgoing.on("timeout", () => outgoing.destroy(new Error("catalog timed out")));
|
|
@@ -30047,6 +30086,7 @@ async function fetchAlanCodeModels(access3, options = {}) {
|
|
|
30047
30086
|
if (!(error61 instanceof CatalogResponseError) || !error61.awaitingAcceptance || clock.monotonic() >= deadline)
|
|
30048
30087
|
throw error61;
|
|
30049
30088
|
await clock.sleep(Math.min(ACTIVATION_POLL_MS, deadline - clock.monotonic()), options.signal);
|
|
30089
|
+
if (clock.monotonic() >= deadline) throw error61;
|
|
30050
30090
|
}
|
|
30051
30091
|
}
|
|
30052
30092
|
}
|
|
@@ -30232,15 +30272,15 @@ async function writePlugin(directory, apiOrigin) {
|
|
|
30232
30272
|
const origin = (0, import_crypto11.createHash)("sha256").update(apiOrigin).digest("hex").slice(0, 12);
|
|
30233
30273
|
const target = (0, import_path8.join)(directory, `engine-plugin-v${ALAN_CODE_ENGINE_PLUGIN_VERSION}-${origin}.mjs`);
|
|
30234
30274
|
const temporary = `${target}.${(0, import_crypto11.randomUUID)()}.tmp`;
|
|
30235
|
-
await (0,
|
|
30236
|
-
await (0,
|
|
30237
|
-
await (0,
|
|
30275
|
+
await (0, import_promises15.mkdir)(directory, { recursive: true, mode: 448 });
|
|
30276
|
+
await (0, import_promises15.writeFile)(temporary, alanCodeEnginePluginSource(apiOrigin), { mode: 384 });
|
|
30277
|
+
await (0, import_promises15.rename)(temporary, target);
|
|
30238
30278
|
return (0, import_url.pathToFileURL)(target).href;
|
|
30239
30279
|
}
|
|
30240
30280
|
async function prepareAlanCodeProfile(input2) {
|
|
30241
30281
|
const directories = Object.values(alanCodeEngineDirectories(input2.engineRoot));
|
|
30242
30282
|
await Promise.all(
|
|
30243
|
-
directories.map((directory) => (0,
|
|
30283
|
+
directories.map((directory) => (0, import_promises15.mkdir)(directory, { recursive: true, mode: 448 }))
|
|
30244
30284
|
);
|
|
30245
30285
|
const [pluginUrl, models] = await Promise.all([
|
|
30246
30286
|
writePlugin((0, import_path8.join)(input2.engineRoot, "plugin"), input2.access.apiOrigin),
|
|
@@ -30263,7 +30303,7 @@ function alanCodeSystemPrompt(alanSystemPrompt) {
|
|
|
30263
30303
|
|
|
30264
30304
|
${instructions}` : ALAN_CODE_TOOL_NAMING_PROMPT;
|
|
30265
30305
|
}
|
|
30266
|
-
var import_http3, import_https, import_fs7, import_path7, import_crypto11,
|
|
30306
|
+
var import_http3, import_https, import_fs7, import_path7, import_crypto11, import_promises15, import_path8, import_url, ALAN_CODE_BASELINE_PROMPT, ALAN_CODE_ENGINE_PROVIDER_ID, DEFAULT_CONTEXT_WINDOW, DEFAULT_MAX_OUTPUT_TOKENS, ALAN_CODE_API_KEY_ENV, ALAN_CODE_CONVERSATION_ID_ENV, ALAN_CODE_PROXY_PATH, ALAN_CODE_WEBSEARCH_PATH, ALAN_CODE_CATALOG_PATH, CATALOG_TIMEOUT_MS, MAX_CATALOG_BYTES, ACTIVATION_WAIT_MS, ACTIVATION_POLL_MS, CatalogResponseError, ALAN_CODE_ENGINE_PATH_ENV, ALAN_CODE_ENGINE_COMMAND, ALAN_CODE_ENGINE_NAME, WINDOWS_RUNNABLE_EXTENSION, ALAN_CODE_ENGINE_PLUGIN_VERSION, ALAN_CODE_TOOL_NAMING_PROMPT;
|
|
30267
30307
|
var init_alan_code = __esm({
|
|
30268
30308
|
"../agent-core/dist/providers/alan-code.js"() {
|
|
30269
30309
|
"use strict";
|
|
@@ -30277,7 +30317,7 @@ var init_alan_code = __esm({
|
|
|
30277
30317
|
import_path7 = require("path");
|
|
30278
30318
|
init_runtime_v2();
|
|
30279
30319
|
import_crypto11 = require("crypto");
|
|
30280
|
-
|
|
30320
|
+
import_promises15 = require("fs/promises");
|
|
30281
30321
|
import_path8 = require("path");
|
|
30282
30322
|
import_url = require("url");
|
|
30283
30323
|
ALAN_CODE_BASELINE_PROMPT = "You are alan-code, an interactive CLI coding agent that helps users with software engineering tasks. Use the instructions below and the tools available to you to assist the user.\n\nDo not invent URLs. Use verified URLs or ones supplied by the user or project.\n\nIf the user asks for help or wants to give feedback, inform them of the following:\n- `--harness-help` / harness help: learn how to run alan-code\n- For product feedback or bugs, report through the Alan / Supatest issue channels used by this repository\n\nWhen the user directly asks about alan-code capabilities (for example \"can alan-code\u2026\", \"does the harness have\u2026\") or asks in second person about your abilities, answer from the tools and instructions available in this session. If a docs/fetch tool is available and project docs URLs are known, use them; otherwise inspect local README / AGENTS.md rather than inventing product claims.\n\n# Personality\n\nYour default personality and tone is concise, direct, and friendly. You communicate efficiently, always keeping the user clearly informed about ongoing actions without unnecessary detail. You always prioritize actionable guidance, clearly stating assumptions, environment prerequisites, and next steps. Unless explicitly asked, you avoid excessively verbose explanations about your work.\n\n# Tone and style\n\nYou should be concise, direct, and to the point. When you run a non-trivial bash command, you should explain what the command does and why you are running it, so the user understands what you are doing (especially important for commands that change their system).\nRemember that your output will be displayed on a command line interface. Your responses can use GitHub-flavored markdown for formatting, and will be rendered in a monospace font using the CommonMark specification.\nOutput text to communicate with the user; all text you output outside of tool use is displayed to the user. Only use tools to complete tasks. Never use tools like Bash or code comments as means to communicate with the user during the session.\nIf you cannot or will not help the user with something, do not lecture about why. Offer helpful alternatives if possible; otherwise keep the response to 1-2 sentences.\nOnly use emojis if the user explicitly requests it. Avoid emojis in all communication unless asked.\nIMPORTANT: Minimize output tokens while staying helpful, correct, and accurate. Only address the specific query or task. Avoid tangential information unless it is critical to completing the request. If you can answer in 1-3 sentences or a short paragraph, do that.\nAnswer the user's question directly. One-word answers are best when they suffice. Avoid text before/after your response such as \"The answer is <answer>.\", \"Here is the content of the file\u2026\", \"Based on the information provided\u2026\", or \"Here is what I will do next\u2026\". Examples of appropriate verbosity:\n<example>\nuser: what is 2+2?\nassistant: 4\n</example>\n\n<example>\nuser: is 11 a prime number?\nassistant: Yes\n</example>\n\n<example>\nuser: what command should I run to list files in the current directory?\nassistant: ls\n</example>\n\n<example>\nuser: what command should I run to watch files in the current directory?\nassistant: [use tools to inspect the project, then answer]\nnpm run dev\n</example>\n\n<example>\nuser: what files are in the directory src/?\nassistant: [lists files and sees foo.c, bar.c, baz.c]\nuser: which file contains the implementation of foo?\nassistant: src/foo.c\n</example>\n\n<example>\nuser: write tests for new feature\nassistant: [searches for similar tests, reads relevant files concurrently, edits/writes tests]\n</example>\n\n# Responsiveness\n\n## Preamble messages\n\nBefore making tool calls, send a brief preamble to the user explaining what you're about to do. When sending preamble messages, follow these principles and examples:\n\n- **Logically group related actions**: if you're about to run several related commands, describe them together in one preamble rather than sending a separate note for each.\n- **Keep it concise**: be no more than 1-2 sentences, focused on immediate, tangible next steps. (8\u201312 words for quick updates).\n- **Build on prior context**: if this is not your first tool call, use the preamble message to connect the dots with what's been done so far and create a sense of momentum and clarity for the user to understand your next actions.\n- **Keep your tone light, friendly and curious**: add small touches of personality in preambles feel collaborative and engaging.\n- **Exception**: Avoid adding a preamble for every trivial read (e.g., `cat` a single file) unless it's part of a larger grouped action.\n\nExamples:\n\n- \"I've explored the repo; now checking the API route definitions.\"\n- \"Next, I'll patch the config and update the related tests.\"\n- \"I'm about to scaffold the CLI commands and helper functions.\"\n- \"Ok cool, so I've wrapped my head around the repo. Now digging into the API routes.\"\n- \"Config's looking tidy. Next up is patching helpers to keep things in sync.\"\n- \"Finished poking at the DB gateway. I will now chase down error handling.\"\n- \"Alright, build pipeline order is interesting. Checking how it reports failures.\"\n- \"Spotted a clever caching util; now hunting where it gets used.\"\n\n# Planning\n\nIf a planning tool is available, use it when it helps track complex work. Keep the plan brief and update it as work progresses.\n\nNote that plans are not for padding out simple work with filler steps or stating the obvious. The content of your plan should not involve doing anything that you aren't capable of doing (i.e. don't try to test things that you can't test). Do not use plans for simple or single-step queries that you can just do or answer immediately.\n\nWhen a planning tool displays the plan, summarize only what changed or what comes next.\n\nKeep any active plan aligned with the work completed and remaining.\n\nUse a plan when:\n\n- The task is non-trivial and will require multiple actions over a long time horizon.\n- There are logical phases or dependencies where sequencing matters.\n- The work has ambiguity that benefits from outlining high-level goals.\n- You want intermediate checkpoints for feedback and validation.\n- When the user asked you to do more than one thing in a single prompt\n- The user has asked you to use the plan tool (aka \"TODOs\")\n- You generate additional steps while working, and plan to do them before yielding to the user\n\n## Examples\n\n**High-quality plans**\n\nExample 1:\n\n1. Add CLI entry with file args\n2. Parse Markdown via CommonMark library\n3. Apply semantic HTML template\n4. Handle code blocks, images, links\n5. Add error handling for invalid files\n\nExample 2:\n\n1. Define CSS variables for colors\n2. Add toggle with localStorage state\n3. Refactor components to use variables\n4. Verify all views for readability\n5. Add smooth theme-change transition\n\nExample 3:\n\n1. Set up Node.js + WebSocket server\n2. Add join/leave broadcast events\n3. Implement messaging with timestamps\n4. Add usernames + mention highlighting\n5. Persist messages in lightweight DB\n6. Add typing indicators + unread count\n\n**Low-quality plans**\n\nExample 1:\n\n1. Create CLI tool\n2. Add Markdown parser\n3. Convert to HTML\n\nExample 2:\n\n1. Add dark mode toggle\n2. Save preference\n3. Make styles look good\n\nExample 3:\n\n1. Create single-file HTML game\n2. Run quick sanity check\n3. Summarize usage instructions\n\nIf you need to write a plan, only write high quality plans, not low quality ones.\n\n## Plan mode and clarification (harness specifics)\n\n- When the session is in plan mode, inspect without making changes and produce a concrete plan. Outside plan mode, proceed with authorized work and ask for approval only when the action requires it.\n- Prefer the durable plan file path over relying on chat memory after compaction.\n- When requirements are ambiguous, ask a targeted question using an available user-input tool instead of guessing.\n- An execution checklist is not a substitute for a durable plan when the task requires one.\n\n# Task execution\n\nYou are a coding agent. Please keep going until the query is completely resolved, before ending your turn and yielding back to the user. Only terminate your turn when you are sure that the problem is solved. Autonomously resolve the query to the best of your ability, using the tools available to you, before coming back to the user. Do NOT guess or make up an answer.\n\nYou MUST adhere to the following criteria when solving queries:\n\n- Working on the repo(s) in the current environment is allowed, even if they are proprietary.\n- Analyzing code for vulnerabilities is allowed.\n- Showing user code and tool call details is allowed.\n- Use the editing tools available in the current host to modify files. Do not assume a particular tool name.\n\nIf completing the user's task requires writing or modifying files, your code and final answer should follow these coding guidelines, though user instructions (i.e. AGENTS.md) may override these guidelines:\n\n- Fix the problem at the root cause rather than applying surface-level patches, when possible.\n- Avoid unneeded complexity in your solution.\n- Do not attempt to fix unrelated bugs or broken tests. It is not your responsibility to fix them. (You may mention them to the user in your final message though.)\n- Update documentation as necessary.\n- Keep changes consistent with the style of the existing codebase. Changes should be minimal and focused on the task.\n- Use `git log` and `git blame` to search the history of the codebase if additional context is required.\n- NEVER add copyright or license headers unless specifically requested.\n- Do not waste tokens by re-reading files after editing them. The tool call will fail if it didn't work. The same goes for making folders, deleting folders, etc.\n- Do not `git commit` your changes or create new git branches unless explicitly requested.\n- Add comments when they explain a non-obvious invariant or reason for a decision.\n- Do not use one-letter variable names unless explicitly requested.\n- NEVER output inline citations like \"\u3010F:README.md\u2020L5-L14\u3011\" in your outputs. The CLI is not able to render these so they will just be broken in the UI. Instead, if you output valid filepaths, users will be able to click on them to open the files in their editor.\n\n# Validating your work\n\nIf the codebase has tests or the ability to build or run, consider using them to verify that your work is complete.\n\nWhen testing, your philosophy should be to start as specific as possible to the code you changed so that you can catch issues efficiently, then make your way to broader tests as you build confidence. If there's no test for the code you changed, and if the adjacent patterns in the codebases show that there's a logical place for you to add a test, you may do so. However, do not add tests to codebases with no tests.\n\nSimilarly, once you're confident in correctness, you can suggest or use formatting commands to ensure that your code is well formatted. If there are issues you can iterate up to 3 times to get formatting right, but if you still can't manage it's better to save the user time and present them a correct solution where you call out the formatting in your final message. If the codebase does not have a formatter configured, do not add one.\n\nFor all of testing, running, building, and formatting, do not attempt to fix unrelated bugs. It is not your responsibility to fix them. (You may mention them to the user in your final message though.)\n\nBe mindful of whether to run validation commands proactively. In the absence of behavioral guidance:\n\n- When running in a non-interactive mode where edits are auto-approved (print/headless, or the `allow edits` permission mode), proactively run tests, lint and do whatever you need to ensure you've completed the task.\n- In plan mode, stay read-only. Otherwise, run focused checks after changes when the host permits them.\n- When working on test-related tasks, such as adding tests, fixing tests, or reproducing a bug to verify behavior, you may proactively run tests regardless of permission mode. Use your judgement to decide whether this is a test-related task.\n\n# Ambition vs. precision\n\nFor tasks that have no prior context (i.e. the user is starting something brand new), you should feel free to be ambitious and demonstrate creativity with your implementation.\n\nIf you're operating in an existing codebase, you should make sure you do exactly what the user asks with surgical precision. Treat the surrounding codebase with respect, and don't overstep (i.e. changing filenames or variables unnecessarily). You should balance being sufficiently ambitious and proactive when completing tasks of this nature.\n\nYou should use judicious initiative to decide on the right level of detail and complexity to deliver based on the user's needs. This means showing good judgment that you're capable of doing the right extras without gold-plating. This might be demonstrated by high-value, creative touches when scope of the task is vague; while being surgical and targeted when scope is tightly specified.\n\n# Sharing progress updates\n\nFor especially longer tasks that you work on (i.e. requiring many tool calls, or a plan with multiple steps), you should provide progress updates back to the user at reasonable intervals. These updates should be structured as a concise sentence or two (no more than 8-10 words long) recapping progress so far in plain language: this update demonstrates your understanding of what needs to be done, progress so far (i.e. files explores, subtasks complete), and where you're going next.\n\nBefore doing large chunks of work that may incur latency as experienced by the user (i.e. writing a new file), you should send a concise message to the user with an update indicating what you're about to do to ensure they know what you're spending time on. Don't start editing or writing large files before informing the user what you are doing and why.\n\nThe messages you send before tool calls should describe what is immediately about to be done next in very concise language. If there was previous work done, this preamble message should also include a note about the work done so far to bring the user along.\n\n# Presenting your work and final message\n\nYour final message should read naturally, like an update from a concise teammate. For casual conversation, brainstorming tasks, or quick questions from the user, respond in a friendly, conversational tone. You should ask questions, suggest ideas, and adapt to the user's style. If you've finished a large amount of work, when describing what you've done to the user, you should follow the final answer formatting guidelines to communicate substantive changes. You don't need to add structured formatting for one-word answers, greetings, or purely conversational exchanges.\n\nYou can skip heavy formatting for single, simple actions or confirmations. In these cases, respond in plain sentences with any relevant next step or quick option. Reserve multi-section structured responses for results that need grouping or explanation.\n\nThe user is working on the same computer as you, and has access to your work. As such there's no need to show the full contents of large files you have already written unless the user explicitly asks for them. Similarly, if you've created or modified files, there's no need to tell users to \"save the file\" or \"copy the code into a file\"\u2014just reference the file path.\n\nComplete authorized next steps, including relevant tests. Ask before a consequential action that needs approval, and briefly report anything you could not verify.\n\nBrevity is very important as a default. You should be very concise (i.e. no more than 10 lines), but can relax this requirement for tasks where additional detail and comprehensiveness is important for the user's understanding.\n\n## Final answer structure and style guidelines\n\nYou are producing plain text that will later be styled by the CLI. Follow these rules exactly. Formatting should make results easy to scan, but not feel mechanical. Use judgment to decide how much structure adds value.\n\n**Section Headers**\n\n- Use only when they improve clarity \u2014 they are not mandatory for every answer.\n- Choose descriptive names that fit the content\n- Keep headers short (1\u20133 words) and in `**Title Case**`. Always start headers with `**` and end with `**`\n- Use the blank lines required by the renderer for headings and lists.\n- Section headers should only be used where they genuinely improve scanability; avoid fragmenting the answer.\n\n**Bullets**\n\n- Use `-` followed by a space for every bullet.\n- Merge related points when possible; avoid a bullet for every trivial detail.\n- Keep bullets to one line unless breaking for clarity is unavoidable.\n- Group into short lists (4\u20136 bullets) ordered by importance.\n- Use consistent keyword phrasing and formatting across sections.\n\n**Monospace**\n\n- Wrap all commands, file paths, env vars, and code identifiers in backticks (`` `...` ``).\n- Apply to inline examples and to bullet keywords if the keyword itself is a literal file/command.\n- Never mix monospace and bold markers; choose one based on whether it's a keyword (`**`) or inline code/path (`` ` ``).\n\n**File References**\n\nWhen referencing files in your response, make sure to include the relevant start line and always follow the below rules:\n\n- Use inline code to make file paths clickable.\n- Each reference should have a stand alone path. Even if it's the same file.\n- Accepted: absolute, workspace\u2011relative, a/ or b/ diff prefixes, or bare filename/suffix.\n- Line/column (1\u2011based, optional): :line[:column] or #Lline[Ccolumn] (column defaults to 1).\n- Do not use URIs like file://, vscode://, or https://.\n- Do not provide range of lines\n- Examples: src/app.ts, src/app.ts:42, b/server/index.js#L10, C:\\repo\\project\\main.rs:12:5\n\n**Structure**\n\n- Place related bullets together; don't mix unrelated concepts in the same section.\n- Order sections from general \u2192 specific \u2192 supporting info.\n- For subsections (e.g., \"Binaries\" under \"Rust Workspace\"), introduce with a bolded keyword bullet, then list items under it.\n- Match structure to complexity:\n - Multi-part or detailed results \u2192 use clear headers and grouped bullets.\n - Simple results \u2192 minimal headers, possibly just a short list or paragraph.\n\n**Tone**\n\n- Keep the voice collaborative and natural, like a coding partner handing off work.\n- Be concise and factual \u2014 no filler or conversational commentary and avoid unnecessary repetition\n- Use present tense and active voice (e.g., \"Runs tests\" not \"This will run tests\").\n- Keep descriptions self-contained; don't refer to \"above\" or \"below\".\n- Use parallel structure in lists for consistency.\n\n**Don't**\n\n- Don't use literal words \"bold\" or \"monospace\" in the content.\n- Don't nest bullets or create deep hierarchies.\n- Don't output ANSI escape codes directly \u2014 the CLI renderer applies them.\n- Don't cram unrelated keywords into a single bullet; split for clarity.\n- Don't let keyword lists run long \u2014 wrap or reformat for scanability.\n\nGenerally, ensure your final answers adapt their shape and depth to the request. For example, answers to code explanations should have a precise, structured explanation with code references that answer the question directly. For tasks with a simple implementation, lead with the outcome and supplement only with what's needed for clarity. Larger changes can be presented as a logical walkthrough of your approach, grouping related steps, explaining rationale where it adds value, and highlighting next actions to accelerate the user. Your answers should provide the right level of detail while being easily scannable.\n\nFor casual greetings, acknowledgements, or other one-off conversational messages that are not delivering substantive information or structured results, respond naturally without section headers or bullet formatting.\n\n# Professional objectivity\n\nPrioritize technical accuracy and truthfulness over validating the user's beliefs. Focus on facts and problem-solving. Be direct and objective without unnecessary praise or emotional validation. Disagree when needed. When uncertain, investigate before confirming the user's assumptions.\n\n# Proactiveness\n\nProactively complete work that follows from the user's request. Avoid unrelated actions that would surprise the user. Strike a balance between:\n\n1. Doing the right thing when asked, including follow-up actions\n2. Not surprising the user with unrequested actions\n For example, if the user asks how to approach something, answer first; do not immediately jump into edits.\n\n# Following conventions\n\nWhen changing files, first understand the file's conventions. Mimic code style, use existing libraries and utilities, and follow existing patterns.\n\n- NEVER assume a library is available, even if it is well known. Whenever you write code that uses a library or framework, first check that this codebase already uses it (neighboring files, package.json, cargo.toml, go.mod, etc.).\n- When creating a new component, first look at existing components for framework choice, naming, typing, and other conventions.\n- When editing code, first look at surrounding context (especially imports) to understand chosen frameworks/libraries, then make the change idiomatically.\n- Always follow security best practices. Never introduce code that exposes or logs secrets and keys. Never commit secrets or keys to the repository.\n\n# Doing tasks\n\nThe user will primarily request software engineering tasks: bugs, features, refactors, explanations, and more. Recommended steps:\n\n- Use available search/read tools extensively to understand the codebase and the query (in parallel when independent).\n- Implement the solution with the tools available to you.\n- Prefer editing existing files. Create documentation when the task or project instructions require it.\n- Verify when possible with tests. NEVER assume a specific test framework or script \u2014 check README / AGENTS.md or search the repo.\n- Run lint and typecheck commands (for example npm run lint, npm run typecheck, ruff, pnpm lint) if they were provided to you \u2014 see Validating your work for when to run them proactively vs. when to hold off. If you cannot find the correct command, ask the user, and if they supply it, proactively suggest writing it to AGENTS.md so you know next time.\n\n- Tool results and user messages may include <system-reminder> tags. Those tags contain useful reminders. They are NOT part of the user's provided input or the tool result.\n\n# Tool usage policy\n\n- Prefer specialized file tools over shell for reading, editing, writing, listing, and searching when those tools are available. Use the `grep`, `glob`, and `list` tools instead of bash for search and listing \u2014 they are ripgrep-backed and return structured, length-capped results. Use shell for real system commands (git, package managers, builds, tests, process control).\n- When doing broad codebase exploration, use the available search tools and delegate only when the task benefits from independent work.\n- You can call multiple tools in one response. When multiple independent pieces of information are needed, batch tool calls for performance. When making multiple bash tool calls, send a single message with multiple tool calls so they can run in parallel (for example git status and git diff together).\n- Match edit old-text exactly, including whitespace.\n- If a tool call is denied by policy, adapt: use an allowed approach or ask the user. Do not retry the same blocked call in a loop.\n\n## Shell commands\n\nWhen using the shell, you must adhere to the following guidelines:\n\n- When searching for text or files, prefer using `rg` or `rg --files` respectively because `rg` is much faster than alternatives like `grep` and `find`. (If the `rg` command is not found, then use alternatives.) Reach for the shell only when the `grep`/`glob` tools cannot express the query \u2014 for example counting matches, or piping results into another command.\n- Search narrow first: use `rg -l` or `rg -c` to find which files match, then read only those files. Do not dump full match bodies across a repo into context.\n- Never pipe a large file into your context. Do not `cat` a big file; use the `read` tool with an offset/limit, or `sed -n 'START,ENDp'` for a specific range.\n- Do not use python scripts to attempt to output larger chunks of a file.\n\nIMPORTANT: Before you begin work, think about what the code you're editing is supposed to do based on the filenames and directory structure.\n\n# AGENTS.md spec\n\n- Repos often contain AGENTS.md files. These files can appear anywhere within the repository.\n- These files are a way for humans to give you (the agent) instructions or tips for working within the container.\n- Some examples might be: coding conventions, info about how code is organized, or instructions for how to run or test code.\n- Instructions in AGENTS.md files:\n - The scope of an AGENTS.md file is the entire directory tree rooted at the folder that contains it.\n - For every file you touch in the final change, you must obey instructions in any AGENTS.md file whose scope includes that file.\n - Instructions about code style, structure, naming, etc. apply only to code within the AGENTS.md file's scope, unless the file states otherwise.\n - More-deeply-nested AGENTS.md files take precedence in the case of conflicting instructions.\n - Direct system/developer/user instructions (as part of a prompt) take precedence over AGENTS.md instructions.\n- The contents of the AGENTS.md file at the root of the repo and the project directory are loaded into your context automatically and don't need to be re-read. AGENTS.md files in subdirectories are NOT loaded automatically: when working in a subdirectory, or a directory outside the CWD, check for any AGENTS.md files that may be applicable.\n\n# Permissions and safety\n\n- Never commit secrets or keys.\n- Never create a git commit unless the user explicitly asks.\n- Do not run destructive commands (mass delete, force-push, hard reset) unless the user clearly requested them.\n";
|
|
@@ -37646,10 +37686,10 @@ var require_dist = __commonJS({
|
|
|
37646
37686
|
var init_dist = __esm({
|
|
37647
37687
|
"../agent-core/dist/index.js"() {
|
|
37648
37688
|
"use strict";
|
|
37649
|
-
|
|
37689
|
+
init_chunk_W3QH4J4A();
|
|
37650
37690
|
init_chunk_UGRKZTAD();
|
|
37651
|
-
|
|
37652
|
-
|
|
37691
|
+
init_chunk_R6R6ORR2();
|
|
37692
|
+
init_chunk_J4T6L5LX();
|
|
37653
37693
|
init_chunk_YXWJW7I5();
|
|
37654
37694
|
}
|
|
37655
37695
|
});
|
|
@@ -37741,7 +37781,7 @@ function within(root, path) {
|
|
|
37741
37781
|
}
|
|
37742
37782
|
async function resolveReal(path) {
|
|
37743
37783
|
try {
|
|
37744
|
-
return await (0,
|
|
37784
|
+
return await (0, import_promises22.realpath)(path);
|
|
37745
37785
|
} catch {
|
|
37746
37786
|
const parent = (0, import_path9.dirname)(path);
|
|
37747
37787
|
if (parent === path) return path;
|
|
@@ -37770,14 +37810,14 @@ function createWorkspaceFs(roots, writable) {
|
|
|
37770
37810
|
return {
|
|
37771
37811
|
read: async (params) => {
|
|
37772
37812
|
const path = await confined(params);
|
|
37773
|
-
const bytes = await (0,
|
|
37813
|
+
const bytes = await (0, import_promises22.readFile)(path);
|
|
37774
37814
|
if (bytes.byteLength > MAX_READ_BYTES) throw new FsDenied(`${path} is too large to read`);
|
|
37775
37815
|
return { content: sliceLines(bytes.toString("utf8"), params) };
|
|
37776
37816
|
},
|
|
37777
37817
|
write: async (params) => {
|
|
37778
37818
|
if (!writable) throw new FsDenied("This session is read-only");
|
|
37779
37819
|
const path = await confined(params);
|
|
37780
|
-
await (0,
|
|
37820
|
+
await (0, import_promises22.writeFile)(path, asString(params.content));
|
|
37781
37821
|
return {};
|
|
37782
37822
|
}
|
|
37783
37823
|
};
|
|
@@ -38380,7 +38420,7 @@ async function acpTurnInput(run, context) {
|
|
|
38380
38420
|
const encoded = await Promise.all(
|
|
38381
38421
|
images.map(async (image) => ({
|
|
38382
38422
|
mimeType: image.mimeType,
|
|
38383
|
-
data: (await (0,
|
|
38423
|
+
data: (await (0, import_promises23.readFile)(image.path)).toString("base64")
|
|
38384
38424
|
}))
|
|
38385
38425
|
);
|
|
38386
38426
|
return {
|
|
@@ -38389,23 +38429,23 @@ async function acpTurnInput(run, context) {
|
|
|
38389
38429
|
...encoded.length ? { images: encoded, imagePaths: images.map((image) => image.path) } : {}
|
|
38390
38430
|
};
|
|
38391
38431
|
}
|
|
38392
|
-
var
|
|
38432
|
+
var import_promises22, import_path9, import_crypto12, import_promises23, CURSOR_ASK_QUESTION, copilotAcpProfile, cursorAcpProfile, MODEL_REJECTED, MAX_READ_BYTES, FsDenied, ENV_REFERENCE, AcpBackgroundTasks, CURSOR_CREATE_PLAN, STATUSES, READ_KINDS, ALLOW_KINDS, REJECT_KINDS, CANCELLED_PERMISSION, STOP_REASONS, CHUNKS, ECHOES, AcpTurn, STDERR_TAIL_LINES4, MAX_BETWEEN_UPDATES2, AcpSession, DEFAULTS3, CLIENT_INFO2, TASK_BACKGROUNDED, TASK_COMPLETED, SESSION_NOTIFICATION, KILLED_STATUSES, SUCCESS_STATUSES, SUBAGENT_ID, grokTaskDialect, grokAcpProfile, kimiAcpProfile, ACP_PROFILES, ACP_MODES;
|
|
38393
38433
|
var init_acp3 = __esm({
|
|
38394
38434
|
"../agent-core/dist/providers/acp.js"() {
|
|
38395
38435
|
"use strict";
|
|
38396
|
-
|
|
38436
|
+
init_chunk_W3QH4J4A();
|
|
38397
38437
|
init_chunk_UGRKZTAD();
|
|
38398
|
-
|
|
38438
|
+
init_chunk_R6R6ORR2();
|
|
38399
38439
|
init_chunk_J2KTV5FP();
|
|
38400
|
-
|
|
38440
|
+
init_chunk_J4T6L5LX();
|
|
38401
38441
|
init_chunk_6WN2R725();
|
|
38402
38442
|
init_chunk_YXWJW7I5();
|
|
38403
|
-
|
|
38443
|
+
import_promises22 = require("fs/promises");
|
|
38404
38444
|
import_path9 = require("path");
|
|
38405
38445
|
init_effort();
|
|
38406
38446
|
init_acp();
|
|
38407
38447
|
import_crypto12 = require("crypto");
|
|
38408
|
-
|
|
38448
|
+
import_promises23 = require("fs/promises");
|
|
38409
38449
|
init_agent2();
|
|
38410
38450
|
CURSOR_ASK_QUESTION = "cursor/ask_question";
|
|
38411
38451
|
copilotAcpProfile = {
|
|
@@ -38921,7 +38961,7 @@ var init_acp3 = __esm({
|
|
|
38921
38961
|
const turn = new AcpTurn(`acp-${this.#turns}-${id}`, this.#profile);
|
|
38922
38962
|
let finish = () => {
|
|
38923
38963
|
};
|
|
38924
|
-
const done = new Promise((
|
|
38964
|
+
const done = new Promise((resolve6) => {
|
|
38925
38965
|
finish = (outcome2) => {
|
|
38926
38966
|
if (this.#current?.id !== id) return;
|
|
38927
38967
|
this.#current = void 0;
|
|
@@ -38929,7 +38969,7 @@ var init_acp3 = __esm({
|
|
|
38929
38969
|
if (this.#state === "busy") this.#state = "idle";
|
|
38930
38970
|
this.#host.scanDescendants(true);
|
|
38931
38971
|
this.#emit({ type: "turn_ended", turnId: id, outcome: outcome2 });
|
|
38932
|
-
|
|
38972
|
+
resolve6({ turnId: id, outcome: outcome2, providerSessionId: this.#sessionId });
|
|
38933
38973
|
};
|
|
38934
38974
|
});
|
|
38935
38975
|
const active = { id, turn, done, finish, cancelRequested: false };
|
|
@@ -39210,7 +39250,7 @@ var init_acp3 = __esm({
|
|
|
39210
39250
|
var init_classify = __esm({
|
|
39211
39251
|
"../agent-core/dist/classify.js"() {
|
|
39212
39252
|
"use strict";
|
|
39213
|
-
|
|
39253
|
+
init_chunk_R6R6ORR2();
|
|
39214
39254
|
init_chunk_YXWJW7I5();
|
|
39215
39255
|
}
|
|
39216
39256
|
});
|
|
@@ -39374,7 +39414,8 @@ function createPersistentDriver(provider4, options) {
|
|
|
39374
39414
|
};
|
|
39375
39415
|
signal.addEventListener("abort", onAbort, { once: true });
|
|
39376
39416
|
try {
|
|
39377
|
-
const
|
|
39417
|
+
const contextPrefix = [inputs.turnContext, opened.contextPrefix].filter((part) => part !== void 0).join("\n\n");
|
|
39418
|
+
const input2 = await provider4.turnInput(spec, inputs, contextPrefix || void 0);
|
|
39378
39419
|
if (signal.aborted) return { outcome: "aborted" };
|
|
39379
39420
|
const result = await session.sendTurn(input2);
|
|
39380
39421
|
live.providerSessionId = result.providerSessionId ?? live.providerSessionId;
|
|
@@ -39566,10 +39607,10 @@ function parseSseBlock(block) {
|
|
|
39566
39607
|
return { type, properties: asRecord(record2.properties) ?? {} };
|
|
39567
39608
|
}
|
|
39568
39609
|
function readText(incoming) {
|
|
39569
|
-
return new Promise((
|
|
39610
|
+
return new Promise((resolve23, reject) => {
|
|
39570
39611
|
const chunks = [];
|
|
39571
39612
|
incoming.on("data", (chunk) => chunks.push(chunk));
|
|
39572
|
-
incoming.on("end", () =>
|
|
39613
|
+
incoming.on("end", () => resolve23(Buffer.concat(chunks).toString("utf8")));
|
|
39573
39614
|
incoming.on("error", reject);
|
|
39574
39615
|
});
|
|
39575
39616
|
}
|
|
@@ -39812,7 +39853,7 @@ function notice(kind, message) {
|
|
|
39812
39853
|
function promptParts2(input2) {
|
|
39813
39854
|
const files = (input2.imagePaths ?? []).map((path, index) => ({
|
|
39814
39855
|
type: "file",
|
|
39815
|
-
mime: input2.images?.[index]?.mimeType ?? IMAGE_TYPES[(0,
|
|
39856
|
+
mime: input2.images?.[index]?.mimeType ?? IMAGE_TYPES[(0, import_path11.extname)(path).toLowerCase()] ?? "application/octet-stream",
|
|
39816
39857
|
filename: path.split(/[\\/]/).at(-1) ?? path,
|
|
39817
39858
|
url: (0, import_url2.pathToFileURL)(path).href
|
|
39818
39859
|
}));
|
|
@@ -39904,6 +39945,34 @@ async function startServer(spec, password, options, attempt) {
|
|
|
39904
39945
|
}
|
|
39905
39946
|
}
|
|
39906
39947
|
}
|
|
39948
|
+
async function canResume(client, sessionId, log) {
|
|
39949
|
+
const stored = await client.readSession(sessionId);
|
|
39950
|
+
if (!stored) {
|
|
39951
|
+
log.warn("opencode.resume_failed", { sessionId, reason: "missing" });
|
|
39952
|
+
return false;
|
|
39953
|
+
}
|
|
39954
|
+
if (!stored.directory) return true;
|
|
39955
|
+
const directory = await client.directory();
|
|
39956
|
+
if (await sameDirectory(stored.directory, directory)) return true;
|
|
39957
|
+
log.warn("opencode.resume_failed", {
|
|
39958
|
+
sessionId,
|
|
39959
|
+
reason: "directory_changed",
|
|
39960
|
+
sessionDirectory: stored.directory,
|
|
39961
|
+
serverDirectory: directory
|
|
39962
|
+
});
|
|
39963
|
+
return false;
|
|
39964
|
+
}
|
|
39965
|
+
async function sameDirectory(left, right) {
|
|
39966
|
+
const [a, b] = await Promise.all([canonicalDirectory(left), canonicalDirectory(right)]);
|
|
39967
|
+
return process.platform === "win32" ? a.toLowerCase() === b.toLowerCase() : a === b;
|
|
39968
|
+
}
|
|
39969
|
+
async function canonicalDirectory(directory) {
|
|
39970
|
+
try {
|
|
39971
|
+
return await (0, import_promises24.realpath)(directory);
|
|
39972
|
+
} catch {
|
|
39973
|
+
return (0, import_path10.resolve)(directory);
|
|
39974
|
+
}
|
|
39975
|
+
}
|
|
39907
39976
|
async function openSession(session, client, spec, log) {
|
|
39908
39977
|
const health = await client.health();
|
|
39909
39978
|
const verdict = judgeOpenCodeVersion(health.version);
|
|
@@ -39919,11 +39988,8 @@ async function openSession(session, client, spec, log) {
|
|
|
39919
39988
|
}
|
|
39920
39989
|
await session.connect(client);
|
|
39921
39990
|
const resumeId = spec.resumeSessionId;
|
|
39922
|
-
if (resumeId && await client
|
|
39923
|
-
if (resumeId)
|
|
39924
|
-
log.warn("opencode.resume_failed", { sessionId: resumeId });
|
|
39925
|
-
session.resumeFailed = true;
|
|
39926
|
-
}
|
|
39991
|
+
if (resumeId && await canResume(client, resumeId, log)) return { id: resumeId, resumed: true };
|
|
39992
|
+
if (resumeId) session.resumeFailed = true;
|
|
39927
39993
|
const id = await client.createSession({ title: spec.title, permission: NON_INTERACTIVE_RULES });
|
|
39928
39994
|
return { id, resumed: false };
|
|
39929
39995
|
}
|
|
@@ -40074,22 +40140,24 @@ function openCodeTurnInput(run, context) {
|
|
|
40074
40140
|
...images.length ? { imagePaths: images.map((image) => image.path) } : {}
|
|
40075
40141
|
};
|
|
40076
40142
|
}
|
|
40077
|
-
var import_http4, import_crypto13, import_path10, import_url2, import_crypto14, IDLE_SOCKET_MS2, OpenCodeHttpError, OpenCodeClient, OPENCODE_CONFIG_ENV, OPENCODE_ENGINE, TEXT_PARTS, STEP_PARTS, STOPPED_BY_USER, OpenCodeSubagents, NAMED_KINDS, OPENCODE_ABORTED_ERROR, PROVIDER_EVENT_META, TASK_TOOL_NAME, TASK_RESULT_TAG, TASK_ERROR_TAG, PERMISSION_DENIED, FILE_OPERATIONS, PartReader, NOTHING, NON_INTERACTIVE_PERMISSIONS, CONTENT_FILTER_FINISHES, OUTPUT_PARTS, OpenCodeTurn, LISTENING, OUTPUT_TAIL_LINES, IMAGE_TYPES, OpenCodeSession, OPENCODE_MIN_VERSION, OPENCODE_REQUIREMENT, OPENCODE_TESTED_LINE, OPENCODE_SUPPORTED_MAJOR, DEFAULTS4, STORE_LOCKED, NON_INTERACTIVE_RULES, TITLE_LENGTH, MAX_VARIANT_LENGTH;
|
|
40143
|
+
var import_http4, import_crypto13, import_promises24, import_path10, import_path11, import_url2, import_crypto14, IDLE_SOCKET_MS2, OpenCodeHttpError, OpenCodeClient, OPENCODE_CONFIG_ENV, OPENCODE_ENGINE, TEXT_PARTS, STEP_PARTS, STOPPED_BY_USER, OpenCodeSubagents, NAMED_KINDS, OPENCODE_ABORTED_ERROR, PROVIDER_EVENT_META, TASK_TOOL_NAME, TASK_RESULT_TAG, TASK_ERROR_TAG, PERMISSION_DENIED, FILE_OPERATIONS, PartReader, NOTHING, NON_INTERACTIVE_PERMISSIONS, CONTENT_FILTER_FINISHES, OUTPUT_PARTS, OpenCodeTurn, LISTENING, OUTPUT_TAIL_LINES, IMAGE_TYPES, OpenCodeSession, OPENCODE_MIN_VERSION, OPENCODE_REQUIREMENT, OPENCODE_TESTED_LINE, OPENCODE_SUPPORTED_MAJOR, DEFAULTS4, STORE_LOCKED, NON_INTERACTIVE_RULES, TITLE_LENGTH, MAX_VARIANT_LENGTH;
|
|
40078
40144
|
var init_opencode = __esm({
|
|
40079
40145
|
"../agent-core/dist/providers/opencode.js"() {
|
|
40080
40146
|
"use strict";
|
|
40081
|
-
|
|
40147
|
+
init_chunk_W3QH4J4A();
|
|
40082
40148
|
init_chunk_UGRKZTAD();
|
|
40083
|
-
|
|
40149
|
+
init_chunk_R6R6ORR2();
|
|
40084
40150
|
init_chunk_J2KTV5FP();
|
|
40085
|
-
|
|
40151
|
+
init_chunk_J4T6L5LX();
|
|
40086
40152
|
init_chunk_6WN2R725();
|
|
40087
40153
|
init_chunk_YXWJW7I5();
|
|
40088
40154
|
import_http4 = require("http");
|
|
40089
40155
|
init_runtime_v2();
|
|
40090
40156
|
import_crypto13 = require("crypto");
|
|
40091
|
-
|
|
40157
|
+
import_promises24 = require("fs/promises");
|
|
40092
40158
|
import_path10 = require("path");
|
|
40159
|
+
init_agent2();
|
|
40160
|
+
import_path11 = require("path");
|
|
40093
40161
|
import_url2 = require("url");
|
|
40094
40162
|
init_acp();
|
|
40095
40163
|
import_crypto14 = require("crypto");
|
|
@@ -40116,11 +40184,11 @@ var init_opencode = __esm({
|
|
|
40116
40184
|
this.#engine = engine;
|
|
40117
40185
|
}
|
|
40118
40186
|
#open(call) {
|
|
40119
|
-
return new Promise((
|
|
40187
|
+
return new Promise((resolve23, reject) => {
|
|
40120
40188
|
const outgoing = (0, import_http4.request)(
|
|
40121
40189
|
`${this.baseUrl}${call.path}`,
|
|
40122
40190
|
{ method: call.method, headers: call.headers, agent: this.#agent },
|
|
40123
|
-
|
|
40191
|
+
resolve23
|
|
40124
40192
|
);
|
|
40125
40193
|
outgoing.on("error", reject);
|
|
40126
40194
|
outgoing.end(call.body);
|
|
@@ -40157,18 +40225,25 @@ var init_opencode = __esm({
|
|
|
40157
40225
|
return id;
|
|
40158
40226
|
}
|
|
40159
40227
|
/**
|
|
40160
|
-
*
|
|
40161
|
-
* other failure raises, so a server hiccup never silently replaces the
|
|
40228
|
+
* The stored session, or undefined when the server's store does not have it. Only a 404
|
|
40229
|
+
* means that: any other failure raises, so a server hiccup never silently replaces the
|
|
40230
|
+
* conversation.
|
|
40162
40231
|
*/
|
|
40163
|
-
async
|
|
40232
|
+
async readSession(sessionId) {
|
|
40164
40233
|
try {
|
|
40165
|
-
|
|
40166
|
-
|
|
40234
|
+
const body = asRecord(
|
|
40235
|
+
await this.#call("session read", "GET", `/session/${encodeURIComponent(sessionId)}`)
|
|
40236
|
+
);
|
|
40237
|
+
return { directory: asString(body?.directory) };
|
|
40167
40238
|
} catch (error61) {
|
|
40168
|
-
if (error61 instanceof OpenCodeHttpError && error61.status === 404) return
|
|
40239
|
+
if (error61 instanceof OpenCodeHttpError && error61.status === 404) return void 0;
|
|
40169
40240
|
throw error61;
|
|
40170
40241
|
}
|
|
40171
40242
|
}
|
|
40243
|
+
/** The directory the server serves when a request names none: its own cwd. */
|
|
40244
|
+
async directory() {
|
|
40245
|
+
return asString(asRecord(await this.#call("path read", "GET", "/path"))?.directory);
|
|
40246
|
+
}
|
|
40172
40247
|
/** Answers 204 at once; the turn itself arrives on `/event`. */
|
|
40173
40248
|
async promptAsync(sessionId, body) {
|
|
40174
40249
|
await this.#call("prompt", "POST", `/session/${encodeURIComponent(sessionId)}/prompt_async`, {
|
|
@@ -40854,8 +40929,8 @@ var init_opencode = __esm({
|
|
|
40854
40929
|
onExit: (exit) => this.#onExit(exit)
|
|
40855
40930
|
}
|
|
40856
40931
|
);
|
|
40857
|
-
this.#listening = new Promise((
|
|
40858
|
-
this.#announce =
|
|
40932
|
+
this.#listening = new Promise((resolve23, reject) => {
|
|
40933
|
+
this.#announce = resolve23;
|
|
40859
40934
|
void this.#host.exited.then(
|
|
40860
40935
|
() => reject(
|
|
40861
40936
|
new CoreFault(
|
|
@@ -40944,12 +41019,8 @@ var init_opencode = __esm({
|
|
|
40944
41019
|
await client.promptAsync(sessionId, body);
|
|
40945
41020
|
} catch (error61) {
|
|
40946
41021
|
if (this.#state === "closed") return;
|
|
41022
|
+
if (this.#current?.id !== active.id) return;
|
|
40947
41023
|
const message = error61 instanceof Error ? error61.message : String(error61);
|
|
40948
|
-
this.#emit({
|
|
40949
|
-
type: "update",
|
|
40950
|
-
turnId: active.id,
|
|
40951
|
-
update: noticeUpdate("error", "provider", message)
|
|
40952
|
-
});
|
|
40953
41024
|
active.finish({ status: "failed", error: classifyProviderError(message) });
|
|
40954
41025
|
}
|
|
40955
41026
|
}
|
|
@@ -41020,7 +41091,7 @@ var init_opencode = __esm({
|
|
|
41020
41091
|
);
|
|
41021
41092
|
let finish = () => {
|
|
41022
41093
|
};
|
|
41023
|
-
const done = new Promise((
|
|
41094
|
+
const done = new Promise((resolve23) => {
|
|
41024
41095
|
finish = (outcome2) => {
|
|
41025
41096
|
if (this.#current?.id !== id) return;
|
|
41026
41097
|
this.#current = void 0;
|
|
@@ -41028,7 +41099,7 @@ var init_opencode = __esm({
|
|
|
41028
41099
|
if (outcome2.status !== "completed") this.#repairPending = true;
|
|
41029
41100
|
this.#host.scanDescendants(true);
|
|
41030
41101
|
this.#emit({ type: "turn_ended", turnId: id, outcome: outcome2 });
|
|
41031
|
-
|
|
41102
|
+
resolve23({ turnId: id, outcome: outcome2, providerSessionId: this.#sessionId });
|
|
41032
41103
|
};
|
|
41033
41104
|
});
|
|
41034
41105
|
const active = {
|
|
@@ -41208,7 +41279,7 @@ function createAlanCodeHolderDriver(options) {
|
|
|
41208
41279
|
const engine = resolveAlanCodeEngine({ env, platform, packaged: [] });
|
|
41209
41280
|
const engineRoot = alanCodeEngineRoot(env.HOME?.trim() || (0, import_node_os2.homedir)());
|
|
41210
41281
|
options.log.info("alan_code.engine", { command: engine.command, source: engine.source });
|
|
41211
|
-
const
|
|
41282
|
+
const open4 = async (planned) => {
|
|
41212
41283
|
if (planned.profile === void 0) throw refuseWithoutCredential();
|
|
41213
41284
|
const { opencode } = planned;
|
|
41214
41285
|
const profile = await prepareAlanCodeProfile({
|
|
@@ -41265,7 +41336,7 @@ function createAlanCodeHolderDriver(options) {
|
|
|
41265
41336
|
};
|
|
41266
41337
|
},
|
|
41267
41338
|
canResume: () => true,
|
|
41268
|
-
open:
|
|
41339
|
+
open: open4,
|
|
41269
41340
|
turnInput: async (spec, inputs, contextPrefix) => openCodeTurnInput(spec, {
|
|
41270
41341
|
attachments: inputs.attachments,
|
|
41271
41342
|
skills: [],
|
|
@@ -41492,8 +41563,8 @@ function createDroidPeer(writer, handlers) {
|
|
|
41492
41563
|
},
|
|
41493
41564
|
request: (method, params = {}) => {
|
|
41494
41565
|
const id = `alan-${counter.next++}`;
|
|
41495
|
-
return new Promise((
|
|
41496
|
-
pending.set(id, { method, resolve:
|
|
41566
|
+
return new Promise((resolve6, reject) => {
|
|
41567
|
+
pending.set(id, { method, resolve: resolve6, reject });
|
|
41497
41568
|
writer.write(envelope("request", { id, method, params })).catch((error61) => {
|
|
41498
41569
|
pending.delete(id);
|
|
41499
41570
|
reject(error61 instanceof Error ? error61 : new Error(String(error61)));
|
|
@@ -41828,25 +41899,25 @@ async function droidTurnInput(run, context) {
|
|
|
41828
41899
|
const encoded = await Promise.all(
|
|
41829
41900
|
images.map(async (image) => ({
|
|
41830
41901
|
mimeType: image.mimeType,
|
|
41831
|
-
data: (await (0,
|
|
41902
|
+
data: (await (0, import_promises25.readFile)(image.path)).toString("base64")
|
|
41832
41903
|
}))
|
|
41833
41904
|
);
|
|
41834
41905
|
return { turnId: run.runId, text: text2, ...encoded.length ? { images: encoded } : {} };
|
|
41835
41906
|
}
|
|
41836
|
-
var import_crypto15,
|
|
41907
|
+
var import_crypto15, import_promises25, FACTORY_API_VERSION, FACTORY_PROTOCOL_VERSION, SUBAGENT_TOOLS, TASK_OUTPUT_TOOLS, TASK_STOP_TOOLS, SILENT2, DroidTurn, STDERR_TAIL_LINES5, UNSUPPORTED_REQUEST2, DroidSession, DEFAULTS5, DROID_REQUIREMENT, DROID_JSONRPC_ARGS;
|
|
41837
41908
|
var init_droid = __esm({
|
|
41838
41909
|
"../agent-core/dist/providers/droid.js"() {
|
|
41839
41910
|
"use strict";
|
|
41840
|
-
|
|
41911
|
+
init_chunk_W3QH4J4A();
|
|
41841
41912
|
init_chunk_UGRKZTAD();
|
|
41842
|
-
|
|
41913
|
+
init_chunk_R6R6ORR2();
|
|
41843
41914
|
init_chunk_J2KTV5FP();
|
|
41844
|
-
|
|
41915
|
+
init_chunk_J4T6L5LX();
|
|
41845
41916
|
init_chunk_6WN2R725();
|
|
41846
41917
|
init_chunk_YXWJW7I5();
|
|
41847
41918
|
init_runtime_v2();
|
|
41848
41919
|
import_crypto15 = require("crypto");
|
|
41849
|
-
|
|
41920
|
+
import_promises25 = require("fs/promises");
|
|
41850
41921
|
init_agent2();
|
|
41851
41922
|
FACTORY_API_VERSION = "1.0.0";
|
|
41852
41923
|
FACTORY_PROTOCOL_VERSION = "1.187.0";
|
|
@@ -42118,14 +42189,14 @@ var init_droid = __esm({
|
|
|
42118
42189
|
const turn = new DroidTurn(sessionId, this.#memory);
|
|
42119
42190
|
let finish = () => {
|
|
42120
42191
|
};
|
|
42121
|
-
const done = new Promise((
|
|
42192
|
+
const done = new Promise((resolve6) => {
|
|
42122
42193
|
finish = (outcome2) => {
|
|
42123
42194
|
if (this.#current?.id !== id) return;
|
|
42124
42195
|
this.#current = void 0;
|
|
42125
42196
|
if (this.#state === "busy") this.#state = "idle";
|
|
42126
42197
|
this.#host.scanDescendants(true);
|
|
42127
42198
|
this.#emit({ type: "turn_ended", turnId: id, outcome: outcome2 });
|
|
42128
|
-
|
|
42199
|
+
resolve6({ turnId: id, outcome: outcome2, providerSessionId: this.#sessionId });
|
|
42129
42200
|
};
|
|
42130
42201
|
});
|
|
42131
42202
|
const active = { id, turn, done, finish, cancelRequested: false };
|
|
@@ -42350,21 +42421,21 @@ function antigravityArgs(input2, capabilities, prompt) {
|
|
|
42350
42421
|
];
|
|
42351
42422
|
}
|
|
42352
42423
|
function workspaceRoot(cwd) {
|
|
42353
|
-
for (let current = (0,
|
|
42354
|
-
if ((0, import_fs8.existsSync)((0,
|
|
42355
|
-
if ((0,
|
|
42424
|
+
for (let current = (0, import_path12.resolve)(cwd); ; current = (0, import_path12.dirname)(current)) {
|
|
42425
|
+
if ((0, import_fs8.existsSync)((0, import_path12.join)(current, ".git"))) return current;
|
|
42426
|
+
if ((0, import_path12.dirname)(current) === current) return (0, import_path12.resolve)(cwd);
|
|
42356
42427
|
}
|
|
42357
42428
|
}
|
|
42358
42429
|
function instructionPaths(cwd) {
|
|
42359
42430
|
const root = workspaceRoot(cwd);
|
|
42360
42431
|
const paths = [];
|
|
42361
|
-
for (let current = (0,
|
|
42362
|
-
const path = (0,
|
|
42432
|
+
for (let current = (0, import_path12.resolve)(cwd); ; current = (0, import_path12.dirname)(current)) {
|
|
42433
|
+
const path = (0, import_path12.join)(current, INSTRUCTIONS_FILE);
|
|
42363
42434
|
try {
|
|
42364
42435
|
if ((0, import_fs8.existsSync)(path) && (0, import_fs8.statSync)(path).isFile()) paths.unshift(path);
|
|
42365
42436
|
} catch {
|
|
42366
42437
|
}
|
|
42367
|
-
if (current === root || (0,
|
|
42438
|
+
if (current === root || (0, import_path12.dirname)(current) === current) return paths;
|
|
42368
42439
|
}
|
|
42369
42440
|
}
|
|
42370
42441
|
function antigravityWorkspaceInstructions(cwd, maxChars = MAX_INSTRUCTION_CHARS) {
|
|
@@ -42618,7 +42689,7 @@ function normalizeAntigravityFrame(event) {
|
|
|
42618
42689
|
}
|
|
42619
42690
|
function antigravityBrainRoot(env) {
|
|
42620
42691
|
const home = env.HOME?.trim() || env.USERPROFILE?.trim();
|
|
42621
|
-
return home ? (0,
|
|
42692
|
+
return home ? (0, import_path13.resolve)(home, ".gemini", "antigravity-cli", "brain") : void 0;
|
|
42622
42693
|
}
|
|
42623
42694
|
function parseEntry(text2) {
|
|
42624
42695
|
try {
|
|
@@ -42656,14 +42727,14 @@ function childTranscriptPath(root, frame) {
|
|
|
42656
42727
|
try {
|
|
42657
42728
|
const url2 = new URL(logUri);
|
|
42658
42729
|
if (url2.protocol !== "file:") return void 0;
|
|
42659
|
-
path = (0,
|
|
42730
|
+
path = (0, import_path13.resolve)((0, import_url3.fileURLToPath)(url2));
|
|
42660
42731
|
} catch {
|
|
42661
42732
|
return void 0;
|
|
42662
42733
|
}
|
|
42663
|
-
const fromRoot = (0,
|
|
42664
|
-
if (!fromRoot || (0,
|
|
42734
|
+
const fromRoot = (0, import_path13.relative)(root, path);
|
|
42735
|
+
if (!fromRoot || (0, import_path13.isAbsolute)(fromRoot) || fromRoot.split(import_path13.sep).includes("..")) return void 0;
|
|
42665
42736
|
const expected = [conversationId, ...LOG_DIRS, TRANSCRIPT_FILE];
|
|
42666
|
-
const segments = fromRoot.split(
|
|
42737
|
+
const segments = fromRoot.split(import_path13.sep);
|
|
42667
42738
|
const matches = segments.length === expected.length && segments.every((segment, index) => segment === expected[index]);
|
|
42668
42739
|
return matches ? path : void 0;
|
|
42669
42740
|
}
|
|
@@ -42902,21 +42973,21 @@ function antigravityTurnInput(run, context) {
|
|
|
42902
42973
|
});
|
|
42903
42974
|
return { turnId: run.runId, text: appendImagePathReferences(text2, images) };
|
|
42904
42975
|
}
|
|
42905
|
-
var import_fs8,
|
|
42976
|
+
var import_fs8, import_path12, import_path13, import_url3, import_crypto16, NO_ANTIGRAVITY_CAPABILITIES, INSTRUCTIONS_FILE, MAX_INSTRUCTION_CHARS, SHORTENED_NOTE, DIFF_BLOCK_START, DIFF_BLOCK_END, HUNK_HEADER, TRANSCRIPT_FILE, FULL_TRANSCRIPT_FILE, LOG_DIRS, TOOL_RESULT_TYPES, BrainTranscript, AntigravityTranscripts, ANTIGRAVITY_GRAMMAR_NAME, AntigravityGrammar, ignored, HANDLERS, SUCCESSFUL_STATUSES, SESSION_START_TYPES, RESULT_TYPES, SUBAGENT_START_TYPES, RESUME_FORKED, EXITED_WITHOUT_RESULT, AntigravityTurn, DEFAULTS6, AntigravitySession, WINDOWS_LINE_MARGIN;
|
|
42906
42977
|
var init_antigravity = __esm({
|
|
42907
42978
|
"../agent-core/dist/providers/antigravity.js"() {
|
|
42908
42979
|
"use strict";
|
|
42909
42980
|
init_chunk_DALFHI4B();
|
|
42910
|
-
|
|
42981
|
+
init_chunk_W3QH4J4A();
|
|
42911
42982
|
init_chunk_UGRKZTAD();
|
|
42912
|
-
|
|
42913
|
-
|
|
42983
|
+
init_chunk_R6R6ORR2();
|
|
42984
|
+
init_chunk_J4T6L5LX();
|
|
42914
42985
|
init_chunk_6WN2R725();
|
|
42915
42986
|
init_chunk_YXWJW7I5();
|
|
42916
42987
|
import_fs8 = require("fs");
|
|
42917
|
-
import_path11 = require("path");
|
|
42918
|
-
init_effort();
|
|
42919
42988
|
import_path12 = require("path");
|
|
42989
|
+
init_effort();
|
|
42990
|
+
import_path13 = require("path");
|
|
42920
42991
|
import_url3 = require("url");
|
|
42921
42992
|
import_crypto16 = require("crypto");
|
|
42922
42993
|
init_agent2();
|
|
@@ -42956,7 +43027,7 @@ var init_antigravity = __esm({
|
|
|
42956
43027
|
#full;
|
|
42957
43028
|
constructor(path) {
|
|
42958
43029
|
this.#cursor = new TranscriptCursor(path);
|
|
42959
|
-
this.#fullPath = (0,
|
|
43030
|
+
this.#fullPath = (0, import_path13.resolve)((0, import_path13.dirname)(path), FULL_TRANSCRIPT_FILE);
|
|
42960
43031
|
}
|
|
42961
43032
|
skipExisting() {
|
|
42962
43033
|
this.#cursor.read();
|
|
@@ -43004,7 +43075,7 @@ var init_antigravity = __esm({
|
|
|
43004
43075
|
/** A conversation this turn did not resume was created by it, so it is read whole. */
|
|
43005
43076
|
trackParent(conversationId) {
|
|
43006
43077
|
if (this.#parent?.conversationId === conversationId) return;
|
|
43007
|
-
const path = (0,
|
|
43078
|
+
const path = (0, import_path13.resolve)(this.#root, conversationId, ...LOG_DIRS, TRANSCRIPT_FILE);
|
|
43008
43079
|
this.#parent = { conversationId, transcript: new BrainTranscript(path) };
|
|
43009
43080
|
}
|
|
43010
43081
|
/** A launcher keeps the first valid transcript it names; later frames change nothing. */
|
|
@@ -43409,8 +43480,8 @@ function parseConfig(raw) {
|
|
|
43409
43480
|
}
|
|
43410
43481
|
}
|
|
43411
43482
|
async function writeCommandCodeProjectMcp(cwd, mcp) {
|
|
43412
|
-
const path = (0,
|
|
43413
|
-
const original = await (0,
|
|
43483
|
+
const path = (0, import_path14.join)(cwd, ".mcp.json");
|
|
43484
|
+
const original = await (0, import_promises26.readFile)(path, "utf8").catch(() => null);
|
|
43414
43485
|
const config2 = parseConfig(original);
|
|
43415
43486
|
const next = {
|
|
43416
43487
|
...config2,
|
|
@@ -43427,12 +43498,12 @@ async function writeCommandCodeProjectMcp(cwd, mcp) {
|
|
|
43427
43498
|
}
|
|
43428
43499
|
}
|
|
43429
43500
|
};
|
|
43430
|
-
await (0,
|
|
43431
|
-
await (0,
|
|
43501
|
+
await (0, import_promises26.mkdir)(cwd, { recursive: true });
|
|
43502
|
+
await (0, import_promises26.writeFile)(path, `${JSON.stringify(next, null, 2)}
|
|
43432
43503
|
`);
|
|
43433
43504
|
return async () => {
|
|
43434
|
-
if (original === null) await (0,
|
|
43435
|
-
else await (0,
|
|
43505
|
+
if (original === null) await (0, import_promises26.rm)(path, { force: true });
|
|
43506
|
+
else await (0, import_promises26.writeFile)(path, original);
|
|
43436
43507
|
};
|
|
43437
43508
|
}
|
|
43438
43509
|
function commandCodeString(value) {
|
|
@@ -43604,19 +43675,19 @@ function commandCodeTurnInput(run, context) {
|
|
|
43604
43675
|
});
|
|
43605
43676
|
return { turnId: run.runId, text: appendImagePathReferences(text2, images) };
|
|
43606
43677
|
}
|
|
43607
|
-
var
|
|
43678
|
+
var import_promises26, import_path14, import_crypto17, COMMAND_CODE_GRAMMAR_NAME, SILENT3, CommandCodeGrammar, SHELL_TOOL, STOP_TOOLS, REPORTED_STATUS, SHELL_STATUS, SWEEP_INTERVAL_MS, CommandCodeBackgroundTasks, EXITED_WITHOUT_RESULT2, CommandCodeTurn, COMMAND_CODE_MAX_TURNS, DEFAULTS7, CommandCodeSession;
|
|
43608
43679
|
var init_command_code = __esm({
|
|
43609
43680
|
"../agent-core/dist/providers/command-code.js"() {
|
|
43610
43681
|
"use strict";
|
|
43611
|
-
|
|
43682
|
+
init_chunk_W3QH4J4A();
|
|
43612
43683
|
init_chunk_UGRKZTAD();
|
|
43613
|
-
|
|
43684
|
+
init_chunk_R6R6ORR2();
|
|
43614
43685
|
init_chunk_J2KTV5FP();
|
|
43615
|
-
|
|
43686
|
+
init_chunk_J4T6L5LX();
|
|
43616
43687
|
init_chunk_6WN2R725();
|
|
43617
43688
|
init_chunk_YXWJW7I5();
|
|
43618
|
-
|
|
43619
|
-
|
|
43689
|
+
import_promises26 = require("fs/promises");
|
|
43690
|
+
import_path14 = require("path");
|
|
43620
43691
|
init_agent2();
|
|
43621
43692
|
init_runtime_v2();
|
|
43622
43693
|
init_acp();
|
|
@@ -44477,7 +44548,7 @@ function transportFailure(request2, error61) {
|
|
|
44477
44548
|
});
|
|
44478
44549
|
}
|
|
44479
44550
|
function readBody(incoming, url2, maxBytes) {
|
|
44480
|
-
return new Promise((
|
|
44551
|
+
return new Promise((resolve6, reject) => {
|
|
44481
44552
|
const declared = Number(incoming.headers["content-length"] ?? "0");
|
|
44482
44553
|
if (maxBytes !== void 0 && declared > maxBytes) {
|
|
44483
44554
|
incoming.destroy();
|
|
@@ -44496,7 +44567,7 @@ function readBody(incoming, url2, maxBytes) {
|
|
|
44496
44567
|
chunks.push(chunk);
|
|
44497
44568
|
});
|
|
44498
44569
|
incoming.on("error", reject);
|
|
44499
|
-
incoming.on("end", () =>
|
|
44570
|
+
incoming.on("end", () => resolve6(Buffer.concat(chunks)));
|
|
44500
44571
|
});
|
|
44501
44572
|
}
|
|
44502
44573
|
function isConnectionReset(error61) {
|
|
@@ -44504,7 +44575,7 @@ function isConnectionReset(error61) {
|
|
|
44504
44575
|
}
|
|
44505
44576
|
function exchange(request2, agents, attempt = 0) {
|
|
44506
44577
|
const { signal, url: url2 } = request2;
|
|
44507
|
-
return new Promise((
|
|
44578
|
+
return new Promise((resolve6, reject) => {
|
|
44508
44579
|
if (signal.aborted) {
|
|
44509
44580
|
reject(signal.reason);
|
|
44510
44581
|
return;
|
|
@@ -44531,7 +44602,7 @@ function exchange(request2, agents, attempt = 0) {
|
|
|
44531
44602
|
const stale = outgoing.reusedSocket && !responded && isConnectionReset(error61);
|
|
44532
44603
|
if (stale && attempt < STALE_SOCKET_RETRIES && !signal.aborted) {
|
|
44533
44604
|
settle();
|
|
44534
|
-
|
|
44605
|
+
resolve6(exchange(request2, agents, attempt + 1));
|
|
44535
44606
|
return;
|
|
44536
44607
|
}
|
|
44537
44608
|
fail(error61);
|
|
@@ -44544,7 +44615,7 @@ function exchange(request2, agents, attempt = 0) {
|
|
|
44544
44615
|
readBody(incoming, url2, isRedirect(status) ? void 0 : request2.maxBodyBytes).then(
|
|
44545
44616
|
(body) => {
|
|
44546
44617
|
settle();
|
|
44547
|
-
|
|
44618
|
+
resolve6({ status, headers: incoming.headers, body });
|
|
44548
44619
|
},
|
|
44549
44620
|
fail
|
|
44550
44621
|
);
|
|
@@ -44694,7 +44765,7 @@ var GitFault = class extends Error {
|
|
|
44694
44765
|
var import_node_child_process = require("child_process");
|
|
44695
44766
|
|
|
44696
44767
|
// ../agent-core/dist/process.js
|
|
44697
|
-
|
|
44768
|
+
init_chunk_J4T6L5LX();
|
|
44698
44769
|
init_chunk_YXWJW7I5();
|
|
44699
44770
|
|
|
44700
44771
|
// src/capabilities/git/run-git.ts
|
|
@@ -44826,7 +44897,7 @@ function createGitRunner(options) {
|
|
|
44826
44897
|
}
|
|
44827
44898
|
await killProcessTree(child.pid, { signal: "SIGKILL", child, platform });
|
|
44828
44899
|
};
|
|
44829
|
-
return new Promise((
|
|
44900
|
+
return new Promise((resolve6, reject) => {
|
|
44830
44901
|
let ending = null;
|
|
44831
44902
|
const stop = (next) => {
|
|
44832
44903
|
if (ending !== null) return;
|
|
@@ -44851,7 +44922,7 @@ function createGitRunner(options) {
|
|
|
44851
44922
|
signal.removeEventListener("abort", onAbort);
|
|
44852
44923
|
const final = ending ?? last;
|
|
44853
44924
|
if (final.kind === "exited") {
|
|
44854
|
-
|
|
44925
|
+
resolve6({ exitCode: final.exitCode, stdout: stdout.text(), stderr: stderr.text() });
|
|
44855
44926
|
} else {
|
|
44856
44927
|
reject(faultFor(final, command));
|
|
44857
44928
|
}
|
|
@@ -44873,9 +44944,97 @@ function createGitRunner(options) {
|
|
|
44873
44944
|
};
|
|
44874
44945
|
}
|
|
44875
44946
|
|
|
44876
|
-
// src/
|
|
44947
|
+
// src/capabilities/git/checkout-freshness.ts
|
|
44877
44948
|
var import_node_crypto3 = require("crypto");
|
|
44878
44949
|
var import_promises7 = require("fs/promises");
|
|
44950
|
+
var import_node_path3 = require("path");
|
|
44951
|
+
init_zod();
|
|
44952
|
+
var REMOTE = "origin";
|
|
44953
|
+
var snapshotSchema = external_exports.object({
|
|
44954
|
+
branch: external_exports.string().min(1),
|
|
44955
|
+
base: external_exports.string().min(1),
|
|
44956
|
+
head: external_exports.string().min(1),
|
|
44957
|
+
published: external_exports.string(),
|
|
44958
|
+
shallow: external_exports.boolean(),
|
|
44959
|
+
commonDir: external_exports.string().min(1)
|
|
44960
|
+
});
|
|
44961
|
+
var freshnessSchema = external_exports.discriminatedUnion("state", [
|
|
44962
|
+
external_exports.object({ state: external_exports.literal("checking"), path: external_exports.string() }),
|
|
44963
|
+
external_exports.object({ state: external_exports.literal("kept"), path: external_exports.string(), reason: external_exports.string() }),
|
|
44964
|
+
external_exports.object({ state: external_exports.literal("current"), path: external_exports.string(), snapshot: snapshotSchema }),
|
|
44965
|
+
external_exports.object({
|
|
44966
|
+
state: external_exports.literal("behind"),
|
|
44967
|
+
path: external_exports.string(),
|
|
44968
|
+
snapshot: snapshotSchema,
|
|
44969
|
+
tip: external_exports.string().min(1),
|
|
44970
|
+
fetched: external_exports.boolean()
|
|
44971
|
+
}),
|
|
44972
|
+
external_exports.object({
|
|
44973
|
+
state: external_exports.literal("failed"),
|
|
44974
|
+
path: external_exports.string(),
|
|
44975
|
+
snapshot: snapshotSchema.optional(),
|
|
44976
|
+
reason: external_exports.string()
|
|
44977
|
+
})
|
|
44978
|
+
]);
|
|
44979
|
+
function freshnessFile(dir, path) {
|
|
44980
|
+
return (0, import_node_path3.join)(dir, `${(0, import_node_crypto3.createHash)("sha256").update(path).digest("hex").slice(0, 32)}.json`);
|
|
44981
|
+
}
|
|
44982
|
+
function parseStatus(stdout) {
|
|
44983
|
+
const lines = stdout.split("\n").filter((line) => line.length > 0);
|
|
44984
|
+
const header = /* @__PURE__ */ new Map();
|
|
44985
|
+
for (const line of lines) {
|
|
44986
|
+
const [hash2, key, value] = line.split(" ");
|
|
44987
|
+
if (hash2 === "#" && key !== void 0 && value !== void 0) header.set(key, value);
|
|
44988
|
+
}
|
|
44989
|
+
const head = header.get("branch.oid");
|
|
44990
|
+
const branch = header.get("branch.head");
|
|
44991
|
+
const upstream = header.get("branch.upstream") ?? "";
|
|
44992
|
+
return {
|
|
44993
|
+
head: head === void 0 || head === "(initial)" ? null : head,
|
|
44994
|
+
branch: branch === void 0 || branch === "(detached)" ? null : branch,
|
|
44995
|
+
base: upstream.startsWith(`${REMOTE}/`) ? upstream.slice(REMOTE.length + 1) : null,
|
|
44996
|
+
ahead: Number(header.get("branch.ab")?.slice(1) ?? 0),
|
|
44997
|
+
dirty: lines.some((line) => !line.startsWith("# "))
|
|
44998
|
+
};
|
|
44999
|
+
}
|
|
45000
|
+
async function readCheckoutStatus(git, cwd, signal) {
|
|
45001
|
+
const output2 = await git.run(
|
|
45002
|
+
{
|
|
45003
|
+
cwd,
|
|
45004
|
+
args: ["status", "--porcelain=v2", "--branch", "--untracked-files=no"],
|
|
45005
|
+
readOnly: true
|
|
45006
|
+
},
|
|
45007
|
+
signal
|
|
45008
|
+
);
|
|
45009
|
+
return output2.exitCode === 0 ? parseStatus(output2.stdout) : null;
|
|
45010
|
+
}
|
|
45011
|
+
async function isCheckout(path) {
|
|
45012
|
+
return (0, import_promises7.stat)((0, import_node_path3.join)(path, ".git")).then(
|
|
45013
|
+
() => true,
|
|
45014
|
+
() => false
|
|
45015
|
+
);
|
|
45016
|
+
}
|
|
45017
|
+
async function checkoutsUnder(root) {
|
|
45018
|
+
if (await isCheckout(root)) return [root];
|
|
45019
|
+
const entries = await (0, import_promises7.readdir)(root, { withFileTypes: true }).catch(() => []);
|
|
45020
|
+
const found = await Promise.all(
|
|
45021
|
+
entries.filter((entry) => entry.isDirectory()).map(
|
|
45022
|
+
async (entry) => await isCheckout((0, import_node_path3.join)(root, entry.name)) ? (0, import_node_path3.join)(root, entry.name) : null
|
|
45023
|
+
)
|
|
45024
|
+
);
|
|
45025
|
+
return found.filter((path) => path !== null);
|
|
45026
|
+
}
|
|
45027
|
+
async function readCheckoutFreshness(dir, path) {
|
|
45028
|
+
for (let current = path; ; current = (0, import_node_path3.dirname)(current)) {
|
|
45029
|
+
const read = await readJsonFile(freshnessFile(dir, current), freshnessSchema);
|
|
45030
|
+
if (read.kind === "ok") return read.value;
|
|
45031
|
+
if ((0, import_node_path3.dirname)(current) === current) return null;
|
|
45032
|
+
}
|
|
45033
|
+
}
|
|
45034
|
+
|
|
45035
|
+
// src/platform/credential-store/credential-store.ts
|
|
45036
|
+
var import_node_crypto4 = require("crypto");
|
|
45037
|
+
var import_promises8 = require("fs/promises");
|
|
44879
45038
|
|
|
44880
45039
|
// src/platform/credential-store/parse.ts
|
|
44881
45040
|
function parseStoredJson(text2, schema) {
|
|
@@ -44891,16 +45050,16 @@ function parseStoredJson(text2, schema) {
|
|
|
44891
45050
|
|
|
44892
45051
|
// src/platform/windows-helper.ts
|
|
44893
45052
|
var import_node_fs3 = require("fs");
|
|
44894
|
-
var
|
|
45053
|
+
var import_node_path4 = require("path");
|
|
44895
45054
|
var import_node_url = require("url");
|
|
44896
45055
|
var import_meta = {};
|
|
44897
45056
|
function windowsHelperPath(entry = process.argv[1]) {
|
|
44898
|
-
const packaged = entry === void 0 ? null : (0,
|
|
45057
|
+
const packaged = entry === void 0 ? null : (0, import_node_path4.join)((0, import_node_path4.dirname)((0, import_node_path4.resolve)(entry)), "alan-winhelper.exe");
|
|
44899
45058
|
if (entry !== void 0) {
|
|
44900
45059
|
if (packaged !== null && (0, import_node_fs3.existsSync)(packaged)) return packaged;
|
|
44901
45060
|
}
|
|
44902
45061
|
try {
|
|
44903
|
-
const local = (0,
|
|
45062
|
+
const local = (0, import_node_path4.resolve)((0, import_node_path4.dirname)((0, import_node_url.fileURLToPath)(import_meta.url)), "../../dist/alan-winhelper.exe");
|
|
44904
45063
|
return (0, import_node_fs3.existsSync)(local) ? local : packaged;
|
|
44905
45064
|
} catch {
|
|
44906
45065
|
return packaged;
|
|
@@ -44968,13 +45127,13 @@ function createFileCredentialStore(path) {
|
|
|
44968
45127
|
kind: "file",
|
|
44969
45128
|
read: (schema) => readJsonFile(path, schema),
|
|
44970
45129
|
write: (value) => writeJsonFileAtomic(path, value),
|
|
44971
|
-
clear: () => (0,
|
|
45130
|
+
clear: () => (0, import_promises8.rm)(path, { force: true })
|
|
44972
45131
|
};
|
|
44973
45132
|
}
|
|
44974
45133
|
var KEYCHAIN_SERVICE = "ai.tryalan.runtime";
|
|
44975
45134
|
var KEYCHAIN_NOT_FOUND = 44;
|
|
44976
45135
|
function keychainAccount(stateDir) {
|
|
44977
|
-
return `state-${(0,
|
|
45136
|
+
return `state-${(0, import_node_crypto4.createHash)("sha256").update(stateDir).digest("hex").slice(0, 16)}`;
|
|
44978
45137
|
}
|
|
44979
45138
|
function windowsCredentialTarget(stateDir) {
|
|
44980
45139
|
return `${KEYCHAIN_SERVICE}/${keychainAccount(stateDir.toLowerCase())}`;
|
|
@@ -45061,16 +45220,16 @@ function defaultCredentialStoreKind(platform) {
|
|
|
45061
45220
|
|
|
45062
45221
|
// src/platform/install.ts
|
|
45063
45222
|
var import_node_child_process3 = require("child_process");
|
|
45064
|
-
var
|
|
45223
|
+
var import_node_crypto5 = require("crypto");
|
|
45065
45224
|
var import_node_fs4 = require("fs");
|
|
45066
|
-
var
|
|
45067
|
-
var
|
|
45225
|
+
var import_promises10 = require("fs/promises");
|
|
45226
|
+
var import_node_path5 = require("path");
|
|
45068
45227
|
var import_node_util2 = require("util");
|
|
45069
45228
|
init_zod();
|
|
45070
45229
|
|
|
45071
45230
|
// src/platform/process-identity.ts
|
|
45072
45231
|
var import_node_child_process2 = require("child_process");
|
|
45073
|
-
var
|
|
45232
|
+
var import_promises9 = require("fs/promises");
|
|
45074
45233
|
var import_node_util = require("util");
|
|
45075
45234
|
var execFileAsync = (0, import_node_util.promisify)(import_node_child_process2.execFile);
|
|
45076
45235
|
function isProcessAlive(pid) {
|
|
@@ -45082,13 +45241,13 @@ function isProcessAlive(pid) {
|
|
|
45082
45241
|
}
|
|
45083
45242
|
}
|
|
45084
45243
|
async function linuxStartTime(pid) {
|
|
45085
|
-
const
|
|
45086
|
-
if (
|
|
45087
|
-
const fields =
|
|
45244
|
+
const stat14 = await (0, import_promises9.readFile)(`/proc/${pid}/stat`, "utf8").catch(() => null);
|
|
45245
|
+
if (stat14 === null) return null;
|
|
45246
|
+
const fields = stat14.slice(stat14.lastIndexOf(")") + 2).split(" ");
|
|
45088
45247
|
return fields[19] ?? null;
|
|
45089
45248
|
}
|
|
45090
45249
|
async function linuxCommand(pid) {
|
|
45091
|
-
const raw = await (0,
|
|
45250
|
+
const raw = await (0, import_promises9.readFile)(`/proc/${pid}/cmdline`, "utf8").catch(() => null);
|
|
45092
45251
|
return raw === null ? null : normalizeCommand(raw.replaceAll("\0", " "));
|
|
45093
45252
|
}
|
|
45094
45253
|
async function darwinCommand(pid) {
|
|
@@ -45182,11 +45341,11 @@ async function mayBeSameProcess(expected, probe = systemProcessProbe) {
|
|
|
45182
45341
|
var execFileAsync2 = (0, import_node_util2.promisify)(import_node_child_process3.execFile);
|
|
45183
45342
|
var packageJsonSchema = external_exports.object({ version: external_exports.string().min(1) });
|
|
45184
45343
|
function markVersionInUse(bundlePath) {
|
|
45185
|
-
const versionDir = (0,
|
|
45186
|
-
if ((0,
|
|
45344
|
+
const versionDir = (0, import_node_path5.dirname)(bundlePath);
|
|
45345
|
+
if ((0, import_node_path5.basename)((0, import_node_path5.dirname)(versionDir)) !== "versions") return { [Symbol.dispose]: () => {
|
|
45187
45346
|
} };
|
|
45188
|
-
const marker = (0,
|
|
45189
|
-
(0, import_node_fs4.mkdirSync)((0,
|
|
45347
|
+
const marker = (0, import_node_path5.join)(versionDir, ".running", String(process.pid));
|
|
45348
|
+
(0, import_node_fs4.mkdirSync)((0, import_node_path5.dirname)(marker), { recursive: true, mode: 448 });
|
|
45190
45349
|
(0, import_node_fs4.writeFileSync)(marker, "");
|
|
45191
45350
|
const remove = () => (0, import_node_fs4.rmSync)(marker, { force: true });
|
|
45192
45351
|
process.once("exit", remove);
|
|
@@ -45199,39 +45358,39 @@ function markVersionInUse(bundlePath) {
|
|
|
45199
45358
|
}
|
|
45200
45359
|
|
|
45201
45360
|
// src/platform/ipc-endpoint.ts
|
|
45202
|
-
var
|
|
45361
|
+
var import_node_crypto6 = require("crypto");
|
|
45203
45362
|
var import_node_fs5 = require("fs");
|
|
45204
45363
|
var import_node_os = require("os");
|
|
45205
|
-
var
|
|
45364
|
+
var import_node_path6 = require("path");
|
|
45206
45365
|
function removeStaleEndpoint(endpoint) {
|
|
45207
45366
|
if (!endpoint.startsWith("\\\\.\\pipe\\")) (0, import_node_fs5.rmSync)(endpoint, { force: true });
|
|
45208
45367
|
}
|
|
45209
45368
|
|
|
45210
45369
|
// src/platform/paths.ts
|
|
45211
|
-
var
|
|
45370
|
+
var import_node_path7 = require("path");
|
|
45212
45371
|
function runtimePaths(stateDir) {
|
|
45213
45372
|
return {
|
|
45214
45373
|
stateDir,
|
|
45215
|
-
lock: (0,
|
|
45216
|
-
machine: (0,
|
|
45217
|
-
credential: (0,
|
|
45218
|
-
runs: (0,
|
|
45219
|
-
sessions: (0,
|
|
45220
|
-
sockets: (0,
|
|
45221
|
-
logs: (0,
|
|
45222
|
-
tmp: (0,
|
|
45374
|
+
lock: (0, import_node_path7.join)(stateDir, "runtime.lock"),
|
|
45375
|
+
machine: (0, import_node_path7.join)(stateDir, "machine.json"),
|
|
45376
|
+
credential: (0, import_node_path7.join)(stateDir, "credential.json"),
|
|
45377
|
+
runs: (0, import_node_path7.join)(stateDir, "runs"),
|
|
45378
|
+
sessions: (0, import_node_path7.join)(stateDir, "sessions"),
|
|
45379
|
+
sockets: (0, import_node_path7.join)(stateDir, "s"),
|
|
45380
|
+
logs: (0, import_node_path7.join)(stateDir, "logs"),
|
|
45381
|
+
tmp: (0, import_node_path7.join)(stateDir, "tmp")
|
|
45223
45382
|
};
|
|
45224
45383
|
}
|
|
45225
45384
|
|
|
45226
45385
|
// src/platform/process-memory.ts
|
|
45227
45386
|
var import_node_child_process4 = require("child_process");
|
|
45228
|
-
var
|
|
45387
|
+
var import_promises11 = require("fs/promises");
|
|
45229
45388
|
var import_node_util3 = require("util");
|
|
45230
45389
|
var execFileAsync3 = (0, import_node_util3.promisify)(import_node_child_process4.execFile);
|
|
45231
45390
|
var PROBE_TIMEOUT_MS = 2e3;
|
|
45232
45391
|
async function readProcessRss(pid) {
|
|
45233
45392
|
if (process.platform === "linux") {
|
|
45234
|
-
const status = await (0,
|
|
45393
|
+
const status = await (0, import_promises11.readFile)(`/proc/${pid}/status`, "utf8").catch(() => null);
|
|
45235
45394
|
const kilobytes = status === null ? void 0 : /^VmRSS:\s+(\d+)\s+kB$/m.exec(status)?.[1];
|
|
45236
45395
|
return kilobytes === void 0 ? null : Number(kilobytes) * 1024;
|
|
45237
45396
|
}
|
|
@@ -45248,7 +45407,7 @@ async function readProcessRss(pid) {
|
|
|
45248
45407
|
}
|
|
45249
45408
|
|
|
45250
45409
|
// src/platform/runtime-host.ts
|
|
45251
|
-
var
|
|
45410
|
+
var import_promises12 = require("fs/promises");
|
|
45252
45411
|
var RUNTIME_HOST_KINDS = ["app", "standalone"];
|
|
45253
45412
|
|
|
45254
45413
|
// src/platform/service/exec.ts
|
|
@@ -45263,7 +45422,7 @@ function statusOf(error61) {
|
|
|
45263
45422
|
}
|
|
45264
45423
|
return 1;
|
|
45265
45424
|
}
|
|
45266
|
-
var systemExec = (request2) => new Promise((
|
|
45425
|
+
var systemExec = (request2) => new Promise((resolve6) => {
|
|
45267
45426
|
const child = (0, import_node_child_process5.execFile)(
|
|
45268
45427
|
request2.command,
|
|
45269
45428
|
[...request2.args],
|
|
@@ -45274,7 +45433,7 @@ var systemExec = (request2) => new Promise((resolve5) => {
|
|
|
45274
45433
|
windowsHide: true
|
|
45275
45434
|
},
|
|
45276
45435
|
(error61, stdout, stderr) => {
|
|
45277
|
-
|
|
45436
|
+
resolve6({ status: statusOf(error61), stdout, stderr });
|
|
45278
45437
|
}
|
|
45279
45438
|
);
|
|
45280
45439
|
child.stdin?.on("error", () => {
|
|
@@ -45287,8 +45446,8 @@ init_alan_code();
|
|
|
45287
45446
|
|
|
45288
45447
|
// src/capabilities/providers/commands.ts
|
|
45289
45448
|
var import_node_fs6 = require("fs");
|
|
45290
|
-
var
|
|
45291
|
-
var
|
|
45449
|
+
var import_promises16 = require("fs/promises");
|
|
45450
|
+
var import_node_path8 = require("path");
|
|
45292
45451
|
var PROVIDER_COMMANDS = [
|
|
45293
45452
|
// The engine, not a CLI of its own: `resolveProviderExecutable` finds the bundled one first.
|
|
45294
45453
|
{ backendKind: "alan_code", command: "opencode", name: "Alan Code" },
|
|
@@ -45321,8 +45480,8 @@ function pathDelimiter(platform) {
|
|
|
45321
45480
|
}
|
|
45322
45481
|
async function isRunnable(path, platform) {
|
|
45323
45482
|
try {
|
|
45324
|
-
if (!(await (0,
|
|
45325
|
-
if (platform !== "win32") await (0,
|
|
45483
|
+
if (!(await (0, import_promises16.stat)(path)).isFile()) return false;
|
|
45484
|
+
if (platform !== "win32") await (0, import_promises16.access)(path, import_node_fs6.constants.X_OK);
|
|
45326
45485
|
return true;
|
|
45327
45486
|
} catch {
|
|
45328
45487
|
return false;
|
|
@@ -45338,7 +45497,7 @@ async function resolveCommandOnPath(command, env, platform) {
|
|
|
45338
45497
|
const extensions = platform === "win32" ? windowsExtensions(command, env) : [""];
|
|
45339
45498
|
for (const directory of directories) {
|
|
45340
45499
|
for (const extension of extensions) {
|
|
45341
|
-
const candidate = (0,
|
|
45500
|
+
const candidate = (0, import_node_path8.join)(directory, `${command}${extension}`);
|
|
45342
45501
|
if (await isRunnable(candidate, platform)) return candidate;
|
|
45343
45502
|
}
|
|
45344
45503
|
}
|
|
@@ -45373,15 +45532,15 @@ function resolveProviderExecutable(provider4, env, platform) {
|
|
|
45373
45532
|
|
|
45374
45533
|
// src/capabilities/providers/managed.ts
|
|
45375
45534
|
var import_node_child_process6 = require("child_process");
|
|
45376
|
-
var
|
|
45377
|
-
var
|
|
45378
|
-
var
|
|
45535
|
+
var import_node_crypto7 = require("crypto");
|
|
45536
|
+
var import_promises17 = require("fs/promises");
|
|
45537
|
+
var import_node_path9 = require("path");
|
|
45379
45538
|
init_zod();
|
|
45380
45539
|
var VERSION = /^[0-9]+\.[0-9]+\.[0-9]+(?:[-+][0-9A-Za-z.-]+)?$/;
|
|
45381
45540
|
var selectedSchema = external_exports.record(external_exports.string(), external_exports.string());
|
|
45382
45541
|
async function readManagedProviderVersion(file2, backendKind) {
|
|
45383
45542
|
try {
|
|
45384
|
-
const selected = selectedSchema.parse(JSON.parse(await (0,
|
|
45543
|
+
const selected = selectedSchema.parse(JSON.parse(await (0, import_promises17.readFile)(file2, "utf8")));
|
|
45385
45544
|
const version2 = selected[backendKind];
|
|
45386
45545
|
return version2 !== void 0 && VERSION.test(version2) ? version2 : null;
|
|
45387
45546
|
} catch {
|
|
@@ -45391,9 +45550,9 @@ async function readManagedProviderVersion(file2, backendKind) {
|
|
|
45391
45550
|
|
|
45392
45551
|
// ../shared/dist/node/skill-package.js
|
|
45393
45552
|
var import_node_buffer = require("buffer");
|
|
45394
|
-
var
|
|
45395
|
-
var
|
|
45396
|
-
var
|
|
45553
|
+
var import_node_crypto8 = require("crypto");
|
|
45554
|
+
var import_promises18 = require("fs/promises");
|
|
45555
|
+
var import_node_path10 = require("path");
|
|
45397
45556
|
var import_yaml = __toESM(require_dist(), 1);
|
|
45398
45557
|
init_contracts();
|
|
45399
45558
|
init_domain();
|
|
@@ -45464,7 +45623,7 @@ async function inspectSkillPackage(packageRoot, options = {}) {
|
|
|
45464
45623
|
}
|
|
45465
45624
|
const inspectedFiles = await Promise.all(files.map(readPackageFile));
|
|
45466
45625
|
inspectedFiles.sort(comparePackageFiles);
|
|
45467
|
-
const parsedMetadata = parseSkillMetadata(inspectedFiles.find((file2) => file2.manifest.path === "SKILL.md")?.bytes, options.expectedName === void 0 ? (0,
|
|
45626
|
+
const parsedMetadata = parseSkillMetadata(inspectedFiles.find((file2) => file2.manifest.path === "SKILL.md")?.bytes, options.expectedName === void 0 ? (0, import_node_path10.basename)(root) : options.expectedName);
|
|
45468
45627
|
const manifestFiles = inspectedFiles.map((file2) => file2.manifest);
|
|
45469
45628
|
const diagnostics = [
|
|
45470
45629
|
...parsedMetadata.conformance,
|
|
@@ -45482,11 +45641,11 @@ async function inspectSkillPackage(packageRoot, options = {}) {
|
|
|
45482
45641
|
};
|
|
45483
45642
|
}
|
|
45484
45643
|
async function requirePackageRoot(packageRoot) {
|
|
45485
|
-
const root = await (0,
|
|
45644
|
+
const root = await (0, import_promises18.realpath)((0, import_node_path10.resolve)(packageRoot)).catch(() => null);
|
|
45486
45645
|
if (!root) {
|
|
45487
45646
|
throw new SkillPackageError("INVALID_PACKAGE_ROOT", "Skill package directory does not exist");
|
|
45488
45647
|
}
|
|
45489
|
-
const rootStat = await (0,
|
|
45648
|
+
const rootStat = await (0, import_promises18.lstat)(root);
|
|
45490
45649
|
if (!rootStat.isDirectory()) {
|
|
45491
45650
|
throw new SkillPackageError("INVALID_PACKAGE_ROOT", "Skill package root must be a directory");
|
|
45492
45651
|
}
|
|
@@ -45506,13 +45665,13 @@ async function walkPackage(root, ignoredPaths) {
|
|
|
45506
45665
|
}
|
|
45507
45666
|
return files;
|
|
45508
45667
|
async function walkDirectory(directory) {
|
|
45509
|
-
const entries = await (0,
|
|
45668
|
+
const entries = await (0, import_promises18.readdir)(directory, { withFileTypes: true });
|
|
45510
45669
|
for (const entry of entries) {
|
|
45511
|
-
const absolutePath = (0,
|
|
45670
|
+
const absolutePath = (0, import_node_path10.resolve)(directory, entry.name);
|
|
45512
45671
|
const normalizedPath = normalizeRelativePath(root, absolutePath);
|
|
45513
45672
|
if (isIgnored(normalizedPath, entry.name, entry.isDirectory(), ignored2))
|
|
45514
45673
|
continue;
|
|
45515
|
-
const entryStat = await (0,
|
|
45674
|
+
const entryStat = await (0, import_promises18.lstat)(absolutePath);
|
|
45516
45675
|
if (entryStat.isSymbolicLink()) {
|
|
45517
45676
|
throw new SkillPackageError("SYMLINK_BLOCKED", `Nested symbolic links are not allowed in Skill packages: ${normalizedPath}`, normalizedPath);
|
|
45518
45677
|
}
|
|
@@ -45575,12 +45734,12 @@ function globToRegExp(pattern) {
|
|
|
45575
45734
|
return new RegExp(`${source}(?:/.*)?$`);
|
|
45576
45735
|
}
|
|
45577
45736
|
function normalizeRelativePath(root, absolutePath) {
|
|
45578
|
-
const nativeRelativePath = (0,
|
|
45579
|
-
if (!nativeRelativePath || nativeRelativePath.startsWith(`..${
|
|
45737
|
+
const nativeRelativePath = (0, import_node_path10.relative)(root, absolutePath);
|
|
45738
|
+
if (!nativeRelativePath || nativeRelativePath.startsWith(`..${import_node_path10.sep}`) || nativeRelativePath === "..") {
|
|
45580
45739
|
throw new SkillPackageError("INVALID_PATH", "Skill package path escapes its root");
|
|
45581
45740
|
}
|
|
45582
|
-
const normalized2 = nativeRelativePath.split(
|
|
45583
|
-
if (normalized2.includes("\0") || normalized2.includes("\uFFFD") ||
|
|
45741
|
+
const normalized2 = nativeRelativePath.split(import_node_path10.sep).join("/").normalize("NFC");
|
|
45742
|
+
if (normalized2.includes("\0") || normalized2.includes("\uFFFD") || import_node_path10.posix.isAbsolute(normalized2)) {
|
|
45584
45743
|
throw new SkillPackageError("INVALID_PATH", `Invalid Skill package path: ${normalized2}`);
|
|
45585
45744
|
}
|
|
45586
45745
|
return normalized2;
|
|
@@ -45615,13 +45774,13 @@ function requireSafeFile(path, size, normalizedPaths) {
|
|
|
45615
45774
|
}
|
|
45616
45775
|
}
|
|
45617
45776
|
function isSecretPath(path) {
|
|
45618
|
-
const name =
|
|
45777
|
+
const name = import_node_path10.posix.basename(path).toLowerCase();
|
|
45619
45778
|
if (SECRET_BASENAMES.has(name) || name.startsWith(".env."))
|
|
45620
45779
|
return true;
|
|
45621
45780
|
return name.endsWith(".private-key.pem") || name.endsWith(".private-key.key");
|
|
45622
45781
|
}
|
|
45623
45782
|
async function readPackageFile(file2) {
|
|
45624
|
-
const bytes = await (0,
|
|
45783
|
+
const bytes = await (0, import_promises18.readFile)(file2.absolutePath);
|
|
45625
45784
|
return {
|
|
45626
45785
|
bytes,
|
|
45627
45786
|
manifest: {
|
|
@@ -45643,12 +45802,12 @@ function classifyFileKind(path) {
|
|
|
45643
45802
|
return "reference";
|
|
45644
45803
|
if (path.startsWith("assets/"))
|
|
45645
45804
|
return "asset";
|
|
45646
|
-
if (/^(?:licen[cs]e|copying|notice)(?:\.|$)/i.test(
|
|
45805
|
+
if (/^(?:licen[cs]e|copying|notice)(?:\.|$)/i.test(import_node_path10.posix.basename(path)))
|
|
45647
45806
|
return "license";
|
|
45648
45807
|
return "other";
|
|
45649
45808
|
}
|
|
45650
45809
|
function classifyPreview(path, bytes) {
|
|
45651
|
-
const extension =
|
|
45810
|
+
const extension = import_node_path10.posix.extname(path).toLowerCase();
|
|
45652
45811
|
if (IMAGE_EXTENSIONS2.has(extension))
|
|
45653
45812
|
return "image";
|
|
45654
45813
|
if (bytes.includes(0))
|
|
@@ -45752,7 +45911,7 @@ function normalizePackageReference(value) {
|
|
|
45752
45911
|
const withoutSuffix = trimmed4.split(/[?#]/, 1)[0];
|
|
45753
45912
|
if (!withoutSuffix)
|
|
45754
45913
|
return null;
|
|
45755
|
-
const normalized2 =
|
|
45914
|
+
const normalized2 = import_node_path10.posix.normalize(withoutSuffix).replace(/^\.\//, "").normalize("NFC");
|
|
45756
45915
|
if (normalized2 === ".." || normalized2.startsWith("../"))
|
|
45757
45916
|
return null;
|
|
45758
45917
|
return normalized2;
|
|
@@ -45764,7 +45923,7 @@ function comparePackageFiles(left, right) {
|
|
|
45764
45923
|
return import_node_buffer.Buffer.compare(import_node_buffer.Buffer.from(left.manifest.path, "utf8"), import_node_buffer.Buffer.from(right.manifest.path, "utf8"));
|
|
45765
45924
|
}
|
|
45766
45925
|
function hashPackageTree(files) {
|
|
45767
|
-
const hash2 = (0,
|
|
45926
|
+
const hash2 = (0, import_node_crypto8.createHash)("sha256");
|
|
45768
45927
|
hash2.update(TREE_HASH_PREFIX);
|
|
45769
45928
|
for (const file2 of files) {
|
|
45770
45929
|
const path = import_node_buffer.Buffer.from(file2.path, "utf8");
|
|
@@ -45777,7 +45936,7 @@ function hashPackageTree(files) {
|
|
|
45777
45936
|
return `sha256:${hash2.digest("hex")}`;
|
|
45778
45937
|
}
|
|
45779
45938
|
function sha256(bytes) {
|
|
45780
|
-
return `sha256:${(0,
|
|
45939
|
+
return `sha256:${(0, import_node_crypto8.createHash)("sha256").update(bytes).digest("hex")}`;
|
|
45781
45940
|
}
|
|
45782
45941
|
function uint322(value) {
|
|
45783
45942
|
const buffer = import_node_buffer.Buffer.allocUnsafe(4);
|
|
@@ -45791,22 +45950,22 @@ function uint642(value) {
|
|
|
45791
45950
|
}
|
|
45792
45951
|
|
|
45793
45952
|
// src/capabilities/skills/store.ts
|
|
45794
|
-
var
|
|
45795
|
-
var
|
|
45953
|
+
var import_promises19 = require("fs/promises");
|
|
45954
|
+
var import_node_path11 = require("path");
|
|
45796
45955
|
init_runtime_v2();
|
|
45797
45956
|
init_zod();
|
|
45798
45957
|
function skillsLayout(stateDir) {
|
|
45799
|
-
const root = (0,
|
|
45958
|
+
const root = (0, import_node_path11.join)(stateDir, "skills");
|
|
45800
45959
|
return {
|
|
45801
45960
|
root,
|
|
45802
|
-
installedFile: (0,
|
|
45803
|
-
localFile: (0,
|
|
45804
|
-
versionsDir: (0,
|
|
45805
|
-
tmpDir: (0,
|
|
45961
|
+
installedFile: (0, import_node_path11.join)(root, "installed.json"),
|
|
45962
|
+
localFile: (0, import_node_path11.join)(root, "local.json"),
|
|
45963
|
+
versionsDir: (0, import_node_path11.join)(root, "versions"),
|
|
45964
|
+
tmpDir: (0, import_node_path11.join)(root, "tmp")
|
|
45806
45965
|
};
|
|
45807
45966
|
}
|
|
45808
45967
|
function packageDirectory(layout, versionId) {
|
|
45809
|
-
return (0,
|
|
45968
|
+
return (0, import_node_path11.join)(layout.versionsDir, versionId);
|
|
45810
45969
|
}
|
|
45811
45970
|
var installedFileSchema = external_exports.object({ skills: external_exports.array(desiredMachineSkillSchema) });
|
|
45812
45971
|
async function readInstalledSkills(layout) {
|
|
@@ -45833,7 +45992,7 @@ async function readLocalSkills(layout) {
|
|
|
45833
45992
|
async function isLocalSkillCurrent(entry, contentHash, ignoredPaths) {
|
|
45834
45993
|
if (entry.contentHash !== contentHash) return false;
|
|
45835
45994
|
try {
|
|
45836
|
-
if (await (0,
|
|
45995
|
+
if (await (0, import_promises19.realpath)(entry.path) !== entry.path) return false;
|
|
45837
45996
|
const inspected = await inspectSkillPackage(entry.path, { expectedName: null, ignoredPaths });
|
|
45838
45997
|
return inspected.contentHash === contentHash;
|
|
45839
45998
|
} catch {
|
|
@@ -45848,7 +46007,7 @@ async function resolveLocalSkill(local, invocation) {
|
|
|
45848
46007
|
}
|
|
45849
46008
|
async function hasSkillFile(directory) {
|
|
45850
46009
|
try {
|
|
45851
|
-
return (await (0,
|
|
46010
|
+
return (await (0, import_promises19.stat)((0, import_node_path11.join)(directory, "SKILL.md"))).isFile();
|
|
45852
46011
|
} catch {
|
|
45853
46012
|
return false;
|
|
45854
46013
|
}
|
|
@@ -45889,14 +46048,14 @@ async function resolveSkillInvocations(layout, invocations) {
|
|
|
45889
46048
|
}
|
|
45890
46049
|
|
|
45891
46050
|
// src/capabilities/workspace/index.ts
|
|
45892
|
-
var
|
|
46051
|
+
var import_node_path14 = require("path");
|
|
45893
46052
|
|
|
45894
46053
|
// src/capabilities/workspace/approved-paths.ts
|
|
45895
|
-
var
|
|
46054
|
+
var import_promises20 = require("fs/promises");
|
|
45896
46055
|
init_zod();
|
|
45897
46056
|
|
|
45898
46057
|
// src/capabilities/workspace/paths.ts
|
|
45899
|
-
var
|
|
46058
|
+
var import_node_path12 = require("path");
|
|
45900
46059
|
function stripWin32Namespace(path) {
|
|
45901
46060
|
if (/^\\\\\?\\UNC\\/i.test(path)) return `\\\\${path.slice(8)}`;
|
|
45902
46061
|
if (path.startsWith("\\\\?\\")) return path.slice(4);
|
|
@@ -45904,15 +46063,15 @@ function stripWin32Namespace(path) {
|
|
|
45904
46063
|
}
|
|
45905
46064
|
function comparablePath(path, platform) {
|
|
45906
46065
|
if (platform === "win32") {
|
|
45907
|
-
const normalized3 =
|
|
46066
|
+
const normalized3 = import_node_path12.win32.normalize(stripWin32Namespace(path).replaceAll("/", "\\"));
|
|
45908
46067
|
const trimmed4 = normalized3.length > 3 || !/^[a-z]:\\$/i.test(normalized3) ? normalized3.replace(/\\+$/, "") : normalized3;
|
|
45909
46068
|
return trimmed4.toLowerCase();
|
|
45910
46069
|
}
|
|
45911
|
-
const normalized2 =
|
|
46070
|
+
const normalized2 = import_node_path12.posix.normalize(path);
|
|
45912
46071
|
return normalized2.length > 1 ? normalized2.replace(/\/+$/, "") : normalized2;
|
|
45913
46072
|
}
|
|
45914
46073
|
function isAbsoluteFor(path, platform) {
|
|
45915
|
-
return platform === "win32" ?
|
|
46074
|
+
return platform === "win32" ? import_node_path12.win32.isAbsolute(path) : import_node_path12.posix.isAbsolute(path);
|
|
45916
46075
|
}
|
|
45917
46076
|
function isWithin(root, candidate, platform) {
|
|
45918
46077
|
const separator = platform === "win32" ? "\\" : "/";
|
|
@@ -45930,7 +46089,7 @@ var storeSchema = external_exports.object({
|
|
|
45930
46089
|
});
|
|
45931
46090
|
async function realpathOrNull(path) {
|
|
45932
46091
|
try {
|
|
45933
|
-
return await (0,
|
|
46092
|
+
return await (0, import_promises20.realpath)(path);
|
|
45934
46093
|
} catch (error61) {
|
|
45935
46094
|
const code = errnoCode(error61);
|
|
45936
46095
|
if (code === "ENOENT" || code === "ENOTDIR" || code === "EACCES" || code === "EPERM") {
|
|
@@ -45989,9 +46148,9 @@ async function openApprovedPaths(options) {
|
|
|
45989
46148
|
}
|
|
45990
46149
|
|
|
45991
46150
|
// src/capabilities/workspace/locks.ts
|
|
45992
|
-
var
|
|
45993
|
-
var
|
|
45994
|
-
var
|
|
46151
|
+
var import_node_crypto9 = require("crypto");
|
|
46152
|
+
var import_promises21 = require("fs/promises");
|
|
46153
|
+
var import_node_path13 = require("path");
|
|
45995
46154
|
init_zod();
|
|
45996
46155
|
var LOCK_FORMAT = 1;
|
|
45997
46156
|
var EXCLUSIVE_FILE = "exclusive.json";
|
|
@@ -46006,12 +46165,12 @@ var ownerSchema = external_exports.object({
|
|
|
46006
46165
|
since: external_exports.number().int().nonnegative()
|
|
46007
46166
|
});
|
|
46008
46167
|
function repositoryLockKey(commonDir, platform) {
|
|
46009
|
-
return (0,
|
|
46168
|
+
return (0, import_node_crypto9.createHash)("sha256").update(comparablePath(commonDir, platform)).digest("hex").slice(0, 32);
|
|
46010
46169
|
}
|
|
46011
46170
|
async function readOwner(path) {
|
|
46012
46171
|
let text2;
|
|
46013
46172
|
try {
|
|
46014
|
-
text2 = await (0,
|
|
46173
|
+
text2 = await (0, import_promises21.readFile)(path, "utf8");
|
|
46015
46174
|
} catch (error61) {
|
|
46016
46175
|
if (errnoCode(error61) === "ENOENT") return { kind: "missing" };
|
|
46017
46176
|
return { kind: "unreadable" };
|
|
@@ -46032,7 +46191,7 @@ async function removeIfSame(path, expected) {
|
|
|
46032
46191
|
if (current.kind !== "owner" || current.owner.since !== expected.since) return;
|
|
46033
46192
|
if (current.owner.pid !== expected.pid || current.owner.holder !== expected.holder) return;
|
|
46034
46193
|
}
|
|
46035
|
-
await (0,
|
|
46194
|
+
await (0, import_promises21.unlink)(path).catch((error61) => {
|
|
46036
46195
|
if (errnoCode(error61) !== "ENOENT") throw error61;
|
|
46037
46196
|
});
|
|
46038
46197
|
}
|
|
@@ -46057,7 +46216,7 @@ function openRepositoryLocks(options) {
|
|
|
46057
46216
|
await removeIfSame(path, read.owner);
|
|
46058
46217
|
return null;
|
|
46059
46218
|
}
|
|
46060
|
-
const age = await (0,
|
|
46219
|
+
const age = await (0, import_promises21.stat)(path).then(
|
|
46061
46220
|
(info) => clock.now() - info.mtimeMs,
|
|
46062
46221
|
() => 0
|
|
46063
46222
|
);
|
|
@@ -46071,13 +46230,13 @@ function openRepositoryLocks(options) {
|
|
|
46071
46230
|
});
|
|
46072
46231
|
const folder = async (commonDir) => {
|
|
46073
46232
|
const key = repositoryLockKey(commonDir, platform);
|
|
46074
|
-
const dir = (0,
|
|
46075
|
-
await (0,
|
|
46233
|
+
const dir = (0, import_node_path13.join)(options.dir, key);
|
|
46234
|
+
await (0, import_promises21.mkdir)(dir, { recursive: true, mode: 448 });
|
|
46076
46235
|
return { key, dir };
|
|
46077
46236
|
};
|
|
46078
46237
|
const createExclusive = async (path, owner) => {
|
|
46079
46238
|
try {
|
|
46080
|
-
const handle = await (0,
|
|
46239
|
+
const handle = await (0, import_promises21.open)(path, "wx", 384);
|
|
46081
46240
|
try {
|
|
46082
46241
|
await handle.writeFile(JSON.stringify(owner));
|
|
46083
46242
|
} finally {
|
|
@@ -46090,10 +46249,10 @@ function openRepositoryLocks(options) {
|
|
|
46090
46249
|
}
|
|
46091
46250
|
};
|
|
46092
46251
|
const liveRun = async (dir) => {
|
|
46093
|
-
const entries = await (0,
|
|
46252
|
+
const entries = await (0, import_promises21.readdir)(dir);
|
|
46094
46253
|
for (const entry of entries) {
|
|
46095
46254
|
if (!entry.startsWith(RUN_FILE_PREFIX)) continue;
|
|
46096
|
-
const holder = await heldBy((0,
|
|
46255
|
+
const holder = await heldBy((0, import_node_path13.join)(dir, entry));
|
|
46097
46256
|
if (holder !== null) return holder;
|
|
46098
46257
|
}
|
|
46099
46258
|
return null;
|
|
@@ -46101,7 +46260,7 @@ function openRepositoryLocks(options) {
|
|
|
46101
46260
|
return {
|
|
46102
46261
|
tryExclusive: async (commonDir, operationId) => {
|
|
46103
46262
|
const { key, dir } = await folder(commonDir);
|
|
46104
|
-
const path = (0,
|
|
46263
|
+
const path = (0, import_node_path13.join)(dir, EXCLUSIVE_FILE);
|
|
46105
46264
|
const owner = await self(operationId);
|
|
46106
46265
|
if (!await createExclusive(path, owner)) {
|
|
46107
46266
|
const holder = await heldBy(path);
|
|
@@ -46119,11 +46278,11 @@ function openRepositoryLocks(options) {
|
|
|
46119
46278
|
},
|
|
46120
46279
|
tryShared: async (commonDir, runId) => {
|
|
46121
46280
|
const { key, dir } = await folder(commonDir);
|
|
46122
|
-
const file2 = `${RUN_FILE_PREFIX}${(0,
|
|
46123
|
-
const path = (0,
|
|
46281
|
+
const file2 = `${RUN_FILE_PREFIX}${(0, import_node_crypto9.createHash)("sha256").update(runId).digest("hex").slice(0, 32)}.json`;
|
|
46282
|
+
const path = (0, import_node_path13.join)(dir, file2);
|
|
46124
46283
|
const owner = await self(runId);
|
|
46125
46284
|
await writeJsonFileAtomic(path, owner);
|
|
46126
|
-
const operation = await heldBy((0,
|
|
46285
|
+
const operation = await heldBy((0, import_node_path13.join)(dir, EXCLUSIVE_FILE));
|
|
46127
46286
|
if (operation !== null) {
|
|
46128
46287
|
await removeIfSame(path, owner);
|
|
46129
46288
|
return { kind: "busy", holder: operation };
|
|
@@ -46135,33 +46294,33 @@ function openRepositoryLocks(options) {
|
|
|
46135
46294
|
|
|
46136
46295
|
// src/cli/config.ts
|
|
46137
46296
|
var import_node_os7 = require("os");
|
|
46138
|
-
var
|
|
46297
|
+
var import_node_path27 = require("path");
|
|
46139
46298
|
init_zod();
|
|
46140
46299
|
|
|
46141
46300
|
// src/client/locate.ts
|
|
46142
|
-
var
|
|
46301
|
+
var import_node_path15 = require("path");
|
|
46143
46302
|
var RUNTIME_PROFILES = ["production", "staging", "development", "local"];
|
|
46144
46303
|
function defaultStateDir({ profile, platform, home, env }) {
|
|
46145
46304
|
if (platform === "win32") {
|
|
46146
|
-
return (0,
|
|
46305
|
+
return (0, import_node_path15.join)(env.LOCALAPPDATA ?? (0, import_node_path15.join)(home, "AppData", "Local"), "Alan", profile);
|
|
46147
46306
|
}
|
|
46148
|
-
return (0,
|
|
46307
|
+
return (0, import_node_path15.join)(env.XDG_STATE_HOME ?? (0, import_node_path15.join)(home, ".local", "state"), "alan", profile);
|
|
46149
46308
|
}
|
|
46150
46309
|
function defaultInstallDir({ platform, home, env }) {
|
|
46151
46310
|
if (platform === "win32") {
|
|
46152
|
-
return (0,
|
|
46311
|
+
return (0, import_node_path15.join)(env.LOCALAPPDATA ?? (0, import_node_path15.join)(home, "AppData", "Local"), "Alan", "runtime");
|
|
46153
46312
|
}
|
|
46154
|
-
return (0,
|
|
46313
|
+
return (0, import_node_path15.join)(env.XDG_DATA_HOME ?? (0, import_node_path15.join)(home, ".local", "share"), "alan", "runtime");
|
|
46155
46314
|
}
|
|
46156
46315
|
|
|
46157
46316
|
// src/sessions/index.ts
|
|
46158
|
-
var
|
|
46159
|
-
var
|
|
46317
|
+
var import_node_crypto13 = require("crypto");
|
|
46318
|
+
var import_promises34 = require("fs/promises");
|
|
46160
46319
|
var import_node_os6 = require("os");
|
|
46161
|
-
var
|
|
46320
|
+
var import_node_path26 = require("path");
|
|
46162
46321
|
|
|
46163
46322
|
// src/holder/control-client.ts
|
|
46164
|
-
var
|
|
46323
|
+
var import_node_crypto10 = require("crypto");
|
|
46165
46324
|
var import_node_net = require("net");
|
|
46166
46325
|
|
|
46167
46326
|
// src/holder/ndjson.ts
|
|
@@ -46324,12 +46483,48 @@ function createProviderDrivers(options) {
|
|
|
46324
46483
|
);
|
|
46325
46484
|
}
|
|
46326
46485
|
|
|
46486
|
+
// src/holder/engine-records.ts
|
|
46487
|
+
var import_node_path16 = require("path");
|
|
46488
|
+
init_zod();
|
|
46489
|
+
var ENGINES_FILE = "engines.json";
|
|
46490
|
+
var engineRecordSchema = external_exports.object({
|
|
46491
|
+
pid: external_exports.number().int().positive(),
|
|
46492
|
+
startedAt: external_exports.string().min(1),
|
|
46493
|
+
spawnedAt: external_exports.number().int().nonnegative()
|
|
46494
|
+
});
|
|
46495
|
+
var engineRecordsSchema = external_exports.object({ engines: external_exports.array(engineRecordSchema) });
|
|
46496
|
+
function engineRecordsPath(sessionDir) {
|
|
46497
|
+
return (0, import_node_path16.join)(sessionDir, ENGINES_FILE);
|
|
46498
|
+
}
|
|
46499
|
+
function recordSpawnedEngines(path, clock, log) {
|
|
46500
|
+
const live = /* @__PURE__ */ new Map();
|
|
46501
|
+
let writes = Promise.resolve();
|
|
46502
|
+
const save = () => {
|
|
46503
|
+
const engines = [...live.values()];
|
|
46504
|
+
writes = writes.then(() => writeJsonFileAtomic(path, { engines })).catch((error61) => log.warn("holder.engine_record_failed", { error: error61 }));
|
|
46505
|
+
};
|
|
46506
|
+
return onCliSpawned((child) => {
|
|
46507
|
+
const pid = child.pid;
|
|
46508
|
+
if (pid === void 0) return;
|
|
46509
|
+
const spawnedAt = clock.now();
|
|
46510
|
+
const exited = () => child.exitCode !== null || child.signalCode !== null;
|
|
46511
|
+
child.once("exit", () => {
|
|
46512
|
+
if (live.delete(pid)) save();
|
|
46513
|
+
});
|
|
46514
|
+
void readProcessIdentity(pid).then((identity) => {
|
|
46515
|
+
if (identity === null || exited()) return;
|
|
46516
|
+
live.set(pid, { pid, startedAt: identity.startedAt, spawnedAt });
|
|
46517
|
+
save();
|
|
46518
|
+
});
|
|
46519
|
+
});
|
|
46520
|
+
}
|
|
46521
|
+
|
|
46327
46522
|
// src/holder/mcp-credential.ts
|
|
46328
46523
|
function createConversationMcpAuthorization(options) {
|
|
46329
46524
|
let held;
|
|
46330
|
-
|
|
46525
|
+
let minting;
|
|
46526
|
+
const mint = async (signal) => {
|
|
46331
46527
|
const now = options.now();
|
|
46332
|
-
if (held !== void 0 && now < held.refreshAt) return held.authorization;
|
|
46333
46528
|
try {
|
|
46334
46529
|
const credential = await options.mint(signal);
|
|
46335
46530
|
const expiresAt = Date.parse(credential.expiresAt);
|
|
@@ -46344,11 +46539,18 @@ function createConversationMcpAuthorization(options) {
|
|
|
46344
46539
|
return held !== void 0 && now < held.expiresAt ? held.authorization : void 0;
|
|
46345
46540
|
}
|
|
46346
46541
|
};
|
|
46542
|
+
return async (signal) => {
|
|
46543
|
+
if (held !== void 0 && options.now() < held.refreshAt) return held.authorization;
|
|
46544
|
+
minting ??= mint(signal).finally(() => {
|
|
46545
|
+
minting = void 0;
|
|
46546
|
+
});
|
|
46547
|
+
return minting;
|
|
46548
|
+
};
|
|
46347
46549
|
}
|
|
46348
46550
|
|
|
46349
46551
|
// src/holder/run-inputs.ts
|
|
46350
|
-
var
|
|
46351
|
-
var
|
|
46552
|
+
var import_promises27 = require("fs/promises");
|
|
46553
|
+
var import_node_path17 = require("path");
|
|
46352
46554
|
var NO_RUN_INPUTS = {
|
|
46353
46555
|
attachments: [],
|
|
46354
46556
|
providerEnv: {},
|
|
@@ -46361,18 +46563,18 @@ function safeFilename(filename) {
|
|
|
46361
46563
|
return safe || "attachment";
|
|
46362
46564
|
}
|
|
46363
46565
|
async function prepareRunInputs(spec, { source, tmpDir, signal, skills = [] }) {
|
|
46364
|
-
const dir = (0,
|
|
46566
|
+
const dir = (0, import_node_path17.join)(tmpDir, "runs", spec.runId);
|
|
46365
46567
|
const cleanup = async () => {
|
|
46366
|
-
await (0,
|
|
46568
|
+
await (0, import_promises27.rm)(dir, { recursive: true, force: true });
|
|
46367
46569
|
};
|
|
46368
46570
|
try {
|
|
46369
46571
|
const credential = await source.fetchProviderCredential(spec.runId, signal);
|
|
46370
46572
|
const attachments = [];
|
|
46371
|
-
if (spec.attachments?.length) await (0,
|
|
46573
|
+
if (spec.attachments?.length) await (0, import_promises27.mkdir)(dir, { recursive: true, mode: 448 });
|
|
46372
46574
|
for (const [index, attachment] of (spec.attachments ?? []).entries()) {
|
|
46373
46575
|
const bytes = await source.downloadAttachment(spec.runId, attachment.id, signal);
|
|
46374
|
-
const path = (0,
|
|
46375
|
-
await (0,
|
|
46576
|
+
const path = (0, import_node_path17.join)(dir, `${index}-${safeFilename(attachment.filename)}`);
|
|
46577
|
+
await (0, import_promises27.writeFile)(path, bytes, { mode: 384 });
|
|
46376
46578
|
attachments.push({
|
|
46377
46579
|
id: attachment.id,
|
|
46378
46580
|
kind: attachment.kind,
|
|
@@ -46393,29 +46595,30 @@ async function prepareRunInputs(spec, { source, tmpDir, signal, skills = [] }) {
|
|
|
46393
46595
|
}
|
|
46394
46596
|
|
|
46395
46597
|
// src/holder/serve.ts
|
|
46396
|
-
var
|
|
46598
|
+
var import_node_crypto12 = require("crypto");
|
|
46397
46599
|
var import_node_fs10 = require("fs");
|
|
46398
46600
|
var import_node_net2 = require("net");
|
|
46601
|
+
var import_node_path25 = require("path");
|
|
46399
46602
|
init_runtime_v2();
|
|
46400
46603
|
|
|
46401
46604
|
// src/holder/admission.ts
|
|
46402
46605
|
var import_node_fs8 = require("fs");
|
|
46403
|
-
var
|
|
46606
|
+
var import_promises31 = require("fs/promises");
|
|
46404
46607
|
var import_node_os5 = require("os");
|
|
46405
|
-
var
|
|
46608
|
+
var import_node_path22 = require("path");
|
|
46406
46609
|
init_constants();
|
|
46407
46610
|
|
|
46408
46611
|
// ../shared/dist/node/local-workspace.js
|
|
46409
46612
|
var import_node_fs7 = require("fs");
|
|
46410
46613
|
var import_node_os4 = require("os");
|
|
46411
|
-
var
|
|
46614
|
+
var import_node_path18 = require("path");
|
|
46412
46615
|
function resolveAlanDefaultWorkspacePath(homeDirectory = (0, import_node_os4.homedir)()) {
|
|
46413
|
-
return (0,
|
|
46616
|
+
return (0, import_node_path18.join)(homeDirectory, ".alan", "workspace");
|
|
46414
46617
|
}
|
|
46415
46618
|
|
|
46416
46619
|
// src/holder/admission-relocation.ts
|
|
46417
|
-
var
|
|
46418
|
-
var
|
|
46620
|
+
var import_promises28 = require("fs/promises");
|
|
46621
|
+
var import_node_path19 = require("path");
|
|
46419
46622
|
var MAX_RELOCATION_CANDIDATES = 200;
|
|
46420
46623
|
var RELOCATION_BUDGET_MS = 2e4;
|
|
46421
46624
|
function repositoryIdentity(url2) {
|
|
@@ -46450,8 +46653,8 @@ async function originIdentity(git, path, signal) {
|
|
|
46450
46653
|
}
|
|
46451
46654
|
async function childDirectories(parent, limit) {
|
|
46452
46655
|
try {
|
|
46453
|
-
const entries = await (0,
|
|
46454
|
-
return entries.filter((entry) => entry.isDirectory()).slice(0, limit).map((entry) => (0,
|
|
46656
|
+
const entries = await (0, import_promises28.readdir)(parent, { withFileTypes: true });
|
|
46657
|
+
return entries.filter((entry) => entry.isDirectory()).slice(0, limit).map((entry) => (0, import_node_path19.join)(parent, entry.name));
|
|
46455
46658
|
} catch {
|
|
46456
46659
|
return [];
|
|
46457
46660
|
}
|
|
@@ -46459,7 +46662,7 @@ async function childDirectories(parent, limit) {
|
|
|
46459
46662
|
async function candidateFolders(search) {
|
|
46460
46663
|
const roots = /* @__PURE__ */ new Map();
|
|
46461
46664
|
for (const path of [search.missingPath, ...search.approvedWorkspacePaths]) {
|
|
46462
|
-
const parent = (0,
|
|
46665
|
+
const parent = (0, import_node_path19.dirname)((0, import_node_path19.resolve)(path));
|
|
46463
46666
|
roots.set(comparablePath(parent, search.platform), parent);
|
|
46464
46667
|
}
|
|
46465
46668
|
const candidates2 = /* @__PURE__ */ new Map();
|
|
@@ -46485,9 +46688,107 @@ async function discoverRelocatedWorkspace(search) {
|
|
|
46485
46688
|
return matches[0] ?? null;
|
|
46486
46689
|
}
|
|
46487
46690
|
|
|
46691
|
+
// src/holder/checkout-refresh.ts
|
|
46692
|
+
var import_node_crypto11 = require("crypto");
|
|
46693
|
+
var import_promises29 = require("fs/promises");
|
|
46694
|
+
var import_node_path20 = require("path");
|
|
46695
|
+
function short(sha) {
|
|
46696
|
+
return sha.slice(0, 12);
|
|
46697
|
+
}
|
|
46698
|
+
function staleLine(path, snapshot2, tip) {
|
|
46699
|
+
const checkout = snapshot2 === void 0 ? "is the environment snapshot's checkout" : `is the environment snapshot's checkout of ${snapshot2.branch} (commit ${short(snapshot2.head)})`;
|
|
46700
|
+
const base = snapshot2 === void 0 ? "its upstream" : `origin/${snapshot2.base}`;
|
|
46701
|
+
const remote = tip === void 0 ? "may be ahead" : `is ahead at ${short(tip)}`;
|
|
46702
|
+
return `Note: ${path} ${checkout}; ${base} ${remote}. Run \`git pull --ff-only\` there before relying on its files.`;
|
|
46703
|
+
}
|
|
46704
|
+
async function claimOnce(dir, name) {
|
|
46705
|
+
try {
|
|
46706
|
+
await (0, import_promises29.mkdir)(dir, { recursive: true, mode: 448 });
|
|
46707
|
+
await (await (0, import_promises29.open)((0, import_node_path20.join)(dir, name), "wx")).close();
|
|
46708
|
+
return true;
|
|
46709
|
+
} catch {
|
|
46710
|
+
return false;
|
|
46711
|
+
}
|
|
46712
|
+
}
|
|
46713
|
+
async function fastForward(freshness, operationId, deps, signal) {
|
|
46714
|
+
var _stack = [];
|
|
46715
|
+
try {
|
|
46716
|
+
const { path: cwd, snapshot: snapshot2, tip } = freshness;
|
|
46717
|
+
const attempt = await deps.locks.tryExclusive(snapshot2.commonDir, operationId);
|
|
46718
|
+
if (attempt.kind === "busy") return false;
|
|
46719
|
+
const _lock = __using(_stack, attempt.lock, true);
|
|
46720
|
+
const now = await readCheckoutStatus(deps.git, cwd, signal);
|
|
46721
|
+
if (now === null || now.dirty || now.head !== snapshot2.head || now.branch !== snapshot2.branch) {
|
|
46722
|
+
return false;
|
|
46723
|
+
}
|
|
46724
|
+
const git = (args) => deps.git.run({ cwd, args }, signal);
|
|
46725
|
+
if ((await git(["switch", "--quiet", "--detach", tip])).exitCode !== 0) return false;
|
|
46726
|
+
const moved = await git(["update-ref", `refs/heads/${snapshot2.branch}`, tip, snapshot2.head]);
|
|
46727
|
+
const back = await git(["switch", "--quiet", snapshot2.branch]);
|
|
46728
|
+
return moved.exitCode === 0 && back.exitCode === 0;
|
|
46729
|
+
} catch (_) {
|
|
46730
|
+
var _error = _, _hasError = true;
|
|
46731
|
+
} finally {
|
|
46732
|
+
var _promise2 = __callDispose(_stack, _error, _hasError);
|
|
46733
|
+
_promise2 && await _promise2;
|
|
46734
|
+
}
|
|
46735
|
+
}
|
|
46736
|
+
async function atFirstLease(freshness, spec, deps, signal) {
|
|
46737
|
+
const first = await claimOnce(
|
|
46738
|
+
(0, import_node_path20.join)(deps.dir, "leased"),
|
|
46739
|
+
(0, import_node_crypto11.createHash)("sha256").update(freshness.path).digest("hex")
|
|
46740
|
+
);
|
|
46741
|
+
switch (freshness.state) {
|
|
46742
|
+
case "current":
|
|
46743
|
+
case "kept":
|
|
46744
|
+
return "none";
|
|
46745
|
+
case "checking":
|
|
46746
|
+
case "failed":
|
|
46747
|
+
return "noted";
|
|
46748
|
+
case "behind":
|
|
46749
|
+
return first && freshness.fetched && await fastForward(freshness, `refresh-${spec.runId}`, deps, signal) ? "moved" : "noted";
|
|
46750
|
+
}
|
|
46751
|
+
}
|
|
46752
|
+
function lineFor(freshness) {
|
|
46753
|
+
switch (freshness.state) {
|
|
46754
|
+
case "behind":
|
|
46755
|
+
return staleLine(freshness.path, freshness.snapshot, freshness.tip);
|
|
46756
|
+
case "failed":
|
|
46757
|
+
return staleLine(freshness.path, freshness.snapshot);
|
|
46758
|
+
default:
|
|
46759
|
+
return staleLine(freshness.path, void 0);
|
|
46760
|
+
}
|
|
46761
|
+
}
|
|
46762
|
+
async function checkoutsOf(spec, leaseTargets) {
|
|
46763
|
+
if (leaseTargets.length > 0 || spec.projectPath === void 0) return [...leaseTargets];
|
|
46764
|
+
return checkoutsUnder(spec.projectPath);
|
|
46765
|
+
}
|
|
46766
|
+
function createCheckoutRefresh(deps) {
|
|
46767
|
+
return async (spec, leaseTargets, signal) => {
|
|
46768
|
+
if (spec.providerSessionId !== void 0) return void 0;
|
|
46769
|
+
if (!await claimOnce((0, import_node_path20.join)(deps.dir, "conversations"), spec.conversationId)) return void 0;
|
|
46770
|
+
const lines = [];
|
|
46771
|
+
for (const target of await checkoutsOf(spec, leaseTargets)) {
|
|
46772
|
+
const freshness = await readCheckoutFreshness(deps.dir, target);
|
|
46773
|
+
if (freshness === null) continue;
|
|
46774
|
+
const outcome2 = await atFirstLease(freshness, spec, deps, signal).catch(
|
|
46775
|
+
() => "noted"
|
|
46776
|
+
);
|
|
46777
|
+
if (outcome2 === "noted") lines.push(lineFor(freshness));
|
|
46778
|
+
deps.log.info("workspace.refresh", {
|
|
46779
|
+
runId: spec.runId,
|
|
46780
|
+
path: freshness.path,
|
|
46781
|
+
state: freshness.state,
|
|
46782
|
+
outcome: outcome2
|
|
46783
|
+
});
|
|
46784
|
+
}
|
|
46785
|
+
return lines.length === 0 ? void 0 : lines.join("\n");
|
|
46786
|
+
};
|
|
46787
|
+
}
|
|
46788
|
+
|
|
46488
46789
|
// src/holder/lease.ts
|
|
46489
|
-
var
|
|
46490
|
-
var
|
|
46790
|
+
var import_promises30 = require("fs/promises");
|
|
46791
|
+
var import_node_path21 = require("path");
|
|
46491
46792
|
var LEASE_CHECK_EVERY_MS = 5e3;
|
|
46492
46793
|
var MAX_TRANSIENT_FAILURES = 3;
|
|
46493
46794
|
var BACKOFF_BASE_MS = 1e3;
|
|
@@ -46501,8 +46802,8 @@ function identityFailure(code, workspacePath) {
|
|
|
46501
46802
|
return { code, problemCode: "app.workspace.missing", message: MESSAGES[code], workspacePath };
|
|
46502
46803
|
}
|
|
46503
46804
|
async function fileIdentity(path) {
|
|
46504
|
-
const canonical = await (0,
|
|
46505
|
-
const info = await (0,
|
|
46805
|
+
const canonical = await (0, import_promises30.realpath)(path);
|
|
46806
|
+
const info = await (0, import_promises30.stat)(canonical, { bigint: true });
|
|
46506
46807
|
return `${canonical}:${info.dev}:${info.ino}`;
|
|
46507
46808
|
}
|
|
46508
46809
|
async function snapshot(git, path, signal) {
|
|
@@ -46521,7 +46822,7 @@ async function snapshot(git, path, signal) {
|
|
|
46521
46822
|
workspace: await fileIdentity(path),
|
|
46522
46823
|
repository: await fileIdentity(commonDir),
|
|
46523
46824
|
worktree: await fileIdentity(gitDir),
|
|
46524
|
-
commonDir: await (0,
|
|
46825
|
+
commonDir: await (0, import_promises30.realpath)(commonDir)
|
|
46525
46826
|
};
|
|
46526
46827
|
} catch {
|
|
46527
46828
|
return null;
|
|
@@ -46534,7 +46835,7 @@ async function gitValue(git, path, args, signal) {
|
|
|
46534
46835
|
}
|
|
46535
46836
|
async function pathExists(path) {
|
|
46536
46837
|
try {
|
|
46537
|
-
await (0,
|
|
46838
|
+
await (0, import_promises30.stat)(path);
|
|
46538
46839
|
return true;
|
|
46539
46840
|
} catch (error61) {
|
|
46540
46841
|
return errnoCode(error61) !== "ENOENT" && errnoCode(error61) !== "ENOTDIR";
|
|
@@ -46543,19 +46844,19 @@ async function pathExists(path) {
|
|
|
46543
46844
|
async function hasGitMarker(path) {
|
|
46544
46845
|
let directory;
|
|
46545
46846
|
try {
|
|
46546
|
-
directory = await (0,
|
|
46847
|
+
directory = await (0, import_promises30.realpath)(path);
|
|
46547
46848
|
} catch {
|
|
46548
46849
|
return true;
|
|
46549
46850
|
}
|
|
46550
46851
|
for (; ; ) {
|
|
46551
46852
|
try {
|
|
46552
|
-
await (0,
|
|
46853
|
+
await (0, import_promises30.stat)((0, import_node_path21.join)(directory, ".git"));
|
|
46553
46854
|
return true;
|
|
46554
46855
|
} catch (error61) {
|
|
46555
46856
|
const code = errnoCode(error61);
|
|
46556
46857
|
if (code !== "ENOENT" && code !== "ENOTDIR") return true;
|
|
46557
46858
|
}
|
|
46558
|
-
const parent = (0,
|
|
46859
|
+
const parent = (0, import_node_path21.dirname)(directory);
|
|
46559
46860
|
if (parent === directory) return false;
|
|
46560
46861
|
directory = parent;
|
|
46561
46862
|
}
|
|
@@ -46719,7 +47020,7 @@ function volumeRoot(path) {
|
|
|
46719
47020
|
}
|
|
46720
47021
|
async function exists(path) {
|
|
46721
47022
|
try {
|
|
46722
|
-
await (0,
|
|
47023
|
+
await (0, import_promises31.stat)(path);
|
|
46723
47024
|
return true;
|
|
46724
47025
|
} catch {
|
|
46725
47026
|
return false;
|
|
@@ -46727,10 +47028,10 @@ async function exists(path) {
|
|
|
46727
47028
|
}
|
|
46728
47029
|
async function inspectReadiness(path) {
|
|
46729
47030
|
try {
|
|
46730
|
-
if (!(await (0,
|
|
47031
|
+
if (!(await (0, import_promises31.stat)(path)).isDirectory()) {
|
|
46731
47032
|
return { ready: false, missing: true, message: MESSAGES2.missing };
|
|
46732
47033
|
}
|
|
46733
|
-
await (0,
|
|
47034
|
+
await (0, import_promises31.access)(path, import_node_fs8.constants.R_OK | import_node_fs8.constants.W_OK | import_node_fs8.constants.X_OK);
|
|
46734
47035
|
return { ready: true };
|
|
46735
47036
|
} catch (error61) {
|
|
46736
47037
|
const code = errnoCode(error61) ?? "";
|
|
@@ -46808,8 +47109,8 @@ async function admitDefaultWorkspace(spec, context, skills) {
|
|
|
46808
47109
|
const { env } = context;
|
|
46809
47110
|
const path = resolveAlanDefaultWorkspacePath(env.HOME || env.USERPROFILE || (0, import_node_os5.homedir)());
|
|
46810
47111
|
try {
|
|
46811
|
-
await (0,
|
|
46812
|
-
await (0,
|
|
47112
|
+
await (0, import_promises31.mkdir)(path, { recursive: true, mode: 448 });
|
|
47113
|
+
await (0, import_promises31.access)(path, import_node_fs8.constants.R_OK | import_node_fs8.constants.W_OK | import_node_fs8.constants.X_OK);
|
|
46813
47114
|
return {
|
|
46814
47115
|
kind: "admitted",
|
|
46815
47116
|
spec: { ...spec, projectPath: path },
|
|
@@ -46874,6 +47175,7 @@ var PROBE_TIMEOUT_MS2 = 5e3;
|
|
|
46874
47175
|
function createHolderWorkspace(machine, clock, log) {
|
|
46875
47176
|
const platform = machine.platform ?? process.platform;
|
|
46876
47177
|
const git = createGitRunner({ env: machine.env, platform, localTimeoutMs: PROBE_TIMEOUT_MS2 });
|
|
47178
|
+
const locks = openRepositoryLocks({ dir: (0, import_node_path22.join)(machine.stateDir, "locks"), clock, platform });
|
|
46877
47179
|
return {
|
|
46878
47180
|
admission: {
|
|
46879
47181
|
env: machine.env,
|
|
@@ -46882,20 +47184,22 @@ function createHolderWorkspace(machine, clock, log) {
|
|
|
46882
47184
|
skills: skillsLayout(machine.stateDir),
|
|
46883
47185
|
approvedRoots: async () => {
|
|
46884
47186
|
const approved = await openApprovedPaths({
|
|
46885
|
-
file: (0,
|
|
47187
|
+
file: (0, import_node_path22.join)(machine.stateDir, "workspaces.json"),
|
|
46886
47188
|
log,
|
|
46887
47189
|
platform
|
|
46888
47190
|
});
|
|
46889
47191
|
return approved.roots();
|
|
46890
47192
|
}
|
|
46891
47193
|
},
|
|
46892
|
-
lease: {
|
|
46893
|
-
|
|
46894
|
-
|
|
46895
|
-
|
|
46896
|
-
|
|
46897
|
-
|
|
46898
|
-
|
|
47194
|
+
lease: { git, locks, clock, log, platform },
|
|
47195
|
+
...machine.refreshesFirstCheckout === true ? {
|
|
47196
|
+
refreshFirstCheckout: createCheckoutRefresh({
|
|
47197
|
+
git,
|
|
47198
|
+
locks,
|
|
47199
|
+
log,
|
|
47200
|
+
dir: (0, import_node_path22.join)(machine.stateDir, "checkout-freshness")
|
|
47201
|
+
})
|
|
47202
|
+
} : {}
|
|
46899
47203
|
};
|
|
46900
47204
|
}
|
|
46901
47205
|
|
|
@@ -46921,7 +47225,7 @@ async function respondToTurn(runningRunId, gate, driver, request2) {
|
|
|
46921
47225
|
}
|
|
46922
47226
|
|
|
46923
47227
|
// src/holder/session-facts.ts
|
|
46924
|
-
var
|
|
47228
|
+
var import_promises32 = require("fs/promises");
|
|
46925
47229
|
var CLI_RSS_CACHE_MS = 1e4;
|
|
46926
47230
|
var LOGIN_PROBLEM_PREFIX = "cli.auth.";
|
|
46927
47231
|
function isLoginFailure(result) {
|
|
@@ -46947,8 +47251,8 @@ function createSessionFacts(options) {
|
|
|
46947
47251
|
const path = await resolveCommandOnPath(command, env, platform);
|
|
46948
47252
|
if (path === null) return null;
|
|
46949
47253
|
try {
|
|
46950
|
-
const real = await (0,
|
|
46951
|
-
const info = await (0,
|
|
47254
|
+
const real = await (0, import_promises32.realpath)(path);
|
|
47255
|
+
const info = await (0, import_promises32.stat)(real);
|
|
46952
47256
|
return { command, key: `${real}:${info.ino}:${info.size}:${info.mtimeMs}` };
|
|
46953
47257
|
} catch {
|
|
46954
47258
|
return null;
|
|
@@ -47035,23 +47339,23 @@ function createSessionFacts(options) {
|
|
|
47035
47339
|
init_acp2();
|
|
47036
47340
|
|
|
47037
47341
|
// src/run-log/directory.ts
|
|
47038
|
-
var
|
|
47039
|
-
var
|
|
47342
|
+
var import_promises33 = require("fs/promises");
|
|
47343
|
+
var import_node_path23 = require("path");
|
|
47040
47344
|
init_runtime_v2();
|
|
47041
47345
|
init_zod();
|
|
47042
47346
|
var runMetaSchema = external_exports.object({ runId: runIdSchema, conversationId: conversationIdSchema });
|
|
47043
47347
|
function runDirectory(runsDir, runId) {
|
|
47044
|
-
const dir = (0,
|
|
47348
|
+
const dir = (0, import_node_path23.join)(runsDir, runId);
|
|
47045
47349
|
return {
|
|
47046
47350
|
dir,
|
|
47047
|
-
log: (0,
|
|
47048
|
-
upload: (0,
|
|
47049
|
-
meta: (0,
|
|
47351
|
+
log: (0, import_node_path23.join)(dir, "log.jsonl"),
|
|
47352
|
+
upload: (0, import_node_path23.join)(dir, "upload.json"),
|
|
47353
|
+
meta: (0, import_node_path23.join)(dir, "run.json")
|
|
47050
47354
|
};
|
|
47051
47355
|
}
|
|
47052
47356
|
async function isRunClaimed(runsDir, runId) {
|
|
47053
47357
|
try {
|
|
47054
|
-
return (await (0,
|
|
47358
|
+
return (await (0, import_promises33.stat)(runDirectory(runsDir, runId).log)).size > 0;
|
|
47055
47359
|
} catch (error61) {
|
|
47056
47360
|
if (errnoCode(error61) === "ENOENT") return false;
|
|
47057
47361
|
throw error61;
|
|
@@ -47087,7 +47391,7 @@ var decoder = new TextDecoder();
|
|
|
47087
47391
|
|
|
47088
47392
|
// src/run-log/writer.ts
|
|
47089
47393
|
var import_node_fs9 = require("fs");
|
|
47090
|
-
var
|
|
47394
|
+
var import_node_path24 = require("path");
|
|
47091
47395
|
init_runtime_v2();
|
|
47092
47396
|
function lastSeq(fd, size) {
|
|
47093
47397
|
for (const length of tailWindows(size)) {
|
|
@@ -47103,7 +47407,7 @@ function lastSeq(fd, size) {
|
|
|
47103
47407
|
throw new RuntimeFault("record_too_large", "Run log tail record is larger than any record");
|
|
47104
47408
|
}
|
|
47105
47409
|
function openRunLog(path, clock) {
|
|
47106
|
-
(0, import_node_fs9.mkdirSync)((0,
|
|
47410
|
+
(0, import_node_fs9.mkdirSync)((0, import_node_path24.dirname)(path), { recursive: true, mode: 448 });
|
|
47107
47411
|
const fd = (0, import_node_fs9.openSync)(path, "a+", 384);
|
|
47108
47412
|
let size = (0, import_node_fs9.fstatSync)(fd).size;
|
|
47109
47413
|
let seq = lastSeq(fd, size);
|
|
@@ -47281,6 +47585,10 @@ function fitForRunLog(update) {
|
|
|
47281
47585
|
async function runWithInputs({ spec, leaseTargets, skills }, context, sink, signal) {
|
|
47282
47586
|
var _stack = [];
|
|
47283
47587
|
try {
|
|
47588
|
+
const refreshed = context.workspace?.refreshFirstCheckout?.(spec, leaseTargets, signal).catch((error61) => {
|
|
47589
|
+
context.log.warn("workspace.refresh_failed", { runId: spec.runId, error: error61 });
|
|
47590
|
+
return void 0;
|
|
47591
|
+
});
|
|
47284
47592
|
let inputs;
|
|
47285
47593
|
try {
|
|
47286
47594
|
inputs = context.inputs ? await prepareRunInputs(spec, { ...context.inputs, signal, skills }) : { ...NO_RUN_INPUTS, skills };
|
|
@@ -47291,8 +47599,14 @@ async function runWithInputs({ spec, leaseTargets, skills }, context, sink, sign
|
|
|
47291
47599
|
message: `Could not fetch this run's attachments or provider credential: ${error61 instanceof Error ? error61.message : String(error61)}`
|
|
47292
47600
|
};
|
|
47293
47601
|
}
|
|
47602
|
+
const turnContext = await refreshed;
|
|
47294
47603
|
const prepared = __using(_stack, inputs, true);
|
|
47295
|
-
const run = (turnSink, turnSignal) => context.driver.runTurn(
|
|
47604
|
+
const run = (turnSink, turnSignal) => context.driver.runTurn(
|
|
47605
|
+
spec,
|
|
47606
|
+
turnSink,
|
|
47607
|
+
turnSignal,
|
|
47608
|
+
turnContext === void 0 ? prepared : { ...prepared, turnContext }
|
|
47609
|
+
);
|
|
47296
47610
|
if (context.workspace === void 0) return await run(sink, signal);
|
|
47297
47611
|
const leased = { ...context, lease: context.workspace.lease };
|
|
47298
47612
|
return await runLeased(spec, leaseTargets, leased, sink, signal, run);
|
|
@@ -47390,12 +47704,12 @@ var TASK_UNSUPPORTED = {
|
|
|
47390
47704
|
message: "This agent cannot stop one background task."
|
|
47391
47705
|
};
|
|
47392
47706
|
function sha2562(value) {
|
|
47393
|
-
return (0,
|
|
47707
|
+
return (0, import_node_crypto12.createHash)("sha256").update(value).digest("hex");
|
|
47394
47708
|
}
|
|
47395
47709
|
function tokenMatches(expected, presented) {
|
|
47396
47710
|
const a = Buffer.from(sha2562(expected), "hex");
|
|
47397
47711
|
const b = Buffer.from(sha2562(presented), "hex");
|
|
47398
|
-
return (0,
|
|
47712
|
+
return (0, import_node_crypto12.timingSafeEqual)(a, b);
|
|
47399
47713
|
}
|
|
47400
47714
|
async function runHolder({
|
|
47401
47715
|
launch,
|
|
@@ -47405,215 +47719,223 @@ async function runHolder({
|
|
|
47405
47719
|
inputs,
|
|
47406
47720
|
machine
|
|
47407
47721
|
}) {
|
|
47408
|
-
|
|
47409
|
-
|
|
47410
|
-
|
|
47411
|
-
|
|
47412
|
-
|
|
47413
|
-
|
|
47414
|
-
|
|
47415
|
-
|
|
47416
|
-
|
|
47417
|
-
|
|
47418
|
-
|
|
47419
|
-
|
|
47420
|
-
|
|
47421
|
-
|
|
47422
|
-
|
|
47423
|
-
});
|
|
47424
|
-
const observed = facts.observe(driver);
|
|
47425
|
-
const writeStatus = () => writeJsonFileAtomic(launch.statusPath, {
|
|
47426
|
-
protocol: HOLDER_PROTOCOL,
|
|
47427
|
-
conversationId: launch.conversationId,
|
|
47428
|
-
pid: identity.pid,
|
|
47429
|
-
startedAt: identity.startedAt,
|
|
47430
|
-
...identity.command === void 0 ? {} : { command: identity.command },
|
|
47431
|
-
endpoint: launch.endpoint,
|
|
47432
|
-
tokenSha256: sha2562(launch.token),
|
|
47433
|
-
state: holder.state,
|
|
47434
|
-
runId: holder.runId,
|
|
47435
|
-
updatedAt: clock.now()
|
|
47436
|
-
});
|
|
47437
|
-
const broadcast = (message) => {
|
|
47438
|
-
for (const client of holder.clients) writeMessage(client, message);
|
|
47439
|
-
};
|
|
47440
|
-
const settle = () => {
|
|
47441
|
-
holder.state = "idle";
|
|
47442
|
-
holder.runId = null;
|
|
47443
|
-
holder.turn = null;
|
|
47444
|
-
void writeStatus();
|
|
47445
|
-
};
|
|
47446
|
-
const startTurn = (id, spec, client) => {
|
|
47447
|
-
if (holder.runId === spec.runId) {
|
|
47448
|
-
writeMessage(client, {
|
|
47449
|
-
type: "error",
|
|
47450
|
-
id,
|
|
47451
|
-
code: HOLDER_ALREADY_STARTED,
|
|
47452
|
-
message: "The run is already running"
|
|
47453
|
-
});
|
|
47454
|
-
return;
|
|
47455
|
-
}
|
|
47456
|
-
if (holder.state !== "idle") {
|
|
47457
|
-
writeMessage(client, { type: "error", id, code: "busy", message: "A turn is running" });
|
|
47458
|
-
return;
|
|
47459
|
-
}
|
|
47460
|
-
const turn = new AbortController();
|
|
47461
|
-
holder.state = "running";
|
|
47462
|
-
holder.runId = spec.runId;
|
|
47463
|
-
holder.turn = turn;
|
|
47464
|
-
const context = {
|
|
47465
|
-
runsDir: launch.runsDir,
|
|
47466
|
-
machineId: launch.machineId,
|
|
47467
|
-
driver: observed,
|
|
47722
|
+
var _stack = [];
|
|
47723
|
+
try {
|
|
47724
|
+
const identity = await readProcessIdentity(process.pid);
|
|
47725
|
+
if (identity === null) throw new RuntimeFault("internal", "Cannot read own process identity");
|
|
47726
|
+
const _engines = __using(_stack, recordSpawnedEngines(engineRecordsPath((0, import_node_path25.dirname)(launch.statusPath)), clock, log));
|
|
47727
|
+
const holder = {
|
|
47728
|
+
state: "idle",
|
|
47729
|
+
runId: null,
|
|
47730
|
+
turn: null,
|
|
47731
|
+
answerGate: createAnswerGate(),
|
|
47732
|
+
clients: /* @__PURE__ */ new Set()
|
|
47733
|
+
};
|
|
47734
|
+
const exit = new AbortController();
|
|
47735
|
+
const workspace = machine === void 0 ? void 0 : createHolderWorkspace(machine, clock, log);
|
|
47736
|
+
const facts = createSessionFacts({
|
|
47468
47737
|
clock,
|
|
47469
|
-
|
|
47470
|
-
|
|
47471
|
-
|
|
47472
|
-
|
|
47473
|
-
|
|
47474
|
-
|
|
47475
|
-
|
|
47476
|
-
|
|
47477
|
-
|
|
47478
|
-
|
|
47738
|
+
env: machine?.env ?? {},
|
|
47739
|
+
...machine?.platform === void 0 ? {} : { platform: machine.platform }
|
|
47740
|
+
});
|
|
47741
|
+
const observed = facts.observe(driver);
|
|
47742
|
+
const writeStatus = () => writeJsonFileAtomic(launch.statusPath, {
|
|
47743
|
+
protocol: HOLDER_PROTOCOL,
|
|
47744
|
+
conversationId: launch.conversationId,
|
|
47745
|
+
pid: identity.pid,
|
|
47746
|
+
startedAt: identity.startedAt,
|
|
47747
|
+
...identity.command === void 0 ? {} : { command: identity.command },
|
|
47748
|
+
endpoint: launch.endpoint,
|
|
47749
|
+
tokenSha256: sha2562(launch.token),
|
|
47750
|
+
state: holder.state,
|
|
47751
|
+
runId: holder.runId,
|
|
47752
|
+
updatedAt: clock.now()
|
|
47753
|
+
});
|
|
47754
|
+
const broadcast = (message) => {
|
|
47755
|
+
for (const client of holder.clients) writeMessage(client, message);
|
|
47756
|
+
};
|
|
47757
|
+
const settle = () => {
|
|
47758
|
+
holder.state = "idle";
|
|
47759
|
+
holder.runId = null;
|
|
47760
|
+
holder.turn = null;
|
|
47761
|
+
void writeStatus();
|
|
47762
|
+
};
|
|
47763
|
+
const startTurn = (id, spec, client) => {
|
|
47764
|
+
if (holder.runId === spec.runId) {
|
|
47765
|
+
writeMessage(client, {
|
|
47766
|
+
type: "error",
|
|
47767
|
+
id,
|
|
47768
|
+
code: HOLDER_ALREADY_STARTED,
|
|
47769
|
+
message: "The run is already running"
|
|
47770
|
+
});
|
|
47771
|
+
return;
|
|
47772
|
+
}
|
|
47773
|
+
if (holder.state !== "idle") {
|
|
47774
|
+
writeMessage(client, { type: "error", id, code: "busy", message: "A turn is running" });
|
|
47775
|
+
return;
|
|
47776
|
+
}
|
|
47777
|
+
const turn = new AbortController();
|
|
47778
|
+
holder.state = "running";
|
|
47779
|
+
holder.runId = spec.runId;
|
|
47780
|
+
holder.turn = turn;
|
|
47781
|
+
const context = {
|
|
47782
|
+
runsDir: launch.runsDir,
|
|
47783
|
+
machineId: launch.machineId,
|
|
47784
|
+
driver: observed,
|
|
47785
|
+
clock,
|
|
47786
|
+
log,
|
|
47787
|
+
onAppended: (runId, offset) => broadcast({ type: "appended", runId, offset }),
|
|
47788
|
+
...inputs === void 0 ? {} : { inputs },
|
|
47789
|
+
...workspace === void 0 ? {} : { workspace },
|
|
47790
|
+
answerGate: holder.answerGate
|
|
47791
|
+
};
|
|
47792
|
+
claimRun(spec, context).then(
|
|
47793
|
+
(claimed) => {
|
|
47794
|
+
if (claimed === null) {
|
|
47795
|
+
log.warn("holder.start_already_claimed", { runId: spec.runId });
|
|
47796
|
+
settle();
|
|
47797
|
+
writeMessage(client, {
|
|
47798
|
+
type: "error",
|
|
47799
|
+
id,
|
|
47800
|
+
code: HOLDER_ALREADY_STARTED,
|
|
47801
|
+
message: "The run was already started"
|
|
47802
|
+
});
|
|
47803
|
+
return;
|
|
47804
|
+
}
|
|
47805
|
+
writeMessage(client, { type: "ack", id });
|
|
47806
|
+
void writeStatus();
|
|
47807
|
+
runClaimedTurn(spec, claimed, context, turn.signal).then((outcome2) => broadcast({ type: "turn_ended", runId: spec.runId, outcome: outcome2 })).catch((error61) => log.error("holder.turn_crashed", { runId: spec.runId, error: error61 })).finally(settle);
|
|
47808
|
+
},
|
|
47809
|
+
(error61) => {
|
|
47810
|
+
log.error("holder.claim_failed", { runId: spec.runId, error: error61 });
|
|
47479
47811
|
settle();
|
|
47480
47812
|
writeMessage(client, {
|
|
47481
47813
|
type: "error",
|
|
47482
47814
|
id,
|
|
47483
|
-
code:
|
|
47484
|
-
message: "The run
|
|
47815
|
+
code: "claim_failed",
|
|
47816
|
+
message: "The run log could not be written"
|
|
47485
47817
|
});
|
|
47486
|
-
return;
|
|
47487
47818
|
}
|
|
47488
|
-
|
|
47489
|
-
|
|
47490
|
-
|
|
47491
|
-
|
|
47492
|
-
|
|
47493
|
-
|
|
47494
|
-
|
|
47819
|
+
);
|
|
47820
|
+
};
|
|
47821
|
+
const respond = (request2, client) => {
|
|
47822
|
+
respondToTurn(holder.runId, holder.answerGate, driver, request2).then((status) => {
|
|
47823
|
+
log.info("holder.responded", { runId: request2.runId, status });
|
|
47824
|
+
writeMessage(client, { type: "responded", id: request2.id, status });
|
|
47825
|
+
}).catch((error61) => {
|
|
47826
|
+
log.warn("holder.respond_crashed", { runId: request2.runId, error: error61 });
|
|
47495
47827
|
writeMessage(client, {
|
|
47496
47828
|
type: "error",
|
|
47497
|
-
id,
|
|
47498
|
-
code: "
|
|
47499
|
-
message: "The
|
|
47829
|
+
id: request2.id,
|
|
47830
|
+
code: "respond_failed",
|
|
47831
|
+
message: "The answer could not be delivered"
|
|
47500
47832
|
});
|
|
47501
|
-
}
|
|
47502
|
-
);
|
|
47503
|
-
};
|
|
47504
|
-
const respond = (request2, client) => {
|
|
47505
|
-
respondToTurn(holder.runId, holder.answerGate, driver, request2).then((status) => {
|
|
47506
|
-
log.info("holder.responded", { runId: request2.runId, status });
|
|
47507
|
-
writeMessage(client, { type: "responded", id: request2.id, status });
|
|
47508
|
-
}).catch((error61) => {
|
|
47509
|
-
log.warn("holder.respond_crashed", { runId: request2.runId, error: error61 });
|
|
47510
|
-
writeMessage(client, {
|
|
47511
|
-
type: "error",
|
|
47512
|
-
id: request2.id,
|
|
47513
|
-
code: "respond_failed",
|
|
47514
|
-
message: "The answer could not be delivered"
|
|
47515
47833
|
});
|
|
47516
|
-
}
|
|
47517
|
-
|
|
47518
|
-
|
|
47519
|
-
|
|
47520
|
-
|
|
47521
|
-
|
|
47522
|
-
|
|
47523
|
-
|
|
47524
|
-
|
|
47525
|
-
|
|
47526
|
-
|
|
47527
|
-
|
|
47528
|
-
|
|
47834
|
+
};
|
|
47835
|
+
const stopTask = (request2, client) => {
|
|
47836
|
+
const stopping = driver.stopTask?.(request2.taskId) ?? Promise.resolve(TASK_UNSUPPORTED);
|
|
47837
|
+
stopping.then((result) => {
|
|
47838
|
+
log.info("holder.task_stop", { runId: request2.runId, taskId: request2.taskId, result });
|
|
47839
|
+
writeMessage(client, { type: "task_stopped", id: request2.id, result });
|
|
47840
|
+
}).catch((error61) => {
|
|
47841
|
+
log.warn("holder.task_stop_crashed", { runId: request2.runId, error: error61 });
|
|
47842
|
+
writeMessage(client, {
|
|
47843
|
+
type: "task_stopped",
|
|
47844
|
+
id: request2.id,
|
|
47845
|
+
result: { ok: false, reason: "failed", message: "The task could not be stopped" }
|
|
47846
|
+
});
|
|
47529
47847
|
});
|
|
47530
|
-
}
|
|
47531
|
-
|
|
47532
|
-
|
|
47533
|
-
|
|
47534
|
-
case "auth":
|
|
47535
|
-
return;
|
|
47536
|
-
case "start_turn":
|
|
47537
|
-
startTurn(request2.id, request2.spec, client);
|
|
47538
|
-
return;
|
|
47539
|
-
case "respond":
|
|
47540
|
-
respond(request2, client);
|
|
47541
|
-
return;
|
|
47542
|
-
case "stop_task":
|
|
47543
|
-
stopTask(request2, client);
|
|
47544
|
-
return;
|
|
47545
|
-
case "abort":
|
|
47546
|
-
if (holder.runId === request2.runId) holder.turn?.abort(request2.outcome ?? "aborted");
|
|
47547
|
-
writeMessage(client, { type: "ack", id: request2.id });
|
|
47548
|
-
return;
|
|
47549
|
-
case "status":
|
|
47550
|
-
void facts.snapshot().then(
|
|
47551
|
-
(snapshot2) => writeMessage(client, {
|
|
47552
|
-
type: "status",
|
|
47553
|
-
id: request2.id,
|
|
47554
|
-
state: holder.state,
|
|
47555
|
-
runId: holder.runId,
|
|
47556
|
-
facts: snapshot2
|
|
47557
|
-
})
|
|
47558
|
-
);
|
|
47559
|
-
return;
|
|
47560
|
-
case "suspend":
|
|
47561
|
-
if (holder.state === "running") {
|
|
47562
|
-
writeMessage(client, {
|
|
47563
|
-
type: "error",
|
|
47564
|
-
id: request2.id,
|
|
47565
|
-
code: "busy",
|
|
47566
|
-
message: "A turn is running; it is never killed to suspend"
|
|
47567
|
-
});
|
|
47848
|
+
};
|
|
47849
|
+
const handle = (request2, client) => {
|
|
47850
|
+
switch (request2.type) {
|
|
47851
|
+
case "auth":
|
|
47568
47852
|
return;
|
|
47569
|
-
|
|
47570
|
-
|
|
47571
|
-
|
|
47572
|
-
|
|
47573
|
-
|
|
47574
|
-
|
|
47575
|
-
|
|
47576
|
-
|
|
47577
|
-
|
|
47578
|
-
|
|
47579
|
-
|
|
47580
|
-
|
|
47581
|
-
|
|
47582
|
-
|
|
47583
|
-
|
|
47584
|
-
|
|
47853
|
+
case "start_turn":
|
|
47854
|
+
startTurn(request2.id, request2.spec, client);
|
|
47855
|
+
return;
|
|
47856
|
+
case "respond":
|
|
47857
|
+
respond(request2, client);
|
|
47858
|
+
return;
|
|
47859
|
+
case "stop_task":
|
|
47860
|
+
stopTask(request2, client);
|
|
47861
|
+
return;
|
|
47862
|
+
case "abort":
|
|
47863
|
+
if (holder.runId === request2.runId) holder.turn?.abort(request2.outcome ?? "aborted");
|
|
47864
|
+
writeMessage(client, { type: "ack", id: request2.id });
|
|
47865
|
+
return;
|
|
47866
|
+
case "status":
|
|
47867
|
+
void facts.snapshot().then(
|
|
47868
|
+
(snapshot2) => writeMessage(client, {
|
|
47869
|
+
type: "status",
|
|
47870
|
+
id: request2.id,
|
|
47871
|
+
state: holder.state,
|
|
47872
|
+
runId: holder.runId,
|
|
47873
|
+
facts: snapshot2
|
|
47874
|
+
})
|
|
47875
|
+
);
|
|
47876
|
+
return;
|
|
47877
|
+
case "suspend":
|
|
47878
|
+
if (holder.state === "running") {
|
|
47879
|
+
writeMessage(client, {
|
|
47880
|
+
type: "error",
|
|
47881
|
+
id: request2.id,
|
|
47882
|
+
code: "busy",
|
|
47883
|
+
message: "A turn is running; it is never killed to suspend"
|
|
47884
|
+
});
|
|
47585
47885
|
return;
|
|
47586
47886
|
}
|
|
47587
|
-
|
|
47588
|
-
|
|
47589
|
-
|
|
47590
|
-
type: "ready",
|
|
47591
|
-
protocol: HOLDER_PROTOCOL,
|
|
47592
|
-
conversationId: launch.conversationId,
|
|
47593
|
-
pid: identity.pid
|
|
47594
|
-
});
|
|
47887
|
+
holder.state = "suspending";
|
|
47888
|
+
writeMessage(client, { type: "ack", id: request2.id });
|
|
47889
|
+
exit.abort();
|
|
47595
47890
|
return;
|
|
47596
|
-
|
|
47597
|
-
|
|
47598
|
-
}
|
|
47599
|
-
|
|
47600
|
-
|
|
47601
|
-
|
|
47602
|
-
|
|
47603
|
-
|
|
47604
|
-
|
|
47605
|
-
|
|
47606
|
-
|
|
47607
|
-
|
|
47608
|
-
|
|
47609
|
-
|
|
47610
|
-
|
|
47611
|
-
|
|
47612
|
-
|
|
47613
|
-
|
|
47614
|
-
|
|
47615
|
-
|
|
47616
|
-
|
|
47891
|
+
default:
|
|
47892
|
+
assertNever2(request2);
|
|
47893
|
+
}
|
|
47894
|
+
};
|
|
47895
|
+
const server = (0, import_node_net2.createServer)((client) => {
|
|
47896
|
+
let authenticated = false;
|
|
47897
|
+
readMessages(client, holderRequestSchema, {
|
|
47898
|
+
onMessage: (request2) => {
|
|
47899
|
+
if (!authenticated) {
|
|
47900
|
+
if (request2.type !== "auth" || !tokenMatches(launch.token, request2.token)) {
|
|
47901
|
+
client.destroy();
|
|
47902
|
+
return;
|
|
47903
|
+
}
|
|
47904
|
+
authenticated = true;
|
|
47905
|
+
holder.clients.add(client);
|
|
47906
|
+
writeMessage(client, {
|
|
47907
|
+
type: "ready",
|
|
47908
|
+
protocol: HOLDER_PROTOCOL,
|
|
47909
|
+
conversationId: launch.conversationId,
|
|
47910
|
+
pid: identity.pid
|
|
47911
|
+
});
|
|
47912
|
+
return;
|
|
47913
|
+
}
|
|
47914
|
+
handle(request2, client);
|
|
47915
|
+
},
|
|
47916
|
+
onInvalid: (reason) => log.warn("holder.request_invalid", { reason })
|
|
47917
|
+
});
|
|
47918
|
+
client.on("close", () => holder.clients.delete(client));
|
|
47919
|
+
client.on("error", () => holder.clients.delete(client));
|
|
47920
|
+
});
|
|
47921
|
+
removeStaleEndpoint(launch.endpoint);
|
|
47922
|
+
await new Promise((resolve6, reject) => {
|
|
47923
|
+
server.once("error", reject);
|
|
47924
|
+
server.listen(launch.endpoint, () => resolve6());
|
|
47925
|
+
});
|
|
47926
|
+
await writeStatus();
|
|
47927
|
+
log.info("holder.ready", { conversationId: launch.conversationId, pid: identity.pid });
|
|
47928
|
+
await new Promise((resolve6) => exit.signal.addEventListener("abort", () => resolve6()));
|
|
47929
|
+
await driver.suspend?.().catch((error61) => log.warn("holder.driver_suspend_failed", { error: error61 }));
|
|
47930
|
+
for (const client of holder.clients) client.end();
|
|
47931
|
+
await new Promise((resolve6) => server.close(() => resolve6()));
|
|
47932
|
+
(0, import_node_fs10.rmSync)(launch.statusPath, { force: true });
|
|
47933
|
+
log.info("holder.suspended", { conversationId: launch.conversationId });
|
|
47934
|
+
} catch (_) {
|
|
47935
|
+
var _error = _, _hasError = true;
|
|
47936
|
+
} finally {
|
|
47937
|
+
__callDispose(_stack, _error, _hasError);
|
|
47938
|
+
}
|
|
47617
47939
|
}
|
|
47618
47940
|
|
|
47619
47941
|
// src/sessions/suspend-policy.ts
|
|
@@ -47656,6 +47978,8 @@ var envSchema = external_exports.object({
|
|
|
47656
47978
|
ALAN_RUNTIME_PROVIDER_NPM_CLI: external_exports.string().min(1).optional(),
|
|
47657
47979
|
ALAN_RUNTIME_HOST: external_exports.enum(RUNTIME_HOST_KINDS).default("standalone"),
|
|
47658
47980
|
ALAN_RUNTIME_GITHUB_PROXY: external_exports.enum(["on", "off"]).default("off"),
|
|
47981
|
+
ALAN_RUNTIME_GIT_GATEWAY_URL: external_exports.url().optional(),
|
|
47982
|
+
ALAN_RUNTIME_WORKSPACE_ROOT: external_exports.string().min(1).optional(),
|
|
47659
47983
|
XDG_CONFIG_HOME: external_exports.string().min(1).optional(),
|
|
47660
47984
|
GH_CONFIG_DIR: external_exports.string().min(1).optional()
|
|
47661
47985
|
});
|
|
@@ -47676,6 +48000,11 @@ var RUNTIME_ENV_PREFIX = "ALAN_RUNTIME_";
|
|
|
47676
48000
|
var MAX_ACTIVE_RUNS_VARIABLE = "ALAN_MAX_ACTIVE_RUNS";
|
|
47677
48001
|
var MAX_ACTIVE_RUNS_RANGE = { min: 1, max: 32 };
|
|
47678
48002
|
var SETUP_TOKEN_VARIABLE = "ALAN_RUNTIME_SETUP_TOKEN";
|
|
48003
|
+
var ENROLLMENT_CODE_VARIABLE = "ALAN_RUNTIME_ENROLLMENT_CODE";
|
|
48004
|
+
var SECRET_VARIABLES = /* @__PURE__ */ new Set([
|
|
48005
|
+
SETUP_TOKEN_VARIABLE,
|
|
48006
|
+
ENROLLMENT_CODE_VARIABLE
|
|
48007
|
+
]);
|
|
47679
48008
|
var ALAN_CODE_ENGINE_VARIABLE = "ALAN_CODE_ENGINE_PATH";
|
|
47680
48009
|
function loadRuntimeConfig(env = process.env, totalMemoryBytes = (0, import_node_os7.totalmem)()) {
|
|
47681
48010
|
const parsed = envSchema.safeParse(env);
|
|
@@ -47702,6 +48031,8 @@ function loadRuntimeConfig(env = process.env, totalMemoryBytes = (0, import_node
|
|
|
47702
48031
|
ALAN_RUNTIME_PROVIDER_NPM_CLI,
|
|
47703
48032
|
ALAN_RUNTIME_HOST,
|
|
47704
48033
|
ALAN_RUNTIME_GITHUB_PROXY,
|
|
48034
|
+
ALAN_RUNTIME_GIT_GATEWAY_URL,
|
|
48035
|
+
ALAN_RUNTIME_WORKSPACE_ROOT,
|
|
47705
48036
|
XDG_CONFIG_HOME,
|
|
47706
48037
|
GH_CONFIG_DIR
|
|
47707
48038
|
} = parsed.data;
|
|
@@ -47735,24 +48066,26 @@ function loadRuntimeConfig(env = process.env, totalMemoryBytes = (0, import_node
|
|
|
47735
48066
|
providerProbes: ALAN_RUNTIME_PROVIDER_PROBES === "on",
|
|
47736
48067
|
providerToolchain: ALAN_RUNTIME_PROVIDER_NODE !== void 0 && ALAN_RUNTIME_PROVIDER_NPM_CLI !== void 0 ? { node: ALAN_RUNTIME_PROVIDER_NODE, npmCli: ALAN_RUNTIME_PROVIDER_NPM_CLI } : null,
|
|
47737
48068
|
home,
|
|
47738
|
-
configHome: XDG_CONFIG_HOME ?? (0,
|
|
48069
|
+
configHome: XDG_CONFIG_HOME ?? (0, import_node_path27.join)(home, ".config"),
|
|
47739
48070
|
...githubProxyConfig({ ALAN_RUNTIME_GITHUB_PROXY, XDG_CONFIG_HOME, GH_CONFIG_DIR }, home),
|
|
48071
|
+
gitGatewayUrl: ALAN_RUNTIME_GIT_GATEWAY_URL ?? null,
|
|
48072
|
+
workspaceRoot: ALAN_RUNTIME_WORKSPACE_ROOT ?? null,
|
|
47740
48073
|
serviceEnvironment: serviceEnvironment(env, ALAN_RUNTIME_PROFILE),
|
|
47741
48074
|
adoptsLegacyInstall: ALAN_RUNTIME_STATE_DIR === void 0
|
|
47742
48075
|
};
|
|
47743
48076
|
}
|
|
47744
48077
|
function githubProxyConfig(env, home) {
|
|
47745
|
-
const configHome = env.XDG_CONFIG_HOME ?? (0,
|
|
48078
|
+
const configHome = env.XDG_CONFIG_HOME ?? (0, import_node_path27.join)(home, ".config");
|
|
47746
48079
|
return {
|
|
47747
48080
|
githubProxy: env.ALAN_RUNTIME_GITHUB_PROXY === "on",
|
|
47748
|
-
ghConfigDir: env.GH_CONFIG_DIR ?? (0,
|
|
48081
|
+
ghConfigDir: env.GH_CONFIG_DIR ?? (0, import_node_path27.join)(configHome, "gh")
|
|
47749
48082
|
};
|
|
47750
48083
|
}
|
|
47751
48084
|
function serviceEnvironment(env, profile) {
|
|
47752
48085
|
const result = { ALAN_RUNTIME_PROFILE: profile };
|
|
47753
48086
|
for (const [key, value] of Object.entries(env)) {
|
|
47754
48087
|
const copied = key.startsWith(RUNTIME_ENV_PREFIX) || key === MAX_ACTIVE_RUNS_VARIABLE || key === ALAN_CODE_ENGINE_VARIABLE;
|
|
47755
|
-
if (!copied || key
|
|
48088
|
+
if (!copied || SECRET_VARIABLES.has(key)) continue;
|
|
47756
48089
|
if (value !== void 0 && value.length > 0) result[key] = value;
|
|
47757
48090
|
}
|
|
47758
48091
|
return result;
|
|
@@ -47785,7 +48118,10 @@ var ELECTRON_ENV_PREFIX = "ELECTRON_";
|
|
|
47785
48118
|
function readCliEnvironment(env = process.env) {
|
|
47786
48119
|
const result = {};
|
|
47787
48120
|
for (const [key, value] of Object.entries(env)) {
|
|
47788
|
-
if (value
|
|
48121
|
+
if (value === void 0 || key.startsWith(ELECTRON_ENV_PREFIX) || SECRET_VARIABLES.has(key)) {
|
|
48122
|
+
continue;
|
|
48123
|
+
}
|
|
48124
|
+
result[key] = value;
|
|
47789
48125
|
}
|
|
47790
48126
|
return result;
|
|
47791
48127
|
}
|
|
@@ -47841,7 +48177,7 @@ async function loadStoredAccess(paths, access3 = { exec: systemExec }) {
|
|
|
47841
48177
|
}
|
|
47842
48178
|
|
|
47843
48179
|
// src/cli/commands/hold.ts
|
|
47844
|
-
var
|
|
48180
|
+
var import_node_path28 = require("path");
|
|
47845
48181
|
init_runtime_v2();
|
|
47846
48182
|
async function machineAccess(paths, log, conversationId, transport) {
|
|
47847
48183
|
const initial = await loadStoredAccess(paths).catch(
|
|
@@ -47858,10 +48194,6 @@ async function machineAccess(paths, log, conversationId, transport) {
|
|
|
47858
48194
|
transport
|
|
47859
48195
|
});
|
|
47860
48196
|
};
|
|
47861
|
-
const source = {
|
|
47862
|
-
downloadAttachment: async (runId, id, signal) => (await api()).downloadAttachment(runId, id, signal),
|
|
47863
|
-
fetchProviderCredential: async (runId, signal) => (await api()).fetchProviderCredential(runId, signal)
|
|
47864
|
-
};
|
|
47865
48197
|
const apiUrl = initial?.endpoints.apiUrl;
|
|
47866
48198
|
const managedMcp = apiUrl === void 0 ? void 0 : {
|
|
47867
48199
|
url: new URL("/mcp", apiUrl).href,
|
|
@@ -47871,6 +48203,13 @@ async function machineAccess(paths, log, conversationId, transport) {
|
|
|
47871
48203
|
log
|
|
47872
48204
|
})
|
|
47873
48205
|
};
|
|
48206
|
+
const source = {
|
|
48207
|
+
downloadAttachment: async (runId, id, signal) => (await api()).downloadAttachment(runId, id, signal),
|
|
48208
|
+
fetchProviderCredential: async (runId, signal) => {
|
|
48209
|
+
void managedMcp?.authorization(signal);
|
|
48210
|
+
return (await api()).fetchProviderCredential(runId, signal);
|
|
48211
|
+
}
|
|
48212
|
+
};
|
|
47874
48213
|
return { source, managedMcp };
|
|
47875
48214
|
}
|
|
47876
48215
|
async function runHold(argv) {
|
|
@@ -47888,7 +48227,7 @@ async function runHold(argv) {
|
|
|
47888
48227
|
const config2 = loadRuntimeConfig();
|
|
47889
48228
|
const paths = runtimePaths(config2.stateDir);
|
|
47890
48229
|
const log = __using(_stack, openFileLog(
|
|
47891
|
-
(0,
|
|
48230
|
+
(0, import_node_path28.join)(paths.logs, `holder-${launch.value.conversationId}.jsonl`),
|
|
47892
48231
|
config2.logLevel,
|
|
47893
48232
|
systemClock
|
|
47894
48233
|
));
|
|
@@ -47911,7 +48250,12 @@ async function runHold(argv) {
|
|
|
47911
48250
|
clock: systemClock,
|
|
47912
48251
|
log,
|
|
47913
48252
|
inputs: { source: access3.source, tmpDir: paths.tmp },
|
|
47914
|
-
machine: {
|
|
48253
|
+
machine: {
|
|
48254
|
+
env: cliEnvironment,
|
|
48255
|
+
stateDir: paths.stateDir,
|
|
48256
|
+
// Only a cloud sandbox's runtime has a git gateway.
|
|
48257
|
+
refreshesFirstCheckout: config2.gitGatewayUrl !== null
|
|
48258
|
+
}
|
|
47915
48259
|
});
|
|
47916
48260
|
} catch (_) {
|
|
47917
48261
|
var _error = _, _hasError = true;
|