@alan-ai-hq/agent-manager-linux-arm64 0.1.134 → 0.1.136
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 +2146 -1254
- package/alan-holder.cjs +1145 -637
- package/package.json +1 -1
package/alan-holder.cjs
CHANGED
|
@@ -20376,10 +20376,13 @@ var init_desired_state = __esm({
|
|
|
20376
20376
|
function runProviderCredentialPath(runId) {
|
|
20377
20377
|
return `/public/machines/me/runs/${encodeURIComponent(runId)}/provider-credential`;
|
|
20378
20378
|
}
|
|
20379
|
+
function runCodexCredentialRefreshPath(runId) {
|
|
20380
|
+
return `${runProviderCredentialPath(runId)}/refresh`;
|
|
20381
|
+
}
|
|
20379
20382
|
function runAttachmentPath(runId, attachmentId) {
|
|
20380
20383
|
return `/public/machines/me/runs/${encodeURIComponent(runId)}/attachments/${encodeURIComponent(attachmentId)}`;
|
|
20381
20384
|
}
|
|
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;
|
|
20385
|
+
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, runCodexCredentialSchema, runCodexCredentialRefreshRequestSchema, runProviderCredentialSchema;
|
|
20383
20386
|
var init_machine_identity = __esm({
|
|
20384
20387
|
"../shared/dist/runtime-v2/machine-identity.js"() {
|
|
20385
20388
|
"use strict";
|
|
@@ -20399,6 +20402,8 @@ var init_machine_identity = __esm({
|
|
|
20399
20402
|
MACHINE_PATHS = {
|
|
20400
20403
|
/** POST with a one-time setup grant (what `install --setup-token` / `setup` send). */
|
|
20401
20404
|
register: "/public/machines/register",
|
|
20405
|
+
/** POST with a cloud sandbox's one-time enrollment code from `ALAN_RUNTIME_ENROLLMENT_CODE`. */
|
|
20406
|
+
enroll: "/public/machines/enroll",
|
|
20402
20407
|
/** POST with the current renewal token; the response carries a new one and the old dies. */
|
|
20403
20408
|
renew: "/public/machines/me/renew",
|
|
20404
20409
|
/** POST by the machine itself on logout/uninstall. */
|
|
@@ -20435,6 +20440,7 @@ var init_machine_identity = __esm({
|
|
|
20435
20440
|
/** Chosen by the install before its first registration, so a credential lost locally still maps to its row. */
|
|
20436
20441
|
installationId: external_exports.guid().optional()
|
|
20437
20442
|
});
|
|
20443
|
+
machineEnrollRequestSchema = external_exports.object({ enrollmentCode: external_exports.string().min(1) });
|
|
20438
20444
|
machineRenewRequestSchema = external_exports.object({ renewalToken: external_exports.string().min(1) });
|
|
20439
20445
|
machineRenewReusedSchema = external_exports.object({
|
|
20440
20446
|
error: external_exports.literal("renewal_token_reused"),
|
|
@@ -20491,9 +20497,20 @@ var init_machine_identity = __esm({
|
|
|
20491
20497
|
machineSiblingsResponseSchema = external_exports.object({
|
|
20492
20498
|
machines: external_exports.array(machineSiblingSchema).max(MACHINE_SIBLINGS_LIMIT)
|
|
20493
20499
|
});
|
|
20500
|
+
runCodexCredentialSchema = external_exports.object({
|
|
20501
|
+
accessToken: external_exports.string().min(1),
|
|
20502
|
+
chatgptAccountId: external_exports.string().min(1),
|
|
20503
|
+
chatgptPlanType: external_exports.string().nullable()
|
|
20504
|
+
});
|
|
20505
|
+
runCodexCredentialRefreshRequestSchema = external_exports.object({
|
|
20506
|
+
/** sha256 hex of the access token Codex was refused with; a newer stored token is returned instead of rotating. */
|
|
20507
|
+
rejectedAccessTokenSha256: external_exports.string().regex(/^[0-9a-f]{64}$/).optional()
|
|
20508
|
+
});
|
|
20494
20509
|
runProviderCredentialSchema = external_exports.object({
|
|
20495
20510
|
/** Environment variables for the agent CLI, e.g. ANTHROPIC_API_KEY; empty when the CLI's own login is used. */
|
|
20496
|
-
env: external_exports.record(external_exports.string(), external_exports.string())
|
|
20511
|
+
env: external_exports.record(external_exports.string(), external_exports.string()),
|
|
20512
|
+
/** The team's Codex login for a cloud sandbox; absent where the CLI's own login is used. */
|
|
20513
|
+
codex: runCodexCredentialSchema.optional()
|
|
20497
20514
|
});
|
|
20498
20515
|
}
|
|
20499
20516
|
});
|
|
@@ -21349,11 +21366,12 @@ function isReadOnlyAgent(agentId) {
|
|
|
21349
21366
|
const agent = getBuiltinAgentDefinition(agentId);
|
|
21350
21367
|
return !agent.capabilities.canEditFiles;
|
|
21351
21368
|
}
|
|
21352
|
-
var COORDINATOR_PROMPT, PM_PROMPT, GENERAL_PROMPT, REVIEW_PROMPT, DESIGNER_PROMPT, BUILTIN_AGENT_DEFINITIONS, BUILTIN_AGENT_BY_ID, LEGACY_AGENT_ID_ALIASES;
|
|
21369
|
+
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
21370
|
var init_agent_definitions = __esm({
|
|
21354
21371
|
"../shared/dist/agent/agent-definitions.js"() {
|
|
21355
21372
|
"use strict";
|
|
21356
21373
|
init_task_duplicate();
|
|
21374
|
+
SETUP_AGENT_ID = "setup";
|
|
21357
21375
|
COORDINATOR_PROMPT = `## You are the Orchestrator
|
|
21358
21376
|
|
|
21359
21377
|
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 +21665,21 @@ For any UI or design work, read and follow the \`uiux\` skill in \`.agents/skill
|
|
|
21647
21665
|
canManageSubtasks: false
|
|
21648
21666
|
},
|
|
21649
21667
|
systemPrompt: DESIGNER_PROMPT
|
|
21668
|
+
},
|
|
21669
|
+
{
|
|
21670
|
+
id: SETUP_AGENT_ID,
|
|
21671
|
+
name: "Setup Agent",
|
|
21672
|
+
description: "Sets up and verifies cloud environments",
|
|
21673
|
+
iconKey: "hard-drive",
|
|
21674
|
+
defaultMode: "agent",
|
|
21675
|
+
capabilities: {
|
|
21676
|
+
canEditFiles: true,
|
|
21677
|
+
canRunCommands: true,
|
|
21678
|
+
canCreateArtifacts: true,
|
|
21679
|
+
canStartSessions: false,
|
|
21680
|
+
canManageSubtasks: false
|
|
21681
|
+
},
|
|
21682
|
+
systemPrompt: ""
|
|
21650
21683
|
}
|
|
21651
21684
|
];
|
|
21652
21685
|
BUILTIN_AGENT_BY_ID = new Map(BUILTIN_AGENT_DEFINITIONS.map((agent) => [agent.id, agent]));
|
|
@@ -21657,9 +21690,7 @@ For any UI or design work, read and follow the \`uiux\` skill in \`.agents/skill
|
|
|
21657
21690
|
implementer: "general",
|
|
21658
21691
|
implementor: "general",
|
|
21659
21692
|
"ui-designer": "designer",
|
|
21660
|
-
verifier: "general"
|
|
21661
|
-
// Former reserved Setup Agent profile \u2014 env setup is now a normal session kickoff.
|
|
21662
|
-
setup: "general"
|
|
21693
|
+
verifier: "general"
|
|
21663
21694
|
};
|
|
21664
21695
|
}
|
|
21665
21696
|
});
|
|
@@ -21679,21 +21710,9 @@ var init_browser_surface = __esm({
|
|
|
21679
21710
|
});
|
|
21680
21711
|
|
|
21681
21712
|
// ../shared/dist/agent/gated-mcp-tools.js
|
|
21682
|
-
var CODE_INDEX_MCP_TOOLS, CONTEXT_GRAPH_MCP_TOOLS, ENTITLEMENT_GATED_MCP_TOOLS;
|
|
21683
21713
|
var init_gated_mcp_tools = __esm({
|
|
21684
21714
|
"../shared/dist/agent/gated-mcp-tools.js"() {
|
|
21685
21715
|
"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
21716
|
}
|
|
21698
21717
|
});
|
|
21699
21718
|
|
|
@@ -22202,7 +22221,7 @@ var init_chunk_YXWJW7I5 = __esm({
|
|
|
22202
22221
|
}
|
|
22203
22222
|
});
|
|
22204
22223
|
|
|
22205
|
-
// ../agent-core/dist/chunk-
|
|
22224
|
+
// ../agent-core/dist/chunk-J4T6L5LX.js
|
|
22206
22225
|
function windowsEnvValue(env, name) {
|
|
22207
22226
|
const wanted = name.toLowerCase();
|
|
22208
22227
|
for (const [key, value] of Object.entries(env)) {
|
|
@@ -22373,7 +22392,7 @@ function plan(command, args, options) {
|
|
|
22373
22392
|
function captureOutput(command, args, options) {
|
|
22374
22393
|
const launch = plan(command, args, options);
|
|
22375
22394
|
if (launch === void 0) return Promise.resolve(NEVER_STARTED);
|
|
22376
|
-
return new Promise((
|
|
22395
|
+
return new Promise((resolve6) => {
|
|
22377
22396
|
(0, import_child_process.execFile)(
|
|
22378
22397
|
launch.file,
|
|
22379
22398
|
[...launch.args],
|
|
@@ -22387,7 +22406,7 @@ function captureOutput(command, args, options) {
|
|
|
22387
22406
|
},
|
|
22388
22407
|
(error61, stdout, stderr) => {
|
|
22389
22408
|
const code = error61 && typeof error61.code === "number" ? error61.code : error61 ? void 0 : 0;
|
|
22390
|
-
|
|
22409
|
+
resolve6({ stdout, stderr, exitCode: code });
|
|
22391
22410
|
}
|
|
22392
22411
|
);
|
|
22393
22412
|
});
|
|
@@ -22429,18 +22448,18 @@ function decode3(bytes, start, end) {
|
|
|
22429
22448
|
}
|
|
22430
22449
|
async function linuxStartTicks(pid) {
|
|
22431
22450
|
try {
|
|
22432
|
-
const
|
|
22433
|
-
const fields =
|
|
22451
|
+
const stat14 = await (0, import_promises5.readFile)(`/proc/${pid}/stat`, "utf8");
|
|
22452
|
+
const fields = stat14.slice(stat14.lastIndexOf(")") + 2).split(" ");
|
|
22434
22453
|
return fields[19];
|
|
22435
22454
|
} catch {
|
|
22436
22455
|
return void 0;
|
|
22437
22456
|
}
|
|
22438
22457
|
}
|
|
22439
22458
|
function psStartTime(pid) {
|
|
22440
|
-
return new Promise((
|
|
22459
|
+
return new Promise((resolve6) => {
|
|
22441
22460
|
(0, import_child_process2.execFile)("ps", ["-o", "lstart=", "-p", String(pid)], { timeout: 2e3 }, (error61, stdout) => {
|
|
22442
22461
|
const text2 = stdout.trim();
|
|
22443
|
-
|
|
22462
|
+
resolve6(error61 || !text2 ? void 0 : text2);
|
|
22444
22463
|
});
|
|
22445
22464
|
});
|
|
22446
22465
|
}
|
|
@@ -22469,12 +22488,12 @@ function parseProcessList(text2) {
|
|
|
22469
22488
|
}
|
|
22470
22489
|
function listProcesses(platform = process.platform) {
|
|
22471
22490
|
if (platform === "win32") return Promise.resolve([]);
|
|
22472
|
-
return new Promise((
|
|
22491
|
+
return new Promise((resolve6) => {
|
|
22473
22492
|
(0, import_child_process3.execFile)(
|
|
22474
22493
|
"ps",
|
|
22475
22494
|
["-A", "-o", "pid=,ppid=,pgid=,lstart="],
|
|
22476
22495
|
{ timeout: 5e3, maxBuffer: 8 * 1024 * 1024 },
|
|
22477
|
-
(error61, stdout) =>
|
|
22496
|
+
(error61, stdout) => resolve6(error61 ? [] : parseProcessList(stdout))
|
|
22478
22497
|
);
|
|
22479
22498
|
});
|
|
22480
22499
|
}
|
|
@@ -22514,11 +22533,11 @@ async function taskkill(pid, options) {
|
|
|
22514
22533
|
stdio: "ignore",
|
|
22515
22534
|
windowsHide: true
|
|
22516
22535
|
});
|
|
22517
|
-
const exited = new Promise((
|
|
22518
|
-
killer.once("error", (error210) =>
|
|
22536
|
+
const exited = new Promise((resolve6) => {
|
|
22537
|
+
killer.once("error", (error210) => resolve6(error210));
|
|
22519
22538
|
killer.once(
|
|
22520
22539
|
"exit",
|
|
22521
|
-
(code, signal) =>
|
|
22540
|
+
(code, signal) => resolve6(code === 0 ? void 0 : new Error(`taskkill failed: exit ${code}, signal ${signal}`))
|
|
22522
22541
|
);
|
|
22523
22542
|
});
|
|
22524
22543
|
const timedOut = clock.sleep(options.timeoutMs ?? DEFAULT_TASKKILL_TIMEOUT_MS, timeout.signal).then(() => new Error("taskkill timed out")).catch(() => void 0);
|
|
@@ -22748,25 +22767,35 @@ async function waitForWindowsJob(child, command) {
|
|
|
22748
22767
|
await (0, import_promises6.rm)(status.directory, { recursive: true, force: true });
|
|
22749
22768
|
}
|
|
22750
22769
|
}
|
|
22770
|
+
function onCliSpawned(listener) {
|
|
22771
|
+
spawnListeners.add(listener);
|
|
22772
|
+
return {
|
|
22773
|
+
[Symbol.dispose]: () => {
|
|
22774
|
+
spawnListeners.delete(listener);
|
|
22775
|
+
}
|
|
22776
|
+
};
|
|
22777
|
+
}
|
|
22751
22778
|
function spawnCli(options) {
|
|
22752
22779
|
const platform = options.platform ?? process.platform;
|
|
22753
22780
|
const plan2 = planSpawn({ ...options, platform });
|
|
22754
22781
|
if (plan2.commandLine !== null) return spawnInWindowsJob(plan2, options);
|
|
22755
|
-
|
|
22782
|
+
const child = (0, import_child_process5.spawn)(plan2.file, [...plan2.args], {
|
|
22756
22783
|
cwd: options.cwd,
|
|
22757
22784
|
env: { ...options.env },
|
|
22758
22785
|
stdio: ["pipe", "pipe", "pipe"],
|
|
22759
22786
|
shell: false,
|
|
22760
22787
|
detached: true
|
|
22761
22788
|
});
|
|
22789
|
+
for (const listener of spawnListeners) listener(child);
|
|
22790
|
+
return child;
|
|
22762
22791
|
}
|
|
22763
22792
|
function waitForSpawn(child, command) {
|
|
22764
22793
|
if (isWindowsJob(child)) return waitForWindowsJob(child, command);
|
|
22765
22794
|
if (child.pid !== void 0) return Promise.resolve();
|
|
22766
|
-
return new Promise((
|
|
22795
|
+
return new Promise((resolve6, reject) => {
|
|
22767
22796
|
const onSpawn = () => {
|
|
22768
22797
|
child.off("error", onError);
|
|
22769
|
-
|
|
22798
|
+
resolve6();
|
|
22770
22799
|
};
|
|
22771
22800
|
const onError = (error61) => {
|
|
22772
22801
|
child.off("spawn", onSpawn);
|
|
@@ -22779,9 +22808,9 @@ function waitForSpawn(child, command) {
|
|
|
22779
22808
|
child.once("error", onError);
|
|
22780
22809
|
});
|
|
22781
22810
|
}
|
|
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-
|
|
22811
|
+
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;
|
|
22812
|
+
var init_chunk_J4T6L5LX = __esm({
|
|
22813
|
+
"../agent-core/dist/chunk-J4T6L5LX.js"() {
|
|
22785
22814
|
"use strict";
|
|
22786
22815
|
init_chunk_YXWJW7I5();
|
|
22787
22816
|
import_child_process = require("child_process");
|
|
@@ -22870,6 +22899,7 @@ var init_chunk_6GPS6OKU = __esm({
|
|
|
22870
22899
|
DEFAULT_TASKKILL_TIMEOUT_MS = 5e3;
|
|
22871
22900
|
statuses = /* @__PURE__ */ new WeakMap();
|
|
22872
22901
|
START_TIMEOUT_MS = 1e4;
|
|
22902
|
+
spawnListeners = /* @__PURE__ */ new Set();
|
|
22873
22903
|
}
|
|
22874
22904
|
});
|
|
22875
22905
|
|
|
@@ -23575,26 +23605,26 @@ var init_constants = __esm({
|
|
|
23575
23605
|
}
|
|
23576
23606
|
});
|
|
23577
23607
|
|
|
23578
|
-
// ../shared/dist/agent/acp/
|
|
23579
|
-
var
|
|
23580
|
-
|
|
23581
|
-
"../shared/dist/agent/acp/background-task.js"() {
|
|
23608
|
+
// ../shared/dist/agent/acp/transcript-http.js
|
|
23609
|
+
var init_transcript_http = __esm({
|
|
23610
|
+
"../shared/dist/agent/acp/transcript-http.js"() {
|
|
23582
23611
|
"use strict";
|
|
23583
|
-
BACKGROUND_TASK_META_KEY = "alan.dev/backgroundTask";
|
|
23584
23612
|
}
|
|
23585
23613
|
});
|
|
23586
23614
|
|
|
23587
|
-
// ../shared/dist/agent/acp/
|
|
23588
|
-
var
|
|
23589
|
-
"../shared/dist/agent/acp/
|
|
23615
|
+
// ../shared/dist/agent/acp/ask.js
|
|
23616
|
+
var init_ask = __esm({
|
|
23617
|
+
"../shared/dist/agent/acp/ask.js"() {
|
|
23590
23618
|
"use strict";
|
|
23591
23619
|
}
|
|
23592
23620
|
});
|
|
23593
23621
|
|
|
23594
|
-
// ../shared/dist/agent/acp/
|
|
23595
|
-
var
|
|
23596
|
-
|
|
23622
|
+
// ../shared/dist/agent/acp/background-task.js
|
|
23623
|
+
var BACKGROUND_TASK_META_KEY;
|
|
23624
|
+
var init_background_task = __esm({
|
|
23625
|
+
"../shared/dist/agent/acp/background-task.js"() {
|
|
23597
23626
|
"use strict";
|
|
23627
|
+
BACKGROUND_TASK_META_KEY = "alan.dev/backgroundTask";
|
|
23598
23628
|
}
|
|
23599
23629
|
});
|
|
23600
23630
|
|
|
@@ -23626,9 +23656,9 @@ var init_prepare_conversation_turns = __esm({
|
|
|
23626
23656
|
}
|
|
23627
23657
|
});
|
|
23628
23658
|
|
|
23629
|
-
// ../shared/dist/agent/acp/
|
|
23630
|
-
var
|
|
23631
|
-
"../shared/dist/agent/acp/
|
|
23659
|
+
// ../shared/dist/agent/acp/event.js
|
|
23660
|
+
var init_event = __esm({
|
|
23661
|
+
"../shared/dist/agent/acp/event.js"() {
|
|
23632
23662
|
"use strict";
|
|
23633
23663
|
}
|
|
23634
23664
|
});
|
|
@@ -23637,7 +23667,7 @@ var init_types2 = __esm({
|
|
|
23637
23667
|
function isUpdate(update, kind) {
|
|
23638
23668
|
return update.sessionUpdate === kind;
|
|
23639
23669
|
}
|
|
23640
|
-
var
|
|
23670
|
+
var init_types2 = __esm({
|
|
23641
23671
|
"../shared/dist/agent/acp/types.js"() {
|
|
23642
23672
|
"use strict";
|
|
23643
23673
|
}
|
|
@@ -23650,6 +23680,20 @@ var init_reduce = __esm({
|
|
|
23650
23680
|
}
|
|
23651
23681
|
});
|
|
23652
23682
|
|
|
23683
|
+
// ../shared/dist/agent/acp/conversation-messages.js
|
|
23684
|
+
var init_conversation_messages = __esm({
|
|
23685
|
+
"../shared/dist/agent/acp/conversation-messages.js"() {
|
|
23686
|
+
"use strict";
|
|
23687
|
+
}
|
|
23688
|
+
});
|
|
23689
|
+
|
|
23690
|
+
// ../shared/dist/agent/acp/presentation/types.js
|
|
23691
|
+
var init_types3 = __esm({
|
|
23692
|
+
"../shared/dist/agent/acp/presentation/types.js"() {
|
|
23693
|
+
"use strict";
|
|
23694
|
+
}
|
|
23695
|
+
});
|
|
23696
|
+
|
|
23653
23697
|
// ../shared/dist/agent/acp/read.js
|
|
23654
23698
|
var init_read = __esm({
|
|
23655
23699
|
"../shared/dist/agent/acp/read.js"() {
|
|
@@ -23664,13 +23708,6 @@ var init_transcript_byte_decoder = __esm({
|
|
|
23664
23708
|
}
|
|
23665
23709
|
});
|
|
23666
23710
|
|
|
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
23711
|
// ../shared/dist/agent/acp/transcript-fold.js
|
|
23675
23712
|
var init_transcript_fold = __esm({
|
|
23676
23713
|
"../shared/dist/agent/acp/transcript-fold.js"() {
|
|
@@ -23691,6 +23728,7 @@ var init_transcript_live = __esm({
|
|
|
23691
23728
|
var init_acp = __esm({
|
|
23692
23729
|
"../shared/dist/agent/acp/index.js"() {
|
|
23693
23730
|
"use strict";
|
|
23731
|
+
init_ask();
|
|
23694
23732
|
init_background_task();
|
|
23695
23733
|
init_conversation_messages();
|
|
23696
23734
|
init_event();
|
|
@@ -23698,7 +23736,7 @@ var init_acp = __esm({
|
|
|
23698
23736
|
init_notice_visibility();
|
|
23699
23737
|
init_prepare_conversation_turns();
|
|
23700
23738
|
init_terminal_events();
|
|
23701
|
-
|
|
23739
|
+
init_types3();
|
|
23702
23740
|
init_read();
|
|
23703
23741
|
init_reduce();
|
|
23704
23742
|
init_transcript_byte_decoder();
|
|
@@ -23706,7 +23744,7 @@ var init_acp = __esm({
|
|
|
23706
23744
|
init_transcript_http();
|
|
23707
23745
|
init_transcript_ingestion();
|
|
23708
23746
|
init_transcript_live();
|
|
23709
|
-
|
|
23747
|
+
init_types2();
|
|
23710
23748
|
}
|
|
23711
23749
|
});
|
|
23712
23750
|
|
|
@@ -24078,11 +24116,20 @@ var init_chunk_DALFHI4B = __esm({
|
|
|
24078
24116
|
}
|
|
24079
24117
|
});
|
|
24080
24118
|
|
|
24081
|
-
// ../agent-core/dist/chunk-
|
|
24119
|
+
// ../agent-core/dist/chunk-54ZRJOQP.js
|
|
24082
24120
|
function specForErrorKind(errorKind) {
|
|
24083
24121
|
const spec = ERROR_SPECS[errorKind];
|
|
24084
24122
|
return { message: spec.message, errorKind, recoveryClass: spec.recoveryClass };
|
|
24085
24123
|
}
|
|
24124
|
+
function withAgentSignIn(classified, harness) {
|
|
24125
|
+
const agent = AGENT_SIGN_IN_BY_HARNESS.get(harness);
|
|
24126
|
+
if (!agent || classified.message !== ERROR_SPECS.not_logged_in.message) return classified;
|
|
24127
|
+
const local = agent.localSignIn ?? "sign in to it";
|
|
24128
|
+
return {
|
|
24129
|
+
...classified,
|
|
24130
|
+
message: `${agent.name} isn't signed in: for cloud runs connect it in Team settings \u2192 Integrations \u2192 Coding agents; on your computer ${local}; then retry.`
|
|
24131
|
+
};
|
|
24132
|
+
}
|
|
24086
24133
|
function embeddedJson(text2) {
|
|
24087
24134
|
const start = text2.indexOf("{");
|
|
24088
24135
|
if (start === -1) return void 0;
|
|
@@ -24192,6 +24239,7 @@ function statusKind(status) {
|
|
|
24192
24239
|
}
|
|
24193
24240
|
function mapProviderApiError(errorCode, apiStatus) {
|
|
24194
24241
|
if (apiStatus === 403) return "access_denied";
|
|
24242
|
+
if (apiStatus === 402) return "payment_required";
|
|
24195
24243
|
if (apiStatus === 401) return "auth_invalid";
|
|
24196
24244
|
const code = errorCode?.trim().toLowerCase();
|
|
24197
24245
|
const byCode = code ? CODE_RULES.find((rule) => rule.pattern.test(code))?.kind : void 0;
|
|
@@ -24205,6 +24253,11 @@ function classifyProviderApiError(input2) {
|
|
|
24205
24253
|
if (fromText && TEXT_REFINES[structured]?.has(fromText.errorKind)) return fromText;
|
|
24206
24254
|
return specForErrorKind(structured);
|
|
24207
24255
|
}
|
|
24256
|
+
function withPaymentRemedy(classified, message) {
|
|
24257
|
+
if (classified.errorKind !== "payment_required") return classified;
|
|
24258
|
+
const remedy = message.replace(STATUS_LEAD, "").trim();
|
|
24259
|
+
return remedy ? { ...classified, message: remedy.slice(0, 300) } : classified;
|
|
24260
|
+
}
|
|
24208
24261
|
function classifyProviderError(text2, hints = {}) {
|
|
24209
24262
|
const detail = readProviderErrorDetail(text2);
|
|
24210
24263
|
const errorCode = hints.errorCode ?? detail.type;
|
|
@@ -24214,7 +24267,7 @@ function classifyProviderError(text2, hints = {}) {
|
|
|
24214
24267
|
...status === void 0 ? {} : { status },
|
|
24215
24268
|
text: detail.message
|
|
24216
24269
|
}) ?? classifyProviderTerminalText(text2);
|
|
24217
|
-
if (classified) return classified;
|
|
24270
|
+
if (classified) return withPaymentRemedy(classified, detail.message);
|
|
24218
24271
|
const message = detail.message.slice(0, 200);
|
|
24219
24272
|
return message ? { message, errorKind: "unknown_cli_error", recoveryClass: "unknown" } : specForErrorKind("unknown_cli_error");
|
|
24220
24273
|
}
|
|
@@ -24235,7 +24288,8 @@ function retryOwnerFor(classified, harnessOwnsRetry, safe) {
|
|
|
24235
24288
|
if (!safe) return "none";
|
|
24236
24289
|
return classified.errorKind === "resume_failed" || classified.errorKind === "history_rejected" ? "alan_resume" : "user_confirmed_fresh_run";
|
|
24237
24290
|
}
|
|
24238
|
-
function createCliProblem(
|
|
24291
|
+
function createCliProblem(observed, options) {
|
|
24292
|
+
const classified = withAgentSignIn(observed, options.harness);
|
|
24239
24293
|
const automatic = classified.recoveryClass === "auto_recovering";
|
|
24240
24294
|
const harnessOwnsRetry = options.finality === "observation" && automatic;
|
|
24241
24295
|
const safe = options.outcomeCertainty === "no_effect" || harnessOwnsRetry;
|
|
@@ -24265,9 +24319,9 @@ function createCliProblem(classified, options) {
|
|
|
24265
24319
|
...classified.resetsAt ? { resetsAt: classified.resetsAt } : {}
|
|
24266
24320
|
});
|
|
24267
24321
|
}
|
|
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-
|
|
24322
|
+
var import_crypto2, ERROR_SPECS, AGENT_ERROR_KINDS, AGENT_SIGN_IN_BY_HARNESS, 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;
|
|
24323
|
+
var init_chunk_54ZRJOQP = __esm({
|
|
24324
|
+
"../agent-core/dist/chunk-54ZRJOQP.js"() {
|
|
24271
24325
|
"use strict";
|
|
24272
24326
|
init_chunk_YXWJW7I5();
|
|
24273
24327
|
import_crypto2 = require("crypto");
|
|
@@ -24286,7 +24340,7 @@ var init_chunk_BR4I6MQF = __esm({
|
|
|
24286
24340
|
recoveryClass: "user_fixable"
|
|
24287
24341
|
},
|
|
24288
24342
|
not_logged_in: {
|
|
24289
|
-
message: "
|
|
24343
|
+
message: "The agent CLI isn't signed in: for cloud runs connect it in Team settings \u2192 Integrations \u2192 Coding agents; on your computer sign in to the CLI; then retry.",
|
|
24290
24344
|
recoveryClass: "user_fixable"
|
|
24291
24345
|
},
|
|
24292
24346
|
not_authenticated: {
|
|
@@ -24301,6 +24355,10 @@ var init_chunk_BR4I6MQF = __esm({
|
|
|
24301
24355
|
message: "This model requires a paid subscription. Switch to a supported model or upgrade your plan.",
|
|
24302
24356
|
recoveryClass: "user_fixable"
|
|
24303
24357
|
},
|
|
24358
|
+
payment_required: {
|
|
24359
|
+
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.",
|
|
24360
|
+
recoveryClass: "user_fixable"
|
|
24361
|
+
},
|
|
24304
24362
|
quota_exceeded: {
|
|
24305
24363
|
message: "API quota exceeded. Wait for it to reset or check your billing, then retry.",
|
|
24306
24364
|
recoveryClass: "user_fixable"
|
|
@@ -24373,6 +24431,19 @@ var init_chunk_BR4I6MQF = __esm({
|
|
|
24373
24431
|
AGENT_ERROR_KINDS = Object.keys(ERROR_SPECS).filter(
|
|
24374
24432
|
(key) => key in ERROR_SPECS
|
|
24375
24433
|
);
|
|
24434
|
+
AGENT_SIGN_IN_BY_HARNESS = /* @__PURE__ */ new Map([
|
|
24435
|
+
["claude_cli", { name: "Claude Code", localSignIn: "run `claude` then `/login`" }],
|
|
24436
|
+
["codex_app_server", { name: "Codex", localSignIn: "run `codex login`" }],
|
|
24437
|
+
["codex_exec", { name: "Codex", localSignIn: "run `codex login`" }],
|
|
24438
|
+
["cursor_agent_cli", { name: "Cursor Agent", localSignIn: "run `cursor-agent login`" }],
|
|
24439
|
+
["copilot_cli", { name: "GitHub Copilot CLI", localSignIn: "run `copilot` then `/login`" }],
|
|
24440
|
+
["opencode_serve", { name: "OpenCode", localSignIn: "run `opencode auth login`" }],
|
|
24441
|
+
["droid_cli", { name: "Droid" }],
|
|
24442
|
+
["antigravity_cli", { name: "Antigravity" }],
|
|
24443
|
+
["grok_cli", { name: "Grok CLI" }],
|
|
24444
|
+
["kimi_cli", { name: "Kimi CLI" }],
|
|
24445
|
+
["command_code_cli", { name: "Command Code" }]
|
|
24446
|
+
]);
|
|
24376
24447
|
STATUS_PREFIX = /\b(?:api error|status|http)[:\s]+(\d{3})\b/i;
|
|
24377
24448
|
TEXT_RULES = [
|
|
24378
24449
|
{ kind: "auth_expired", pattern: /\bcodex cli connection expired\b|\breconnect openai codex\b/ },
|
|
@@ -24477,6 +24548,7 @@ var init_chunk_BR4I6MQF = __esm({
|
|
|
24477
24548
|
rate_limited: /* @__PURE__ */ new Set(["usage_limit", "quota_exceeded"]),
|
|
24478
24549
|
auth_invalid: /* @__PURE__ */ new Set(["auth_expired", "not_logged_in", "not_authenticated"])
|
|
24479
24550
|
};
|
|
24551
|
+
STATUS_LEAD = /^(?:api error|status|http)[:\s]+\d{3}\b[:\s]*/i;
|
|
24480
24552
|
CLI_PROBLEM_CODE_BY_ERROR_KIND = {
|
|
24481
24553
|
model_mismatch: "cli.model.unavailable",
|
|
24482
24554
|
auth_invalid: "cli.auth.invalid",
|
|
@@ -24485,6 +24557,7 @@ var init_chunk_BR4I6MQF = __esm({
|
|
|
24485
24557
|
not_authenticated: "cli.auth.invalid",
|
|
24486
24558
|
auth_expired: "cli.auth.expired",
|
|
24487
24559
|
subscription_required: "cli.entitlement.required",
|
|
24560
|
+
payment_required: "cli.entitlement.required",
|
|
24488
24561
|
quota_exceeded: "cli.quota_exceeded",
|
|
24489
24562
|
usage_limit: "cli.quota_exceeded",
|
|
24490
24563
|
context_length: "cli.context_exhausted",
|
|
@@ -24511,7 +24584,7 @@ var init_chunk_BR4I6MQF = __esm({
|
|
|
24511
24584
|
}
|
|
24512
24585
|
});
|
|
24513
24586
|
|
|
24514
|
-
// ../agent-core/dist/chunk-
|
|
24587
|
+
// ../agent-core/dist/chunk-YPYC4VBL.js
|
|
24515
24588
|
function collectStrings(value, out) {
|
|
24516
24589
|
if (typeof value === "string") out.push(value);
|
|
24517
24590
|
else if (Array.isArray(value)) for (const item of value) collectStrings(item, out);
|
|
@@ -24603,8 +24676,8 @@ function readMediaFiles(candidates2, cwd, mimeByExt, maxBytes) {
|
|
|
24603
24676
|
seen.add(path);
|
|
24604
24677
|
const mimeType = mimeByExt[(0, import_path3.extname)(path).toLowerCase()];
|
|
24605
24678
|
if (!mimeType) continue;
|
|
24606
|
-
const
|
|
24607
|
-
if (!
|
|
24679
|
+
const stat14 = (0, import_fs4.statSync)(path);
|
|
24680
|
+
if (!stat14.isFile() || stat14.size <= 0 || stat14.size > maxBytes) continue;
|
|
24608
24681
|
files.push({ path, mimeType, buffer: (0, import_fs4.readFileSync)(path) });
|
|
24609
24682
|
}
|
|
24610
24683
|
return files;
|
|
@@ -24679,8 +24752,8 @@ function createJsonRpcPeer(writer, handlers) {
|
|
|
24679
24752
|
},
|
|
24680
24753
|
request: (method, params = {}) => {
|
|
24681
24754
|
const id = counter.next++;
|
|
24682
|
-
return new Promise((
|
|
24683
|
-
pending.set(id, { method, resolve:
|
|
24755
|
+
return new Promise((resolve6, reject) => {
|
|
24756
|
+
pending.set(id, { method, resolve: resolve6, reject });
|
|
24684
24757
|
writer.write({ id, method, params }).catch((error61) => {
|
|
24685
24758
|
pending.delete(id);
|
|
24686
24759
|
reject(error61 instanceof Error ? error61 : new Error(String(error61)));
|
|
@@ -24793,7 +24866,7 @@ function createNdjsonWriter(stream) {
|
|
|
24793
24866
|
get writable() {
|
|
24794
24867
|
return stream.writable && !stream.destroyed && failure5.error === void 0;
|
|
24795
24868
|
},
|
|
24796
|
-
write: (value) => new Promise((
|
|
24869
|
+
write: (value) => new Promise((resolve6, reject) => {
|
|
24797
24870
|
if (failure5.error) {
|
|
24798
24871
|
reject(failure5.error);
|
|
24799
24872
|
return;
|
|
@@ -24805,7 +24878,7 @@ function createNdjsonWriter(stream) {
|
|
|
24805
24878
|
stream.write(`${JSON.stringify(value)}
|
|
24806
24879
|
`, (error61) => {
|
|
24807
24880
|
if (error61) reject(error61);
|
|
24808
|
-
else
|
|
24881
|
+
else resolve6();
|
|
24809
24882
|
});
|
|
24810
24883
|
}),
|
|
24811
24884
|
end: () => {
|
|
@@ -24821,11 +24894,11 @@ function hostProcess(child, tree, options, handlers) {
|
|
|
24821
24894
|
const stderr = new LineSplitter((line) => handlers.onStderrLine(line));
|
|
24822
24895
|
child.stderr.on("data", (chunk) => stderr.push(chunk));
|
|
24823
24896
|
child.stderr.once("end", () => stderr.flush());
|
|
24824
|
-
const processExit = new Promise((
|
|
24825
|
-
child.once("exit", (code, signal) =>
|
|
24897
|
+
const processExit = new Promise((resolve6) => {
|
|
24898
|
+
child.once("exit", (code, signal) => resolve6({ code, signal }));
|
|
24826
24899
|
});
|
|
24827
|
-
const outputEnded = new Promise((
|
|
24828
|
-
child.stdout.once("close", () =>
|
|
24900
|
+
const outputEnded = new Promise((resolve6) => {
|
|
24901
|
+
child.stdout.once("close", () => resolve6());
|
|
24829
24902
|
});
|
|
24830
24903
|
const watch = async () => {
|
|
24831
24904
|
const { clock, stdoutDrainMs, log, name } = options;
|
|
@@ -24881,12 +24954,12 @@ function silentStartError(name, timeoutMs) {
|
|
|
24881
24954
|
};
|
|
24882
24955
|
}
|
|
24883
24956
|
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-
|
|
24957
|
+
var init_chunk_YPYC4VBL = __esm({
|
|
24958
|
+
"../agent-core/dist/chunk-YPYC4VBL.js"() {
|
|
24886
24959
|
"use strict";
|
|
24887
24960
|
init_chunk_UGRKZTAD();
|
|
24888
|
-
|
|
24889
|
-
|
|
24961
|
+
init_chunk_54ZRJOQP();
|
|
24962
|
+
init_chunk_J4T6L5LX();
|
|
24890
24963
|
init_chunk_YXWJW7I5();
|
|
24891
24964
|
import_crypto3 = require("crypto");
|
|
24892
24965
|
import_fs4 = require("fs");
|
|
@@ -25114,13 +25187,13 @@ var init_chunk_UKUTSW3L = __esm({
|
|
|
25114
25187
|
const turnId = input2.turnId;
|
|
25115
25188
|
let finish = () => {
|
|
25116
25189
|
};
|
|
25117
|
-
const done = new Promise((
|
|
25190
|
+
const done = new Promise((resolve6) => {
|
|
25118
25191
|
finish = (outcome2) => {
|
|
25119
25192
|
if (this.#current?.id !== turnId) return;
|
|
25120
25193
|
this.#current = void 0;
|
|
25121
25194
|
if (this.#state === "busy") this.#state = "idle";
|
|
25122
25195
|
this.#emit({ type: "turn_ended", turnId, outcome: outcome2 });
|
|
25123
|
-
|
|
25196
|
+
resolve6({ turnId, outcome: outcome2, providerSessionId: this.#sessionId });
|
|
25124
25197
|
};
|
|
25125
25198
|
});
|
|
25126
25199
|
const pending = {
|
|
@@ -25316,20 +25389,20 @@ function canonicalizeManagedMcpToolName(toolName) {
|
|
|
25316
25389
|
return flattened ? `mcp__${MANAGED_MCP_SERVER_NAME}__${flattened[1]}` : toolName;
|
|
25317
25390
|
}
|
|
25318
25391
|
async function writeSecretFile(name, contents) {
|
|
25319
|
-
const dir = await (0,
|
|
25392
|
+
const dir = await (0, import_promises13.mkdtemp)((0, import_path4.join)((0, import_os2.tmpdir)(), "alan-mcp-"));
|
|
25320
25393
|
const path = (0, import_path4.join)(dir, name);
|
|
25321
25394
|
const remove = async () => {
|
|
25322
|
-
await (0,
|
|
25395
|
+
await (0, import_promises13.rm)(dir, { recursive: true, force: true });
|
|
25323
25396
|
};
|
|
25324
25397
|
try {
|
|
25325
|
-
await (0,
|
|
25398
|
+
await (0, import_promises13.writeFile)(path, contents, { mode: 384, flag: "wx" });
|
|
25326
25399
|
} catch (error61) {
|
|
25327
25400
|
await remove();
|
|
25328
25401
|
throw error61;
|
|
25329
25402
|
}
|
|
25330
25403
|
return { path, remove, [Symbol.asyncDispose]: remove };
|
|
25331
25404
|
}
|
|
25332
|
-
var import_crypto4, import_crypto5,
|
|
25405
|
+
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
25406
|
var init_chunk_J2KTV5FP = __esm({
|
|
25334
25407
|
"../agent-core/dist/chunk-J2KTV5FP.js"() {
|
|
25335
25408
|
"use strict";
|
|
@@ -25338,7 +25411,7 @@ var init_chunk_J2KTV5FP = __esm({
|
|
|
25338
25411
|
import_crypto5 = require("crypto");
|
|
25339
25412
|
init_agent2();
|
|
25340
25413
|
init_runtime_v2();
|
|
25341
|
-
|
|
25414
|
+
import_promises13 = require("fs/promises");
|
|
25342
25415
|
import_os2 = require("os");
|
|
25343
25416
|
import_path4 = require("path");
|
|
25344
25417
|
MANAGED_MCP_SERVER_NAME = "alan";
|
|
@@ -26253,9 +26326,12 @@ function resultMessageId(state) {
|
|
|
26253
26326
|
state.resultMessageId ??= synthId(state, "claude-result");
|
|
26254
26327
|
return state.resultMessageId;
|
|
26255
26328
|
}
|
|
26329
|
+
function isErrorResult(event) {
|
|
26330
|
+
return asString(event.subtype).startsWith("error") || event.is_error === true || event.terminal_reason === "api_error" || typeof event.api_error_status === "number";
|
|
26331
|
+
}
|
|
26256
26332
|
function parseResult(event, state) {
|
|
26257
26333
|
const stopReason = stopReasonFor(asString(event.stop_reason), event.is_error === true);
|
|
26258
|
-
const resultText2 = asString(event.result);
|
|
26334
|
+
const resultText2 = isErrorResult(event) ? "" : asString(event.result);
|
|
26259
26335
|
const updates = [];
|
|
26260
26336
|
const streamed = state.lastForegroundText;
|
|
26261
26337
|
if (resultText2) {
|
|
@@ -26736,21 +26812,21 @@ async function claudeTurnInput(run, context) {
|
|
|
26736
26812
|
const encoded = await Promise.all(
|
|
26737
26813
|
images.map(async (image) => ({
|
|
26738
26814
|
mimeType: image.mimeType,
|
|
26739
|
-
data: (await (0,
|
|
26815
|
+
data: (await (0, import_promises14.readFile)(image.path)).toString("base64")
|
|
26740
26816
|
}))
|
|
26741
26817
|
);
|
|
26742
26818
|
return { turnId: run.runId, text: text2, ...encoded.length ? { images: encoded } : {} };
|
|
26743
26819
|
}
|
|
26744
|
-
var import_crypto6, import_fs5, import_path5, import_crypto7,
|
|
26820
|
+
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
26821
|
var init_claude = __esm({
|
|
26746
26822
|
"../agent-core/dist/providers/claude.js"() {
|
|
26747
26823
|
"use strict";
|
|
26748
26824
|
init_chunk_DALFHI4B();
|
|
26749
|
-
|
|
26825
|
+
init_chunk_YPYC4VBL();
|
|
26750
26826
|
init_chunk_UGRKZTAD();
|
|
26751
|
-
|
|
26827
|
+
init_chunk_54ZRJOQP();
|
|
26752
26828
|
init_chunk_J2KTV5FP();
|
|
26753
|
-
|
|
26829
|
+
init_chunk_J4T6L5LX();
|
|
26754
26830
|
init_chunk_6WN2R725();
|
|
26755
26831
|
init_chunk_YXWJW7I5();
|
|
26756
26832
|
init_effort();
|
|
@@ -26764,7 +26840,7 @@ var init_claude = __esm({
|
|
|
26764
26840
|
import_fs5 = require("fs");
|
|
26765
26841
|
import_path5 = require("path");
|
|
26766
26842
|
import_crypto7 = require("crypto");
|
|
26767
|
-
|
|
26843
|
+
import_promises14 = require("fs/promises");
|
|
26768
26844
|
init_agent2();
|
|
26769
26845
|
EDIT_TOOLS = /* @__PURE__ */ new Set([
|
|
26770
26846
|
"Edit",
|
|
@@ -27463,8 +27539,8 @@ var init_claude = __esm({
|
|
|
27463
27539
|
}
|
|
27464
27540
|
async #awaitTaskStop(requestId, taskId) {
|
|
27465
27541
|
const timer = new AbortController();
|
|
27466
|
-
const answered = new Promise((
|
|
27467
|
-
this.#taskStops.set(requestId,
|
|
27542
|
+
const answered = new Promise((resolve6) => {
|
|
27543
|
+
this.#taskStops.set(requestId, resolve6);
|
|
27468
27544
|
});
|
|
27469
27545
|
const timeoutMs = this.#options.stopTaskTimeoutMs;
|
|
27470
27546
|
const timedOut = this.#options.clock.sleep(timeoutMs, timer.signal).then(
|
|
@@ -27537,17 +27613,17 @@ var init_claude = __esm({
|
|
|
27537
27613
|
};
|
|
27538
27614
|
let markStarted = () => {
|
|
27539
27615
|
};
|
|
27540
|
-
const whenStarted = new Promise((
|
|
27541
|
-
markStarted =
|
|
27616
|
+
const whenStarted = new Promise((resolve6) => {
|
|
27617
|
+
markStarted = resolve6;
|
|
27542
27618
|
});
|
|
27543
|
-
const done = new Promise((
|
|
27619
|
+
const done = new Promise((resolve6) => {
|
|
27544
27620
|
finish = (outcome2) => {
|
|
27545
27621
|
if (this.#current?.id !== id) return;
|
|
27546
27622
|
this.#current = void 0;
|
|
27547
27623
|
this.#lastTurn = turn;
|
|
27548
27624
|
if (this.#state === "busy") this.#state = "idle";
|
|
27549
27625
|
this.#emit({ type: "turn_ended", turnId: id, outcome: outcome2 });
|
|
27550
|
-
|
|
27626
|
+
resolve6({ turnId: id, outcome: outcome2, providerSessionId: this.#providerSessionId });
|
|
27551
27627
|
};
|
|
27552
27628
|
});
|
|
27553
27629
|
const active = {
|
|
@@ -27665,8 +27741,8 @@ var init_claude = __esm({
|
|
|
27665
27741
|
void removeLaunchFiles(this.#launchFiles).catch((error61) => {
|
|
27666
27742
|
this.#options.log.warn("claude.launch_files_cleanup_failed", { error: error61 });
|
|
27667
27743
|
});
|
|
27668
|
-
for (const
|
|
27669
|
-
|
|
27744
|
+
for (const resolve6 of this.#taskStops.values()) {
|
|
27745
|
+
resolve6({ ok: false, reason: "runtime_unavailable", message: "Claude Code exited." });
|
|
27670
27746
|
}
|
|
27671
27747
|
const active = this.#current;
|
|
27672
27748
|
if (active) {
|
|
@@ -28514,11 +28590,12 @@ async function withDeadline(work, clock, ms, what) {
|
|
|
28514
28590
|
`codex app-server did not answer ${what} within ${ms} ms`
|
|
28515
28591
|
);
|
|
28516
28592
|
}
|
|
28517
|
-
async function handshake(session, log) {
|
|
28593
|
+
async function handshake(session, spec, log) {
|
|
28594
|
+
const experimentalApi = spec.externalAuth !== void 0;
|
|
28518
28595
|
const init = asRecord(
|
|
28519
28596
|
await session.rpc.request("initialize", {
|
|
28520
28597
|
clientInfo: CLIENT_INFO,
|
|
28521
|
-
capabilities: { experimentalApi
|
|
28598
|
+
capabilities: { experimentalApi, requestAttestation: false }
|
|
28522
28599
|
})
|
|
28523
28600
|
);
|
|
28524
28601
|
const userAgent = asString(init?.userAgent);
|
|
@@ -28611,7 +28688,7 @@ function createCodexDriver(options = {}) {
|
|
|
28611
28688
|
await started;
|
|
28612
28689
|
try {
|
|
28613
28690
|
const opening = (async () => {
|
|
28614
|
-
await handshake(session, resolved.log);
|
|
28691
|
+
await handshake(session, spec, resolved.log);
|
|
28615
28692
|
await preflight(session, spec);
|
|
28616
28693
|
return openThread(session, spec, resolved.log);
|
|
28617
28694
|
})();
|
|
@@ -28878,11 +28955,11 @@ var init_codex = __esm({
|
|
|
28878
28955
|
"../agent-core/dist/providers/codex.js"() {
|
|
28879
28956
|
"use strict";
|
|
28880
28957
|
init_chunk_DALFHI4B();
|
|
28881
|
-
|
|
28958
|
+
init_chunk_YPYC4VBL();
|
|
28882
28959
|
init_chunk_UGRKZTAD();
|
|
28883
|
-
|
|
28960
|
+
init_chunk_54ZRJOQP();
|
|
28884
28961
|
init_chunk_J2KTV5FP();
|
|
28885
|
-
|
|
28962
|
+
init_chunk_J4T6L5LX();
|
|
28886
28963
|
init_chunk_6WN2R725();
|
|
28887
28964
|
init_chunk_YXWJW7I5();
|
|
28888
28965
|
import_fs6 = require("fs");
|
|
@@ -29502,10 +29579,10 @@ var init_codex = __esm({
|
|
|
29502
29579
|
};
|
|
29503
29580
|
let identify = () => {
|
|
29504
29581
|
};
|
|
29505
|
-
const identified = new Promise((
|
|
29506
|
-
identify =
|
|
29582
|
+
const identified = new Promise((resolve6) => {
|
|
29583
|
+
identify = resolve6;
|
|
29507
29584
|
});
|
|
29508
|
-
const done = new Promise((
|
|
29585
|
+
const done = new Promise((resolve6) => {
|
|
29509
29586
|
finish = (outcome2) => {
|
|
29510
29587
|
if (this.#current?.id !== id) return;
|
|
29511
29588
|
this.#current = void 0;
|
|
@@ -29513,7 +29590,7 @@ var init_codex = __esm({
|
|
|
29513
29590
|
if (this.#state === "busy") this.#state = "idle";
|
|
29514
29591
|
this.#host.scanDescendants(true);
|
|
29515
29592
|
this.#emit({ type: "turn_ended", turnId: id, outcome: outcome2 });
|
|
29516
|
-
|
|
29593
|
+
resolve6({ turnId: id, outcome: outcome2, providerSessionId: this.#threadId });
|
|
29517
29594
|
};
|
|
29518
29595
|
});
|
|
29519
29596
|
const active = {
|
|
@@ -29986,7 +30063,7 @@ function alanCodeConfigContent(existing, input2) {
|
|
|
29986
30063
|
});
|
|
29987
30064
|
}
|
|
29988
30065
|
function readBody2(response) {
|
|
29989
|
-
return new Promise((
|
|
30066
|
+
return new Promise((resolve6, reject) => {
|
|
29990
30067
|
const chunks = [];
|
|
29991
30068
|
let size = 0;
|
|
29992
30069
|
response.on("data", (chunk) => {
|
|
@@ -29994,7 +30071,7 @@ function readBody2(response) {
|
|
|
29994
30071
|
if (size > MAX_CATALOG_BYTES) response.destroy(new Error("catalog too large"));
|
|
29995
30072
|
else chunks.push(chunk);
|
|
29996
30073
|
});
|
|
29997
|
-
response.on("end", () =>
|
|
30074
|
+
response.on("end", () => resolve6(Buffer.concat(chunks).toString("utf8")));
|
|
29998
30075
|
response.on("error", reject);
|
|
29999
30076
|
});
|
|
30000
30077
|
}
|
|
@@ -30010,13 +30087,13 @@ function parseResponseBody(text2, status) {
|
|
|
30010
30087
|
}
|
|
30011
30088
|
function getJson(url2, headers, timeout, signal) {
|
|
30012
30089
|
const request2 = url2.protocol === "https:" ? import_https.request : import_http3.request;
|
|
30013
|
-
return new Promise((
|
|
30090
|
+
return new Promise((resolve6, reject) => {
|
|
30014
30091
|
const outgoing = request2(url2, { method: "GET", headers, timeout, signal }, (response) => {
|
|
30015
30092
|
const status = response.statusCode ?? 0;
|
|
30016
30093
|
readBody2(response).then((text2) => {
|
|
30017
30094
|
const body = parseResponseBody(text2, status);
|
|
30018
30095
|
if (status < 200 || status >= 300) reject(new CatalogResponseError(status, body));
|
|
30019
|
-
else
|
|
30096
|
+
else resolve6(body);
|
|
30020
30097
|
}).catch(reject);
|
|
30021
30098
|
});
|
|
30022
30099
|
outgoing.on("timeout", () => outgoing.destroy(new Error("catalog timed out")));
|
|
@@ -30233,15 +30310,15 @@ async function writePlugin(directory, apiOrigin) {
|
|
|
30233
30310
|
const origin = (0, import_crypto11.createHash)("sha256").update(apiOrigin).digest("hex").slice(0, 12);
|
|
30234
30311
|
const target = (0, import_path8.join)(directory, `engine-plugin-v${ALAN_CODE_ENGINE_PLUGIN_VERSION}-${origin}.mjs`);
|
|
30235
30312
|
const temporary = `${target}.${(0, import_crypto11.randomUUID)()}.tmp`;
|
|
30236
|
-
await (0,
|
|
30237
|
-
await (0,
|
|
30238
|
-
await (0,
|
|
30313
|
+
await (0, import_promises15.mkdir)(directory, { recursive: true, mode: 448 });
|
|
30314
|
+
await (0, import_promises15.writeFile)(temporary, alanCodeEnginePluginSource(apiOrigin), { mode: 384 });
|
|
30315
|
+
await (0, import_promises15.rename)(temporary, target);
|
|
30239
30316
|
return (0, import_url.pathToFileURL)(target).href;
|
|
30240
30317
|
}
|
|
30241
30318
|
async function prepareAlanCodeProfile(input2) {
|
|
30242
30319
|
const directories = Object.values(alanCodeEngineDirectories(input2.engineRoot));
|
|
30243
30320
|
await Promise.all(
|
|
30244
|
-
directories.map((directory) => (0,
|
|
30321
|
+
directories.map((directory) => (0, import_promises15.mkdir)(directory, { recursive: true, mode: 448 }))
|
|
30245
30322
|
);
|
|
30246
30323
|
const [pluginUrl, models] = await Promise.all([
|
|
30247
30324
|
writePlugin((0, import_path8.join)(input2.engineRoot, "plugin"), input2.access.apiOrigin),
|
|
@@ -30264,7 +30341,7 @@ function alanCodeSystemPrompt(alanSystemPrompt) {
|
|
|
30264
30341
|
|
|
30265
30342
|
${instructions}` : ALAN_CODE_TOOL_NAMING_PROMPT;
|
|
30266
30343
|
}
|
|
30267
|
-
var import_http3, import_https, import_fs7, import_path7, import_crypto11,
|
|
30344
|
+
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;
|
|
30268
30345
|
var init_alan_code = __esm({
|
|
30269
30346
|
"../agent-core/dist/providers/alan-code.js"() {
|
|
30270
30347
|
"use strict";
|
|
@@ -30278,7 +30355,7 @@ var init_alan_code = __esm({
|
|
|
30278
30355
|
import_path7 = require("path");
|
|
30279
30356
|
init_runtime_v2();
|
|
30280
30357
|
import_crypto11 = require("crypto");
|
|
30281
|
-
|
|
30358
|
+
import_promises15 = require("fs/promises");
|
|
30282
30359
|
import_path8 = require("path");
|
|
30283
30360
|
import_url = require("url");
|
|
30284
30361
|
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";
|
|
@@ -37647,10 +37724,10 @@ var require_dist = __commonJS({
|
|
|
37647
37724
|
var init_dist = __esm({
|
|
37648
37725
|
"../agent-core/dist/index.js"() {
|
|
37649
37726
|
"use strict";
|
|
37650
|
-
|
|
37727
|
+
init_chunk_YPYC4VBL();
|
|
37651
37728
|
init_chunk_UGRKZTAD();
|
|
37652
|
-
|
|
37653
|
-
|
|
37729
|
+
init_chunk_54ZRJOQP();
|
|
37730
|
+
init_chunk_J4T6L5LX();
|
|
37654
37731
|
init_chunk_YXWJW7I5();
|
|
37655
37732
|
}
|
|
37656
37733
|
});
|
|
@@ -37742,7 +37819,7 @@ function within(root, path) {
|
|
|
37742
37819
|
}
|
|
37743
37820
|
async function resolveReal(path) {
|
|
37744
37821
|
try {
|
|
37745
|
-
return await (0,
|
|
37822
|
+
return await (0, import_promises22.realpath)(path);
|
|
37746
37823
|
} catch {
|
|
37747
37824
|
const parent = (0, import_path9.dirname)(path);
|
|
37748
37825
|
if (parent === path) return path;
|
|
@@ -37771,14 +37848,14 @@ function createWorkspaceFs(roots, writable) {
|
|
|
37771
37848
|
return {
|
|
37772
37849
|
read: async (params) => {
|
|
37773
37850
|
const path = await confined(params);
|
|
37774
|
-
const bytes = await (0,
|
|
37851
|
+
const bytes = await (0, import_promises22.readFile)(path);
|
|
37775
37852
|
if (bytes.byteLength > MAX_READ_BYTES) throw new FsDenied(`${path} is too large to read`);
|
|
37776
37853
|
return { content: sliceLines(bytes.toString("utf8"), params) };
|
|
37777
37854
|
},
|
|
37778
37855
|
write: async (params) => {
|
|
37779
37856
|
if (!writable) throw new FsDenied("This session is read-only");
|
|
37780
37857
|
const path = await confined(params);
|
|
37781
|
-
await (0,
|
|
37858
|
+
await (0, import_promises22.writeFile)(path, asString(params.content));
|
|
37782
37859
|
return {};
|
|
37783
37860
|
}
|
|
37784
37861
|
};
|
|
@@ -38381,7 +38458,7 @@ async function acpTurnInput(run, context) {
|
|
|
38381
38458
|
const encoded = await Promise.all(
|
|
38382
38459
|
images.map(async (image) => ({
|
|
38383
38460
|
mimeType: image.mimeType,
|
|
38384
|
-
data: (await (0,
|
|
38461
|
+
data: (await (0, import_promises23.readFile)(image.path)).toString("base64")
|
|
38385
38462
|
}))
|
|
38386
38463
|
);
|
|
38387
38464
|
return {
|
|
@@ -38390,23 +38467,23 @@ async function acpTurnInput(run, context) {
|
|
|
38390
38467
|
...encoded.length ? { images: encoded, imagePaths: images.map((image) => image.path) } : {}
|
|
38391
38468
|
};
|
|
38392
38469
|
}
|
|
38393
|
-
var
|
|
38470
|
+
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;
|
|
38394
38471
|
var init_acp3 = __esm({
|
|
38395
38472
|
"../agent-core/dist/providers/acp.js"() {
|
|
38396
38473
|
"use strict";
|
|
38397
|
-
|
|
38474
|
+
init_chunk_YPYC4VBL();
|
|
38398
38475
|
init_chunk_UGRKZTAD();
|
|
38399
|
-
|
|
38476
|
+
init_chunk_54ZRJOQP();
|
|
38400
38477
|
init_chunk_J2KTV5FP();
|
|
38401
|
-
|
|
38478
|
+
init_chunk_J4T6L5LX();
|
|
38402
38479
|
init_chunk_6WN2R725();
|
|
38403
38480
|
init_chunk_YXWJW7I5();
|
|
38404
|
-
|
|
38481
|
+
import_promises22 = require("fs/promises");
|
|
38405
38482
|
import_path9 = require("path");
|
|
38406
38483
|
init_effort();
|
|
38407
38484
|
init_acp();
|
|
38408
38485
|
import_crypto12 = require("crypto");
|
|
38409
|
-
|
|
38486
|
+
import_promises23 = require("fs/promises");
|
|
38410
38487
|
init_agent2();
|
|
38411
38488
|
CURSOR_ASK_QUESTION = "cursor/ask_question";
|
|
38412
38489
|
copilotAcpProfile = {
|
|
@@ -38922,7 +38999,7 @@ var init_acp3 = __esm({
|
|
|
38922
38999
|
const turn = new AcpTurn(`acp-${this.#turns}-${id}`, this.#profile);
|
|
38923
39000
|
let finish = () => {
|
|
38924
39001
|
};
|
|
38925
|
-
const done = new Promise((
|
|
39002
|
+
const done = new Promise((resolve6) => {
|
|
38926
39003
|
finish = (outcome2) => {
|
|
38927
39004
|
if (this.#current?.id !== id) return;
|
|
38928
39005
|
this.#current = void 0;
|
|
@@ -38930,7 +39007,7 @@ var init_acp3 = __esm({
|
|
|
38930
39007
|
if (this.#state === "busy") this.#state = "idle";
|
|
38931
39008
|
this.#host.scanDescendants(true);
|
|
38932
39009
|
this.#emit({ type: "turn_ended", turnId: id, outcome: outcome2 });
|
|
38933
|
-
|
|
39010
|
+
resolve6({ turnId: id, outcome: outcome2, providerSessionId: this.#sessionId });
|
|
38934
39011
|
};
|
|
38935
39012
|
});
|
|
38936
39013
|
const active = { id, turn, done, finish, cancelRequested: false };
|
|
@@ -39211,7 +39288,7 @@ var init_acp3 = __esm({
|
|
|
39211
39288
|
var init_classify = __esm({
|
|
39212
39289
|
"../agent-core/dist/classify.js"() {
|
|
39213
39290
|
"use strict";
|
|
39214
|
-
|
|
39291
|
+
init_chunk_54ZRJOQP();
|
|
39215
39292
|
init_chunk_YXWJW7I5();
|
|
39216
39293
|
}
|
|
39217
39294
|
});
|
|
@@ -39241,38 +39318,31 @@ function toTurnResult(harness, outcome2, spec, providerSessionId, clock, apiKeyS
|
|
|
39241
39318
|
return { outcome: "aborted", ...session };
|
|
39242
39319
|
case "interrupted":
|
|
39243
39320
|
return { outcome: "interrupted", message: outcome2.reason, ...session };
|
|
39244
|
-
case "failed":
|
|
39245
|
-
|
|
39246
|
-
|
|
39247
|
-
|
|
39248
|
-
|
|
39249
|
-
|
|
39250
|
-
|
|
39251
|
-
|
|
39252
|
-
|
|
39253
|
-
|
|
39254
|
-
|
|
39255
|
-
|
|
39256
|
-
}),
|
|
39257
|
-
...session
|
|
39258
|
-
};
|
|
39321
|
+
case "failed": {
|
|
39322
|
+
const problem = createCliProblem(outcome2.error, {
|
|
39323
|
+
harness,
|
|
39324
|
+
phase: "stream",
|
|
39325
|
+
finality: "terminal",
|
|
39326
|
+
outcomeCertainty: "effect_unknown",
|
|
39327
|
+
occurredAt: new Date(clock.now()).toISOString(),
|
|
39328
|
+
scope: { runId: spec.runId, conversationId: spec.conversationId },
|
|
39329
|
+
apiKeySupplied
|
|
39330
|
+
});
|
|
39331
|
+
return { outcome: "failed", message: problem.detail, problem, ...session };
|
|
39332
|
+
}
|
|
39259
39333
|
}
|
|
39260
39334
|
}
|
|
39261
39335
|
function refusalResult(harness, refusal2, spec, clock, apiKeySupplied) {
|
|
39262
|
-
const
|
|
39263
|
-
|
|
39264
|
-
|
|
39265
|
-
|
|
39266
|
-
|
|
39267
|
-
|
|
39268
|
-
|
|
39269
|
-
|
|
39270
|
-
|
|
39271
|
-
|
|
39272
|
-
scope: { runId: spec.runId, conversationId: spec.conversationId },
|
|
39273
|
-
apiKeySupplied
|
|
39274
|
-
})
|
|
39275
|
-
};
|
|
39336
|
+
const problem = createCliProblem(refusal2.classified ?? specForErrorKind("not_authenticated"), {
|
|
39337
|
+
harness,
|
|
39338
|
+
phase: "preflight",
|
|
39339
|
+
finality: "terminal",
|
|
39340
|
+
outcomeCertainty: "no_effect",
|
|
39341
|
+
occurredAt: new Date(clock.now()).toISOString(),
|
|
39342
|
+
scope: { runId: spec.runId, conversationId: spec.conversationId },
|
|
39343
|
+
apiKeySupplied
|
|
39344
|
+
});
|
|
39345
|
+
return { outcome: "failed", message: problem.detail, problem };
|
|
39276
39346
|
}
|
|
39277
39347
|
function createPersistentDriver(provider4, options) {
|
|
39278
39348
|
const { log, clock } = options;
|
|
@@ -39375,7 +39445,8 @@ function createPersistentDriver(provider4, options) {
|
|
|
39375
39445
|
};
|
|
39376
39446
|
signal.addEventListener("abort", onAbort, { once: true });
|
|
39377
39447
|
try {
|
|
39378
|
-
const
|
|
39448
|
+
const contextPrefix = [inputs.turnContext, opened.contextPrefix].filter((part) => part !== void 0).join("\n\n");
|
|
39449
|
+
const input2 = await provider4.turnInput(spec, inputs, contextPrefix || void 0);
|
|
39379
39450
|
if (signal.aborted) return { outcome: "aborted" };
|
|
39380
39451
|
const result = await session.sendTurn(input2);
|
|
39381
39452
|
live.providerSessionId = result.providerSessionId ?? live.providerSessionId;
|
|
@@ -39567,10 +39638,10 @@ function parseSseBlock(block) {
|
|
|
39567
39638
|
return { type, properties: asRecord(record2.properties) ?? {} };
|
|
39568
39639
|
}
|
|
39569
39640
|
function readText(incoming) {
|
|
39570
|
-
return new Promise((
|
|
39641
|
+
return new Promise((resolve23, reject) => {
|
|
39571
39642
|
const chunks = [];
|
|
39572
39643
|
incoming.on("data", (chunk) => chunks.push(chunk));
|
|
39573
|
-
incoming.on("end", () =>
|
|
39644
|
+
incoming.on("end", () => resolve23(Buffer.concat(chunks).toString("utf8")));
|
|
39574
39645
|
incoming.on("error", reject);
|
|
39575
39646
|
});
|
|
39576
39647
|
}
|
|
@@ -39813,7 +39884,7 @@ function notice(kind, message) {
|
|
|
39813
39884
|
function promptParts2(input2) {
|
|
39814
39885
|
const files = (input2.imagePaths ?? []).map((path, index) => ({
|
|
39815
39886
|
type: "file",
|
|
39816
|
-
mime: input2.images?.[index]?.mimeType ?? IMAGE_TYPES[(0,
|
|
39887
|
+
mime: input2.images?.[index]?.mimeType ?? IMAGE_TYPES[(0, import_path11.extname)(path).toLowerCase()] ?? "application/octet-stream",
|
|
39817
39888
|
filename: path.split(/[\\/]/).at(-1) ?? path,
|
|
39818
39889
|
url: (0, import_url2.pathToFileURL)(path).href
|
|
39819
39890
|
}));
|
|
@@ -39905,6 +39976,34 @@ async function startServer(spec, password, options, attempt) {
|
|
|
39905
39976
|
}
|
|
39906
39977
|
}
|
|
39907
39978
|
}
|
|
39979
|
+
async function canResume(client, sessionId, log) {
|
|
39980
|
+
const stored = await client.readSession(sessionId);
|
|
39981
|
+
if (!stored) {
|
|
39982
|
+
log.warn("opencode.resume_failed", { sessionId, reason: "missing" });
|
|
39983
|
+
return false;
|
|
39984
|
+
}
|
|
39985
|
+
if (!stored.directory) return true;
|
|
39986
|
+
const directory = await client.directory();
|
|
39987
|
+
if (await sameDirectory(stored.directory, directory)) return true;
|
|
39988
|
+
log.warn("opencode.resume_failed", {
|
|
39989
|
+
sessionId,
|
|
39990
|
+
reason: "directory_changed",
|
|
39991
|
+
sessionDirectory: stored.directory,
|
|
39992
|
+
serverDirectory: directory
|
|
39993
|
+
});
|
|
39994
|
+
return false;
|
|
39995
|
+
}
|
|
39996
|
+
async function sameDirectory(left, right) {
|
|
39997
|
+
const [a, b] = await Promise.all([canonicalDirectory(left), canonicalDirectory(right)]);
|
|
39998
|
+
return process.platform === "win32" ? a.toLowerCase() === b.toLowerCase() : a === b;
|
|
39999
|
+
}
|
|
40000
|
+
async function canonicalDirectory(directory) {
|
|
40001
|
+
try {
|
|
40002
|
+
return await (0, import_promises24.realpath)(directory);
|
|
40003
|
+
} catch {
|
|
40004
|
+
return (0, import_path10.resolve)(directory);
|
|
40005
|
+
}
|
|
40006
|
+
}
|
|
39908
40007
|
async function openSession(session, client, spec, log) {
|
|
39909
40008
|
const health = await client.health();
|
|
39910
40009
|
const verdict = judgeOpenCodeVersion(health.version);
|
|
@@ -39920,11 +40019,8 @@ async function openSession(session, client, spec, log) {
|
|
|
39920
40019
|
}
|
|
39921
40020
|
await session.connect(client);
|
|
39922
40021
|
const resumeId = spec.resumeSessionId;
|
|
39923
|
-
if (resumeId && await client
|
|
39924
|
-
if (resumeId)
|
|
39925
|
-
log.warn("opencode.resume_failed", { sessionId: resumeId });
|
|
39926
|
-
session.resumeFailed = true;
|
|
39927
|
-
}
|
|
40022
|
+
if (resumeId && await canResume(client, resumeId, log)) return { id: resumeId, resumed: true };
|
|
40023
|
+
if (resumeId) session.resumeFailed = true;
|
|
39928
40024
|
const id = await client.createSession({ title: spec.title, permission: NON_INTERACTIVE_RULES });
|
|
39929
40025
|
return { id, resumed: false };
|
|
39930
40026
|
}
|
|
@@ -40075,22 +40171,24 @@ function openCodeTurnInput(run, context) {
|
|
|
40075
40171
|
...images.length ? { imagePaths: images.map((image) => image.path) } : {}
|
|
40076
40172
|
};
|
|
40077
40173
|
}
|
|
40078
|
-
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;
|
|
40174
|
+
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;
|
|
40079
40175
|
var init_opencode = __esm({
|
|
40080
40176
|
"../agent-core/dist/providers/opencode.js"() {
|
|
40081
40177
|
"use strict";
|
|
40082
|
-
|
|
40178
|
+
init_chunk_YPYC4VBL();
|
|
40083
40179
|
init_chunk_UGRKZTAD();
|
|
40084
|
-
|
|
40180
|
+
init_chunk_54ZRJOQP();
|
|
40085
40181
|
init_chunk_J2KTV5FP();
|
|
40086
|
-
|
|
40182
|
+
init_chunk_J4T6L5LX();
|
|
40087
40183
|
init_chunk_6WN2R725();
|
|
40088
40184
|
init_chunk_YXWJW7I5();
|
|
40089
40185
|
import_http4 = require("http");
|
|
40090
40186
|
init_runtime_v2();
|
|
40091
40187
|
import_crypto13 = require("crypto");
|
|
40092
|
-
|
|
40188
|
+
import_promises24 = require("fs/promises");
|
|
40093
40189
|
import_path10 = require("path");
|
|
40190
|
+
init_agent2();
|
|
40191
|
+
import_path11 = require("path");
|
|
40094
40192
|
import_url2 = require("url");
|
|
40095
40193
|
init_acp();
|
|
40096
40194
|
import_crypto14 = require("crypto");
|
|
@@ -40117,11 +40215,11 @@ var init_opencode = __esm({
|
|
|
40117
40215
|
this.#engine = engine;
|
|
40118
40216
|
}
|
|
40119
40217
|
#open(call) {
|
|
40120
|
-
return new Promise((
|
|
40218
|
+
return new Promise((resolve23, reject) => {
|
|
40121
40219
|
const outgoing = (0, import_http4.request)(
|
|
40122
40220
|
`${this.baseUrl}${call.path}`,
|
|
40123
40221
|
{ method: call.method, headers: call.headers, agent: this.#agent },
|
|
40124
|
-
|
|
40222
|
+
resolve23
|
|
40125
40223
|
);
|
|
40126
40224
|
outgoing.on("error", reject);
|
|
40127
40225
|
outgoing.end(call.body);
|
|
@@ -40158,18 +40256,25 @@ var init_opencode = __esm({
|
|
|
40158
40256
|
return id;
|
|
40159
40257
|
}
|
|
40160
40258
|
/**
|
|
40161
|
-
*
|
|
40162
|
-
* other failure raises, so a server hiccup never silently replaces the
|
|
40259
|
+
* The stored session, or undefined when the server's store does not have it. Only a 404
|
|
40260
|
+
* means that: any other failure raises, so a server hiccup never silently replaces the
|
|
40261
|
+
* conversation.
|
|
40163
40262
|
*/
|
|
40164
|
-
async
|
|
40263
|
+
async readSession(sessionId) {
|
|
40165
40264
|
try {
|
|
40166
|
-
|
|
40167
|
-
|
|
40265
|
+
const body = asRecord(
|
|
40266
|
+
await this.#call("session read", "GET", `/session/${encodeURIComponent(sessionId)}`)
|
|
40267
|
+
);
|
|
40268
|
+
return { directory: asString(body?.directory) };
|
|
40168
40269
|
} catch (error61) {
|
|
40169
|
-
if (error61 instanceof OpenCodeHttpError && error61.status === 404) return
|
|
40270
|
+
if (error61 instanceof OpenCodeHttpError && error61.status === 404) return void 0;
|
|
40170
40271
|
throw error61;
|
|
40171
40272
|
}
|
|
40172
40273
|
}
|
|
40274
|
+
/** The directory the server serves when a request names none: its own cwd. */
|
|
40275
|
+
async directory() {
|
|
40276
|
+
return asString(asRecord(await this.#call("path read", "GET", "/path"))?.directory);
|
|
40277
|
+
}
|
|
40173
40278
|
/** Answers 204 at once; the turn itself arrives on `/event`. */
|
|
40174
40279
|
async promptAsync(sessionId, body) {
|
|
40175
40280
|
await this.#call("prompt", "POST", `/session/${encodeURIComponent(sessionId)}/prompt_async`, {
|
|
@@ -40855,8 +40960,8 @@ var init_opencode = __esm({
|
|
|
40855
40960
|
onExit: (exit) => this.#onExit(exit)
|
|
40856
40961
|
}
|
|
40857
40962
|
);
|
|
40858
|
-
this.#listening = new Promise((
|
|
40859
|
-
this.#announce =
|
|
40963
|
+
this.#listening = new Promise((resolve23, reject) => {
|
|
40964
|
+
this.#announce = resolve23;
|
|
40860
40965
|
void this.#host.exited.then(
|
|
40861
40966
|
() => reject(
|
|
40862
40967
|
new CoreFault(
|
|
@@ -40945,12 +41050,8 @@ var init_opencode = __esm({
|
|
|
40945
41050
|
await client.promptAsync(sessionId, body);
|
|
40946
41051
|
} catch (error61) {
|
|
40947
41052
|
if (this.#state === "closed") return;
|
|
41053
|
+
if (this.#current?.id !== active.id) return;
|
|
40948
41054
|
const message = error61 instanceof Error ? error61.message : String(error61);
|
|
40949
|
-
this.#emit({
|
|
40950
|
-
type: "update",
|
|
40951
|
-
turnId: active.id,
|
|
40952
|
-
update: noticeUpdate("error", "provider", message)
|
|
40953
|
-
});
|
|
40954
41055
|
active.finish({ status: "failed", error: classifyProviderError(message) });
|
|
40955
41056
|
}
|
|
40956
41057
|
}
|
|
@@ -41021,7 +41122,7 @@ var init_opencode = __esm({
|
|
|
41021
41122
|
);
|
|
41022
41123
|
let finish = () => {
|
|
41023
41124
|
};
|
|
41024
|
-
const done = new Promise((
|
|
41125
|
+
const done = new Promise((resolve23) => {
|
|
41025
41126
|
finish = (outcome2) => {
|
|
41026
41127
|
if (this.#current?.id !== id) return;
|
|
41027
41128
|
this.#current = void 0;
|
|
@@ -41029,7 +41130,7 @@ var init_opencode = __esm({
|
|
|
41029
41130
|
if (outcome2.status !== "completed") this.#repairPending = true;
|
|
41030
41131
|
this.#host.scanDescendants(true);
|
|
41031
41132
|
this.#emit({ type: "turn_ended", turnId: id, outcome: outcome2 });
|
|
41032
|
-
|
|
41133
|
+
resolve23({ turnId: id, outcome: outcome2, providerSessionId: this.#sessionId });
|
|
41033
41134
|
};
|
|
41034
41135
|
});
|
|
41035
41136
|
const active = {
|
|
@@ -41209,7 +41310,7 @@ function createAlanCodeHolderDriver(options) {
|
|
|
41209
41310
|
const engine = resolveAlanCodeEngine({ env, platform, packaged: [] });
|
|
41210
41311
|
const engineRoot = alanCodeEngineRoot(env.HOME?.trim() || (0, import_node_os2.homedir)());
|
|
41211
41312
|
options.log.info("alan_code.engine", { command: engine.command, source: engine.source });
|
|
41212
|
-
const
|
|
41313
|
+
const open4 = async (planned) => {
|
|
41213
41314
|
if (planned.profile === void 0) throw refuseWithoutCredential();
|
|
41214
41315
|
const { opencode } = planned;
|
|
41215
41316
|
const profile = await prepareAlanCodeProfile({
|
|
@@ -41266,7 +41367,7 @@ function createAlanCodeHolderDriver(options) {
|
|
|
41266
41367
|
};
|
|
41267
41368
|
},
|
|
41268
41369
|
canResume: () => true,
|
|
41269
|
-
open:
|
|
41370
|
+
open: open4,
|
|
41270
41371
|
turnInput: async (spec, inputs, contextPrefix) => openCodeTurnInput(spec, {
|
|
41271
41372
|
attachments: inputs.attachments,
|
|
41272
41373
|
skills: [],
|
|
@@ -41350,21 +41451,63 @@ var codex_exports = {};
|
|
|
41350
41451
|
__export(codex_exports, {
|
|
41351
41452
|
createCodexHolderDriver: () => createCodexHolderDriver
|
|
41352
41453
|
});
|
|
41454
|
+
function sha2562(value) {
|
|
41455
|
+
return (0, import_node_crypto12.createHash)("sha256").update(value).digest("hex");
|
|
41456
|
+
}
|
|
41457
|
+
function createCodexLogin(broker) {
|
|
41458
|
+
const state = {};
|
|
41459
|
+
return {
|
|
41460
|
+
forTurn: (runId, tokens2) => {
|
|
41461
|
+
state.runId = runId;
|
|
41462
|
+
state.latest = tokens2;
|
|
41463
|
+
},
|
|
41464
|
+
externalAuth: {
|
|
41465
|
+
current: async () => {
|
|
41466
|
+
if (state.latest === void 0) throw new Error("No Codex sign-in for this turn");
|
|
41467
|
+
state.given = state.latest;
|
|
41468
|
+
return state.given;
|
|
41469
|
+
},
|
|
41470
|
+
refresh: async () => {
|
|
41471
|
+
if (broker === void 0 || state.runId === void 0) {
|
|
41472
|
+
throw new Error("Codex sign-in cannot be refreshed on this machine");
|
|
41473
|
+
}
|
|
41474
|
+
const rejected2 = state.given === void 0 ? void 0 : sha2562(state.given.accessToken);
|
|
41475
|
+
const fresh = await broker.refresh(state.runId, rejected2);
|
|
41476
|
+
state.latest = fresh;
|
|
41477
|
+
state.given = fresh;
|
|
41478
|
+
return fresh;
|
|
41479
|
+
}
|
|
41480
|
+
}
|
|
41481
|
+
};
|
|
41482
|
+
}
|
|
41483
|
+
function withLogin(planned, externalAuth, accountId) {
|
|
41484
|
+
return {
|
|
41485
|
+
...planned,
|
|
41486
|
+
spec: { ...planned.spec, externalAuth },
|
|
41487
|
+
key: JSON.stringify([planned.key, accountId])
|
|
41488
|
+
};
|
|
41489
|
+
}
|
|
41353
41490
|
function createCodexHolderDriver(options) {
|
|
41354
41491
|
const clock = options.clock ?? systemClock2;
|
|
41355
41492
|
const sessions = options.sessions ?? createCodexDriver({ ...options.timings, clock, log: options.log });
|
|
41493
|
+
const login = createCodexLogin(options.codexCredentials);
|
|
41356
41494
|
return createPersistentDriver(
|
|
41357
41495
|
{
|
|
41358
41496
|
harness: "codex_app_server",
|
|
41359
41497
|
displayName: "Codex app-server",
|
|
41360
|
-
plan: (spec, inputs, resumeId, managedMcp) =>
|
|
41361
|
-
|
|
41362
|
-
|
|
41363
|
-
|
|
41364
|
-
|
|
41365
|
-
|
|
41366
|
-
|
|
41367
|
-
|
|
41498
|
+
plan: (spec, inputs, resumeId, managedMcp) => {
|
|
41499
|
+
const planned = planCodexSession(spec, {
|
|
41500
|
+
command: options.command ?? "codex",
|
|
41501
|
+
cwd: spec.projectPath ?? options.defaultCwd,
|
|
41502
|
+
cliEnv: options.cliEnvironment,
|
|
41503
|
+
providerEnv: inputs.providerEnv,
|
|
41504
|
+
...managedMcp === void 0 ? {} : { managedMcp },
|
|
41505
|
+
...resumeId === void 0 ? {} : { resumeThreadId: resumeId }
|
|
41506
|
+
});
|
|
41507
|
+
if (inputs.codex === void 0) return planned;
|
|
41508
|
+
login.forTurn(spec.runId, inputs.codex);
|
|
41509
|
+
return withLogin(planned, login.externalAuth, inputs.codex.chatgptAccountId);
|
|
41510
|
+
},
|
|
41368
41511
|
canResume: () => true,
|
|
41369
41512
|
open: async (spec) => {
|
|
41370
41513
|
const session = await sessions.open(spec);
|
|
@@ -41384,9 +41527,11 @@ function createCodexHolderDriver(options) {
|
|
|
41384
41527
|
}
|
|
41385
41528
|
);
|
|
41386
41529
|
}
|
|
41530
|
+
var import_node_crypto12;
|
|
41387
41531
|
var init_codex2 = __esm({
|
|
41388
41532
|
"src/holder/drivers/codex.ts"() {
|
|
41389
41533
|
"use strict";
|
|
41534
|
+
import_node_crypto12 = require("crypto");
|
|
41390
41535
|
init_dist();
|
|
41391
41536
|
init_codex();
|
|
41392
41537
|
init_persistent();
|
|
@@ -41493,8 +41638,8 @@ function createDroidPeer(writer, handlers) {
|
|
|
41493
41638
|
},
|
|
41494
41639
|
request: (method, params = {}) => {
|
|
41495
41640
|
const id = `alan-${counter.next++}`;
|
|
41496
|
-
return new Promise((
|
|
41497
|
-
pending.set(id, { method, resolve:
|
|
41641
|
+
return new Promise((resolve6, reject) => {
|
|
41642
|
+
pending.set(id, { method, resolve: resolve6, reject });
|
|
41498
41643
|
writer.write(envelope("request", { id, method, params })).catch((error61) => {
|
|
41499
41644
|
pending.delete(id);
|
|
41500
41645
|
reject(error61 instanceof Error ? error61 : new Error(String(error61)));
|
|
@@ -41829,25 +41974,25 @@ async function droidTurnInput(run, context) {
|
|
|
41829
41974
|
const encoded = await Promise.all(
|
|
41830
41975
|
images.map(async (image) => ({
|
|
41831
41976
|
mimeType: image.mimeType,
|
|
41832
|
-
data: (await (0,
|
|
41977
|
+
data: (await (0, import_promises25.readFile)(image.path)).toString("base64")
|
|
41833
41978
|
}))
|
|
41834
41979
|
);
|
|
41835
41980
|
return { turnId: run.runId, text: text2, ...encoded.length ? { images: encoded } : {} };
|
|
41836
41981
|
}
|
|
41837
|
-
var import_crypto15,
|
|
41982
|
+
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;
|
|
41838
41983
|
var init_droid = __esm({
|
|
41839
41984
|
"../agent-core/dist/providers/droid.js"() {
|
|
41840
41985
|
"use strict";
|
|
41841
|
-
|
|
41986
|
+
init_chunk_YPYC4VBL();
|
|
41842
41987
|
init_chunk_UGRKZTAD();
|
|
41843
|
-
|
|
41988
|
+
init_chunk_54ZRJOQP();
|
|
41844
41989
|
init_chunk_J2KTV5FP();
|
|
41845
|
-
|
|
41990
|
+
init_chunk_J4T6L5LX();
|
|
41846
41991
|
init_chunk_6WN2R725();
|
|
41847
41992
|
init_chunk_YXWJW7I5();
|
|
41848
41993
|
init_runtime_v2();
|
|
41849
41994
|
import_crypto15 = require("crypto");
|
|
41850
|
-
|
|
41995
|
+
import_promises25 = require("fs/promises");
|
|
41851
41996
|
init_agent2();
|
|
41852
41997
|
FACTORY_API_VERSION = "1.0.0";
|
|
41853
41998
|
FACTORY_PROTOCOL_VERSION = "1.187.0";
|
|
@@ -42119,14 +42264,14 @@ var init_droid = __esm({
|
|
|
42119
42264
|
const turn = new DroidTurn(sessionId, this.#memory);
|
|
42120
42265
|
let finish = () => {
|
|
42121
42266
|
};
|
|
42122
|
-
const done = new Promise((
|
|
42267
|
+
const done = new Promise((resolve6) => {
|
|
42123
42268
|
finish = (outcome2) => {
|
|
42124
42269
|
if (this.#current?.id !== id) return;
|
|
42125
42270
|
this.#current = void 0;
|
|
42126
42271
|
if (this.#state === "busy") this.#state = "idle";
|
|
42127
42272
|
this.#host.scanDescendants(true);
|
|
42128
42273
|
this.#emit({ type: "turn_ended", turnId: id, outcome: outcome2 });
|
|
42129
|
-
|
|
42274
|
+
resolve6({ turnId: id, outcome: outcome2, providerSessionId: this.#sessionId });
|
|
42130
42275
|
};
|
|
42131
42276
|
});
|
|
42132
42277
|
const active = { id, turn, done, finish, cancelRequested: false };
|
|
@@ -42311,6 +42456,35 @@ var init_opencode2 = __esm({
|
|
|
42311
42456
|
});
|
|
42312
42457
|
|
|
42313
42458
|
// ../agent-core/dist/providers/antigravity.js
|
|
42459
|
+
function settingsPath(env) {
|
|
42460
|
+
const home = env.HOME?.trim() || env.USERPROFILE?.trim();
|
|
42461
|
+
return home ? (0, import_path12.resolve)(home, ".gemini", "antigravity-cli", "settings.json") : void 0;
|
|
42462
|
+
}
|
|
42463
|
+
async function readSettings(path) {
|
|
42464
|
+
let raw;
|
|
42465
|
+
try {
|
|
42466
|
+
raw = (await (0, import_promises26.readFile)(path, "utf8")).trim();
|
|
42467
|
+
} catch {
|
|
42468
|
+
return {};
|
|
42469
|
+
}
|
|
42470
|
+
if (!raw) return {};
|
|
42471
|
+
try {
|
|
42472
|
+
const parsed = JSON.parse(raw);
|
|
42473
|
+
return isRecord(parsed) ? parsed : "malformed";
|
|
42474
|
+
} catch {
|
|
42475
|
+
return "malformed";
|
|
42476
|
+
}
|
|
42477
|
+
}
|
|
42478
|
+
async function selectAntigravityApiKeyMode(env) {
|
|
42479
|
+
const path = settingsPath(env);
|
|
42480
|
+
if (!env.GEMINI_API_KEY?.trim() || path === void 0) return "no_key";
|
|
42481
|
+
const settings2 = await readSettings(path);
|
|
42482
|
+
if (settings2 === "malformed") return "malformed";
|
|
42483
|
+
if (settings2.modelProvider === "gemini") return "already_selected";
|
|
42484
|
+
await (0, import_promises26.mkdir)((0, import_path12.dirname)(path), { recursive: true });
|
|
42485
|
+
await (0, import_promises26.writeFile)(path, JSON.stringify({ ...settings2, modelProvider: "gemini" }), { mode: 384 });
|
|
42486
|
+
return "selected";
|
|
42487
|
+
}
|
|
42314
42488
|
function readAntigravityCapabilities(version2, help) {
|
|
42315
42489
|
const text2 = help.toLowerCase().replace(/\s+/g, " ");
|
|
42316
42490
|
const structured = /\bstream-json\b/.test(text2) || /\bjsonl\b/.test(text2) || /\bjson\b/.test(text2);
|
|
@@ -42351,21 +42525,21 @@ function antigravityArgs(input2, capabilities, prompt) {
|
|
|
42351
42525
|
];
|
|
42352
42526
|
}
|
|
42353
42527
|
function workspaceRoot(cwd) {
|
|
42354
|
-
for (let current = (0,
|
|
42355
|
-
if ((0, import_fs8.existsSync)((0,
|
|
42356
|
-
if ((0,
|
|
42528
|
+
for (let current = (0, import_path13.resolve)(cwd); ; current = (0, import_path13.dirname)(current)) {
|
|
42529
|
+
if ((0, import_fs8.existsSync)((0, import_path13.join)(current, ".git"))) return current;
|
|
42530
|
+
if ((0, import_path13.dirname)(current) === current) return (0, import_path13.resolve)(cwd);
|
|
42357
42531
|
}
|
|
42358
42532
|
}
|
|
42359
42533
|
function instructionPaths(cwd) {
|
|
42360
42534
|
const root = workspaceRoot(cwd);
|
|
42361
42535
|
const paths = [];
|
|
42362
|
-
for (let current = (0,
|
|
42363
|
-
const path = (0,
|
|
42536
|
+
for (let current = (0, import_path13.resolve)(cwd); ; current = (0, import_path13.dirname)(current)) {
|
|
42537
|
+
const path = (0, import_path13.join)(current, INSTRUCTIONS_FILE);
|
|
42364
42538
|
try {
|
|
42365
42539
|
if ((0, import_fs8.existsSync)(path) && (0, import_fs8.statSync)(path).isFile()) paths.unshift(path);
|
|
42366
42540
|
} catch {
|
|
42367
42541
|
}
|
|
42368
|
-
if (current === root || (0,
|
|
42542
|
+
if (current === root || (0, import_path13.dirname)(current) === current) return paths;
|
|
42369
42543
|
}
|
|
42370
42544
|
}
|
|
42371
42545
|
function antigravityWorkspaceInstructions(cwd, maxChars = MAX_INSTRUCTION_CHARS) {
|
|
@@ -42619,7 +42793,7 @@ function normalizeAntigravityFrame(event) {
|
|
|
42619
42793
|
}
|
|
42620
42794
|
function antigravityBrainRoot(env) {
|
|
42621
42795
|
const home = env.HOME?.trim() || env.USERPROFILE?.trim();
|
|
42622
|
-
return home ? (0,
|
|
42796
|
+
return home ? (0, import_path14.resolve)(home, ".gemini", "antigravity-cli", "brain") : void 0;
|
|
42623
42797
|
}
|
|
42624
42798
|
function parseEntry(text2) {
|
|
42625
42799
|
try {
|
|
@@ -42657,14 +42831,14 @@ function childTranscriptPath(root, frame) {
|
|
|
42657
42831
|
try {
|
|
42658
42832
|
const url2 = new URL(logUri);
|
|
42659
42833
|
if (url2.protocol !== "file:") return void 0;
|
|
42660
|
-
path = (0,
|
|
42834
|
+
path = (0, import_path14.resolve)((0, import_url3.fileURLToPath)(url2));
|
|
42661
42835
|
} catch {
|
|
42662
42836
|
return void 0;
|
|
42663
42837
|
}
|
|
42664
|
-
const fromRoot = (0,
|
|
42665
|
-
if (!fromRoot || (0,
|
|
42838
|
+
const fromRoot = (0, import_path14.relative)(root, path);
|
|
42839
|
+
if (!fromRoot || (0, import_path14.isAbsolute)(fromRoot) || fromRoot.split(import_path14.sep).includes("..")) return void 0;
|
|
42666
42840
|
const expected = [conversationId, ...LOG_DIRS, TRANSCRIPT_FILE];
|
|
42667
|
-
const segments = fromRoot.split(
|
|
42841
|
+
const segments = fromRoot.split(import_path14.sep);
|
|
42668
42842
|
const matches = segments.length === expected.length && segments.every((segment, index) => segment === expected[index]);
|
|
42669
42843
|
return matches ? path : void 0;
|
|
42670
42844
|
}
|
|
@@ -42842,11 +43016,15 @@ ${output2.stderr}`).join("\n")
|
|
|
42842
43016
|
name: "antigravity_cli",
|
|
42843
43017
|
capabilities,
|
|
42844
43018
|
open: async (spec) => {
|
|
42845
|
-
const found = await
|
|
43019
|
+
const [found, apiKeyMode] = await Promise.all([
|
|
43020
|
+
capabilities(spec.command, spec.env),
|
|
43021
|
+
selectAntigravityApiKeyMode(spec.env).catch(() => "unwritable")
|
|
43022
|
+
]);
|
|
42846
43023
|
session.log.info("antigravity.opened", {
|
|
42847
43024
|
version: found.version,
|
|
42848
43025
|
structured: found.structuredPrint,
|
|
42849
|
-
resumeId: spec.resumeSessionId
|
|
43026
|
+
resumeId: spec.resumeSessionId,
|
|
43027
|
+
apiKeyMode
|
|
42850
43028
|
});
|
|
42851
43029
|
return new AntigravitySession(
|
|
42852
43030
|
provider2(spec, found, options.platform ?? process.platform),
|
|
@@ -42903,21 +43081,24 @@ function antigravityTurnInput(run, context) {
|
|
|
42903
43081
|
});
|
|
42904
43082
|
return { turnId: run.runId, text: appendImagePathReferences(text2, images) };
|
|
42905
43083
|
}
|
|
42906
|
-
var import_fs8,
|
|
43084
|
+
var import_promises26, import_path12, import_fs8, import_path13, import_path14, 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;
|
|
42907
43085
|
var init_antigravity = __esm({
|
|
42908
43086
|
"../agent-core/dist/providers/antigravity.js"() {
|
|
42909
43087
|
"use strict";
|
|
42910
43088
|
init_chunk_DALFHI4B();
|
|
42911
|
-
|
|
43089
|
+
init_chunk_YPYC4VBL();
|
|
42912
43090
|
init_chunk_UGRKZTAD();
|
|
42913
|
-
|
|
42914
|
-
|
|
43091
|
+
init_chunk_54ZRJOQP();
|
|
43092
|
+
init_chunk_J4T6L5LX();
|
|
42915
43093
|
init_chunk_6WN2R725();
|
|
42916
43094
|
init_chunk_YXWJW7I5();
|
|
43095
|
+
import_promises26 = require("fs/promises");
|
|
43096
|
+
import_path12 = require("path");
|
|
43097
|
+
init_type_guards();
|
|
42917
43098
|
import_fs8 = require("fs");
|
|
42918
|
-
|
|
43099
|
+
import_path13 = require("path");
|
|
42919
43100
|
init_effort();
|
|
42920
|
-
|
|
43101
|
+
import_path14 = require("path");
|
|
42921
43102
|
import_url3 = require("url");
|
|
42922
43103
|
import_crypto16 = require("crypto");
|
|
42923
43104
|
init_agent2();
|
|
@@ -42957,7 +43138,7 @@ var init_antigravity = __esm({
|
|
|
42957
43138
|
#full;
|
|
42958
43139
|
constructor(path) {
|
|
42959
43140
|
this.#cursor = new TranscriptCursor(path);
|
|
42960
|
-
this.#fullPath = (0,
|
|
43141
|
+
this.#fullPath = (0, import_path14.resolve)((0, import_path14.dirname)(path), FULL_TRANSCRIPT_FILE);
|
|
42961
43142
|
}
|
|
42962
43143
|
skipExisting() {
|
|
42963
43144
|
this.#cursor.read();
|
|
@@ -43005,7 +43186,7 @@ var init_antigravity = __esm({
|
|
|
43005
43186
|
/** A conversation this turn did not resume was created by it, so it is read whole. */
|
|
43006
43187
|
trackParent(conversationId) {
|
|
43007
43188
|
if (this.#parent?.conversationId === conversationId) return;
|
|
43008
|
-
const path = (0,
|
|
43189
|
+
const path = (0, import_path14.resolve)(this.#root, conversationId, ...LOG_DIRS, TRANSCRIPT_FILE);
|
|
43009
43190
|
this.#parent = { conversationId, transcript: new BrainTranscript(path) };
|
|
43010
43191
|
}
|
|
43011
43192
|
/** A launcher keeps the first valid transcript it names; later frames change nothing. */
|
|
@@ -43410,8 +43591,8 @@ function parseConfig(raw) {
|
|
|
43410
43591
|
}
|
|
43411
43592
|
}
|
|
43412
43593
|
async function writeCommandCodeProjectMcp(cwd, mcp) {
|
|
43413
|
-
const path = (0,
|
|
43414
|
-
const original = await (0,
|
|
43594
|
+
const path = (0, import_path15.join)(cwd, ".mcp.json");
|
|
43595
|
+
const original = await (0, import_promises27.readFile)(path, "utf8").catch(() => null);
|
|
43415
43596
|
const config2 = parseConfig(original);
|
|
43416
43597
|
const next = {
|
|
43417
43598
|
...config2,
|
|
@@ -43428,12 +43609,12 @@ async function writeCommandCodeProjectMcp(cwd, mcp) {
|
|
|
43428
43609
|
}
|
|
43429
43610
|
}
|
|
43430
43611
|
};
|
|
43431
|
-
await (0,
|
|
43432
|
-
await (0,
|
|
43612
|
+
await (0, import_promises27.mkdir)(cwd, { recursive: true });
|
|
43613
|
+
await (0, import_promises27.writeFile)(path, `${JSON.stringify(next, null, 2)}
|
|
43433
43614
|
`);
|
|
43434
43615
|
return async () => {
|
|
43435
|
-
if (original === null) await (0,
|
|
43436
|
-
else await (0,
|
|
43616
|
+
if (original === null) await (0, import_promises27.rm)(path, { force: true });
|
|
43617
|
+
else await (0, import_promises27.writeFile)(path, original);
|
|
43437
43618
|
};
|
|
43438
43619
|
}
|
|
43439
43620
|
function commandCodeString(value) {
|
|
@@ -43605,19 +43786,19 @@ function commandCodeTurnInput(run, context) {
|
|
|
43605
43786
|
});
|
|
43606
43787
|
return { turnId: run.runId, text: appendImagePathReferences(text2, images) };
|
|
43607
43788
|
}
|
|
43608
|
-
var
|
|
43789
|
+
var import_promises27, import_path15, 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;
|
|
43609
43790
|
var init_command_code = __esm({
|
|
43610
43791
|
"../agent-core/dist/providers/command-code.js"() {
|
|
43611
43792
|
"use strict";
|
|
43612
|
-
|
|
43793
|
+
init_chunk_YPYC4VBL();
|
|
43613
43794
|
init_chunk_UGRKZTAD();
|
|
43614
|
-
|
|
43795
|
+
init_chunk_54ZRJOQP();
|
|
43615
43796
|
init_chunk_J2KTV5FP();
|
|
43616
|
-
|
|
43797
|
+
init_chunk_J4T6L5LX();
|
|
43617
43798
|
init_chunk_6WN2R725();
|
|
43618
43799
|
init_chunk_YXWJW7I5();
|
|
43619
|
-
|
|
43620
|
-
|
|
43800
|
+
import_promises27 = require("fs/promises");
|
|
43801
|
+
import_path15 = require("path");
|
|
43621
43802
|
init_agent2();
|
|
43622
43803
|
init_runtime_v2();
|
|
43623
43804
|
init_acp();
|
|
@@ -44478,7 +44659,7 @@ function transportFailure(request2, error61) {
|
|
|
44478
44659
|
});
|
|
44479
44660
|
}
|
|
44480
44661
|
function readBody(incoming, url2, maxBytes) {
|
|
44481
|
-
return new Promise((
|
|
44662
|
+
return new Promise((resolve6, reject) => {
|
|
44482
44663
|
const declared = Number(incoming.headers["content-length"] ?? "0");
|
|
44483
44664
|
if (maxBytes !== void 0 && declared > maxBytes) {
|
|
44484
44665
|
incoming.destroy();
|
|
@@ -44497,7 +44678,7 @@ function readBody(incoming, url2, maxBytes) {
|
|
|
44497
44678
|
chunks.push(chunk);
|
|
44498
44679
|
});
|
|
44499
44680
|
incoming.on("error", reject);
|
|
44500
|
-
incoming.on("end", () =>
|
|
44681
|
+
incoming.on("end", () => resolve6(Buffer.concat(chunks)));
|
|
44501
44682
|
});
|
|
44502
44683
|
}
|
|
44503
44684
|
function isConnectionReset(error61) {
|
|
@@ -44505,7 +44686,7 @@ function isConnectionReset(error61) {
|
|
|
44505
44686
|
}
|
|
44506
44687
|
function exchange(request2, agents, attempt = 0) {
|
|
44507
44688
|
const { signal, url: url2 } = request2;
|
|
44508
|
-
return new Promise((
|
|
44689
|
+
return new Promise((resolve6, reject) => {
|
|
44509
44690
|
if (signal.aborted) {
|
|
44510
44691
|
reject(signal.reason);
|
|
44511
44692
|
return;
|
|
@@ -44532,7 +44713,7 @@ function exchange(request2, agents, attempt = 0) {
|
|
|
44532
44713
|
const stale = outgoing.reusedSocket && !responded && isConnectionReset(error61);
|
|
44533
44714
|
if (stale && attempt < STALE_SOCKET_RETRIES && !signal.aborted) {
|
|
44534
44715
|
settle();
|
|
44535
|
-
|
|
44716
|
+
resolve6(exchange(request2, agents, attempt + 1));
|
|
44536
44717
|
return;
|
|
44537
44718
|
}
|
|
44538
44719
|
fail(error61);
|
|
@@ -44545,7 +44726,7 @@ function exchange(request2, agents, attempt = 0) {
|
|
|
44545
44726
|
readBody(incoming, url2, isRedirect(status) ? void 0 : request2.maxBodyBytes).then(
|
|
44546
44727
|
(body) => {
|
|
44547
44728
|
settle();
|
|
44548
|
-
|
|
44729
|
+
resolve6({ status, headers: incoming.headers, body });
|
|
44549
44730
|
},
|
|
44550
44731
|
fail
|
|
44551
44732
|
);
|
|
@@ -44650,6 +44831,13 @@ function createHolderApiClient({
|
|
|
44650
44831
|
}
|
|
44651
44832
|
return runProviderCredentialSchema.parse(jsonBody(response));
|
|
44652
44833
|
},
|
|
44834
|
+
refreshCodexCredential: async (runId, body, signal) => {
|
|
44835
|
+
const response = await request2("POST", runCodexCredentialRefreshPath(runId), signal, body);
|
|
44836
|
+
if (!isOk(response)) {
|
|
44837
|
+
throw new RuntimeFault("io_failed", `Codex sign-in refresh failed: ${response.status}`);
|
|
44838
|
+
}
|
|
44839
|
+
return runCodexCredentialSchema.parse(jsonBody(response));
|
|
44840
|
+
},
|
|
44653
44841
|
mintMcpCredential: async (conversationId, signal) => {
|
|
44654
44842
|
const response = await request2("POST", MACHINE_PATHS.mcpCredential, signal, {
|
|
44655
44843
|
conversationId
|
|
@@ -44695,7 +44883,7 @@ var GitFault = class extends Error {
|
|
|
44695
44883
|
var import_node_child_process = require("child_process");
|
|
44696
44884
|
|
|
44697
44885
|
// ../agent-core/dist/process.js
|
|
44698
|
-
|
|
44886
|
+
init_chunk_J4T6L5LX();
|
|
44699
44887
|
init_chunk_YXWJW7I5();
|
|
44700
44888
|
|
|
44701
44889
|
// src/capabilities/git/run-git.ts
|
|
@@ -44827,7 +45015,7 @@ function createGitRunner(options) {
|
|
|
44827
45015
|
}
|
|
44828
45016
|
await killProcessTree(child.pid, { signal: "SIGKILL", child, platform });
|
|
44829
45017
|
};
|
|
44830
|
-
return new Promise((
|
|
45018
|
+
return new Promise((resolve6, reject) => {
|
|
44831
45019
|
let ending = null;
|
|
44832
45020
|
const stop = (next) => {
|
|
44833
45021
|
if (ending !== null) return;
|
|
@@ -44852,7 +45040,7 @@ function createGitRunner(options) {
|
|
|
44852
45040
|
signal.removeEventListener("abort", onAbort);
|
|
44853
45041
|
const final = ending ?? last;
|
|
44854
45042
|
if (final.kind === "exited") {
|
|
44855
|
-
|
|
45043
|
+
resolve6({ exitCode: final.exitCode, stdout: stdout.text(), stderr: stderr.text() });
|
|
44856
45044
|
} else {
|
|
44857
45045
|
reject(faultFor(final, command));
|
|
44858
45046
|
}
|
|
@@ -44874,9 +45062,97 @@ function createGitRunner(options) {
|
|
|
44874
45062
|
};
|
|
44875
45063
|
}
|
|
44876
45064
|
|
|
44877
|
-
// src/
|
|
45065
|
+
// src/capabilities/git/checkout-freshness.ts
|
|
44878
45066
|
var import_node_crypto3 = require("crypto");
|
|
44879
45067
|
var import_promises7 = require("fs/promises");
|
|
45068
|
+
var import_node_path3 = require("path");
|
|
45069
|
+
init_zod();
|
|
45070
|
+
var REMOTE = "origin";
|
|
45071
|
+
var snapshotSchema = external_exports.object({
|
|
45072
|
+
branch: external_exports.string().min(1),
|
|
45073
|
+
base: external_exports.string().min(1),
|
|
45074
|
+
head: external_exports.string().min(1),
|
|
45075
|
+
published: external_exports.string(),
|
|
45076
|
+
shallow: external_exports.boolean(),
|
|
45077
|
+
commonDir: external_exports.string().min(1)
|
|
45078
|
+
});
|
|
45079
|
+
var freshnessSchema = external_exports.discriminatedUnion("state", [
|
|
45080
|
+
external_exports.object({ state: external_exports.literal("checking"), path: external_exports.string() }),
|
|
45081
|
+
external_exports.object({ state: external_exports.literal("kept"), path: external_exports.string(), reason: external_exports.string() }),
|
|
45082
|
+
external_exports.object({ state: external_exports.literal("current"), path: external_exports.string(), snapshot: snapshotSchema }),
|
|
45083
|
+
external_exports.object({
|
|
45084
|
+
state: external_exports.literal("behind"),
|
|
45085
|
+
path: external_exports.string(),
|
|
45086
|
+
snapshot: snapshotSchema,
|
|
45087
|
+
tip: external_exports.string().min(1),
|
|
45088
|
+
fetched: external_exports.boolean()
|
|
45089
|
+
}),
|
|
45090
|
+
external_exports.object({
|
|
45091
|
+
state: external_exports.literal("failed"),
|
|
45092
|
+
path: external_exports.string(),
|
|
45093
|
+
snapshot: snapshotSchema.optional(),
|
|
45094
|
+
reason: external_exports.string()
|
|
45095
|
+
})
|
|
45096
|
+
]);
|
|
45097
|
+
function freshnessFile(dir, path) {
|
|
45098
|
+
return (0, import_node_path3.join)(dir, `${(0, import_node_crypto3.createHash)("sha256").update(path).digest("hex").slice(0, 32)}.json`);
|
|
45099
|
+
}
|
|
45100
|
+
function parseStatus(stdout) {
|
|
45101
|
+
const lines = stdout.split("\n").filter((line) => line.length > 0);
|
|
45102
|
+
const header = /* @__PURE__ */ new Map();
|
|
45103
|
+
for (const line of lines) {
|
|
45104
|
+
const [hash2, key, value] = line.split(" ");
|
|
45105
|
+
if (hash2 === "#" && key !== void 0 && value !== void 0) header.set(key, value);
|
|
45106
|
+
}
|
|
45107
|
+
const head = header.get("branch.oid");
|
|
45108
|
+
const branch = header.get("branch.head");
|
|
45109
|
+
const upstream = header.get("branch.upstream") ?? "";
|
|
45110
|
+
return {
|
|
45111
|
+
head: head === void 0 || head === "(initial)" ? null : head,
|
|
45112
|
+
branch: branch === void 0 || branch === "(detached)" ? null : branch,
|
|
45113
|
+
base: upstream.startsWith(`${REMOTE}/`) ? upstream.slice(REMOTE.length + 1) : null,
|
|
45114
|
+
ahead: Number(header.get("branch.ab")?.slice(1) ?? 0),
|
|
45115
|
+
dirty: lines.some((line) => !line.startsWith("# "))
|
|
45116
|
+
};
|
|
45117
|
+
}
|
|
45118
|
+
async function readCheckoutStatus(git, cwd, signal) {
|
|
45119
|
+
const output2 = await git.run(
|
|
45120
|
+
{
|
|
45121
|
+
cwd,
|
|
45122
|
+
args: ["status", "--porcelain=v2", "--branch", "--untracked-files=no"],
|
|
45123
|
+
readOnly: true
|
|
45124
|
+
},
|
|
45125
|
+
signal
|
|
45126
|
+
);
|
|
45127
|
+
return output2.exitCode === 0 ? parseStatus(output2.stdout) : null;
|
|
45128
|
+
}
|
|
45129
|
+
async function isCheckout(path) {
|
|
45130
|
+
return (0, import_promises7.stat)((0, import_node_path3.join)(path, ".git")).then(
|
|
45131
|
+
() => true,
|
|
45132
|
+
() => false
|
|
45133
|
+
);
|
|
45134
|
+
}
|
|
45135
|
+
async function checkoutsUnder(root) {
|
|
45136
|
+
if (await isCheckout(root)) return [root];
|
|
45137
|
+
const entries = await (0, import_promises7.readdir)(root, { withFileTypes: true }).catch(() => []);
|
|
45138
|
+
const found = await Promise.all(
|
|
45139
|
+
entries.filter((entry) => entry.isDirectory()).map(
|
|
45140
|
+
async (entry) => await isCheckout((0, import_node_path3.join)(root, entry.name)) ? (0, import_node_path3.join)(root, entry.name) : null
|
|
45141
|
+
)
|
|
45142
|
+
);
|
|
45143
|
+
return found.filter((path) => path !== null);
|
|
45144
|
+
}
|
|
45145
|
+
async function readCheckoutFreshness(dir, path) {
|
|
45146
|
+
for (let current = path; ; current = (0, import_node_path3.dirname)(current)) {
|
|
45147
|
+
const read = await readJsonFile(freshnessFile(dir, current), freshnessSchema);
|
|
45148
|
+
if (read.kind === "ok") return read.value;
|
|
45149
|
+
if ((0, import_node_path3.dirname)(current) === current) return null;
|
|
45150
|
+
}
|
|
45151
|
+
}
|
|
45152
|
+
|
|
45153
|
+
// src/platform/credential-store/credential-store.ts
|
|
45154
|
+
var import_node_crypto4 = require("crypto");
|
|
45155
|
+
var import_promises8 = require("fs/promises");
|
|
44880
45156
|
|
|
44881
45157
|
// src/platform/credential-store/parse.ts
|
|
44882
45158
|
function parseStoredJson(text2, schema) {
|
|
@@ -44892,16 +45168,16 @@ function parseStoredJson(text2, schema) {
|
|
|
44892
45168
|
|
|
44893
45169
|
// src/platform/windows-helper.ts
|
|
44894
45170
|
var import_node_fs3 = require("fs");
|
|
44895
|
-
var
|
|
45171
|
+
var import_node_path4 = require("path");
|
|
44896
45172
|
var import_node_url = require("url");
|
|
44897
45173
|
var import_meta = {};
|
|
44898
45174
|
function windowsHelperPath(entry = process.argv[1]) {
|
|
44899
|
-
const packaged = entry === void 0 ? null : (0,
|
|
45175
|
+
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");
|
|
44900
45176
|
if (entry !== void 0) {
|
|
44901
45177
|
if (packaged !== null && (0, import_node_fs3.existsSync)(packaged)) return packaged;
|
|
44902
45178
|
}
|
|
44903
45179
|
try {
|
|
44904
|
-
const local = (0,
|
|
45180
|
+
const local = (0, import_node_path4.resolve)((0, import_node_path4.dirname)((0, import_node_url.fileURLToPath)(import_meta.url)), "../../dist/alan-winhelper.exe");
|
|
44905
45181
|
return (0, import_node_fs3.existsSync)(local) ? local : packaged;
|
|
44906
45182
|
} catch {
|
|
44907
45183
|
return packaged;
|
|
@@ -44969,13 +45245,13 @@ function createFileCredentialStore(path) {
|
|
|
44969
45245
|
kind: "file",
|
|
44970
45246
|
read: (schema) => readJsonFile(path, schema),
|
|
44971
45247
|
write: (value) => writeJsonFileAtomic(path, value),
|
|
44972
|
-
clear: () => (0,
|
|
45248
|
+
clear: () => (0, import_promises8.rm)(path, { force: true })
|
|
44973
45249
|
};
|
|
44974
45250
|
}
|
|
44975
45251
|
var KEYCHAIN_SERVICE = "ai.tryalan.runtime";
|
|
44976
45252
|
var KEYCHAIN_NOT_FOUND = 44;
|
|
44977
45253
|
function keychainAccount(stateDir) {
|
|
44978
|
-
return `state-${(0,
|
|
45254
|
+
return `state-${(0, import_node_crypto4.createHash)("sha256").update(stateDir).digest("hex").slice(0, 16)}`;
|
|
44979
45255
|
}
|
|
44980
45256
|
function windowsCredentialTarget(stateDir) {
|
|
44981
45257
|
return `${KEYCHAIN_SERVICE}/${keychainAccount(stateDir.toLowerCase())}`;
|
|
@@ -45062,16 +45338,16 @@ function defaultCredentialStoreKind(platform) {
|
|
|
45062
45338
|
|
|
45063
45339
|
// src/platform/install.ts
|
|
45064
45340
|
var import_node_child_process3 = require("child_process");
|
|
45065
|
-
var
|
|
45341
|
+
var import_node_crypto5 = require("crypto");
|
|
45066
45342
|
var import_node_fs4 = require("fs");
|
|
45067
|
-
var
|
|
45068
|
-
var
|
|
45343
|
+
var import_promises10 = require("fs/promises");
|
|
45344
|
+
var import_node_path5 = require("path");
|
|
45069
45345
|
var import_node_util2 = require("util");
|
|
45070
45346
|
init_zod();
|
|
45071
45347
|
|
|
45072
45348
|
// src/platform/process-identity.ts
|
|
45073
45349
|
var import_node_child_process2 = require("child_process");
|
|
45074
|
-
var
|
|
45350
|
+
var import_promises9 = require("fs/promises");
|
|
45075
45351
|
var import_node_util = require("util");
|
|
45076
45352
|
var execFileAsync = (0, import_node_util.promisify)(import_node_child_process2.execFile);
|
|
45077
45353
|
function isProcessAlive(pid) {
|
|
@@ -45083,13 +45359,13 @@ function isProcessAlive(pid) {
|
|
|
45083
45359
|
}
|
|
45084
45360
|
}
|
|
45085
45361
|
async function linuxStartTime(pid) {
|
|
45086
|
-
const
|
|
45087
|
-
if (
|
|
45088
|
-
const fields =
|
|
45362
|
+
const stat14 = await (0, import_promises9.readFile)(`/proc/${pid}/stat`, "utf8").catch(() => null);
|
|
45363
|
+
if (stat14 === null) return null;
|
|
45364
|
+
const fields = stat14.slice(stat14.lastIndexOf(")") + 2).split(" ");
|
|
45089
45365
|
return fields[19] ?? null;
|
|
45090
45366
|
}
|
|
45091
45367
|
async function linuxCommand(pid) {
|
|
45092
|
-
const raw = await (0,
|
|
45368
|
+
const raw = await (0, import_promises9.readFile)(`/proc/${pid}/cmdline`, "utf8").catch(() => null);
|
|
45093
45369
|
return raw === null ? null : normalizeCommand(raw.replaceAll("\0", " "));
|
|
45094
45370
|
}
|
|
45095
45371
|
async function darwinCommand(pid) {
|
|
@@ -45183,11 +45459,11 @@ async function mayBeSameProcess(expected, probe = systemProcessProbe) {
|
|
|
45183
45459
|
var execFileAsync2 = (0, import_node_util2.promisify)(import_node_child_process3.execFile);
|
|
45184
45460
|
var packageJsonSchema = external_exports.object({ version: external_exports.string().min(1) });
|
|
45185
45461
|
function markVersionInUse(bundlePath) {
|
|
45186
|
-
const versionDir = (0,
|
|
45187
|
-
if ((0,
|
|
45462
|
+
const versionDir = (0, import_node_path5.dirname)(bundlePath);
|
|
45463
|
+
if ((0, import_node_path5.basename)((0, import_node_path5.dirname)(versionDir)) !== "versions") return { [Symbol.dispose]: () => {
|
|
45188
45464
|
} };
|
|
45189
|
-
const marker = (0,
|
|
45190
|
-
(0, import_node_fs4.mkdirSync)((0,
|
|
45465
|
+
const marker = (0, import_node_path5.join)(versionDir, ".running", String(process.pid));
|
|
45466
|
+
(0, import_node_fs4.mkdirSync)((0, import_node_path5.dirname)(marker), { recursive: true, mode: 448 });
|
|
45191
45467
|
(0, import_node_fs4.writeFileSync)(marker, "");
|
|
45192
45468
|
const remove = () => (0, import_node_fs4.rmSync)(marker, { force: true });
|
|
45193
45469
|
process.once("exit", remove);
|
|
@@ -45200,39 +45476,39 @@ function markVersionInUse(bundlePath) {
|
|
|
45200
45476
|
}
|
|
45201
45477
|
|
|
45202
45478
|
// src/platform/ipc-endpoint.ts
|
|
45203
|
-
var
|
|
45479
|
+
var import_node_crypto6 = require("crypto");
|
|
45204
45480
|
var import_node_fs5 = require("fs");
|
|
45205
45481
|
var import_node_os = require("os");
|
|
45206
|
-
var
|
|
45482
|
+
var import_node_path6 = require("path");
|
|
45207
45483
|
function removeStaleEndpoint(endpoint) {
|
|
45208
45484
|
if (!endpoint.startsWith("\\\\.\\pipe\\")) (0, import_node_fs5.rmSync)(endpoint, { force: true });
|
|
45209
45485
|
}
|
|
45210
45486
|
|
|
45211
45487
|
// src/platform/paths.ts
|
|
45212
|
-
var
|
|
45488
|
+
var import_node_path7 = require("path");
|
|
45213
45489
|
function runtimePaths(stateDir) {
|
|
45214
45490
|
return {
|
|
45215
45491
|
stateDir,
|
|
45216
|
-
lock: (0,
|
|
45217
|
-
machine: (0,
|
|
45218
|
-
credential: (0,
|
|
45219
|
-
runs: (0,
|
|
45220
|
-
sessions: (0,
|
|
45221
|
-
sockets: (0,
|
|
45222
|
-
logs: (0,
|
|
45223
|
-
tmp: (0,
|
|
45492
|
+
lock: (0, import_node_path7.join)(stateDir, "runtime.lock"),
|
|
45493
|
+
machine: (0, import_node_path7.join)(stateDir, "machine.json"),
|
|
45494
|
+
credential: (0, import_node_path7.join)(stateDir, "credential.json"),
|
|
45495
|
+
runs: (0, import_node_path7.join)(stateDir, "runs"),
|
|
45496
|
+
sessions: (0, import_node_path7.join)(stateDir, "sessions"),
|
|
45497
|
+
sockets: (0, import_node_path7.join)(stateDir, "s"),
|
|
45498
|
+
logs: (0, import_node_path7.join)(stateDir, "logs"),
|
|
45499
|
+
tmp: (0, import_node_path7.join)(stateDir, "tmp")
|
|
45224
45500
|
};
|
|
45225
45501
|
}
|
|
45226
45502
|
|
|
45227
45503
|
// src/platform/process-memory.ts
|
|
45228
45504
|
var import_node_child_process4 = require("child_process");
|
|
45229
|
-
var
|
|
45505
|
+
var import_promises11 = require("fs/promises");
|
|
45230
45506
|
var import_node_util3 = require("util");
|
|
45231
45507
|
var execFileAsync3 = (0, import_node_util3.promisify)(import_node_child_process4.execFile);
|
|
45232
45508
|
var PROBE_TIMEOUT_MS = 2e3;
|
|
45233
45509
|
async function readProcessRss(pid) {
|
|
45234
45510
|
if (process.platform === "linux") {
|
|
45235
|
-
const status = await (0,
|
|
45511
|
+
const status = await (0, import_promises11.readFile)(`/proc/${pid}/status`, "utf8").catch(() => null);
|
|
45236
45512
|
const kilobytes = status === null ? void 0 : /^VmRSS:\s+(\d+)\s+kB$/m.exec(status)?.[1];
|
|
45237
45513
|
return kilobytes === void 0 ? null : Number(kilobytes) * 1024;
|
|
45238
45514
|
}
|
|
@@ -45249,7 +45525,7 @@ async function readProcessRss(pid) {
|
|
|
45249
45525
|
}
|
|
45250
45526
|
|
|
45251
45527
|
// src/platform/runtime-host.ts
|
|
45252
|
-
var
|
|
45528
|
+
var import_promises12 = require("fs/promises");
|
|
45253
45529
|
var RUNTIME_HOST_KINDS = ["app", "standalone"];
|
|
45254
45530
|
|
|
45255
45531
|
// src/platform/service/exec.ts
|
|
@@ -45264,7 +45540,7 @@ function statusOf(error61) {
|
|
|
45264
45540
|
}
|
|
45265
45541
|
return 1;
|
|
45266
45542
|
}
|
|
45267
|
-
var systemExec = (request2) => new Promise((
|
|
45543
|
+
var systemExec = (request2) => new Promise((resolve6) => {
|
|
45268
45544
|
const child = (0, import_node_child_process5.execFile)(
|
|
45269
45545
|
request2.command,
|
|
45270
45546
|
[...request2.args],
|
|
@@ -45275,7 +45551,7 @@ var systemExec = (request2) => new Promise((resolve5) => {
|
|
|
45275
45551
|
windowsHide: true
|
|
45276
45552
|
},
|
|
45277
45553
|
(error61, stdout, stderr) => {
|
|
45278
|
-
|
|
45554
|
+
resolve6({ status: statusOf(error61), stdout, stderr });
|
|
45279
45555
|
}
|
|
45280
45556
|
);
|
|
45281
45557
|
child.stdin?.on("error", () => {
|
|
@@ -45288,8 +45564,8 @@ init_alan_code();
|
|
|
45288
45564
|
|
|
45289
45565
|
// src/capabilities/providers/commands.ts
|
|
45290
45566
|
var import_node_fs6 = require("fs");
|
|
45291
|
-
var
|
|
45292
|
-
var
|
|
45567
|
+
var import_promises16 = require("fs/promises");
|
|
45568
|
+
var import_node_path8 = require("path");
|
|
45293
45569
|
var PROVIDER_COMMANDS = [
|
|
45294
45570
|
// The engine, not a CLI of its own: `resolveProviderExecutable` finds the bundled one first.
|
|
45295
45571
|
{ backendKind: "alan_code", command: "opencode", name: "Alan Code" },
|
|
@@ -45322,8 +45598,8 @@ function pathDelimiter(platform) {
|
|
|
45322
45598
|
}
|
|
45323
45599
|
async function isRunnable(path, platform) {
|
|
45324
45600
|
try {
|
|
45325
|
-
if (!(await (0,
|
|
45326
|
-
if (platform !== "win32") await (0,
|
|
45601
|
+
if (!(await (0, import_promises16.stat)(path)).isFile()) return false;
|
|
45602
|
+
if (platform !== "win32") await (0, import_promises16.access)(path, import_node_fs6.constants.X_OK);
|
|
45327
45603
|
return true;
|
|
45328
45604
|
} catch {
|
|
45329
45605
|
return false;
|
|
@@ -45339,7 +45615,7 @@ async function resolveCommandOnPath(command, env, platform) {
|
|
|
45339
45615
|
const extensions = platform === "win32" ? windowsExtensions(command, env) : [""];
|
|
45340
45616
|
for (const directory of directories) {
|
|
45341
45617
|
for (const extension of extensions) {
|
|
45342
|
-
const candidate = (0,
|
|
45618
|
+
const candidate = (0, import_node_path8.join)(directory, `${command}${extension}`);
|
|
45343
45619
|
if (await isRunnable(candidate, platform)) return candidate;
|
|
45344
45620
|
}
|
|
45345
45621
|
}
|
|
@@ -45374,15 +45650,15 @@ function resolveProviderExecutable(provider4, env, platform) {
|
|
|
45374
45650
|
|
|
45375
45651
|
// src/capabilities/providers/managed.ts
|
|
45376
45652
|
var import_node_child_process6 = require("child_process");
|
|
45377
|
-
var
|
|
45378
|
-
var
|
|
45379
|
-
var
|
|
45653
|
+
var import_node_crypto7 = require("crypto");
|
|
45654
|
+
var import_promises17 = require("fs/promises");
|
|
45655
|
+
var import_node_path9 = require("path");
|
|
45380
45656
|
init_zod();
|
|
45381
45657
|
var VERSION = /^[0-9]+\.[0-9]+\.[0-9]+(?:[-+][0-9A-Za-z.-]+)?$/;
|
|
45382
45658
|
var selectedSchema = external_exports.record(external_exports.string(), external_exports.string());
|
|
45383
45659
|
async function readManagedProviderVersion(file2, backendKind) {
|
|
45384
45660
|
try {
|
|
45385
|
-
const selected = selectedSchema.parse(JSON.parse(await (0,
|
|
45661
|
+
const selected = selectedSchema.parse(JSON.parse(await (0, import_promises17.readFile)(file2, "utf8")));
|
|
45386
45662
|
const version2 = selected[backendKind];
|
|
45387
45663
|
return version2 !== void 0 && VERSION.test(version2) ? version2 : null;
|
|
45388
45664
|
} catch {
|
|
@@ -45392,9 +45668,9 @@ async function readManagedProviderVersion(file2, backendKind) {
|
|
|
45392
45668
|
|
|
45393
45669
|
// ../shared/dist/node/skill-package.js
|
|
45394
45670
|
var import_node_buffer = require("buffer");
|
|
45395
|
-
var
|
|
45396
|
-
var
|
|
45397
|
-
var
|
|
45671
|
+
var import_node_crypto8 = require("crypto");
|
|
45672
|
+
var import_promises18 = require("fs/promises");
|
|
45673
|
+
var import_node_path10 = require("path");
|
|
45398
45674
|
var import_yaml = __toESM(require_dist(), 1);
|
|
45399
45675
|
init_contracts();
|
|
45400
45676
|
init_domain();
|
|
@@ -45465,7 +45741,7 @@ async function inspectSkillPackage(packageRoot, options = {}) {
|
|
|
45465
45741
|
}
|
|
45466
45742
|
const inspectedFiles = await Promise.all(files.map(readPackageFile));
|
|
45467
45743
|
inspectedFiles.sort(comparePackageFiles);
|
|
45468
|
-
const parsedMetadata = parseSkillMetadata(inspectedFiles.find((file2) => file2.manifest.path === "SKILL.md")?.bytes, options.expectedName === void 0 ? (0,
|
|
45744
|
+
const parsedMetadata = parseSkillMetadata(inspectedFiles.find((file2) => file2.manifest.path === "SKILL.md")?.bytes, options.expectedName === void 0 ? (0, import_node_path10.basename)(root) : options.expectedName);
|
|
45469
45745
|
const manifestFiles = inspectedFiles.map((file2) => file2.manifest);
|
|
45470
45746
|
const diagnostics = [
|
|
45471
45747
|
...parsedMetadata.conformance,
|
|
@@ -45483,11 +45759,11 @@ async function inspectSkillPackage(packageRoot, options = {}) {
|
|
|
45483
45759
|
};
|
|
45484
45760
|
}
|
|
45485
45761
|
async function requirePackageRoot(packageRoot) {
|
|
45486
|
-
const root = await (0,
|
|
45762
|
+
const root = await (0, import_promises18.realpath)((0, import_node_path10.resolve)(packageRoot)).catch(() => null);
|
|
45487
45763
|
if (!root) {
|
|
45488
45764
|
throw new SkillPackageError("INVALID_PACKAGE_ROOT", "Skill package directory does not exist");
|
|
45489
45765
|
}
|
|
45490
|
-
const rootStat = await (0,
|
|
45766
|
+
const rootStat = await (0, import_promises18.lstat)(root);
|
|
45491
45767
|
if (!rootStat.isDirectory()) {
|
|
45492
45768
|
throw new SkillPackageError("INVALID_PACKAGE_ROOT", "Skill package root must be a directory");
|
|
45493
45769
|
}
|
|
@@ -45507,13 +45783,13 @@ async function walkPackage(root, ignoredPaths) {
|
|
|
45507
45783
|
}
|
|
45508
45784
|
return files;
|
|
45509
45785
|
async function walkDirectory(directory) {
|
|
45510
|
-
const entries = await (0,
|
|
45786
|
+
const entries = await (0, import_promises18.readdir)(directory, { withFileTypes: true });
|
|
45511
45787
|
for (const entry of entries) {
|
|
45512
|
-
const absolutePath = (0,
|
|
45788
|
+
const absolutePath = (0, import_node_path10.resolve)(directory, entry.name);
|
|
45513
45789
|
const normalizedPath = normalizeRelativePath(root, absolutePath);
|
|
45514
45790
|
if (isIgnored(normalizedPath, entry.name, entry.isDirectory(), ignored2))
|
|
45515
45791
|
continue;
|
|
45516
|
-
const entryStat = await (0,
|
|
45792
|
+
const entryStat = await (0, import_promises18.lstat)(absolutePath);
|
|
45517
45793
|
if (entryStat.isSymbolicLink()) {
|
|
45518
45794
|
throw new SkillPackageError("SYMLINK_BLOCKED", `Nested symbolic links are not allowed in Skill packages: ${normalizedPath}`, normalizedPath);
|
|
45519
45795
|
}
|
|
@@ -45576,12 +45852,12 @@ function globToRegExp(pattern) {
|
|
|
45576
45852
|
return new RegExp(`${source}(?:/.*)?$`);
|
|
45577
45853
|
}
|
|
45578
45854
|
function normalizeRelativePath(root, absolutePath) {
|
|
45579
|
-
const nativeRelativePath = (0,
|
|
45580
|
-
if (!nativeRelativePath || nativeRelativePath.startsWith(`..${
|
|
45855
|
+
const nativeRelativePath = (0, import_node_path10.relative)(root, absolutePath);
|
|
45856
|
+
if (!nativeRelativePath || nativeRelativePath.startsWith(`..${import_node_path10.sep}`) || nativeRelativePath === "..") {
|
|
45581
45857
|
throw new SkillPackageError("INVALID_PATH", "Skill package path escapes its root");
|
|
45582
45858
|
}
|
|
45583
|
-
const normalized2 = nativeRelativePath.split(
|
|
45584
|
-
if (normalized2.includes("\0") || normalized2.includes("\uFFFD") ||
|
|
45859
|
+
const normalized2 = nativeRelativePath.split(import_node_path10.sep).join("/").normalize("NFC");
|
|
45860
|
+
if (normalized2.includes("\0") || normalized2.includes("\uFFFD") || import_node_path10.posix.isAbsolute(normalized2)) {
|
|
45585
45861
|
throw new SkillPackageError("INVALID_PATH", `Invalid Skill package path: ${normalized2}`);
|
|
45586
45862
|
}
|
|
45587
45863
|
return normalized2;
|
|
@@ -45616,13 +45892,13 @@ function requireSafeFile(path, size, normalizedPaths) {
|
|
|
45616
45892
|
}
|
|
45617
45893
|
}
|
|
45618
45894
|
function isSecretPath(path) {
|
|
45619
|
-
const name =
|
|
45895
|
+
const name = import_node_path10.posix.basename(path).toLowerCase();
|
|
45620
45896
|
if (SECRET_BASENAMES.has(name) || name.startsWith(".env."))
|
|
45621
45897
|
return true;
|
|
45622
45898
|
return name.endsWith(".private-key.pem") || name.endsWith(".private-key.key");
|
|
45623
45899
|
}
|
|
45624
45900
|
async function readPackageFile(file2) {
|
|
45625
|
-
const bytes = await (0,
|
|
45901
|
+
const bytes = await (0, import_promises18.readFile)(file2.absolutePath);
|
|
45626
45902
|
return {
|
|
45627
45903
|
bytes,
|
|
45628
45904
|
manifest: {
|
|
@@ -45644,12 +45920,12 @@ function classifyFileKind(path) {
|
|
|
45644
45920
|
return "reference";
|
|
45645
45921
|
if (path.startsWith("assets/"))
|
|
45646
45922
|
return "asset";
|
|
45647
|
-
if (/^(?:licen[cs]e|copying|notice)(?:\.|$)/i.test(
|
|
45923
|
+
if (/^(?:licen[cs]e|copying|notice)(?:\.|$)/i.test(import_node_path10.posix.basename(path)))
|
|
45648
45924
|
return "license";
|
|
45649
45925
|
return "other";
|
|
45650
45926
|
}
|
|
45651
45927
|
function classifyPreview(path, bytes) {
|
|
45652
|
-
const extension =
|
|
45928
|
+
const extension = import_node_path10.posix.extname(path).toLowerCase();
|
|
45653
45929
|
if (IMAGE_EXTENSIONS2.has(extension))
|
|
45654
45930
|
return "image";
|
|
45655
45931
|
if (bytes.includes(0))
|
|
@@ -45753,7 +46029,7 @@ function normalizePackageReference(value) {
|
|
|
45753
46029
|
const withoutSuffix = trimmed4.split(/[?#]/, 1)[0];
|
|
45754
46030
|
if (!withoutSuffix)
|
|
45755
46031
|
return null;
|
|
45756
|
-
const normalized2 =
|
|
46032
|
+
const normalized2 = import_node_path10.posix.normalize(withoutSuffix).replace(/^\.\//, "").normalize("NFC");
|
|
45757
46033
|
if (normalized2 === ".." || normalized2.startsWith("../"))
|
|
45758
46034
|
return null;
|
|
45759
46035
|
return normalized2;
|
|
@@ -45765,7 +46041,7 @@ function comparePackageFiles(left, right) {
|
|
|
45765
46041
|
return import_node_buffer.Buffer.compare(import_node_buffer.Buffer.from(left.manifest.path, "utf8"), import_node_buffer.Buffer.from(right.manifest.path, "utf8"));
|
|
45766
46042
|
}
|
|
45767
46043
|
function hashPackageTree(files) {
|
|
45768
|
-
const hash2 = (0,
|
|
46044
|
+
const hash2 = (0, import_node_crypto8.createHash)("sha256");
|
|
45769
46045
|
hash2.update(TREE_HASH_PREFIX);
|
|
45770
46046
|
for (const file2 of files) {
|
|
45771
46047
|
const path = import_node_buffer.Buffer.from(file2.path, "utf8");
|
|
@@ -45778,7 +46054,7 @@ function hashPackageTree(files) {
|
|
|
45778
46054
|
return `sha256:${hash2.digest("hex")}`;
|
|
45779
46055
|
}
|
|
45780
46056
|
function sha256(bytes) {
|
|
45781
|
-
return `sha256:${(0,
|
|
46057
|
+
return `sha256:${(0, import_node_crypto8.createHash)("sha256").update(bytes).digest("hex")}`;
|
|
45782
46058
|
}
|
|
45783
46059
|
function uint322(value) {
|
|
45784
46060
|
const buffer = import_node_buffer.Buffer.allocUnsafe(4);
|
|
@@ -45792,22 +46068,39 @@ function uint642(value) {
|
|
|
45792
46068
|
}
|
|
45793
46069
|
|
|
45794
46070
|
// src/capabilities/skills/store.ts
|
|
45795
|
-
var
|
|
45796
|
-
var
|
|
46071
|
+
var import_promises19 = require("fs/promises");
|
|
46072
|
+
var import_node_path11 = require("path");
|
|
46073
|
+
|
|
46074
|
+
// ../shared/dist/node/alan-skill-identity.js
|
|
46075
|
+
var import_node_crypto9 = require("crypto");
|
|
46076
|
+
var ALAN_SKILL_NAMESPACE = "ec71d99b-d207-4ca2-a9eb-3a7bed4a73fd";
|
|
46077
|
+
function uuidV5(name, namespace) {
|
|
46078
|
+
const bytes = (0, import_node_crypto9.createHash)("sha1").update(Buffer.from(namespace.replaceAll("-", ""), "hex")).update(name, "utf8").digest().subarray(0, 16);
|
|
46079
|
+
bytes[6] = bytes[6] & 15 | 80;
|
|
46080
|
+
bytes[8] = bytes[8] & 63 | 128;
|
|
46081
|
+
const hex3 = bytes.toString("hex");
|
|
46082
|
+
return `${hex3.slice(0, 8)}-${hex3.slice(8, 12)}-${hex3.slice(12, 16)}-${hex3.slice(16, 20)}-${hex3.slice(20)}`;
|
|
46083
|
+
}
|
|
46084
|
+
function alanSkillId(slug) {
|
|
46085
|
+
return uuidV5(`alan:${slug}`, ALAN_SKILL_NAMESPACE);
|
|
46086
|
+
}
|
|
46087
|
+
|
|
46088
|
+
// src/capabilities/skills/store.ts
|
|
45797
46089
|
init_runtime_v2();
|
|
45798
46090
|
init_zod();
|
|
45799
|
-
function skillsLayout(stateDir) {
|
|
45800
|
-
const root = (0,
|
|
46091
|
+
function skillsLayout(stateDir, home) {
|
|
46092
|
+
const root = (0, import_node_path11.join)(stateDir, "skills");
|
|
45801
46093
|
return {
|
|
45802
46094
|
root,
|
|
45803
|
-
installedFile: (0,
|
|
45804
|
-
localFile: (0,
|
|
45805
|
-
versionsDir: (0,
|
|
45806
|
-
tmpDir: (0,
|
|
46095
|
+
installedFile: (0, import_node_path11.join)(root, "installed.json"),
|
|
46096
|
+
localFile: (0, import_node_path11.join)(root, "local.json"),
|
|
46097
|
+
versionsDir: (0, import_node_path11.join)(root, "versions"),
|
|
46098
|
+
tmpDir: (0, import_node_path11.join)(root, "tmp"),
|
|
46099
|
+
nativeDir: home === void 0 || home === "" ? null : (0, import_node_path11.join)(home, ".agents", "skills")
|
|
45807
46100
|
};
|
|
45808
46101
|
}
|
|
45809
46102
|
function packageDirectory(layout, versionId) {
|
|
45810
|
-
return (0,
|
|
46103
|
+
return (0, import_node_path11.join)(layout.versionsDir, versionId);
|
|
45811
46104
|
}
|
|
45812
46105
|
var installedFileSchema = external_exports.object({ skills: external_exports.array(desiredMachineSkillSchema) });
|
|
45813
46106
|
async function readInstalledSkills(layout) {
|
|
@@ -45834,7 +46127,7 @@ async function readLocalSkills(layout) {
|
|
|
45834
46127
|
async function isLocalSkillCurrent(entry, contentHash, ignoredPaths) {
|
|
45835
46128
|
if (entry.contentHash !== contentHash) return false;
|
|
45836
46129
|
try {
|
|
45837
|
-
if (await (0,
|
|
46130
|
+
if (await (0, import_promises19.realpath)(entry.path) !== entry.path) return false;
|
|
45838
46131
|
const inspected = await inspectSkillPackage(entry.path, { expectedName: null, ignoredPaths });
|
|
45839
46132
|
return inspected.contentHash === contentHash;
|
|
45840
46133
|
} catch {
|
|
@@ -45849,7 +46142,7 @@ async function resolveLocalSkill(local, invocation) {
|
|
|
45849
46142
|
}
|
|
45850
46143
|
async function hasSkillFile(directory) {
|
|
45851
46144
|
try {
|
|
45852
|
-
return (await (0,
|
|
46145
|
+
return (await (0, import_promises19.stat)((0, import_node_path11.join)(directory, "SKILL.md"))).isFile();
|
|
45853
46146
|
} catch {
|
|
45854
46147
|
return false;
|
|
45855
46148
|
}
|
|
@@ -45864,6 +46157,17 @@ async function isIntact(layout, skill) {
|
|
|
45864
46157
|
return false;
|
|
45865
46158
|
}
|
|
45866
46159
|
}
|
|
46160
|
+
async function resolveNativeBuiltIn(layout, invocation) {
|
|
46161
|
+
const slug = invocation.displayName;
|
|
46162
|
+
if (layout.nativeDir === null || invocation.skillId !== alanSkillId(slug)) return null;
|
|
46163
|
+
const directory = (0, import_node_path11.join)(layout.nativeDir, slug);
|
|
46164
|
+
try {
|
|
46165
|
+
await inspectSkillPackage(directory, { expectedName: slug });
|
|
46166
|
+
return { packageDirectory: directory };
|
|
46167
|
+
} catch {
|
|
46168
|
+
return null;
|
|
46169
|
+
}
|
|
46170
|
+
}
|
|
45867
46171
|
async function resolveSkillInvocations(layout, invocations) {
|
|
45868
46172
|
if (invocations.length === 0) return { kind: "resolved", skills: [] };
|
|
45869
46173
|
const installed = await readInstalledSkills(layout);
|
|
@@ -45882,22 +46186,24 @@ async function resolveSkillInvocations(layout, invocations) {
|
|
|
45882
46186
|
);
|
|
45883
46187
|
if (skill !== void 0 && await isIntact(layout, skill)) {
|
|
45884
46188
|
resolved.push({ packageDirectory: packageDirectory(layout, skill.versionId) });
|
|
45885
|
-
|
|
45886
|
-
missing.push(invocation.displayName);
|
|
46189
|
+
continue;
|
|
45887
46190
|
}
|
|
46191
|
+
const native = await resolveNativeBuiltIn(layout, invocation);
|
|
46192
|
+
if (native === null) missing.push(invocation.displayName);
|
|
46193
|
+
else resolved.push(native);
|
|
45888
46194
|
}
|
|
45889
46195
|
return missing.length === 0 ? { kind: "resolved", skills: resolved } : { kind: "missing", names: missing };
|
|
45890
46196
|
}
|
|
45891
46197
|
|
|
45892
46198
|
// src/capabilities/workspace/index.ts
|
|
45893
|
-
var
|
|
46199
|
+
var import_node_path14 = require("path");
|
|
45894
46200
|
|
|
45895
46201
|
// src/capabilities/workspace/approved-paths.ts
|
|
45896
|
-
var
|
|
46202
|
+
var import_promises20 = require("fs/promises");
|
|
45897
46203
|
init_zod();
|
|
45898
46204
|
|
|
45899
46205
|
// src/capabilities/workspace/paths.ts
|
|
45900
|
-
var
|
|
46206
|
+
var import_node_path12 = require("path");
|
|
45901
46207
|
function stripWin32Namespace(path) {
|
|
45902
46208
|
if (/^\\\\\?\\UNC\\/i.test(path)) return `\\\\${path.slice(8)}`;
|
|
45903
46209
|
if (path.startsWith("\\\\?\\")) return path.slice(4);
|
|
@@ -45905,15 +46211,15 @@ function stripWin32Namespace(path) {
|
|
|
45905
46211
|
}
|
|
45906
46212
|
function comparablePath(path, platform) {
|
|
45907
46213
|
if (platform === "win32") {
|
|
45908
|
-
const normalized3 =
|
|
46214
|
+
const normalized3 = import_node_path12.win32.normalize(stripWin32Namespace(path).replaceAll("/", "\\"));
|
|
45909
46215
|
const trimmed4 = normalized3.length > 3 || !/^[a-z]:\\$/i.test(normalized3) ? normalized3.replace(/\\+$/, "") : normalized3;
|
|
45910
46216
|
return trimmed4.toLowerCase();
|
|
45911
46217
|
}
|
|
45912
|
-
const normalized2 =
|
|
46218
|
+
const normalized2 = import_node_path12.posix.normalize(path);
|
|
45913
46219
|
return normalized2.length > 1 ? normalized2.replace(/\/+$/, "") : normalized2;
|
|
45914
46220
|
}
|
|
45915
46221
|
function isAbsoluteFor(path, platform) {
|
|
45916
|
-
return platform === "win32" ?
|
|
46222
|
+
return platform === "win32" ? import_node_path12.win32.isAbsolute(path) : import_node_path12.posix.isAbsolute(path);
|
|
45917
46223
|
}
|
|
45918
46224
|
function isWithin(root, candidate, platform) {
|
|
45919
46225
|
const separator = platform === "win32" ? "\\" : "/";
|
|
@@ -45931,7 +46237,7 @@ var storeSchema = external_exports.object({
|
|
|
45931
46237
|
});
|
|
45932
46238
|
async function realpathOrNull(path) {
|
|
45933
46239
|
try {
|
|
45934
|
-
return await (0,
|
|
46240
|
+
return await (0, import_promises20.realpath)(path);
|
|
45935
46241
|
} catch (error61) {
|
|
45936
46242
|
const code = errnoCode(error61);
|
|
45937
46243
|
if (code === "ENOENT" || code === "ENOTDIR" || code === "EACCES" || code === "EPERM") {
|
|
@@ -45990,9 +46296,9 @@ async function openApprovedPaths(options) {
|
|
|
45990
46296
|
}
|
|
45991
46297
|
|
|
45992
46298
|
// src/capabilities/workspace/locks.ts
|
|
45993
|
-
var
|
|
45994
|
-
var
|
|
45995
|
-
var
|
|
46299
|
+
var import_node_crypto10 = require("crypto");
|
|
46300
|
+
var import_promises21 = require("fs/promises");
|
|
46301
|
+
var import_node_path13 = require("path");
|
|
45996
46302
|
init_zod();
|
|
45997
46303
|
var LOCK_FORMAT = 1;
|
|
45998
46304
|
var EXCLUSIVE_FILE = "exclusive.json";
|
|
@@ -46007,12 +46313,12 @@ var ownerSchema = external_exports.object({
|
|
|
46007
46313
|
since: external_exports.number().int().nonnegative()
|
|
46008
46314
|
});
|
|
46009
46315
|
function repositoryLockKey(commonDir, platform) {
|
|
46010
|
-
return (0,
|
|
46316
|
+
return (0, import_node_crypto10.createHash)("sha256").update(comparablePath(commonDir, platform)).digest("hex").slice(0, 32);
|
|
46011
46317
|
}
|
|
46012
46318
|
async function readOwner(path) {
|
|
46013
46319
|
let text2;
|
|
46014
46320
|
try {
|
|
46015
|
-
text2 = await (0,
|
|
46321
|
+
text2 = await (0, import_promises21.readFile)(path, "utf8");
|
|
46016
46322
|
} catch (error61) {
|
|
46017
46323
|
if (errnoCode(error61) === "ENOENT") return { kind: "missing" };
|
|
46018
46324
|
return { kind: "unreadable" };
|
|
@@ -46033,7 +46339,7 @@ async function removeIfSame(path, expected) {
|
|
|
46033
46339
|
if (current.kind !== "owner" || current.owner.since !== expected.since) return;
|
|
46034
46340
|
if (current.owner.pid !== expected.pid || current.owner.holder !== expected.holder) return;
|
|
46035
46341
|
}
|
|
46036
|
-
await (0,
|
|
46342
|
+
await (0, import_promises21.unlink)(path).catch((error61) => {
|
|
46037
46343
|
if (errnoCode(error61) !== "ENOENT") throw error61;
|
|
46038
46344
|
});
|
|
46039
46345
|
}
|
|
@@ -46058,7 +46364,7 @@ function openRepositoryLocks(options) {
|
|
|
46058
46364
|
await removeIfSame(path, read.owner);
|
|
46059
46365
|
return null;
|
|
46060
46366
|
}
|
|
46061
|
-
const age = await (0,
|
|
46367
|
+
const age = await (0, import_promises21.stat)(path).then(
|
|
46062
46368
|
(info) => clock.now() - info.mtimeMs,
|
|
46063
46369
|
() => 0
|
|
46064
46370
|
);
|
|
@@ -46072,13 +46378,13 @@ function openRepositoryLocks(options) {
|
|
|
46072
46378
|
});
|
|
46073
46379
|
const folder = async (commonDir) => {
|
|
46074
46380
|
const key = repositoryLockKey(commonDir, platform);
|
|
46075
|
-
const dir = (0,
|
|
46076
|
-
await (0,
|
|
46381
|
+
const dir = (0, import_node_path13.join)(options.dir, key);
|
|
46382
|
+
await (0, import_promises21.mkdir)(dir, { recursive: true, mode: 448 });
|
|
46077
46383
|
return { key, dir };
|
|
46078
46384
|
};
|
|
46079
46385
|
const createExclusive = async (path, owner) => {
|
|
46080
46386
|
try {
|
|
46081
|
-
const handle = await (0,
|
|
46387
|
+
const handle = await (0, import_promises21.open)(path, "wx", 384);
|
|
46082
46388
|
try {
|
|
46083
46389
|
await handle.writeFile(JSON.stringify(owner));
|
|
46084
46390
|
} finally {
|
|
@@ -46091,10 +46397,10 @@ function openRepositoryLocks(options) {
|
|
|
46091
46397
|
}
|
|
46092
46398
|
};
|
|
46093
46399
|
const liveRun = async (dir) => {
|
|
46094
|
-
const entries = await (0,
|
|
46400
|
+
const entries = await (0, import_promises21.readdir)(dir);
|
|
46095
46401
|
for (const entry of entries) {
|
|
46096
46402
|
if (!entry.startsWith(RUN_FILE_PREFIX)) continue;
|
|
46097
|
-
const holder = await heldBy((0,
|
|
46403
|
+
const holder = await heldBy((0, import_node_path13.join)(dir, entry));
|
|
46098
46404
|
if (holder !== null) return holder;
|
|
46099
46405
|
}
|
|
46100
46406
|
return null;
|
|
@@ -46102,7 +46408,7 @@ function openRepositoryLocks(options) {
|
|
|
46102
46408
|
return {
|
|
46103
46409
|
tryExclusive: async (commonDir, operationId) => {
|
|
46104
46410
|
const { key, dir } = await folder(commonDir);
|
|
46105
|
-
const path = (0,
|
|
46411
|
+
const path = (0, import_node_path13.join)(dir, EXCLUSIVE_FILE);
|
|
46106
46412
|
const owner = await self(operationId);
|
|
46107
46413
|
if (!await createExclusive(path, owner)) {
|
|
46108
46414
|
const holder = await heldBy(path);
|
|
@@ -46120,11 +46426,11 @@ function openRepositoryLocks(options) {
|
|
|
46120
46426
|
},
|
|
46121
46427
|
tryShared: async (commonDir, runId) => {
|
|
46122
46428
|
const { key, dir } = await folder(commonDir);
|
|
46123
|
-
const file2 = `${RUN_FILE_PREFIX}${(0,
|
|
46124
|
-
const path = (0,
|
|
46429
|
+
const file2 = `${RUN_FILE_PREFIX}${(0, import_node_crypto10.createHash)("sha256").update(runId).digest("hex").slice(0, 32)}.json`;
|
|
46430
|
+
const path = (0, import_node_path13.join)(dir, file2);
|
|
46125
46431
|
const owner = await self(runId);
|
|
46126
46432
|
await writeJsonFileAtomic(path, owner);
|
|
46127
|
-
const operation = await heldBy((0,
|
|
46433
|
+
const operation = await heldBy((0, import_node_path13.join)(dir, EXCLUSIVE_FILE));
|
|
46128
46434
|
if (operation !== null) {
|
|
46129
46435
|
await removeIfSame(path, owner);
|
|
46130
46436
|
return { kind: "busy", holder: operation };
|
|
@@ -46136,33 +46442,33 @@ function openRepositoryLocks(options) {
|
|
|
46136
46442
|
|
|
46137
46443
|
// src/cli/config.ts
|
|
46138
46444
|
var import_node_os7 = require("os");
|
|
46139
|
-
var
|
|
46445
|
+
var import_node_path27 = require("path");
|
|
46140
46446
|
init_zod();
|
|
46141
46447
|
|
|
46142
46448
|
// src/client/locate.ts
|
|
46143
|
-
var
|
|
46449
|
+
var import_node_path15 = require("path");
|
|
46144
46450
|
var RUNTIME_PROFILES = ["production", "staging", "development", "local"];
|
|
46145
46451
|
function defaultStateDir({ profile, platform, home, env }) {
|
|
46146
46452
|
if (platform === "win32") {
|
|
46147
|
-
return (0,
|
|
46453
|
+
return (0, import_node_path15.join)(env.LOCALAPPDATA ?? (0, import_node_path15.join)(home, "AppData", "Local"), "Alan", profile);
|
|
46148
46454
|
}
|
|
46149
|
-
return (0,
|
|
46455
|
+
return (0, import_node_path15.join)(env.XDG_STATE_HOME ?? (0, import_node_path15.join)(home, ".local", "state"), "alan", profile);
|
|
46150
46456
|
}
|
|
46151
46457
|
function defaultInstallDir({ platform, home, env }) {
|
|
46152
46458
|
if (platform === "win32") {
|
|
46153
|
-
return (0,
|
|
46459
|
+
return (0, import_node_path15.join)(env.LOCALAPPDATA ?? (0, import_node_path15.join)(home, "AppData", "Local"), "Alan", "runtime");
|
|
46154
46460
|
}
|
|
46155
|
-
return (0,
|
|
46461
|
+
return (0, import_node_path15.join)(env.XDG_DATA_HOME ?? (0, import_node_path15.join)(home, ".local", "share"), "alan", "runtime");
|
|
46156
46462
|
}
|
|
46157
46463
|
|
|
46158
46464
|
// src/sessions/index.ts
|
|
46159
|
-
var
|
|
46160
|
-
var
|
|
46465
|
+
var import_node_crypto15 = require("crypto");
|
|
46466
|
+
var import_promises35 = require("fs/promises");
|
|
46161
46467
|
var import_node_os6 = require("os");
|
|
46162
|
-
var
|
|
46468
|
+
var import_node_path26 = require("path");
|
|
46163
46469
|
|
|
46164
46470
|
// src/holder/control-client.ts
|
|
46165
|
-
var
|
|
46471
|
+
var import_node_crypto11 = require("crypto");
|
|
46166
46472
|
var import_node_net = require("net");
|
|
46167
46473
|
|
|
46168
46474
|
// src/holder/ndjson.ts
|
|
@@ -46325,12 +46631,48 @@ function createProviderDrivers(options) {
|
|
|
46325
46631
|
);
|
|
46326
46632
|
}
|
|
46327
46633
|
|
|
46634
|
+
// src/holder/engine-records.ts
|
|
46635
|
+
var import_node_path16 = require("path");
|
|
46636
|
+
init_zod();
|
|
46637
|
+
var ENGINES_FILE = "engines.json";
|
|
46638
|
+
var engineRecordSchema = external_exports.object({
|
|
46639
|
+
pid: external_exports.number().int().positive(),
|
|
46640
|
+
startedAt: external_exports.string().min(1),
|
|
46641
|
+
spawnedAt: external_exports.number().int().nonnegative()
|
|
46642
|
+
});
|
|
46643
|
+
var engineRecordsSchema = external_exports.object({ engines: external_exports.array(engineRecordSchema) });
|
|
46644
|
+
function engineRecordsPath(sessionDir) {
|
|
46645
|
+
return (0, import_node_path16.join)(sessionDir, ENGINES_FILE);
|
|
46646
|
+
}
|
|
46647
|
+
function recordSpawnedEngines(path, clock, log) {
|
|
46648
|
+
const live = /* @__PURE__ */ new Map();
|
|
46649
|
+
let writes = Promise.resolve();
|
|
46650
|
+
const save = () => {
|
|
46651
|
+
const engines = [...live.values()];
|
|
46652
|
+
writes = writes.then(() => writeJsonFileAtomic(path, { engines })).catch((error61) => log.warn("holder.engine_record_failed", { error: error61 }));
|
|
46653
|
+
};
|
|
46654
|
+
return onCliSpawned((child) => {
|
|
46655
|
+
const pid = child.pid;
|
|
46656
|
+
if (pid === void 0) return;
|
|
46657
|
+
const spawnedAt = clock.now();
|
|
46658
|
+
const exited = () => child.exitCode !== null || child.signalCode !== null;
|
|
46659
|
+
child.once("exit", () => {
|
|
46660
|
+
if (live.delete(pid)) save();
|
|
46661
|
+
});
|
|
46662
|
+
void readProcessIdentity(pid).then((identity) => {
|
|
46663
|
+
if (identity === null || exited()) return;
|
|
46664
|
+
live.set(pid, { pid, startedAt: identity.startedAt, spawnedAt });
|
|
46665
|
+
save();
|
|
46666
|
+
});
|
|
46667
|
+
});
|
|
46668
|
+
}
|
|
46669
|
+
|
|
46328
46670
|
// src/holder/mcp-credential.ts
|
|
46329
46671
|
function createConversationMcpAuthorization(options) {
|
|
46330
46672
|
let held;
|
|
46331
|
-
|
|
46673
|
+
let minting;
|
|
46674
|
+
const mint = async (signal) => {
|
|
46332
46675
|
const now = options.now();
|
|
46333
|
-
if (held !== void 0 && now < held.refreshAt) return held.authorization;
|
|
46334
46676
|
try {
|
|
46335
46677
|
const credential = await options.mint(signal);
|
|
46336
46678
|
const expiresAt = Date.parse(credential.expiresAt);
|
|
@@ -46345,11 +46687,18 @@ function createConversationMcpAuthorization(options) {
|
|
|
46345
46687
|
return held !== void 0 && now < held.expiresAt ? held.authorization : void 0;
|
|
46346
46688
|
}
|
|
46347
46689
|
};
|
|
46690
|
+
return async (signal) => {
|
|
46691
|
+
if (held !== void 0 && options.now() < held.refreshAt) return held.authorization;
|
|
46692
|
+
minting ??= mint(signal).finally(() => {
|
|
46693
|
+
minting = void 0;
|
|
46694
|
+
});
|
|
46695
|
+
return minting;
|
|
46696
|
+
};
|
|
46348
46697
|
}
|
|
46349
46698
|
|
|
46350
46699
|
// src/holder/run-inputs.ts
|
|
46351
|
-
var
|
|
46352
|
-
var
|
|
46700
|
+
var import_promises28 = require("fs/promises");
|
|
46701
|
+
var import_node_path17 = require("path");
|
|
46353
46702
|
var NO_RUN_INPUTS = {
|
|
46354
46703
|
attachments: [],
|
|
46355
46704
|
providerEnv: {},
|
|
@@ -46362,18 +46711,18 @@ function safeFilename(filename) {
|
|
|
46362
46711
|
return safe || "attachment";
|
|
46363
46712
|
}
|
|
46364
46713
|
async function prepareRunInputs(spec, { source, tmpDir, signal, skills = [] }) {
|
|
46365
|
-
const dir = (0,
|
|
46714
|
+
const dir = (0, import_node_path17.join)(tmpDir, "runs", spec.runId);
|
|
46366
46715
|
const cleanup = async () => {
|
|
46367
|
-
await (0,
|
|
46716
|
+
await (0, import_promises28.rm)(dir, { recursive: true, force: true });
|
|
46368
46717
|
};
|
|
46369
46718
|
try {
|
|
46370
46719
|
const credential = await source.fetchProviderCredential(spec.runId, signal);
|
|
46371
46720
|
const attachments = [];
|
|
46372
|
-
if (spec.attachments?.length) await (0,
|
|
46721
|
+
if (spec.attachments?.length) await (0, import_promises28.mkdir)(dir, { recursive: true, mode: 448 });
|
|
46373
46722
|
for (const [index, attachment] of (spec.attachments ?? []).entries()) {
|
|
46374
46723
|
const bytes = await source.downloadAttachment(spec.runId, attachment.id, signal);
|
|
46375
|
-
const path = (0,
|
|
46376
|
-
await (0,
|
|
46724
|
+
const path = (0, import_node_path17.join)(dir, `${index}-${safeFilename(attachment.filename)}`);
|
|
46725
|
+
await (0, import_promises28.writeFile)(path, bytes, { mode: 384 });
|
|
46377
46726
|
attachments.push({
|
|
46378
46727
|
id: attachment.id,
|
|
46379
46728
|
kind: attachment.kind,
|
|
@@ -46386,7 +46735,13 @@ async function prepareRunInputs(spec, { source, tmpDir, signal, skills = [] }) {
|
|
|
46386
46735
|
...attachment.height === void 0 ? {} : { height: attachment.height }
|
|
46387
46736
|
});
|
|
46388
46737
|
}
|
|
46389
|
-
return {
|
|
46738
|
+
return {
|
|
46739
|
+
attachments,
|
|
46740
|
+
providerEnv: credential.env,
|
|
46741
|
+
...credential.codex === void 0 ? {} : { codex: credential.codex },
|
|
46742
|
+
skills,
|
|
46743
|
+
[Symbol.asyncDispose]: cleanup
|
|
46744
|
+
};
|
|
46390
46745
|
} catch (error61) {
|
|
46391
46746
|
await cleanup();
|
|
46392
46747
|
throw error61;
|
|
@@ -46394,29 +46749,30 @@ async function prepareRunInputs(spec, { source, tmpDir, signal, skills = [] }) {
|
|
|
46394
46749
|
}
|
|
46395
46750
|
|
|
46396
46751
|
// src/holder/serve.ts
|
|
46397
|
-
var
|
|
46752
|
+
var import_node_crypto14 = require("crypto");
|
|
46398
46753
|
var import_node_fs10 = require("fs");
|
|
46399
46754
|
var import_node_net2 = require("net");
|
|
46755
|
+
var import_node_path25 = require("path");
|
|
46400
46756
|
init_runtime_v2();
|
|
46401
46757
|
|
|
46402
46758
|
// src/holder/admission.ts
|
|
46403
46759
|
var import_node_fs8 = require("fs");
|
|
46404
|
-
var
|
|
46760
|
+
var import_promises32 = require("fs/promises");
|
|
46405
46761
|
var import_node_os5 = require("os");
|
|
46406
|
-
var
|
|
46762
|
+
var import_node_path22 = require("path");
|
|
46407
46763
|
init_constants();
|
|
46408
46764
|
|
|
46409
46765
|
// ../shared/dist/node/local-workspace.js
|
|
46410
46766
|
var import_node_fs7 = require("fs");
|
|
46411
46767
|
var import_node_os4 = require("os");
|
|
46412
|
-
var
|
|
46768
|
+
var import_node_path18 = require("path");
|
|
46413
46769
|
function resolveAlanDefaultWorkspacePath(homeDirectory = (0, import_node_os4.homedir)()) {
|
|
46414
|
-
return (0,
|
|
46770
|
+
return (0, import_node_path18.join)(homeDirectory, ".alan", "workspace");
|
|
46415
46771
|
}
|
|
46416
46772
|
|
|
46417
46773
|
// src/holder/admission-relocation.ts
|
|
46418
|
-
var
|
|
46419
|
-
var
|
|
46774
|
+
var import_promises29 = require("fs/promises");
|
|
46775
|
+
var import_node_path19 = require("path");
|
|
46420
46776
|
var MAX_RELOCATION_CANDIDATES = 200;
|
|
46421
46777
|
var RELOCATION_BUDGET_MS = 2e4;
|
|
46422
46778
|
function repositoryIdentity(url2) {
|
|
@@ -46451,8 +46807,8 @@ async function originIdentity(git, path, signal) {
|
|
|
46451
46807
|
}
|
|
46452
46808
|
async function childDirectories(parent, limit) {
|
|
46453
46809
|
try {
|
|
46454
|
-
const entries = await (0,
|
|
46455
|
-
return entries.filter((entry) => entry.isDirectory()).slice(0, limit).map((entry) => (0,
|
|
46810
|
+
const entries = await (0, import_promises29.readdir)(parent, { withFileTypes: true });
|
|
46811
|
+
return entries.filter((entry) => entry.isDirectory()).slice(0, limit).map((entry) => (0, import_node_path19.join)(parent, entry.name));
|
|
46456
46812
|
} catch {
|
|
46457
46813
|
return [];
|
|
46458
46814
|
}
|
|
@@ -46460,7 +46816,7 @@ async function childDirectories(parent, limit) {
|
|
|
46460
46816
|
async function candidateFolders(search) {
|
|
46461
46817
|
const roots = /* @__PURE__ */ new Map();
|
|
46462
46818
|
for (const path of [search.missingPath, ...search.approvedWorkspacePaths]) {
|
|
46463
|
-
const parent = (0,
|
|
46819
|
+
const parent = (0, import_node_path19.dirname)((0, import_node_path19.resolve)(path));
|
|
46464
46820
|
roots.set(comparablePath(parent, search.platform), parent);
|
|
46465
46821
|
}
|
|
46466
46822
|
const candidates2 = /* @__PURE__ */ new Map();
|
|
@@ -46486,9 +46842,107 @@ async function discoverRelocatedWorkspace(search) {
|
|
|
46486
46842
|
return matches[0] ?? null;
|
|
46487
46843
|
}
|
|
46488
46844
|
|
|
46845
|
+
// src/holder/checkout-refresh.ts
|
|
46846
|
+
var import_node_crypto13 = require("crypto");
|
|
46847
|
+
var import_promises30 = require("fs/promises");
|
|
46848
|
+
var import_node_path20 = require("path");
|
|
46849
|
+
function short(sha) {
|
|
46850
|
+
return sha.slice(0, 12);
|
|
46851
|
+
}
|
|
46852
|
+
function staleLine(path, snapshot2, tip) {
|
|
46853
|
+
const checkout = snapshot2 === void 0 ? "is the environment snapshot's checkout" : `is the environment snapshot's checkout of ${snapshot2.branch} (commit ${short(snapshot2.head)})`;
|
|
46854
|
+
const base = snapshot2 === void 0 ? "its upstream" : `origin/${snapshot2.base}`;
|
|
46855
|
+
const remote = tip === void 0 ? "may be ahead" : `is ahead at ${short(tip)}`;
|
|
46856
|
+
return `Note: ${path} ${checkout}; ${base} ${remote}. Run \`git pull --ff-only\` there before relying on its files.`;
|
|
46857
|
+
}
|
|
46858
|
+
async function claimOnce(dir, name) {
|
|
46859
|
+
try {
|
|
46860
|
+
await (0, import_promises30.mkdir)(dir, { recursive: true, mode: 448 });
|
|
46861
|
+
await (await (0, import_promises30.open)((0, import_node_path20.join)(dir, name), "wx")).close();
|
|
46862
|
+
return true;
|
|
46863
|
+
} catch {
|
|
46864
|
+
return false;
|
|
46865
|
+
}
|
|
46866
|
+
}
|
|
46867
|
+
async function fastForward(freshness, operationId, deps, signal) {
|
|
46868
|
+
var _stack = [];
|
|
46869
|
+
try {
|
|
46870
|
+
const { path: cwd, snapshot: snapshot2, tip } = freshness;
|
|
46871
|
+
const attempt = await deps.locks.tryExclusive(snapshot2.commonDir, operationId);
|
|
46872
|
+
if (attempt.kind === "busy") return false;
|
|
46873
|
+
const _lock = __using(_stack, attempt.lock, true);
|
|
46874
|
+
const now = await readCheckoutStatus(deps.git, cwd, signal);
|
|
46875
|
+
if (now === null || now.dirty || now.head !== snapshot2.head || now.branch !== snapshot2.branch) {
|
|
46876
|
+
return false;
|
|
46877
|
+
}
|
|
46878
|
+
const git = (args) => deps.git.run({ cwd, args }, signal);
|
|
46879
|
+
if ((await git(["switch", "--quiet", "--detach", tip])).exitCode !== 0) return false;
|
|
46880
|
+
const moved = await git(["update-ref", `refs/heads/${snapshot2.branch}`, tip, snapshot2.head]);
|
|
46881
|
+
const back = await git(["switch", "--quiet", snapshot2.branch]);
|
|
46882
|
+
return moved.exitCode === 0 && back.exitCode === 0;
|
|
46883
|
+
} catch (_) {
|
|
46884
|
+
var _error = _, _hasError = true;
|
|
46885
|
+
} finally {
|
|
46886
|
+
var _promise2 = __callDispose(_stack, _error, _hasError);
|
|
46887
|
+
_promise2 && await _promise2;
|
|
46888
|
+
}
|
|
46889
|
+
}
|
|
46890
|
+
async function atFirstLease(freshness, spec, deps, signal) {
|
|
46891
|
+
const first = await claimOnce(
|
|
46892
|
+
(0, import_node_path20.join)(deps.dir, "leased"),
|
|
46893
|
+
(0, import_node_crypto13.createHash)("sha256").update(freshness.path).digest("hex")
|
|
46894
|
+
);
|
|
46895
|
+
switch (freshness.state) {
|
|
46896
|
+
case "current":
|
|
46897
|
+
case "kept":
|
|
46898
|
+
return "none";
|
|
46899
|
+
case "checking":
|
|
46900
|
+
case "failed":
|
|
46901
|
+
return "noted";
|
|
46902
|
+
case "behind":
|
|
46903
|
+
return first && freshness.fetched && await fastForward(freshness, `refresh-${spec.runId}`, deps, signal) ? "moved" : "noted";
|
|
46904
|
+
}
|
|
46905
|
+
}
|
|
46906
|
+
function lineFor(freshness) {
|
|
46907
|
+
switch (freshness.state) {
|
|
46908
|
+
case "behind":
|
|
46909
|
+
return staleLine(freshness.path, freshness.snapshot, freshness.tip);
|
|
46910
|
+
case "failed":
|
|
46911
|
+
return staleLine(freshness.path, freshness.snapshot);
|
|
46912
|
+
default:
|
|
46913
|
+
return staleLine(freshness.path, void 0);
|
|
46914
|
+
}
|
|
46915
|
+
}
|
|
46916
|
+
async function checkoutsOf(spec, leaseTargets) {
|
|
46917
|
+
if (leaseTargets.length > 0 || spec.projectPath === void 0) return [...leaseTargets];
|
|
46918
|
+
return checkoutsUnder(spec.projectPath);
|
|
46919
|
+
}
|
|
46920
|
+
function createCheckoutRefresh(deps) {
|
|
46921
|
+
return async (spec, leaseTargets, signal) => {
|
|
46922
|
+
if (spec.providerSessionId !== void 0) return void 0;
|
|
46923
|
+
if (!await claimOnce((0, import_node_path20.join)(deps.dir, "conversations"), spec.conversationId)) return void 0;
|
|
46924
|
+
const lines = [];
|
|
46925
|
+
for (const target of await checkoutsOf(spec, leaseTargets)) {
|
|
46926
|
+
const freshness = await readCheckoutFreshness(deps.dir, target);
|
|
46927
|
+
if (freshness === null) continue;
|
|
46928
|
+
const outcome2 = await atFirstLease(freshness, spec, deps, signal).catch(
|
|
46929
|
+
() => "noted"
|
|
46930
|
+
);
|
|
46931
|
+
if (outcome2 === "noted") lines.push(lineFor(freshness));
|
|
46932
|
+
deps.log.info("workspace.refresh", {
|
|
46933
|
+
runId: spec.runId,
|
|
46934
|
+
path: freshness.path,
|
|
46935
|
+
state: freshness.state,
|
|
46936
|
+
outcome: outcome2
|
|
46937
|
+
});
|
|
46938
|
+
}
|
|
46939
|
+
return lines.length === 0 ? void 0 : lines.join("\n");
|
|
46940
|
+
};
|
|
46941
|
+
}
|
|
46942
|
+
|
|
46489
46943
|
// src/holder/lease.ts
|
|
46490
|
-
var
|
|
46491
|
-
var
|
|
46944
|
+
var import_promises31 = require("fs/promises");
|
|
46945
|
+
var import_node_path21 = require("path");
|
|
46492
46946
|
var LEASE_CHECK_EVERY_MS = 5e3;
|
|
46493
46947
|
var MAX_TRANSIENT_FAILURES = 3;
|
|
46494
46948
|
var BACKOFF_BASE_MS = 1e3;
|
|
@@ -46502,8 +46956,8 @@ function identityFailure(code, workspacePath) {
|
|
|
46502
46956
|
return { code, problemCode: "app.workspace.missing", message: MESSAGES[code], workspacePath };
|
|
46503
46957
|
}
|
|
46504
46958
|
async function fileIdentity(path) {
|
|
46505
|
-
const canonical = await (0,
|
|
46506
|
-
const info = await (0,
|
|
46959
|
+
const canonical = await (0, import_promises31.realpath)(path);
|
|
46960
|
+
const info = await (0, import_promises31.stat)(canonical, { bigint: true });
|
|
46507
46961
|
return `${canonical}:${info.dev}:${info.ino}`;
|
|
46508
46962
|
}
|
|
46509
46963
|
async function snapshot(git, path, signal) {
|
|
@@ -46522,7 +46976,7 @@ async function snapshot(git, path, signal) {
|
|
|
46522
46976
|
workspace: await fileIdentity(path),
|
|
46523
46977
|
repository: await fileIdentity(commonDir),
|
|
46524
46978
|
worktree: await fileIdentity(gitDir),
|
|
46525
|
-
commonDir: await (0,
|
|
46979
|
+
commonDir: await (0, import_promises31.realpath)(commonDir)
|
|
46526
46980
|
};
|
|
46527
46981
|
} catch {
|
|
46528
46982
|
return null;
|
|
@@ -46535,7 +46989,7 @@ async function gitValue(git, path, args, signal) {
|
|
|
46535
46989
|
}
|
|
46536
46990
|
async function pathExists(path) {
|
|
46537
46991
|
try {
|
|
46538
|
-
await (0,
|
|
46992
|
+
await (0, import_promises31.stat)(path);
|
|
46539
46993
|
return true;
|
|
46540
46994
|
} catch (error61) {
|
|
46541
46995
|
return errnoCode(error61) !== "ENOENT" && errnoCode(error61) !== "ENOTDIR";
|
|
@@ -46544,19 +46998,19 @@ async function pathExists(path) {
|
|
|
46544
46998
|
async function hasGitMarker(path) {
|
|
46545
46999
|
let directory;
|
|
46546
47000
|
try {
|
|
46547
|
-
directory = await (0,
|
|
47001
|
+
directory = await (0, import_promises31.realpath)(path);
|
|
46548
47002
|
} catch {
|
|
46549
47003
|
return true;
|
|
46550
47004
|
}
|
|
46551
47005
|
for (; ; ) {
|
|
46552
47006
|
try {
|
|
46553
|
-
await (0,
|
|
47007
|
+
await (0, import_promises31.stat)((0, import_node_path21.join)(directory, ".git"));
|
|
46554
47008
|
return true;
|
|
46555
47009
|
} catch (error61) {
|
|
46556
47010
|
const code = errnoCode(error61);
|
|
46557
47011
|
if (code !== "ENOENT" && code !== "ENOTDIR") return true;
|
|
46558
47012
|
}
|
|
46559
|
-
const parent = (0,
|
|
47013
|
+
const parent = (0, import_node_path21.dirname)(directory);
|
|
46560
47014
|
if (parent === directory) return false;
|
|
46561
47015
|
directory = parent;
|
|
46562
47016
|
}
|
|
@@ -46720,7 +47174,7 @@ function volumeRoot(path) {
|
|
|
46720
47174
|
}
|
|
46721
47175
|
async function exists(path) {
|
|
46722
47176
|
try {
|
|
46723
|
-
await (0,
|
|
47177
|
+
await (0, import_promises32.stat)(path);
|
|
46724
47178
|
return true;
|
|
46725
47179
|
} catch {
|
|
46726
47180
|
return false;
|
|
@@ -46728,10 +47182,10 @@ async function exists(path) {
|
|
|
46728
47182
|
}
|
|
46729
47183
|
async function inspectReadiness(path) {
|
|
46730
47184
|
try {
|
|
46731
|
-
if (!(await (0,
|
|
47185
|
+
if (!(await (0, import_promises32.stat)(path)).isDirectory()) {
|
|
46732
47186
|
return { ready: false, missing: true, message: MESSAGES2.missing };
|
|
46733
47187
|
}
|
|
46734
|
-
await (0,
|
|
47188
|
+
await (0, import_promises32.access)(path, import_node_fs8.constants.R_OK | import_node_fs8.constants.W_OK | import_node_fs8.constants.X_OK);
|
|
46735
47189
|
return { ready: true };
|
|
46736
47190
|
} catch (error61) {
|
|
46737
47191
|
const code = errnoCode(error61) ?? "";
|
|
@@ -46809,8 +47263,8 @@ async function admitDefaultWorkspace(spec, context, skills) {
|
|
|
46809
47263
|
const { env } = context;
|
|
46810
47264
|
const path = resolveAlanDefaultWorkspacePath(env.HOME || env.USERPROFILE || (0, import_node_os5.homedir)());
|
|
46811
47265
|
try {
|
|
46812
|
-
await (0,
|
|
46813
|
-
await (0,
|
|
47266
|
+
await (0, import_promises32.mkdir)(path, { recursive: true, mode: 448 });
|
|
47267
|
+
await (0, import_promises32.access)(path, import_node_fs8.constants.R_OK | import_node_fs8.constants.W_OK | import_node_fs8.constants.X_OK);
|
|
46814
47268
|
return {
|
|
46815
47269
|
kind: "admitted",
|
|
46816
47270
|
spec: { ...spec, projectPath: path },
|
|
@@ -46875,28 +47329,34 @@ var PROBE_TIMEOUT_MS2 = 5e3;
|
|
|
46875
47329
|
function createHolderWorkspace(machine, clock, log) {
|
|
46876
47330
|
const platform = machine.platform ?? process.platform;
|
|
46877
47331
|
const git = createGitRunner({ env: machine.env, platform, localTimeoutMs: PROBE_TIMEOUT_MS2 });
|
|
47332
|
+
const locks = openRepositoryLocks({ dir: (0, import_node_path22.join)(machine.stateDir, "locks"), clock, platform });
|
|
46878
47333
|
return {
|
|
46879
47334
|
admission: {
|
|
46880
47335
|
env: machine.env,
|
|
46881
47336
|
git,
|
|
46882
47337
|
platform,
|
|
46883
|
-
skills: skillsLayout(
|
|
47338
|
+
skills: skillsLayout(
|
|
47339
|
+
machine.stateDir,
|
|
47340
|
+
machine.env.HOME || machine.env.USERPROFILE || (0, import_node_os5.homedir)()
|
|
47341
|
+
),
|
|
46884
47342
|
approvedRoots: async () => {
|
|
46885
47343
|
const approved = await openApprovedPaths({
|
|
46886
|
-
file: (0,
|
|
47344
|
+
file: (0, import_node_path22.join)(machine.stateDir, "workspaces.json"),
|
|
46887
47345
|
log,
|
|
46888
47346
|
platform
|
|
46889
47347
|
});
|
|
46890
47348
|
return approved.roots();
|
|
46891
47349
|
}
|
|
46892
47350
|
},
|
|
46893
|
-
lease: {
|
|
46894
|
-
|
|
46895
|
-
|
|
46896
|
-
|
|
46897
|
-
|
|
46898
|
-
|
|
46899
|
-
|
|
47351
|
+
lease: { git, locks, clock, log, platform },
|
|
47352
|
+
...machine.refreshesFirstCheckout === true ? {
|
|
47353
|
+
refreshFirstCheckout: createCheckoutRefresh({
|
|
47354
|
+
git,
|
|
47355
|
+
locks,
|
|
47356
|
+
log,
|
|
47357
|
+
dir: (0, import_node_path22.join)(machine.stateDir, "checkout-freshness")
|
|
47358
|
+
})
|
|
47359
|
+
} : {}
|
|
46900
47360
|
};
|
|
46901
47361
|
}
|
|
46902
47362
|
|
|
@@ -46922,7 +47382,7 @@ async function respondToTurn(runningRunId, gate, driver, request2) {
|
|
|
46922
47382
|
}
|
|
46923
47383
|
|
|
46924
47384
|
// src/holder/session-facts.ts
|
|
46925
|
-
var
|
|
47385
|
+
var import_promises33 = require("fs/promises");
|
|
46926
47386
|
var CLI_RSS_CACHE_MS = 1e4;
|
|
46927
47387
|
var LOGIN_PROBLEM_PREFIX = "cli.auth.";
|
|
46928
47388
|
function isLoginFailure(result) {
|
|
@@ -46948,8 +47408,8 @@ function createSessionFacts(options) {
|
|
|
46948
47408
|
const path = await resolveCommandOnPath(command, env, platform);
|
|
46949
47409
|
if (path === null) return null;
|
|
46950
47410
|
try {
|
|
46951
|
-
const real = await (0,
|
|
46952
|
-
const info = await (0,
|
|
47411
|
+
const real = await (0, import_promises33.realpath)(path);
|
|
47412
|
+
const info = await (0, import_promises33.stat)(real);
|
|
46953
47413
|
return { command, key: `${real}:${info.ino}:${info.size}:${info.mtimeMs}` };
|
|
46954
47414
|
} catch {
|
|
46955
47415
|
return null;
|
|
@@ -47036,23 +47496,23 @@ function createSessionFacts(options) {
|
|
|
47036
47496
|
init_acp2();
|
|
47037
47497
|
|
|
47038
47498
|
// src/run-log/directory.ts
|
|
47039
|
-
var
|
|
47040
|
-
var
|
|
47499
|
+
var import_promises34 = require("fs/promises");
|
|
47500
|
+
var import_node_path23 = require("path");
|
|
47041
47501
|
init_runtime_v2();
|
|
47042
47502
|
init_zod();
|
|
47043
47503
|
var runMetaSchema = external_exports.object({ runId: runIdSchema, conversationId: conversationIdSchema });
|
|
47044
47504
|
function runDirectory(runsDir, runId) {
|
|
47045
|
-
const dir = (0,
|
|
47505
|
+
const dir = (0, import_node_path23.join)(runsDir, runId);
|
|
47046
47506
|
return {
|
|
47047
47507
|
dir,
|
|
47048
|
-
log: (0,
|
|
47049
|
-
upload: (0,
|
|
47050
|
-
meta: (0,
|
|
47508
|
+
log: (0, import_node_path23.join)(dir, "log.jsonl"),
|
|
47509
|
+
upload: (0, import_node_path23.join)(dir, "upload.json"),
|
|
47510
|
+
meta: (0, import_node_path23.join)(dir, "run.json")
|
|
47051
47511
|
};
|
|
47052
47512
|
}
|
|
47053
47513
|
async function isRunClaimed(runsDir, runId) {
|
|
47054
47514
|
try {
|
|
47055
|
-
return (await (0,
|
|
47515
|
+
return (await (0, import_promises34.stat)(runDirectory(runsDir, runId).log)).size > 0;
|
|
47056
47516
|
} catch (error61) {
|
|
47057
47517
|
if (errnoCode(error61) === "ENOENT") return false;
|
|
47058
47518
|
throw error61;
|
|
@@ -47088,7 +47548,7 @@ var decoder = new TextDecoder();
|
|
|
47088
47548
|
|
|
47089
47549
|
// src/run-log/writer.ts
|
|
47090
47550
|
var import_node_fs9 = require("fs");
|
|
47091
|
-
var
|
|
47551
|
+
var import_node_path24 = require("path");
|
|
47092
47552
|
init_runtime_v2();
|
|
47093
47553
|
function lastSeq(fd, size) {
|
|
47094
47554
|
for (const length of tailWindows(size)) {
|
|
@@ -47104,7 +47564,7 @@ function lastSeq(fd, size) {
|
|
|
47104
47564
|
throw new RuntimeFault("record_too_large", "Run log tail record is larger than any record");
|
|
47105
47565
|
}
|
|
47106
47566
|
function openRunLog(path, clock) {
|
|
47107
|
-
(0, import_node_fs9.mkdirSync)((0,
|
|
47567
|
+
(0, import_node_fs9.mkdirSync)((0, import_node_path24.dirname)(path), { recursive: true, mode: 448 });
|
|
47108
47568
|
const fd = (0, import_node_fs9.openSync)(path, "a+", 384);
|
|
47109
47569
|
let size = (0, import_node_fs9.fstatSync)(fd).size;
|
|
47110
47570
|
let seq = lastSeq(fd, size);
|
|
@@ -47282,6 +47742,10 @@ function fitForRunLog(update) {
|
|
|
47282
47742
|
async function runWithInputs({ spec, leaseTargets, skills }, context, sink, signal) {
|
|
47283
47743
|
var _stack = [];
|
|
47284
47744
|
try {
|
|
47745
|
+
const refreshed = context.workspace?.refreshFirstCheckout?.(spec, leaseTargets, signal).catch((error61) => {
|
|
47746
|
+
context.log.warn("workspace.refresh_failed", { runId: spec.runId, error: error61 });
|
|
47747
|
+
return void 0;
|
|
47748
|
+
});
|
|
47285
47749
|
let inputs;
|
|
47286
47750
|
try {
|
|
47287
47751
|
inputs = context.inputs ? await prepareRunInputs(spec, { ...context.inputs, signal, skills }) : { ...NO_RUN_INPUTS, skills };
|
|
@@ -47292,8 +47756,14 @@ async function runWithInputs({ spec, leaseTargets, skills }, context, sink, sign
|
|
|
47292
47756
|
message: `Could not fetch this run's attachments or provider credential: ${error61 instanceof Error ? error61.message : String(error61)}`
|
|
47293
47757
|
};
|
|
47294
47758
|
}
|
|
47759
|
+
const turnContext = await refreshed;
|
|
47295
47760
|
const prepared = __using(_stack, inputs, true);
|
|
47296
|
-
const run = (turnSink, turnSignal) => context.driver.runTurn(
|
|
47761
|
+
const run = (turnSink, turnSignal) => context.driver.runTurn(
|
|
47762
|
+
spec,
|
|
47763
|
+
turnSink,
|
|
47764
|
+
turnSignal,
|
|
47765
|
+
turnContext === void 0 ? prepared : { ...prepared, turnContext }
|
|
47766
|
+
);
|
|
47297
47767
|
if (context.workspace === void 0) return await run(sink, signal);
|
|
47298
47768
|
const leased = { ...context, lease: context.workspace.lease };
|
|
47299
47769
|
return await runLeased(spec, leaseTargets, leased, sink, signal, run);
|
|
@@ -47390,13 +47860,13 @@ var TASK_UNSUPPORTED = {
|
|
|
47390
47860
|
reason: "unsupported",
|
|
47391
47861
|
message: "This agent cannot stop one background task."
|
|
47392
47862
|
};
|
|
47393
|
-
function
|
|
47394
|
-
return (0,
|
|
47863
|
+
function sha2563(value) {
|
|
47864
|
+
return (0, import_node_crypto14.createHash)("sha256").update(value).digest("hex");
|
|
47395
47865
|
}
|
|
47396
47866
|
function tokenMatches(expected, presented) {
|
|
47397
|
-
const a = Buffer.from(
|
|
47398
|
-
const b = Buffer.from(
|
|
47399
|
-
return (0,
|
|
47867
|
+
const a = Buffer.from(sha2563(expected), "hex");
|
|
47868
|
+
const b = Buffer.from(sha2563(presented), "hex");
|
|
47869
|
+
return (0, import_node_crypto14.timingSafeEqual)(a, b);
|
|
47400
47870
|
}
|
|
47401
47871
|
async function runHolder({
|
|
47402
47872
|
launch,
|
|
@@ -47406,215 +47876,223 @@ async function runHolder({
|
|
|
47406
47876
|
inputs,
|
|
47407
47877
|
machine
|
|
47408
47878
|
}) {
|
|
47409
|
-
|
|
47410
|
-
|
|
47411
|
-
|
|
47412
|
-
|
|
47413
|
-
|
|
47414
|
-
|
|
47415
|
-
|
|
47416
|
-
|
|
47417
|
-
|
|
47418
|
-
|
|
47419
|
-
|
|
47420
|
-
|
|
47421
|
-
|
|
47422
|
-
|
|
47423
|
-
|
|
47424
|
-
});
|
|
47425
|
-
const observed = facts.observe(driver);
|
|
47426
|
-
const writeStatus = () => writeJsonFileAtomic(launch.statusPath, {
|
|
47427
|
-
protocol: HOLDER_PROTOCOL,
|
|
47428
|
-
conversationId: launch.conversationId,
|
|
47429
|
-
pid: identity.pid,
|
|
47430
|
-
startedAt: identity.startedAt,
|
|
47431
|
-
...identity.command === void 0 ? {} : { command: identity.command },
|
|
47432
|
-
endpoint: launch.endpoint,
|
|
47433
|
-
tokenSha256: sha2562(launch.token),
|
|
47434
|
-
state: holder.state,
|
|
47435
|
-
runId: holder.runId,
|
|
47436
|
-
updatedAt: clock.now()
|
|
47437
|
-
});
|
|
47438
|
-
const broadcast = (message) => {
|
|
47439
|
-
for (const client of holder.clients) writeMessage(client, message);
|
|
47440
|
-
};
|
|
47441
|
-
const settle = () => {
|
|
47442
|
-
holder.state = "idle";
|
|
47443
|
-
holder.runId = null;
|
|
47444
|
-
holder.turn = null;
|
|
47445
|
-
void writeStatus();
|
|
47446
|
-
};
|
|
47447
|
-
const startTurn = (id, spec, client) => {
|
|
47448
|
-
if (holder.runId === spec.runId) {
|
|
47449
|
-
writeMessage(client, {
|
|
47450
|
-
type: "error",
|
|
47451
|
-
id,
|
|
47452
|
-
code: HOLDER_ALREADY_STARTED,
|
|
47453
|
-
message: "The run is already running"
|
|
47454
|
-
});
|
|
47455
|
-
return;
|
|
47456
|
-
}
|
|
47457
|
-
if (holder.state !== "idle") {
|
|
47458
|
-
writeMessage(client, { type: "error", id, code: "busy", message: "A turn is running" });
|
|
47459
|
-
return;
|
|
47460
|
-
}
|
|
47461
|
-
const turn = new AbortController();
|
|
47462
|
-
holder.state = "running";
|
|
47463
|
-
holder.runId = spec.runId;
|
|
47464
|
-
holder.turn = turn;
|
|
47465
|
-
const context = {
|
|
47466
|
-
runsDir: launch.runsDir,
|
|
47467
|
-
machineId: launch.machineId,
|
|
47468
|
-
driver: observed,
|
|
47879
|
+
var _stack = [];
|
|
47880
|
+
try {
|
|
47881
|
+
const identity = await readProcessIdentity(process.pid);
|
|
47882
|
+
if (identity === null) throw new RuntimeFault("internal", "Cannot read own process identity");
|
|
47883
|
+
const _engines = __using(_stack, recordSpawnedEngines(engineRecordsPath((0, import_node_path25.dirname)(launch.statusPath)), clock, log));
|
|
47884
|
+
const holder = {
|
|
47885
|
+
state: "idle",
|
|
47886
|
+
runId: null,
|
|
47887
|
+
turn: null,
|
|
47888
|
+
answerGate: createAnswerGate(),
|
|
47889
|
+
clients: /* @__PURE__ */ new Set()
|
|
47890
|
+
};
|
|
47891
|
+
const exit = new AbortController();
|
|
47892
|
+
const workspace = machine === void 0 ? void 0 : createHolderWorkspace(machine, clock, log);
|
|
47893
|
+
const facts = createSessionFacts({
|
|
47469
47894
|
clock,
|
|
47470
|
-
|
|
47471
|
-
|
|
47472
|
-
|
|
47473
|
-
|
|
47474
|
-
|
|
47475
|
-
|
|
47476
|
-
|
|
47477
|
-
|
|
47478
|
-
|
|
47479
|
-
|
|
47895
|
+
env: machine?.env ?? {},
|
|
47896
|
+
...machine?.platform === void 0 ? {} : { platform: machine.platform }
|
|
47897
|
+
});
|
|
47898
|
+
const observed = facts.observe(driver);
|
|
47899
|
+
const writeStatus = () => writeJsonFileAtomic(launch.statusPath, {
|
|
47900
|
+
protocol: HOLDER_PROTOCOL,
|
|
47901
|
+
conversationId: launch.conversationId,
|
|
47902
|
+
pid: identity.pid,
|
|
47903
|
+
startedAt: identity.startedAt,
|
|
47904
|
+
...identity.command === void 0 ? {} : { command: identity.command },
|
|
47905
|
+
endpoint: launch.endpoint,
|
|
47906
|
+
tokenSha256: sha2563(launch.token),
|
|
47907
|
+
state: holder.state,
|
|
47908
|
+
runId: holder.runId,
|
|
47909
|
+
updatedAt: clock.now()
|
|
47910
|
+
});
|
|
47911
|
+
const broadcast = (message) => {
|
|
47912
|
+
for (const client of holder.clients) writeMessage(client, message);
|
|
47913
|
+
};
|
|
47914
|
+
const settle = () => {
|
|
47915
|
+
holder.state = "idle";
|
|
47916
|
+
holder.runId = null;
|
|
47917
|
+
holder.turn = null;
|
|
47918
|
+
void writeStatus();
|
|
47919
|
+
};
|
|
47920
|
+
const startTurn = (id, spec, client) => {
|
|
47921
|
+
if (holder.runId === spec.runId) {
|
|
47922
|
+
writeMessage(client, {
|
|
47923
|
+
type: "error",
|
|
47924
|
+
id,
|
|
47925
|
+
code: HOLDER_ALREADY_STARTED,
|
|
47926
|
+
message: "The run is already running"
|
|
47927
|
+
});
|
|
47928
|
+
return;
|
|
47929
|
+
}
|
|
47930
|
+
if (holder.state !== "idle") {
|
|
47931
|
+
writeMessage(client, { type: "error", id, code: "busy", message: "A turn is running" });
|
|
47932
|
+
return;
|
|
47933
|
+
}
|
|
47934
|
+
const turn = new AbortController();
|
|
47935
|
+
holder.state = "running";
|
|
47936
|
+
holder.runId = spec.runId;
|
|
47937
|
+
holder.turn = turn;
|
|
47938
|
+
const context = {
|
|
47939
|
+
runsDir: launch.runsDir,
|
|
47940
|
+
machineId: launch.machineId,
|
|
47941
|
+
driver: observed,
|
|
47942
|
+
clock,
|
|
47943
|
+
log,
|
|
47944
|
+
onAppended: (runId, offset) => broadcast({ type: "appended", runId, offset }),
|
|
47945
|
+
...inputs === void 0 ? {} : { inputs },
|
|
47946
|
+
...workspace === void 0 ? {} : { workspace },
|
|
47947
|
+
answerGate: holder.answerGate
|
|
47948
|
+
};
|
|
47949
|
+
claimRun(spec, context).then(
|
|
47950
|
+
(claimed) => {
|
|
47951
|
+
if (claimed === null) {
|
|
47952
|
+
log.warn("holder.start_already_claimed", { runId: spec.runId });
|
|
47953
|
+
settle();
|
|
47954
|
+
writeMessage(client, {
|
|
47955
|
+
type: "error",
|
|
47956
|
+
id,
|
|
47957
|
+
code: HOLDER_ALREADY_STARTED,
|
|
47958
|
+
message: "The run was already started"
|
|
47959
|
+
});
|
|
47960
|
+
return;
|
|
47961
|
+
}
|
|
47962
|
+
writeMessage(client, { type: "ack", id });
|
|
47963
|
+
void writeStatus();
|
|
47964
|
+
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);
|
|
47965
|
+
},
|
|
47966
|
+
(error61) => {
|
|
47967
|
+
log.error("holder.claim_failed", { runId: spec.runId, error: error61 });
|
|
47480
47968
|
settle();
|
|
47481
47969
|
writeMessage(client, {
|
|
47482
47970
|
type: "error",
|
|
47483
47971
|
id,
|
|
47484
|
-
code:
|
|
47485
|
-
message: "The run
|
|
47972
|
+
code: "claim_failed",
|
|
47973
|
+
message: "The run log could not be written"
|
|
47486
47974
|
});
|
|
47487
|
-
return;
|
|
47488
47975
|
}
|
|
47489
|
-
|
|
47490
|
-
|
|
47491
|
-
|
|
47492
|
-
|
|
47493
|
-
|
|
47494
|
-
|
|
47495
|
-
|
|
47976
|
+
);
|
|
47977
|
+
};
|
|
47978
|
+
const respond = (request2, client) => {
|
|
47979
|
+
respondToTurn(holder.runId, holder.answerGate, driver, request2).then((status) => {
|
|
47980
|
+
log.info("holder.responded", { runId: request2.runId, status });
|
|
47981
|
+
writeMessage(client, { type: "responded", id: request2.id, status });
|
|
47982
|
+
}).catch((error61) => {
|
|
47983
|
+
log.warn("holder.respond_crashed", { runId: request2.runId, error: error61 });
|
|
47496
47984
|
writeMessage(client, {
|
|
47497
47985
|
type: "error",
|
|
47498
|
-
id,
|
|
47499
|
-
code: "
|
|
47500
|
-
message: "The
|
|
47986
|
+
id: request2.id,
|
|
47987
|
+
code: "respond_failed",
|
|
47988
|
+
message: "The answer could not be delivered"
|
|
47501
47989
|
});
|
|
47502
|
-
}
|
|
47503
|
-
);
|
|
47504
|
-
};
|
|
47505
|
-
const respond = (request2, client) => {
|
|
47506
|
-
respondToTurn(holder.runId, holder.answerGate, driver, request2).then((status) => {
|
|
47507
|
-
log.info("holder.responded", { runId: request2.runId, status });
|
|
47508
|
-
writeMessage(client, { type: "responded", id: request2.id, status });
|
|
47509
|
-
}).catch((error61) => {
|
|
47510
|
-
log.warn("holder.respond_crashed", { runId: request2.runId, error: error61 });
|
|
47511
|
-
writeMessage(client, {
|
|
47512
|
-
type: "error",
|
|
47513
|
-
id: request2.id,
|
|
47514
|
-
code: "respond_failed",
|
|
47515
|
-
message: "The answer could not be delivered"
|
|
47516
47990
|
});
|
|
47517
|
-
}
|
|
47518
|
-
|
|
47519
|
-
|
|
47520
|
-
|
|
47521
|
-
|
|
47522
|
-
|
|
47523
|
-
|
|
47524
|
-
|
|
47525
|
-
|
|
47526
|
-
|
|
47527
|
-
|
|
47528
|
-
|
|
47529
|
-
|
|
47991
|
+
};
|
|
47992
|
+
const stopTask = (request2, client) => {
|
|
47993
|
+
const stopping = driver.stopTask?.(request2.taskId) ?? Promise.resolve(TASK_UNSUPPORTED);
|
|
47994
|
+
stopping.then((result) => {
|
|
47995
|
+
log.info("holder.task_stop", { runId: request2.runId, taskId: request2.taskId, result });
|
|
47996
|
+
writeMessage(client, { type: "task_stopped", id: request2.id, result });
|
|
47997
|
+
}).catch((error61) => {
|
|
47998
|
+
log.warn("holder.task_stop_crashed", { runId: request2.runId, error: error61 });
|
|
47999
|
+
writeMessage(client, {
|
|
48000
|
+
type: "task_stopped",
|
|
48001
|
+
id: request2.id,
|
|
48002
|
+
result: { ok: false, reason: "failed", message: "The task could not be stopped" }
|
|
48003
|
+
});
|
|
47530
48004
|
});
|
|
47531
|
-
}
|
|
47532
|
-
|
|
47533
|
-
|
|
47534
|
-
|
|
47535
|
-
case "auth":
|
|
47536
|
-
return;
|
|
47537
|
-
case "start_turn":
|
|
47538
|
-
startTurn(request2.id, request2.spec, client);
|
|
47539
|
-
return;
|
|
47540
|
-
case "respond":
|
|
47541
|
-
respond(request2, client);
|
|
47542
|
-
return;
|
|
47543
|
-
case "stop_task":
|
|
47544
|
-
stopTask(request2, client);
|
|
47545
|
-
return;
|
|
47546
|
-
case "abort":
|
|
47547
|
-
if (holder.runId === request2.runId) holder.turn?.abort(request2.outcome ?? "aborted");
|
|
47548
|
-
writeMessage(client, { type: "ack", id: request2.id });
|
|
47549
|
-
return;
|
|
47550
|
-
case "status":
|
|
47551
|
-
void facts.snapshot().then(
|
|
47552
|
-
(snapshot2) => writeMessage(client, {
|
|
47553
|
-
type: "status",
|
|
47554
|
-
id: request2.id,
|
|
47555
|
-
state: holder.state,
|
|
47556
|
-
runId: holder.runId,
|
|
47557
|
-
facts: snapshot2
|
|
47558
|
-
})
|
|
47559
|
-
);
|
|
47560
|
-
return;
|
|
47561
|
-
case "suspend":
|
|
47562
|
-
if (holder.state === "running") {
|
|
47563
|
-
writeMessage(client, {
|
|
47564
|
-
type: "error",
|
|
47565
|
-
id: request2.id,
|
|
47566
|
-
code: "busy",
|
|
47567
|
-
message: "A turn is running; it is never killed to suspend"
|
|
47568
|
-
});
|
|
48005
|
+
};
|
|
48006
|
+
const handle = (request2, client) => {
|
|
48007
|
+
switch (request2.type) {
|
|
48008
|
+
case "auth":
|
|
47569
48009
|
return;
|
|
47570
|
-
|
|
47571
|
-
|
|
47572
|
-
|
|
47573
|
-
|
|
47574
|
-
|
|
47575
|
-
|
|
47576
|
-
|
|
47577
|
-
|
|
47578
|
-
|
|
47579
|
-
|
|
47580
|
-
|
|
47581
|
-
|
|
47582
|
-
|
|
47583
|
-
|
|
47584
|
-
|
|
47585
|
-
|
|
48010
|
+
case "start_turn":
|
|
48011
|
+
startTurn(request2.id, request2.spec, client);
|
|
48012
|
+
return;
|
|
48013
|
+
case "respond":
|
|
48014
|
+
respond(request2, client);
|
|
48015
|
+
return;
|
|
48016
|
+
case "stop_task":
|
|
48017
|
+
stopTask(request2, client);
|
|
48018
|
+
return;
|
|
48019
|
+
case "abort":
|
|
48020
|
+
if (holder.runId === request2.runId) holder.turn?.abort(request2.outcome ?? "aborted");
|
|
48021
|
+
writeMessage(client, { type: "ack", id: request2.id });
|
|
48022
|
+
return;
|
|
48023
|
+
case "status":
|
|
48024
|
+
void facts.snapshot().then(
|
|
48025
|
+
(snapshot2) => writeMessage(client, {
|
|
48026
|
+
type: "status",
|
|
48027
|
+
id: request2.id,
|
|
48028
|
+
state: holder.state,
|
|
48029
|
+
runId: holder.runId,
|
|
48030
|
+
facts: snapshot2
|
|
48031
|
+
})
|
|
48032
|
+
);
|
|
48033
|
+
return;
|
|
48034
|
+
case "suspend":
|
|
48035
|
+
if (holder.state === "running") {
|
|
48036
|
+
writeMessage(client, {
|
|
48037
|
+
type: "error",
|
|
48038
|
+
id: request2.id,
|
|
48039
|
+
code: "busy",
|
|
48040
|
+
message: "A turn is running; it is never killed to suspend"
|
|
48041
|
+
});
|
|
47586
48042
|
return;
|
|
47587
48043
|
}
|
|
47588
|
-
|
|
47589
|
-
|
|
47590
|
-
|
|
47591
|
-
type: "ready",
|
|
47592
|
-
protocol: HOLDER_PROTOCOL,
|
|
47593
|
-
conversationId: launch.conversationId,
|
|
47594
|
-
pid: identity.pid
|
|
47595
|
-
});
|
|
48044
|
+
holder.state = "suspending";
|
|
48045
|
+
writeMessage(client, { type: "ack", id: request2.id });
|
|
48046
|
+
exit.abort();
|
|
47596
48047
|
return;
|
|
47597
|
-
|
|
47598
|
-
|
|
47599
|
-
}
|
|
47600
|
-
|
|
47601
|
-
|
|
47602
|
-
|
|
47603
|
-
|
|
47604
|
-
|
|
47605
|
-
|
|
47606
|
-
|
|
47607
|
-
|
|
47608
|
-
|
|
47609
|
-
|
|
47610
|
-
|
|
47611
|
-
|
|
47612
|
-
|
|
47613
|
-
|
|
47614
|
-
|
|
47615
|
-
|
|
47616
|
-
|
|
47617
|
-
|
|
48048
|
+
default:
|
|
48049
|
+
assertNever2(request2);
|
|
48050
|
+
}
|
|
48051
|
+
};
|
|
48052
|
+
const server = (0, import_node_net2.createServer)((client) => {
|
|
48053
|
+
let authenticated = false;
|
|
48054
|
+
readMessages(client, holderRequestSchema, {
|
|
48055
|
+
onMessage: (request2) => {
|
|
48056
|
+
if (!authenticated) {
|
|
48057
|
+
if (request2.type !== "auth" || !tokenMatches(launch.token, request2.token)) {
|
|
48058
|
+
client.destroy();
|
|
48059
|
+
return;
|
|
48060
|
+
}
|
|
48061
|
+
authenticated = true;
|
|
48062
|
+
holder.clients.add(client);
|
|
48063
|
+
writeMessage(client, {
|
|
48064
|
+
type: "ready",
|
|
48065
|
+
protocol: HOLDER_PROTOCOL,
|
|
48066
|
+
conversationId: launch.conversationId,
|
|
48067
|
+
pid: identity.pid
|
|
48068
|
+
});
|
|
48069
|
+
return;
|
|
48070
|
+
}
|
|
48071
|
+
handle(request2, client);
|
|
48072
|
+
},
|
|
48073
|
+
onInvalid: (reason) => log.warn("holder.request_invalid", { reason })
|
|
48074
|
+
});
|
|
48075
|
+
client.on("close", () => holder.clients.delete(client));
|
|
48076
|
+
client.on("error", () => holder.clients.delete(client));
|
|
48077
|
+
});
|
|
48078
|
+
removeStaleEndpoint(launch.endpoint);
|
|
48079
|
+
await new Promise((resolve6, reject) => {
|
|
48080
|
+
server.once("error", reject);
|
|
48081
|
+
server.listen(launch.endpoint, () => resolve6());
|
|
48082
|
+
});
|
|
48083
|
+
await writeStatus();
|
|
48084
|
+
log.info("holder.ready", { conversationId: launch.conversationId, pid: identity.pid });
|
|
48085
|
+
await new Promise((resolve6) => exit.signal.addEventListener("abort", () => resolve6()));
|
|
48086
|
+
await driver.suspend?.().catch((error61) => log.warn("holder.driver_suspend_failed", { error: error61 }));
|
|
48087
|
+
for (const client of holder.clients) client.end();
|
|
48088
|
+
await new Promise((resolve6) => server.close(() => resolve6()));
|
|
48089
|
+
(0, import_node_fs10.rmSync)(launch.statusPath, { force: true });
|
|
48090
|
+
log.info("holder.suspended", { conversationId: launch.conversationId });
|
|
48091
|
+
} catch (_) {
|
|
48092
|
+
var _error = _, _hasError = true;
|
|
48093
|
+
} finally {
|
|
48094
|
+
__callDispose(_stack, _error, _hasError);
|
|
48095
|
+
}
|
|
47618
48096
|
}
|
|
47619
48097
|
|
|
47620
48098
|
// src/sessions/suspend-policy.ts
|
|
@@ -47657,6 +48135,8 @@ var envSchema = external_exports.object({
|
|
|
47657
48135
|
ALAN_RUNTIME_PROVIDER_NPM_CLI: external_exports.string().min(1).optional(),
|
|
47658
48136
|
ALAN_RUNTIME_HOST: external_exports.enum(RUNTIME_HOST_KINDS).default("standalone"),
|
|
47659
48137
|
ALAN_RUNTIME_GITHUB_PROXY: external_exports.enum(["on", "off"]).default("off"),
|
|
48138
|
+
ALAN_RUNTIME_GIT_GATEWAY_URL: external_exports.url().optional(),
|
|
48139
|
+
ALAN_RUNTIME_WORKSPACE_ROOT: external_exports.string().min(1).optional(),
|
|
47660
48140
|
XDG_CONFIG_HOME: external_exports.string().min(1).optional(),
|
|
47661
48141
|
GH_CONFIG_DIR: external_exports.string().min(1).optional()
|
|
47662
48142
|
});
|
|
@@ -47677,6 +48157,11 @@ var RUNTIME_ENV_PREFIX = "ALAN_RUNTIME_";
|
|
|
47677
48157
|
var MAX_ACTIVE_RUNS_VARIABLE = "ALAN_MAX_ACTIVE_RUNS";
|
|
47678
48158
|
var MAX_ACTIVE_RUNS_RANGE = { min: 1, max: 32 };
|
|
47679
48159
|
var SETUP_TOKEN_VARIABLE = "ALAN_RUNTIME_SETUP_TOKEN";
|
|
48160
|
+
var ENROLLMENT_CODE_VARIABLE = "ALAN_RUNTIME_ENROLLMENT_CODE";
|
|
48161
|
+
var SECRET_VARIABLES = /* @__PURE__ */ new Set([
|
|
48162
|
+
SETUP_TOKEN_VARIABLE,
|
|
48163
|
+
ENROLLMENT_CODE_VARIABLE
|
|
48164
|
+
]);
|
|
47680
48165
|
var ALAN_CODE_ENGINE_VARIABLE = "ALAN_CODE_ENGINE_PATH";
|
|
47681
48166
|
function loadRuntimeConfig(env = process.env, totalMemoryBytes = (0, import_node_os7.totalmem)()) {
|
|
47682
48167
|
const parsed = envSchema.safeParse(env);
|
|
@@ -47703,6 +48188,8 @@ function loadRuntimeConfig(env = process.env, totalMemoryBytes = (0, import_node
|
|
|
47703
48188
|
ALAN_RUNTIME_PROVIDER_NPM_CLI,
|
|
47704
48189
|
ALAN_RUNTIME_HOST,
|
|
47705
48190
|
ALAN_RUNTIME_GITHUB_PROXY,
|
|
48191
|
+
ALAN_RUNTIME_GIT_GATEWAY_URL,
|
|
48192
|
+
ALAN_RUNTIME_WORKSPACE_ROOT,
|
|
47706
48193
|
XDG_CONFIG_HOME,
|
|
47707
48194
|
GH_CONFIG_DIR
|
|
47708
48195
|
} = parsed.data;
|
|
@@ -47736,24 +48223,26 @@ function loadRuntimeConfig(env = process.env, totalMemoryBytes = (0, import_node
|
|
|
47736
48223
|
providerProbes: ALAN_RUNTIME_PROVIDER_PROBES === "on",
|
|
47737
48224
|
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,
|
|
47738
48225
|
home,
|
|
47739
|
-
configHome: XDG_CONFIG_HOME ?? (0,
|
|
48226
|
+
configHome: XDG_CONFIG_HOME ?? (0, import_node_path27.join)(home, ".config"),
|
|
47740
48227
|
...githubProxyConfig({ ALAN_RUNTIME_GITHUB_PROXY, XDG_CONFIG_HOME, GH_CONFIG_DIR }, home),
|
|
48228
|
+
gitGatewayUrl: ALAN_RUNTIME_GIT_GATEWAY_URL ?? null,
|
|
48229
|
+
workspaceRoot: ALAN_RUNTIME_WORKSPACE_ROOT ?? null,
|
|
47741
48230
|
serviceEnvironment: serviceEnvironment(env, ALAN_RUNTIME_PROFILE),
|
|
47742
48231
|
adoptsLegacyInstall: ALAN_RUNTIME_STATE_DIR === void 0
|
|
47743
48232
|
};
|
|
47744
48233
|
}
|
|
47745
48234
|
function githubProxyConfig(env, home) {
|
|
47746
|
-
const configHome = env.XDG_CONFIG_HOME ?? (0,
|
|
48235
|
+
const configHome = env.XDG_CONFIG_HOME ?? (0, import_node_path27.join)(home, ".config");
|
|
47747
48236
|
return {
|
|
47748
48237
|
githubProxy: env.ALAN_RUNTIME_GITHUB_PROXY === "on",
|
|
47749
|
-
ghConfigDir: env.GH_CONFIG_DIR ?? (0,
|
|
48238
|
+
ghConfigDir: env.GH_CONFIG_DIR ?? (0, import_node_path27.join)(configHome, "gh")
|
|
47750
48239
|
};
|
|
47751
48240
|
}
|
|
47752
48241
|
function serviceEnvironment(env, profile) {
|
|
47753
48242
|
const result = { ALAN_RUNTIME_PROFILE: profile };
|
|
47754
48243
|
for (const [key, value] of Object.entries(env)) {
|
|
47755
48244
|
const copied = key.startsWith(RUNTIME_ENV_PREFIX) || key === MAX_ACTIVE_RUNS_VARIABLE || key === ALAN_CODE_ENGINE_VARIABLE;
|
|
47756
|
-
if (!copied || key
|
|
48245
|
+
if (!copied || SECRET_VARIABLES.has(key)) continue;
|
|
47757
48246
|
if (value !== void 0 && value.length > 0) result[key] = value;
|
|
47758
48247
|
}
|
|
47759
48248
|
return result;
|
|
@@ -47786,7 +48275,10 @@ var ELECTRON_ENV_PREFIX = "ELECTRON_";
|
|
|
47786
48275
|
function readCliEnvironment(env = process.env) {
|
|
47787
48276
|
const result = {};
|
|
47788
48277
|
for (const [key, value] of Object.entries(env)) {
|
|
47789
|
-
if (value
|
|
48278
|
+
if (value === void 0 || key.startsWith(ELECTRON_ENV_PREFIX) || SECRET_VARIABLES.has(key)) {
|
|
48279
|
+
continue;
|
|
48280
|
+
}
|
|
48281
|
+
result[key] = value;
|
|
47790
48282
|
}
|
|
47791
48283
|
return result;
|
|
47792
48284
|
}
|
|
@@ -47842,7 +48334,7 @@ async function loadStoredAccess(paths, access3 = { exec: systemExec }) {
|
|
|
47842
48334
|
}
|
|
47843
48335
|
|
|
47844
48336
|
// src/cli/commands/hold.ts
|
|
47845
|
-
var
|
|
48337
|
+
var import_node_path28 = require("path");
|
|
47846
48338
|
init_runtime_v2();
|
|
47847
48339
|
async function machineAccess(paths, log, conversationId, transport) {
|
|
47848
48340
|
const initial = await loadStoredAccess(paths).catch(
|
|
@@ -47859,10 +48351,6 @@ async function machineAccess(paths, log, conversationId, transport) {
|
|
|
47859
48351
|
transport
|
|
47860
48352
|
});
|
|
47861
48353
|
};
|
|
47862
|
-
const source = {
|
|
47863
|
-
downloadAttachment: async (runId, id, signal) => (await api()).downloadAttachment(runId, id, signal),
|
|
47864
|
-
fetchProviderCredential: async (runId, signal) => (await api()).fetchProviderCredential(runId, signal)
|
|
47865
|
-
};
|
|
47866
48354
|
const apiUrl = initial?.endpoints.apiUrl;
|
|
47867
48355
|
const managedMcp = apiUrl === void 0 ? void 0 : {
|
|
47868
48356
|
url: new URL("/mcp", apiUrl).href,
|
|
@@ -47872,7 +48360,21 @@ async function machineAccess(paths, log, conversationId, transport) {
|
|
|
47872
48360
|
log
|
|
47873
48361
|
})
|
|
47874
48362
|
};
|
|
47875
|
-
|
|
48363
|
+
const source = {
|
|
48364
|
+
downloadAttachment: async (runId, id, signal) => (await api()).downloadAttachment(runId, id, signal),
|
|
48365
|
+
fetchProviderCredential: async (runId, signal) => {
|
|
48366
|
+
void managedMcp?.authorization(signal);
|
|
48367
|
+
return (await api()).fetchProviderCredential(runId, signal);
|
|
48368
|
+
}
|
|
48369
|
+
};
|
|
48370
|
+
const codexCredentials = {
|
|
48371
|
+
refresh: async (runId, rejectedAccessTokenSha256) => (await api()).refreshCodexCredential(
|
|
48372
|
+
runId,
|
|
48373
|
+
rejectedAccessTokenSha256 === void 0 ? {} : { rejectedAccessTokenSha256 },
|
|
48374
|
+
new AbortController().signal
|
|
48375
|
+
)
|
|
48376
|
+
};
|
|
48377
|
+
return { source, managedMcp, codexCredentials };
|
|
47876
48378
|
}
|
|
47877
48379
|
async function runHold(argv) {
|
|
47878
48380
|
var _stack = [];
|
|
@@ -47889,7 +48391,7 @@ async function runHold(argv) {
|
|
|
47889
48391
|
const config2 = loadRuntimeConfig();
|
|
47890
48392
|
const paths = runtimePaths(config2.stateDir);
|
|
47891
48393
|
const log = __using(_stack, openFileLog(
|
|
47892
|
-
(0,
|
|
48394
|
+
(0, import_node_path28.join)(paths.logs, `holder-${launch.value.conversationId}.jsonl`),
|
|
47893
48395
|
config2.logLevel,
|
|
47894
48396
|
systemClock
|
|
47895
48397
|
));
|
|
@@ -47907,12 +48409,18 @@ async function runHold(argv) {
|
|
|
47907
48409
|
defaultCwd: process.cwd(),
|
|
47908
48410
|
timings: config2.sessionTimings,
|
|
47909
48411
|
log,
|
|
48412
|
+
codexCredentials: access3.codexCredentials,
|
|
47910
48413
|
...access3.managedMcp === void 0 ? {} : { managedMcp: access3.managedMcp }
|
|
47911
48414
|
}),
|
|
47912
48415
|
clock: systemClock,
|
|
47913
48416
|
log,
|
|
47914
48417
|
inputs: { source: access3.source, tmpDir: paths.tmp },
|
|
47915
|
-
machine: {
|
|
48418
|
+
machine: {
|
|
48419
|
+
env: cliEnvironment,
|
|
48420
|
+
stateDir: paths.stateDir,
|
|
48421
|
+
// Only a cloud sandbox's runtime has a git gateway.
|
|
48422
|
+
refreshesFirstCheckout: config2.gitGatewayUrl !== null
|
|
48423
|
+
}
|
|
47916
48424
|
});
|
|
47917
48425
|
} catch (_) {
|
|
47918
48426
|
var _error = _, _hasError = true;
|