@alan-ai-hq/agent-manager 0.1.125 → 0.1.127
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/dist/index.cjs +254 -174
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -35445,7 +35445,7 @@ function buildComputerReadiness(input2) {
|
|
|
35445
35445
|
}
|
|
35446
35446
|
|
|
35447
35447
|
// src/version.ts
|
|
35448
|
-
var AGENT_VERSION = "0.1.
|
|
35448
|
+
var AGENT_VERSION = "0.1.127";
|
|
35449
35449
|
|
|
35450
35450
|
// src/daemon/status.ts
|
|
35451
35451
|
var PENDING_RUN_START_TTL_MS = 10 * 6e4;
|
|
@@ -36769,7 +36769,7 @@ async function runHookCommand(args, overrides2 = {}) {
|
|
|
36769
36769
|
}
|
|
36770
36770
|
|
|
36771
36771
|
// src/cli/install.ts
|
|
36772
|
-
var
|
|
36772
|
+
var import_promises17 = require("timers/promises");
|
|
36773
36773
|
|
|
36774
36774
|
// src/sleep-inhibitor.ts
|
|
36775
36775
|
var import_node_child_process4 = require("child_process");
|
|
@@ -43669,31 +43669,34 @@ function isAlanDefaultWorkspace(value2) {
|
|
|
43669
43669
|
|
|
43670
43670
|
// ../agent-core/dist/index.js
|
|
43671
43671
|
var import_crypto7 = require("crypto");
|
|
43672
|
-
var
|
|
43672
|
+
var import_promises5 = require("fs/promises");
|
|
43673
43673
|
var import_os6 = require("os");
|
|
43674
43674
|
var import_path13 = require("path");
|
|
43675
|
-
var
|
|
43675
|
+
var import_fs13 = require("fs");
|
|
43676
|
+
var import_os7 = require("os");
|
|
43676
43677
|
var import_path14 = require("path");
|
|
43677
|
-
var
|
|
43678
|
+
var import_promises6 = require("timers/promises");
|
|
43678
43679
|
var import_path15 = require("path");
|
|
43679
|
-
var
|
|
43680
|
-
var import_os7 = require("os");
|
|
43680
|
+
var import_fs14 = require("fs");
|
|
43681
43681
|
var import_path16 = require("path");
|
|
43682
|
-
var
|
|
43683
|
-
var import_fs16 = require("fs");
|
|
43682
|
+
var import_fs15 = require("fs");
|
|
43684
43683
|
var import_os8 = require("os");
|
|
43685
43684
|
var import_path17 = require("path");
|
|
43686
|
-
var
|
|
43685
|
+
var import_crypto8 = require("crypto");
|
|
43686
|
+
var import_fs16 = require("fs");
|
|
43687
43687
|
var import_os9 = require("os");
|
|
43688
43688
|
var import_path18 = require("path");
|
|
43689
|
-
var
|
|
43690
|
-
var import_fs18 = require("fs");
|
|
43689
|
+
var import_fs17 = require("fs");
|
|
43691
43690
|
var import_os10 = require("os");
|
|
43692
43691
|
var import_path19 = require("path");
|
|
43693
|
-
var
|
|
43694
|
-
var
|
|
43692
|
+
var import_crypto9 = require("crypto");
|
|
43693
|
+
var import_fs18 = require("fs");
|
|
43695
43694
|
var import_os11 = require("os");
|
|
43696
43695
|
var import_path20 = require("path");
|
|
43696
|
+
var import_child_process8 = require("child_process");
|
|
43697
|
+
var import_fs19 = require("fs");
|
|
43698
|
+
var import_os12 = require("os");
|
|
43699
|
+
var import_path21 = require("path");
|
|
43697
43700
|
function createGrammarState() {
|
|
43698
43701
|
return { seenToolCallIds: /* @__PURE__ */ new Set(), counter: 0, scratch: {} };
|
|
43699
43702
|
}
|
|
@@ -45570,7 +45573,9 @@ function spawnWindowsJob(file2, args, options) {
|
|
|
45570
45573
|
}
|
|
45571
45574
|
}
|
|
45572
45575
|
if (useShell && commandArgs.some((arg) => /[\r\n]/.test(arg))) {
|
|
45573
|
-
throw new Error(
|
|
45576
|
+
throw new Error(
|
|
45577
|
+
`Multiline provider arguments require a native executable or a Node CLI shim, but ${commandFile} runs through cmd.exe. Point Alan at the provider's .exe (for Claude Code, set ALAN_CLAUDE_PATH) and restart Alan.`
|
|
45578
|
+
);
|
|
45574
45579
|
}
|
|
45575
45580
|
const meta22 = /([()\][%!^"`<>&|;, *?])/g;
|
|
45576
45581
|
const escapeCmd = (value2) => value2.replace(meta22, "^$1");
|
|
@@ -48816,6 +48821,12 @@ function alanCodeEngineDirectories(root) {
|
|
|
48816
48821
|
function defaultEngineRoot(env) {
|
|
48817
48822
|
return (0, import_path10.join)(env.HOME?.trim() || (0, import_os4.homedir)(), ".alan", "alan-code", "engine");
|
|
48818
48823
|
}
|
|
48824
|
+
var ALAN_CODE_TOOL_NAMING_PROMPT = `## Alan tool names
|
|
48825
|
+
|
|
48826
|
+
This engine exposes Alan MCP tools with an \`alan_\` prefix. Where these instructions name an Alan tool, call its prefixed form: \`search_context\` is \`alan_search_context\`, \`search_code_context\` is \`alan_search_code_context\`, and \`find_records\` is \`alan_find_records\`.`;
|
|
48827
|
+
function buildAlanCodeSystemPrompt(alanSystemPrompt) {
|
|
48828
|
+
return [ALAN_CODE_BASELINE_PROMPT, ALAN_CODE_TOOL_NAMING_PROMPT, alanSystemPrompt?.trim()].filter((part) => Boolean(part)).join("\n\n");
|
|
48829
|
+
}
|
|
48819
48830
|
async function withAlanCodeEngine(context, dependencies = {}) {
|
|
48820
48831
|
const registration = context.config.alanMcp;
|
|
48821
48832
|
if (!registration) {
|
|
@@ -48826,10 +48837,11 @@ async function withAlanCodeEngine(context, dependencies = {}) {
|
|
|
48826
48837
|
const apiOrigin = new URL(registration.url).origin;
|
|
48827
48838
|
const models = await loadAlanCodeModels(apiOrigin, registration, dependencies.fetchCatalog);
|
|
48828
48839
|
const modelId = resolveAlanCodeModelId(context.config.selectedModel, models);
|
|
48840
|
+
const { systemPrompt, systemPromptAppend: _append, ...config4 } = context.config;
|
|
48829
48841
|
return {
|
|
48830
48842
|
...context,
|
|
48831
48843
|
config: {
|
|
48832
|
-
...
|
|
48844
|
+
...config4,
|
|
48833
48845
|
selectedModel: `${ALAN_CODE_ENGINE_PROVIDER_ID}/${modelId}`
|
|
48834
48846
|
},
|
|
48835
48847
|
env: {
|
|
@@ -48841,7 +48853,8 @@ async function withAlanCodeEngine(context, dependencies = {}) {
|
|
|
48841
48853
|
baseURL: `${apiOrigin}${ALAN_CODE_PROXY_PATH}`,
|
|
48842
48854
|
modelId,
|
|
48843
48855
|
models,
|
|
48844
|
-
pluginUrl: materializeEnginePlugin(dependencies.pluginDirectory, apiOrigin)
|
|
48856
|
+
pluginUrl: materializeEnginePlugin(dependencies.pluginDirectory, apiOrigin),
|
|
48857
|
+
prompt: buildAlanCodeSystemPrompt(systemPrompt)
|
|
48845
48858
|
})
|
|
48846
48859
|
}
|
|
48847
48860
|
};
|
|
@@ -51039,8 +51052,8 @@ var disallowedTools = (input2) => {
|
|
|
51039
51052
|
const tools = getClaudeDisallowedTools(config22(input2));
|
|
51040
51053
|
return tools.length > 0 ? tools.join(",") : void 0;
|
|
51041
51054
|
};
|
|
51042
|
-
var
|
|
51043
|
-
var
|
|
51055
|
+
var systemPromptFile = (input2) => input2.promptFiles.system;
|
|
51056
|
+
var appendSystemPromptFile = (input2) => input2.promptFiles.append;
|
|
51044
51057
|
var hasMcpGrant = (input2) => Boolean(config22(input2).alanMcp);
|
|
51045
51058
|
var baseModel = (input2) => collapseModelIdToBase(trimmedOrUndefined(config22(input2).selectedModel) ?? "");
|
|
51046
51059
|
var modelArg = (input2) => {
|
|
@@ -51066,8 +51079,8 @@ var CLAUDE_FLAGS = [
|
|
|
51066
51079
|
{ build: option("--permission-mode", permissionMode) },
|
|
51067
51080
|
{ build: spreadArgs(managedMcpArgs) },
|
|
51068
51081
|
{ build: option("--disallowedTools", disallowedTools) },
|
|
51069
|
-
{ build: option("--system-prompt",
|
|
51070
|
-
{ build: option("--append-system-prompt",
|
|
51082
|
+
{ build: option("--system-prompt-file", systemPromptFile) },
|
|
51083
|
+
{ build: option("--append-system-prompt-file", appendSystemPromptFile) },
|
|
51071
51084
|
{ requires: "supportsApproveMcps", build: flag("--approve-mcps", hasMcpGrant) },
|
|
51072
51085
|
{ build: option("--model", modelArg) },
|
|
51073
51086
|
{ build: option("--effort", effort) },
|
|
@@ -51607,6 +51620,30 @@ function latchApiError(event, state) {
|
|
|
51607
51620
|
function numberOf(value2) {
|
|
51608
51621
|
return typeof value2 === "number" && Number.isFinite(value2) ? value2 : 0;
|
|
51609
51622
|
}
|
|
51623
|
+
var NO_PROMPT_FILES = { paths: {}, dispose: async () => {
|
|
51624
|
+
} };
|
|
51625
|
+
async function writeClaudePromptFiles(context, resume) {
|
|
51626
|
+
const system = resume.resumeId ? void 0 : trimmedOrUndefined(context.config.systemPrompt);
|
|
51627
|
+
const append = resume.resumeId ? trimmedOrUndefined(context.config.systemPromptAppend) : void 0;
|
|
51628
|
+
if (!system && !append) return NO_PROMPT_FILES;
|
|
51629
|
+
const directory = await (0, import_promises5.mkdtemp)((0, import_path13.join)((0, import_os6.tmpdir)(), "alan-claude-prompt-"));
|
|
51630
|
+
const dispose = () => (0, import_promises5.rm)(directory, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
|
|
51631
|
+
try {
|
|
51632
|
+
const paths = {};
|
|
51633
|
+
if (system) {
|
|
51634
|
+
paths.system = (0, import_path13.join)(directory, "system-prompt.md");
|
|
51635
|
+
await (0, import_promises5.writeFile)(paths.system, system, "utf8");
|
|
51636
|
+
}
|
|
51637
|
+
if (append) {
|
|
51638
|
+
paths.append = (0, import_path13.join)(directory, "append-system-prompt.md");
|
|
51639
|
+
await (0, import_promises5.writeFile)(paths.append, append, "utf8");
|
|
51640
|
+
}
|
|
51641
|
+
return { paths, dispose };
|
|
51642
|
+
} catch (error61) {
|
|
51643
|
+
await dispose();
|
|
51644
|
+
throw error61;
|
|
51645
|
+
}
|
|
51646
|
+
}
|
|
51610
51647
|
function planClaudeResume(context) {
|
|
51611
51648
|
const requestedResumeId = context.config.runtimeSessionId?.trim() || context.config.providerSessionId?.trim();
|
|
51612
51649
|
if (!requestedResumeId) return {};
|
|
@@ -51661,29 +51698,35 @@ function createClaudeCliBackend(command = "claude", defaultArgs = []) {
|
|
|
51661
51698
|
needsApproveMcps: Boolean(context.config.alanMcp)
|
|
51662
51699
|
});
|
|
51663
51700
|
const resume = planClaudeResume(context);
|
|
51664
|
-
const
|
|
51665
|
-
|
|
51666
|
-
|
|
51667
|
-
|
|
51668
|
-
|
|
51669
|
-
|
|
51670
|
-
|
|
51671
|
-
|
|
51672
|
-
|
|
51673
|
-
|
|
51674
|
-
|
|
51675
|
-
|
|
51676
|
-
|
|
51677
|
-
|
|
51678
|
-
|
|
51679
|
-
|
|
51680
|
-
|
|
51681
|
-
|
|
51701
|
+
const promptFiles = await writeClaudePromptFiles(context, resume);
|
|
51702
|
+
try {
|
|
51703
|
+
const args = buildClaudeCliArgs(
|
|
51704
|
+
{
|
|
51705
|
+
context,
|
|
51706
|
+
capabilities,
|
|
51707
|
+
resume,
|
|
51708
|
+
managedRegistration,
|
|
51709
|
+
externalServers: externalMcp?.servers,
|
|
51710
|
+
promptFiles: promptFiles.paths
|
|
51711
|
+
},
|
|
51712
|
+
defaultArgs
|
|
51713
|
+
);
|
|
51714
|
+
return await createCliBackend({
|
|
51715
|
+
kind: "claude_cli",
|
|
51716
|
+
supportTier: "structured",
|
|
51717
|
+
command,
|
|
51718
|
+
args,
|
|
51719
|
+
parseStructuredLine: grammarAsStructuredLineParser(claudeGrammar, claudeEffects),
|
|
51720
|
+
stdinWriter: (stdin, ctx) => {
|
|
51721
|
+
stdin.write(`${buildClaudeUserMessage(ctx, resume)}
|
|
51682
51722
|
`);
|
|
51683
|
-
|
|
51684
|
-
|
|
51685
|
-
|
|
51686
|
-
|
|
51723
|
+
},
|
|
51724
|
+
keepStdinOpen: true,
|
|
51725
|
+
stopBackgroundTask: (task, ctx, state) => requestClaudeTaskStop(task, ctx, state)
|
|
51726
|
+
}).run(runContext);
|
|
51727
|
+
} finally {
|
|
51728
|
+
await promptFiles.dispose();
|
|
51729
|
+
}
|
|
51687
51730
|
}
|
|
51688
51731
|
};
|
|
51689
51732
|
}
|
|
@@ -51791,7 +51834,7 @@ function foldImageGenerationLine(entryType, payload, fold) {
|
|
|
51791
51834
|
id: item.id,
|
|
51792
51835
|
call_id: toolCallId,
|
|
51793
51836
|
result: item.result,
|
|
51794
|
-
filename: savedPath && (0,
|
|
51837
|
+
filename: savedPath && (0, import_path15.basename)(savedPath)
|
|
51795
51838
|
},
|
|
51796
51839
|
{ dataFields: ["result"], toolIdFields: ["call_id"], idFields: ["id"] }
|
|
51797
51840
|
) : null;
|
|
@@ -51817,18 +51860,18 @@ function takeImageGenerationUpdates(fold) {
|
|
|
51817
51860
|
var DAY_MS = 24 * 60 * 60 * 1e3;
|
|
51818
51861
|
var MAX_HEADER_BYTES = 1024 * 1024;
|
|
51819
51862
|
function workerDirectories(rootLog) {
|
|
51820
|
-
const directory = (0,
|
|
51821
|
-
const monthDirectory = (0,
|
|
51822
|
-
const yearDirectory = (0,
|
|
51823
|
-
const date5 = `${(0,
|
|
51863
|
+
const directory = (0, import_path16.dirname)(rootLog);
|
|
51864
|
+
const monthDirectory = (0, import_path16.dirname)(directory);
|
|
51865
|
+
const yearDirectory = (0, import_path16.dirname)(monthDirectory);
|
|
51866
|
+
const date5 = `${(0, import_path16.basename)(yearDirectory)}-${(0, import_path16.basename)(monthDirectory)}-${(0, import_path16.basename)(directory)}`;
|
|
51824
51867
|
if (!/^\d{4}-\d{2}-\d{2}$/.test(date5)) return [directory];
|
|
51825
51868
|
const timestamp = Date.parse(`${date5}T00:00:00Z`);
|
|
51826
51869
|
if (!Number.isFinite(timestamp) || new Date(timestamp).toISOString().slice(0, 10) !== date5)
|
|
51827
51870
|
return [directory];
|
|
51828
|
-
const sessionsDirectory2 = (0,
|
|
51871
|
+
const sessionsDirectory2 = (0, import_path16.dirname)(yearDirectory);
|
|
51829
51872
|
return [0, 1, -1].map((offset2) => {
|
|
51830
51873
|
const day = new Date(timestamp + offset2 * DAY_MS).toISOString().slice(0, 10);
|
|
51831
|
-
return (0,
|
|
51874
|
+
return (0, import_path16.join)(sessionsDirectory2, ...day.split("-"));
|
|
51832
51875
|
});
|
|
51833
51876
|
}
|
|
51834
51877
|
function firstLine(path2) {
|
|
@@ -51865,7 +51908,7 @@ function findCodexWorkerLogs(rootLog, parentThreadId) {
|
|
|
51865
51908
|
}
|
|
51866
51909
|
for (const entry of entries) {
|
|
51867
51910
|
if (!entry.isFile() || !entry.name.endsWith(".jsonl")) continue;
|
|
51868
|
-
const path2 = (0,
|
|
51911
|
+
const path2 = (0, import_path16.join)(directory, entry.name);
|
|
51869
51912
|
if (path2 === rootLog) continue;
|
|
51870
51913
|
try {
|
|
51871
51914
|
const line = firstLine(path2);
|
|
@@ -51893,7 +51936,7 @@ function findCodexWorkerLogs(rootLog, parentThreadId) {
|
|
|
51893
51936
|
return workers;
|
|
51894
51937
|
}
|
|
51895
51938
|
function resolveCodexHome(env) {
|
|
51896
|
-
return env.CODEX_HOME || process.env.CODEX_HOME || (0,
|
|
51939
|
+
return env.CODEX_HOME || process.env.CODEX_HOME || (0, import_path14.join)((0, import_os7.homedir)(), ".codex");
|
|
51897
51940
|
}
|
|
51898
51941
|
function mtimeOf(path2) {
|
|
51899
51942
|
try {
|
|
@@ -51907,11 +51950,11 @@ function newestMatchIn(dir, entries, sessionId) {
|
|
|
51907
51950
|
(entry) => entry.isFile() && entry.name.endsWith(".jsonl") && entry.name.includes(sessionId)
|
|
51908
51951
|
);
|
|
51909
51952
|
if (matches.length === 0) return null;
|
|
51910
|
-
if (matches.length === 1) return (0,
|
|
51953
|
+
if (matches.length === 1) return (0, import_path14.join)(dir, matches[0].name);
|
|
51911
51954
|
let best = "";
|
|
51912
51955
|
let bestMtime = -1;
|
|
51913
51956
|
for (const entry of matches) {
|
|
51914
|
-
const path2 = (0,
|
|
51957
|
+
const path2 = (0, import_path14.join)(dir, entry.name);
|
|
51915
51958
|
const mtime = mtimeOf(path2);
|
|
51916
51959
|
if (mtime > bestMtime) {
|
|
51917
51960
|
best = path2;
|
|
@@ -51922,7 +51965,7 @@ function newestMatchIn(dir, entries, sessionId) {
|
|
|
51922
51965
|
}
|
|
51923
51966
|
function findCodexSessionLog(runtimeSessionId, codexHome) {
|
|
51924
51967
|
if (!runtimeSessionId) return null;
|
|
51925
|
-
const stack = [(0,
|
|
51968
|
+
const stack = [(0, import_path14.join)(codexHome, "sessions")];
|
|
51926
51969
|
while (stack.length > 0) {
|
|
51927
51970
|
const dir = stack.pop();
|
|
51928
51971
|
let entries;
|
|
@@ -51935,7 +51978,7 @@ function findCodexSessionLog(runtimeSessionId, codexHome) {
|
|
|
51935
51978
|
if (match) return match;
|
|
51936
51979
|
const subdirs = entries.filter((entry) => entry.isDirectory()).map((entry) => entry.name);
|
|
51937
51980
|
subdirs.sort();
|
|
51938
|
-
for (const name of subdirs) stack.push((0,
|
|
51981
|
+
for (const name of subdirs) stack.push((0, import_path14.join)(dir, name));
|
|
51939
51982
|
}
|
|
51940
51983
|
return null;
|
|
51941
51984
|
}
|
|
@@ -52371,7 +52414,7 @@ async function flushCodexImageGenerationOnExit(context, state) {
|
|
|
52371
52414
|
const updates = takeImageGenerationUpdates(fold);
|
|
52372
52415
|
if (updates.length === 0) break;
|
|
52373
52416
|
for (const update of updates) emitSessionUpdate(update, context, state);
|
|
52374
|
-
if (fold.updates.length > 0) await (0,
|
|
52417
|
+
if (fold.updates.length > 0) await (0, import_promises6.setTimeout)(EXIT_IMAGE_SPACING_MS);
|
|
52375
52418
|
}
|
|
52376
52419
|
for (const update of settlePendingImageGenerations(fold))
|
|
52377
52420
|
emitSessionUpdate(update, context, state);
|
|
@@ -54661,8 +54704,8 @@ function activeTaskIdNamedIn(state, content) {
|
|
|
54661
54704
|
}
|
|
54662
54705
|
function writeCopilotMcpConfig(registration) {
|
|
54663
54706
|
if (!registration) return null;
|
|
54664
|
-
const dir = (0, import_fs15.mkdtempSync)((0,
|
|
54665
|
-
const path2 = (0,
|
|
54707
|
+
const dir = (0, import_fs15.mkdtempSync)((0, import_path17.join)((0, import_os8.tmpdir)(), "alan-copilot-mcp-"));
|
|
54708
|
+
const path2 = (0, import_path17.join)(dir, "mcp-config.json");
|
|
54666
54709
|
(0, import_fs15.writeFileSync)(
|
|
54667
54710
|
path2,
|
|
54668
54711
|
JSON.stringify({
|
|
@@ -54680,12 +54723,12 @@ function writeCopilotMcpConfig(registration) {
|
|
|
54680
54723
|
return { path: path2, cleanup: () => (0, import_fs15.rmSync)(dir, { recursive: true, force: true }) };
|
|
54681
54724
|
}
|
|
54682
54725
|
function resolveCopilotHome(env) {
|
|
54683
|
-
return env.COPILOT_HOME || (0,
|
|
54726
|
+
return env.COPILOT_HOME || (0, import_path18.join)(env.HOME || (0, import_os9.homedir)(), ".copilot");
|
|
54684
54727
|
}
|
|
54685
54728
|
function copilotSessionPresence(sessionId, home) {
|
|
54686
|
-
const stateRoot = (0,
|
|
54729
|
+
const stateRoot = (0, import_path18.join)(home, "session-state");
|
|
54687
54730
|
if (!(0, import_fs16.existsSync)(stateRoot)) return "unknown";
|
|
54688
|
-
return (0, import_fs16.existsSync)((0,
|
|
54731
|
+
return (0, import_fs16.existsSync)((0, import_path18.join)(stateRoot, sessionId, "events.jsonl")) ? "present" : "missing";
|
|
54689
54732
|
}
|
|
54690
54733
|
function freshSession(contextPrefix) {
|
|
54691
54734
|
const sessionId = (0, import_crypto8.randomUUID)();
|
|
@@ -55351,11 +55394,11 @@ function cursorConversationStepText(steps) {
|
|
|
55351
55394
|
}
|
|
55352
55395
|
function cursorTranscriptsRoot(context) {
|
|
55353
55396
|
const projectKey = context.cwd.replace(/^[/\\]+/, "").replace(/[/\\]+/g, "-");
|
|
55354
|
-
const home = context.env.HOME || process.env.HOME || (0,
|
|
55355
|
-
return (0,
|
|
55397
|
+
const home = context.env.HOME || process.env.HOME || (0, import_os10.homedir)();
|
|
55398
|
+
return (0, import_path19.join)(home, ".cursor", "projects", projectKey, "agent-transcripts");
|
|
55356
55399
|
}
|
|
55357
55400
|
function cursorTranscriptPathForAgent(context, agentId) {
|
|
55358
|
-
return (0,
|
|
55401
|
+
return (0, import_path19.join)(cursorTranscriptsRoot(context), agentId, `${agentId}.jsonl`);
|
|
55359
55402
|
}
|
|
55360
55403
|
function resolveCursorSubagentTranscriptPath(success2, context) {
|
|
55361
55404
|
const explicit = success2?.transcriptPath ?? success2?.transcript_path;
|
|
@@ -55725,10 +55768,10 @@ function workspaceKeys(cwd) {
|
|
|
55725
55768
|
);
|
|
55726
55769
|
}
|
|
55727
55770
|
function cursorChatPresence(query) {
|
|
55728
|
-
const chatsRoot = (0,
|
|
55771
|
+
const chatsRoot = (0, import_path20.join)(query.home, ".cursor", "chats");
|
|
55729
55772
|
if (!(0, import_fs18.existsSync)(chatsRoot)) return "unknown";
|
|
55730
55773
|
const found = workspaceKeys(query.cwd).some(
|
|
55731
|
-
(key) => (0, import_fs18.existsSync)((0,
|
|
55774
|
+
(key) => (0, import_fs18.existsSync)((0, import_path20.join)(chatsRoot, key, query.chatId, "store.db"))
|
|
55732
55775
|
);
|
|
55733
55776
|
return found ? "present" : "missing";
|
|
55734
55777
|
}
|
|
@@ -55738,7 +55781,7 @@ function planCursorResume(context) {
|
|
|
55738
55781
|
const presence = cursorChatPresence({
|
|
55739
55782
|
chatId: requestedResumeId,
|
|
55740
55783
|
cwd: context.cwd,
|
|
55741
|
-
home: context.env.HOME || (0,
|
|
55784
|
+
home: context.env.HOME || (0, import_os11.homedir)()
|
|
55742
55785
|
});
|
|
55743
55786
|
if (presence !== "missing") return { resumeId: requestedResumeId };
|
|
55744
55787
|
const contextPrefix = context.config.resumeFallbackContext?.trim() || void 0;
|
|
@@ -57741,8 +57784,8 @@ function createKimiCliBackend(command = "kimi", defaultArgs = []) {
|
|
|
57741
57784
|
async run(context) {
|
|
57742
57785
|
const dialect = await detectKimiCliDialect(command, context);
|
|
57743
57786
|
const registration = dialect === "kimi-cli" ? context.config.alanMcp : void 0;
|
|
57744
|
-
const mcpDirectory = registration ? (0, import_fs19.mkdtempSync)((0,
|
|
57745
|
-
const mcpConfigPath = mcpDirectory ? (0,
|
|
57787
|
+
const mcpDirectory = registration ? (0, import_fs19.mkdtempSync)((0, import_path21.join)((0, import_os12.tmpdir)(), "alan-kimi-mcp-")) : null;
|
|
57788
|
+
const mcpConfigPath = mcpDirectory ? (0, import_path21.join)(mcpDirectory, "mcp.json") : null;
|
|
57746
57789
|
if (registration && mcpConfigPath) {
|
|
57747
57790
|
(0, import_fs19.writeFileSync)(
|
|
57748
57791
|
mcpConfigPath,
|
|
@@ -58054,6 +58097,23 @@ var AgentRunner = class {
|
|
|
58054
58097
|
content: [{ type: "text", text: text2 }]
|
|
58055
58098
|
});
|
|
58056
58099
|
}
|
|
58100
|
+
/**
|
|
58101
|
+
* Memory the API retrieved before the provider started, recorded as the
|
|
58102
|
+
* `search_context` call it stands in for so the transcript shows what the agent was given.
|
|
58103
|
+
*/
|
|
58104
|
+
recordRelevantContext(recall) {
|
|
58105
|
+
if (!recall) return;
|
|
58106
|
+
this.emit({
|
|
58107
|
+
sessionUpdate: "tool_call_update",
|
|
58108
|
+
toolCallId: `relevant-context-${(0, import_crypto.randomUUID)()}`,
|
|
58109
|
+
name: "search_context",
|
|
58110
|
+
kind: "search",
|
|
58111
|
+
status: "completed",
|
|
58112
|
+
rawInput: { query: recall.query },
|
|
58113
|
+
rawOutput: JSON.stringify(recall.envelope),
|
|
58114
|
+
_meta: { "alan.dev/contextRecall": "prefetch" }
|
|
58115
|
+
});
|
|
58116
|
+
}
|
|
58057
58117
|
log(message) {
|
|
58058
58118
|
this.emit({ sessionUpdate: "_alan/log", source: "agent", message });
|
|
58059
58119
|
}
|
|
@@ -58353,6 +58413,7 @@ ${runtimeConfig.task}` } : {}
|
|
|
58353
58413
|
};
|
|
58354
58414
|
this.host.onStart?.(initialConfig);
|
|
58355
58415
|
this.recordUserMessage(config4.task);
|
|
58416
|
+
this.recordRelevantContext(config4.relevantContext);
|
|
58356
58417
|
this.emit({ sessionUpdate: "state_update", state: "running" });
|
|
58357
58418
|
let safeProjectPath = initialConfig.teamPath;
|
|
58358
58419
|
if (initialConfig.teamPath) {
|
|
@@ -63926,11 +63987,11 @@ function removeNativeHooks(homeDir = (0, import_node_os14.homedir)()) {
|
|
|
63926
63987
|
}
|
|
63927
63988
|
|
|
63928
63989
|
// src/events/runtime-command-reply.ts
|
|
63929
|
-
var
|
|
63990
|
+
var import_promises7 = require("timers/promises");
|
|
63930
63991
|
async function publishRuntimeCommandReply(path2, reply, credentials) {
|
|
63931
63992
|
const body = JSON.stringify(reply);
|
|
63932
63993
|
for (let attempt = 0; attempt < 2; attempt += 1) {
|
|
63933
|
-
if (attempt > 0) await (0,
|
|
63994
|
+
if (attempt > 0) await (0, import_promises7.setTimeout)(250, void 0, { signal: credentials.signal });
|
|
63934
63995
|
credentials.signal.throwIfAborted();
|
|
63935
63996
|
let response;
|
|
63936
63997
|
try {
|
|
@@ -63967,7 +64028,7 @@ var import_node_fs19 = require("fs");
|
|
|
63967
64028
|
// src/events/live.ts
|
|
63968
64029
|
var import_node_crypto9 = require("crypto");
|
|
63969
64030
|
var import_node_fs17 = require("fs");
|
|
63970
|
-
var
|
|
64031
|
+
var import_promises10 = require("fs/promises");
|
|
63971
64032
|
|
|
63972
64033
|
// src/events/http-retry.ts
|
|
63973
64034
|
var TranscriptRequestError = class extends Error {
|
|
@@ -64028,7 +64089,7 @@ function requestDeadline(timeoutMs, parent) {
|
|
|
64028
64089
|
// src/events/push.ts
|
|
64029
64090
|
var import_node_crypto8 = require("crypto");
|
|
64030
64091
|
var import_node_fs16 = require("fs");
|
|
64031
|
-
var
|
|
64092
|
+
var import_promises9 = require("fs/promises");
|
|
64032
64093
|
|
|
64033
64094
|
// src/events/session.ts
|
|
64034
64095
|
var import_node_fs15 = require("fs");
|
|
@@ -64237,7 +64298,7 @@ function writeRunTranscriptState(configPath, conversationId, runId, state) {
|
|
|
64237
64298
|
}
|
|
64238
64299
|
|
|
64239
64300
|
// src/events/transcript-buffer.ts
|
|
64240
|
-
var
|
|
64301
|
+
var import_promises8 = require("fs/promises");
|
|
64241
64302
|
var RETAINED_BYTES = 256 * 1024;
|
|
64242
64303
|
var MAX_PENDING_TRANSCRIPT_BYTES = 8 * 1024 * 1024;
|
|
64243
64304
|
var TranscriptBuffer = class {
|
|
@@ -64297,7 +64358,7 @@ function closeTranscriptBuffer(path2, buffer) {
|
|
|
64297
64358
|
async function retryTranscriptWrites(path2, runId) {
|
|
64298
64359
|
const buffer = active.get(path2);
|
|
64299
64360
|
if (!buffer || buffer.runId !== runId) return void 0;
|
|
64300
|
-
const file2 = await (0,
|
|
64361
|
+
const file2 = await (0, import_promises8.open)(path2, "r+");
|
|
64301
64362
|
try {
|
|
64302
64363
|
const stat4 = await file2.stat();
|
|
64303
64364
|
if (`${stat4.dev}.${stat4.ino}.${stat4.birthtimeMs}` !== buffer.generation)
|
|
@@ -64697,7 +64758,7 @@ function startTranscriptPush(target, onProblem) {
|
|
|
64697
64758
|
const current = state();
|
|
64698
64759
|
if (!current) throw new Error("Transcript run range disappeared");
|
|
64699
64760
|
const end = Math.min(boundary, admitted + adaptivePushBytes);
|
|
64700
|
-
const file2 = await (0,
|
|
64761
|
+
const file2 = await (0, import_promises9.open)(path2, "r");
|
|
64701
64762
|
let bytes;
|
|
64702
64763
|
try {
|
|
64703
64764
|
bytes = Buffer.alloc(end - admitted);
|
|
@@ -64940,7 +65001,7 @@ function startTranscriptLive(target, onProblem) {
|
|
|
64940
65001
|
if (active2 && from < active2.retainedFrom)
|
|
64941
65002
|
length = Math.min(length, active2.retainedFrom - from);
|
|
64942
65003
|
bytes = Buffer.alloc(length);
|
|
64943
|
-
const file2 = await (0,
|
|
65004
|
+
const file2 = await (0, import_promises10.open)(path2, "r");
|
|
64944
65005
|
try {
|
|
64945
65006
|
const read = await file2.read(bytes, 0, length, from);
|
|
64946
65007
|
if (read.bytesRead !== length) throw new Error("Live transcript changed during read");
|
|
@@ -65488,7 +65549,7 @@ function createTranscriptWatchRegistry() {
|
|
|
65488
65549
|
|
|
65489
65550
|
// src/native/ingest.ts
|
|
65490
65551
|
var import_node_fs21 = require("fs");
|
|
65491
|
-
var
|
|
65552
|
+
var import_promises12 = require("fs/promises");
|
|
65492
65553
|
|
|
65493
65554
|
// src/native/alan-runs.ts
|
|
65494
65555
|
function nativeProviderForBackend(backendKind) {
|
|
@@ -65827,7 +65888,7 @@ function reconcileTranscriptIdentity(entry, transcriptPath2, identity, size) {
|
|
|
65827
65888
|
|
|
65828
65889
|
// src/native/turns.ts
|
|
65829
65890
|
var import_node_crypto11 = require("crypto");
|
|
65830
|
-
var
|
|
65891
|
+
var import_promises11 = require("fs/promises");
|
|
65831
65892
|
var SCAN_BYTES = 1024 * 1024;
|
|
65832
65893
|
var MIN_READ_BYTES = 64 * 1024;
|
|
65833
65894
|
var SKIPPED_RECORD_LINE = Buffer.from("\n");
|
|
@@ -65874,7 +65935,7 @@ async function findRecordEnd(handle, from, size) {
|
|
|
65874
65935
|
return null;
|
|
65875
65936
|
}
|
|
65876
65937
|
async function readTranscriptWindow(path2, offset2, limits) {
|
|
65877
|
-
const handle = await (0,
|
|
65938
|
+
const handle = await (0, import_promises11.open)(path2, "r");
|
|
65878
65939
|
try {
|
|
65879
65940
|
const stats = await handle.stat({ bigint: true });
|
|
65880
65941
|
const size = Number(stats.size);
|
|
@@ -66401,7 +66462,7 @@ function createNativeIngestionSink(deps) {
|
|
|
66401
66462
|
store.put(entry);
|
|
66402
66463
|
if (ending) log3("native-ingest-turn", worker, "closed");
|
|
66403
66464
|
}
|
|
66404
|
-
const current = await (0,
|
|
66465
|
+
const current = await (0, import_promises12.stat)(path2).catch(() => void 0);
|
|
66405
66466
|
return { grewDuringPass: current !== void 0 && current.size > lastSize };
|
|
66406
66467
|
};
|
|
66407
66468
|
const handleFailure = (worker, error61) => {
|
|
@@ -66888,12 +66949,12 @@ var RuntimeSkillCoordinator = class {
|
|
|
66888
66949
|
// src/skills/runtime-skill-manager.ts
|
|
66889
66950
|
var import_node_buffer5 = require("buffer");
|
|
66890
66951
|
var import_node_crypto14 = require("crypto");
|
|
66891
|
-
var
|
|
66952
|
+
var import_promises15 = require("fs/promises");
|
|
66892
66953
|
var import_node_path24 = require("path");
|
|
66893
66954
|
|
|
66894
66955
|
// src/skills/managed-skill-store.ts
|
|
66895
66956
|
var import_node_crypto12 = require("crypto");
|
|
66896
|
-
var
|
|
66957
|
+
var import_promises13 = require("fs/promises");
|
|
66897
66958
|
var import_node_path22 = require("path");
|
|
66898
66959
|
var EMPTY_STATE = {
|
|
66899
66960
|
version: 1,
|
|
@@ -66909,9 +66970,9 @@ var ManagedSkillStore = class _ManagedSkillStore {
|
|
|
66909
66970
|
state;
|
|
66910
66971
|
integrity;
|
|
66911
66972
|
static async open(baseDirectory) {
|
|
66912
|
-
await (0,
|
|
66973
|
+
await (0, import_promises13.mkdir)(baseDirectory, { recursive: true, mode: 448 });
|
|
66913
66974
|
try {
|
|
66914
|
-
const parsed = JSON.parse(await (0,
|
|
66975
|
+
const parsed = JSON.parse(await (0, import_promises13.readFile)((0, import_node_path22.join)(baseDirectory, "state.json"), "utf8"));
|
|
66915
66976
|
return new _ManagedSkillStore(baseDirectory, parseState(parsed), "verified");
|
|
66916
66977
|
} catch (error61) {
|
|
66917
66978
|
if (isMissingPath(error61)) {
|
|
@@ -66975,15 +67036,15 @@ var ManagedSkillStore = class _ManagedSkillStore {
|
|
|
66975
67036
|
`.state.json.pending-${process.pid}-${(0, import_node_crypto12.randomBytes)(6).toString("hex")}`
|
|
66976
67037
|
);
|
|
66977
67038
|
try {
|
|
66978
|
-
await (0,
|
|
67039
|
+
await (0, import_promises13.writeFile)(pendingPath, `${JSON.stringify(this.state, null, 2)}
|
|
66979
67040
|
`, {
|
|
66980
67041
|
encoding: "utf8",
|
|
66981
67042
|
flag: "wx",
|
|
66982
67043
|
mode: 384
|
|
66983
67044
|
});
|
|
66984
|
-
await (0,
|
|
67045
|
+
await (0, import_promises13.rename)(pendingPath, statePath);
|
|
66985
67046
|
} finally {
|
|
66986
|
-
await (0,
|
|
67047
|
+
await (0, import_promises13.rm)(pendingPath, { force: true });
|
|
66987
67048
|
}
|
|
66988
67049
|
}
|
|
66989
67050
|
};
|
|
@@ -67038,7 +67099,7 @@ function isMissingPath(error61) {
|
|
|
67038
67099
|
// ../shared/dist/node/skill-bundle.js
|
|
67039
67100
|
var import_node_buffer3 = require("buffer");
|
|
67040
67101
|
var import_node_crypto13 = require("crypto");
|
|
67041
|
-
var
|
|
67102
|
+
var import_promises14 = require("fs/promises");
|
|
67042
67103
|
var import_node_path23 = require("path");
|
|
67043
67104
|
var import_node_stream = require("stream");
|
|
67044
67105
|
var import_node_zlib = require("zlib");
|
|
@@ -67048,7 +67109,7 @@ async function createSkillBundle(packageRoot, options = {}) {
|
|
|
67048
67109
|
const archive = (0, import_tar_stream.pack)();
|
|
67049
67110
|
const tarPromise = collectStream(archive);
|
|
67050
67111
|
for (const file2 of before.files) {
|
|
67051
|
-
const bytes2 = await (0,
|
|
67112
|
+
const bytes2 = await (0, import_promises14.readFile)((0, import_node_path23.join)(packageRoot, ...file2.path.split("/")));
|
|
67052
67113
|
await addArchiveEntry(archive, {
|
|
67053
67114
|
name: file2.path,
|
|
67054
67115
|
type: "file",
|
|
@@ -67080,7 +67141,7 @@ async function extractSkillBundle(archiveBytes, destination, expected) {
|
|
|
67080
67141
|
throw new Error("Skill archive hash does not match the expected immutable Version");
|
|
67081
67142
|
}
|
|
67082
67143
|
const tarBytes = await decompressBounded(archiveBytes);
|
|
67083
|
-
await (0,
|
|
67144
|
+
await (0, import_promises14.mkdir)(destination, { recursive: false, mode: 448 });
|
|
67084
67145
|
try {
|
|
67085
67146
|
await extractTar(tarBytes, destination);
|
|
67086
67147
|
const inspected = await inspectSkillPackage(destination, { expectedName: null });
|
|
@@ -67088,7 +67149,7 @@ async function extractSkillBundle(archiveBytes, destination, expected) {
|
|
|
67088
67149
|
throw new Error("Extracted Skill package hash does not match the expected immutable Version");
|
|
67089
67150
|
}
|
|
67090
67151
|
} catch (error61) {
|
|
67091
|
-
await (0,
|
|
67152
|
+
await (0, import_promises14.rm)(destination, { recursive: true, force: true });
|
|
67092
67153
|
throw error61;
|
|
67093
67154
|
}
|
|
67094
67155
|
}
|
|
@@ -67164,8 +67225,8 @@ async function extractEntry(header, stream, destination, limits) {
|
|
|
67164
67225
|
throw new Error(`Skill archive file size is invalid: ${path2}`);
|
|
67165
67226
|
}
|
|
67166
67227
|
const outputPath = (0, import_node_path23.join)(destination, ...path2.split("/"));
|
|
67167
|
-
await (0,
|
|
67168
|
-
await (0,
|
|
67228
|
+
await (0, import_promises14.mkdir)((0, import_node_path23.dirname)(outputPath), { recursive: true, mode: 448 });
|
|
67229
|
+
await (0, import_promises14.writeFile)(outputPath, bytes, { mode: (header.mode ?? 420) & 73 ? 493 : 420 });
|
|
67169
67230
|
}
|
|
67170
67231
|
function requireSafeArchivePath(value2) {
|
|
67171
67232
|
const normalized2 = value2.replaceAll("\\", "/").normalize("NFC");
|
|
@@ -67425,12 +67486,12 @@ var RuntimeSkillManager = class _RuntimeSkillManager {
|
|
|
67425
67486
|
}
|
|
67426
67487
|
async reconcileUnlocked(manifest) {
|
|
67427
67488
|
const desired = desiredSkillManifestSchema.parse(manifest);
|
|
67428
|
-
await (0,
|
|
67429
|
-
await (0,
|
|
67489
|
+
await (0, import_promises15.mkdir)(this.managedSkillsDirectory, { recursive: true, mode: 448 });
|
|
67490
|
+
await (0, import_promises15.mkdir)((0, import_node_path24.join)(this.skillsStateDirectory, "cache", "sha256"), {
|
|
67430
67491
|
recursive: true,
|
|
67431
67492
|
mode: 448
|
|
67432
67493
|
});
|
|
67433
|
-
await (0,
|
|
67494
|
+
await (0, import_promises15.mkdir)((0, import_node_path24.join)(this.skillsStateDirectory, "tmp"), { recursive: true, mode: 448 });
|
|
67434
67495
|
const results = [];
|
|
67435
67496
|
const nextProjections = {};
|
|
67436
67497
|
for (const entry of desired.skills) {
|
|
@@ -67553,52 +67614,52 @@ var RuntimeSkillManager = class _RuntimeSkillManager {
|
|
|
67553
67614
|
let sourceMoved = false;
|
|
67554
67615
|
let destinationInstalled = false;
|
|
67555
67616
|
try {
|
|
67556
|
-
await (0,
|
|
67617
|
+
await (0, import_promises15.rename)(source2, backup);
|
|
67557
67618
|
sourceMoved = true;
|
|
67558
|
-
await (0,
|
|
67619
|
+
await (0, import_promises15.cp)(backup, pending, { recursive: true, errorOnExist: true, force: false });
|
|
67559
67620
|
const skillMarkdown = (0, import_node_path24.join)(pending, "SKILL.md");
|
|
67560
|
-
await (0,
|
|
67621
|
+
await (0, import_promises15.writeFile)(
|
|
67561
67622
|
skillMarkdown,
|
|
67562
|
-
rewriteSkillMarkdownName(await (0,
|
|
67623
|
+
rewriteSkillMarkdownName(await (0, import_promises15.readFile)(skillMarkdown, "utf8"), name),
|
|
67563
67624
|
{
|
|
67564
67625
|
encoding: "utf8",
|
|
67565
67626
|
mode: 420
|
|
67566
67627
|
}
|
|
67567
67628
|
);
|
|
67568
67629
|
await inspectSkillPackage(pending, { expectedName: name });
|
|
67569
|
-
await (0,
|
|
67630
|
+
await (0, import_promises15.rename)(pending, destination);
|
|
67570
67631
|
destinationInstalled = true;
|
|
67571
|
-
await (0,
|
|
67632
|
+
await (0, import_promises15.rm)(backup, { recursive: true, force: true });
|
|
67572
67633
|
} catch (error61) {
|
|
67573
|
-
if (destinationInstalled) await (0,
|
|
67634
|
+
if (destinationInstalled) await (0, import_promises15.rm)(destination, { recursive: true, force: true });
|
|
67574
67635
|
if (sourceMoved && await pathExists2(backup) && !await pathExists2(source2)) {
|
|
67575
|
-
await (0,
|
|
67636
|
+
await (0, import_promises15.rename)(backup, source2);
|
|
67576
67637
|
}
|
|
67577
67638
|
throw error61;
|
|
67578
67639
|
} finally {
|
|
67579
|
-
await (0,
|
|
67640
|
+
await (0, import_promises15.rm)(pending, { recursive: true, force: true });
|
|
67580
67641
|
if (!sourceMoved || destinationInstalled) {
|
|
67581
|
-
await (0,
|
|
67642
|
+
await (0, import_promises15.rm)(backup, { recursive: true, force: true });
|
|
67582
67643
|
}
|
|
67583
67644
|
}
|
|
67584
67645
|
}
|
|
67585
67646
|
async overwriteLocalConflict(input2, entry, conflict, manifest) {
|
|
67586
67647
|
const source2 = this.conflictDirectory(entry.runtimeDirectory, conflict.kind);
|
|
67587
67648
|
const backup = `${source2}.overwrite-backup-${process.pid}-${(0, import_node_crypto14.randomBytes)(8).toString("hex")}`;
|
|
67588
|
-
await (0,
|
|
67649
|
+
await (0, import_promises15.rename)(source2, backup);
|
|
67589
67650
|
try {
|
|
67590
67651
|
const reconciled = await this.reconcileUnlocked(manifest);
|
|
67591
67652
|
const result = resolutionFromReconcile(input2, reconciled);
|
|
67592
67653
|
if (result.state !== "applied") {
|
|
67593
67654
|
await this.removeResolvedProjection(entry, conflict.kind);
|
|
67594
|
-
await (0,
|
|
67655
|
+
await (0, import_promises15.rename)(backup, source2);
|
|
67595
67656
|
return result;
|
|
67596
67657
|
}
|
|
67597
|
-
await (0,
|
|
67658
|
+
await (0, import_promises15.rm)(backup, { recursive: true, force: true });
|
|
67598
67659
|
return result;
|
|
67599
67660
|
} catch (error61) {
|
|
67600
67661
|
await this.removeResolvedProjection(entry, conflict.kind).catch(() => void 0);
|
|
67601
|
-
if (!await pathExists2(source2) && await pathExists2(backup)) await (0,
|
|
67662
|
+
if (!await pathExists2(source2) && await pathExists2(backup)) await (0, import_promises15.rename)(backup, source2);
|
|
67602
67663
|
throw error61;
|
|
67603
67664
|
}
|
|
67604
67665
|
}
|
|
@@ -67608,7 +67669,7 @@ var RuntimeSkillManager = class _RuntimeSkillManager {
|
|
|
67608
67669
|
if (conflictKind === "managed_destination") {
|
|
67609
67670
|
const marker = await readMarker(destination);
|
|
67610
67671
|
if (marker?.skillId === entry.skillId && marker.versionId === entry.versionId && marker.contentHash === entry.contentHash) {
|
|
67611
|
-
await (0,
|
|
67672
|
+
await (0, import_promises15.rm)(destination, { recursive: true, force: true });
|
|
67612
67673
|
}
|
|
67613
67674
|
return;
|
|
67614
67675
|
}
|
|
@@ -67640,16 +67701,16 @@ var RuntimeSkillManager = class _RuntimeSkillManager {
|
|
|
67640
67701
|
if (!await legacyFileMatches(source2, legacy.hash) || !await packageMatches(source2, entry.contentHash)) {
|
|
67641
67702
|
return;
|
|
67642
67703
|
}
|
|
67643
|
-
await (0,
|
|
67704
|
+
await (0, import_promises15.rename)(source2, destination);
|
|
67644
67705
|
try {
|
|
67645
|
-
await (0,
|
|
67706
|
+
await (0, import_promises15.writeFile)(
|
|
67646
67707
|
(0, import_node_path24.join)(destination, ".alan-managed.json"),
|
|
67647
67708
|
`${JSON.stringify(markerFor(entry), null, 2)}
|
|
67648
67709
|
`,
|
|
67649
67710
|
{ encoding: "utf8", flag: "wx", mode: 384 }
|
|
67650
67711
|
);
|
|
67651
67712
|
} catch (error61) {
|
|
67652
|
-
await (0,
|
|
67713
|
+
await (0, import_promises15.rename)(destination, source2).catch(() => void 0);
|
|
67653
67714
|
throw error61;
|
|
67654
67715
|
}
|
|
67655
67716
|
await removeExactLegacySkill((0, import_node_path24.join)(this.compatibilitySkillsDirectory, entry.slug), legacy.hash);
|
|
@@ -67662,7 +67723,7 @@ var RuntimeSkillManager = class _RuntimeSkillManager {
|
|
|
67662
67723
|
await removeExactLegacySkill((0, import_node_path24.join)(this.managedSkillsDirectory, command), entry.hash);
|
|
67663
67724
|
await removeExactLegacySkill((0, import_node_path24.join)(this.compatibilitySkillsDirectory, command), entry.hash);
|
|
67664
67725
|
}
|
|
67665
|
-
await (0,
|
|
67726
|
+
await (0, import_promises15.rm)(this.legacyManifestPath, { force: true });
|
|
67666
67727
|
}
|
|
67667
67728
|
async ensureCached(entry) {
|
|
67668
67729
|
const cacheDirectory = (0, import_node_path24.join)(
|
|
@@ -67672,7 +67733,7 @@ var RuntimeSkillManager = class _RuntimeSkillManager {
|
|
|
67672
67733
|
entry.contentHash.slice("sha256:".length)
|
|
67673
67734
|
);
|
|
67674
67735
|
if (await packageMatches(cacheDirectory, entry.contentHash)) return cacheDirectory;
|
|
67675
|
-
await (0,
|
|
67736
|
+
await (0, import_promises15.rm)(cacheDirectory, { recursive: true, force: true });
|
|
67676
67737
|
const bytes = await this.downloadBundle(entry);
|
|
67677
67738
|
if (bytes.byteLength !== entry.compressedBytes) {
|
|
67678
67739
|
throw new Error(
|
|
@@ -67690,12 +67751,12 @@ var RuntimeSkillManager = class _RuntimeSkillManager {
|
|
|
67690
67751
|
expectedContentHash: entry.contentHash
|
|
67691
67752
|
});
|
|
67692
67753
|
try {
|
|
67693
|
-
await (0,
|
|
67754
|
+
await (0, import_promises15.rename)(pendingDirectory, cacheDirectory);
|
|
67694
67755
|
} catch (error61) {
|
|
67695
67756
|
if (!await packageMatches(cacheDirectory, entry.contentHash)) throw error61;
|
|
67696
67757
|
}
|
|
67697
67758
|
} finally {
|
|
67698
|
-
await (0,
|
|
67759
|
+
await (0, import_promises15.rm)(pendingDirectory, { recursive: true, force: true });
|
|
67699
67760
|
}
|
|
67700
67761
|
return cacheDirectory;
|
|
67701
67762
|
}
|
|
@@ -67713,8 +67774,8 @@ var RuntimeSkillManager = class _RuntimeSkillManager {
|
|
|
67713
67774
|
let installedPending = false;
|
|
67714
67775
|
let completed = false;
|
|
67715
67776
|
try {
|
|
67716
|
-
await (0,
|
|
67717
|
-
await (0,
|
|
67777
|
+
await (0, import_promises15.cp)(cacheDirectory, pending, { recursive: true, errorOnExist: true, force: false });
|
|
67778
|
+
await (0, import_promises15.writeFile)(
|
|
67718
67779
|
(0, import_node_path24.join)(pending, ".alan-managed.json"),
|
|
67719
67780
|
`${JSON.stringify(markerFor(entry), null, 2)}
|
|
67720
67781
|
`,
|
|
@@ -67724,14 +67785,14 @@ var RuntimeSkillManager = class _RuntimeSkillManager {
|
|
|
67724
67785
|
throw new Error("Pending managed Skill projection failed content verification");
|
|
67725
67786
|
}
|
|
67726
67787
|
if (await pathExists2(destination)) {
|
|
67727
|
-
await (0,
|
|
67788
|
+
await (0, import_promises15.rename)(destination, backup);
|
|
67728
67789
|
movedExisting = true;
|
|
67729
67790
|
}
|
|
67730
67791
|
try {
|
|
67731
|
-
await (0,
|
|
67792
|
+
await (0, import_promises15.rename)(pending, destination);
|
|
67732
67793
|
installedPending = true;
|
|
67733
67794
|
} catch (error61) {
|
|
67734
|
-
if (movedExisting) await (0,
|
|
67795
|
+
if (movedExisting) await (0, import_promises15.rename)(backup, destination);
|
|
67735
67796
|
throw error61;
|
|
67736
67797
|
}
|
|
67737
67798
|
const inspected = await inspectSkillPackage(destination, { expectedName: null });
|
|
@@ -67740,18 +67801,18 @@ var RuntimeSkillManager = class _RuntimeSkillManager {
|
|
|
67740
67801
|
}
|
|
67741
67802
|
await this.ensureCompatibilityProjection(entry, destination);
|
|
67742
67803
|
completed = true;
|
|
67743
|
-
await (0,
|
|
67804
|
+
await (0, import_promises15.rm)(backup, { recursive: true, force: true });
|
|
67744
67805
|
return inspected.contentHash;
|
|
67745
67806
|
} catch (error61) {
|
|
67746
67807
|
if (!completed && installedPending) {
|
|
67747
|
-
await (0,
|
|
67748
|
-
if (movedExisting && await pathExists2(backup)) await (0,
|
|
67808
|
+
await (0, import_promises15.rm)(destination, { recursive: true, force: true });
|
|
67809
|
+
if (movedExisting && await pathExists2(backup)) await (0, import_promises15.rename)(backup, destination);
|
|
67749
67810
|
}
|
|
67750
67811
|
throw error61;
|
|
67751
67812
|
} finally {
|
|
67752
|
-
await (0,
|
|
67813
|
+
await (0, import_promises15.rm)(pending, { recursive: true, force: true });
|
|
67753
67814
|
if (completed || !movedExisting) {
|
|
67754
|
-
await (0,
|
|
67815
|
+
await (0, import_promises15.rm)(backup, { recursive: true, force: true });
|
|
67755
67816
|
}
|
|
67756
67817
|
}
|
|
67757
67818
|
}
|
|
@@ -67779,7 +67840,7 @@ var RuntimeSkillManager = class _RuntimeSkillManager {
|
|
|
67779
67840
|
const failures = [];
|
|
67780
67841
|
let entries;
|
|
67781
67842
|
try {
|
|
67782
|
-
entries = await (0,
|
|
67843
|
+
entries = await (0, import_promises15.readdir)(this.managedSkillsDirectory);
|
|
67783
67844
|
} catch (error61) {
|
|
67784
67845
|
if (isMissingPath2(error61)) return failures;
|
|
67785
67846
|
throw error61;
|
|
@@ -67816,12 +67877,12 @@ var RuntimeSkillManager = class _RuntimeSkillManager {
|
|
|
67816
67877
|
});
|
|
67817
67878
|
continue;
|
|
67818
67879
|
}
|
|
67819
|
-
await (0,
|
|
67880
|
+
await (0, import_promises15.rm)(destination, { recursive: true, force: true });
|
|
67820
67881
|
}
|
|
67821
67882
|
return failures;
|
|
67822
67883
|
}
|
|
67823
67884
|
async ensureCompatibilityProjection(entry, canonicalDirectory) {
|
|
67824
|
-
await (0,
|
|
67885
|
+
await (0, import_promises15.mkdir)(this.compatibilitySkillsDirectory, { recursive: true, mode: 448 });
|
|
67825
67886
|
const destination = (0, import_node_path24.join)(
|
|
67826
67887
|
this.compatibilitySkillsDirectory,
|
|
67827
67888
|
this.projectionDirectoryName(entry.runtimeDirectory)
|
|
@@ -67831,23 +67892,23 @@ var RuntimeSkillManager = class _RuntimeSkillManager {
|
|
|
67831
67892
|
throw unmanagedCompatibilityConflict(entry.runtimeDirectory);
|
|
67832
67893
|
}
|
|
67833
67894
|
try {
|
|
67834
|
-
await (0,
|
|
67895
|
+
await (0, import_promises15.symlink)(canonicalDirectory, destination, "dir");
|
|
67835
67896
|
return;
|
|
67836
67897
|
} catch (error61) {
|
|
67837
67898
|
if (!isSymlinkUnsupported(error61)) throw error61;
|
|
67838
67899
|
}
|
|
67839
67900
|
const pending = `${destination}.pending-${process.pid}-${(0, import_node_crypto14.randomBytes)(6).toString("hex")}`;
|
|
67840
67901
|
try {
|
|
67841
|
-
await (0,
|
|
67842
|
-
await (0,
|
|
67902
|
+
await (0, import_promises15.cp)(canonicalDirectory, pending, { recursive: true, errorOnExist: true, force: false });
|
|
67903
|
+
await (0, import_promises15.writeFile)(
|
|
67843
67904
|
(0, import_node_path24.join)(pending, ".alan-compatibility.json"),
|
|
67844
67905
|
`${JSON.stringify({ ...markerFor(entry), canonicalDirectory }, null, 2)}
|
|
67845
67906
|
`,
|
|
67846
67907
|
{ encoding: "utf8", flag: "wx", mode: 384 }
|
|
67847
67908
|
);
|
|
67848
|
-
await (0,
|
|
67909
|
+
await (0, import_promises15.rename)(pending, destination);
|
|
67849
67910
|
} finally {
|
|
67850
|
-
await (0,
|
|
67911
|
+
await (0, import_promises15.rm)(pending, { recursive: true, force: true });
|
|
67851
67912
|
}
|
|
67852
67913
|
}
|
|
67853
67914
|
async runExclusively(work) {
|
|
@@ -67871,29 +67932,29 @@ var RuntimeSkillManager = class _RuntimeSkillManager {
|
|
|
67871
67932
|
return this.storageNamespace ? `${runtimeDirectory}--alan-${this.storageNamespace}` : runtimeDirectory;
|
|
67872
67933
|
}
|
|
67873
67934
|
async withMachineLock(work) {
|
|
67874
|
-
await (0,
|
|
67935
|
+
await (0, import_promises15.mkdir)(this.skillsStateDirectory, { recursive: true, mode: 448 });
|
|
67875
67936
|
const lockDirectory = (0, import_node_path24.join)(this.skillsStateDirectory, "manager.lock");
|
|
67876
67937
|
const deadline = Date.now() + 3e4;
|
|
67877
67938
|
while (true) {
|
|
67878
67939
|
try {
|
|
67879
|
-
await (0,
|
|
67940
|
+
await (0, import_promises15.mkdir)(lockDirectory, { mode: 448 });
|
|
67880
67941
|
try {
|
|
67881
|
-
await (0,
|
|
67942
|
+
await (0, import_promises15.writeFile)(
|
|
67882
67943
|
(0, import_node_path24.join)(lockDirectory, "owner.json"),
|
|
67883
67944
|
`${JSON.stringify({ pid: process.pid, acquiredAt: (/* @__PURE__ */ new Date()).toISOString() })}
|
|
67884
67945
|
`,
|
|
67885
67946
|
{ encoding: "utf8", flag: "wx", mode: 384 }
|
|
67886
67947
|
);
|
|
67887
67948
|
} catch (error61) {
|
|
67888
|
-
await (0,
|
|
67949
|
+
await (0, import_promises15.rm)(lockDirectory, { recursive: true, force: true });
|
|
67889
67950
|
throw error61;
|
|
67890
67951
|
}
|
|
67891
67952
|
break;
|
|
67892
67953
|
} catch (error61) {
|
|
67893
67954
|
if (!isAlreadyPresent2(error61)) throw error61;
|
|
67894
|
-
const ageMs = await (0,
|
|
67955
|
+
const ageMs = await (0, import_promises15.stat)(lockDirectory).then((metadata) => Date.now() - metadata.mtimeMs).catch(() => 0);
|
|
67895
67956
|
if (ageMs > 15 * 6e4) {
|
|
67896
|
-
await (0,
|
|
67957
|
+
await (0, import_promises15.rm)(lockDirectory, { recursive: true, force: true });
|
|
67897
67958
|
continue;
|
|
67898
67959
|
}
|
|
67899
67960
|
if (Date.now() >= deadline) {
|
|
@@ -67907,7 +67968,7 @@ var RuntimeSkillManager = class _RuntimeSkillManager {
|
|
|
67907
67968
|
try {
|
|
67908
67969
|
return await work();
|
|
67909
67970
|
} finally {
|
|
67910
|
-
await (0,
|
|
67971
|
+
await (0, import_promises15.rm)(lockDirectory, { recursive: true, force: true });
|
|
67911
67972
|
}
|
|
67912
67973
|
}
|
|
67913
67974
|
};
|
|
@@ -67929,7 +67990,7 @@ async function packageMatches(directory, expectedHash) {
|
|
|
67929
67990
|
async function readMarker(directory) {
|
|
67930
67991
|
try {
|
|
67931
67992
|
const value2 = JSON.parse(
|
|
67932
|
-
await (0,
|
|
67993
|
+
await (0, import_promises15.readFile)((0, import_node_path24.join)(directory, ".alan-managed.json"), "utf8")
|
|
67933
67994
|
);
|
|
67934
67995
|
if (typeof value2 !== "object" || value2 === null || !("protocolVersion" in value2) || value2.protocolVersion !== SKILLS_PROTOCOL_VERSION || !("skillId" in value2) || typeof value2.skillId !== "string" || !("versionId" in value2) || typeof value2.versionId !== "string" || !("contentHash" in value2) || typeof value2.contentHash !== "string" || !/^sha256:[a-f0-9]{64}$/.test(value2.contentHash)) {
|
|
67935
67996
|
return null;
|
|
@@ -67940,9 +68001,9 @@ async function readMarker(directory) {
|
|
|
67940
68001
|
}
|
|
67941
68002
|
}
|
|
67942
68003
|
async function compatibilityProjectionMatches(destination, canonicalDirectory, entry) {
|
|
67943
|
-
const metadata = await (0,
|
|
68004
|
+
const metadata = await (0, import_promises15.lstat)(destination);
|
|
67944
68005
|
if (metadata.isSymbolicLink()) {
|
|
67945
|
-
const target = await (0,
|
|
68006
|
+
const target = await (0, import_promises15.readlink)(destination);
|
|
67946
68007
|
return (0, import_node_path24.resolve)((0, import_node_path24.dirname)(destination), target) === (0, import_node_path24.resolve)(canonicalDirectory);
|
|
67947
68008
|
}
|
|
67948
68009
|
if (!metadata.isDirectory()) return false;
|
|
@@ -67951,22 +68012,22 @@ async function compatibilityProjectionMatches(destination, canonicalDirectory, e
|
|
|
67951
68012
|
}
|
|
67952
68013
|
async function removeCompatibilityProjection(destination, canonicalDirectory, projection) {
|
|
67953
68014
|
if (!await pathExists2(destination)) return true;
|
|
67954
|
-
const metadata = await (0,
|
|
68015
|
+
const metadata = await (0, import_promises15.lstat)(destination);
|
|
67955
68016
|
if (metadata.isSymbolicLink()) {
|
|
67956
|
-
const target = await (0,
|
|
68017
|
+
const target = await (0, import_promises15.readlink)(destination);
|
|
67957
68018
|
if ((0, import_node_path24.resolve)((0, import_node_path24.dirname)(destination), target) !== (0, import_node_path24.resolve)(canonicalDirectory)) return false;
|
|
67958
|
-
await (0,
|
|
68019
|
+
await (0, import_promises15.rm)(destination, { force: true });
|
|
67959
68020
|
return true;
|
|
67960
68021
|
}
|
|
67961
68022
|
const marker = await readCompatibilityMarker(destination);
|
|
67962
68023
|
if (!marker || !markerMatchesProjection(marker, projection)) return false;
|
|
67963
|
-
await (0,
|
|
68024
|
+
await (0, import_promises15.rm)(destination, { recursive: true, force: true });
|
|
67964
68025
|
return true;
|
|
67965
68026
|
}
|
|
67966
68027
|
async function readCompatibilityMarker(directory) {
|
|
67967
68028
|
try {
|
|
67968
68029
|
const value2 = JSON.parse(
|
|
67969
|
-
await (0,
|
|
68030
|
+
await (0, import_promises15.readFile)((0, import_node_path24.join)(directory, ".alan-compatibility.json"), "utf8")
|
|
67970
68031
|
);
|
|
67971
68032
|
if (value2.protocolVersion !== SKILLS_PROTOCOL_VERSION || typeof value2.skillId !== "string" || typeof value2.versionId !== "string" || !/^sha256:[a-f0-9]{64}$/.test(value2.contentHash) || typeof value2.canonicalDirectory !== "string") {
|
|
67972
68033
|
return null;
|
|
@@ -67986,7 +68047,7 @@ function markerFor(entry) {
|
|
|
67986
68047
|
}
|
|
67987
68048
|
async function readLegacyManifest(path2) {
|
|
67988
68049
|
try {
|
|
67989
|
-
const value2 = JSON.parse(await (0,
|
|
68050
|
+
const value2 = JSON.parse(await (0, import_promises15.readFile)(path2, "utf8"));
|
|
67990
68051
|
if (!value2 || typeof value2 !== "object" || !("skills" in value2)) return null;
|
|
67991
68052
|
const skillsValue = value2.skills;
|
|
67992
68053
|
if (!skillsValue || typeof skillsValue !== "object" || Array.isArray(skillsValue)) return null;
|
|
@@ -68004,9 +68065,9 @@ async function readLegacyManifest(path2) {
|
|
|
68004
68065
|
}
|
|
68005
68066
|
async function legacyFileMatches(directory, expectedHash) {
|
|
68006
68067
|
try {
|
|
68007
|
-
const metadata = await (0,
|
|
68068
|
+
const metadata = await (0, import_promises15.lstat)(directory);
|
|
68008
68069
|
if (!metadata.isDirectory() || metadata.isSymbolicLink()) return false;
|
|
68009
|
-
const content = await (0,
|
|
68070
|
+
const content = await (0, import_promises15.readFile)((0, import_node_path24.join)(directory, "SKILL.md"));
|
|
68010
68071
|
return (0, import_node_crypto14.createHash)("sha256").update(content).digest("hex").slice(0, 16) === expectedHash;
|
|
68011
68072
|
} catch {
|
|
68012
68073
|
return false;
|
|
@@ -68014,9 +68075,9 @@ async function legacyFileMatches(directory, expectedHash) {
|
|
|
68014
68075
|
}
|
|
68015
68076
|
async function removeExactLegacySkill(directory, expectedHash) {
|
|
68016
68077
|
if (!await legacyFileMatches(directory, expectedHash)) return;
|
|
68017
|
-
await (0,
|
|
68018
|
-
const remaining = await (0,
|
|
68019
|
-
if (remaining.length === 0) await (0,
|
|
68078
|
+
await (0, import_promises15.rm)((0, import_node_path24.join)(directory, "SKILL.md"), { force: true });
|
|
68079
|
+
const remaining = await (0, import_promises15.readdir)(directory);
|
|
68080
|
+
if (remaining.length === 0) await (0, import_promises15.rm)(directory, { recursive: true, force: true });
|
|
68020
68081
|
}
|
|
68021
68082
|
function markerMatchesProjection(marker, projection) {
|
|
68022
68083
|
return marker.skillId === projection.skillId && marker.versionId === projection.versionId && marker.contentHash === projection.contentHash;
|
|
@@ -68118,7 +68179,7 @@ function localTextMediaType(path2) {
|
|
|
68118
68179
|
}
|
|
68119
68180
|
async function pathExists2(path2) {
|
|
68120
68181
|
try {
|
|
68121
|
-
await (0,
|
|
68182
|
+
await (0, import_promises15.lstat)(path2);
|
|
68122
68183
|
return true;
|
|
68123
68184
|
} catch (error61) {
|
|
68124
68185
|
if (isMissingPath2(error61)) return false;
|
|
@@ -68560,6 +68621,9 @@ function buildAgentRunConfig(input2) {
|
|
|
68560
68621
|
teamId: input2.teamId,
|
|
68561
68622
|
currentUser: input2.currentUser,
|
|
68562
68623
|
sessionVisibility: input2.sessionVisibility,
|
|
68624
|
+
codeIndexEnabled: input2.codeIndexEnabled,
|
|
68625
|
+
contextGraphEnabled: input2.contextGraphEnabled,
|
|
68626
|
+
relevantContext: input2.relevantContext,
|
|
68563
68627
|
workflowTools: input2.workflowTools,
|
|
68564
68628
|
workflowId: input2.workflowId,
|
|
68565
68629
|
workflowExecutionId: input2.workflowExecutionId,
|
|
@@ -68601,19 +68665,19 @@ ${input2.userRequest}
|
|
|
68601
68665
|
}
|
|
68602
68666
|
|
|
68603
68667
|
// src/workspace-run-lease.ts
|
|
68604
|
-
var
|
|
68668
|
+
var import_promises16 = require("fs/promises");
|
|
68605
68669
|
var import_node_path25 = require("path");
|
|
68606
68670
|
var WORKSPACE_LEASE_CHECK_INTERVAL_MS = 1e3;
|
|
68607
68671
|
async function hasGitWorkspaceMarker(workspacePath) {
|
|
68608
68672
|
let directory;
|
|
68609
68673
|
try {
|
|
68610
|
-
directory = await (0,
|
|
68674
|
+
directory = await (0, import_promises16.realpath)((0, import_node_path25.resolve)(workspacePath));
|
|
68611
68675
|
} catch {
|
|
68612
68676
|
return true;
|
|
68613
68677
|
}
|
|
68614
68678
|
while (true) {
|
|
68615
68679
|
try {
|
|
68616
|
-
await (0,
|
|
68680
|
+
await (0, import_promises16.stat)((0, import_node_path25.join)(directory, ".git"));
|
|
68617
68681
|
return true;
|
|
68618
68682
|
} catch (error61) {
|
|
68619
68683
|
const code = error61.code;
|
|
@@ -68625,8 +68689,8 @@ async function hasGitWorkspaceMarker(workspacePath) {
|
|
|
68625
68689
|
}
|
|
68626
68690
|
}
|
|
68627
68691
|
async function filesystemIdentity(path2) {
|
|
68628
|
-
const canonicalPath = await (0,
|
|
68629
|
-
const metadata = await (0,
|
|
68692
|
+
const canonicalPath = await (0, import_promises16.realpath)(path2);
|
|
68693
|
+
const metadata = await (0, import_promises16.stat)(canonicalPath);
|
|
68630
68694
|
return `${canonicalPath}:${metadata.dev}:${metadata.ino}`;
|
|
68631
68695
|
}
|
|
68632
68696
|
function resolveGitPath(workspacePath, value2) {
|
|
@@ -68638,7 +68702,7 @@ async function resolveGitIdentityPaths(canonicalWorkspacePath) {
|
|
|
68638
68702
|
const marker = (0, import_node_path25.join)(directory, ".git");
|
|
68639
68703
|
let markerStats;
|
|
68640
68704
|
try {
|
|
68641
|
-
markerStats = await (0,
|
|
68705
|
+
markerStats = await (0, import_promises16.stat)(marker);
|
|
68642
68706
|
} catch (error61) {
|
|
68643
68707
|
const code = error61.code;
|
|
68644
68708
|
if (code !== "ENOENT" && code !== "ENOTDIR") return null;
|
|
@@ -68652,7 +68716,7 @@ async function resolveGitIdentityPaths(canonicalWorkspacePath) {
|
|
|
68652
68716
|
}
|
|
68653
68717
|
let pointer;
|
|
68654
68718
|
try {
|
|
68655
|
-
pointer = await (0,
|
|
68719
|
+
pointer = await (0, import_promises16.readFile)(marker, "utf8");
|
|
68656
68720
|
} catch {
|
|
68657
68721
|
return null;
|
|
68658
68722
|
}
|
|
@@ -68661,7 +68725,7 @@ async function resolveGitIdentityPaths(canonicalWorkspacePath) {
|
|
|
68661
68725
|
const gitDirectory = resolveGitPath(directory, gitDirMatch[1].trim());
|
|
68662
68726
|
let commonDirectory = gitDirectory;
|
|
68663
68727
|
try {
|
|
68664
|
-
const commonRaw = (await (0,
|
|
68728
|
+
const commonRaw = (await (0, import_promises16.readFile)((0, import_node_path25.join)(gitDirectory, "commondir"), "utf8")).trim();
|
|
68665
68729
|
if (commonRaw) commonDirectory = (0, import_node_path25.resolve)(gitDirectory, commonRaw);
|
|
68666
68730
|
} catch (error61) {
|
|
68667
68731
|
const code = error61.code;
|
|
@@ -68707,7 +68771,7 @@ var DEFAULT_PROBE = {
|
|
|
68707
68771
|
snapshot: createWorkspaceRunLeaseSnapshotProbe(snapshotWorkspace),
|
|
68708
68772
|
pathExists: async (workspacePath) => {
|
|
68709
68773
|
try {
|
|
68710
|
-
await (0,
|
|
68774
|
+
await (0, import_promises16.access)((0, import_node_path25.resolve)(workspacePath));
|
|
68711
68775
|
return true;
|
|
68712
68776
|
} catch (error61) {
|
|
68713
68777
|
return error61.code !== "ENOENT";
|
|
@@ -68716,7 +68780,7 @@ var DEFAULT_PROBE = {
|
|
|
68716
68780
|
};
|
|
68717
68781
|
async function snapshotWorkspace(workspacePath) {
|
|
68718
68782
|
try {
|
|
68719
|
-
const canonicalWorkspacePath = await (0,
|
|
68783
|
+
const canonicalWorkspacePath = await (0, import_promises16.realpath)((0, import_node_path25.resolve)(workspacePath));
|
|
68720
68784
|
const gitPaths = await resolveGitIdentityPaths(canonicalWorkspacePath);
|
|
68721
68785
|
if (!gitPaths) return null;
|
|
68722
68786
|
return {
|
|
@@ -69633,6 +69697,9 @@ async function launchRun(ctx, payload, plan) {
|
|
|
69633
69697
|
teamId: payload.teamId,
|
|
69634
69698
|
currentUser: payload.currentUser,
|
|
69635
69699
|
sessionVisibility: payload.sessionVisibility,
|
|
69700
|
+
codeIndexEnabled: payload.codeIndexEnabled,
|
|
69701
|
+
contextGraphEnabled: payload.contextGraphEnabled,
|
|
69702
|
+
relevantContext: payload.relevantContext,
|
|
69636
69703
|
workflowTools: payload.workflowTools,
|
|
69637
69704
|
workflowId: payload.workflowId,
|
|
69638
69705
|
workflowExecutionId: payload.workflowExecutionId,
|
|
@@ -75351,7 +75418,7 @@ async function setupWindowsRuntime(commandArgs) {
|
|
|
75351
75418
|
throw new Error("Windows runtime setup completed without a local readiness endpoint");
|
|
75352
75419
|
}
|
|
75353
75420
|
const probe = () => probeLocalDaemon(localApiPort, localApiToken, Math.min(250, remainingMs()));
|
|
75354
|
-
const poll = () => (0,
|
|
75421
|
+
const poll = () => (0, import_promises17.setTimeout)(Math.min(100, remainingMs()), void 0, { signal: controller.signal });
|
|
75355
75422
|
if (runtimeIdentityChanged) {
|
|
75356
75423
|
while (true) {
|
|
75357
75424
|
const status2 = await probe();
|
|
@@ -75992,6 +76059,9 @@ var WSClient = class {
|
|
|
75992
76059
|
teamId: data.teamId,
|
|
75993
76060
|
currentUser: data.currentUser,
|
|
75994
76061
|
sessionVisibility: data.sessionVisibility,
|
|
76062
|
+
codeIndexEnabled: data.codeIndexEnabled,
|
|
76063
|
+
contextGraphEnabled: data.contextGraphEnabled,
|
|
76064
|
+
relevantContext: data.relevantContext,
|
|
75995
76065
|
terminalContextRefs: data.terminalContextRefs,
|
|
75996
76066
|
terminalSnapshots: data.terminalSnapshots,
|
|
75997
76067
|
externalMcpServers: data.externalMcpServers
|
|
@@ -76804,6 +76874,9 @@ function initialTurn(seed) {
|
|
|
76804
76874
|
teamId: seed.teamId,
|
|
76805
76875
|
currentUser: seed.currentUser,
|
|
76806
76876
|
sessionVisibility: seed.sessionVisibility,
|
|
76877
|
+
codeIndexEnabled: void 0,
|
|
76878
|
+
contextGraphEnabled: void 0,
|
|
76879
|
+
relevantContext: void 0,
|
|
76807
76880
|
terminalContextRefs: void 0,
|
|
76808
76881
|
terminalSnapshots: void 0
|
|
76809
76882
|
};
|
|
@@ -76826,6 +76899,10 @@ function applyUserMessage(turn, patch) {
|
|
|
76826
76899
|
canonicalUserMessage: patch.canonicalUserMessage,
|
|
76827
76900
|
canonicalAssistantMessage: patch.canonicalAssistantMessage,
|
|
76828
76901
|
cloudEnvironmentId: patch.cloudEnvironmentId,
|
|
76902
|
+
// Entitlements and recall are decided per message, so an omission never inherits.
|
|
76903
|
+
codeIndexEnabled: patch.codeIndexEnabled,
|
|
76904
|
+
contextGraphEnabled: patch.contextGraphEnabled,
|
|
76905
|
+
relevantContext: patch.relevantContext,
|
|
76829
76906
|
// A resume hint only travels with the session it belongs to.
|
|
76830
76907
|
...patch.providerSessionId ? {
|
|
76831
76908
|
providerSessionId: patch.providerSessionId,
|
|
@@ -77201,6 +77278,9 @@ async function runSandbox(config4) {
|
|
|
77201
77278
|
teamId: turn.teamId,
|
|
77202
77279
|
currentUser: turn.currentUser,
|
|
77203
77280
|
sessionVisibility: turn.sessionVisibility,
|
|
77281
|
+
codeIndexEnabled: turn.codeIndexEnabled,
|
|
77282
|
+
contextGraphEnabled: turn.contextGraphEnabled,
|
|
77283
|
+
relevantContext: turn.relevantContext,
|
|
77204
77284
|
workflowTools: turn.workflowTools,
|
|
77205
77285
|
workflowId,
|
|
77206
77286
|
workflowExecutionId,
|
|
@@ -77299,7 +77379,7 @@ async function runSandbox(config4) {
|
|
|
77299
77379
|
}
|
|
77300
77380
|
|
|
77301
77381
|
// src/skills/skill-cli.ts
|
|
77302
|
-
var
|
|
77382
|
+
var import_promises18 = require("fs/promises");
|
|
77303
77383
|
var import_node_os22 = require("os");
|
|
77304
77384
|
var import_node_path40 = require("path");
|
|
77305
77385
|
async function runSkillsCommand(args) {
|
|
@@ -77346,7 +77426,7 @@ async function defaultScanInput(homeDirectory2) {
|
|
|
77346
77426
|
}
|
|
77347
77427
|
async function readProtectedJson(path2) {
|
|
77348
77428
|
const absolutePath = (0, import_node_path40.resolve)(path2);
|
|
77349
|
-
const stat4 = await (0,
|
|
77429
|
+
const stat4 = await (0, import_promises18.lstat)(absolutePath);
|
|
77350
77430
|
if (!stat4.isFile()) throw new Error(`Skill input is not a regular file: ${absolutePath}`);
|
|
77351
77431
|
if (process.platform !== "win32" && (stat4.mode & 63) !== 0) {
|
|
77352
77432
|
throw new Error(`Skill input must not be accessible by group or other users: ${absolutePath}`);
|
|
@@ -77355,7 +77435,7 @@ async function readProtectedJson(path2) {
|
|
|
77355
77435
|
throw new Error(`Skill input must be owned by the current user: ${absolutePath}`);
|
|
77356
77436
|
}
|
|
77357
77437
|
if (stat4.size > 2 * 1024 * 1024) throw new Error("Skill input exceeds 2 MiB");
|
|
77358
|
-
return JSON.parse(await (0,
|
|
77438
|
+
return JSON.parse(await (0, import_promises18.readFile)(absolutePath, "utf8"));
|
|
77359
77439
|
}
|
|
77360
77440
|
function option2(args, name) {
|
|
77361
77441
|
const index = args.indexOf(name);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alan-ai-hq/agent-manager",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.127",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Alan agent runtime — cloud sandbox and local daemon (alan-agent CLI)",
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
"tsx": "^4.19.0",
|
|
29
29
|
"typescript": "~5.9.3",
|
|
30
30
|
"@alan-ai/agent-core": "0.1.0",
|
|
31
|
-
"@alan-ai/
|
|
32
|
-
"@alan-ai/
|
|
31
|
+
"@alan-ai/sandbox-runtime-spec": "0.1.0",
|
|
32
|
+
"@alan-ai/shared": "0.1.0"
|
|
33
33
|
},
|
|
34
34
|
"scripts": {
|
|
35
35
|
"build": "tsup",
|