@alan-ai-hq/agent-manager-linux-x64 0.1.129 → 0.1.131
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 +487 -551
- package/alan-holder.cjs +305 -390
- package/package.json +1 -1
package/alan-agent.cjs
CHANGED
|
@@ -19993,7 +19993,7 @@ var init_ids = __esm({
|
|
|
19993
19993
|
function wire() {
|
|
19994
19994
|
return (schema) => schema;
|
|
19995
19995
|
}
|
|
19996
|
-
var canonicalUserMessageSchema, canonicalAssistantMessageSchema, externalMcpServerSchema, runAttachmentSchema, parsedAttachmentSchema, taskMetaSchema, pullRequestMetaSchema, agentUserIdentitySchema, workflowToolRefSchema,
|
|
19996
|
+
var canonicalUserMessageSchema, canonicalAssistantMessageSchema, externalMcpServerSchema, runAttachmentSchema, parsedAttachmentSchema, taskMetaSchema, pullRequestMetaSchema, agentUserIdentitySchema, workflowToolRefSchema, runPromptContextSchema;
|
|
19997
19997
|
var init_run_context = __esm({
|
|
19998
19998
|
"../shared/dist/runtime-v2/run-context.js"() {
|
|
19999
19999
|
"use strict";
|
|
@@ -20099,7 +20099,6 @@ var init_run_context = __esm({
|
|
|
20099
20099
|
}));
|
|
20100
20100
|
agentUserIdentitySchema = wire()(external_exports.object({ id: external_exports.string().min(1), name: external_exports.string().nullable(), email: external_exports.string() }));
|
|
20101
20101
|
workflowToolRefSchema = wire()(external_exports.object({ type: external_exports.string().min(1), id: external_exports.string().min(1) }));
|
|
20102
|
-
relevantContextRecallSchema = wire()(external_exports.object({ query: external_exports.string(), envelope: external_exports.record(external_exports.string(), external_exports.unknown()) }));
|
|
20103
20102
|
runPromptContextSchema = external_exports.object({
|
|
20104
20103
|
taskMeta: taskMetaSchema.optional(),
|
|
20105
20104
|
prMeta: pullRequestMetaSchema.optional(),
|
|
@@ -20356,10 +20355,8 @@ var init_desired_state = __esm({
|
|
|
20356
20355
|
promptContext: runPromptContextSchema.optional(),
|
|
20357
20356
|
/** Absent means entitled, so a spec from an older server keeps the code-index prompts. */
|
|
20358
20357
|
codeIndexEnabled: external_exports.boolean().optional(),
|
|
20359
|
-
/**
|
|
20358
|
+
/** Omitted by older servers; only an explicit entitlement enables context-search guidance. */
|
|
20360
20359
|
contextGraphEnabled: external_exports.boolean().optional(),
|
|
20361
|
-
/** Already appended to `content` as `<relevantContext>`; the holder records it as a recall. */
|
|
20362
|
-
relevantContext: relevantContextRecallSchema.optional(),
|
|
20363
20360
|
cloudEnvironmentId: external_exports.guid().optional(),
|
|
20364
20361
|
localRepoUrls: external_exports.array(external_exports.string().min(1)).optional()
|
|
20365
20362
|
// Never here: the provider API key. The holder fetches it per run (RUN_PROVIDER_CREDENTIAL_PATH).
|
|
@@ -21358,11 +21355,8 @@ var init_workflow_tools_filter = __esm({
|
|
|
21358
21355
|
"create_test_report",
|
|
21359
21356
|
"create_plan",
|
|
21360
21357
|
"create_document_artifact",
|
|
21361
|
-
"upsert_prototype_version",
|
|
21362
21358
|
"list_artifacts",
|
|
21363
|
-
"get_artifact"
|
|
21364
|
-
"list_prototypes",
|
|
21365
|
-
"get_prototype"
|
|
21359
|
+
"get_artifact"
|
|
21366
21360
|
];
|
|
21367
21361
|
LEGACY_WORKFLOW_BUILTIN_TOOLS = {
|
|
21368
21362
|
list_document_comments: "get_document",
|
|
@@ -21436,7 +21430,7 @@ Use these tools, in roughly this order of frequency:
|
|
|
21436
21430
|
4. \`get_session_context\` \u2014 check what a worker accomplished
|
|
21437
21431
|
5. \`update_task\` \u2014 keep status, priority, labels current
|
|
21438
21432
|
6. \`send_session_message\` / \`start_task_session\` \u2014 continue a specific session or force a new session only when needed
|
|
21439
|
-
7. \`list_sessions\` / \`find_records\` / \`
|
|
21433
|
+
7. \`list_sessions\` / \`find_records\` / \`search_code_context\` / \`Read\` / \`Glob\` / \`Grep\` \u2014 situational awareness (\`find_records\` locates canonical records; \`search_code_context\` handles source-code discovery; read exact cited sources before claiming authoritative details)
|
|
21440
21434
|
8. \`create_plan\` \u2014 document implementation plans and durable specs as artifacts
|
|
21441
21435
|
9. \`add_task_comment\` \u2014 human-facing collaboration: answer questions, post explicit status updates, escalate blockers, or leave comments the user asked you to post. Do not use comments as running notes or context storage.
|
|
21442
21436
|
|
|
@@ -21511,8 +21505,7 @@ You work on the Alan platform. The platform is where product truth lives: tasks,
|
|
|
21511
21505
|
| Scope, status, priority, or history of work | \`get_task\`, \`list_subtasks\`, \`list_tasks\` | \`git log\`, commit messages |
|
|
21512
21506
|
| What was decided and why | \`list_task_decisions\`, \`list_task_events\` | code comments, in-repo ADRs |
|
|
21513
21507
|
| What an agent did or is doing | \`list_sessions\`, \`get_session_context\` | \`git log\`, diffing the worktree |
|
|
21514
|
-
| Prior agent context | \`
|
|
21515
|
-
| Relevant non-code context with no exact source | \`search_context\` | guessing IDs, container tags, or provider filters |
|
|
21508
|
+
| Prior agent context | \`list_task_events\`, \`get_session_context\` | scratch files |
|
|
21516
21509
|
| Outputs of completed work | \`list_artifacts\`, \`get_artifact\` | build output, generated files |
|
|
21517
21510
|
| Where code lives or how it works | \`search_code_context\` first, then \`Read\` the cited files | \`Grep\`/\`Glob\` sweeps |
|
|
21518
21511
|
|
|
@@ -21541,8 +21534,7 @@ Use these tools, in roughly this order of frequency:
|
|
|
21541
21534
|
4. \`get_session_context\` / \`list_sessions\` \u2014 track progress
|
|
21542
21535
|
5. \`update_task\` \u2014 keep status and priority current
|
|
21543
21536
|
6. \`list_task_events\` / \`add_task_event\` \u2014 persist only high-signal human-readable decisions, learnings, checkpoints, and outcomes in the Agent Log
|
|
21544
|
-
7. \`
|
|
21545
|
-
8. \`add_task_comment\` \u2014 human-facing collaboration: answer questions, post explicit status updates, escalate blockers, or leave comments the user asked you to post. Do not use comments as running notes or context storage.
|
|
21537
|
+
7. \`add_task_comment\` \u2014 human-facing collaboration: answer questions, post explicit status updates, escalate blockers, or leave comments the user asked you to post. Do not use comments as running notes or context storage.
|
|
21546
21538
|
|
|
21547
21539
|
## How to think like a PM
|
|
21548
21540
|
|
|
@@ -21743,13 +21735,6 @@ var init_browser_surface = __esm({
|
|
|
21743
21735
|
}
|
|
21744
21736
|
});
|
|
21745
21737
|
|
|
21746
|
-
// ../shared/dist/agent/context-intent.js
|
|
21747
|
-
var init_context_intent = __esm({
|
|
21748
|
-
"../shared/dist/agent/context-intent.js"() {
|
|
21749
|
-
"use strict";
|
|
21750
|
-
}
|
|
21751
|
-
});
|
|
21752
|
-
|
|
21753
21738
|
// ../shared/dist/agent/gated-mcp-tools.js
|
|
21754
21739
|
var CODE_INDEX_MCP_TOOLS, CONTEXT_GRAPH_MCP_TOOLS, ENTITLEMENT_GATED_MCP_TOOLS;
|
|
21755
21740
|
var init_gated_mcp_tools = __esm({
|
|
@@ -22068,13 +22053,13 @@ var init_system_prompt = __esm({
|
|
|
22068
22053
|
|
|
22069
22054
|
The codebase records what the system does. It does not record why it is that way, what was ruled out, what an outside constraint forbids, or what someone was left owed. That record lives in \`search_context\` \u2014 this team's decisions, constraints, procedures, ownership, rejected approaches and unfinished work.
|
|
22070
22055
|
|
|
22056
|
+
Before answering or acting on a question about a past decision, ownership, history, or unfinished work whose exact source is unknown, call \`search_context\` first.
|
|
22057
|
+
|
|
22071
22058
|
So when a turn depends on something the repository cannot tell you \u2014 a value chosen rather than tuned, an approach that may already have been tried, a boundary another team owns, work someone else left half-done \u2014 recover it before you answer or act. Reading the code, or the document someone named, does not settle it: those answer a different question, and one turn can need both.
|
|
22072
22059
|
|
|
22073
22060
|
What comes back is the answer, not a step towards it. Carry its specifics into what you write or change \u2014 the value, the constraint, the reason, the person \u2014 and say plainly when the evidence contradicts what was asked for. Retrieving a decision and then producing work that ignores it is worse than never having searched, because it looks informed.
|
|
22074
22061
|
|
|
22075
|
-
Skip it when nothing team-specific is at stake: source-code questions, general knowledge, mechanical work fully specified in the request, or an exact ID already in hand
|
|
22076
|
-
|
|
22077
|
-
A \`relevantContext\` block, when present, is evidence already retrieved. Use it, do not search again for what it answers, and do not mention that it was loaded.`;
|
|
22062
|
+
Skip it when nothing team-specific is at stake: source-code questions, general knowledge, mechanical work fully specified in the request, or an exact ID already in hand.`;
|
|
22078
22063
|
ALAN_PLATFORM_TOOL_ROUTING_PROMPT = `## Alan platform tools
|
|
22079
22064
|
|
|
22080
22065
|
When an action reads, creates, changes, links, sends, or controls Alan-owned state \u2014 or uses a provider identity connected through Alan \u2014 use the matching Alan MCP tool. This applies whether the agent runs locally or in the cloud. Do not substitute a shell CLI, browser automation, raw HTTP, or a local file; those paths bypass Alan's identity, authorization, audit trail, and task linkage.
|
|
@@ -22117,8 +22102,6 @@ Team
|
|
|
22117
22102
|
|
|
22118
22103
|
${ALAN_PLATFORM_TOOL_ROUTING_PROMPT}
|
|
22119
22104
|
|
|
22120
|
-
${ALAN_CONTEXT_SEARCH_PROMPT}
|
|
22121
|
-
|
|
22122
22105
|
## Record & Entity Resolution (Tasks, PRs, Docs, Epics)
|
|
22123
22106
|
|
|
22124
22107
|
When the user refers to a specific task, pull request, document, or epic by human identifier (e.g. \`AL-2980\`, \`2980\`, \`#45\`), title, or topic phrase:
|
|
@@ -22261,7 +22244,6 @@ var init_agent2 = __esm({
|
|
|
22261
22244
|
init_agent_definitions();
|
|
22262
22245
|
init_attachment_mention();
|
|
22263
22246
|
init_browser_surface();
|
|
22264
|
-
init_context_intent();
|
|
22265
22247
|
init_gated_mcp_tools();
|
|
22266
22248
|
init_generated_images();
|
|
22267
22249
|
init_iframe_embeddability();
|
|
@@ -22352,7 +22334,7 @@ var init_chunk_YXWJW7I5 = __esm({
|
|
|
22352
22334
|
}
|
|
22353
22335
|
});
|
|
22354
22336
|
|
|
22355
|
-
// ../agent-core/dist/chunk-
|
|
22337
|
+
// ../agent-core/dist/chunk-NDAB5G24.js
|
|
22356
22338
|
function windowsEnvValue(env, name) {
|
|
22357
22339
|
const wanted = name.toLowerCase();
|
|
22358
22340
|
for (const [key, value2] of Object.entries(env)) {
|
|
@@ -22476,6 +22458,12 @@ function planSpawn({ command, args, env, platform: platform3, files }) {
|
|
|
22476
22458
|
if (launch === void 0) {
|
|
22477
22459
|
throw new CoreFault("spawn_failed", `Could not start ${command} (not found on PATH)`);
|
|
22478
22460
|
}
|
|
22461
|
+
if (launch.kind === "batch") {
|
|
22462
|
+
throw new CoreFault(
|
|
22463
|
+
"spawn_failed",
|
|
22464
|
+
`${command} resolves to a batch file that cannot run as a managed Windows agent; install its native executable or supported npm shim`
|
|
22465
|
+
);
|
|
22466
|
+
}
|
|
22479
22467
|
return { file: launch.file, args: launch.args, commandLine: windowsCommandLine(launch, env) };
|
|
22480
22468
|
}
|
|
22481
22469
|
function planDirectLaunch({
|
|
@@ -22807,45 +22795,90 @@ function createProcessTree(child, options = {}) {
|
|
|
22807
22795
|
}
|
|
22808
22796
|
};
|
|
22809
22797
|
}
|
|
22810
|
-
function
|
|
22811
|
-
|
|
22812
|
-
|
|
22813
|
-
|
|
22814
|
-
|
|
22815
|
-
|
|
22816
|
-
|
|
22817
|
-
|
|
22818
|
-
].join("\n");
|
|
22798
|
+
function providerEnvironment(env) {
|
|
22799
|
+
const unique2 = /* @__PURE__ */ new Map();
|
|
22800
|
+
for (const [name, value2] of Object.entries(env)) {
|
|
22801
|
+
if (/^ALAN_JOB_(FILE|COMMAND|STATUS)$/i.test(name) || /^ALAN_WINHELPER_PATH$/i.test(name))
|
|
22802
|
+
continue;
|
|
22803
|
+
unique2.set(name.toLowerCase(), [name, value2]);
|
|
22804
|
+
}
|
|
22805
|
+
return Object.fromEntries(unique2.values());
|
|
22819
22806
|
}
|
|
22820
|
-
function
|
|
22821
|
-
|
|
22822
|
-
|
|
22823
|
-
|
|
22824
|
-
|
|
22825
|
-
|
|
22826
|
-
|
|
22827
|
-
|
|
22828
|
-
|
|
22829
|
-
|
|
22830
|
-
|
|
22831
|
-
|
|
22832
|
-
|
|
22833
|
-
|
|
22834
|
-
|
|
22835
|
-
|
|
22807
|
+
function requireStartedProvider(response, command) {
|
|
22808
|
+
if (response.startsWith("error:")) {
|
|
22809
|
+
throw new CoreFault("spawn_failed", `Could not start ${command} (${response.slice(6)})`);
|
|
22810
|
+
}
|
|
22811
|
+
if (!/^\d+$/.test(response)) {
|
|
22812
|
+
throw new CoreFault("spawn_failed", `Could not start ${command} (invalid helper response)`);
|
|
22813
|
+
}
|
|
22814
|
+
}
|
|
22815
|
+
function isWindowsJob(child) {
|
|
22816
|
+
return statuses.has(child);
|
|
22817
|
+
}
|
|
22818
|
+
function helperFile(env) {
|
|
22819
|
+
const override = Object.entries(env).find(([name]) => /^ALAN_WINHELPER_PATH$/i.test(name))?.[1];
|
|
22820
|
+
if (override) return override;
|
|
22821
|
+
const entry = process.argv[1];
|
|
22822
|
+
if (!entry) throw new CoreFault("spawn_failed", "Cannot locate the Windows agent helper");
|
|
22823
|
+
return (0, import_path2.join)((0, import_path2.dirname)(entry), "alan-winhelper.exe");
|
|
22836
22824
|
}
|
|
22837
22825
|
function spawnInWindowsJob(plan2, options) {
|
|
22838
22826
|
if (plan2.commandLine === null) {
|
|
22839
22827
|
throw new CoreFault("internal", `No Windows command line was planned for ${plan2.file}`);
|
|
22840
22828
|
}
|
|
22841
|
-
const
|
|
22842
|
-
|
|
22829
|
+
const file2 = helperFile(options.env);
|
|
22830
|
+
const directory = (0, import_fs2.mkdtempSync)((0, import_path2.join)((0, import_os.tmpdir)(), `alan-job-${(0, import_crypto.randomUUID)()}-`));
|
|
22831
|
+
const path4 = (0, import_path2.join)(directory, "started");
|
|
22832
|
+
const child = (0, import_child_process6.spawn)(file2, [String(process.pid)], {
|
|
22843
22833
|
cwd: options.cwd,
|
|
22844
|
-
env: {
|
|
22834
|
+
env: {
|
|
22835
|
+
...providerEnvironment(options.env),
|
|
22836
|
+
ALAN_JOB_FILE: plan2.file,
|
|
22837
|
+
ALAN_JOB_COMMAND: plan2.commandLine,
|
|
22838
|
+
ALAN_JOB_STATUS: path4
|
|
22839
|
+
},
|
|
22845
22840
|
stdio: ["pipe", "pipe", "pipe"],
|
|
22846
22841
|
shell: false,
|
|
22847
22842
|
windowsHide: true
|
|
22848
22843
|
});
|
|
22844
|
+
const status = { directory, path: path4 };
|
|
22845
|
+
child.once("error", (error61) => {
|
|
22846
|
+
status.error = error61;
|
|
22847
|
+
});
|
|
22848
|
+
statuses.set(child, status);
|
|
22849
|
+
return child;
|
|
22850
|
+
}
|
|
22851
|
+
async function waitForWindowsJob(child, command) {
|
|
22852
|
+
const status = statuses.get(child);
|
|
22853
|
+
if (!status) throw new CoreFault("internal", "Missing Windows helper startup state");
|
|
22854
|
+
const deadline = systemClock2.monotonic() + START_TIMEOUT_MS;
|
|
22855
|
+
try {
|
|
22856
|
+
while (systemClock2.monotonic() < deadline) {
|
|
22857
|
+
const providerPid = await (0, import_promises10.readFile)(status.path, "utf8").catch(() => void 0);
|
|
22858
|
+
if (providerPid !== void 0) {
|
|
22859
|
+
requireStartedProvider(providerPid, command);
|
|
22860
|
+
return;
|
|
22861
|
+
}
|
|
22862
|
+
if (status.error) {
|
|
22863
|
+
throw new CoreFault(
|
|
22864
|
+
"spawn_failed",
|
|
22865
|
+
`Could not start ${command} (${status.error.message})`,
|
|
22866
|
+
{
|
|
22867
|
+
cause: status.error
|
|
22868
|
+
}
|
|
22869
|
+
);
|
|
22870
|
+
}
|
|
22871
|
+
if (child.exitCode !== null || child.signalCode !== null) {
|
|
22872
|
+
throw new CoreFault("spawn_failed", `Could not start ${command} (Windows helper exited)`);
|
|
22873
|
+
}
|
|
22874
|
+
await systemClock2.sleep(25);
|
|
22875
|
+
}
|
|
22876
|
+
child.kill("SIGKILL");
|
|
22877
|
+
throw new CoreFault("spawn_failed", `Could not start ${command} (Windows helper timed out)`);
|
|
22878
|
+
} finally {
|
|
22879
|
+
statuses.delete(child);
|
|
22880
|
+
await (0, import_promises10.rm)(status.directory, { recursive: true, force: true });
|
|
22881
|
+
}
|
|
22849
22882
|
}
|
|
22850
22883
|
function spawnCli(options) {
|
|
22851
22884
|
const platform3 = options.platform ?? process.platform;
|
|
@@ -22860,6 +22893,7 @@ function spawnCli(options) {
|
|
|
22860
22893
|
});
|
|
22861
22894
|
}
|
|
22862
22895
|
function waitForSpawn(child, command) {
|
|
22896
|
+
if (isWindowsJob(child)) return waitForWindowsJob(child, command);
|
|
22863
22897
|
if (child.pid !== void 0) return Promise.resolve();
|
|
22864
22898
|
return new Promise((resolve10, reject) => {
|
|
22865
22899
|
const onSpawn = () => {
|
|
@@ -22877,9 +22911,9 @@ function waitForSpawn(child, command) {
|
|
|
22877
22911
|
child.once("error", onError);
|
|
22878
22912
|
});
|
|
22879
22913
|
}
|
|
22880
|
-
var import_child_process, import_fs, import_path, import_child_process2, import_promises9, import_child_process3, import_child_process4, import_child_process5, import_child_process6, 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,
|
|
22881
|
-
var
|
|
22882
|
-
"../agent-core/dist/chunk-
|
|
22914
|
+
var import_child_process, import_fs, import_path, import_child_process2, import_promises9, import_child_process3, import_child_process4, import_child_process5, import_child_process6, import_crypto, import_fs2, import_promises10, 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;
|
|
22915
|
+
var init_chunk_NDAB5G24 = __esm({
|
|
22916
|
+
"../agent-core/dist/chunk-NDAB5G24.js"() {
|
|
22883
22917
|
"use strict";
|
|
22884
22918
|
init_chunk_YXWJW7I5();
|
|
22885
22919
|
import_child_process = require("child_process");
|
|
@@ -22891,6 +22925,10 @@ var init_chunk_VZIZDY3T = __esm({
|
|
|
22891
22925
|
import_child_process4 = require("child_process");
|
|
22892
22926
|
import_child_process5 = require("child_process");
|
|
22893
22927
|
import_child_process6 = require("child_process");
|
|
22928
|
+
import_crypto = require("crypto");
|
|
22929
|
+
import_fs2 = require("fs");
|
|
22930
|
+
import_promises10 = require("fs/promises");
|
|
22931
|
+
import_os = require("os");
|
|
22894
22932
|
import_path2 = require("path");
|
|
22895
22933
|
SHIM_MAX_BYTES = 64 * 1024;
|
|
22896
22934
|
CMD_MAX_COMMAND_LINE = 8191;
|
|
@@ -22962,87 +23000,8 @@ var init_chunk_VZIZDY3T = __esm({
|
|
|
22962
23000
|
DEFAULT_GRACE_MS = 3e3;
|
|
22963
23001
|
DEFAULT_KILL_WAIT_MS = 2e3;
|
|
22964
23002
|
DEFAULT_TASKKILL_TIMEOUT_MS = 5e3;
|
|
22965
|
-
|
|
22966
|
-
|
|
22967
|
-
using System;
|
|
22968
|
-
using System.Text;
|
|
22969
|
-
using System.Runtime.InteropServices;
|
|
22970
|
-
using System.ComponentModel;
|
|
22971
|
-
public static class AlanProviderJob {
|
|
22972
|
-
[StructLayout(LayoutKind.Sequential)] struct IO { public ulong a,b,c,d,e,f; }
|
|
22973
|
-
[StructLayout(LayoutKind.Sequential)] struct Limits {
|
|
22974
|
-
public long perProcess, perJob; public uint flags;
|
|
22975
|
-
public UIntPtr minWorkingSet, maxWorkingSet; public uint activeProcesses;
|
|
22976
|
-
public UIntPtr affinity; public uint priority, scheduling;
|
|
22977
|
-
}
|
|
22978
|
-
[StructLayout(LayoutKind.Sequential)] struct ExtendedLimits {
|
|
22979
|
-
public Limits basic; public IO io;
|
|
22980
|
-
public UIntPtr processMemory, jobMemory, peakProcessMemory, peakJobMemory;
|
|
22981
|
-
}
|
|
22982
|
-
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)] struct Startup {
|
|
22983
|
-
public uint cb; public string reserved, desktop, title;
|
|
22984
|
-
public uint x,y,xSize,ySize,xChars,yChars,fill,flags;
|
|
22985
|
-
public ushort show,reservedSize; public IntPtr reserved2, stdin, stdout, stderr;
|
|
22986
|
-
}
|
|
22987
|
-
[StructLayout(LayoutKind.Sequential)] struct ProcessInfo {
|
|
22988
|
-
public IntPtr process, thread; public uint pid, tid;
|
|
22989
|
-
}
|
|
22990
|
-
[DllImport("kernel32.dll", SetLastError=true)] static extern IntPtr CreateJobObject(IntPtr security, string name);
|
|
22991
|
-
[DllImport("kernel32.dll", SetLastError=true)] static extern bool SetInformationJobObject(IntPtr job, int kind, ref ExtendedLimits limits, uint size);
|
|
22992
|
-
[DllImport("kernel32.dll", SetLastError=true)] static extern bool AssignProcessToJobObject(IntPtr job, IntPtr process);
|
|
22993
|
-
[DllImport("kernel32.dll", SetLastError=true)] static extern bool TerminateJobObject(IntPtr job, uint code);
|
|
22994
|
-
[DllImport("kernel32.dll", SetLastError=true)] static extern bool TerminateProcess(IntPtr process, uint code);
|
|
22995
|
-
[DllImport("kernel32.dll", CharSet=CharSet.Unicode, SetLastError=true)] static extern bool CreateProcess(string app, StringBuilder command, IntPtr ps, IntPtr ts, bool inherit, uint flags, IntPtr env, string cwd, ref Startup si, out ProcessInfo pi);
|
|
22996
|
-
[DllImport("kernel32.dll")] static extern IntPtr GetStdHandle(int id);
|
|
22997
|
-
[DllImport("kernel32.dll")] static extern IntPtr GetCurrentProcess();
|
|
22998
|
-
[DllImport("kernel32.dll", SetLastError=true)] static extern bool DuplicateHandle(IntPtr sourceProcess, IntPtr source, IntPtr targetProcess, out IntPtr target, uint access, bool inherit, uint options);
|
|
22999
|
-
[DllImport("kernel32.dll", SetLastError=true)] static extern uint ResumeThread(IntPtr thread);
|
|
23000
|
-
[DllImport("kernel32.dll", SetLastError=true)] static extern IntPtr OpenProcess(uint access, bool inherit, int pid);
|
|
23001
|
-
[DllImport("kernel32.dll", SetLastError=true)] static extern uint WaitForMultipleObjects(uint count, IntPtr[] handles, bool all, uint ms);
|
|
23002
|
-
[DllImport("kernel32.dll")] static extern bool GetExitCodeProcess(IntPtr process, out uint code);
|
|
23003
|
-
[DllImport("kernel32.dll")] static extern bool CloseHandle(IntPtr handle);
|
|
23004
|
-
static void Check(bool ok) { if (!ok) throw new Win32Exception(Marshal.GetLastWin32Error()); }
|
|
23005
|
-
static IntPtr CopyStd(int id) {
|
|
23006
|
-
IntPtr result; var self = GetCurrentProcess();
|
|
23007
|
-
Check(DuplicateHandle(self, GetStdHandle(id), self, out result, 0, true, 2));
|
|
23008
|
-
return result;
|
|
23009
|
-
}
|
|
23010
|
-
public static int Run(string command, int ownerPid) {
|
|
23011
|
-
Environment.SetEnvironmentVariable("${JOB_COMMAND_VARIABLE}", null);
|
|
23012
|
-
IntPtr owner = OpenProcess(0x100000, false, ownerPid);
|
|
23013
|
-
if (owner == IntPtr.Zero) throw new Win32Exception(Marshal.GetLastWin32Error());
|
|
23014
|
-
IntPtr job = CreateJobObject(IntPtr.Zero, null);
|
|
23015
|
-
if (job == IntPtr.Zero) { CloseHandle(owner); throw new Win32Exception(Marshal.GetLastWin32Error()); }
|
|
23016
|
-
ProcessInfo pi = new ProcessInfo(); Startup si = new Startup();
|
|
23017
|
-
try {
|
|
23018
|
-
var limits = new ExtendedLimits(); limits.basic.flags = 0x2000;
|
|
23019
|
-
Check(SetInformationJobObject(job, 9, ref limits, (uint)Marshal.SizeOf(limits)));
|
|
23020
|
-
si.cb = (uint)Marshal.SizeOf(si); si.flags = 0x100;
|
|
23021
|
-
si.stdin = CopyStd(-10); si.stdout = CopyStd(-11); si.stderr = CopyStd(-12);
|
|
23022
|
-
Check(CreateProcess(null, new StringBuilder(command), IntPtr.Zero, IntPtr.Zero, true, 0x08000004, IntPtr.Zero, null, ref si, out pi));
|
|
23023
|
-
if (!AssignProcessToJobObject(job, pi.process)) {
|
|
23024
|
-
int error = Marshal.GetLastWin32Error(); TerminateProcess(pi.process, 1);
|
|
23025
|
-
throw new Win32Exception(error);
|
|
23026
|
-
}
|
|
23027
|
-
if (ResumeThread(pi.thread) == 0xffffffff) throw new Win32Exception(Marshal.GetLastWin32Error());
|
|
23028
|
-
uint wait = WaitForMultipleObjects(2, new IntPtr[] { pi.process, owner }, false, 0xffffffff);
|
|
23029
|
-
if (wait == 1) return 1;
|
|
23030
|
-
if (wait != 0) throw new Win32Exception(Marshal.GetLastWin32Error());
|
|
23031
|
-
uint code; Check(GetExitCodeProcess(pi.process, out code));
|
|
23032
|
-
Check(TerminateJobObject(job, code));
|
|
23033
|
-
return unchecked((int)code);
|
|
23034
|
-
} finally {
|
|
23035
|
-
CloseHandle(job);
|
|
23036
|
-
CloseHandle(owner);
|
|
23037
|
-
if (pi.thread != IntPtr.Zero) CloseHandle(pi.thread);
|
|
23038
|
-
if (pi.process != IntPtr.Zero) CloseHandle(pi.process);
|
|
23039
|
-
if (si.stdin != IntPtr.Zero) CloseHandle(si.stdin);
|
|
23040
|
-
if (si.stdout != IntPtr.Zero) CloseHandle(si.stdout);
|
|
23041
|
-
if (si.stderr != IntPtr.Zero) CloseHandle(si.stderr);
|
|
23042
|
-
}
|
|
23043
|
-
}
|
|
23044
|
-
}
|
|
23045
|
-
`;
|
|
23003
|
+
statuses = /* @__PURE__ */ new WeakMap();
|
|
23004
|
+
START_TIMEOUT_MS = 1e4;
|
|
23046
23005
|
}
|
|
23047
23006
|
});
|
|
23048
23007
|
|
|
@@ -23851,7 +23810,7 @@ var init_acp = __esm({
|
|
|
23851
23810
|
}
|
|
23852
23811
|
});
|
|
23853
23812
|
|
|
23854
|
-
// ../agent-core/dist/chunk-
|
|
23813
|
+
// ../agent-core/dist/chunk-UGRKZTAD.js
|
|
23855
23814
|
function textBlock(text2) {
|
|
23856
23815
|
return { type: "text", text: text2 };
|
|
23857
23816
|
}
|
|
@@ -23879,18 +23838,6 @@ function noticeUpdate(severity, kind, title, description) {
|
|
|
23879
23838
|
_meta: { [NOTICE_KIND_META]: kind }
|
|
23880
23839
|
};
|
|
23881
23840
|
}
|
|
23882
|
-
function contextRecallUpdate(toolCallId, recall) {
|
|
23883
|
-
return {
|
|
23884
|
-
sessionUpdate: "tool_call_update",
|
|
23885
|
-
toolCallId,
|
|
23886
|
-
name: "search_context",
|
|
23887
|
-
kind: "search",
|
|
23888
|
-
status: "completed",
|
|
23889
|
-
rawInput: { query: recall.query },
|
|
23890
|
-
rawOutput: JSON.stringify(recall.envelope),
|
|
23891
|
-
_meta: { [CONTEXT_RECALL_META]: "prefetch" }
|
|
23892
|
-
};
|
|
23893
|
-
}
|
|
23894
23841
|
function usageUpdate(breakdown, fallbackModel = "") {
|
|
23895
23842
|
const used = (breakdown.inputTokens ?? 0) + (breakdown.outputTokens ?? 0) + (breakdown.cacheReadTokens ?? 0) + (breakdown.cacheCreationTokens ?? 0);
|
|
23896
23843
|
const model = breakdown.model || fallbackModel;
|
|
@@ -24093,9 +24040,9 @@ function withoutInlineMedia(update) {
|
|
|
24093
24040
|
...nextRawOutput === rawOutput ? {} : { rawOutput: nextRawOutput }
|
|
24094
24041
|
};
|
|
24095
24042
|
}
|
|
24096
|
-
var PROVIDER_PAYLOAD_META, TOOL_RESULT_ONLY_META, PARENT_TOOL_CALL_META, SUBAGENT_LAUNCHER_META, SUBAGENT_TASK_ID_META, SUBAGENT_OUTPUT_FILE_META, USAGE_META, TODOS_META, NOTICE_KIND_META,
|
|
24097
|
-
var
|
|
24098
|
-
"../agent-core/dist/chunk-
|
|
24043
|
+
var PROVIDER_PAYLOAD_META, TOOL_RESULT_ONLY_META, PARENT_TOOL_CALL_META, SUBAGENT_LAUNCHER_META, SUBAGENT_TASK_ID_META, SUBAGENT_OUTPUT_FILE_META, USAGE_META, TODOS_META, NOTICE_KIND_META, ASK_USER_QUESTIONS_META, USER_ANSWER_META, AWAITING_TOOL_CALLS_META, EXIT_PLAN_MODE_INPUT_META, BACKGROUND_TASK_META, TASK_PROGRESS_META, RATE_LIMIT_META, MODEL_META, TOOLS_META, SLASH_COMMANDS_META, TOOL_KIND_RULES, ANSWER_PREFIX, ACCEPT_WORDS, MIN_INLINE_MEDIA_CHARS, DATA_URL_PREFIX, BASE64_BODY;
|
|
24044
|
+
var init_chunk_UGRKZTAD = __esm({
|
|
24045
|
+
"../agent-core/dist/chunk-UGRKZTAD.js"() {
|
|
24099
24046
|
"use strict";
|
|
24100
24047
|
init_chunk_YXWJW7I5();
|
|
24101
24048
|
init_constants();
|
|
@@ -24109,7 +24056,6 @@ var init_chunk_OUQ7HMD3 = __esm({
|
|
|
24109
24056
|
USAGE_META = "alan.dev/usage";
|
|
24110
24057
|
TODOS_META = "alan.dev/todos";
|
|
24111
24058
|
NOTICE_KIND_META = "alan.dev/noticeKind";
|
|
24112
|
-
CONTEXT_RECALL_META = "alan.dev/contextRecall";
|
|
24113
24059
|
ASK_USER_QUESTIONS_META = "alan.dev/askUserQuestions";
|
|
24114
24060
|
USER_ANSWER_META = "alan.dev/userAnswer";
|
|
24115
24061
|
AWAITING_TOOL_CALLS_META = "alan.dev/awaitingToolCallIds";
|
|
@@ -24146,12 +24092,12 @@ var init_chunk_OUQ7HMD3 = __esm({
|
|
|
24146
24092
|
var init_acp2 = __esm({
|
|
24147
24093
|
"../agent-core/dist/acp.js"() {
|
|
24148
24094
|
"use strict";
|
|
24149
|
-
|
|
24095
|
+
init_chunk_UGRKZTAD();
|
|
24150
24096
|
init_chunk_YXWJW7I5();
|
|
24151
24097
|
}
|
|
24152
24098
|
});
|
|
24153
24099
|
|
|
24154
|
-
// ../agent-core/dist/chunk-
|
|
24100
|
+
// ../agent-core/dist/chunk-DALFHI4B.js
|
|
24155
24101
|
function isRecordValue(value2) {
|
|
24156
24102
|
return value2 !== null;
|
|
24157
24103
|
}
|
|
@@ -24329,13 +24275,13 @@ function readTranscriptTurns(transcript, chunk, baseOffset, skipped = []) {
|
|
|
24329
24275
|
});
|
|
24330
24276
|
return { turns, consumedBytes: consumedEnd - baseOffset };
|
|
24331
24277
|
}
|
|
24332
|
-
var
|
|
24333
|
-
var
|
|
24334
|
-
"../agent-core/dist/chunk-
|
|
24278
|
+
var import_fs3, NEWLINE2, TranscriptCursor, TranscriptLineLookup, CONTENT_UPDATES;
|
|
24279
|
+
var init_chunk_DALFHI4B = __esm({
|
|
24280
|
+
"../agent-core/dist/chunk-DALFHI4B.js"() {
|
|
24335
24281
|
"use strict";
|
|
24336
|
-
|
|
24282
|
+
init_chunk_UGRKZTAD();
|
|
24337
24283
|
init_chunk_YXWJW7I5();
|
|
24338
|
-
|
|
24284
|
+
import_fs3 = require("fs");
|
|
24339
24285
|
NEWLINE2 = 10;
|
|
24340
24286
|
TranscriptCursor = class {
|
|
24341
24287
|
#path;
|
|
@@ -24353,7 +24299,7 @@ var init_chunk_LR52JUGL = __esm({
|
|
|
24353
24299
|
try {
|
|
24354
24300
|
this.#offset = Math.max(
|
|
24355
24301
|
this.#offset,
|
|
24356
|
-
(0,
|
|
24302
|
+
(0, import_fs3.statSync)(this.#path, { throwIfNoEntry: false })?.size ?? 0
|
|
24357
24303
|
);
|
|
24358
24304
|
} catch {
|
|
24359
24305
|
}
|
|
@@ -24375,15 +24321,15 @@ var init_chunk_LR52JUGL = __esm({
|
|
|
24375
24321
|
/** Runs on the CLI's stdout path, so an unreadable file reads as no new lines. */
|
|
24376
24322
|
#unread() {
|
|
24377
24323
|
try {
|
|
24378
|
-
const size = (0,
|
|
24324
|
+
const size = (0, import_fs3.statSync)(this.#path, { throwIfNoEntry: false })?.size ?? 0;
|
|
24379
24325
|
if (size <= this.#offset) return void 0;
|
|
24380
24326
|
const buffer = Buffer.alloc(size - this.#offset);
|
|
24381
|
-
const fd = (0,
|
|
24327
|
+
const fd = (0, import_fs3.openSync)(this.#path, "r");
|
|
24382
24328
|
try {
|
|
24383
|
-
const read = (0,
|
|
24329
|
+
const read = (0, import_fs3.readSync)(fd, buffer, 0, buffer.length, this.#offset);
|
|
24384
24330
|
return buffer.subarray(0, read);
|
|
24385
24331
|
} finally {
|
|
24386
|
-
(0,
|
|
24332
|
+
(0, import_fs3.closeSync)(fd);
|
|
24387
24333
|
}
|
|
24388
24334
|
} catch {
|
|
24389
24335
|
return void 0;
|
|
@@ -24581,7 +24527,7 @@ function createCliProblem(classified, options) {
|
|
|
24581
24527
|
return createAlanProblem({
|
|
24582
24528
|
domain: "agent_cli",
|
|
24583
24529
|
code: problemCodeFor(classified, options),
|
|
24584
|
-
id: options.id ?? (0,
|
|
24530
|
+
id: options.id ?? (0, import_crypto2.randomUUID)(),
|
|
24585
24531
|
title: terminal2 ? "Agent CLI run failed" : "Agent CLI problem observed",
|
|
24586
24532
|
detail: classified.message,
|
|
24587
24533
|
occurredAt: options.occurredAt,
|
|
@@ -24602,12 +24548,12 @@ function createCliProblem(classified, options) {
|
|
|
24602
24548
|
...classified.resetsAt ? { resetsAt: classified.resetsAt } : {}
|
|
24603
24549
|
});
|
|
24604
24550
|
}
|
|
24605
|
-
var
|
|
24551
|
+
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;
|
|
24606
24552
|
var init_chunk_R32NAS3B = __esm({
|
|
24607
24553
|
"../agent-core/dist/chunk-R32NAS3B.js"() {
|
|
24608
24554
|
"use strict";
|
|
24609
24555
|
init_chunk_YXWJW7I5();
|
|
24610
|
-
|
|
24556
|
+
import_crypto2 = require("crypto");
|
|
24611
24557
|
init_agent2();
|
|
24612
24558
|
ERROR_SPECS = {
|
|
24613
24559
|
model_mismatch: {
|
|
@@ -24842,7 +24788,7 @@ var init_chunk_R32NAS3B = __esm({
|
|
|
24842
24788
|
}
|
|
24843
24789
|
});
|
|
24844
24790
|
|
|
24845
|
-
// ../agent-core/dist/chunk-
|
|
24791
|
+
// ../agent-core/dist/chunk-X5JKSBTB.js
|
|
24846
24792
|
function collectStrings(value2, out) {
|
|
24847
24793
|
if (typeof value2 === "string") out.push(value2);
|
|
24848
24794
|
else if (Array.isArray(value2)) for (const item of value2) collectStrings(item, out);
|
|
@@ -24930,13 +24876,13 @@ function readMediaFiles(candidates2, cwd, mimeByExt, maxBytes) {
|
|
|
24930
24876
|
const files = [];
|
|
24931
24877
|
for (const candidate of candidates2) {
|
|
24932
24878
|
const path4 = normalizePath(candidate, cwd);
|
|
24933
|
-
if (!path4 || seen.has(path4) || !(0,
|
|
24879
|
+
if (!path4 || seen.has(path4) || !(0, import_fs4.existsSync)(path4)) continue;
|
|
24934
24880
|
seen.add(path4);
|
|
24935
24881
|
const mimeType = mimeByExt[(0, import_path3.extname)(path4).toLowerCase()];
|
|
24936
24882
|
if (!mimeType) continue;
|
|
24937
|
-
const stat19 = (0,
|
|
24883
|
+
const stat19 = (0, import_fs4.statSync)(path4);
|
|
24938
24884
|
if (!stat19.isFile() || stat19.size <= 0 || stat19.size > maxBytes) continue;
|
|
24939
|
-
files.push({ path: path4, mimeType, buffer: (0,
|
|
24885
|
+
files.push({ path: path4, mimeType, buffer: (0, import_fs4.readFileSync)(path4) });
|
|
24940
24886
|
}
|
|
24941
24887
|
return files;
|
|
24942
24888
|
}
|
|
@@ -25211,16 +25157,16 @@ function silentStartError(name, timeoutMs) {
|
|
|
25211
25157
|
message: `${name} printed nothing for ${seconds}s after it started and was stopped. Send your message again.`
|
|
25212
25158
|
};
|
|
25213
25159
|
}
|
|
25214
|
-
var
|
|
25215
|
-
var
|
|
25216
|
-
"../agent-core/dist/chunk-
|
|
25160
|
+
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;
|
|
25161
|
+
var init_chunk_X5JKSBTB = __esm({
|
|
25162
|
+
"../agent-core/dist/chunk-X5JKSBTB.js"() {
|
|
25217
25163
|
"use strict";
|
|
25218
|
-
|
|
25164
|
+
init_chunk_UGRKZTAD();
|
|
25219
25165
|
init_chunk_R32NAS3B();
|
|
25220
|
-
|
|
25166
|
+
init_chunk_NDAB5G24();
|
|
25221
25167
|
init_chunk_YXWJW7I5();
|
|
25222
|
-
|
|
25223
|
-
|
|
25168
|
+
import_crypto3 = require("crypto");
|
|
25169
|
+
import_fs4 = require("fs");
|
|
25224
25170
|
import_path3 = require("path");
|
|
25225
25171
|
init_agent2();
|
|
25226
25172
|
init_acp();
|
|
@@ -25281,13 +25227,13 @@ var init_chunk_2KE6BVIX = __esm({
|
|
|
25281
25227
|
}
|
|
25282
25228
|
#payloadFields(file2, toolId) {
|
|
25283
25229
|
return {
|
|
25284
|
-
id: (0,
|
|
25230
|
+
id: (0, import_crypto3.randomUUID)(),
|
|
25285
25231
|
filename: (0, import_path3.basename)(file2.path),
|
|
25286
25232
|
mimeType: file2.mimeType,
|
|
25287
25233
|
size: file2.buffer.length,
|
|
25288
25234
|
data: file2.buffer.toString("base64"),
|
|
25289
25235
|
sourcePath: file2.path,
|
|
25290
|
-
sourceHash: (0,
|
|
25236
|
+
sourceHash: (0, import_crypto3.createHash)("sha256").update(file2.buffer).digest("hex"),
|
|
25291
25237
|
toolId,
|
|
25292
25238
|
ts: this.#clock.now()
|
|
25293
25239
|
};
|
|
@@ -25571,7 +25517,7 @@ function selectExternalMcpServers(spec) {
|
|
|
25571
25517
|
return selected;
|
|
25572
25518
|
}
|
|
25573
25519
|
function headerEnvName(server, header) {
|
|
25574
|
-
const fingerprint = (0,
|
|
25520
|
+
const fingerprint = (0, import_crypto4.createHash)("sha256").update(`${server}\0${header}`).digest("hex").slice(0, 12);
|
|
25575
25521
|
return `ALAN_MCP_HEADER_${fingerprint.toUpperCase()}`;
|
|
25576
25522
|
}
|
|
25577
25523
|
function deliverRemote(name, server, env) {
|
|
@@ -25635,7 +25581,7 @@ function managedMcpHeaders(identity) {
|
|
|
25635
25581
|
}
|
|
25636
25582
|
function credentialDigest(authorization) {
|
|
25637
25583
|
if (authorization === void 0) return void 0;
|
|
25638
|
-
return (0,
|
|
25584
|
+
return (0, import_crypto5.createHash)("sha256").update(authorization).digest("hex").slice(0, 16);
|
|
25639
25585
|
}
|
|
25640
25586
|
function canonicalizeManagedMcpServerName(serverName) {
|
|
25641
25587
|
return RUN_SCOPED_SERVER.test(serverName) ? MANAGED_MCP_SERVER_NAME : serverName;
|
|
@@ -25647,30 +25593,30 @@ function canonicalizeManagedMcpToolName(toolName2) {
|
|
|
25647
25593
|
return flattened ? `mcp__${MANAGED_MCP_SERVER_NAME}__${flattened[1]}` : toolName2;
|
|
25648
25594
|
}
|
|
25649
25595
|
async function writeSecretFile(name, contents) {
|
|
25650
|
-
const dir = await (0,
|
|
25596
|
+
const dir = await (0, import_promises29.mkdtemp)((0, import_path4.join)((0, import_os2.tmpdir)(), "alan-mcp-"));
|
|
25651
25597
|
const path4 = (0, import_path4.join)(dir, name);
|
|
25652
25598
|
const remove = async () => {
|
|
25653
|
-
await (0,
|
|
25599
|
+
await (0, import_promises29.rm)(dir, { recursive: true, force: true });
|
|
25654
25600
|
};
|
|
25655
25601
|
try {
|
|
25656
|
-
await (0,
|
|
25602
|
+
await (0, import_promises29.writeFile)(path4, contents, { mode: 384, flag: "wx" });
|
|
25657
25603
|
} catch (error61) {
|
|
25658
25604
|
await remove();
|
|
25659
25605
|
throw error61;
|
|
25660
25606
|
}
|
|
25661
25607
|
return { path: path4, remove, [Symbol.asyncDispose]: remove };
|
|
25662
25608
|
}
|
|
25663
|
-
var
|
|
25609
|
+
var import_crypto4, import_crypto5, import_promises29, import_os2, import_path4, MANAGED_MCP_SERVER_NAME, RUN_SCOPED_SERVER, NAMESPACED_RUN_TOOL, FLATTENED_RUN_TOOL;
|
|
25664
25610
|
var init_chunk_J2KTV5FP = __esm({
|
|
25665
25611
|
"../agent-core/dist/chunk-J2KTV5FP.js"() {
|
|
25666
25612
|
"use strict";
|
|
25667
|
-
import_crypto3 = require("crypto");
|
|
25668
|
-
init_agent2();
|
|
25669
25613
|
import_crypto4 = require("crypto");
|
|
25670
25614
|
init_agent2();
|
|
25615
|
+
import_crypto5 = require("crypto");
|
|
25616
|
+
init_agent2();
|
|
25671
25617
|
init_runtime_v2();
|
|
25672
|
-
|
|
25673
|
-
|
|
25618
|
+
import_promises29 = require("fs/promises");
|
|
25619
|
+
import_os2 = require("os");
|
|
25674
25620
|
import_path4 = require("path");
|
|
25675
25621
|
MANAGED_MCP_SERVER_NAME = "alan";
|
|
25676
25622
|
RUN_SCOPED_SERVER = /^alan-run-[a-f0-9]{16}$/;
|
|
@@ -25679,7 +25625,7 @@ var init_chunk_J2KTV5FP = __esm({
|
|
|
25679
25625
|
}
|
|
25680
25626
|
});
|
|
25681
25627
|
|
|
25682
|
-
// ../agent-core/dist/chunk-
|
|
25628
|
+
// ../agent-core/dist/chunk-6WN2R725.js
|
|
25683
25629
|
function truncate(value2, limit) {
|
|
25684
25630
|
const normalized2 = Array.from(value2, (character) => {
|
|
25685
25631
|
const code = character.charCodeAt(0);
|
|
@@ -25881,7 +25827,6 @@ function artifactIdsSection(owner) {
|
|
|
25881
25827
|
const ids = artifactIds(owner);
|
|
25882
25828
|
if (ids.length === 0) return void 0;
|
|
25883
25829
|
const tools = ["create_plan", "create_document_artifact", "create_test_report"];
|
|
25884
|
-
if (owner.taskId || owner.isWorkflowSession) tools.push("upsert_prototype_version");
|
|
25885
25830
|
return [
|
|
25886
25831
|
`When creating artifacts using MCP tools (${tools.join(", ")}), always pass these IDs:`,
|
|
25887
25832
|
...ids
|
|
@@ -25893,26 +25838,6 @@ function standaloneChatSection(owner) {
|
|
|
25893
25838
|
}
|
|
25894
25839
|
return "This is a standalone chat. For create_plan, create_document_artifact, and create_test_report, omit taskId and workflowId; conversationId is the artifact owner. Do not use create_document unless the user explicitly asks for a standalone team Document.";
|
|
25895
25840
|
}
|
|
25896
|
-
function prototypeScope(owner) {
|
|
25897
|
-
if (owner.workflowId) {
|
|
25898
|
-
return {
|
|
25899
|
-
ids: "teamId, workflowId, workflowExecutionId, conversationId",
|
|
25900
|
-
lookup: "list_prototypes (with workflowId) or get_prototype"
|
|
25901
|
-
};
|
|
25902
|
-
}
|
|
25903
|
-
return owner.taskId ? { ids: "teamId, taskId, conversationId", lookup: "list_prototypes or get_prototype" } : void 0;
|
|
25904
|
-
}
|
|
25905
|
-
function prototypeSection(owner) {
|
|
25906
|
-
if (!owner.conversationId || !owner.teamId) return void 0;
|
|
25907
|
-
const scope = prototypeScope(owner);
|
|
25908
|
-
if (!scope) return void 0;
|
|
25909
|
-
return [
|
|
25910
|
-
"## Prototype Artifacts",
|
|
25911
|
-
"When the user asks to create, build, modify, or iterate on a prototype, do not create local prototype files such as prototype/index.html.",
|
|
25912
|
-
`Instead, generate a Vite React TypeScript source snapshot and call the Alan MCP tool upsert_prototype_version with ${scope.ids}, title, sourceSnapshot, and packageJson.`,
|
|
25913
|
-
`For follow-up changes to the same prototype, call ${scope.lookup} if needed, then call upsert_prototype_version again with the existing prototypeId and parentVersionId.`
|
|
25914
|
-
].join("\n");
|
|
25915
|
-
}
|
|
25916
25841
|
function contextSections(spec) {
|
|
25917
25842
|
const owner = ownershipOf(spec);
|
|
25918
25843
|
const context = spec.promptContext;
|
|
@@ -25921,8 +25846,7 @@ function contextSections(spec) {
|
|
|
25921
25846
|
taskContextSection(context?.taskMeta),
|
|
25922
25847
|
pullRequestSection(context?.prMeta),
|
|
25923
25848
|
artifactIdsSection(owner),
|
|
25924
|
-
standaloneChatSection(owner)
|
|
25925
|
-
prototypeSection(owner)
|
|
25849
|
+
standaloneChatSection(owner)
|
|
25926
25850
|
].filter((section) => section !== void 0);
|
|
25927
25851
|
}
|
|
25928
25852
|
function taskLifecycleSection(spec) {
|
|
@@ -25972,7 +25896,7 @@ Prefer relative paths and keep your work scoped to this project.` : void 0;
|
|
|
25972
25896
|
]),
|
|
25973
25897
|
append: present([
|
|
25974
25898
|
ALAN_PLATFORM_TOOL_ROUTING_PROMPT,
|
|
25975
|
-
spec.contextGraphEnabled ===
|
|
25899
|
+
spec.contextGraphEnabled === true ? ALAN_CONTEXT_SEARCH_PROMPT : void 0,
|
|
25976
25900
|
overlay
|
|
25977
25901
|
])
|
|
25978
25902
|
};
|
|
@@ -26028,8 +25952,8 @@ ${body}` : body;
|
|
|
26028
25952
|
return spec.mode === "plan" ? planModePrefix(prefixed) : prefixed;
|
|
26029
25953
|
}
|
|
26030
25954
|
var MAX_PARSED_ATTACHMENTS, MAX_PARSED_ATTACHMENT_CHARS, MAX_METADATA_CHARS, UNAVAILABLE, READ_ONLY_MODES, AGENT_MODES;
|
|
26031
|
-
var
|
|
26032
|
-
"../agent-core/dist/chunk-
|
|
25955
|
+
var init_chunk_6WN2R725 = __esm({
|
|
25956
|
+
"../agent-core/dist/chunk-6WN2R725.js"() {
|
|
26033
25957
|
"use strict";
|
|
26034
25958
|
init_agent2();
|
|
26035
25959
|
MAX_PARSED_ATTACHMENTS = 3;
|
|
@@ -27007,7 +26931,7 @@ function encodeProjectDir(cwd) {
|
|
|
27007
26931
|
}
|
|
27008
26932
|
function realCwd(cwd) {
|
|
27009
26933
|
try {
|
|
27010
|
-
return (0,
|
|
26934
|
+
return (0, import_fs5.realpathSync)(cwd);
|
|
27011
26935
|
} catch {
|
|
27012
26936
|
return cwd;
|
|
27013
26937
|
}
|
|
@@ -27021,12 +26945,12 @@ function claudeSessionLogExists(query) {
|
|
|
27021
26945
|
encodeProjectDir(cwd),
|
|
27022
26946
|
`${query.sessionId}.jsonl`
|
|
27023
26947
|
);
|
|
27024
|
-
if ((0,
|
|
26948
|
+
if ((0, import_fs5.existsSync)(log)) return true;
|
|
27025
26949
|
}
|
|
27026
26950
|
return false;
|
|
27027
26951
|
}
|
|
27028
26952
|
function envDigest(env) {
|
|
27029
|
-
const hash2 = (0,
|
|
26953
|
+
const hash2 = (0, import_crypto7.createHash)("sha256");
|
|
27030
26954
|
for (const key of Object.keys(env).sort()) hash2.update(`${key}\0${env[key]}\0`);
|
|
27031
26955
|
return hash2.digest("hex");
|
|
27032
26956
|
}
|
|
@@ -27089,7 +27013,7 @@ async function claudeTurnInput(run2, context) {
|
|
|
27089
27013
|
const encoded = await Promise.all(
|
|
27090
27014
|
images.map(async (image) => ({
|
|
27091
27015
|
mimeType: image.mimeType,
|
|
27092
|
-
data: (await (0,
|
|
27016
|
+
data: (await (0, import_promises30.readFile)(image.path)).toString("base64")
|
|
27093
27017
|
}))
|
|
27094
27018
|
);
|
|
27095
27019
|
return { turnId: run2.runId, text: text2, ...encoded.length ? { images: encoded } : {} };
|
|
@@ -27288,30 +27212,30 @@ function claudeTurnClosingUpdates(records, state) {
|
|
|
27288
27212
|
function readClaudeTranscriptTurns(chunk, baseOffset, skipped) {
|
|
27289
27213
|
return readTranscriptTurns(claudeTranscriptFile, chunk, baseOffset, skipped);
|
|
27290
27214
|
}
|
|
27291
|
-
var
|
|
27215
|
+
var import_crypto6, import_fs5, import_path5, import_crypto7, import_promises30, 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, SYNTHETIC_MODEL, INTERRUPT_MARKER, NON_PROMPT_PREFIXES, PRELUDE_TYPES, claudeTranscriptFile;
|
|
27292
27216
|
var init_claude = __esm({
|
|
27293
27217
|
"../agent-core/dist/providers/claude.js"() {
|
|
27294
27218
|
"use strict";
|
|
27295
|
-
|
|
27296
|
-
|
|
27297
|
-
|
|
27219
|
+
init_chunk_DALFHI4B();
|
|
27220
|
+
init_chunk_X5JKSBTB();
|
|
27221
|
+
init_chunk_UGRKZTAD();
|
|
27298
27222
|
init_chunk_R32NAS3B();
|
|
27299
27223
|
init_chunk_J2KTV5FP();
|
|
27300
|
-
|
|
27301
|
-
|
|
27224
|
+
init_chunk_NDAB5G24();
|
|
27225
|
+
init_chunk_6WN2R725();
|
|
27302
27226
|
init_chunk_YXWJW7I5();
|
|
27303
27227
|
init_effort();
|
|
27304
|
-
|
|
27228
|
+
import_crypto6 = require("crypto");
|
|
27305
27229
|
init_constants();
|
|
27306
27230
|
init_zod();
|
|
27307
27231
|
init_acp();
|
|
27308
27232
|
init_acp();
|
|
27309
27233
|
init_constants();
|
|
27310
27234
|
init_agent2();
|
|
27311
|
-
|
|
27235
|
+
import_fs5 = require("fs");
|
|
27312
27236
|
import_path5 = require("path");
|
|
27313
|
-
|
|
27314
|
-
|
|
27237
|
+
import_crypto7 = require("crypto");
|
|
27238
|
+
import_promises30 = require("fs/promises");
|
|
27315
27239
|
init_agent2();
|
|
27316
27240
|
EDIT_TOOLS = /* @__PURE__ */ new Set([
|
|
27317
27241
|
"Edit",
|
|
@@ -27953,7 +27877,7 @@ var init_claude = __esm({
|
|
|
27953
27877
|
sessionId: this.#lastTurn.grammar.sessionId,
|
|
27954
27878
|
taskRecords: this.#taskRecords
|
|
27955
27879
|
});
|
|
27956
|
-
const messageId = this.#replaysUserMessages ? (0,
|
|
27880
|
+
const messageId = this.#replaysUserMessages ? (0, import_crypto6.randomUUID)() : void 0;
|
|
27957
27881
|
const active = this.#startTurn(input2.turnId, turn, messageId);
|
|
27958
27882
|
this.#host.writer.write(claudeUserMessage(input2, messageId)).catch((error61) => {
|
|
27959
27883
|
this.#options.log.warn("claude.stdin_write_failed", { turnId: input2.turnId, error: error61 });
|
|
@@ -28371,7 +28295,7 @@ function codexHomeOf(env) {
|
|
|
28371
28295
|
}
|
|
28372
28296
|
function namesNewestFirst(dir, isDir) {
|
|
28373
28297
|
try {
|
|
28374
|
-
return (0,
|
|
28298
|
+
return (0, import_fs6.readdirSync)(dir, { withFileTypes: true }).filter((entry) => isDir ? entry.isDirectory() : entry.isFile()).map((entry) => entry.name).sort().reverse();
|
|
28375
28299
|
} catch {
|
|
28376
28300
|
return [];
|
|
28377
28301
|
}
|
|
@@ -28551,7 +28475,7 @@ function codexGeneratedImage(payload, ts) {
|
|
|
28551
28475
|
const declared = asString(payload.mimeType) || asString(payload.mime_type);
|
|
28552
28476
|
const mimeType = declared.startsWith("image/") ? declared : inferImageMimeType(buffer);
|
|
28553
28477
|
if (!mimeType) return null;
|
|
28554
|
-
const sourceHash = (0,
|
|
28478
|
+
const sourceHash = (0, import_crypto8.createHash)("sha256").update(buffer).digest("hex");
|
|
28555
28479
|
const toolId = asString(payload.call_id);
|
|
28556
28480
|
const id = asString(payload.id) || toolId || sourceHash;
|
|
28557
28481
|
const sourcePath = asString(payload.sourcePath);
|
|
@@ -28602,7 +28526,7 @@ function basenameOf(path4) {
|
|
|
28602
28526
|
return path4.split(/[\\/]/).at(-1) ?? "";
|
|
28603
28527
|
}
|
|
28604
28528
|
function mayMatter(line) {
|
|
28605
|
-
return line.includes("image_gen")
|
|
28529
|
+
return line.includes("image_gen");
|
|
28606
28530
|
}
|
|
28607
28531
|
function imageKey(update) {
|
|
28608
28532
|
if (update.sessionUpdate !== "_alan/generated_image") return void 0;
|
|
@@ -29333,7 +29257,7 @@ function createCodexExecDriver(options = {}) {
|
|
|
29333
29257
|
};
|
|
29334
29258
|
}
|
|
29335
29259
|
function envDigest2(env) {
|
|
29336
|
-
const hash2 = (0,
|
|
29260
|
+
const hash2 = (0, import_crypto9.createHash)("sha256");
|
|
29337
29261
|
for (const key of Object.keys(env).sort()) hash2.update(`${key}\0${env[key]}\0`);
|
|
29338
29262
|
return hash2.digest("hex");
|
|
29339
29263
|
}
|
|
@@ -29995,7 +29919,7 @@ function readCodexRolloutTurns(chunk, baseOffset, skipped) {
|
|
|
29995
29919
|
return readTranscriptTurns(codexRolloutFile, chunk, baseOffset, skipped);
|
|
29996
29920
|
}
|
|
29997
29921
|
function envDigest22(env) {
|
|
29998
|
-
const hash2 = (0,
|
|
29922
|
+
const hash2 = (0, import_crypto10.createHash)("sha256");
|
|
29999
29923
|
for (const key of Object.keys(env).sort()) hash2.update(`${key}\0${env[key]}\0`);
|
|
30000
29924
|
return hash2.digest("hex");
|
|
30001
29925
|
}
|
|
@@ -30064,26 +29988,26 @@ function codexTurnInput(run2, context) {
|
|
|
30064
29988
|
...images.length ? { imagePaths: images.map((image) => image.path) } : {}
|
|
30065
29989
|
};
|
|
30066
29990
|
}
|
|
30067
|
-
var
|
|
29991
|
+
var import_fs6, import_path6, import_crypto8, import_crypto9, import_crypto10, TokenRefresher, MCP_STARTUP_TIMEOUT_SEC, FIELD_TYPES, YES_NO, ACCEPT_DECLINE, MAX_INLINE_GENERATED_IMAGE_BYTES, PNG_SIGNATURE, JPEG_NON_FRAME_MARKERS, IMAGE_GEN_CALL, PROMPT_LITERAL, RELOCATE_EVERY_MS, CodexImageGenerationFold, CodexRolloutImages, USER_INPUT_METHOD, PERMISSIONS_METHOD, ELICITATION_METHOD, COMMAND_OR_FILE, LEGACY, DECISIONS, COORDINATION_TOOLS, SETTLED_AGENT, STATUS, CHANGE_OPERATIONS, SILENT_ON_START, IGNORED_ITEMS, PLAN_STATUS, WORKER_LIFECYCLE, INFO_KINDS, SILENT, CodexTurn, STDERR_TAIL_LINES3, MAX_BETWEEN_UPDATES, UNSUPPORTED_REQUEST, DECLINED_ELICITATION, IMAGE_CATCH_UP_MS, IMAGE_POLL_MS, CodexSession, CODEX_MIN_VERSION, CODEX_REQUIREMENT, CODEX_TESTED_LINE, DEFAULTS2, CLIENT_INFO, STATUS2, EXITED_WITHOUT_RESPONSE, CodexExecTurn, DEFAULTS22, CodexExecSession, INJECTED_USER_PREFIXES, SHELL_TOOL_NAMES, ANNOUNCING_ITEM_TYPES, OUTPUT_MARKER, OPEN_PAGE_ACTIONS, FIND_IN_PAGE_ACTIONS, FILE_OPERATIONS, UNDERSTOOD_ITEM_TYPES, PRELUDE_TYPES2, PRELUDE_EVENTS, codexRolloutFile;
|
|
30068
29992
|
var init_codex = __esm({
|
|
30069
29993
|
"../agent-core/dist/providers/codex.js"() {
|
|
30070
29994
|
"use strict";
|
|
30071
|
-
|
|
30072
|
-
|
|
30073
|
-
|
|
29995
|
+
init_chunk_DALFHI4B();
|
|
29996
|
+
init_chunk_X5JKSBTB();
|
|
29997
|
+
init_chunk_UGRKZTAD();
|
|
30074
29998
|
init_chunk_R32NAS3B();
|
|
30075
29999
|
init_chunk_J2KTV5FP();
|
|
30076
|
-
|
|
30077
|
-
|
|
30000
|
+
init_chunk_NDAB5G24();
|
|
30001
|
+
init_chunk_6WN2R725();
|
|
30078
30002
|
init_chunk_YXWJW7I5();
|
|
30079
|
-
|
|
30003
|
+
import_fs6 = require("fs");
|
|
30080
30004
|
import_path6 = require("path");
|
|
30081
30005
|
init_effort();
|
|
30082
|
-
import_crypto7 = require("crypto");
|
|
30083
|
-
init_agent2();
|
|
30084
30006
|
import_crypto8 = require("crypto");
|
|
30085
30007
|
init_agent2();
|
|
30086
30008
|
import_crypto9 = require("crypto");
|
|
30009
|
+
init_agent2();
|
|
30010
|
+
import_crypto10 = require("crypto");
|
|
30087
30011
|
init_effort();
|
|
30088
30012
|
TokenRefresher = class {
|
|
30089
30013
|
#auth;
|
|
@@ -30128,19 +30052,17 @@ var init_codex = __esm({
|
|
|
30128
30052
|
JPEG_NON_FRAME_MARKERS = /* @__PURE__ */ new Set([196, 200, 204]);
|
|
30129
30053
|
IMAGE_GEN_CALL = /\bimage_gen\w*\s*\(/;
|
|
30130
30054
|
PROMPT_LITERAL = /\bprompt\s*:\s*("(?:[^"\\]|\\.)*")/;
|
|
30131
|
-
TURN_END_EVENTS = /* @__PURE__ */ new Set(["task_complete", "turn_aborted"]);
|
|
30132
30055
|
RELOCATE_EVERY_MS = 1e3;
|
|
30133
30056
|
CodexImageGenerationFold = class {
|
|
30134
30057
|
#clock;
|
|
30135
30058
|
#pending = [];
|
|
30136
30059
|
#updates = [];
|
|
30137
|
-
#turnEnded = false;
|
|
30138
30060
|
constructor(clock) {
|
|
30139
30061
|
this.#clock = clock;
|
|
30140
30062
|
}
|
|
30141
|
-
/** A call is still waiting for its image
|
|
30063
|
+
/** A call is still waiting for its image. */
|
|
30142
30064
|
get waiting() {
|
|
30143
|
-
return this.#pending.length > 0
|
|
30065
|
+
return this.#pending.length > 0;
|
|
30144
30066
|
}
|
|
30145
30067
|
foldLine(text2) {
|
|
30146
30068
|
if (!mayMatter(text2)) return;
|
|
@@ -30163,7 +30085,6 @@ var init_codex = __esm({
|
|
|
30163
30085
|
}
|
|
30164
30086
|
if (entryType !== "event_msg") return;
|
|
30165
30087
|
const type = asString(payload.type);
|
|
30166
|
-
if (TURN_END_EVENTS.has(type)) this.#turnEnded = true;
|
|
30167
30088
|
if (type === "image_generation_end") {
|
|
30168
30089
|
this.#finish(payload, ts);
|
|
30169
30090
|
return;
|
|
@@ -30247,7 +30168,7 @@ var init_codex = __esm({
|
|
|
30247
30168
|
settle() {
|
|
30248
30169
|
return [...this.drain(), ...this.#fold.settlePending()];
|
|
30249
30170
|
}
|
|
30250
|
-
/** Waits, up to `ms`, for
|
|
30171
|
+
/** Waits, up to `ms`, for pending images. A prior turn's end can trail this turn's start. */
|
|
30251
30172
|
async catchUp(ms, pollMs) {
|
|
30252
30173
|
const updates = this.drain();
|
|
30253
30174
|
const deadline = this.#clock.monotonic() + ms;
|
|
@@ -31295,9 +31216,9 @@ function packagedAlanCodeEnginePath(bundle, platform3) {
|
|
|
31295
31216
|
}
|
|
31296
31217
|
function isRunnableFile(path4, platform3) {
|
|
31297
31218
|
try {
|
|
31298
|
-
if (!(0,
|
|
31219
|
+
if (!(0, import_fs7.statSync)(path4).isFile()) return false;
|
|
31299
31220
|
if (platform3 === "win32") return WINDOWS_RUNNABLE_EXTENSION.test(path4);
|
|
31300
|
-
(0,
|
|
31221
|
+
(0, import_fs7.accessSync)(path4, import_fs7.constants.X_OK);
|
|
31301
31222
|
return true;
|
|
31302
31223
|
} catch {
|
|
31303
31224
|
return false;
|
|
@@ -31466,18 +31387,18 @@ function alanCodeEngineEnv(input2) {
|
|
|
31466
31387
|
};
|
|
31467
31388
|
}
|
|
31468
31389
|
async function writePlugin(directory, apiOrigin) {
|
|
31469
|
-
const origin = (0,
|
|
31390
|
+
const origin = (0, import_crypto11.createHash)("sha256").update(apiOrigin).digest("hex").slice(0, 12);
|
|
31470
31391
|
const target = (0, import_path8.join)(directory, `engine-plugin-v${ALAN_CODE_ENGINE_PLUGIN_VERSION}-${origin}.mjs`);
|
|
31471
|
-
const temporary = `${target}.${(0,
|
|
31472
|
-
await (0,
|
|
31473
|
-
await (0,
|
|
31474
|
-
await (0,
|
|
31392
|
+
const temporary = `${target}.${(0, import_crypto11.randomUUID)()}.tmp`;
|
|
31393
|
+
await (0, import_promises33.mkdir)(directory, { recursive: true, mode: 448 });
|
|
31394
|
+
await (0, import_promises33.writeFile)(temporary, alanCodeEnginePluginSource(apiOrigin), { mode: 384 });
|
|
31395
|
+
await (0, import_promises33.rename)(temporary, target);
|
|
31475
31396
|
return (0, import_url.pathToFileURL)(target).href;
|
|
31476
31397
|
}
|
|
31477
31398
|
async function prepareAlanCodeProfile(input2) {
|
|
31478
31399
|
const directories = Object.values(alanCodeEngineDirectories(input2.engineRoot));
|
|
31479
31400
|
await Promise.all(
|
|
31480
|
-
directories.map((directory) => (0,
|
|
31401
|
+
directories.map((directory) => (0, import_promises33.mkdir)(directory, { recursive: true, mode: 448 }))
|
|
31481
31402
|
);
|
|
31482
31403
|
const [pluginUrl, models] = await Promise.all([
|
|
31483
31404
|
writePlugin((0, import_path8.join)(input2.engineRoot, "plugin"), input2.access.apiOrigin),
|
|
@@ -31500,7 +31421,7 @@ function alanCodeSystemPrompt(alanSystemPrompt) {
|
|
|
31500
31421
|
|
|
31501
31422
|
${instructions}` : ALAN_CODE_TOOL_NAMING_PROMPT;
|
|
31502
31423
|
}
|
|
31503
|
-
var import_http9, import_https,
|
|
31424
|
+
var import_http9, import_https, import_fs7, import_path7, import_crypto11, import_promises33, 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, 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;
|
|
31504
31425
|
var init_alan_code = __esm({
|
|
31505
31426
|
"../agent-core/dist/providers/alan-code.js"() {
|
|
31506
31427
|
"use strict";
|
|
@@ -31510,11 +31431,11 @@ var init_alan_code = __esm({
|
|
|
31510
31431
|
init_runtime_v2();
|
|
31511
31432
|
init_runtime_v2();
|
|
31512
31433
|
init_models();
|
|
31513
|
-
|
|
31434
|
+
import_fs7 = require("fs");
|
|
31514
31435
|
import_path7 = require("path");
|
|
31515
31436
|
init_runtime_v2();
|
|
31516
|
-
|
|
31517
|
-
|
|
31437
|
+
import_crypto11 = require("crypto");
|
|
31438
|
+
import_promises33 = require("fs/promises");
|
|
31518
31439
|
import_path8 = require("path");
|
|
31519
31440
|
import_url = require("url");
|
|
31520
31441
|
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\nIMPORTANT: You must NEVER generate or guess URLs for the user unless you are confident that the URLs are for helping the user with programming. You may use URLs provided by the user in their messages or local files.\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\nYou have access to a `todowrite` tool which tracks steps and progress and renders them to the user. Using the tool helps demonstrate that you've understood the task and convey how you're approaching it. Plans can help to make complex, ambiguous, or multi-phase work clearer and more collaborative for the user. A good plan should break the task into meaningful, logically ordered steps that are easy to verify as you go.\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\nDo not repeat the full contents of the plan after a `todowrite` call \u2014 the harness already displays it. Instead, summarize the change made and highlight any important context or next step.\n\nBefore running a command, consider whether or not you have completed the previous step, and make sure to mark it as completed before moving on to the next step. It may be the case that you complete all steps in your plan after a single pass of implementation. If this is the case, you can simply mark all the planned steps as completed. Sometimes, you may need to change plans in the middle of a task: call `todowrite` with the updated plan and make sure to explain the rationale when doing so.\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- For multi-step or risky work, enter plan mode (`/plan` or `--plan`) before editing. Explore read-only, then call `plan_write` with a decision-complete markdown plan (approach, rejected alternatives, verification, assumptions). Wait for user approval before implementing.\n- Prefer the durable plan file path over relying on chat memory after compaction.\n- When requirements are ambiguous, use the `question` tool with concrete options instead of guessing.\n- `todowrite` tracks execution steps (see its Tool Guidelines entry); it is not a substitute for a durable plan file.\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 `edit` tool to modify existing files and the `write` tool to create new ones. This harness has no structured-patch tool \u2014 never try `apply_patch`, `applypatch`, or `apply-patch`.\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- Do not add inline comments within code unless explicitly requested.\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- When working in interactive permission modes like `ask before edits` or `plan`, hold off on running tests or lint commands until the user is ready for you to finalize your output, because these commands take time to run and slow down iteration. Instead suggest what you want to do next, and let the user confirm first.\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\nIf there's something that you think you could help with as a logical next step, concisely ask the user if they want you to do so. Good examples of this are running tests, committing changes, or building out the next logical component. If there's something that you couldn't do (even with approval) but that the user might want to do (such as verifying changes by running the app), include those instructions succinctly.\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- Leave no blank line before the first bullet under a header.\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\nYou may be proactive, but only when the user asks you to do something. 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 over creating new ones. Do not create documentation or markdown files unless asked.\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, prefer a task/subagent tool if one is available to reduce context usage; otherwise use the available search tools.\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\n## `todowrite`\n\nA tool named `todowrite` is available to you. You can use it to keep an up-to-date, step-by-step plan for the task.\n\nTo create a new plan, call `todowrite` with a short list of 1-sentence steps (no more than 5-7 words each) with a `status` for each step (`pending`, `in_progress`, `completed`, or `cancelled`). The call is a full replace \u2014 always send the complete list, not a delta.\n\nWhen steps have been completed, use `todowrite` to mark each finished step as `completed` and the next step you are working on as `in_progress`. There should always be exactly one `in_progress` step until everything is done. You can mark multiple items as complete in a single `todowrite` call.\n\nIf all steps are complete, ensure you call `todowrite` to mark all steps as `completed`.\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";
|
|
@@ -41309,10 +41230,10 @@ var require_tar_stream = __commonJS({
|
|
|
41309
41230
|
var init_dist = __esm({
|
|
41310
41231
|
"../agent-core/dist/index.js"() {
|
|
41311
41232
|
"use strict";
|
|
41312
|
-
|
|
41313
|
-
|
|
41233
|
+
init_chunk_X5JKSBTB();
|
|
41234
|
+
init_chunk_UGRKZTAD();
|
|
41314
41235
|
init_chunk_R32NAS3B();
|
|
41315
|
-
|
|
41236
|
+
init_chunk_NDAB5G24();
|
|
41316
41237
|
init_chunk_YXWJW7I5();
|
|
41317
41238
|
}
|
|
41318
41239
|
});
|
|
@@ -41404,7 +41325,7 @@ function within(root, path4) {
|
|
|
41404
41325
|
}
|
|
41405
41326
|
async function resolveReal(path4) {
|
|
41406
41327
|
try {
|
|
41407
|
-
return await (0,
|
|
41328
|
+
return await (0, import_promises46.realpath)(path4);
|
|
41408
41329
|
} catch {
|
|
41409
41330
|
const parent = (0, import_path9.dirname)(path4);
|
|
41410
41331
|
if (parent === path4) return path4;
|
|
@@ -41433,14 +41354,14 @@ function createWorkspaceFs(roots, writable) {
|
|
|
41433
41354
|
return {
|
|
41434
41355
|
read: async (params) => {
|
|
41435
41356
|
const path4 = await confined(params);
|
|
41436
|
-
const bytes = await (0,
|
|
41357
|
+
const bytes = await (0, import_promises46.readFile)(path4);
|
|
41437
41358
|
if (bytes.byteLength > MAX_READ_BYTES) throw new FsDenied(`${path4} is too large to read`);
|
|
41438
41359
|
return { content: sliceLines(bytes.toString("utf8"), params) };
|
|
41439
41360
|
},
|
|
41440
41361
|
write: async (params) => {
|
|
41441
41362
|
if (!writable) throw new FsDenied("This session is read-only");
|
|
41442
41363
|
const path4 = await confined(params);
|
|
41443
|
-
await (0,
|
|
41364
|
+
await (0, import_promises46.writeFile)(path4, asString(params.content));
|
|
41444
41365
|
return {};
|
|
41445
41366
|
}
|
|
41446
41367
|
};
|
|
@@ -41985,7 +41906,7 @@ function isAcpBackendKind(value2) {
|
|
|
41985
41906
|
return Object.hasOwn(ACP_PROFILES, value2);
|
|
41986
41907
|
}
|
|
41987
41908
|
function envDigest3(env) {
|
|
41988
|
-
const hash2 = (0,
|
|
41909
|
+
const hash2 = (0, import_crypto12.createHash)("sha256");
|
|
41989
41910
|
for (const key of Object.keys(env).sort()) hash2.update(`${key}\0${env[key]}\0`);
|
|
41990
41911
|
return hash2.digest("hex");
|
|
41991
41912
|
}
|
|
@@ -42043,7 +41964,7 @@ async function acpTurnInput(run2, context) {
|
|
|
42043
41964
|
const encoded = await Promise.all(
|
|
42044
41965
|
images.map(async (image) => ({
|
|
42045
41966
|
mimeType: image.mimeType,
|
|
42046
|
-
data: (await (0,
|
|
41967
|
+
data: (await (0, import_promises47.readFile)(image.path)).toString("base64")
|
|
42047
41968
|
}))
|
|
42048
41969
|
);
|
|
42049
41970
|
return {
|
|
@@ -42052,23 +41973,23 @@ async function acpTurnInput(run2, context) {
|
|
|
42052
41973
|
...encoded.length ? { images: encoded, imagePaths: images.map((image) => image.path) } : {}
|
|
42053
41974
|
};
|
|
42054
41975
|
}
|
|
42055
|
-
var
|
|
41976
|
+
var import_promises46, import_path9, import_crypto12, import_promises47, 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;
|
|
42056
41977
|
var init_acp3 = __esm({
|
|
42057
41978
|
"../agent-core/dist/providers/acp.js"() {
|
|
42058
41979
|
"use strict";
|
|
42059
|
-
|
|
42060
|
-
|
|
41980
|
+
init_chunk_X5JKSBTB();
|
|
41981
|
+
init_chunk_UGRKZTAD();
|
|
42061
41982
|
init_chunk_R32NAS3B();
|
|
42062
41983
|
init_chunk_J2KTV5FP();
|
|
42063
|
-
|
|
42064
|
-
|
|
41984
|
+
init_chunk_NDAB5G24();
|
|
41985
|
+
init_chunk_6WN2R725();
|
|
42065
41986
|
init_chunk_YXWJW7I5();
|
|
42066
|
-
|
|
41987
|
+
import_promises46 = require("fs/promises");
|
|
42067
41988
|
import_path9 = require("path");
|
|
42068
41989
|
init_effort();
|
|
42069
41990
|
init_acp();
|
|
42070
|
-
|
|
42071
|
-
|
|
41991
|
+
import_crypto12 = require("crypto");
|
|
41992
|
+
import_promises47 = require("fs/promises");
|
|
42072
41993
|
init_agent2();
|
|
42073
41994
|
CURSOR_ASK_QUESTION = "cursor/ask_question";
|
|
42074
41995
|
copilotAcpProfile = {
|
|
@@ -43592,7 +43513,7 @@ function createOpenCodeDriver(options = {}) {
|
|
|
43592
43513
|
await authorization?.remove();
|
|
43593
43514
|
};
|
|
43594
43515
|
const spec = { ...planned, env: launchEnv(planned, authorization) };
|
|
43595
|
-
const password = options.password?.() ?? (0,
|
|
43516
|
+
const password = options.password?.() ?? (0, import_crypto13.randomBytes)(24).toString("base64url");
|
|
43596
43517
|
const attempt2 = { abandoned: false };
|
|
43597
43518
|
const { session, url: url3 } = await withDeadline3(
|
|
43598
43519
|
startServer(spec, password, resolved, attempt2),
|
|
@@ -43636,7 +43557,7 @@ function createOpenCodeDriver(options = {}) {
|
|
|
43636
43557
|
};
|
|
43637
43558
|
}
|
|
43638
43559
|
function envDigest4(env) {
|
|
43639
|
-
const hash2 = (0,
|
|
43560
|
+
const hash2 = (0, import_crypto14.createHash)("sha256");
|
|
43640
43561
|
for (const key of Object.keys(env).sort()) hash2.update(`${key}\0${env[key]}\0`);
|
|
43641
43562
|
return hash2.digest("hex");
|
|
43642
43563
|
}
|
|
@@ -43716,25 +43637,25 @@ function openCodeTurnInput(run2, context) {
|
|
|
43716
43637
|
...images.length ? { imagePaths: images.map((image) => image.path) } : {}
|
|
43717
43638
|
};
|
|
43718
43639
|
}
|
|
43719
|
-
var import_http10,
|
|
43640
|
+
var import_http10, import_crypto13, import_path10, import_url2, import_crypto14, IDLE_SOCKET_MS3, 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_OPERATIONS2, 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;
|
|
43720
43641
|
var init_opencode = __esm({
|
|
43721
43642
|
"../agent-core/dist/providers/opencode.js"() {
|
|
43722
43643
|
"use strict";
|
|
43723
|
-
|
|
43724
|
-
|
|
43644
|
+
init_chunk_X5JKSBTB();
|
|
43645
|
+
init_chunk_UGRKZTAD();
|
|
43725
43646
|
init_chunk_R32NAS3B();
|
|
43726
43647
|
init_chunk_J2KTV5FP();
|
|
43727
|
-
|
|
43728
|
-
|
|
43648
|
+
init_chunk_NDAB5G24();
|
|
43649
|
+
init_chunk_6WN2R725();
|
|
43729
43650
|
init_chunk_YXWJW7I5();
|
|
43730
43651
|
import_http10 = require("http");
|
|
43731
43652
|
init_runtime_v2();
|
|
43732
|
-
|
|
43653
|
+
import_crypto13 = require("crypto");
|
|
43733
43654
|
init_agent2();
|
|
43734
43655
|
import_path10 = require("path");
|
|
43735
43656
|
import_url2 = require("url");
|
|
43736
43657
|
init_acp();
|
|
43737
|
-
|
|
43658
|
+
import_crypto14 = require("crypto");
|
|
43738
43659
|
init_agent2();
|
|
43739
43660
|
IDLE_SOCKET_MS3 = 4e3;
|
|
43740
43661
|
OpenCodeHttpError = class extends Error {
|
|
@@ -45415,7 +45336,7 @@ function createDroidDriver(options = {}) {
|
|
|
45415
45336
|
};
|
|
45416
45337
|
}
|
|
45417
45338
|
function envDigest5(env) {
|
|
45418
|
-
const hash2 = (0,
|
|
45339
|
+
const hash2 = (0, import_crypto15.createHash)("sha256");
|
|
45419
45340
|
for (const key of Object.keys(env).sort()) hash2.update(`${key}\0${env[key]}\0`);
|
|
45420
45341
|
return hash2.digest("hex");
|
|
45421
45342
|
}
|
|
@@ -45470,25 +45391,25 @@ async function droidTurnInput(run2, context) {
|
|
|
45470
45391
|
const encoded = await Promise.all(
|
|
45471
45392
|
images.map(async (image) => ({
|
|
45472
45393
|
mimeType: image.mimeType,
|
|
45473
|
-
data: (await (0,
|
|
45394
|
+
data: (await (0, import_promises48.readFile)(image.path)).toString("base64")
|
|
45474
45395
|
}))
|
|
45475
45396
|
);
|
|
45476
45397
|
return { turnId: run2.runId, text: text2, ...encoded.length ? { images: encoded } : {} };
|
|
45477
45398
|
}
|
|
45478
|
-
var
|
|
45399
|
+
var import_crypto15, import_promises48, 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;
|
|
45479
45400
|
var init_droid = __esm({
|
|
45480
45401
|
"../agent-core/dist/providers/droid.js"() {
|
|
45481
45402
|
"use strict";
|
|
45482
|
-
|
|
45483
|
-
|
|
45403
|
+
init_chunk_X5JKSBTB();
|
|
45404
|
+
init_chunk_UGRKZTAD();
|
|
45484
45405
|
init_chunk_R32NAS3B();
|
|
45485
45406
|
init_chunk_J2KTV5FP();
|
|
45486
|
-
|
|
45487
|
-
|
|
45407
|
+
init_chunk_NDAB5G24();
|
|
45408
|
+
init_chunk_6WN2R725();
|
|
45488
45409
|
init_chunk_YXWJW7I5();
|
|
45489
45410
|
init_runtime_v2();
|
|
45490
|
-
|
|
45491
|
-
|
|
45411
|
+
import_crypto15 = require("crypto");
|
|
45412
|
+
import_promises48 = require("fs/promises");
|
|
45492
45413
|
init_agent2();
|
|
45493
45414
|
FACTORY_API_VERSION = "1.0.0";
|
|
45494
45415
|
FACTORY_PROTOCOL_VERSION = "1.187.0";
|
|
@@ -45993,7 +45914,7 @@ function antigravityArgs(input2, capabilities, prompt) {
|
|
|
45993
45914
|
}
|
|
45994
45915
|
function workspaceRoot(cwd) {
|
|
45995
45916
|
for (let current = (0, import_path11.resolve)(cwd); ; current = (0, import_path11.dirname)(current)) {
|
|
45996
|
-
if ((0,
|
|
45917
|
+
if ((0, import_fs8.existsSync)((0, import_path11.join)(current, ".git"))) return current;
|
|
45997
45918
|
if ((0, import_path11.dirname)(current) === current) return (0, import_path11.resolve)(cwd);
|
|
45998
45919
|
}
|
|
45999
45920
|
}
|
|
@@ -46003,7 +45924,7 @@ function instructionPaths(cwd) {
|
|
|
46003
45924
|
for (let current = (0, import_path11.resolve)(cwd); ; current = (0, import_path11.dirname)(current)) {
|
|
46004
45925
|
const path4 = (0, import_path11.join)(current, INSTRUCTIONS_FILE);
|
|
46005
45926
|
try {
|
|
46006
|
-
if ((0,
|
|
45927
|
+
if ((0, import_fs8.existsSync)(path4) && (0, import_fs8.statSync)(path4).isFile()) paths.unshift(path4);
|
|
46007
45928
|
} catch {
|
|
46008
45929
|
}
|
|
46009
45930
|
if (current === root || (0, import_path11.dirname)(current) === current) return paths;
|
|
@@ -46017,7 +45938,7 @@ function antigravityWorkspaceInstructions(cwd, maxChars = MAX_INSTRUCTION_CHARS)
|
|
|
46017
45938
|
if (remaining <= 0) break;
|
|
46018
45939
|
let content;
|
|
46019
45940
|
try {
|
|
46020
|
-
content = (0,
|
|
45941
|
+
content = (0, import_fs8.readFileSync)(path4, "utf8").trim();
|
|
46021
45942
|
} catch {
|
|
46022
45943
|
continue;
|
|
46023
45944
|
}
|
|
@@ -46498,7 +46419,7 @@ ${output2.stderr}`).join("\n")
|
|
|
46498
46419
|
};
|
|
46499
46420
|
}
|
|
46500
46421
|
function envDigest6(env) {
|
|
46501
|
-
const hash2 = (0,
|
|
46422
|
+
const hash2 = (0, import_crypto16.createHash)("sha256");
|
|
46502
46423
|
for (const key of Object.keys(env).sort()) hash2.update(`${key}\0${env[key]}\0`);
|
|
46503
46424
|
return hash2.digest("hex");
|
|
46504
46425
|
}
|
|
@@ -46544,23 +46465,23 @@ function antigravityTurnInput(run2, context) {
|
|
|
46544
46465
|
});
|
|
46545
46466
|
return { turnId: run2.runId, text: appendImagePathReferences(text2, images) };
|
|
46546
46467
|
}
|
|
46547
|
-
var
|
|
46468
|
+
var import_fs8, import_path11, import_path12, 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, AntigravityTurn, DEFAULTS6, AntigravitySession, WINDOWS_LINE_MARGIN;
|
|
46548
46469
|
var init_antigravity = __esm({
|
|
46549
46470
|
"../agent-core/dist/providers/antigravity.js"() {
|
|
46550
46471
|
"use strict";
|
|
46551
|
-
|
|
46552
|
-
|
|
46553
|
-
|
|
46472
|
+
init_chunk_DALFHI4B();
|
|
46473
|
+
init_chunk_X5JKSBTB();
|
|
46474
|
+
init_chunk_UGRKZTAD();
|
|
46554
46475
|
init_chunk_R32NAS3B();
|
|
46555
|
-
|
|
46556
|
-
|
|
46476
|
+
init_chunk_NDAB5G24();
|
|
46477
|
+
init_chunk_6WN2R725();
|
|
46557
46478
|
init_chunk_YXWJW7I5();
|
|
46558
|
-
|
|
46479
|
+
import_fs8 = require("fs");
|
|
46559
46480
|
import_path11 = require("path");
|
|
46560
46481
|
init_effort();
|
|
46561
46482
|
import_path12 = require("path");
|
|
46562
46483
|
import_url3 = require("url");
|
|
46563
|
-
|
|
46484
|
+
import_crypto16 = require("crypto");
|
|
46564
46485
|
init_agent2();
|
|
46565
46486
|
NO_ANTIGRAVITY_CAPABILITIES = {
|
|
46566
46487
|
structuredPrint: false,
|
|
@@ -47046,7 +46967,7 @@ function parseConfig(raw) {
|
|
|
47046
46967
|
}
|
|
47047
46968
|
async function writeCommandCodeProjectMcp(cwd, mcp) {
|
|
47048
46969
|
const path4 = (0, import_path13.join)(cwd, ".mcp.json");
|
|
47049
|
-
const original = await (0,
|
|
46970
|
+
const original = await (0, import_promises49.readFile)(path4, "utf8").catch(() => null);
|
|
47050
46971
|
const config2 = parseConfig(original);
|
|
47051
46972
|
const next = {
|
|
47052
46973
|
...config2,
|
|
@@ -47063,12 +46984,12 @@ async function writeCommandCodeProjectMcp(cwd, mcp) {
|
|
|
47063
46984
|
}
|
|
47064
46985
|
}
|
|
47065
46986
|
};
|
|
47066
|
-
await (0,
|
|
47067
|
-
await (0,
|
|
46987
|
+
await (0, import_promises49.mkdir)(cwd, { recursive: true });
|
|
46988
|
+
await (0, import_promises49.writeFile)(path4, `${JSON.stringify(next, null, 2)}
|
|
47068
46989
|
`);
|
|
47069
46990
|
return async () => {
|
|
47070
|
-
if (original === null) await (0,
|
|
47071
|
-
else await (0,
|
|
46991
|
+
if (original === null) await (0, import_promises49.rm)(path4, { force: true });
|
|
46992
|
+
else await (0, import_promises49.writeFile)(path4, original);
|
|
47072
46993
|
};
|
|
47073
46994
|
}
|
|
47074
46995
|
function commandCodeString(value2) {
|
|
@@ -47177,7 +47098,7 @@ function createCommandCodeDriver(options = {}) {
|
|
|
47177
47098
|
};
|
|
47178
47099
|
}
|
|
47179
47100
|
function envDigest7(env) {
|
|
47180
|
-
const hash2 = (0,
|
|
47101
|
+
const hash2 = (0, import_crypto17.createHash)("sha256");
|
|
47181
47102
|
for (const key of Object.keys(env).sort()) hash2.update(`${key}\0${env[key]}\0`);
|
|
47182
47103
|
return hash2.digest("hex");
|
|
47183
47104
|
}
|
|
@@ -47229,22 +47150,22 @@ function commandCodeTurnInput(run2, context) {
|
|
|
47229
47150
|
});
|
|
47230
47151
|
return { turnId: run2.runId, text: appendImagePathReferences(text2, images) };
|
|
47231
47152
|
}
|
|
47232
|
-
var
|
|
47153
|
+
var import_promises49, import_path13, import_crypto17, COMMAND_CODE_GRAMMAR_NAME, SILENT3, CommandCodeGrammar, CommandCodeTurn, COMMAND_CODE_MAX_TURNS, DEFAULTS7, CommandCodeSession;
|
|
47233
47154
|
var init_command_code = __esm({
|
|
47234
47155
|
"../agent-core/dist/providers/command-code.js"() {
|
|
47235
47156
|
"use strict";
|
|
47236
|
-
|
|
47237
|
-
|
|
47157
|
+
init_chunk_X5JKSBTB();
|
|
47158
|
+
init_chunk_UGRKZTAD();
|
|
47238
47159
|
init_chunk_R32NAS3B();
|
|
47239
47160
|
init_chunk_J2KTV5FP();
|
|
47240
|
-
|
|
47241
|
-
|
|
47161
|
+
init_chunk_NDAB5G24();
|
|
47162
|
+
init_chunk_6WN2R725();
|
|
47242
47163
|
init_chunk_YXWJW7I5();
|
|
47243
|
-
|
|
47164
|
+
import_promises49 = require("fs/promises");
|
|
47244
47165
|
import_path13 = require("path");
|
|
47245
47166
|
init_agent2();
|
|
47246
47167
|
init_runtime_v2();
|
|
47247
|
-
|
|
47168
|
+
import_crypto17 = require("crypto");
|
|
47248
47169
|
init_agent2();
|
|
47249
47170
|
COMMAND_CODE_GRAMMAR_NAME = "command_code_cli";
|
|
47250
47171
|
SILENT3 = /* @__PURE__ */ new Set([
|
|
@@ -52433,7 +52354,7 @@ var require_websocket_server = __commonJS({
|
|
|
52433
52354
|
// package.json
|
|
52434
52355
|
var package_default = {
|
|
52435
52356
|
name: "@alan-ai-hq/agent-manager",
|
|
52436
|
-
version: "0.1.
|
|
52357
|
+
version: "0.1.131",
|
|
52437
52358
|
private: true,
|
|
52438
52359
|
type: "module",
|
|
52439
52360
|
description: "Alan machine runtime (alan-agent): identity, link, reconciler, session holders, run log, uploader, local API",
|
|
@@ -52480,7 +52401,7 @@ var package_default = {
|
|
|
52480
52401
|
|
|
52481
52402
|
// src/cli/commands/compat.ts
|
|
52482
52403
|
var import_node_crypto25 = require("crypto");
|
|
52483
|
-
var
|
|
52404
|
+
var import_promises59 = require("fs/promises");
|
|
52484
52405
|
init_runtime_v2();
|
|
52485
52406
|
init_zod();
|
|
52486
52407
|
|
|
@@ -54495,7 +54416,7 @@ async function push(context, request2) {
|
|
|
54495
54416
|
var import_node_child_process = require("child_process");
|
|
54496
54417
|
|
|
54497
54418
|
// ../agent-core/dist/process.js
|
|
54498
|
-
|
|
54419
|
+
init_chunk_NDAB5G24();
|
|
54499
54420
|
init_chunk_YXWJW7I5();
|
|
54500
54421
|
|
|
54501
54422
|
// src/capabilities/git/run-git.ts
|
|
@@ -54781,7 +54702,7 @@ var import_node_net = require("net");
|
|
|
54781
54702
|
|
|
54782
54703
|
// src/platform/credential-store/credential-store.ts
|
|
54783
54704
|
var import_node_crypto4 = require("crypto");
|
|
54784
|
-
var
|
|
54705
|
+
var import_promises11 = require("fs/promises");
|
|
54785
54706
|
|
|
54786
54707
|
// src/platform/credential-store/parse.ts
|
|
54787
54708
|
function parseStoredJson(text2, schema) {
|
|
@@ -54930,7 +54851,7 @@ function createFileCredentialStore(path4) {
|
|
|
54930
54851
|
kind: "file",
|
|
54931
54852
|
read: (schema) => readJsonFile(path4, schema),
|
|
54932
54853
|
write: (value2) => writeJsonFileAtomic(path4, value2),
|
|
54933
|
-
clear: () => (0,
|
|
54854
|
+
clear: () => (0, import_promises11.rm)(path4, { force: true })
|
|
54934
54855
|
};
|
|
54935
54856
|
}
|
|
54936
54857
|
var KEYCHAIN_SERVICE = "ai.tryalan.runtime";
|
|
@@ -55025,14 +54946,14 @@ function defaultCredentialStoreKind(platform3) {
|
|
|
55025
54946
|
var import_node_child_process3 = require("child_process");
|
|
55026
54947
|
var import_node_crypto5 = require("crypto");
|
|
55027
54948
|
var import_node_fs3 = require("fs");
|
|
55028
|
-
var
|
|
54949
|
+
var import_promises13 = require("fs/promises");
|
|
55029
54950
|
var import_node_path7 = require("path");
|
|
55030
54951
|
var import_node_util2 = require("util");
|
|
55031
54952
|
init_zod();
|
|
55032
54953
|
|
|
55033
54954
|
// src/platform/process-identity.ts
|
|
55034
54955
|
var import_node_child_process2 = require("child_process");
|
|
55035
|
-
var
|
|
54956
|
+
var import_promises12 = require("fs/promises");
|
|
55036
54957
|
var import_node_util = require("util");
|
|
55037
54958
|
var execFileAsync = (0, import_node_util.promisify)(import_node_child_process2.execFile);
|
|
55038
54959
|
function isProcessAlive(pid) {
|
|
@@ -55044,13 +54965,13 @@ function isProcessAlive(pid) {
|
|
|
55044
54965
|
}
|
|
55045
54966
|
}
|
|
55046
54967
|
async function linuxStartTime(pid) {
|
|
55047
|
-
const stat19 = await (0,
|
|
54968
|
+
const stat19 = await (0, import_promises12.readFile)(`/proc/${pid}/stat`, "utf8").catch(() => null);
|
|
55048
54969
|
if (stat19 === null) return null;
|
|
55049
54970
|
const fields = stat19.slice(stat19.lastIndexOf(")") + 2).split(" ");
|
|
55050
54971
|
return fields[19] ?? null;
|
|
55051
54972
|
}
|
|
55052
54973
|
async function linuxCommand(pid) {
|
|
55053
|
-
const raw = await (0,
|
|
54974
|
+
const raw = await (0, import_promises12.readFile)(`/proc/${pid}/cmdline`, "utf8").catch(() => null);
|
|
55054
54975
|
return raw === null ? null : normalizeCommand(raw.replaceAll("\0", " "));
|
|
55055
54976
|
}
|
|
55056
54977
|
async function darwinCommand(pid) {
|
|
@@ -55240,23 +55161,23 @@ async function reportedVersion(versionDir) {
|
|
|
55240
55161
|
return stdout.trim();
|
|
55241
55162
|
}
|
|
55242
55163
|
async function switchLauncher(layout, version2) {
|
|
55243
|
-
await (0,
|
|
55164
|
+
await (0, import_promises13.mkdir)(layout.bin, { recursive: true, mode: 448 });
|
|
55244
55165
|
const staged = (0, import_node_path7.join)(layout.bin, `.${(0, import_node_path7.basename)(layout.launcher)}.${(0, import_node_crypto5.randomUUID)()}`);
|
|
55245
55166
|
if (process.platform === "win32") {
|
|
55246
55167
|
(0, import_node_fs3.writeFileSync)(staged, `@"%~dp0..\\versions\\${version2}\\alan-agent.cmd" %*\r
|
|
55247
55168
|
`);
|
|
55248
55169
|
} else {
|
|
55249
|
-
await (0,
|
|
55170
|
+
await (0, import_promises13.symlink)((0, import_node_path7.join)("..", "versions", version2, "alan-agent"), staged);
|
|
55250
55171
|
}
|
|
55251
|
-
await (0,
|
|
55172
|
+
await (0, import_promises13.rename)(staged, layout.launcher);
|
|
55252
55173
|
}
|
|
55253
55174
|
async function launcherVersion(launcher) {
|
|
55254
55175
|
try {
|
|
55255
55176
|
if (process.platform === "win32") {
|
|
55256
|
-
const match = /versions\\([^\\]+)\\/.exec(await (0,
|
|
55177
|
+
const match = /versions\\([^\\]+)\\/.exec(await (0, import_promises13.readFile)(launcher, "utf8"));
|
|
55257
55178
|
return match?.[1] ?? null;
|
|
55258
55179
|
}
|
|
55259
|
-
return (0, import_node_path7.basename)((0, import_node_path7.dirname)(await (0,
|
|
55180
|
+
return (0, import_node_path7.basename)((0, import_node_path7.dirname)(await (0, import_promises13.readlink)(launcher)));
|
|
55260
55181
|
} catch (error61) {
|
|
55261
55182
|
if (errnoCode(error61) === "ENOENT") return null;
|
|
55262
55183
|
throw error61;
|
|
@@ -55267,7 +55188,7 @@ function currentVersion(layout) {
|
|
|
55267
55188
|
}
|
|
55268
55189
|
async function launcherVersions(layout) {
|
|
55269
55190
|
const versions = [];
|
|
55270
|
-
for (const name of await (0,
|
|
55191
|
+
for (const name of await (0, import_promises13.readdir)(layout.bin).catch(() => [])) {
|
|
55271
55192
|
if (!name.startsWith(LAUNCHER_STEM)) continue;
|
|
55272
55193
|
const version2 = await launcherVersion((0, import_node_path7.join)(layout.bin, name)).catch(() => null);
|
|
55273
55194
|
if (version2 !== null) versions.push(version2);
|
|
@@ -55299,7 +55220,7 @@ function assertUsableVersion(version2) {
|
|
|
55299
55220
|
}
|
|
55300
55221
|
}
|
|
55301
55222
|
async function exists(path4) {
|
|
55302
|
-
return (0,
|
|
55223
|
+
return (0, import_promises13.stat)(path4).then(
|
|
55303
55224
|
() => true,
|
|
55304
55225
|
() => false
|
|
55305
55226
|
);
|
|
@@ -55310,7 +55231,7 @@ function isVersionInstalled(layout, version2) {
|
|
|
55310
55231
|
async function stageVersion(layout, sourceDir, expectedVersion) {
|
|
55311
55232
|
var _stack = [];
|
|
55312
55233
|
try {
|
|
55313
|
-
await (0,
|
|
55234
|
+
await (0, import_promises13.mkdir)(layout.versions, { recursive: true, mode: 448 });
|
|
55314
55235
|
const _lock = __using(_stack, takeInstallLock(layout.lock));
|
|
55315
55236
|
const version2 = await readPackageVersion(sourceDir);
|
|
55316
55237
|
if (expectedVersion !== void 0 && version2 !== expectedVersion) {
|
|
@@ -55323,17 +55244,17 @@ async function stageVersion(layout, sourceDir, expectedVersion) {
|
|
|
55323
55244
|
const target = (0, import_node_path7.join)(layout.versions, version2);
|
|
55324
55245
|
if (await exists(target)) return version2;
|
|
55325
55246
|
const staging = (0, import_node_path7.join)(layout.versions, `.${version2}`);
|
|
55326
|
-
await (0,
|
|
55247
|
+
await (0, import_promises13.rm)(staging, { recursive: true, force: true });
|
|
55327
55248
|
try {
|
|
55328
|
-
await (0,
|
|
55249
|
+
await (0, import_promises13.cp)(sourceDir, staging, { recursive: true });
|
|
55329
55250
|
if (await reportedVersion(staging) !== version2) {
|
|
55330
55251
|
throw new RuntimeFault("invalid_file", `Staged runtime ${version2} does not start`);
|
|
55331
55252
|
}
|
|
55332
55253
|
} catch (error61) {
|
|
55333
|
-
await (0,
|
|
55254
|
+
await (0, import_promises13.rm)(staging, { recursive: true, force: true });
|
|
55334
55255
|
throw error61;
|
|
55335
55256
|
}
|
|
55336
|
-
await (0,
|
|
55257
|
+
await (0, import_promises13.rename)(staging, target);
|
|
55337
55258
|
return version2;
|
|
55338
55259
|
} catch (_) {
|
|
55339
55260
|
var _error = _, _hasError = true;
|
|
@@ -55350,19 +55271,19 @@ async function installVersion(layout, sourceDir) {
|
|
|
55350
55271
|
async function hasLiveMarker(versionDir) {
|
|
55351
55272
|
const markers = (0, import_node_path7.join)(versionDir, ".running");
|
|
55352
55273
|
let live = false;
|
|
55353
|
-
for (const name of await (0,
|
|
55274
|
+
for (const name of await (0, import_promises13.readdir)(markers).catch(() => [])) {
|
|
55354
55275
|
if (isProcessAlive(Number(name))) live = true;
|
|
55355
|
-
else await (0,
|
|
55276
|
+
else await (0, import_promises13.rm)((0, import_node_path7.join)(markers, name), { force: true });
|
|
55356
55277
|
}
|
|
55357
55278
|
return live;
|
|
55358
55279
|
}
|
|
55359
55280
|
async function collectOldVersions(layout) {
|
|
55360
|
-
const entries = await (0,
|
|
55281
|
+
const entries = await (0, import_promises13.readdir)(layout.versions, { withFileTypes: true }).catch(() => []);
|
|
55361
55282
|
const versions = await Promise.all(
|
|
55362
55283
|
entries.filter((entry) => entry.isDirectory() && !entry.name.startsWith(".")).map(async (entry) => ({
|
|
55363
55284
|
name: entry.name,
|
|
55364
55285
|
// The launcher, not the directory: `.running` markers touch the directory's mtime.
|
|
55365
|
-
installedAtMs: (await (0,
|
|
55286
|
+
installedAtMs: (await (0, import_promises13.stat)(launcherIn((0, import_node_path7.join)(layout.versions, entry.name)))).mtimeMs
|
|
55366
55287
|
}))
|
|
55367
55288
|
);
|
|
55368
55289
|
const keep = new Set(
|
|
@@ -55373,7 +55294,7 @@ async function collectOldVersions(layout) {
|
|
|
55373
55294
|
for (const { name } of versions) {
|
|
55374
55295
|
const dir = (0, import_node_path7.join)(layout.versions, name);
|
|
55375
55296
|
if (keep.has(name) || await hasLiveMarker(dir)) continue;
|
|
55376
|
-
await (0,
|
|
55297
|
+
await (0, import_promises13.rm)(dir, { recursive: true, force: true });
|
|
55377
55298
|
removed.push(name);
|
|
55378
55299
|
}
|
|
55379
55300
|
return removed;
|
|
@@ -55397,7 +55318,7 @@ function markVersionInUse(bundlePath) {
|
|
|
55397
55318
|
|
|
55398
55319
|
// src/platform/instance-lock.ts
|
|
55399
55320
|
var import_node_fs4 = require("fs");
|
|
55400
|
-
var
|
|
55321
|
+
var import_promises14 = require("fs/promises");
|
|
55401
55322
|
var import_node_path8 = require("path");
|
|
55402
55323
|
init_zod();
|
|
55403
55324
|
var LOCK_POLL_MS = 100;
|
|
@@ -55454,7 +55375,7 @@ async function attempt(path4, self, probe) {
|
|
|
55454
55375
|
return tryCreate(path4, self) ? { kind: "acquired" } : attempt(path4, self, probe);
|
|
55455
55376
|
}
|
|
55456
55377
|
async function acquireInstanceLock(path4, { clock, waitMs, signal, probe = systemProcessProbe }) {
|
|
55457
|
-
await (0,
|
|
55378
|
+
await (0, import_promises14.mkdir)((0, import_node_path8.dirname)(path4), { recursive: true, mode: 448 });
|
|
55458
55379
|
const self = await readProcessIdentity(process.pid);
|
|
55459
55380
|
if (self === null) throw new RuntimeFault("internal", "Cannot read this process's identity");
|
|
55460
55381
|
const deadline = clock.monotonic() + waitMs;
|
|
@@ -55610,13 +55531,13 @@ function runtimePaths(stateDir) {
|
|
|
55610
55531
|
|
|
55611
55532
|
// src/platform/process-memory.ts
|
|
55612
55533
|
var import_node_child_process4 = require("child_process");
|
|
55613
|
-
var
|
|
55534
|
+
var import_promises15 = require("fs/promises");
|
|
55614
55535
|
var import_node_util3 = require("util");
|
|
55615
55536
|
var execFileAsync3 = (0, import_node_util3.promisify)(import_node_child_process4.execFile);
|
|
55616
55537
|
var PROBE_TIMEOUT_MS = 2e3;
|
|
55617
55538
|
async function readProcessRss(pid) {
|
|
55618
55539
|
if (process.platform === "linux") {
|
|
55619
|
-
const status = await (0,
|
|
55540
|
+
const status = await (0, import_promises15.readFile)(`/proc/${pid}/status`, "utf8").catch(() => null);
|
|
55620
55541
|
const kilobytes = status === null ? void 0 : /^VmRSS:\s+(\d+)\s+kB$/m.exec(status)?.[1];
|
|
55621
55542
|
return kilobytes === void 0 ? null : Number(kilobytes) * 1024;
|
|
55622
55543
|
}
|
|
@@ -55648,7 +55569,7 @@ async function darwinPressure() {
|
|
|
55648
55569
|
var PSI_WARN_SOME_AVG10 = 20;
|
|
55649
55570
|
var PSI_CRITICAL_FULL_AVG10 = 10;
|
|
55650
55571
|
async function linuxPressure() {
|
|
55651
|
-
const psi = await (0,
|
|
55572
|
+
const psi = await (0, import_promises15.readFile)("/proc/pressure/memory", "utf8").catch(() => null);
|
|
55652
55573
|
if (psi === null) return "normal";
|
|
55653
55574
|
const avg10 = (kind) => Number(new RegExp(`^${kind} avg10=([\\d.]+)`, "m").exec(psi)?.[1] ?? 0);
|
|
55654
55575
|
if (avg10("full") >= PSI_CRITICAL_FULL_AVG10) return "critical";
|
|
@@ -55735,7 +55656,7 @@ function planUpdate(input2) {
|
|
|
55735
55656
|
// src/platform/release-apply.ts
|
|
55736
55657
|
var import_node_child_process5 = require("child_process");
|
|
55737
55658
|
var import_node_crypto9 = require("crypto");
|
|
55738
|
-
var
|
|
55659
|
+
var import_promises16 = require("fs/promises");
|
|
55739
55660
|
var import_node_path11 = require("path");
|
|
55740
55661
|
var import_node_util4 = require("util");
|
|
55741
55662
|
init_zod();
|
|
@@ -55759,7 +55680,7 @@ function npmReleaseFrom(bytes, request2) {
|
|
|
55759
55680
|
return resolved.release;
|
|
55760
55681
|
}
|
|
55761
55682
|
async function extractPackageTarball(tarballPath, destination) {
|
|
55762
|
-
await (0,
|
|
55683
|
+
await (0, import_promises16.mkdir)(destination, { recursive: true, mode: 448 });
|
|
55763
55684
|
await execFileAsync4("tar", ["-xzf", tarballPath, "-C", destination]);
|
|
55764
55685
|
return (0, import_node_path11.join)(destination, "package");
|
|
55765
55686
|
}
|
|
@@ -55772,14 +55693,14 @@ async function stageNpmTarball({
|
|
|
55772
55693
|
const integrity = verifyNpmIntegrity(tarball, release2.dist);
|
|
55773
55694
|
if (!integrity.ok) throw new RuntimeFault("invalid_file", integrity.reason);
|
|
55774
55695
|
const scratch = (0, import_node_path11.join)(tmpDir, (0, import_node_crypto9.randomUUID)());
|
|
55775
|
-
await (0,
|
|
55696
|
+
await (0, import_promises16.mkdir)(scratch, { recursive: true, mode: 448 });
|
|
55776
55697
|
try {
|
|
55777
55698
|
const tarballPath = (0, import_node_path11.join)(scratch, "package.tgz");
|
|
55778
|
-
await (0,
|
|
55699
|
+
await (0, import_promises16.writeFile)(tarballPath, tarball, { mode: 384 });
|
|
55779
55700
|
const packageDir = await extractPackageTarball(tarballPath, (0, import_node_path11.join)(scratch, "unpacked"));
|
|
55780
55701
|
return await stageVersion(layout, packageDir, release2.version);
|
|
55781
55702
|
} finally {
|
|
55782
|
-
await (0,
|
|
55703
|
+
await (0, import_promises16.rm)(scratch, { recursive: true, force: true });
|
|
55783
55704
|
}
|
|
55784
55705
|
}
|
|
55785
55706
|
var pendingUpgradeSchema = external_exports.object({
|
|
@@ -55804,7 +55725,7 @@ async function recordPendingUpgrade(layout, from, to, now) {
|
|
|
55804
55725
|
await writeJsonFileAtomic(layout.pendingUpgrade, { from, to, startedAt: now, starts: 0 });
|
|
55805
55726
|
}
|
|
55806
55727
|
async function clearPendingUpgrade(layout) {
|
|
55807
|
-
await (0,
|
|
55728
|
+
await (0, import_promises16.rm)(layout.pendingUpgrade, { force: true });
|
|
55808
55729
|
}
|
|
55809
55730
|
async function rollBackUpgrade(layout, pending, now) {
|
|
55810
55731
|
const installed = await currentVersion(layout);
|
|
@@ -55836,7 +55757,7 @@ async function settlePendingUpgrade(layout, runningVersion, now) {
|
|
|
55836
55757
|
}
|
|
55837
55758
|
|
|
55838
55759
|
// src/platform/runtime-host.ts
|
|
55839
|
-
var
|
|
55760
|
+
var import_promises17 = require("fs/promises");
|
|
55840
55761
|
var RUNTIME_HOST_KINDS = ["app", "standalone"];
|
|
55841
55762
|
var APP_HOST_ENVIRONMENT = {
|
|
55842
55763
|
ELECTRON_RUN_AS_NODE: "1"
|
|
@@ -55874,7 +55795,7 @@ function serviceCommand(kind, proc, launcher) {
|
|
|
55874
55795
|
}
|
|
55875
55796
|
async function fileStamp(path4) {
|
|
55876
55797
|
try {
|
|
55877
|
-
const stats = await (0,
|
|
55798
|
+
const stats = await (0, import_promises17.stat)(path4);
|
|
55878
55799
|
return `${stats.dev}:${stats.ino}:${stats.size}:${stats.mtimeMs}`;
|
|
55879
55800
|
} catch {
|
|
55880
55801
|
return null;
|
|
@@ -56068,11 +55989,11 @@ var systemExec = (request2) => new Promise((resolve10) => {
|
|
|
56068
55989
|
});
|
|
56069
55990
|
|
|
56070
55991
|
// src/platform/service/legacy.ts
|
|
56071
|
-
var
|
|
55992
|
+
var import_promises19 = require("fs/promises");
|
|
56072
55993
|
var import_node_path15 = require("path");
|
|
56073
55994
|
|
|
56074
55995
|
// src/platform/service/windows-service.ts
|
|
56075
|
-
var
|
|
55996
|
+
var import_promises18 = require("fs/promises");
|
|
56076
55997
|
var import_node_path14 = require("path");
|
|
56077
55998
|
|
|
56078
55999
|
// src/platform/service/runtime-process.ts
|
|
@@ -56280,7 +56201,7 @@ async function readUserSid(exec) {
|
|
|
56280
56201
|
}
|
|
56281
56202
|
async function readBytes(path4) {
|
|
56282
56203
|
try {
|
|
56283
|
-
return await (0,
|
|
56204
|
+
return await (0, import_promises18.readFile)(path4);
|
|
56284
56205
|
} catch (error61) {
|
|
56285
56206
|
if (errnoCode(error61) === "ENOENT") return null;
|
|
56286
56207
|
throw error61;
|
|
@@ -56288,8 +56209,8 @@ async function readBytes(path4) {
|
|
|
56288
56209
|
}
|
|
56289
56210
|
async function writeIfChanged(path4, contents) {
|
|
56290
56211
|
if ((await readBytes(path4))?.equals(contents) === true) return false;
|
|
56291
|
-
await (0,
|
|
56292
|
-
await (0,
|
|
56212
|
+
await (0, import_promises18.mkdir)((0, import_node_path14.dirname)(path4), { recursive: true });
|
|
56213
|
+
await (0, import_promises18.writeFile)(path4, contents);
|
|
56293
56214
|
return true;
|
|
56294
56215
|
}
|
|
56295
56216
|
async function run(exec, request2) {
|
|
@@ -56371,7 +56292,7 @@ function windowsManager(host, profile) {
|
|
|
56371
56292
|
name: files.runValue,
|
|
56372
56293
|
definitionPath: files.script,
|
|
56373
56294
|
install: async (spec, { restart }) => {
|
|
56374
|
-
await (0,
|
|
56295
|
+
await (0, import_promises18.mkdir)((0, import_node_path14.dirname)(spec.logPath), { recursive: true });
|
|
56375
56296
|
const script = renderWindowsSupervisorScript(spec, files);
|
|
56376
56297
|
const xml2 = renderWindowsTaskXml({ spec, files, userSid: await userSid() });
|
|
56377
56298
|
const scriptChanged = await writeIfChanged(
|
|
@@ -56412,7 +56333,7 @@ function windowsManager(host, profile) {
|
|
|
56412
56333
|
const defined = await readBytes(files.script) !== null;
|
|
56413
56334
|
await Promise.all(
|
|
56414
56335
|
[files.script, files.taskXml, files.supervisorRecord].map(
|
|
56415
|
-
(path4) => (0,
|
|
56336
|
+
(path4) => (0, import_promises18.rm)(path4, { force: true })
|
|
56416
56337
|
)
|
|
56417
56338
|
);
|
|
56418
56339
|
return {
|
|
@@ -56464,7 +56385,7 @@ function legacyServiceNames(profile) {
|
|
|
56464
56385
|
};
|
|
56465
56386
|
}
|
|
56466
56387
|
async function exists2(path4) {
|
|
56467
|
-
return (0,
|
|
56388
|
+
return (0, import_promises19.stat)(path4).then(
|
|
56468
56389
|
() => true,
|
|
56469
56390
|
() => false
|
|
56470
56391
|
);
|
|
@@ -56475,7 +56396,7 @@ async function removeLaunchd(host, label) {
|
|
|
56475
56396
|
const loaded = (await host.exec({ command: "launchctl", args: ["print", target] })).status === 0;
|
|
56476
56397
|
if (loaded) await host.exec({ command: "launchctl", args: ["bootout", target] });
|
|
56477
56398
|
const defined = await exists2(plist);
|
|
56478
|
-
await (0,
|
|
56399
|
+
await (0, import_promises19.rm)(plist, { force: true });
|
|
56479
56400
|
return { found: loaded || defined };
|
|
56480
56401
|
}
|
|
56481
56402
|
async function removeSystemd(exec, configHome, unit) {
|
|
@@ -56484,7 +56405,7 @@ async function removeSystemd(exec, configHome, unit) {
|
|
|
56484
56405
|
const active = (await exec({ command: "systemctl", args: ["--user", "is-active", "--quiet", unit] })).status === 0;
|
|
56485
56406
|
if (!defined && !active) return { found: false };
|
|
56486
56407
|
await exec({ command: "systemctl", args: ["--user", "disable", "--now", unit] });
|
|
56487
|
-
await (0,
|
|
56408
|
+
await (0, import_promises19.rm)(unitPath, { force: true });
|
|
56488
56409
|
await exec({ command: "systemctl", args: ["--user", "daemon-reload"] });
|
|
56489
56410
|
return { found: true };
|
|
56490
56411
|
}
|
|
@@ -56511,15 +56432,15 @@ async function removeLegacyService(host, profile) {
|
|
|
56511
56432
|
}
|
|
56512
56433
|
|
|
56513
56434
|
// src/platform/service/service-manager.ts
|
|
56514
|
-
var
|
|
56435
|
+
var import_promises22 = require("fs/promises");
|
|
56515
56436
|
var import_node_path18 = require("path");
|
|
56516
56437
|
|
|
56517
56438
|
// src/platform/service/service-files.ts
|
|
56518
|
-
var
|
|
56439
|
+
var import_promises20 = require("fs/promises");
|
|
56519
56440
|
var import_node_path16 = require("path");
|
|
56520
56441
|
async function readText(path4) {
|
|
56521
56442
|
try {
|
|
56522
|
-
return await (0,
|
|
56443
|
+
return await (0, import_promises20.readFile)(path4, "utf8");
|
|
56523
56444
|
} catch (error61) {
|
|
56524
56445
|
if (errnoCode(error61) === "ENOENT") return null;
|
|
56525
56446
|
throw error61;
|
|
@@ -56527,15 +56448,15 @@ async function readText(path4) {
|
|
|
56527
56448
|
}
|
|
56528
56449
|
async function writeDefinition(path4, contents, mode = 420) {
|
|
56529
56450
|
if (await readText(path4) === contents) return false;
|
|
56530
|
-
await (0,
|
|
56451
|
+
await (0, import_promises20.mkdir)((0, import_node_path16.dirname)(path4), { recursive: true });
|
|
56531
56452
|
const staged = `${path4}.${process.pid}.tmp`;
|
|
56532
|
-
await (0,
|
|
56533
|
-
await (0,
|
|
56453
|
+
await (0, import_promises20.writeFile)(staged, contents, { mode });
|
|
56454
|
+
await (0, import_promises20.rename)(staged, path4);
|
|
56534
56455
|
return true;
|
|
56535
56456
|
}
|
|
56536
56457
|
async function removeDefinition(path4) {
|
|
56537
56458
|
const existed = await readText(path4) !== null;
|
|
56538
|
-
await (0,
|
|
56459
|
+
await (0, import_promises20.rm)(path4, { force: true });
|
|
56539
56460
|
return existed;
|
|
56540
56461
|
}
|
|
56541
56462
|
async function runChecked(exec, request2) {
|
|
@@ -56663,7 +56584,7 @@ function systemdManager(host, profile) {
|
|
|
56663
56584
|
}
|
|
56664
56585
|
|
|
56665
56586
|
// src/platform/service/xdg-autostart.ts
|
|
56666
|
-
var
|
|
56587
|
+
var import_promises21 = require("fs/promises");
|
|
56667
56588
|
var import_node_path17 = require("path");
|
|
56668
56589
|
var AUTOSTART_PREFIX = "alan-runtime";
|
|
56669
56590
|
var ALREADY_RUNNING_EXIT_STATUS2 = 73;
|
|
@@ -56779,7 +56700,7 @@ function xdgAutostartManager(host, profile) {
|
|
|
56779
56700
|
name: files.name,
|
|
56780
56701
|
definitionPath: files.entry,
|
|
56781
56702
|
install: async (spec, { restart }) => {
|
|
56782
|
-
await (0,
|
|
56703
|
+
await (0, import_promises21.mkdir)((0, import_node_path17.dirname)(spec.logPath), { recursive: true, mode: 448 });
|
|
56783
56704
|
const scriptChanged = await writeDefinition(
|
|
56784
56705
|
files.script,
|
|
56785
56706
|
renderSupervisorScript(spec, files),
|
|
@@ -56806,7 +56727,7 @@ function xdgAutostartManager(host, profile) {
|
|
|
56806
56727
|
removeDefinition(files.entry),
|
|
56807
56728
|
removeDefinition(files.script)
|
|
56808
56729
|
]);
|
|
56809
|
-
await (0,
|
|
56730
|
+
await (0, import_promises21.rm)(files.supervisorRecord, { force: true });
|
|
56810
56731
|
return { manager: "xdg-autostart", name: files.name, removed: entry || script };
|
|
56811
56732
|
},
|
|
56812
56733
|
status: async () => {
|
|
@@ -56850,7 +56771,7 @@ function launchdManager(host, profile) {
|
|
|
56850
56771
|
name: label,
|
|
56851
56772
|
definitionPath: plist,
|
|
56852
56773
|
install: async (spec, { restart }) => {
|
|
56853
|
-
await (0,
|
|
56774
|
+
await (0, import_promises22.mkdir)((0, import_node_path18.dirname)(spec.logPath), { recursive: true, mode: 448 });
|
|
56854
56775
|
const changed = await writeDefinition(plist, renderLaunchdPlist(spec));
|
|
56855
56776
|
const loaded = await isLoaded();
|
|
56856
56777
|
if (loaded && !changed) {
|
|
@@ -56910,7 +56831,7 @@ function linuxManager(host, profile) {
|
|
|
56910
56831
|
if (manager === systemd) {
|
|
56911
56832
|
if (await readText(autostart.definitionPath) !== null) await autostart.uninstall();
|
|
56912
56833
|
} else {
|
|
56913
|
-
await (0,
|
|
56834
|
+
await (0, import_promises22.rm)(staleUnitPath, { force: true });
|
|
56914
56835
|
}
|
|
56915
56836
|
return manager.install(spec, options);
|
|
56916
56837
|
},
|
|
@@ -57384,7 +57305,7 @@ function createGit(options) {
|
|
|
57384
57305
|
// src/capabilities/github-proxy/certificates.ts
|
|
57385
57306
|
var import_node_child_process9 = require("child_process");
|
|
57386
57307
|
var import_node_crypto11 = require("crypto");
|
|
57387
|
-
var
|
|
57308
|
+
var import_promises23 = require("fs/promises");
|
|
57388
57309
|
var import_node_path20 = require("path");
|
|
57389
57310
|
var OPENSSL_TIMEOUT_MS = 1e4;
|
|
57390
57311
|
var VALIDITY_DAYS = "30";
|
|
@@ -57422,13 +57343,13 @@ function openssl(args, cwd) {
|
|
|
57422
57343
|
}
|
|
57423
57344
|
async function createGitHubProxyCertificates(stateDir) {
|
|
57424
57345
|
const work = (0, import_node_path20.join)(stateDir, "github-proxy");
|
|
57425
|
-
await (0,
|
|
57426
|
-
await (0,
|
|
57346
|
+
await (0, import_promises23.rm)(work, { recursive: true, force: true });
|
|
57347
|
+
await (0, import_promises23.mkdir)(work, { recursive: true, mode: 448 });
|
|
57427
57348
|
try {
|
|
57428
|
-
await (0,
|
|
57349
|
+
await (0, import_promises23.writeFile)((0, import_node_path20.join)(work, "ca.cnf"), opensslConfig("Alan sandbox GitHub proxy CA"), {
|
|
57429
57350
|
mode: 384
|
|
57430
57351
|
});
|
|
57431
|
-
await (0,
|
|
57352
|
+
await (0, import_promises23.writeFile)((0, import_node_path20.join)(work, "leaf.cnf"), opensslConfig("github.com"), { mode: 384 });
|
|
57432
57353
|
const curve = ["ecparam", "-name", "prime256v1", "-genkey", "-noout"];
|
|
57433
57354
|
await openssl([...curve, "-out", "ca.key"], work);
|
|
57434
57355
|
await openssl(
|
|
@@ -57452,19 +57373,19 @@ async function createGitHubProxyCertificates(stateDir) {
|
|
|
57452
57373
|
work
|
|
57453
57374
|
);
|
|
57454
57375
|
const caPath = (0, import_node_path20.join)(stateDir, "github-ca.pem");
|
|
57455
|
-
await (0,
|
|
57376
|
+
await (0, import_promises23.writeFile)(caPath, await (0, import_promises23.readFile)((0, import_node_path20.join)(work, "ca.pem")), { mode: 384 });
|
|
57456
57377
|
return {
|
|
57457
57378
|
caPath,
|
|
57458
|
-
leafKeyPem: await (0,
|
|
57459
|
-
leafCertPem: await (0,
|
|
57379
|
+
leafKeyPem: await (0, import_promises23.readFile)((0, import_node_path20.join)(work, "leaf.key"), "utf8"),
|
|
57380
|
+
leafCertPem: await (0, import_promises23.readFile)((0, import_node_path20.join)(work, "leaf.pem"), "utf8")
|
|
57460
57381
|
};
|
|
57461
57382
|
} finally {
|
|
57462
|
-
await (0,
|
|
57383
|
+
await (0, import_promises23.rm)(work, { recursive: true, force: true });
|
|
57463
57384
|
}
|
|
57464
57385
|
}
|
|
57465
57386
|
|
|
57466
57387
|
// src/capabilities/github-proxy/config.ts
|
|
57467
|
-
var
|
|
57388
|
+
var import_promises24 = require("fs/promises");
|
|
57468
57389
|
var import_node_path21 = require("path");
|
|
57469
57390
|
init_runtime_v2();
|
|
57470
57391
|
var GITHUB_URL = "https://github.com/";
|
|
@@ -57481,10 +57402,10 @@ function withGhConfigKey(yaml, key, value2) {
|
|
|
57481
57402
|
`;
|
|
57482
57403
|
}
|
|
57483
57404
|
async function configureGh(ghConfigDir, socketPath) {
|
|
57484
|
-
await (0,
|
|
57405
|
+
await (0, import_promises24.mkdir)(ghConfigDir, { recursive: true, mode: 448 });
|
|
57485
57406
|
const path4 = (0, import_node_path21.join)(ghConfigDir, "config.yml");
|
|
57486
|
-
const current = await (0,
|
|
57487
|
-
await (0,
|
|
57407
|
+
const current = await (0, import_promises24.readFile)(path4, "utf8").catch(() => "");
|
|
57408
|
+
await (0, import_promises24.writeFile)(path4, withGhConfigKey(current, GH_SOCKET_KEY, socketPath), { mode: 384 });
|
|
57488
57409
|
}
|
|
57489
57410
|
async function configureGit(input2, git) {
|
|
57490
57411
|
const run2 = async (args, allowedExitCodes = [0]) => {
|
|
@@ -57514,7 +57435,7 @@ async function configureGitHubProxyClients(input2) {
|
|
|
57514
57435
|
}
|
|
57515
57436
|
|
|
57516
57437
|
// src/capabilities/github-proxy/server.ts
|
|
57517
|
-
var
|
|
57438
|
+
var import_promises25 = require("fs/promises");
|
|
57518
57439
|
var import_node_http3 = require("http");
|
|
57519
57440
|
var import_node_tls = require("tls");
|
|
57520
57441
|
init_runtime_v2();
|
|
@@ -57656,7 +57577,7 @@ async function startGitHubProxy(options) {
|
|
|
57656
57577
|
});
|
|
57657
57578
|
removeStaleEndpoint(options.socketPath);
|
|
57658
57579
|
await listen(gh, options.socketPath);
|
|
57659
|
-
await (0,
|
|
57580
|
+
await (0, import_promises25.chmod)(options.socketPath, 384);
|
|
57660
57581
|
const git = options.certificates === null ? null : await startGitListener(options.certificates, relay);
|
|
57661
57582
|
options.log.info("github_proxy.listening", {
|
|
57662
57583
|
socketPath: options.socketPath,
|
|
@@ -57675,7 +57596,7 @@ async function startGitHubProxy(options) {
|
|
|
57675
57596
|
|
|
57676
57597
|
// src/capabilities/mcp-config/mcp-config.ts
|
|
57677
57598
|
var import_node_crypto12 = require("crypto");
|
|
57678
|
-
var
|
|
57599
|
+
var import_promises26 = require("fs/promises");
|
|
57679
57600
|
var import_node_path22 = require("path");
|
|
57680
57601
|
|
|
57681
57602
|
// ../../node_modules/smol-toml/dist/error.js
|
|
@@ -58517,6 +58438,7 @@ var MCP_CLIS = [
|
|
|
58517
58438
|
guardDir: "",
|
|
58518
58439
|
configPath: ".claude.json",
|
|
58519
58440
|
section: "mcpServers",
|
|
58441
|
+
writesEntry: true,
|
|
58520
58442
|
entry: (url3) => ({ type: "http", url: url3, headers: {} })
|
|
58521
58443
|
},
|
|
58522
58444
|
{
|
|
@@ -58525,6 +58447,9 @@ var MCP_CLIS = [
|
|
|
58525
58447
|
guardDir: ".codex",
|
|
58526
58448
|
configPath: ".codex/config.toml",
|
|
58527
58449
|
section: "mcp_servers",
|
|
58450
|
+
// ChatGPT.app's bundled Codex reads this file too and never completes MCP OAuth, so a
|
|
58451
|
+
// credential-free entry only loops 401s; Alan runs pass their own per-thread config.
|
|
58452
|
+
writesEntry: false,
|
|
58528
58453
|
entry: (url3) => ({ url: url3 })
|
|
58529
58454
|
},
|
|
58530
58455
|
{
|
|
@@ -58533,6 +58458,7 @@ var MCP_CLIS = [
|
|
|
58533
58458
|
guardDir: ".cursor",
|
|
58534
58459
|
configPath: ".cursor/mcp.json",
|
|
58535
58460
|
section: "mcpServers",
|
|
58461
|
+
writesEntry: true,
|
|
58536
58462
|
entry: (url3) => ({ type: "http", url: url3, headers: {} })
|
|
58537
58463
|
},
|
|
58538
58464
|
{
|
|
@@ -58541,6 +58467,7 @@ var MCP_CLIS = [
|
|
|
58541
58467
|
guardDir: ".kimi",
|
|
58542
58468
|
configPath: ".kimi/mcp.json",
|
|
58543
58469
|
section: "mcpServers",
|
|
58470
|
+
writesEntry: true,
|
|
58544
58471
|
entry: (url3) => ({ url: url3, headers: {} })
|
|
58545
58472
|
},
|
|
58546
58473
|
{
|
|
@@ -58549,6 +58476,7 @@ var MCP_CLIS = [
|
|
|
58549
58476
|
guardDir: ".commandcode",
|
|
58550
58477
|
configPath: ".commandcode/mcp.json",
|
|
58551
58478
|
section: "mcpServers",
|
|
58479
|
+
writesEntry: true,
|
|
58552
58480
|
entry: (url3) => ({ transport: "http", enabled: true, url: url3 })
|
|
58553
58481
|
},
|
|
58554
58482
|
{
|
|
@@ -58557,6 +58485,7 @@ var MCP_CLIS = [
|
|
|
58557
58485
|
guardDir: ".config/opencode",
|
|
58558
58486
|
configPath: ".config/opencode/opencode.json",
|
|
58559
58487
|
section: "mcp",
|
|
58488
|
+
writesEntry: true,
|
|
58560
58489
|
entry: (url3) => ({ type: "remote", url: url3, headers: {} })
|
|
58561
58490
|
},
|
|
58562
58491
|
{
|
|
@@ -58565,6 +58494,7 @@ var MCP_CLIS = [
|
|
|
58565
58494
|
guardDir: ".factory",
|
|
58566
58495
|
configPath: ".factory/mcp.json",
|
|
58567
58496
|
section: "mcpServers",
|
|
58497
|
+
writesEntry: true,
|
|
58568
58498
|
entry: (url3) => ({ type: "http", url: url3, disabled: false })
|
|
58569
58499
|
},
|
|
58570
58500
|
{
|
|
@@ -58573,6 +58503,7 @@ var MCP_CLIS = [
|
|
|
58573
58503
|
guardDir: ".copilot",
|
|
58574
58504
|
configPath: ".copilot/mcp-config.json",
|
|
58575
58505
|
section: "mcpServers",
|
|
58506
|
+
writesEntry: true,
|
|
58576
58507
|
entry: (url3) => ({ type: "http", url: url3, tools: ["*"], headers: {} })
|
|
58577
58508
|
},
|
|
58578
58509
|
{
|
|
@@ -58581,6 +58512,7 @@ var MCP_CLIS = [
|
|
|
58581
58512
|
guardDir: ".grok",
|
|
58582
58513
|
configPath: ".grok/config.toml",
|
|
58583
58514
|
section: "mcp_servers",
|
|
58515
|
+
writesEntry: true,
|
|
58584
58516
|
entry: (url3) => ({ url: url3 })
|
|
58585
58517
|
}
|
|
58586
58518
|
];
|
|
@@ -58609,9 +58541,12 @@ function isAlanEntry(entry, endpoint) {
|
|
|
58609
58541
|
if (url3.pathname.replace(/\/+$/, "") !== "/mcp") return false;
|
|
58610
58542
|
return url3.origin === endpoint.origin || url3.hostname.endsWith(ALAN_HOST_SUFFIX);
|
|
58611
58543
|
}
|
|
58544
|
+
function isCredentialFreeAlanEntry(entry, endpoint) {
|
|
58545
|
+
return isAlanEntry(entry, endpoint) && isRecord2(entry) && Object.keys(entry).every((key) => URL_KEYS.includes(key));
|
|
58546
|
+
}
|
|
58612
58547
|
async function isInstalled(cli, home) {
|
|
58613
58548
|
try {
|
|
58614
|
-
return (await (0,
|
|
58549
|
+
return (await (0, import_promises26.stat)((0, import_node_path22.join)(home, cli.guardDir))).isDirectory();
|
|
58615
58550
|
} catch (error61) {
|
|
58616
58551
|
if (errorCode2(error61) === "ENOENT") return false;
|
|
58617
58552
|
throw error61;
|
|
@@ -58619,7 +58554,7 @@ async function isInstalled(cli, home) {
|
|
|
58619
58554
|
}
|
|
58620
58555
|
async function readText2(path4) {
|
|
58621
58556
|
try {
|
|
58622
|
-
return await (0,
|
|
58557
|
+
return await (0, import_promises26.readFile)(path4, "utf8");
|
|
58623
58558
|
} catch (error61) {
|
|
58624
58559
|
if (errorCode2(error61) === "ENOENT") return null;
|
|
58625
58560
|
throw error61;
|
|
@@ -58646,10 +58581,10 @@ async function readConfig(cli, home) {
|
|
|
58646
58581
|
async function writeConfig(path4, text2) {
|
|
58647
58582
|
const temporary = `${path4}.alan-${(0, import_node_crypto12.randomUUID)()}.tmp`;
|
|
58648
58583
|
try {
|
|
58649
|
-
await (0,
|
|
58650
|
-
await (0,
|
|
58584
|
+
await (0, import_promises26.writeFile)(temporary, text2, { encoding: "utf8", mode: 384, flag: "wx" });
|
|
58585
|
+
await (0, import_promises26.rename)(temporary, path4);
|
|
58651
58586
|
} finally {
|
|
58652
|
-
await (0,
|
|
58587
|
+
await (0, import_promises26.rm)(temporary, { force: true });
|
|
58653
58588
|
}
|
|
58654
58589
|
}
|
|
58655
58590
|
async function editCli(cli, home, endpoint, edit) {
|
|
@@ -58677,6 +58612,13 @@ async function editInstalledClis(home, apiUrl, edit) {
|
|
|
58677
58612
|
}
|
|
58678
58613
|
function syncAlanMcp(options) {
|
|
58679
58614
|
return editInstalledClis(options.home, options.apiUrl, (servers, endpoint, cli) => {
|
|
58615
|
+
if (!cli.writesEntry) {
|
|
58616
|
+
const stale = [ALAN_MCP_SERVER_NAME, ...options.legacyServerNames].filter(
|
|
58617
|
+
(name) => isCredentialFreeAlanEntry(servers.get(name), endpoint)
|
|
58618
|
+
);
|
|
58619
|
+
for (const name of stale) servers.delete(name);
|
|
58620
|
+
return stale.length > 0;
|
|
58621
|
+
}
|
|
58680
58622
|
const current = servers.get(ALAN_MCP_SERVER_NAME);
|
|
58681
58623
|
if (current !== void 0 && !isAlanEntry(current, endpoint)) {
|
|
58682
58624
|
throw new Error(`an entry that is not Alan's already uses the name ${ALAN_MCP_SERVER_NAME}`);
|
|
@@ -58720,7 +58662,7 @@ async function inspectAlanMcp(options) {
|
|
|
58720
58662
|
}
|
|
58721
58663
|
|
|
58722
58664
|
// src/capabilities/models/opencode-models.ts
|
|
58723
|
-
var
|
|
58665
|
+
var import_promises27 = require("fs/promises");
|
|
58724
58666
|
var import_node_path23 = require("path");
|
|
58725
58667
|
init_runtime_v2();
|
|
58726
58668
|
init_zod();
|
|
@@ -59036,7 +58978,7 @@ async function readOpenCodeCatalogueCache(env) {
|
|
|
59036
58978
|
const home = env.HOME?.trim();
|
|
59037
58979
|
const cacheHome = env.XDG_CACHE_HOME?.trim() || (home ? (0, import_node_path23.join)(home, ".cache") : "");
|
|
59038
58980
|
if (cacheHome === "") return null;
|
|
59039
|
-
const text2 = await (0,
|
|
58981
|
+
const text2 = await (0, import_promises27.readFile)((0, import_node_path23.join)(cacheHome, ...CATALOGUE_CACHE_SEGMENTS), "utf8").catch(
|
|
59040
58982
|
() => void 0
|
|
59041
58983
|
);
|
|
59042
58984
|
if (text2 === void 0) return null;
|
|
@@ -59155,7 +59097,7 @@ async function discoverModels(backendKind, executable, env, capture) {
|
|
|
59155
59097
|
}
|
|
59156
59098
|
|
|
59157
59099
|
// src/capabilities/models/opencode-entitlement.ts
|
|
59158
|
-
var
|
|
59100
|
+
var import_promises28 = require("fs/promises");
|
|
59159
59101
|
var import_node_os2 = require("os");
|
|
59160
59102
|
var import_node_path24 = require("path");
|
|
59161
59103
|
init_agent2();
|
|
@@ -59165,7 +59107,7 @@ async function readOpenCodeZenCredential(env) {
|
|
|
59165
59107
|
const injected = env.OPENCODE_AUTH_CONTENT?.trim();
|
|
59166
59108
|
if (injected) return readZenCredentialFromAuthDocument(injected);
|
|
59167
59109
|
const dataHome = env.XDG_DATA_HOME?.trim() || (0, import_node_path24.join)(env.HOME?.trim() || (0, import_node_os2.homedir)(), ".local", "share");
|
|
59168
|
-
const document2 = await (0,
|
|
59110
|
+
const document2 = await (0, import_promises28.readFile)((0, import_node_path24.join)(dataHome, "opencode", "auth.json"), "utf8").catch(
|
|
59169
59111
|
() => void 0
|
|
59170
59112
|
);
|
|
59171
59113
|
return readZenCredentialFromAuthDocument(document2);
|
|
@@ -59608,7 +59550,7 @@ function nextAlanBoundary(entry, inFlightFrom) {
|
|
|
59608
59550
|
}
|
|
59609
59551
|
|
|
59610
59552
|
// src/capabilities/native-ingest/pass.ts
|
|
59611
|
-
var
|
|
59553
|
+
var import_promises32 = require("fs/promises");
|
|
59612
59554
|
|
|
59613
59555
|
// src/capabilities/native-ingest/ports.ts
|
|
59614
59556
|
var NativeRequestFailure = class extends Error {
|
|
@@ -59746,7 +59688,7 @@ function reconcileTranscriptIdentity(entry, transcriptPath, identity, size) {
|
|
|
59746
59688
|
|
|
59747
59689
|
// src/capabilities/native-ingest/transcript-window.ts
|
|
59748
59690
|
var import_node_crypto13 = require("crypto");
|
|
59749
|
-
var
|
|
59691
|
+
var import_promises31 = require("fs/promises");
|
|
59750
59692
|
init_acp2();
|
|
59751
59693
|
init_claude();
|
|
59752
59694
|
init_codex();
|
|
@@ -59801,7 +59743,7 @@ async function findRecordEnd(handle, from, size) {
|
|
|
59801
59743
|
return null;
|
|
59802
59744
|
}
|
|
59803
59745
|
async function readTranscriptWindow(path4, offset, limits) {
|
|
59804
|
-
const handle = await (0,
|
|
59746
|
+
const handle = await (0, import_promises31.open)(path4, "r");
|
|
59805
59747
|
try {
|
|
59806
59748
|
const stats = await handle.stat({ bigint: true });
|
|
59807
59749
|
const size = Number(stats.size);
|
|
@@ -60254,7 +60196,7 @@ async function runPass(ctx, worker) {
|
|
|
60254
60196
|
});
|
|
60255
60197
|
if (signal.ending) ctx.log.info("native_ingest.closed", workerFields(worker));
|
|
60256
60198
|
}
|
|
60257
|
-
const current = await (0,
|
|
60199
|
+
const current = await (0, import_promises32.stat)(worker.latest.transcriptPath).catch(() => void 0);
|
|
60258
60200
|
return { grewDuringPass: current !== void 0 && current.size > state.lastSize };
|
|
60259
60201
|
}
|
|
60260
60202
|
|
|
@@ -60611,7 +60553,7 @@ init_alan_code();
|
|
|
60611
60553
|
|
|
60612
60554
|
// src/capabilities/providers/commands.ts
|
|
60613
60555
|
var import_node_fs10 = require("fs");
|
|
60614
|
-
var
|
|
60556
|
+
var import_promises34 = require("fs/promises");
|
|
60615
60557
|
var import_node_path30 = require("path");
|
|
60616
60558
|
var PROVIDER_COMMANDS = [
|
|
60617
60559
|
// The engine, not a CLI of its own: `resolveProviderExecutable` finds the bundled one first.
|
|
@@ -60645,8 +60587,8 @@ function pathDelimiter(platform3) {
|
|
|
60645
60587
|
}
|
|
60646
60588
|
async function isRunnable(path4, platform3) {
|
|
60647
60589
|
try {
|
|
60648
|
-
if (!(await (0,
|
|
60649
|
-
if (platform3 !== "win32") await (0,
|
|
60590
|
+
if (!(await (0, import_promises34.stat)(path4)).isFile()) return false;
|
|
60591
|
+
if (platform3 !== "win32") await (0, import_promises34.access)(path4, import_node_fs10.constants.X_OK);
|
|
60650
60592
|
return true;
|
|
60651
60593
|
} catch {
|
|
60652
60594
|
return false;
|
|
@@ -61189,13 +61131,13 @@ async function openCliEnvironment(options) {
|
|
|
61189
61131
|
}
|
|
61190
61132
|
|
|
61191
61133
|
// src/capabilities/skills/local-preview.ts
|
|
61192
|
-
var
|
|
61134
|
+
var import_promises39 = require("fs/promises");
|
|
61193
61135
|
var import_node_path39 = __toESM(require("path"));
|
|
61194
61136
|
|
|
61195
61137
|
// ../shared/dist/node/skill-package.js
|
|
61196
61138
|
var import_node_buffer = require("buffer");
|
|
61197
61139
|
var import_node_crypto15 = require("crypto");
|
|
61198
|
-
var
|
|
61140
|
+
var import_promises35 = require("fs/promises");
|
|
61199
61141
|
var import_node_path35 = require("path");
|
|
61200
61142
|
var import_yaml = __toESM(require_dist(), 1);
|
|
61201
61143
|
init_contracts();
|
|
@@ -61291,11 +61233,11 @@ async function readSkillPackageFile(packageRoot, path4, expectedSha256) {
|
|
|
61291
61233
|
if (!normalizedPath || normalizedPath !== path4 || normalizedPath.includes("\\") || components.some((component) => !component || component === "." || component === "..")) {
|
|
61292
61234
|
throw new SkillPackageError("INVALID_PATH", `Invalid Skill package path: ${path4}`, path4);
|
|
61293
61235
|
}
|
|
61294
|
-
const absolutePath = await (0,
|
|
61236
|
+
const absolutePath = await (0, import_promises35.realpath)((0, import_node_path35.resolve)(root, ...components)).catch(() => null);
|
|
61295
61237
|
if (!absolutePath || normalizeRelativePath(root, absolutePath) !== normalizedPath) {
|
|
61296
61238
|
throw new SkillPackageError("INVALID_PATH", `Skill package file was not found: ${path4}`, path4);
|
|
61297
61239
|
}
|
|
61298
|
-
const entryStat = await (0,
|
|
61240
|
+
const entryStat = await (0, import_promises35.lstat)(absolutePath);
|
|
61299
61241
|
if (!entryStat.isFile()) {
|
|
61300
61242
|
throw new SkillPackageError("SPECIAL_FILE_BLOCKED", `Only regular files are allowed in Skill packages: ${path4}`, path4);
|
|
61301
61243
|
}
|
|
@@ -61312,11 +61254,11 @@ async function readSkillPackageFile(packageRoot, path4, expectedSha256) {
|
|
|
61312
61254
|
return { file: read.manifest, bytes: read.bytes };
|
|
61313
61255
|
}
|
|
61314
61256
|
async function requirePackageRoot(packageRoot) {
|
|
61315
|
-
const root = await (0,
|
|
61257
|
+
const root = await (0, import_promises35.realpath)((0, import_node_path35.resolve)(packageRoot)).catch(() => null);
|
|
61316
61258
|
if (!root) {
|
|
61317
61259
|
throw new SkillPackageError("INVALID_PACKAGE_ROOT", "Skill package directory does not exist");
|
|
61318
61260
|
}
|
|
61319
|
-
const rootStat = await (0,
|
|
61261
|
+
const rootStat = await (0, import_promises35.lstat)(root);
|
|
61320
61262
|
if (!rootStat.isDirectory()) {
|
|
61321
61263
|
throw new SkillPackageError("INVALID_PACKAGE_ROOT", "Skill package root must be a directory");
|
|
61322
61264
|
}
|
|
@@ -61336,13 +61278,13 @@ async function walkPackage(root, ignoredPaths) {
|
|
|
61336
61278
|
}
|
|
61337
61279
|
return files;
|
|
61338
61280
|
async function walkDirectory(directory) {
|
|
61339
|
-
const entries = await (0,
|
|
61281
|
+
const entries = await (0, import_promises35.readdir)(directory, { withFileTypes: true });
|
|
61340
61282
|
for (const entry of entries) {
|
|
61341
61283
|
const absolutePath = (0, import_node_path35.resolve)(directory, entry.name);
|
|
61342
61284
|
const normalizedPath = normalizeRelativePath(root, absolutePath);
|
|
61343
61285
|
if (isIgnored(normalizedPath, entry.name, entry.isDirectory(), ignored2))
|
|
61344
61286
|
continue;
|
|
61345
|
-
const entryStat = await (0,
|
|
61287
|
+
const entryStat = await (0, import_promises35.lstat)(absolutePath);
|
|
61346
61288
|
if (entryStat.isSymbolicLink()) {
|
|
61347
61289
|
throw new SkillPackageError("SYMLINK_BLOCKED", `Nested symbolic links are not allowed in Skill packages: ${normalizedPath}`, normalizedPath);
|
|
61348
61290
|
}
|
|
@@ -61451,7 +61393,7 @@ function isSecretPath(path4) {
|
|
|
61451
61393
|
return name.endsWith(".private-key.pem") || name.endsWith(".private-key.key");
|
|
61452
61394
|
}
|
|
61453
61395
|
async function readPackageFile(file2) {
|
|
61454
|
-
const bytes = await (0,
|
|
61396
|
+
const bytes = await (0, import_promises35.readFile)(file2.absolutePath);
|
|
61455
61397
|
return {
|
|
61456
61398
|
bytes,
|
|
61457
61399
|
manifest: {
|
|
@@ -61622,13 +61564,13 @@ function uint642(value2) {
|
|
|
61622
61564
|
|
|
61623
61565
|
// src/capabilities/skills/local-sources.ts
|
|
61624
61566
|
var import_node_crypto17 = require("crypto");
|
|
61625
|
-
var
|
|
61567
|
+
var import_promises37 = require("fs/promises");
|
|
61626
61568
|
var import_node_path37 = __toESM(require("path"));
|
|
61627
61569
|
init_type_guards();
|
|
61628
61570
|
|
|
61629
61571
|
// src/capabilities/skills/local-scan.ts
|
|
61630
61572
|
var import_node_crypto16 = require("crypto");
|
|
61631
|
-
var
|
|
61573
|
+
var import_promises36 = require("fs/promises");
|
|
61632
61574
|
var import_node_path36 = __toESM(require("path"));
|
|
61633
61575
|
var MAX_CANDIDATES = 2e3;
|
|
61634
61576
|
var MAX_DIAGNOSTICS = 100;
|
|
@@ -61748,7 +61690,7 @@ function invalid(resolvedRoot, name, error61) {
|
|
|
61748
61690
|
}
|
|
61749
61691
|
async function scanRootAsPackage(pass, resolvedRoot) {
|
|
61750
61692
|
if (!await exists3(import_node_path36.default.join(resolvedRoot.directory, "SKILL.md"))) return null;
|
|
61751
|
-
const canonical = await (0,
|
|
61693
|
+
const canonical = await (0, import_promises36.realpath)(resolvedRoot.directory).catch(() => resolvedRoot.directory);
|
|
61752
61694
|
try {
|
|
61753
61695
|
const inspected = await inspectCached(pass, canonical, null);
|
|
61754
61696
|
return {
|
|
@@ -61777,7 +61719,7 @@ async function scanRoot(pass, resolvedRoot) {
|
|
|
61777
61719
|
if (asPackage !== null) return asPackage;
|
|
61778
61720
|
let entries;
|
|
61779
61721
|
try {
|
|
61780
|
-
entries = await (0,
|
|
61722
|
+
entries = await (0, import_promises36.readdir)(resolvedRoot.directory, { withFileTypes: true });
|
|
61781
61723
|
} catch (error61) {
|
|
61782
61724
|
const code = errnoCode(error61);
|
|
61783
61725
|
if (code === "ENOENT" || code === "ENOTDIR") {
|
|
@@ -61795,7 +61737,7 @@ async function scanRoot(pass, resolvedRoot) {
|
|
|
61795
61737
|
incomplete: true
|
|
61796
61738
|
};
|
|
61797
61739
|
}
|
|
61798
|
-
const canonicalRoot = await (0,
|
|
61740
|
+
const canonicalRoot = await (0, import_promises36.realpath)(resolvedRoot.directory).catch(() => resolvedRoot.directory);
|
|
61799
61741
|
const scan = { candidates: [], diagnostics: [], incomplete: false };
|
|
61800
61742
|
for (const entry of entries) {
|
|
61801
61743
|
if (!entry.isDirectory() && !entry.isSymbolicLink()) continue;
|
|
@@ -61807,7 +61749,7 @@ async function scanRoot(pass, resolvedRoot) {
|
|
|
61807
61749
|
}
|
|
61808
61750
|
async function scanEntry(pass, resolvedRoot, canonicalRoot, name) {
|
|
61809
61751
|
const rootLabel = resolvedRoot.root.label;
|
|
61810
|
-
const canonical = await (0,
|
|
61752
|
+
const canonical = await (0, import_promises36.realpath)(import_node_path36.default.join(resolvedRoot.directory, name)).catch(() => null);
|
|
61811
61753
|
if (canonical === null) {
|
|
61812
61754
|
const message2 = `Could not resolve Skill ${name}`;
|
|
61813
61755
|
return { kind: "diagnostic", diagnostic: { code: "SOURCE_UNREADABLE", message: message2, rootLabel } };
|
|
@@ -61891,12 +61833,12 @@ function deduplicateByContent(candidates2) {
|
|
|
61891
61833
|
async function fingerprintPackage(root) {
|
|
61892
61834
|
const hash2 = (0, import_node_crypto16.createHash)("sha256").update("alan-skill-stat-fingerprint-v1\0");
|
|
61893
61835
|
const visit2 = async (directory, relativeDirectory) => {
|
|
61894
|
-
const entries = await (0,
|
|
61836
|
+
const entries = await (0, import_promises36.readdir)(directory, { withFileTypes: true });
|
|
61895
61837
|
entries.sort((left, right) => Buffer.compare(Buffer.from(left.name), Buffer.from(right.name)));
|
|
61896
61838
|
for (const entry of entries) {
|
|
61897
61839
|
const relative5 = relativeDirectory ? `${relativeDirectory}/${entry.name}` : entry.name;
|
|
61898
61840
|
const absolute = import_node_path36.default.join(directory, entry.name);
|
|
61899
|
-
const metadata = await (0,
|
|
61841
|
+
const metadata = await (0, import_promises36.lstat)(absolute);
|
|
61900
61842
|
const kind = entryKind(entry);
|
|
61901
61843
|
hash2.update(relative5.normalize("NFC")).update(`\0${kind}\0${metadata.size}\0${metadata.mtimeMs}\0${metadata.mode & 511}\0`);
|
|
61902
61844
|
if (entry.isDirectory()) await visit2(absolute, relative5);
|
|
@@ -61912,7 +61854,7 @@ function entryKind(entry) {
|
|
|
61912
61854
|
}
|
|
61913
61855
|
async function canonicalDirectories(directories) {
|
|
61914
61856
|
const canonical = await Promise.all(
|
|
61915
|
-
directories.map((directory) => (0,
|
|
61857
|
+
directories.map((directory) => (0, import_promises36.realpath)(directory).catch(() => directory))
|
|
61916
61858
|
);
|
|
61917
61859
|
return [...new Set(canonical)];
|
|
61918
61860
|
}
|
|
@@ -61922,7 +61864,7 @@ function isWithinDirectory2(parent, candidate) {
|
|
|
61922
61864
|
}
|
|
61923
61865
|
async function exists3(candidate) {
|
|
61924
61866
|
try {
|
|
61925
|
-
await (0,
|
|
61867
|
+
await (0, import_promises36.access)(candidate);
|
|
61926
61868
|
return true;
|
|
61927
61869
|
} catch {
|
|
61928
61870
|
return false;
|
|
@@ -61930,7 +61872,7 @@ async function exists3(candidate) {
|
|
|
61930
61872
|
}
|
|
61931
61873
|
async function isDirectory3(candidate) {
|
|
61932
61874
|
try {
|
|
61933
|
-
return (await (0,
|
|
61875
|
+
return (await (0, import_promises36.lstat)(candidate)).isDirectory();
|
|
61934
61876
|
} catch {
|
|
61935
61877
|
return false;
|
|
61936
61878
|
}
|
|
@@ -62018,7 +61960,7 @@ async function resolveLocalScanInput(home, context, mode) {
|
|
|
62018
61960
|
async function readSkillSourceConfig(home) {
|
|
62019
61961
|
let content;
|
|
62020
61962
|
try {
|
|
62021
|
-
content = await (0,
|
|
61963
|
+
content = await (0, import_promises37.readFile)(skillSourceConfigPath(home), "utf8");
|
|
62022
61964
|
} catch (error61) {
|
|
62023
61965
|
if (errnoCode(error61) !== "ENOENT") {
|
|
62024
61966
|
return { kind: "invalid_config", diagnostic: "~/.alan/config.toml could not be read" };
|
|
@@ -62135,7 +62077,7 @@ async function scanLocalSkills(home, context, cache2, mode = "incremental") {
|
|
|
62135
62077
|
}
|
|
62136
62078
|
|
|
62137
62079
|
// src/capabilities/skills/store.ts
|
|
62138
|
-
var
|
|
62080
|
+
var import_promises38 = require("fs/promises");
|
|
62139
62081
|
var import_node_path38 = require("path");
|
|
62140
62082
|
init_runtime_v2();
|
|
62141
62083
|
init_zod();
|
|
@@ -62183,7 +62125,7 @@ function writeLocalSkills(layout, file2) {
|
|
|
62183
62125
|
async function isLocalSkillCurrent(entry, contentHash, ignoredPaths) {
|
|
62184
62126
|
if (entry.contentHash !== contentHash) return false;
|
|
62185
62127
|
try {
|
|
62186
|
-
if (await (0,
|
|
62128
|
+
if (await (0, import_promises38.realpath)(entry.path) !== entry.path) return false;
|
|
62187
62129
|
const inspected = await inspectSkillPackage(entry.path, { expectedName: null, ignoredPaths });
|
|
62188
62130
|
return inspected.contentHash === contentHash;
|
|
62189
62131
|
} catch {
|
|
@@ -62198,7 +62140,7 @@ async function resolveLocalSkill(local, invocation) {
|
|
|
62198
62140
|
}
|
|
62199
62141
|
async function hasSkillFile(directory) {
|
|
62200
62142
|
try {
|
|
62201
|
-
return (await (0,
|
|
62143
|
+
return (await (0, import_promises38.stat)((0, import_node_path38.join)(directory, "SKILL.md"))).isFile();
|
|
62202
62144
|
} catch {
|
|
62203
62145
|
return false;
|
|
62204
62146
|
}
|
|
@@ -62299,7 +62241,7 @@ async function readLocalSkillFile(layout, ref) {
|
|
|
62299
62241
|
}
|
|
62300
62242
|
async function isDirectory4(candidate) {
|
|
62301
62243
|
try {
|
|
62302
|
-
return (await (0,
|
|
62244
|
+
return (await (0, import_promises39.stat)(candidate)).isDirectory();
|
|
62303
62245
|
} catch {
|
|
62304
62246
|
return false;
|
|
62305
62247
|
}
|
|
@@ -62312,21 +62254,21 @@ async function addSkillSource(home, input2) {
|
|
|
62312
62254
|
return { state: "invalid", diagnostic: `${sourcePath} is not a folder` };
|
|
62313
62255
|
}
|
|
62314
62256
|
const configPath = skillSourceConfigPath(home);
|
|
62315
|
-
await (0,
|
|
62316
|
-
await (0,
|
|
62257
|
+
await (0, import_promises39.mkdir)(import_node_path39.default.dirname(configPath), { recursive: true, mode: 448 });
|
|
62258
|
+
await (0, import_promises39.writeFile)(configPath, DEFAULT_SKILL_CONFIG, { flag: "wx", mode: 384 }).catch(
|
|
62317
62259
|
(error61) => {
|
|
62318
62260
|
if (errnoCode(error61) !== "EEXIST") throw error61;
|
|
62319
62261
|
}
|
|
62320
62262
|
);
|
|
62321
62263
|
const loaded = await readSkillSourceConfig(home);
|
|
62322
62264
|
if (loaded.kind === "invalid_config") return { state: "invalid", diagnostic: loaded.diagnostic };
|
|
62323
|
-
const canonical = await (0,
|
|
62265
|
+
const canonical = await (0, import_promises39.realpath)(sourcePath).catch(() => sourcePath);
|
|
62324
62266
|
for (const source of loaded.config.sources) {
|
|
62325
|
-
if (await (0,
|
|
62267
|
+
if (await (0, import_promises39.realpath)(source.path).catch(() => source.path) === canonical) {
|
|
62326
62268
|
return { state: "already_present", label: source.label };
|
|
62327
62269
|
}
|
|
62328
62270
|
}
|
|
62329
|
-
const current = await (0,
|
|
62271
|
+
const current = await (0, import_promises39.readFile)(configPath, "utf8");
|
|
62330
62272
|
const block = [
|
|
62331
62273
|
"",
|
|
62332
62274
|
"[[skills.sources]]",
|
|
@@ -62334,7 +62276,7 @@ async function addSkillSource(home, input2) {
|
|
|
62334
62276
|
`label = ${JSON.stringify(label)}`,
|
|
62335
62277
|
""
|
|
62336
62278
|
].join("\n");
|
|
62337
|
-
await (0,
|
|
62279
|
+
await (0, import_promises39.writeFile)(configPath, `${current.replace(/\n*$/, "\n")}${block}`, { mode: 384 });
|
|
62338
62280
|
const reloaded = await readSkillSourceConfig(home);
|
|
62339
62281
|
if (reloaded.kind === "invalid_config") {
|
|
62340
62282
|
return { state: "invalid", diagnostic: reloaded.diagnostic };
|
|
@@ -62343,12 +62285,12 @@ async function addSkillSource(home, input2) {
|
|
|
62343
62285
|
}
|
|
62344
62286
|
|
|
62345
62287
|
// src/capabilities/skills/local-upload.ts
|
|
62346
|
-
var
|
|
62288
|
+
var import_promises41 = require("fs/promises");
|
|
62347
62289
|
|
|
62348
62290
|
// ../shared/dist/node/skill-bundle.js
|
|
62349
62291
|
var import_node_buffer2 = require("buffer");
|
|
62350
62292
|
var import_node_crypto18 = require("crypto");
|
|
62351
|
-
var
|
|
62293
|
+
var import_promises40 = require("fs/promises");
|
|
62352
62294
|
var import_node_path40 = require("path");
|
|
62353
62295
|
var import_node_stream = require("stream");
|
|
62354
62296
|
var import_node_zlib = require("zlib");
|
|
@@ -62359,7 +62301,7 @@ async function createSkillBundle(packageRoot, options = {}) {
|
|
|
62359
62301
|
const archive = (0, import_tar_stream.pack)();
|
|
62360
62302
|
const tarPromise = collectStream(archive);
|
|
62361
62303
|
for (const file2 of before.files) {
|
|
62362
|
-
const bytes2 = await (0,
|
|
62304
|
+
const bytes2 = await (0, import_promises40.readFile)((0, import_node_path40.join)(packageRoot, ...file2.path.split("/")));
|
|
62363
62305
|
await addArchiveEntry(archive, {
|
|
62364
62306
|
name: file2.path,
|
|
62365
62307
|
type: "file",
|
|
@@ -62391,7 +62333,7 @@ async function extractSkillBundle(archiveBytes, destination, expected) {
|
|
|
62391
62333
|
throw new Error("Skill archive hash does not match the expected immutable Version");
|
|
62392
62334
|
}
|
|
62393
62335
|
const tarBytes = await decompressBounded(archiveBytes);
|
|
62394
|
-
await (0,
|
|
62336
|
+
await (0, import_promises40.mkdir)(destination, { recursive: false, mode: 448 });
|
|
62395
62337
|
try {
|
|
62396
62338
|
await extractTar(tarBytes, destination);
|
|
62397
62339
|
const inspected = await inspectSkillPackage(destination, { expectedName: null });
|
|
@@ -62399,7 +62341,7 @@ async function extractSkillBundle(archiveBytes, destination, expected) {
|
|
|
62399
62341
|
throw new Error("Extracted Skill package hash does not match the expected immutable Version");
|
|
62400
62342
|
}
|
|
62401
62343
|
} catch (error61) {
|
|
62402
|
-
await (0,
|
|
62344
|
+
await (0, import_promises40.rm)(destination, { recursive: true, force: true });
|
|
62403
62345
|
throw error61;
|
|
62404
62346
|
}
|
|
62405
62347
|
}
|
|
@@ -62475,8 +62417,8 @@ async function extractEntry(header, stream, destination, limits) {
|
|
|
62475
62417
|
throw new Error(`Skill archive file size is invalid: ${path4}`);
|
|
62476
62418
|
}
|
|
62477
62419
|
const outputPath = (0, import_node_path40.join)(destination, ...path4.split("/"));
|
|
62478
|
-
await (0,
|
|
62479
|
-
await (0,
|
|
62420
|
+
await (0, import_promises40.mkdir)((0, import_node_path40.dirname)(outputPath), { recursive: true, mode: 448 });
|
|
62421
|
+
await (0, import_promises40.writeFile)(outputPath, bytes, { mode: (header.mode ?? 420) & 73 ? 493 : 420 });
|
|
62480
62422
|
}
|
|
62481
62423
|
function requireSafeArchivePath(value2) {
|
|
62482
62424
|
const normalized2 = value2.replaceAll("\\", "/").normalize("NFC");
|
|
@@ -62502,8 +62444,8 @@ async function publishLocalSkill(options) {
|
|
|
62502
62444
|
if (Date.parse(request2.uploadGrant.expiresAt) <= (options.now ?? Date.now())) {
|
|
62503
62445
|
throw new RuntimeFault("invalid_file", "Skill upload grant expired");
|
|
62504
62446
|
}
|
|
62505
|
-
const folder = await (0,
|
|
62506
|
-
if (!folder.isDirectory() || await (0,
|
|
62447
|
+
const folder = await (0, import_promises41.lstat)(entry.path);
|
|
62448
|
+
if (!folder.isDirectory() || await (0, import_promises41.realpath)(entry.path) !== entry.path) {
|
|
62507
62449
|
throw new RuntimeFault("invalid_file", "Skill folder moved since the last scan");
|
|
62508
62450
|
}
|
|
62509
62451
|
const bundle = await createSkillBundle(entry.path, {
|
|
@@ -62531,31 +62473,31 @@ async function publishLocalSkill(options) {
|
|
|
62531
62473
|
|
|
62532
62474
|
// src/capabilities/skills/sync.ts
|
|
62533
62475
|
var import_node_crypto19 = require("crypto");
|
|
62534
|
-
var
|
|
62476
|
+
var import_promises42 = require("fs/promises");
|
|
62535
62477
|
var import_node_path41 = require("path");
|
|
62536
62478
|
var SKILL_PREPARE_WAIT_MS = 15e3;
|
|
62537
62479
|
async function install(layout, source, skill, download, signal) {
|
|
62538
62480
|
const bytes = await source.download(download.url, signal);
|
|
62539
|
-
await (0,
|
|
62481
|
+
await (0, import_promises42.mkdir)(layout.tmpDir, { recursive: true, mode: 448 });
|
|
62540
62482
|
const staging = (0, import_node_path41.join)(layout.tmpDir, (0, import_node_crypto19.randomUUID)());
|
|
62541
62483
|
await extractSkillBundle(Buffer.from(bytes), staging, {
|
|
62542
62484
|
expectedArchiveHash: download.archiveHash,
|
|
62543
62485
|
expectedContentHash: skill.contentHash
|
|
62544
62486
|
});
|
|
62545
62487
|
const target = packageDirectory(layout, skill.versionId);
|
|
62546
|
-
await (0,
|
|
62547
|
-
await (0,
|
|
62548
|
-
await (0,
|
|
62488
|
+
await (0, import_promises42.mkdir)(layout.versionsDir, { recursive: true, mode: 448 });
|
|
62489
|
+
await (0, import_promises42.rm)(target, { recursive: true, force: true });
|
|
62490
|
+
await (0, import_promises42.rename)(staging, target);
|
|
62549
62491
|
}
|
|
62550
62492
|
async function sweep(layout, keep) {
|
|
62551
62493
|
const kept = new Set(keep.map((skill) => skill.versionId));
|
|
62552
|
-
const stale = (await (0,
|
|
62494
|
+
const stale = (await (0, import_promises42.readdir)(layout.versionsDir).catch(() => [])).filter(
|
|
62553
62495
|
(name) => !kept.has(name)
|
|
62554
62496
|
);
|
|
62555
62497
|
await Promise.all(
|
|
62556
|
-
stale.map((name) => (0,
|
|
62498
|
+
stale.map((name) => (0, import_promises42.rm)((0, import_node_path41.join)(layout.versionsDir, name), { recursive: true, force: true }))
|
|
62557
62499
|
);
|
|
62558
|
-
await (0,
|
|
62500
|
+
await (0, import_promises42.rm)(layout.tmpDir, { recursive: true, force: true });
|
|
62559
62501
|
return stale.length;
|
|
62560
62502
|
}
|
|
62561
62503
|
async function intactSkills(layout) {
|
|
@@ -62790,7 +62732,7 @@ var import_node_path44 = require("path");
|
|
|
62790
62732
|
init_runtime_v2();
|
|
62791
62733
|
|
|
62792
62734
|
// src/capabilities/workspace/approved-paths.ts
|
|
62793
|
-
var
|
|
62735
|
+
var import_promises43 = require("fs/promises");
|
|
62794
62736
|
init_zod();
|
|
62795
62737
|
|
|
62796
62738
|
// src/capabilities/workspace/paths.ts
|
|
@@ -62828,7 +62770,7 @@ var storeSchema = external_exports.object({
|
|
|
62828
62770
|
});
|
|
62829
62771
|
async function realpathOrNull(path4) {
|
|
62830
62772
|
try {
|
|
62831
|
-
return await (0,
|
|
62773
|
+
return await (0, import_promises43.realpath)(path4);
|
|
62832
62774
|
} catch (error61) {
|
|
62833
62775
|
const code = errnoCode(error61);
|
|
62834
62776
|
if (code === "ENOENT" || code === "ENOTDIR" || code === "EACCES" || code === "EPERM") {
|
|
@@ -62888,7 +62830,7 @@ async function openApprovedPaths(options) {
|
|
|
62888
62830
|
|
|
62889
62831
|
// src/capabilities/workspace/locks.ts
|
|
62890
62832
|
var import_node_crypto20 = require("crypto");
|
|
62891
|
-
var
|
|
62833
|
+
var import_promises44 = require("fs/promises");
|
|
62892
62834
|
var import_node_path43 = require("path");
|
|
62893
62835
|
init_zod();
|
|
62894
62836
|
var LOCK_FORMAT = 1;
|
|
@@ -62909,7 +62851,7 @@ function repositoryLockKey(commonDir, platform3) {
|
|
|
62909
62851
|
async function readOwner2(path4) {
|
|
62910
62852
|
let text2;
|
|
62911
62853
|
try {
|
|
62912
|
-
text2 = await (0,
|
|
62854
|
+
text2 = await (0, import_promises44.readFile)(path4, "utf8");
|
|
62913
62855
|
} catch (error61) {
|
|
62914
62856
|
if (errnoCode(error61) === "ENOENT") return { kind: "missing" };
|
|
62915
62857
|
return { kind: "unreadable" };
|
|
@@ -62930,7 +62872,7 @@ async function removeIfSame(path4, expected) {
|
|
|
62930
62872
|
if (current.kind !== "owner" || current.owner.since !== expected.since) return;
|
|
62931
62873
|
if (current.owner.pid !== expected.pid || current.owner.holder !== expected.holder) return;
|
|
62932
62874
|
}
|
|
62933
|
-
await (0,
|
|
62875
|
+
await (0, import_promises44.unlink)(path4).catch((error61) => {
|
|
62934
62876
|
if (errnoCode(error61) !== "ENOENT") throw error61;
|
|
62935
62877
|
});
|
|
62936
62878
|
}
|
|
@@ -62955,7 +62897,7 @@ function openRepositoryLocks(options) {
|
|
|
62955
62897
|
await removeIfSame(path4, read.owner);
|
|
62956
62898
|
return null;
|
|
62957
62899
|
}
|
|
62958
|
-
const age = await (0,
|
|
62900
|
+
const age = await (0, import_promises44.stat)(path4).then(
|
|
62959
62901
|
(info) => clock.now() - info.mtimeMs,
|
|
62960
62902
|
() => 0
|
|
62961
62903
|
);
|
|
@@ -62970,12 +62912,12 @@ function openRepositoryLocks(options) {
|
|
|
62970
62912
|
const folder = async (commonDir) => {
|
|
62971
62913
|
const key = repositoryLockKey(commonDir, platform3);
|
|
62972
62914
|
const dir = (0, import_node_path43.join)(options.dir, key);
|
|
62973
|
-
await (0,
|
|
62915
|
+
await (0, import_promises44.mkdir)(dir, { recursive: true, mode: 448 });
|
|
62974
62916
|
return { key, dir };
|
|
62975
62917
|
};
|
|
62976
62918
|
const createExclusive = async (path4, owner) => {
|
|
62977
62919
|
try {
|
|
62978
|
-
const handle = await (0,
|
|
62920
|
+
const handle = await (0, import_promises44.open)(path4, "wx", 384);
|
|
62979
62921
|
try {
|
|
62980
62922
|
await handle.writeFile(JSON.stringify(owner));
|
|
62981
62923
|
} finally {
|
|
@@ -62988,7 +62930,7 @@ function openRepositoryLocks(options) {
|
|
|
62988
62930
|
}
|
|
62989
62931
|
};
|
|
62990
62932
|
const liveRun = async (dir) => {
|
|
62991
|
-
const entries = await (0,
|
|
62933
|
+
const entries = await (0, import_promises44.readdir)(dir);
|
|
62992
62934
|
for (const entry of entries) {
|
|
62993
62935
|
if (!entry.startsWith(RUN_FILE_PREFIX)) continue;
|
|
62994
62936
|
const holder = await heldBy((0, import_node_path43.join)(dir, entry));
|
|
@@ -63496,7 +63438,7 @@ var mcpConfigResultSchema = external_exports.object({
|
|
|
63496
63438
|
});
|
|
63497
63439
|
|
|
63498
63440
|
// src/client/runtime-client.ts
|
|
63499
|
-
var
|
|
63441
|
+
var import_promises45 = require("fs/promises");
|
|
63500
63442
|
init_runtime_v2();
|
|
63501
63443
|
|
|
63502
63444
|
// src/client/sse.ts
|
|
@@ -63552,7 +63494,7 @@ var DEFAULT_BACKOFF = { initialMs: 250, maxMs: 3e4 };
|
|
|
63552
63494
|
async function readDiscovery(path4) {
|
|
63553
63495
|
let text2;
|
|
63554
63496
|
try {
|
|
63555
|
-
text2 = await (0,
|
|
63497
|
+
text2 = await (0, import_promises45.readFile)(path4, "utf8");
|
|
63556
63498
|
} catch (error61) {
|
|
63557
63499
|
throw new RuntimeClientError("unavailable", "The runtime is not running", { cause: error61 });
|
|
63558
63500
|
}
|
|
@@ -63857,7 +63799,7 @@ async function sendNativeHookSignal(discoveryPath, hookSignal, signal) {
|
|
|
63857
63799
|
|
|
63858
63800
|
// src/sessions/index.ts
|
|
63859
63801
|
var import_node_crypto24 = require("crypto");
|
|
63860
|
-
var
|
|
63802
|
+
var import_promises57 = require("fs/promises");
|
|
63861
63803
|
var import_node_os10 = require("os");
|
|
63862
63804
|
var import_node_path56 = require("path");
|
|
63863
63805
|
init_runtime_v2();
|
|
@@ -64111,7 +64053,7 @@ function createConversationMcpAuthorization(options) {
|
|
|
64111
64053
|
}
|
|
64112
64054
|
|
|
64113
64055
|
// src/holder/run-inputs.ts
|
|
64114
|
-
var
|
|
64056
|
+
var import_promises50 = require("fs/promises");
|
|
64115
64057
|
var import_node_path48 = require("path");
|
|
64116
64058
|
var NO_RUN_INPUTS = {
|
|
64117
64059
|
attachments: [],
|
|
@@ -64127,16 +64069,16 @@ function safeFilename(filename) {
|
|
|
64127
64069
|
async function prepareRunInputs(spec, { source, tmpDir, signal, skills = [] }) {
|
|
64128
64070
|
const dir = (0, import_node_path48.join)(tmpDir, "runs", spec.runId);
|
|
64129
64071
|
const cleanup = async () => {
|
|
64130
|
-
await (0,
|
|
64072
|
+
await (0, import_promises50.rm)(dir, { recursive: true, force: true });
|
|
64131
64073
|
};
|
|
64132
64074
|
try {
|
|
64133
64075
|
const credential = await source.fetchProviderCredential(spec.runId, signal);
|
|
64134
64076
|
const attachments = [];
|
|
64135
|
-
if (spec.attachments?.length) await (0,
|
|
64077
|
+
if (spec.attachments?.length) await (0, import_promises50.mkdir)(dir, { recursive: true, mode: 448 });
|
|
64136
64078
|
for (const [index, attachment] of (spec.attachments ?? []).entries()) {
|
|
64137
64079
|
const bytes = await source.downloadAttachment(spec.runId, attachment.id, signal);
|
|
64138
64080
|
const path4 = (0, import_node_path48.join)(dir, `${index}-${safeFilename(attachment.filename)}`);
|
|
64139
|
-
await (0,
|
|
64081
|
+
await (0, import_promises50.writeFile)(path4, bytes, { mode: 384 });
|
|
64140
64082
|
attachments.push({
|
|
64141
64083
|
id: attachment.id,
|
|
64142
64084
|
kind: attachment.kind,
|
|
@@ -64164,7 +64106,7 @@ init_runtime_v2();
|
|
|
64164
64106
|
|
|
64165
64107
|
// src/holder/admission.ts
|
|
64166
64108
|
var import_node_fs15 = require("fs");
|
|
64167
|
-
var
|
|
64109
|
+
var import_promises53 = require("fs/promises");
|
|
64168
64110
|
var import_node_os9 = require("os");
|
|
64169
64111
|
var import_node_path52 = require("path");
|
|
64170
64112
|
init_constants();
|
|
@@ -64178,7 +64120,7 @@ function resolveAlanDefaultWorkspacePath(homeDirectory = (0, import_node_os8.hom
|
|
|
64178
64120
|
}
|
|
64179
64121
|
|
|
64180
64122
|
// src/holder/admission-relocation.ts
|
|
64181
|
-
var
|
|
64123
|
+
var import_promises51 = require("fs/promises");
|
|
64182
64124
|
var import_node_path50 = require("path");
|
|
64183
64125
|
var MAX_RELOCATION_CANDIDATES = 200;
|
|
64184
64126
|
var RELOCATION_BUDGET_MS = 2e4;
|
|
@@ -64214,7 +64156,7 @@ async function originIdentity(git, path4, signal) {
|
|
|
64214
64156
|
}
|
|
64215
64157
|
async function childDirectories(parent, limit) {
|
|
64216
64158
|
try {
|
|
64217
|
-
const entries = await (0,
|
|
64159
|
+
const entries = await (0, import_promises51.readdir)(parent, { withFileTypes: true });
|
|
64218
64160
|
return entries.filter((entry) => entry.isDirectory()).slice(0, limit).map((entry) => (0, import_node_path50.join)(parent, entry.name));
|
|
64219
64161
|
} catch {
|
|
64220
64162
|
return [];
|
|
@@ -64250,7 +64192,7 @@ async function discoverRelocatedWorkspace(search) {
|
|
|
64250
64192
|
}
|
|
64251
64193
|
|
|
64252
64194
|
// src/holder/lease.ts
|
|
64253
|
-
var
|
|
64195
|
+
var import_promises52 = require("fs/promises");
|
|
64254
64196
|
var import_node_path51 = require("path");
|
|
64255
64197
|
var LEASE_CHECK_EVERY_MS = 5e3;
|
|
64256
64198
|
var MAX_TRANSIENT_FAILURES = 3;
|
|
@@ -64265,8 +64207,8 @@ function identityFailure(code, workspacePath) {
|
|
|
64265
64207
|
return { code, problemCode: "app.workspace.missing", message: MESSAGES[code], workspacePath };
|
|
64266
64208
|
}
|
|
64267
64209
|
async function fileIdentity(path4) {
|
|
64268
|
-
const canonical = await (0,
|
|
64269
|
-
const info = await (0,
|
|
64210
|
+
const canonical = await (0, import_promises52.realpath)(path4);
|
|
64211
|
+
const info = await (0, import_promises52.stat)(canonical, { bigint: true });
|
|
64270
64212
|
return `${canonical}:${info.dev}:${info.ino}`;
|
|
64271
64213
|
}
|
|
64272
64214
|
async function snapshot(git, path4, signal) {
|
|
@@ -64285,7 +64227,7 @@ async function snapshot(git, path4, signal) {
|
|
|
64285
64227
|
workspace: await fileIdentity(path4),
|
|
64286
64228
|
repository: await fileIdentity(commonDir),
|
|
64287
64229
|
worktree: await fileIdentity(gitDir),
|
|
64288
|
-
commonDir: await (0,
|
|
64230
|
+
commonDir: await (0, import_promises52.realpath)(commonDir)
|
|
64289
64231
|
};
|
|
64290
64232
|
} catch {
|
|
64291
64233
|
return null;
|
|
@@ -64298,7 +64240,7 @@ async function gitValue(git, path4, args, signal) {
|
|
|
64298
64240
|
}
|
|
64299
64241
|
async function pathExists(path4) {
|
|
64300
64242
|
try {
|
|
64301
|
-
await (0,
|
|
64243
|
+
await (0, import_promises52.stat)(path4);
|
|
64302
64244
|
return true;
|
|
64303
64245
|
} catch (error61) {
|
|
64304
64246
|
return errnoCode(error61) !== "ENOENT" && errnoCode(error61) !== "ENOTDIR";
|
|
@@ -64307,13 +64249,13 @@ async function pathExists(path4) {
|
|
|
64307
64249
|
async function hasGitMarker(path4) {
|
|
64308
64250
|
let directory;
|
|
64309
64251
|
try {
|
|
64310
|
-
directory = await (0,
|
|
64252
|
+
directory = await (0, import_promises52.realpath)(path4);
|
|
64311
64253
|
} catch {
|
|
64312
64254
|
return true;
|
|
64313
64255
|
}
|
|
64314
64256
|
for (; ; ) {
|
|
64315
64257
|
try {
|
|
64316
|
-
await (0,
|
|
64258
|
+
await (0, import_promises52.stat)((0, import_node_path51.join)(directory, ".git"));
|
|
64317
64259
|
return true;
|
|
64318
64260
|
} catch (error61) {
|
|
64319
64261
|
const code = errnoCode(error61);
|
|
@@ -64483,7 +64425,7 @@ function volumeRoot(path4) {
|
|
|
64483
64425
|
}
|
|
64484
64426
|
async function exists4(path4) {
|
|
64485
64427
|
try {
|
|
64486
|
-
await (0,
|
|
64428
|
+
await (0, import_promises53.stat)(path4);
|
|
64487
64429
|
return true;
|
|
64488
64430
|
} catch {
|
|
64489
64431
|
return false;
|
|
@@ -64491,10 +64433,10 @@ async function exists4(path4) {
|
|
|
64491
64433
|
}
|
|
64492
64434
|
async function inspectReadiness(path4) {
|
|
64493
64435
|
try {
|
|
64494
|
-
if (!(await (0,
|
|
64436
|
+
if (!(await (0, import_promises53.stat)(path4)).isDirectory()) {
|
|
64495
64437
|
return { ready: false, missing: true, message: MESSAGES2.missing };
|
|
64496
64438
|
}
|
|
64497
|
-
await (0,
|
|
64439
|
+
await (0, import_promises53.access)(path4, import_node_fs15.constants.R_OK | import_node_fs15.constants.W_OK | import_node_fs15.constants.X_OK);
|
|
64498
64440
|
return { ready: true };
|
|
64499
64441
|
} catch (error61) {
|
|
64500
64442
|
const code = errnoCode(error61) ?? "";
|
|
@@ -64572,8 +64514,8 @@ async function admitDefaultWorkspace(spec, context, skills) {
|
|
|
64572
64514
|
const { env } = context;
|
|
64573
64515
|
const path4 = resolveAlanDefaultWorkspacePath(env.HOME || env.USERPROFILE || (0, import_node_os9.homedir)());
|
|
64574
64516
|
try {
|
|
64575
|
-
await (0,
|
|
64576
|
-
await (0,
|
|
64517
|
+
await (0, import_promises53.mkdir)(path4, { recursive: true, mode: 448 });
|
|
64518
|
+
await (0, import_promises53.access)(path4, import_node_fs15.constants.R_OK | import_node_fs15.constants.W_OK | import_node_fs15.constants.X_OK);
|
|
64577
64519
|
return {
|
|
64578
64520
|
kind: "admitted",
|
|
64579
64521
|
spec: { ...spec, projectPath: path4 },
|
|
@@ -64685,7 +64627,7 @@ async function respondToTurn(runningRunId, gate, driver, request2) {
|
|
|
64685
64627
|
}
|
|
64686
64628
|
|
|
64687
64629
|
// src/holder/session-facts.ts
|
|
64688
|
-
var
|
|
64630
|
+
var import_promises54 = require("fs/promises");
|
|
64689
64631
|
var CLI_RSS_CACHE_MS = 1e4;
|
|
64690
64632
|
var LOGIN_PROBLEM_PREFIX = "cli.auth.";
|
|
64691
64633
|
function isLoginFailure(result) {
|
|
@@ -64709,8 +64651,8 @@ function createSessionFacts(options) {
|
|
|
64709
64651
|
const path4 = await resolveCommandOnPath(command, env, platform3);
|
|
64710
64652
|
if (path4 === null) return null;
|
|
64711
64653
|
try {
|
|
64712
|
-
const real = await (0,
|
|
64713
|
-
const info = await (0,
|
|
64654
|
+
const real = await (0, import_promises54.realpath)(path4);
|
|
64655
|
+
const info = await (0, import_promises54.stat)(real);
|
|
64714
64656
|
return { command, key: `${real}:${info.ino}:${info.size}:${info.mtimeMs}` };
|
|
64715
64657
|
} catch {
|
|
64716
64658
|
return null;
|
|
@@ -64791,7 +64733,7 @@ var import_node_fs16 = require("fs");
|
|
|
64791
64733
|
var import_node_path54 = require("path");
|
|
64792
64734
|
|
|
64793
64735
|
// src/run-log/directory.ts
|
|
64794
|
-
var
|
|
64736
|
+
var import_promises55 = require("fs/promises");
|
|
64795
64737
|
var import_node_path53 = require("path");
|
|
64796
64738
|
init_runtime_v2();
|
|
64797
64739
|
init_zod();
|
|
@@ -64811,7 +64753,7 @@ function runDirectory(runsDir, runId) {
|
|
|
64811
64753
|
}
|
|
64812
64754
|
async function isRunClaimed(runsDir, runId) {
|
|
64813
64755
|
try {
|
|
64814
|
-
return (await (0,
|
|
64756
|
+
return (await (0, import_promises55.stat)(runDirectory(runsDir, runId).log)).size > 0;
|
|
64815
64757
|
} catch (error61) {
|
|
64816
64758
|
if (errnoCode(error61) === "ENOENT") return false;
|
|
64817
64759
|
throw error61;
|
|
@@ -64849,7 +64791,7 @@ async function writeCompleteRunLog(runsDir, meta3, records) {
|
|
|
64849
64791
|
}
|
|
64850
64792
|
|
|
64851
64793
|
// src/run-log/reader.ts
|
|
64852
|
-
var
|
|
64794
|
+
var import_promises56 = require("fs/promises");
|
|
64853
64795
|
init_runtime_v2();
|
|
64854
64796
|
|
|
64855
64797
|
// src/run-log/tail.ts
|
|
@@ -64872,7 +64814,7 @@ function firstRecordLength(bytes) {
|
|
|
64872
64814
|
return bytes.indexOf(RUN_LOG_RECORD_SEPARATOR) + 1;
|
|
64873
64815
|
}
|
|
64874
64816
|
async function openRunLogReader(path4) {
|
|
64875
|
-
const handle = await (0,
|
|
64817
|
+
const handle = await (0, import_promises56.open)(path4, "r");
|
|
64876
64818
|
const readAt = async (position, length) => {
|
|
64877
64819
|
const buffer = Buffer.alloc(length);
|
|
64878
64820
|
const { bytesRead } = await handle.read(buffer, 0, length, position);
|
|
@@ -64906,7 +64848,7 @@ async function openRunLogReader(path4) {
|
|
|
64906
64848
|
};
|
|
64907
64849
|
}
|
|
64908
64850
|
async function readLastRecord(path4) {
|
|
64909
|
-
const handle = await (0,
|
|
64851
|
+
const handle = await (0, import_promises56.open)(path4, "r").catch(() => null);
|
|
64910
64852
|
if (handle === null) return null;
|
|
64911
64853
|
try {
|
|
64912
64854
|
const { size } = await handle.stat();
|
|
@@ -65156,10 +65098,6 @@ async function runWithInputs({ spec, leaseTargets, skills }, context, sink, sign
|
|
|
65156
65098
|
_promise2 && await _promise2;
|
|
65157
65099
|
}
|
|
65158
65100
|
}
|
|
65159
|
-
function recordRelevantContext(spec, append) {
|
|
65160
|
-
if (spec.relevantContext === void 0) return;
|
|
65161
|
-
append(fitForRunLog(contextRecallUpdate(`relevant-context-${spec.runId}`, spec.relevantContext)));
|
|
65162
|
-
}
|
|
65163
65101
|
async function admitAndRun(spec, context, append, sink, signal) {
|
|
65164
65102
|
if (context.workspace === void 0) {
|
|
65165
65103
|
if (spec.skillInvocations?.length) {
|
|
@@ -65169,7 +65107,6 @@ async function admitAndRun(spec, context, append, sink, signal) {
|
|
|
65169
65107
|
message: "Selected skills need this computer's skill sync, which this holder does not have."
|
|
65170
65108
|
};
|
|
65171
65109
|
}
|
|
65172
|
-
recordRelevantContext(spec, append);
|
|
65173
65110
|
return runWithInputs({ spec, leaseTargets: [], skills: [] }, context, sink, signal);
|
|
65174
65111
|
}
|
|
65175
65112
|
const admission = await admitRun(spec, context.workspace.admission, signal);
|
|
@@ -65178,7 +65115,6 @@ async function admitAndRun(spec, context, append, sink, signal) {
|
|
|
65178
65115
|
return { outcome: "rejected", rejection: admission.rejection, message: admission.message };
|
|
65179
65116
|
}
|
|
65180
65117
|
if (admission.relocated !== null) append(admission.relocated);
|
|
65181
|
-
recordRelevantContext(spec, append);
|
|
65182
65118
|
return runWithInputs(admission, context, sink, signal);
|
|
65183
65119
|
}
|
|
65184
65120
|
async function claimRun(spec, context) {
|
|
@@ -65545,7 +65481,7 @@ var DEFAULT_MAX_ACTIVE_RUNS = 32;
|
|
|
65545
65481
|
var HOLDER_BUSY = "busy";
|
|
65546
65482
|
async function listIds(dir, schema) {
|
|
65547
65483
|
const ids = [];
|
|
65548
|
-
for (const name of await (0,
|
|
65484
|
+
for (const name of await (0, import_promises57.readdir)(dir).catch(() => [])) {
|
|
65549
65485
|
const parsed = schema.safeParse(name);
|
|
65550
65486
|
if (parsed.success) ids.push(parsed.data);
|
|
65551
65487
|
}
|
|
@@ -65606,7 +65542,7 @@ async function openSessions(deps) {
|
|
|
65606
65542
|
}
|
|
65607
65543
|
await clock.sleep(HOLDER_READY_POLL_MS, AbortSignal.timeout(HOLDER_EXIT_GRACE_MS));
|
|
65608
65544
|
}
|
|
65609
|
-
await (0,
|
|
65545
|
+
await (0, import_promises57.rm)(files.dir, { recursive: true, force: true });
|
|
65610
65546
|
for (const [runId, owner] of launched) if (owner === conversationId) launched.delete(runId);
|
|
65611
65547
|
for (const runId of await listIds(paths.runs, runIdSchema)) {
|
|
65612
65548
|
const meta3 = await readRunMeta(runDirectory(paths.runs, runId).meta);
|
|
@@ -65655,7 +65591,7 @@ async function openSessions(deps) {
|
|
|
65655
65591
|
if (!await waitForExit2(holder)) return false;
|
|
65656
65592
|
}
|
|
65657
65593
|
legacy.delete(conversationId);
|
|
65658
|
-
await (0,
|
|
65594
|
+
await (0, import_promises57.rm)(sessionFiles(paths, conversationId).dir, { recursive: true, force: true });
|
|
65659
65595
|
for (const runId of await unendedRunsOf(conversationId)) await markInterrupted(runId);
|
|
65660
65596
|
log.info("sessions.legacy_holder_retired", { conversationId });
|
|
65661
65597
|
return true;
|
|
@@ -65681,7 +65617,7 @@ async function openSessions(deps) {
|
|
|
65681
65617
|
log.info("sessions.reattached", { conversationId });
|
|
65682
65618
|
return;
|
|
65683
65619
|
}
|
|
65684
|
-
await (0,
|
|
65620
|
+
await (0, import_promises57.rm)(files.dir, { recursive: true, force: true });
|
|
65685
65621
|
};
|
|
65686
65622
|
const busyRunIds = async () => {
|
|
65687
65623
|
const busy = /* @__PURE__ */ new Set();
|
|
@@ -65735,7 +65671,7 @@ async function openSessions(deps) {
|
|
|
65735
65671
|
const meta3 = await readRunMeta(dir.meta);
|
|
65736
65672
|
const last = await readLastRecord(dir.log);
|
|
65737
65673
|
if (meta3 === null || last === null) return null;
|
|
65738
|
-
const logged = await (0,
|
|
65674
|
+
const logged = await (0, import_promises57.stat)(dir.log).catch((error61) => {
|
|
65739
65675
|
if (errnoCode(error61) === "ENOENT") return null;
|
|
65740
65676
|
throw error61;
|
|
65741
65677
|
});
|
|
@@ -66087,7 +66023,7 @@ function readCliEnvironment(env = process.env) {
|
|
|
66087
66023
|
}
|
|
66088
66024
|
|
|
66089
66025
|
// src/cli/context.ts
|
|
66090
|
-
var
|
|
66026
|
+
var import_promises58 = require("fs/promises");
|
|
66091
66027
|
var import_node_os12 = require("os");
|
|
66092
66028
|
var import_node_path58 = require("path");
|
|
66093
66029
|
var DESKTOP_BUNDLE_IDS = {
|
|
@@ -66137,7 +66073,7 @@ async function installedServiceSpec(ctx) {
|
|
|
66137
66073
|
const spec = serviceSpec(ctx);
|
|
66138
66074
|
if (ctx.config.host === "app") return spec;
|
|
66139
66075
|
const layout = installLayout(ctx.config.installDir, ctx.config.profile);
|
|
66140
|
-
const installed = await (0,
|
|
66076
|
+
const installed = await (0, import_promises58.access)(layout.launcher).then(
|
|
66141
66077
|
() => true,
|
|
66142
66078
|
() => false
|
|
66143
66079
|
);
|
|
@@ -66264,7 +66200,7 @@ var manifestRevisionSchema = external_exports.object({ revision: external_export
|
|
|
66264
66200
|
async function manifestRevision(path4) {
|
|
66265
66201
|
let raw;
|
|
66266
66202
|
try {
|
|
66267
|
-
raw = JSON.parse(await (0,
|
|
66203
|
+
raw = JSON.parse(await (0, import_promises59.readFile)(path4, "utf8"));
|
|
66268
66204
|
} catch (error61) {
|
|
66269
66205
|
throw new RuntimeFault("invalid_file", `Cannot read the skill manifest at ${path4}`, {
|
|
66270
66206
|
cause: error61
|
|
@@ -66318,7 +66254,7 @@ async function runSkills(argv) {
|
|
|
66318
66254
|
}
|
|
66319
66255
|
|
|
66320
66256
|
// src/cli/commands/doctor.ts
|
|
66321
|
-
var
|
|
66257
|
+
var import_promises62 = require("fs/promises");
|
|
66322
66258
|
var import_node_path62 = require("path");
|
|
66323
66259
|
init_runtime_v2();
|
|
66324
66260
|
|
|
@@ -66496,7 +66432,7 @@ async function authorizeDevice(input2) {
|
|
|
66496
66432
|
}
|
|
66497
66433
|
|
|
66498
66434
|
// src/identity/enroll.ts
|
|
66499
|
-
var
|
|
66435
|
+
var import_promises60 = require("fs/promises");
|
|
66500
66436
|
init_runtime_v2();
|
|
66501
66437
|
|
|
66502
66438
|
// src/identity/installation.ts
|
|
@@ -66567,12 +66503,12 @@ async function enrollFromGrantFile(input2) {
|
|
|
66567
66503
|
clock: input2.clock,
|
|
66568
66504
|
access: input2.access
|
|
66569
66505
|
});
|
|
66570
|
-
await (0,
|
|
66506
|
+
await (0, import_promises60.rm)(input2.grantPath, { force: true });
|
|
66571
66507
|
return machine;
|
|
66572
66508
|
}
|
|
66573
66509
|
|
|
66574
66510
|
// src/identity/migrate-v1.ts
|
|
66575
|
-
var
|
|
66511
|
+
var import_promises61 = require("fs/promises");
|
|
66576
66512
|
var import_node_path60 = require("path");
|
|
66577
66513
|
init_runtime_v2();
|
|
66578
66514
|
init_zod();
|
|
@@ -66623,8 +66559,8 @@ async function scrubLegacyInstall(install2) {
|
|
|
66623
66559
|
const scrubbed = { ...install2.config, migratedToRuntimeV2: true };
|
|
66624
66560
|
for (const key of SCRUBBED_KEYS) delete scrubbed[key];
|
|
66625
66561
|
await writeJsonFileAtomic(`${install2.configPath}.migrated-v1`, scrubbed);
|
|
66626
|
-
await (0,
|
|
66627
|
-
await (0,
|
|
66562
|
+
await (0, import_promises61.rm)(install2.configPath, { force: true });
|
|
66563
|
+
await (0, import_promises61.rm)(install2.ownerLeasePath, { force: true });
|
|
66628
66564
|
}
|
|
66629
66565
|
async function exchangeCredential(deps) {
|
|
66630
66566
|
const { config: config2 } = deps.install;
|
|
@@ -67033,7 +66969,7 @@ async function probeHolder(dir, conversationId) {
|
|
|
67033
66969
|
}
|
|
67034
66970
|
}
|
|
67035
66971
|
async function holdersCheck(ctx) {
|
|
67036
|
-
const names = await (0,
|
|
66972
|
+
const names = await (0, import_promises62.readdir)(ctx.paths.sessions).catch(() => []);
|
|
67037
66973
|
const holders = (await Promise.all(names.map((name) => probeHolder((0, import_node_path62.join)(ctx.paths.sessions, name), name)))).filter((facts) => facts !== null);
|
|
67038
66974
|
const dead = holders.filter((holder) => !holder.alive).length;
|
|
67039
66975
|
return check2(
|
|
@@ -67045,7 +66981,7 @@ async function holdersCheck(ctx) {
|
|
|
67045
66981
|
}
|
|
67046
66982
|
async function freeBytesAt(path4) {
|
|
67047
66983
|
try {
|
|
67048
|
-
const stats = await (0,
|
|
66984
|
+
const stats = await (0, import_promises62.statfs)(path4);
|
|
67049
66985
|
return { path: path4, freeBytes: stats.bavail * stats.bsize };
|
|
67050
66986
|
} catch (error61) {
|
|
67051
66987
|
const parent = (0, import_node_path62.dirname)(path4);
|
|
@@ -67184,7 +67120,7 @@ async function runDoctor(argv, context = cliContext) {
|
|
|
67184
67120
|
}
|
|
67185
67121
|
|
|
67186
67122
|
// src/cli/commands/git-credential.ts
|
|
67187
|
-
var
|
|
67123
|
+
var import_promises63 = require("fs/promises");
|
|
67188
67124
|
var import_node_net4 = require("net");
|
|
67189
67125
|
var MAX_RESPONSE_BYTES = 64 * 1024;
|
|
67190
67126
|
async function readAll(stream) {
|
|
@@ -67289,7 +67225,7 @@ async function configure(argv) {
|
|
|
67289
67225
|
}
|
|
67290
67226
|
const config2 = loadRuntimeConfig();
|
|
67291
67227
|
const { launcher } = installLayout(config2.installDir, config2.profile);
|
|
67292
|
-
const installed = await (0,
|
|
67228
|
+
const installed = await (0, import_promises63.access)(launcher).then(
|
|
67293
67229
|
() => true,
|
|
67294
67230
|
() => false
|
|
67295
67231
|
);
|
|
@@ -67466,7 +67402,7 @@ async function runHook(argv, overrides = {}) {
|
|
|
67466
67402
|
}
|
|
67467
67403
|
|
|
67468
67404
|
// src/cli/commands/ingestion-hooks.ts
|
|
67469
|
-
var
|
|
67405
|
+
var import_promises64 = require("fs/promises");
|
|
67470
67406
|
var CODEX_TRUST_NOTE = "Codex runs new hooks only after you review them: open /hooks in Codex.";
|
|
67471
67407
|
function isAction(value2) {
|
|
67472
67408
|
return value2 === "enable" || value2 === "disable" || value2 === "status";
|
|
@@ -67489,7 +67425,7 @@ function errorMessage2(error61) {
|
|
|
67489
67425
|
return error61 instanceof Error ? error61.message : String(error61);
|
|
67490
67426
|
}
|
|
67491
67427
|
async function exists5(path4) {
|
|
67492
|
-
return (0,
|
|
67428
|
+
return (0, import_promises64.access)(path4).then(
|
|
67493
67429
|
() => true,
|
|
67494
67430
|
() => false
|
|
67495
67431
|
);
|
|
@@ -67848,7 +67784,7 @@ async function runToken(argv, signal) {
|
|
|
67848
67784
|
}
|
|
67849
67785
|
|
|
67850
67786
|
// src/cli/commands/logout.ts
|
|
67851
|
-
var
|
|
67787
|
+
var import_promises65 = require("fs/promises");
|
|
67852
67788
|
var import_node_path67 = require("path");
|
|
67853
67789
|
init_runtime_v2();
|
|
67854
67790
|
var RUNTIME_EXIT_WAIT_MS = 35e3;
|
|
@@ -67908,7 +67844,7 @@ async function stopHolder(launch, deps, outcome2) {
|
|
|
67908
67844
|
}
|
|
67909
67845
|
async function stopHeldRuns(ctx, deps, outcome2 = "aborted") {
|
|
67910
67846
|
const stopped = [];
|
|
67911
|
-
for (const name of await (0,
|
|
67847
|
+
for (const name of await (0, import_promises65.readdir)(ctx.paths.sessions).catch(() => [])) {
|
|
67912
67848
|
const launch = await readJsonFile(
|
|
67913
67849
|
(0, import_node_path67.join)(ctx.paths.sessions, name, "launch.json"),
|
|
67914
67850
|
holderLaunchSchema
|
|
@@ -67947,7 +67883,7 @@ async function forgetMachineLocally(ctx) {
|
|
|
67947
67883
|
const machine = await readMachineFile(ctx.paths);
|
|
67948
67884
|
if (machine === null) return;
|
|
67949
67885
|
await credentialStoreFor(ctx.paths, machine.credentialStore, ctx.access).clear();
|
|
67950
|
-
await (0,
|
|
67886
|
+
await (0, import_promises65.rm)(ctx.paths.machine, { force: true });
|
|
67951
67887
|
}
|
|
67952
67888
|
async function runLogout(argv, signal) {
|
|
67953
67889
|
var _stack = [];
|
|
@@ -68036,7 +67972,7 @@ function createRunAppends() {
|
|
|
68036
67972
|
|
|
68037
67973
|
// src/local-api/server.ts
|
|
68038
67974
|
var import_node_crypto28 = require("crypto");
|
|
68039
|
-
var
|
|
67975
|
+
var import_promises66 = require("fs/promises");
|
|
68040
67976
|
var import_node_http4 = require("http");
|
|
68041
67977
|
var import_node_path68 = require("path");
|
|
68042
67978
|
|
|
@@ -68695,7 +68631,7 @@ async function serveLocalApi(deps) {
|
|
|
68695
68631
|
await watchedStatus[Symbol.asyncDispose]();
|
|
68696
68632
|
const current = await readJsonFile(discoveryPath, localApiDiscoverySchema);
|
|
68697
68633
|
if (current.kind === "ok" && current.value.token === token) {
|
|
68698
|
-
await (0,
|
|
68634
|
+
await (0, import_promises66.rm)(discoveryPath, { force: true });
|
|
68699
68635
|
}
|
|
68700
68636
|
await closeServer(server);
|
|
68701
68637
|
log.info("local_api.closed", {});
|
|
@@ -72448,7 +72384,7 @@ function refusalFailure(refusal2) {
|
|
|
72448
72384
|
}
|
|
72449
72385
|
|
|
72450
72386
|
// src/link/probe.ts
|
|
72451
|
-
var
|
|
72387
|
+
var import_promises67 = require("dns/promises");
|
|
72452
72388
|
var import_node_net5 = require("net");
|
|
72453
72389
|
var import_node_tls2 = require("tls");
|
|
72454
72390
|
var PROBE_TIMEOUT_MS4 = 5e3;
|
|
@@ -72484,7 +72420,7 @@ async function connectOnce(url3, clock) {
|
|
|
72484
72420
|
}
|
|
72485
72421
|
async function probeEndpoint(url3, clock) {
|
|
72486
72422
|
try {
|
|
72487
|
-
await (0,
|
|
72423
|
+
await (0, import_promises67.lookup)(url3.hostname);
|
|
72488
72424
|
} catch (error61) {
|
|
72489
72425
|
const reason = classifyTransportFailure(error61);
|
|
72490
72426
|
return reason === "other" ? "dns" : reason;
|
|
@@ -72920,7 +72856,7 @@ function createReconciler(host, lifecycle, log, signal) {
|
|
|
72920
72856
|
}
|
|
72921
72857
|
|
|
72922
72858
|
// src/uploader/index.ts
|
|
72923
|
-
var
|
|
72859
|
+
var import_promises68 = require("fs/promises");
|
|
72924
72860
|
init_runtime_v2();
|
|
72925
72861
|
init_zod();
|
|
72926
72862
|
var RETRY_DELAYS_MS = [250, 500, 1e3, 2e3, 5e3, 1e4, 3e4];
|
|
@@ -73061,7 +72997,7 @@ function startUploader({ api, runsDir, clock, log }) {
|
|
|
73061
72997
|
active.set(runId, task);
|
|
73062
72998
|
};
|
|
73063
72999
|
const sweep2 = async () => {
|
|
73064
|
-
for (const name of await (0,
|
|
73000
|
+
for (const name of await (0, import_promises68.readdir)(runsDir).catch(() => [])) {
|
|
73065
73001
|
const runId = runIdSchema.safeParse(name);
|
|
73066
73002
|
if (runId.success) run2(runId.data);
|
|
73067
73003
|
}
|
|
@@ -73071,18 +73007,18 @@ function startUploader({ api, runsDir, clock, log }) {
|
|
|
73071
73007
|
const dir = runDirectory(runsDir, runId);
|
|
73072
73008
|
const progress = await readJsonFile(dir.upload, uploadProgressSchema);
|
|
73073
73009
|
if (progress.kind !== "ok" || !progress.value.sealed) return false;
|
|
73074
|
-
const sealedAt = (await (0,
|
|
73010
|
+
const sealedAt = (await (0, import_promises68.stat)(dir.upload)).mtimeMs;
|
|
73075
73011
|
if (clock.now() - sealedAt < options.sealedForMs) return false;
|
|
73076
73012
|
return (await readLastRecord(dir.log))?.update.sessionUpdate === "_alan/run.ended";
|
|
73077
73013
|
};
|
|
73078
73014
|
const prune = async (options) => {
|
|
73079
73015
|
let removed = 0;
|
|
73080
|
-
for (const name of await (0,
|
|
73016
|
+
for (const name of await (0, import_promises68.readdir)(runsDir).catch(() => [])) {
|
|
73081
73017
|
const runId = runIdSchema.safeParse(name);
|
|
73082
73018
|
if (!runId.success) continue;
|
|
73083
73019
|
try {
|
|
73084
73020
|
if (!await isPrunable(runId.data, options)) continue;
|
|
73085
|
-
await (0,
|
|
73021
|
+
await (0, import_promises68.rm)(runDirectory(runsDir, runId.data).dir, { recursive: true, force: true });
|
|
73086
73022
|
removed += 1;
|
|
73087
73023
|
} catch (error61) {
|
|
73088
73024
|
log.warn("upload.prune_failed", { runId: runId.data, error: error61 });
|
|
@@ -74232,17 +74168,17 @@ async function runServiceCommand(argv, ctx = cliContext()) {
|
|
|
74232
74168
|
}
|
|
74233
74169
|
|
|
74234
74170
|
// src/cli/commands/upgrade.ts
|
|
74235
|
-
var
|
|
74171
|
+
var import_promises69 = require("fs/promises");
|
|
74236
74172
|
var import_node_path72 = require("path");
|
|
74237
74173
|
function isNotNewer(version2, installed) {
|
|
74238
74174
|
return installed !== null && isReleaseVersion(version2) && isReleaseVersion(installed) && compareVersions(version2, installed) <= 0;
|
|
74239
74175
|
}
|
|
74240
74176
|
async function installFromSource(source) {
|
|
74241
74177
|
const { layout, from, ifNewer } = source;
|
|
74242
|
-
const isTarball = (await (0,
|
|
74178
|
+
const isTarball = (await (0, import_promises69.stat)(from)).isFile();
|
|
74243
74179
|
const downloads = (0, import_node_path72.join)(layout.root, ".downloads");
|
|
74244
|
-
if (isTarball) await (0,
|
|
74245
|
-
const scratch = isTarball ? await (0,
|
|
74180
|
+
if (isTarball) await (0, import_promises69.mkdir)(downloads, { recursive: true, mode: 448 });
|
|
74181
|
+
const scratch = isTarball ? await (0, import_promises69.mkdtemp)((0, import_node_path72.join)(downloads, "upgrade-")) : null;
|
|
74246
74182
|
try {
|
|
74247
74183
|
const sourceDir = scratch === null ? from : await extractPackageTarball(from, scratch);
|
|
74248
74184
|
const version2 = await readPackageVersion(sourceDir);
|
|
@@ -74250,7 +74186,7 @@ async function installFromSource(source) {
|
|
|
74250
74186
|
if (ifNewer && isNotNewer(version2, installed)) return { kind: "skipped", version: version2, installed };
|
|
74251
74187
|
return { kind: "installed", ...await installVersion(layout, sourceDir) };
|
|
74252
74188
|
} finally {
|
|
74253
|
-
if (scratch !== null) await (0,
|
|
74189
|
+
if (scratch !== null) await (0, import_promises69.rm)(scratch, { recursive: true, force: true });
|
|
74254
74190
|
}
|
|
74255
74191
|
}
|
|
74256
74192
|
async function runUpgrade(argv) {
|