@foldrun/core 24.10.0 → 24.12.0
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/src/engine-common.d.ts +21 -0
- package/dist/src/engine-common.js +12 -1
- package/dist/src/engine-loop.js +7 -2
- package/dist/src/engine-mcp.d.ts +4 -0
- package/dist/src/engine-mcp.js +62 -2
- package/dist/src/engine-tools.d.ts +7 -0
- package/dist/src/engine-tools.js +275 -19
- package/dist/src/local-sandbox.d.ts +135 -0
- package/dist/src/local-sandbox.js +1289 -0
- package/dist/src/runner.d.ts +7 -1
- package/dist/src/runner.js +27 -4
- package/package.json +9 -2
- package/src/engine-common.ts +29 -1
- package/src/engine-loop.ts +7 -2
- package/src/engine-mcp.ts +60 -3
- package/src/engine-tools.ts +257 -25
- package/src/local-sandbox.ts +1274 -0
- package/src/runner.ts +27 -6
package/src/runner.ts
CHANGED
|
@@ -22,7 +22,7 @@ import { resolveAgentPath } from "./confine.ts";
|
|
|
22
22
|
import { browserPodLine, podLossDecision, RERAN_ON_FULL } from "./browser-pod.ts";
|
|
23
23
|
import { eventUrl } from "./webhook.ts";
|
|
24
24
|
import { runStepInContainer, resolveResources, memoryGiB, heldCores, killRunSandboxes, classDisk, type StepTiming } from "./run-container.ts";
|
|
25
|
-
import { readResources, hasOverride } from "./resources.ts";
|
|
25
|
+
import { readResources, hasOverride, anyMemoryMi } from "./resources.ts";
|
|
26
26
|
import { hostSafeEnv, platformApiUrl } from "./host-env.ts";
|
|
27
27
|
import { resolveModelCredential, credentialLine, accountModelBlock, isClaudeLoginToken, isModelEnvName, DECLARED_ENV_PREFIX } from "./model-credential.ts";
|
|
28
28
|
import { parseJudge } from "./judge-verdict.ts";
|
|
@@ -567,20 +567,41 @@ export function agentRuntimeSpec(tenant: string, workspace: string, agentDir: st
|
|
|
567
567
|
return mergeRuntimes(ownRuntime(front, agentDir, tenant), ...tools);
|
|
568
568
|
}
|
|
569
569
|
|
|
570
|
-
/**
|
|
570
|
+
/** The node disk one agent's steps may write: its `size:` class's, or its
|
|
571
|
+
* own `resources: disk` over it — the figure the runner gives its pod. */
|
|
572
|
+
export function agentDisk(agentDir: string): string {
|
|
573
|
+
const file = path.join(agentDir, "agent.md");
|
|
574
|
+
let front: Record<string, unknown> = {};
|
|
575
|
+
try {
|
|
576
|
+
// The step's own parser: it lifts `guardrail: { resources: … }` to the
|
|
577
|
+
// top, so both spellings of a disk override count here as they do there.
|
|
578
|
+
if (fs.existsSync(file)) front = configMatter(fs.readFileSync(file, "utf8")).data as Record<string, unknown>;
|
|
579
|
+
} catch {
|
|
580
|
+
/* frontmatter that does not parse: the class default, as `check` reports it */
|
|
581
|
+
}
|
|
582
|
+
const size: "small" | "large" | "heavy" = front.size === "small" ? "small" : front.size === "heavy" ? "heavy" : "large";
|
|
583
|
+
return resolveResources(size, readResources(front.resources).value).disk ?? classDisk(size);
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
/** Every distinct runtime a workspace's agents need, with who needs it and
|
|
587
|
+
* `disk`, the most node disk any of those agents' steps may write (a
|
|
588
|
+
* runtime built for them has at least that much room to be built in). */
|
|
571
589
|
export function workspaceRuntimePlan(
|
|
572
590
|
tenant: string,
|
|
573
591
|
workspace: string,
|
|
574
|
-
): { fingerprint: string; spec: RuntimeSpec; agents: string[] }[] {
|
|
575
|
-
const byFp = new Map<string, { fingerprint: string; spec: RuntimeSpec; agents: string[] }>();
|
|
592
|
+
): { fingerprint: string; spec: RuntimeSpec; agents: string[]; disk: string }[] {
|
|
593
|
+
const byFp = new Map<string, { fingerprint: string; spec: RuntimeSpec; agents: string[]; disk: string }>();
|
|
576
594
|
const agentsRoot = path.join(workspaceDir(tenant, workspace), "agents");
|
|
577
595
|
if (!fs.existsSync(agentsRoot)) return [];
|
|
578
596
|
for (const name of fs.readdirSync(agentsRoot).sort()) {
|
|
579
|
-
const
|
|
597
|
+
const dir = path.join(agentsRoot, name);
|
|
598
|
+
const spec = agentRuntimeSpec(tenant, workspace, dir);
|
|
580
599
|
if (!spec) continue;
|
|
581
600
|
const fp = fingerprint(spec);
|
|
582
|
-
const
|
|
601
|
+
const disk = agentDisk(dir);
|
|
602
|
+
const entry = byFp.get(fp) ?? { fingerprint: fp, spec, agents: [], disk };
|
|
583
603
|
entry.agents.push(name);
|
|
604
|
+
if (anyMemoryMi(disk) > anyMemoryMi(entry.disk)) entry.disk = disk;
|
|
584
605
|
byFp.set(fp, entry);
|
|
585
606
|
}
|
|
586
607
|
return [...byFp.values()];
|