The Open Framework for Building Agents
feat(eve): write skills into `$HOME/.agents/skills` instead of the workspace directory (#554)
Felix Arntz73a9bf936a78
diff --git a/.changeset/cool-camels-see.md b/.changeset/cool-camels-see.mdnew file mode 100644index 000000000..01ae3ddf2--- /dev/null+++ b/.changeset/cool-camels-see.md@@ -0,0 +1,5 @@+---+"eve": minor+---++feat(eve): write skills into `$HOME/.agents/skills` instead of the workspace directorydiff --git a/docs/concepts/context-control.md b/docs/concepts/context-control.mdindex 88be833f4..0809905fd 100644--- a/docs/concepts/context-control.md+++ b/docs/concepts/context-control.md@@ -52,13 +52,13 @@ When the task is novel or ambiguous, gather evidence first, then answer with theremaining uncertainty.```-Packaged skills are useful when you also want sibling files such as `references/`, `assets/`, or `scripts/` under the same skill directory. Those paths show up under the runtime workspace root, so the model can inspect them with the normal file or shell tools instead of pasting their content into the prompt.+Packaged skills are useful when you also want sibling files such as `references/`, `assets/`, or `scripts/` under the same skill directory. Those files are available under the runtime skill root, normally `$HOME/.agents/skills/<skill>/`. Relative references inside a `SKILL.md` resolve from that specific skill directory, so `references/checklist.md` means `$HOME/.agents/skills/<skill>/references/checklist.md` unless eve has fallen back to `/workspace/skills/<skill>/`.See [Skills](../skills) for the full authoring model and install notes.## Put runtime files in the workspace, not the prompt-eve does not inline the entire authored surface into the prompt. Instead, it gives the model a shallow workspace hint and runtime tools to inspect deeper when needed. Skill files are available under the active workspace root, and the model inspects them with the shared `bash` tool, which keeps prompts smaller and makes file and command work explicit.+eve does not inline the entire authored surface into the prompt. Instead, it gives the model a shallow workspace hint, a separate skill-root hint, and runtime tools to inspect deeper when needed. Skill package files are outside `/workspace` in the normal case, and the model inspects them with the shared `bash` tool, which keeps prompts smaller and makes file and command work explicit.See [Sandbox](../sandbox) for the workspace and sandbox model.diff --git a/docs/reference/project-layout.md b/docs/reference/project-layout.mdindex b4239801a..ff159f76b 100644--- a/docs/reference/project-layout.md+++ b/docs/reference/project-layout.md@@ -54,7 +54,7 @@ The Subagents column states whether a local subagent (`subagents/<id>/`) can aut| `channels/` | HTTP / messaging entrypoints | No | Root-only. || `connections/` | External service connections (MCP, OpenAPI) | Yes | One connection per file; name derived from filename. || `hooks/` | Lifecycle and stream-event subscribers | Yes | Module-backed only. Recursive directories supported. |-| `skills/` | On-demand procedures and capability packs | Yes | Flat markdown, module-backed skills, or packaged skills. Seeded into `/workspace/skills/...`. |+| `skills/` | On-demand procedures and capability packs | Yes | Flat markdown, module-backed skills, or packaged skills. Seeded into `$HOME/.agents/skills/...`, with `/workspace/skills/...` as a fallback if `$HOME` is unavailable. || `lib/` | Shared authored helper code | Yes | Import-only; not mounted into the workspace. || `sandbox.ts` or `sandbox/sandbox.ts` | The agent's single sandbox | Yes | Use top-level `sandbox.ts` for a definition-only override; use `sandbox/sandbox.ts` + `sandbox/workspace/**` to also seed files. Framework default applies when neither is authored. || `sandbox/workspace/**` | Files seeded into the sandbox | Yes | Mirrored into `/workspace/...` at session bootstrap. |@@ -62,13 +62,14 @@ The Subagents column states whether a local subagent (`subagents/<id>/`) can aut| `schedules/` | Recurring jobs | No | Each schedule is `<name>.ts` (default-exported `defineSchedule`) or `<name>.md` (frontmatter `cron:` + prompt body). Recursive nesting supported. Root-only. || `subagents/` | Specialist child agents | Yes | Each child is its own local package under `subagents/<id>/`. Nested subagents are supported. |-## What reaches the runtime workspace+## What reaches the runtime sandbox-eve does not mount the whole tree. Only two sources land in the sandbox workspace:+eve does not mount the whole tree. Authored workspace files land in the sandbox workspace:-- `skills/` files → `/workspace/skills/...`- `agent/sandbox/workspace/**` → `/workspace/...` at session bootstrap+Skill files land outside the workspace, under `$HOME/.agents/skills/...`. If `$HOME` is unavailable, eve falls back to `/workspace/skills/...`. Packaged skill references such as `references/checklist.md` resolve relative to the directory containing that skill's `SKILL.md`.+Everything in `lib/` stays import-only source code and never reaches the workspace.## Local subagent layoutdiff --git a/docs/sandbox.mdx b/docs/sandbox.mdxindex 544ab702e..55de36d0b 100644--- a/docs/sandbox.mdx+++ b/docs/sandbox.mdx@@ -82,7 +82,7 @@ agent/sandbox/scripts/run.sh ← lands at /workspace/scripts/run.sh```-Every file under `workspace/` mirrors into the sandbox cwd with its structure intact, and eve lists the top-level entries to the model in the prompt automatically. One subtree is off limits. Skill discovery already seeds skill files under `/workspace/skills/`, so authoring `agent/sandbox/workspace/skills/...` is rejected; put those under `agent/skills/` instead.+Every file under `workspace/` mirrors into the sandbox cwd with its structure intact, and eve lists the top-level entries to the model in the prompt automatically. `agent/skills/` files are materialized separately under `$HOME/.agents/skills/`, so `agent/sandbox/workspace/skills/...` is an ordinary workspace subtree when you choose to author one.## Overriding the sandboxdiff --git a/docs/skills.mdx b/docs/skills.mdxindex 746d481f0..5ffc5d2f4 100644--- a/docs/skills.mdx+++ b/docs/skills.mdx@@ -9,6 +9,8 @@ A skill is a model-loadable procedure that follows the `SKILL.md` convention. Iteve scans the files under `agent/skills/` and exposes each one's description to the model alongside a framework-owned `load_skill` tool. When a request matches a skill's description (or you name the skill outright), the model calls `load_skill`, and eve appends that skill's markdown to the active turn's context.+At runtime, skill package files are placed under `$HOME/.agents/skills/<skill>/`. If `$HOME` is unavailable in a sandbox, eve falls back to `/workspace/skills/<skill>/`. `load_skill` reads `SKILL.md` automatically; any sibling references inside that file, such as `references/checklist.md`, are relative to the directory containing that specific `SKILL.md`.+The description is a routing hint, not a label. Write it as the task that should trigger activation:```md@@ -68,7 +70,7 @@ const research = ctx.getSkill("research");const checklist = await research.file("references/checklist.md").text();```-The handle exposes the skill's `name` and `file(relativePath)`; file content is read lazily from the active sandbox.+The handle exposes the skill's `name` and `file(relativePath)`; file content is read lazily from the active sandbox, relative to that skill package directory.## Dynamic skillsdiff --git a/packages/eve/src/compiler/manifest.ts b/packages/eve/src/compiler/manifest.tsindex 1371f11e2..317df7ba8 100644--- a/packages/eve/src/compiler/manifest.ts+++ b/packages/eve/src/compiler/manifest.ts@@ -789,10 +789,6 @@ export function deriveResourceRootEntries(input: {}): readonly string[] {const rootEntries = new Set<string>();- if ((input.skills ?? []).length > 0) {- rootEntries.add("skills/");- }-for (const workspace of input.sandboxWorkspaces ?? []) {for (const entry of workspace.rootEntries) {rootEntries.add(entry);diff --git a/packages/eve/src/compiler/workspace-resources.ts b/packages/eve/src/compiler/workspace-resources.tsindex df7f17d09..4c74df156 100644--- a/packages/eve/src/compiler/workspace-resources.ts+++ b/packages/eve/src/compiler/workspace-resources.ts@@ -13,6 +13,8 @@ import { normalizeLogicalPath } from "#discover/filesystem.js";import { normalizeSkillPackage, writeSkillPackageDirectory } from "#shared/skill-package.js";const RESOURCES_DIRECTORY = "workspace-resources";+const RESOURCE_WORKSPACE_DIRECTORY = "workspace";+const RESOURCE_SKILLS_DIRECTORY = "skills";/*** Materializes the per-node workspace resource trees under@@ -58,7 +60,7 @@ export async function materializeWorkspaceResources(input: {function createResourceRoot(manifest: CompiledAgentNodeManifest,nodeId: string,- contentHash: string,+ contentHash: string | undefined,): CompiledWorkspaceResourceRoot {return {contentHash,@@ -75,21 +77,15 @@ async function materializeNode(input: {readonly nodeId: string;readonly resourcesRoot: string;}): Promise<CompiledAgentNodeManifest> {- // Validate up-front so a `skills/`-shadowing workspace doesn't leave- // partial output behind from earlier workspaces in the same node.- for (const workspace of input.manifest.sandboxWorkspaces) {- if (workspace.rootEntries.some((entry) => entry === "skills/" || entry === "skills")) {- throw new Error(- `Sandbox workspace "${workspace.logicalPath}" cannot define "skills" because eve manages that workspace entry.`,- );- }- }-const nodeRoot = join(input.resourcesRoot, input.nodeId);await mkdir(nodeRoot, { recursive: true });+ const workspaceRoot = join(nodeRoot, RESOURCE_WORKSPACE_DIRECTORY);for (const workspace of input.manifest.sandboxWorkspaces) {- await cp(workspace.sourcePath, nodeRoot, { recursive: true });+ await copyDirectoryContents({+ sourcePath: workspace.sourcePath,+ targetPath: workspaceRoot,+ });}for (const skill of input.manifest.skills) {@@ -109,7 +105,7 @@ async function materializeSkill(input: {readonly nodeRoot: string;readonly skill: CompiledSkillDefinition;}): Promise<void> {- const skillRoot = join(input.nodeRoot, "skills", input.skill.name);+ const skillRoot = join(input.nodeRoot, RESOURCE_SKILLS_DIRECTORY, input.skill.name);if (input.skill.sourceKind === "skill-package") {await cp(input.skill.rootPath, skillRoot, { recursive: true });@@ -127,13 +123,37 @@ function stripSkillPackageFiles(skill: CompiledSkillDefinition): CompiledSkillDereturn manifestSkill;}-async function hashWorkspaceResourceRoot(rootPath: string): Promise<string> {+async function copyDirectoryContents(input: {+ readonly sourcePath: string;+ readonly targetPath: string;+}): Promise<void> {+ const entries = await readdir(input.sourcePath, {+ withFileTypes: true,+ });++ await mkdir(input.targetPath, { recursive: true });+ for (const entry of entries) {+ if (!entry.isDirectory() && !entry.isFile()) {+ continue;+ }++ await cp(join(input.sourcePath, entry.name), join(input.targetPath, entry.name), {+ recursive: true,+ });+ }+}++async function hashWorkspaceResourceRoot(rootPath: string): Promise<string | undefined> {const files = await listWorkspaceResourceFiles({logicalDirectoryPath: ".",sourceDirectoryPath: rootPath,});files.sort((left, right) => left.logicalPath.localeCompare(right.logicalPath));+ if (files.length === 0) {+ return undefined;+ }+const hash = createHash("sha256");hash.update("eve-workspace-resource-root-v1\0");diff --git a/packages/eve/src/context/dynamic-skill-lifecycle.test.ts b/packages/eve/src/context/dynamic-skill-lifecycle.test.tsindex 9e0f75992..6c30c715f 100644--- a/packages/eve/src/context/dynamic-skill-lifecycle.test.ts+++ b/packages/eve/src/context/dynamic-skill-lifecycle.test.ts@@ -13,6 +13,8 @@ import { BundleKey, type CompiledBundle } from "#runtime/sessions/runtime-conteximport type { ResolvedDynamicSkillResolver } from "#runtime/types.js";import type { SkillPackageDefinition } from "#shared/skill-definition.js";+const HOME_PROBE_COMMAND = `printf '%s\\n' "$HOME"`;+function createMockBundle(authoredSkillNames: readonly string[] = []): CompiledBundle {return {adapterRegistry: undefined as never,@@ -33,7 +35,11 @@ function createMockBundle(authoredSkillNames: readonly string[] = []): CompiledBfunction createCtx(authoredSkillNames: readonly string[] = []) {const ctx = new ContextContainer();- const sandbox = mockSandbox();+ const sandbox = mockSandbox({+ commands: {+ [HOME_PROBE_COMMAND]: { exitCode: 0, stderr: "", stdout: "/home/agent\n" },+ },+ });ctx.set(SessionIdKey, "test-session");ctx.set(SandboxKey, sandbox.access);ctx.set(BundleKey, createMockBundle(authoredSkillNames));@@ -74,7 +80,7 @@ function makeSkill(description: string, markdown = description): SkillPackageDefdescribe("dispatchDynamicSkillEvent", () => {it("clears removed dynamic skills from the durable announcement", async () => {- const { ctx } = createCtx();+ const { ctx, sandbox } = createCtx();let enabled = true;const resolver = createResolver("tenant", () =>enabled ? makeSkill("Tenant policy", "Follow tenant policy.") : null,@@ -102,6 +108,7 @@ describe("dispatchDynamicSkillEvent", () => {expect(ctx.get(DynamicSkillManifestKey)).toEqual({});expect(ctx.get(PendingSkillAnnouncementKey)).toBe("");+ expect(sandbox.removedPaths).toEqual(["/home/agent/.agents/skills/tenant"]);});it("keeps remaining dynamic skills in the announcement when one resolver removes its skill", async () => {@@ -149,7 +156,9 @@ describe("dispatchDynamicSkillEvent", () => {custom: [{ description: "Talk like a dog", name: "talk-like-a-dog" }],});expect(ctx.get(PendingSkillAnnouncementKey)).toContain("talk-like-a-dog: Talk like a dog");- expect(sandbox.writes.some((w) => w.path.includes("/skills/talk-like-a-dog/"))).toBe(true);+ expect(+ sandbox.writes.some((w) => w.path.includes("/home/agent/.agents/skills/talk-like-a-dog/")),+ ).toBe(true);});it("lets a dynamic skill override a same-named authored skill instead of throwing", async () => {@@ -169,9 +178,11 @@ describe("dispatchDynamicSkillEvent", () => {expect(ctx.get(DynamicSkillManifestKey)).toEqual({custom: [{ description: "Dynamic override", name: "talk-like-a-dog" }],});- expect(sandbox.writes.some((w) => w.path.includes("/skills/talk-like-a-dog/SKILL.md"))).toBe(- true,- );+ expect(+ sandbox.writes.some((w) =>+ w.path.includes("/home/agent/.agents/skills/talk-like-a-dog/SKILL.md"),+ ),+ ).toBe(true);});it("collapses a directly-returned single defineSkill to the bare slug", async () => {@@ -188,7 +199,9 @@ describe("dispatchDynamicSkillEvent", () => {expect(ctx.get(DynamicSkillManifestKey)).toEqual({tenant: [{ description: "Tenant policy", name: "tenant" }],});- expect(sandbox.writes.some((w) => w.path.includes("/skills/tenant/"))).toBe(true);+ expect(sandbox.writes.some((w) => w.path.includes("/home/agent/.agents/skills/tenant/"))).toBe(+ true,+ );});it("throws and recommends manual namespacing when two resolvers emit the same name", async () => {diff --git a/packages/eve/src/context/dynamic-skill-lifecycle.ts b/packages/eve/src/context/dynamic-skill-lifecycle.tsindex b451c899e..25875c69d 100644--- a/packages/eve/src/context/dynamic-skill-lifecycle.ts+++ b/packages/eve/src/context/dynamic-skill-lifecycle.ts@@ -8,6 +8,7 @@ import type { SkillPackageDefinition } from "#shared/skill-definition.js";import {type MaterializableSkillPackage,normalizeSkillPackage,+ removeSkillPackageFromSandbox,writeSkillPackageToSandbox,} from "#shared/skill-package.js";import type { HandleMessageStreamEvent } from "#protocol/message.js";@@ -22,6 +23,7 @@ import {SandboxKey,} from "#context/keys.js";import { buildResolveContext } from "#context/dynamic-resolve-context.js";+import { resolveSandboxSkillRoot } from "#shared/skill-paths.js";const log = createLogger("dynamic-skills");@@ -62,10 +64,13 @@ interface DynamicSkillResolution {readonly named: readonly { name: string; entry: SkillPackageDefinition }[];}-function formatDynamicSkillAnnouncement(- manifest: Readonly<Record<string, readonly DurableDynamicSkillMetadata[]>>,-): string {- return formatAvailableSkillsSection(Object.values(manifest).flat()) ?? "";+async function formatDynamicSkillAnnouncement(input: {+ readonly ctx: ContextContainer;+ readonly manifest: Readonly<Record<string, readonly DurableDynamicSkillMetadata[]>>;+}): Promise<string> {+ const sandbox = await input.ctx.require(SandboxKey).get();+ const skillRoot = sandbox === null ? undefined : await resolveSandboxSkillRoot({ sandbox });+ return formatAvailableSkillsSection(Object.values(input.manifest).flat(), { skillRoot }) ?? "";}// ---------------------------------------------------------------------------@@ -110,7 +115,10 @@ export async function dispatchDynamicSkillEvent(input: {if (ctx.get(PendingSkillAnnouncementKey) === undefined) {const manifest = ctx.get(DynamicSkillManifestKey);if (manifest !== undefined && Object.keys(manifest).length > 0) {- ctx.setVirtualContext(PendingSkillAnnouncementKey, formatDynamicSkillAnnouncement(manifest));+ ctx.setVirtualContext(+ PendingSkillAnnouncementKey,+ await formatDynamicSkillAnnouncement({ ctx, manifest }),+ );}}@@ -196,6 +204,25 @@ export async function dispatchDynamicSkillEvent(input: {const sandbox = await ctx.require(SandboxKey).get();if (sandbox !== null) {+ const finalDynamicSkillNames = new Set(+ Object.values(newManifest)+ .flat()+ .map((skill) => skill.name),+ );+ const removedSkillNames = new Set<string>();++ for (const { resolver } of updates) {+ for (const skill of manifest[resolver.slug] ?? []) {+ if (!finalDynamicSkillNames.has(skill.name)) {+ removedSkillNames.add(skill.name);+ }+ }+ }++ for (const name of removedSkillNames) {+ await removeSkillPackageFromSandbox({ name, sandbox });+ }+for (const { skills } of updates) {for (const skill of skills) {await writeSkillPackageToSandbox({ sandbox, skill });@@ -204,5 +231,8 @@ export async function dispatchDynamicSkillEvent(input: {}ctx.set(DynamicSkillManifestKey, newManifest);- ctx.setVirtualContext(PendingSkillAnnouncementKey, formatDynamicSkillAnnouncement(newManifest));+ ctx.setVirtualContext(+ PendingSkillAnnouncementKey,+ await formatDynamicSkillAnnouncement({ ctx, manifest: newManifest }),+ );}diff --git a/packages/eve/src/discover/sandbox.integration.test.ts b/packages/eve/src/discover/sandbox.integration.test.tsindex 7d474e97f..68551cd97 100644--- a/packages/eve/src/discover/sandbox.integration.test.ts+++ b/packages/eve/src/discover/sandbox.integration.test.ts@@ -6,11 +6,7 @@ import {DISCOVER_SANDBOX_DIRECTORY_INVALID,readSortedDirectoryEntries,} from "#discover/grammar.js";-import {- DISCOVER_SANDBOX_FOLDER_EMPTY,- DISCOVER_SANDBOX_WORKSPACE_SKILLS_RESERVED,- discoverSandboxSource,-} from "#discover/sandbox.js";+import { DISCOVER_SANDBOX_FOLDER_EMPTY, discoverSandboxSource } from "#discover/sandbox.js";describe("discoverSandboxSource (memory)", () => {it("returns no entries when the agent has no sandbox/ folder", async () => {@@ -147,7 +143,7 @@ describe("discoverSandboxSource (memory)", () => {expect(result.sandboxWorkspace).toBeNull();});- it("reports DISCOVER_SANDBOX_WORKSPACE_SKILLS_RESERVED when workspace/ contains a skills/ subtree", async () => {+ it("allows workspace/ to contain a skills/ subtree", async () => {const project = buildMemoryAgentProject({agentFiles: {"sandbox/workspace/skills/shadow.md": "shadowed",@@ -161,10 +157,8 @@ describe("discoverSandboxSource (memory)", () => {source: project.source,});- expect(result.diagnostics.map((diagnostic) => diagnostic.code)).toContain(- DISCOVER_SANDBOX_WORKSPACE_SKILLS_RESERVED,- );- expect(result.sandboxWorkspace).toBeNull();+ expect(result.diagnostics).toEqual([]);+ expect(result.sandboxWorkspace?.rootEntries).toEqual(["skills/"]);});it("discovers a top-level sandbox.<ext> when no sandbox/ folder exists", async () => {diff --git a/packages/eve/src/discover/sandbox.ts b/packages/eve/src/discover/sandbox.tsindex 20f712b02..ec03bc830 100644--- a/packages/eve/src/discover/sandbox.ts+++ b/packages/eve/src/discover/sandbox.ts@@ -33,14 +33,6 @@ const SANDBOX_WORKSPACE_DIRECTORY_NAME = "workspace";*/const SANDBOX_DEFINITION_BASE_NAME = "sandbox";-/**- * Discovery diagnostic emitted when the `sandbox/` folder contains an- * authored `workspace/skills/` subtree, which is reserved for the- * framework's skill discovery.- */-export const DISCOVER_SANDBOX_WORKSPACE_SKILLS_RESERVED =- "discover/sandbox-workspace-skills-reserved";-/*** Discovery diagnostic emitted when the `sandbox/` folder exists but* contains neither a `sandbox.<ext>` module nor a `workspace/`@@ -158,21 +150,13 @@ export async function discoverSandboxSource(input: {join(SANDBOX_DIRECTORY_NAME, SANDBOX_WORKSPACE_DIRECTORY_NAME),);- const reservedSkillsDiagnostic = await checkWorkspaceSkillsReservation(- input.source,- workspacePath,- );- if (reservedSkillsDiagnostic !== null) {- diagnostics.push(reservedSkillsDiagnostic);- } else {- const rootEntries = await collectWorkspaceRootEntries(input.source, workspacePath);- sandboxWorkspace = {- logicalPath: workspaceLogicalPath,- rootEntries,- sourceId: createPathDerivedSourceId(workspaceLogicalPath),- sourcePath: workspacePath,- };- }+ const rootEntries = await collectWorkspaceRootEntries(input.source, workspacePath);+ sandboxWorkspace = {+ logicalPath: workspaceLogicalPath,+ rootEntries,+ sourceId: createPathDerivedSourceId(workspaceLogicalPath),+ sourcePath: workspacePath,+ };}return {@@ -282,28 +266,3 @@ async function collectWorkspaceRootEntries(return rendered;}--/**- * Returns a diagnostic when the sandbox workspace folder declares a- * `skills/` subtree, since that path is reserved for the framework's- * skill discovery.- */-async function checkWorkspaceSkillsReservation(- source: ProjectSource,- workspacePath: string,-): Promise<DiscoverDiagnostic | null> {- const entries = await readSortedDirectoryEntries(source, workspacePath);- const skillsEntry = entries.find((entry) => entry.name === "skills");-- if (skillsEntry === undefined) {- return null;- }-- return createDiscoverErrorDiagnostic({- code: DISCOVER_SANDBOX_WORKSPACE_SKILLS_RESERVED,- message:- `"sandbox/workspace/skills/" is reserved for the framework skill discovery. ` +- `Move skill files under "agent/skills/" instead, or rename the subtree.`,- sourcePath: join(workspacePath, "skills"),- });-}diff --git a/packages/eve/src/execution/sandbox/bindings/local-backend-utils.ts b/packages/eve/src/execution/sandbox/bindings/local-backend-utils.tsindex b90e9e026..bf436bd3b 100644--- a/packages/eve/src/execution/sandbox/bindings/local-backend-utils.ts+++ b/packages/eve/src/execution/sandbox/bindings/local-backend-utils.ts@@ -4,6 +4,7 @@ import { dirname, join } from "node:path";import { bufferToStream, streamToBuffer } from "#execution/sandbox/stream-utils.js";import { WORKSPACE_ROOT } from "#runtime/workspace/types.js";+import { resolveSandboxSeedFilePath } from "#shared/skill-paths.js";import type { SandboxSeedFile } from "#shared/sandbox-backend.js";import type {InternalSandboxSession,@@ -111,14 +112,19 @@ export function resolveLocalBackendSessionRootPath(}export async function writeSandboxSeedFiles(- session: Pick<SandboxSession, "writeBinaryFile" | "writeTextFile">,+ session: SandboxSession,seedFiles: ReadonlyArray<SandboxSeedFile>,): Promise<void> {for (const file of seedFiles) {+ const path = await resolveSandboxSeedFilePath({+ path: file.path,+ sandbox: session,+ });+if (typeof file.content === "string") {- await session.writeTextFile({ content: file.content, path: file.path });+ await session.writeTextFile({ content: file.content, path });} else {- await session.writeBinaryFile({ content: file.content, path: file.path });+ await session.writeBinaryFile({ content: file.content, path });}}}diff --git a/packages/eve/src/execution/sandbox/bindings/vercel.ts b/packages/eve/src/execution/sandbox/bindings/vercel.tsindex afb1b0d07..0f4c0ca7f 100644--- a/packages/eve/src/execution/sandbox/bindings/vercel.ts+++ b/packages/eve/src/execution/sandbox/bindings/vercel.ts@@ -42,6 +42,7 @@ import {} from "#execution/sandbox/bindings/vercel-errors.js";import { getNamedVercelSandbox } from "#execution/sandbox/bindings/vercel-lookup.js";import { normalizeVercelReadStream } from "#execution/sandbox/bindings/vercel-read-stream.js";+import { writeSandboxSeedFiles } from "#execution/sandbox/bindings/local-backend-utils.js";import type {VercelCreateOptions,VercelModule,@@ -334,13 +335,7 @@ async function ensureTemplate(input: EnsureTemplateInput): Promise<EnsureTemplat});}- for (const file of input.seedFiles) {- if (typeof file.content === "string") {- await templateSession.writeTextFile({ content: file.content, path: file.path });- } else {- await templateSession.writeBinaryFile({ content: file.content, path: file.path });- }- }+ await writeSandboxSeedFiles(templateSession, input.seedFiles);const snapshot = await sandbox.snapshot();return {diff --git a/packages/eve/src/execution/sandbox/ensure.test.ts b/packages/eve/src/execution/sandbox/ensure.test.tsindex 544ceeb22..73979a3e9 100644--- a/packages/eve/src/execution/sandbox/ensure.test.ts+++ b/packages/eve/src/execution/sandbox/ensure.test.ts@@ -60,7 +60,7 @@ function createTestRegistry(return {sandbox: {definition: resolved,- workspaceResourceRoot: { contentHash: "test-content-hash", logicalPath: "", rootEntries: [] },+ workspaceResourceRoot: { logicalPath: "", rootEntries: [] },},};}diff --git a/packages/eve/src/execution/sandbox/prewarm.scenario.test.ts b/packages/eve/src/execution/sandbox/prewarm.scenario.test.tsindex f88b1fdd0..6903fc439 100644--- a/packages/eve/src/execution/sandbox/prewarm.scenario.test.ts+++ b/packages/eve/src/execution/sandbox/prewarm.scenario.test.ts@@ -46,8 +46,8 @@ describe("prewarmAppSandboxes", () => {expect(events.templateKeys).toHaveLength(2);expect(events.seededTemplateCount).toBe(2);expect([...events.seededFilePaths].sort()).toEqual([- "/workspace/skills/research/SKILL.md",- "/workspace/skills/route-weather/SKILL.md",+ "$HOME/.agents/skills/research/SKILL.md",+ "$HOME/.agents/skills/route-weather/SKILL.md",]);expect([...events.bootstrapCommands].sort()).toEqual(["echo child-bootstrap",@@ -78,8 +78,8 @@ describe("prewarmAppSandboxes", () => {expect(new Set(events.runtimeContextAppRoots)).toEqual(new Set([appRoot]));expect(events.seededTemplateCount).toBe(2);expect([...events.seededFilePaths].sort()).toEqual([- "/workspace/skills/research/SKILL.md",- "/workspace/skills/route-weather/SKILL.md",+ "$HOME/.agents/skills/research/SKILL.md",+ "$HOME/.agents/skills/route-weather/SKILL.md",]);});@@ -219,7 +219,7 @@ describe("prewarmAppSandboxes", () => {expect(firstEvents.templateKeys).toHaveLength(1);expect(secondEvents.templateKeys).toEqual(firstEvents.templateKeys);expect(changedEvents.templateKeys[0]).not.toBe(firstEvents.templateKeys[0]);- expect(firstEvents.seededFilePaths).toEqual(["/workspace/skills/route-weather/SKILL.md"]);+ expect(firstEvents.seededFilePaths).toEqual(["$HOME/.agents/skills/route-weather/SKILL.md"]);});it("uses compiled bootstrap revalidation keys across deploy roots without re-evaluating at prewarm", async () => {@@ -441,8 +441,8 @@ describe("prewarmAppSandboxes", () => {expect(events.seededTemplateCount).toBe(1);expect([...events.seededFilePaths].sort()).toEqual([- "/workspace/skills/route-weather/SKILL.md",- "/workspace/skills/route-weather/references/checklist.md",+ "$HOME/.agents/skills/route-weather/SKILL.md",+ "$HOME/.agents/skills/route-weather/references/checklist.md",].sort(),);expect([...events.bootstrapCommands]).toEqual(["echo default-bootstrap"]);diff --git a/packages/eve/src/execution/sandbox/prewarm.test.ts b/packages/eve/src/execution/sandbox/prewarm.test.tsindex 6fb620ab2..182029f31 100644--- a/packages/eve/src/execution/sandbox/prewarm.test.ts+++ b/packages/eve/src/execution/sandbox/prewarm.test.ts@@ -14,6 +14,9 @@ vi.mock("#execution/sandbox/template-prewarm-lock.js", () => ({withSandboxTemplatePrewarmLock: async (_input: unknown, callback: () => Promise<unknown>) =>await callback(),}));+vi.mock("#runtime/workspace/seed-files.js", () => ({+ materializeWorkspaceDirectory: vi.fn(async () => []),+}));describe("prewarmAppSandboxes", () => {afterEach(() => {@@ -26,6 +29,11 @@ describe("prewarmAppSandboxes", () => {const secondSnapshotRoot = `${appRoot}/.eve/dev-runtime/snapshots/two/app`;const firstInputs: SandboxBackendPrewarmInput[] = [];const secondInputs: SandboxBackendPrewarmInput[] = [];+ const workspaceResourceRoot = {+ contentHash: "workspace-content-hash",+ logicalPath: "empty-resource-root",+ rootEntries: [],+ };await prewarmAppSandboxes({appRoot,@@ -34,7 +42,7 @@ describe("prewarmAppSandboxes", () => {sandboxAppRoot: appRoot,}),dispatch: recordPrewarmInputs(firstInputs),- loadAgentGraph: async () => createGraph(),+ loadAgentGraph: async () => createGraph({ workspaceResourceRoot }),});await prewarmAppSandboxes({appRoot,@@ -43,7 +51,7 @@ describe("prewarmAppSandboxes", () => {sandboxAppRoot: appRoot,}),dispatch: recordPrewarmInputs(secondInputs),- loadAgentGraph: async () => createGraph(),+ loadAgentGraph: async () => createGraph({ workspaceResourceRoot }),});expect(firstInputs).toHaveLength(1);@@ -89,7 +97,7 @@ describe("prewarmAppSandboxes", () => {dispatch: async () => {throw cause;},- loadAgentGraph: async () => createGraph(backendName),+ loadAgentGraph: async () => createGraph({ backendName }),log,}),).rejects.toMatchObject({@@ -126,12 +134,21 @@ function recordPrewarmInputs(inputs: SandboxBackendPrewarmInput[]) {};}-function createGraph(backendName = "test"): ResolvedAgentGraphBundle {+function createGraph(+ input: {+ readonly backendName?: string;+ readonly workspaceResourceRoot?: {+ readonly contentHash?: string;+ readonly logicalPath: string;+ readonly rootEntries: readonly string[];+ };+ } = {},+): ResolvedAgentGraphBundle {const backend: SandboxBackend = {async create() {throw new Error("Unexpected create call.");},- name: backendName,+ name: input.backendName ?? "test",async prewarm() {return { reused: true };},@@ -150,8 +167,7 @@ function createGraph(backendName = "test"): ResolvedAgentGraphBundle {sandboxRegistry: {sandbox: {definition,- workspaceResourceRoot: {- contentHash: "workspace-content-hash",+ workspaceResourceRoot: input.workspaceResourceRoot ?? {logicalPath: "",rootEntries: [],},diff --git a/packages/eve/src/execution/sandbox/prewarm.ts b/packages/eve/src/execution/sandbox/prewarm.tsindex 41dfa411c..db16a5c29 100644--- a/packages/eve/src/execution/sandbox/prewarm.ts+++ b/packages/eve/src/execution/sandbox/prewarm.ts@@ -288,7 +288,10 @@ async function loadResourceRootSeedFiles(input: {readonly compileDirectoryPath: string;readonly workspaceResourceRoot: CompiledWorkspaceResourceRoot;}): Promise<readonly SandboxSeedFile[]> {- if (input.workspaceResourceRoot.rootEntries.length === 0) {+ if (+ input.workspaceResourceRoot.contentHash === undefined &&+ input.workspaceResourceRoot.rootEntries.length === 0+ ) {return [];}const materialized = await materializeWorkspaceDirectory(diff --git a/packages/eve/src/execution/session.test.ts b/packages/eve/src/execution/session.test.tsindex 675faaa4a..72ad7af1c 100644--- a/packages/eve/src/execution/session.test.ts+++ b/packages/eve/src/execution/session.test.ts@@ -97,6 +97,26 @@ describe("createSession", () => {]);});+ it("renders available skill paths with the chosen skill root", () => {+ const session = createSession({+ continuationToken: "root-token",+ sessionId: "sess-root",+ skillRoot: "/home/agent/.agents/skills",+ turnAgent: createTestTurnAgent({+ availableSkills: [{ description: "Research topics.", name: "research" }],+ }),+ });++ expect(session.agent.system).toContain(+ "Skill files live under `/home/agent/.agents/skills/<skill>/`.",+ );+ expect(session.agent.system).toContain(+ "- research: Research topics. (path: /home/agent/.agents/skills/research/SKILL.md)",+ );+ expect(session.agent.system).not.toContain("/workspace/skills");+ expect(session.agent.system).not.toContain("fallback");+ });+it("starts with empty history and stores the continuation token verbatim", () => {const session = createSession({continuationToken: "root-token",@@ -459,4 +479,30 @@ describe("refreshSessionFromTurnAgent", () => {});expect(refreshed.agent.system).toBe("Updated prompt from the current deployment.");});++ it("refreshes available skill paths with the chosen skill root", () => {+ const session = createSession({+ continuationToken: "root-token",+ sessionId: "sess-root",+ turnAgent: createTestTurnAgent({+ availableSkills: [{ description: "Research topics.", name: "research" }],+ }),+ });+ const refreshed = refreshSessionFromTurnAgent({+ session,+ skillRoot: "/workspace/skills",+ turnAgent: createTestTurnAgent({+ availableSkills: [{ description: "Research topics.", name: "research" }],+ }),+ });++ expect(refreshed.agent.system).toContain(+ "Skill files live under `/workspace/skills/<skill>/`.",+ );+ expect(refreshed.agent.system).toContain(+ "- research: Research topics. (path: /workspace/skills/research/SKILL.md)",+ );+ expect(refreshed.agent.system).not.toContain("$HOME");+ expect(refreshed.agent.system).not.toContain("fallback");+ });});diff --git a/packages/eve/src/execution/session.ts b/packages/eve/src/execution/session.tsindex ea69f1d15..174691d8f 100644--- a/packages/eve/src/execution/session.ts+++ b/packages/eve/src/execution/session.ts@@ -1,4 +1,5 @@import type { DurableSession } from "#execution/durable-session-store.js";+import { formatAvailableSkillsSection } from "#execution/skills/instructions.js";import type { HarnessSession, SessionLimits, SessionToolDefinition } from "#harness/types.js";import type { RuntimeTurnAgent } from "#runtime/agent/bootstrap.js";@@ -56,6 +57,7 @@ export interface CreateSessionInput {readonly turnAgent: RuntimeTurnAgent;readonly limits?: SessionLimits;readonly outputSchema?: HarnessSession["outputSchema"];+ readonly skillRoot?: string;readonly subagentDepth?: number;readonly subagentMaxDepth?: number;}@@ -72,7 +74,10 @@ export function createSession(input: CreateSessionInput): HarnessSession {compactionModelReference: turnAgent.compactionModel,modelReference: turnAgent.model,reasoning: turnAgent.reasoning,- system: turnAgent.instructions.join("\n\n"),+ system: createSessionSystemPrompt({+ skillRoot: input.skillRoot,+ turnAgent,+ }),tools,},compaction: createCompactionConfig({@@ -112,6 +117,7 @@ export function refreshSessionFromTurnAgent(input: {readonly compactionOverrides?: {readonly thresholdPercent?: number;};+ readonly skillRoot?: string;}): HarnessSession {return {...input.session,@@ -119,7 +125,10 @@ export function refreshSessionFromTurnAgent(input: {compactionModelReference: input.turnAgent.compactionModel,modelReference: input.turnAgent.model,reasoning: input.turnAgent.reasoning,- system: input.turnAgent.instructions.join("\n\n"),+ system: createSessionSystemPrompt({+ skillRoot: input.skillRoot,+ turnAgent: input.turnAgent,+ }),tools: createSessionToolDefinitions(input.turnAgent),},compaction: createCompactionConfig({@@ -131,6 +140,20 @@ export function refreshSessionFromTurnAgent(input: {};}+function createSessionSystemPrompt(input: {+ readonly skillRoot?: string;+ readonly turnAgent: RuntimeTurnAgent;+}): string {+ const skillSection = formatAvailableSkillsSection(input.turnAgent.availableSkills ?? [], {+ skillRoot: input.skillRoot,+ });+ const blocks =+ skillSection === null+ ? input.turnAgent.instructions+ : [...input.turnAgent.instructions, skillSection];+ return blocks.join("\n\n");+}+/*** Mints a continuation token for a delegated subagent session.* Deterministic when `suffix` is provided so retries address the samediff --git a/packages/eve/src/execution/skills/instructions.test.ts b/packages/eve/src/execution/skills/instructions.test.tsindex fc0ab4600..f8c5d571a 100644--- a/packages/eve/src/execution/skills/instructions.test.ts+++ b/packages/eve/src/execution/skills/instructions.test.ts@@ -37,23 +37,31 @@ describe("formatAvailableSkillsSection", () => {expect(result).toContain("If multiple skills match, activate the minimal set that covers the task.",);- expect(result).toContain("Packaged sibling files under a skill path can be inspected");expect(result).toContain(- "- test-skill: A test skill (path: /workspace/skills/test-skill/SKILL.md)",+ "Skill files are available after load_skill resolves the active sandbox skill location.",);+ expect(result).toContain(+ "resolve them relative to the directory containing that specific SKILL.md",+ );+ expect(result).toContain("- test-skill: A test skill");+ expect(result).not.toContain("/workspace/skills");});- it("formats skill line with name and description", () => {+ it("formats skill line with the resolved skill root", () => {const skill = createTestSkill({logicalPath: "skills/my-skill/SKILL.md",name: "my-skill",});- const result = formatAvailableSkillsSection([skill]);+ const result = formatAvailableSkillsSection([skill], {+ skillRoot: "/home/agent/.agents/skills",+ });+ expect(result).toContain("Skill files live under `/home/agent/.agents/skills/<skill>/`.");expect(result).toContain(- "- my-skill: A test skill (path: /workspace/skills/my-skill/SKILL.md)",+ "- my-skill: A test skill (path: /home/agent/.agents/skills/my-skill/SKILL.md)",);+ expect(result).not.toContain("fallback");});it("always lists all skills in the menu regardless of activation state", () => {@@ -63,12 +71,8 @@ describe("formatAvailableSkillsSection", () => {const result = formatAvailableSkillsSection([s1, s2]);expect(result).toContain("Available skills");- expect(result).toContain(- "- skill-one: A test skill (path: /workspace/skills/skill-one/SKILL.md)",- );- expect(result).toContain(- "- skill-two: A test skill (path: /workspace/skills/skill-two/SKILL.md)",- );+ expect(result).toContain("- skill-one: A test skill");+ expect(result).toContain("- skill-two: A test skill");});it("never includes active skill markdown content", () => {@@ -77,9 +81,7 @@ describe("formatAvailableSkillsSection", () => {const result = formatAvailableSkillsSection([skill]);expect(result).toContain("Available skills");- expect(result).toContain(- "- test-skill: A test skill (path: /workspace/skills/test-skill/SKILL.md)",- );+ expect(result).toContain("- test-skill: A test skill");expect(result).not.toContain("Skill (test-skill)");expect(result).not.toContain("# Full Instructions");});diff --git a/packages/eve/src/execution/skills/instructions.ts b/packages/eve/src/execution/skills/instructions.tsindex 7797f9250..c1149eebd 100644--- a/packages/eve/src/execution/skills/instructions.ts+++ b/packages/eve/src/execution/skills/instructions.ts@@ -1,17 +1,20 @@-import { WORKSPACE_ROOT } from "#runtime/workspace/types.js";--interface AvailableSkillDescription {+export interface AvailableSkillDescription {readonly description: string;readonly name: string;}+interface FormatAvailableSkillsSectionOptions {+ readonly skillRoot?: string;+}+/*** Formats the "Available skills" system prompt section.** All skills are always listed regardless of activation state. Active skill* instructions are never injected into the system prompt — the model already- * has them from the `load_skill` tool result. This keeps the system- * prompt identical across the entire session, preserving prompt caching.+ * has them from the `load_skill` tool result. The caller may pass the active+ * sandbox skill root so the model sees only the location that eve selected+ * for this run.** Authored skills call this at graph resolution time so the section is* part of the turn agent's static instructions. Dynamic skills@@ -20,6 +23,7 @@ interface AvailableSkillDescription {*/export function formatAvailableSkillsSection(skills: readonly AvailableSkillDescription[],+ options: FormatAvailableSkillsSectionOptions = {},): string | null {if (skills.length === 0) {return null;@@ -30,13 +34,32 @@ export function formatAvailableSkillsSection("Listed skills are available in this run. Do not claim a listed skill is inaccessible unless activation or workspace inspection actually fails.","If the user names a skill or the request clearly matches one of the descriptions below, call load_skill before proceeding.","If multiple skills match, activate the minimal set that covers the task. After activation, follow the returned instructions instead of improvising around them.",- "If activation fails, say so briefly and continue with the best fallback. Packaged sibling files under a skill path can be inspected with bash or read_file when needed.",- ...skills.map((skill) => formatAvailableSkillLine(skill)),+ "If activation fails, say so briefly and continue with the best available alternative.",+ formatSkillLocationLine(options),+ "When a loaded SKILL.md mentions sibling files such as `references/foo.md`, resolve them relative to the directory containing that specific SKILL.md.",+ ...skills.map((skill) => formatAvailableSkillLine({ skill, skillRoot: options.skillRoot })),];return lines.join("\n");}-function formatAvailableSkillLine(skill: AvailableSkillDescription): string {- return `- ${skill.name}: ${skill.description} (path: ${WORKSPACE_ROOT}/skills/${skill.name}/SKILL.md)`;+function formatSkillLocationLine(options: FormatAvailableSkillsSectionOptions): string {+ if (options.skillRoot === undefined) {+ return "Skill files are available after load_skill resolves the active sandbox skill location.";+ }++ return `Skill files live under \`${options.skillRoot}/<skill>/\`.`;+}++function formatAvailableSkillLine(input: {+ readonly skill: AvailableSkillDescription;+ readonly skillRoot?: string;+}): string {+ const prefix = `- ${input.skill.name}: ${input.skill.description}`;++ if (input.skillRoot === undefined) {+ return prefix;+ }++ return `${prefix} (path: ${input.skillRoot}/${input.skill.name}/SKILL.md)`;}diff --git a/packages/eve/src/execution/workflow-skill-root.ts b/packages/eve/src/execution/workflow-skill-root.tsnew file mode 100644index 000000000..8b71748df--- /dev/null+++ b/packages/eve/src/execution/workflow-skill-root.ts@@ -0,0 +1,25 @@+import type { ContextContainer } from "#context/container.js";+import { SandboxKey } from "#context/keys.js";+import type { RuntimeTurnAgent } from "#runtime/agent/bootstrap.js";+import { resolveSandboxSkillRoot } from "#shared/skill-paths.js";++export async function resolveSessionSkillRoot(input: {+ readonly ctx: ContextContainer;+ readonly turnAgent: RuntimeTurnAgent;+}): Promise<string | undefined> {+ if ((input.turnAgent.availableSkills?.length ?? 0) === 0) {+ return undefined;+ }++ const access = input.ctx.get(SandboxKey);+ if (access === undefined) {+ return undefined;+ }++ const sandbox = await access.get();+ if (sandbox === null) {+ return undefined;+ }++ return await resolveSandboxSkillRoot({ sandbox });+}diff --git a/packages/eve/src/execution/workflow-steps.ts b/packages/eve/src/execution/workflow-steps.tsindex 1a8c82f7d..2eafd2b46 100644--- a/packages/eve/src/execution/workflow-steps.ts+++ b/packages/eve/src/execution/workflow-steps.ts@@ -64,6 +64,7 @@ import { recordSubagentUsageSpans } from "#execution/subagent-usage-span.js";import { hydrateDurableSession, refreshSessionFromTurnAgent } from "#execution/session.js";import { buildTurnAttributes, readRootSessionId } from "#execution/eve-workflow-attributes.js";import { normalizeEveAttributes } from "#runtime/attributes/normalize.js";+import { resolveSessionSkillRoot } from "#execution/workflow-skill-root.js";import {createWorkflowRuntime,startWorkflowPreferLatest,@@ -315,11 +316,16 @@ export async function turnStep(rawInput: TurnStepInput): Promise<DurableStepResulifecycleSession: HarnessSession,stepInput: StepInput | undefined,): Promise<StepResult> => {+ const skillRoot = await resolveSessionSkillRoot({+ ctx,+ turnAgent: bundle.turnAgent,+ });const refreshedSession = refreshSessionFromTurnAgent({compactionOverrides: {thresholdPercent: bundle.resolvedAgent.config.compaction?.thresholdPercent,},session: lifecycleSession,+ skillRoot,turnAgent: bundle.turnAgent,});diff --git a/packages/eve/src/runtime/agent/bootstrap.ts b/packages/eve/src/runtime/agent/bootstrap.tsindex 23939bd5e..35bfd5a64 100644--- a/packages/eve/src/runtime/agent/bootstrap.ts+++ b/packages/eve/src/runtime/agent/bootstrap.ts@@ -3,6 +3,7 @@ import type { PreparedRuntimeTool } from "#runtime/sessions/turn.js";import type { ResolvedAgent } from "#runtime/types.js";import type { WorkspaceRuntimeSpec } from "#runtime/workspace/types.js";import type { InternalAgentModelDefinition } from "#shared/agent-definition.js";+import type { AvailableSkillDescription } from "#execution/skills/instructions.js";/*** Fixed internal model reference used only by the framework-owned bootstrap@@ -19,6 +20,7 @@ export type RuntimeModelReference = Readonly<InternalAgentModelDefinition>;* Minimal runtime-owned agent shape prepared for one harness turn.*/export interface RuntimeTurnAgent {+ readonly availableSkills?: readonly AvailableSkillDescription[];readonly id: string;readonly instructions: readonly string[];/**@@ -52,11 +54,14 @@ export function createResolvedRuntimeTurnAgent(input: {}): RuntimeTurnAgent {const agent = input.agent;return {+ availableSkills: agent.skills.map((skill) => ({+ description: skill.description,+ name: skill.name,+ })),id: agent.config.name,instructions: composeRuntimeBasePrompt({connections: agent.connections,instructions: agent.instructions,- skills: agent.skills,toolsAvailable: input.tools.length > 0,workspaceSpec: agent.workspaceSpec,}),diff --git a/packages/eve/src/runtime/agent/mock-model-adapter.test.ts b/packages/eve/src/runtime/agent/mock-model-adapter.test.tsindex aefe8e49a..2ff2eac28 100644--- a/packages/eve/src/runtime/agent/mock-model-adapter.test.ts+++ b/packages/eve/src/runtime/agent/mock-model-adapter.test.ts@@ -37,13 +37,13 @@ describe("createMockAuthoredRuntimeModel", () => {expect(shouldMockAuthoredRuntimeModels()).toBe(true);});- it("activates a matching skill when the available skill line includes a workspace path", async () => {+ it("activates a matching skill when the available skill line includes a skill path", async () => {const result = await generateWithPrompt([{content: ["Available skills\n","Listed skills are available in this run.\n",- "- weather-skill: Use the weather tool before answering forecast or temperature questions. (path: /workspace/skills/weather-skill/SKILL.md)",+ "- weather-skill: Use the weather tool before answering forecast or temperature questions. (path: /home/agent/.agents/skills/weather-skill/SKILL.md)",].join(""),role: "system",},@@ -70,7 +70,7 @@ describe("createMockAuthoredRuntimeModel", () => {content: ["Available skills\n","Listed skills are available in this run.\n",- "- research: Research unfamiliar topics before answering with confidence. (path: /workspace/skills/research/SKILL.md)",+ "- research: Research unfamiliar topics before answering with confidence. (path: /home/agent/.agents/skills/research/SKILL.md)",].join(""),role: "system",},@@ -95,7 +95,7 @@ describe("createMockAuthoredRuntimeModel", () => {content: ["Available skills\n","Listed skills are available in this run.\n",- "- release: Use for release checklist requests. (path: /workspace/skills/release/SKILL.md)",+ "- release: Use for release checklist requests. (path: /home/agent/.agents/skills/release/SKILL.md)",].join(""),role: "system",},@@ -103,7 +103,7 @@ describe("createMockAuthoredRuntimeModel", () => {content: ["Available skills\n","Listed skills are available in this run.\n",- "- tenant-weather: Use tenant weather policy before answering forecast questions. (path: /workspace/skills/tenant-weather/SKILL.md)",+ "- tenant-weather: Use tenant weather policy before answering forecast questions. (path: /home/agent/.agents/skills/tenant-weather/SKILL.md)",].join(""),role: "system",},@@ -134,7 +134,7 @@ describe("createMockAuthoredRuntimeModel", () => {"","Available skills","Listed skills are available in this run.",- "- echo-marker: Use when the user asks for the echo marker. (path: /workspace/skills/echo-marker/SKILL.md)",+ "- echo-marker: Use when the user asks for the echo marker. (path: /home/agent/.agents/skills/echo-marker/SKILL.md)","","Another section that must not be parsed as skills.",].join("\n"),@@ -163,7 +163,7 @@ describe("createMockAuthoredRuntimeModel", () => {content: ["Available skills","Listed skills are available in this run.",- "- echo-marker: Use when the user asks for the echo marker. (path: /workspace/skills/echo-marker/SKILL.md)",+ "- echo-marker: Use when the user asks for the echo marker. (path: /home/agent/.agents/skills/echo-marker/SKILL.md)",].join("\n"),role: "system",},diff --git a/packages/eve/src/runtime/sandbox/keys.test.ts b/packages/eve/src/runtime/sandbox/keys.test.tsindex 3c7803adf..4f12ccc4d 100644--- a/packages/eve/src/runtime/sandbox/keys.test.ts+++ b/packages/eve/src/runtime/sandbox/keys.test.ts@@ -12,7 +12,7 @@ import { createBundledRuntimeCompiledArtifactsSource } from "#runtime/compiled-aimport { withBundledCompiledArtifacts } from "#runtime/loaders/bundled-artifacts.js";import { createRuntimeSandboxTemplateKey } from "#runtime/sandbox/keys.js";-const RUNTIME_SANDBOX_CONTRACT_VERSION = 6;+const RUNTIME_SANDBOX_CONTRACT_VERSION = 7;const CONTENT_HASH = "a".repeat(64);diff --git a/packages/eve/src/runtime/sandbox/keys.ts b/packages/eve/src/runtime/sandbox/keys.tsindex c1a9e6573..d360ea77b 100644--- a/packages/eve/src/runtime/sandbox/keys.ts+++ b/packages/eve/src/runtime/sandbox/keys.ts@@ -10,9 +10,12 @@ import {import { loadCompileMetadata } from "#runtime/loaders/compile-metadata.js";import type { RuntimeSandboxTemplatePlan } from "#runtime/sandbox/template-plan.js";-// v6: the local backend's default engine moved from just-bash to-// Docker; bumping invalidates just-bash-era template state.-const RUNTIME_SANDBOX_CONTRACT_VERSION = 6;+/*+ * Template keys include this version for sandbox runtime contract changes+ * that are not captured by source or resource hashes. Version 7 writes static+ * skill seed files to the sandbox user's $HOME/.agents/skills directory.+ */+const RUNTIME_SANDBOX_CONTRACT_VERSION = 7;/*** Input for deriving the stable runtime keys used for one sandbox definition.diff --git a/packages/eve/src/runtime/sandbox/template-plan.ts b/packages/eve/src/runtime/sandbox/template-plan.tsindex 740e4222c..729597701 100644--- a/packages/eve/src/runtime/sandbox/template-plan.ts+++ b/packages/eve/src/runtime/sandbox/template-plan.ts@@ -45,7 +45,10 @@ export function createRuntimeSandboxTemplatePlan(input: {};}- if (input.workspaceResourceRoot.rootEntries.length === 0) {+ if (+ input.workspaceResourceRoot.contentHash === undefined &&+ input.workspaceResourceRoot.rootEntries.length === 0+ ) {return { kind: "none" };}diff --git a/packages/eve/src/runtime/skills/sandbox-access.test.ts b/packages/eve/src/runtime/skills/sandbox-access.test.tsindex d6909062c..a70da8aef 100644--- a/packages/eve/src/runtime/skills/sandbox-access.test.ts+++ b/packages/eve/src/runtime/skills/sandbox-access.test.ts@@ -7,6 +7,8 @@ import {} from "#runtime/skills/sandbox-access.js";import { mockSandbox } from "#internal/testing/mocks/mock-sandbox.js";+const HOME_PROBE_COMMAND = `printf '%s\\n' "$HOME"`;+describe("assertSafeSkillId", () => {it("accepts path-derived skill ids", () => {expect(() => assertSafeSkillId("research-skill")).not.toThrow();@@ -23,8 +25,11 @@ describe("assertSafeSkillId", () => {describe("loadSkillFromSandbox", () => {it("reads SKILL.md from the sandbox and strips frontmatter", async () => {const sandbox = mockSandbox({+ commands: {+ [HOME_PROBE_COMMAND]: { exitCode: 0, stderr: "", stdout: "/home/agent\n" },+ },initialFiles: {- "/workspace/skills/research/SKILL.md":+ "/home/agent/.agents/skills/research/SKILL.md":"---\nname: research\ndescription: x\n---\n# Research\n",},});@@ -32,6 +37,31 @@ describe("loadSkillFromSandbox", () => {await expect(loadSkillFromSandbox(sandbox.access, "research")).resolves.toBe("# Research\n");});+ it("does not read an ordinary workspace skills subtree when HOME is usable", async () => {+ const sandbox = mockSandbox({+ commands: {+ [HOME_PROBE_COMMAND]: { exitCode: 0, stderr: "", stdout: "/home/agent\n" },+ },+ initialFiles: {+ "/workspace/skills/research/SKILL.md": "# Research\n",+ },+ });++ await expect(loadSkillFromSandbox(sandbox.access, "research")).rejects.toThrow(+ 'No skill named "research" at /home/agent/.agents/skills/research/SKILL.md.',+ );+ });++ it("reads the legacy workspace skill path when HOME is unavailable", async () => {+ const sandbox = mockSandbox({+ initialFiles: {+ "/workspace/skills/research/SKILL.md": "# Research\n",+ },+ });++ await expect(loadSkillFromSandbox(sandbox.access, "research")).resolves.toBe("# Research\n");+ });+it("throws when the skill is missing", async () => {const sandbox = mockSandbox();@@ -55,8 +85,11 @@ describe("loadSkillFromSandbox", () => {describe("createSandboxSkillHandle", () => {it("reads text and bytes relative to the skill root", async () => {const sandbox = mockSandbox({+ commands: {+ [HOME_PROBE_COMMAND]: { exitCode: 0, stderr: "", stdout: "/home/agent\n" },+ },initialFiles: {- "/workspace/skills/research/references/catalog.yml": "entities: []\n",+ "/home/agent/.agents/skills/research/references/catalog.yml": "entities: []\n",},});const handle = createSandboxSkillHandle(sandbox.access, "research");diff --git a/packages/eve/src/runtime/skills/sandbox-access.ts b/packages/eve/src/runtime/skills/sandbox-access.tsindex 07ae4fc4b..1bb965075 100644--- a/packages/eve/src/runtime/skills/sandbox-access.ts+++ b/packages/eve/src/runtime/skills/sandbox-access.ts@@ -1,13 +1,13 @@import type { SandboxSession } from "#public/definitions/sandbox.js";import type { SandboxAccess } from "#sandbox/state.js";import type { SkillHandle } from "#execution/skills/types.js";-import { WORKSPACE_ROOT } from "#runtime/workspace/types.js";+import { resolveSandboxSkillReadPaths } from "#shared/skill-paths.js";const FRONTMATTER_PATTERN = /^---\r?\n[\s\S]*?\r?\n---\r?\n?/;/*** Validates a skill id before it is used as one path segment under- * `/workspace/skills`.+ * the sandbox skill root.*/export function assertSafeSkillId(id: string): asserts id is string {if (@@ -41,16 +41,21 @@ export async function loadSkillFromSandbox(): Promise<string> {assertSafeSkillId(id);const sandbox = await requireSandboxSession(access);- const path = skillFilePath(id, "SKILL.md");- const instructions = await sandbox.readTextFile({ path });+ const paths = await resolveSandboxSkillReadPaths({+ name: id,+ relativePath: "SKILL.md",+ sandbox,+ });- if (instructions === null) {- const hint =- availableNames.length > 0 ? ` Available skills: ${availableNames.join(", ")}.` : "";- throw new Error(`No skill named "${id}" at ${path}.${hint}`);+ for (const path of paths) {+ const instructions = await sandbox.readTextFile({ path });+ if (instructions !== null) {+ return instructions.replace(FRONTMATTER_PATTERN, "");+ }}- return instructions.replace(FRONTMATTER_PATTERN, "");+ const hint = availableNames.length > 0 ? ` Available skills: ${availableNames.join(", ")}.` : "";+ throw new Error(`No skill named "${id}" at ${paths[0]}.${hint}`);}/**@@ -64,20 +69,41 @@ export function createSandboxSkillHandle(access: SandboxAccess, id: string): Skiname: id,file(relativePath: string) {assertSafeSkillRelativePath(relativePath);- const path = skillFilePath(id, relativePath);return {async bytes(): Promise<Uint8Array> {const sandbox = await requireSandboxSession(access);- const content = await sandbox.readBinaryFile({ path });- if (content === null) throw new Error(`Skill file not found: ${path}`);- return content;+ const paths = await resolveSandboxSkillReadPaths({+ name: id,+ relativePath,+ sandbox,+ });++ for (const path of paths) {+ const content = await sandbox.readBinaryFile({ path });+ if (content !== null) {+ return content;+ }+ }++ throw new Error(`Skill file not found: ${paths[0]}`);},async text(): Promise<string> {const sandbox = await requireSandboxSession(access);- const content = await sandbox.readTextFile({ path });- if (content === null) throw new Error(`Skill file not found: ${path}`);- return content;+ const paths = await resolveSandboxSkillReadPaths({+ name: id,+ relativePath,+ sandbox,+ });++ for (const path of paths) {+ const content = await sandbox.readTextFile({ path });+ if (content !== null) {+ return content;+ }+ }++ throw new Error(`Skill file not found: ${paths[0]}`);},};},@@ -104,7 +130,3 @@ async function requireSandboxSession(access: SandboxAccess): Promise<SandboxSess}return sandbox;}--function skillFilePath(id: string, relativePath: string): string {- return `${WORKSPACE_ROOT}/skills/${id}/${relativePath}`;-}diff --git a/packages/eve/src/runtime/workspace/seed-files.ts b/packages/eve/src/runtime/workspace/seed-files.tsindex e1118b750..af0c91bab 100644--- a/packages/eve/src/runtime/workspace/seed-files.ts+++ b/packages/eve/src/runtime/workspace/seed-files.ts@@ -2,6 +2,10 @@ import { readdir, readFile } from "node:fs/promises";import { join, posix as pathPosix } from "node:path";import { WORKSPACE_ROOT } from "#runtime/workspace/types.js";+import { MODEL_SKILL_ROOT } from "#shared/skill-paths.js";++const RESOURCE_WORKSPACE_DIRECTORY = "workspace";+const RESOURCE_SKILLS_DIRECTORY = "skills";/*** One concrete file materialized from a workspace seed directory for@@ -21,11 +25,43 @@ export async function materializeWorkspaceDirectory(sourceDirectoryPath: string,): Promise<readonly MaterializedWorkspaceFile[]> {const files: MaterializedWorkspaceFile[] = [];- await addMaterializedDirectoryFiles({- files,- logicalDirectoryPath: ".",- sourceDirectoryPath,+ const entries = await readdir(sourceDirectoryPath, {+ withFileTypes: true,});+ const workspaceEntry = entries.find(+ (entry) => entry.name === RESOURCE_WORKSPACE_DIRECTORY && entry.isDirectory(),+ );+ const skillsEntry = entries.find(+ (entry) => entry.name === RESOURCE_SKILLS_DIRECTORY && entry.isDirectory(),+ );++ if (workspaceEntry !== undefined || skillsEntry !== undefined) {+ if (workspaceEntry !== undefined) {+ await addMaterializedDirectoryFiles({+ files,+ logicalDirectoryPath: ".",+ sourceDirectoryPath: join(sourceDirectoryPath, RESOURCE_WORKSPACE_DIRECTORY),+ targetRoot: WORKSPACE_ROOT,+ });+ }++ if (skillsEntry !== undefined) {+ await addMaterializedDirectoryFiles({+ files,+ logicalDirectoryPath: ".",+ sourceDirectoryPath: join(sourceDirectoryPath, RESOURCE_SKILLS_DIRECTORY),+ targetRoot: MODEL_SKILL_ROOT,+ });+ }+ } else {+ await addMaterializedDirectoryFiles({+ files,+ logicalDirectoryPath: ".",+ sourceDirectoryPath,+ targetRoot: WORKSPACE_ROOT,+ });+ }+files.sort((left, right) => left.path.localeCompare(right.path));return files;}@@ -34,6 +70,7 @@ async function addMaterializedDirectoryFiles(input: {readonly files: MaterializedWorkspaceFile[];readonly logicalDirectoryPath: string;readonly sourceDirectoryPath: string;+ readonly targetRoot: string;}): Promise<void> {const entries = await readdir(input.sourceDirectoryPath, {withFileTypes: true,@@ -52,13 +89,14 @@ async function addMaterializedDirectoryFiles(input: {files: input.files,logicalDirectoryPath: logicalPath,sourceDirectoryPath: sourcePath,+ targetRoot: input.targetRoot,});continue;}input.files.push({content: await readFile(sourcePath),- path: pathPosix.join(WORKSPACE_ROOT, logicalPath),+ path: pathPosix.join(input.targetRoot, logicalPath),});}}diff --git a/packages/eve/src/runtime/workspace/spec.test.ts b/packages/eve/src/runtime/workspace/spec.test.tsindex 520430673..1b088f53d 100644--- a/packages/eve/src/runtime/workspace/spec.test.ts+++ b/packages/eve/src/runtime/workspace/spec.test.ts@@ -5,7 +5,7 @@ import { createWorkspacePromptSection } from "#runtime/workspace/spec.js";describe("createWorkspacePromptSection", () => {it("tells the model not to answer from the overview when bash verification fails", () => {const section = createWorkspacePromptSection({- rootEntries: ["skills", "weather-codes.md"],+ rootEntries: ["weather-codes.md"],});expect(section).toContain(diff --git a/packages/eve/src/shared/skill-package.test.ts b/packages/eve/src/shared/skill-package.test.tsindex edff90156..2e127b694 100644--- a/packages/eve/src/shared/skill-package.test.ts+++ b/packages/eve/src/shared/skill-package.test.ts@@ -7,6 +7,8 @@ import {writeSkillPackageToSandbox,} from "#shared/skill-package.js";+const HOME_PROBE_COMMAND = `printf '%s\\n' "$HOME"`;+describe("normalizeSkillPackage", () => {it("generates SKILL.md and sorts package files deterministically", () => {const packageDefinition = normalizeSkillPackage({@@ -68,7 +70,11 @@ describe("normalizeSkillPackage", () => {describe("writeSkillPackageToSandbox", () => {it("writes generated and sibling files into the live skill package directory", async () => {- const sandbox = mockSandbox();+ const sandbox = mockSandbox({+ commands: {+ [HOME_PROBE_COMMAND]: { exitCode: 0, stderr: "", stdout: "/home/agent\n" },+ },+ });const skill = normalizeSkillPackage({name: "tenant",description: "Tenant-specific procedures.",@@ -80,13 +86,56 @@ describe("writeSkillPackageToSandbox", () => {await writeSkillPackageToSandbox({ sandbox: sandbox.session, skill });+ expect(sandbox.files.get("/home/agent/.agents/skills/tenant/SKILL.md")).toBe(+ "Follow tenant policy.",+ );+ expect(sandbox.files.get("/home/agent/.agents/skills/tenant/references/policy.md")).toBe(+ "Policy body",+ );+ });++ it("falls back to the legacy workspace skill directory when HOME is unavailable", async () => {+ const sandbox = mockSandbox();+ const skill = normalizeSkillPackage({+ name: "tenant",+ description: "Tenant-specific procedures.",+ markdown: "Follow tenant policy.",+ });++ await writeSkillPackageToSandbox({ sandbox: sandbox.session, skill });+expect(sandbox.files.get("/workspace/skills/tenant/SKILL.md")).toBe("Follow tenant policy.");- expect(sandbox.files.get("/workspace/skills/tenant/references/policy.md")).toBe("Policy body");});});describe("removeSkillPackageFromSandbox", () => {- it("validates the skill name before removing the package directory", async () => {+ it("removes only the resolved HOME package directory", async () => {+ const sandbox = mockSandbox({+ commands: {+ [HOME_PROBE_COMMAND]: { exitCode: 0, stderr: "", stdout: "/home/agent\n" },+ },+ initialFiles: {+ "/home/agent/.agents/skills/tenant_policy-1/SKILL.md": "Tenant policy",+ "/home/agent/.agents/skills/tenant_policy-1/references/policy.md": "Policy",+ "/workspace/skills/tenant_policy-1/SKILL.md": "Tenant policy",+ "/workspace/skills/tenant_policy-1/references/policy.md": "Policy",+ },+ });++ await removeSkillPackageFromSandbox({ sandbox: sandbox.session, name: "tenant_policy-1" });++ expect(sandbox.removedPaths).toEqual(["/home/agent/.agents/skills/tenant_policy-1"]);+ expect(sandbox.files.has("/home/agent/.agents/skills/tenant_policy-1/SKILL.md")).toBe(false);+ expect(+ sandbox.files.has("/home/agent/.agents/skills/tenant_policy-1/references/policy.md"),+ ).toBe(false);+ expect(sandbox.files.get("/workspace/skills/tenant_policy-1/SKILL.md")).toBe("Tenant policy");+ expect(sandbox.files.get("/workspace/skills/tenant_policy-1/references/policy.md")).toBe(+ "Policy",+ );+ });++ it("removes /workspace/skills only when HOME is unavailable", async () => {const sandbox = mockSandbox({initialFiles: {"/workspace/skills/tenant_policy-1/SKILL.md": "Tenant policy",diff --git a/packages/eve/src/shared/skill-package.ts b/packages/eve/src/shared/skill-package.tsindex 172b93e61..0c7f1af01 100644--- a/packages/eve/src/shared/skill-package.ts+++ b/packages/eve/src/shared/skill-package.ts@@ -4,8 +4,7 @@ import { dirname, join } from "node:path";import type { SandboxSession } from "#shared/sandbox-session.js";import type { NamedSkillDefinition } from "#shared/skill-definition.js";--const WORKSPACE_ROOT = "/workspace";+import { resolveSandboxSkillRoot, resolveSandboxSkillWritePath } from "#shared/skill-paths.js";export interface NormalizedSkillPackageFile {readonly content: Buffer;@@ -74,7 +73,7 @@ export async function writeSkillPackageDirectory(input: {/*** Writes a normalized package into the live sandbox under- * `/workspace/skills/<name>/`.+ * the sandbox skill root.*/export async function writeSkillPackageToSandbox(input: {readonly sandbox: SandboxSession;@@ -83,7 +82,11 @@ export async function writeSkillPackageToSandbox(input: {for (const file of input.skill.files) {await input.sandbox.writeBinaryFile({content: file.content,- path: `${WORKSPACE_ROOT}/skills/${input.skill.name}/${file.relativePath}`,+ path: await resolveSandboxSkillWritePath({+ name: input.skill.name,+ relativePath: file.relativePath,+ sandbox: input.sandbox,+ }),});}}@@ -96,16 +99,18 @@ export async function removeSkillPackageFromSandbox(input: {readonly name: string;}): Promise<void> {assertSafeSkillPackageName(input.name);+ const root = await resolveSandboxSkillRoot({ sandbox: input.sandbox });+await input.sandbox.removePath({force: true,- path: `${WORKSPACE_ROOT}/skills/${input.name}`,+ path: `${root}/${input.name}`,recursive: true,});}/*** Validates a runtime-contributed skill name before it becomes one path- * segment under `/workspace/skills`.+ * segment under the sandbox skill root.*/export function assertSafeSkillPackageName(name: string): void {if (diff --git a/packages/eve/src/shared/skill-paths.test.ts b/packages/eve/src/shared/skill-paths.test.tsnew file mode 100644index 000000000..cea8261c7--- /dev/null+++ b/packages/eve/src/shared/skill-paths.test.ts@@ -0,0 +1,100 @@+import { describe, expect, it } from "vitest";++import { mockSandbox } from "#internal/testing/mocks/mock-sandbox.js";+import {+ FALLBACK_SKILL_ROOT,+ MODEL_SKILL_ROOT,+ formatFallbackSkillPath,+ formatSkillModelPath,+ resolveSandboxSeedFilePath,+ resolveSandboxSkillReadPaths,+ resolveSandboxSkillRoot,+} from "#shared/skill-paths.js";++const HOME_PROBE_COMMAND = `printf '%s\\n' "$HOME"`;++describe("skill path helpers", () => {+ it("formats model-facing and fallback skill paths", () => {+ expect(formatSkillModelPath({ name: "research", relativePath: "SKILL.md" })).toBe(+ `${MODEL_SKILL_ROOT}/research/SKILL.md`,+ );+ expect(formatFallbackSkillPath({ name: "research", relativePath: "SKILL.md" })).toBe(+ `${FALLBACK_SKILL_ROOT}/research/SKILL.md`,+ );+ });++ it("resolves the sandbox skill root from HOME", async () => {+ const sandbox = mockSandbox({+ commands: {+ [HOME_PROBE_COMMAND]: { exitCode: 0, stderr: "", stdout: "/home/agent\n" },+ },+ });++ await expect(resolveSandboxSkillRoot({ sandbox: sandbox.session })).resolves.toBe(+ "/home/agent/.agents/skills",+ );+ await expect(resolveSandboxSkillRoot({ sandbox: sandbox.session })).resolves.toBe(+ "/home/agent/.agents/skills",+ );+ expect(sandbox.commandLog).toEqual([HOME_PROBE_COMMAND]);+ });++ it("falls back to /workspace/skills when HOME is unusable", async () => {+ const sandbox = mockSandbox({+ commands: {+ [HOME_PROBE_COMMAND]: { exitCode: 0, stderr: "", stdout: "\n" },+ },+ });++ await expect(resolveSandboxSkillRoot({ sandbox: sandbox.session })).resolves.toBe(+ FALLBACK_SKILL_ROOT,+ );+ });++ it("reads only from the resolved HOME skill root when HOME is usable", async () => {+ const sandbox = mockSandbox({+ commands: {+ [HOME_PROBE_COMMAND]: { exitCode: 0, stderr: "", stdout: "/home/agent\n" },+ },+ });++ await expect(+ resolveSandboxSkillReadPaths({+ name: "research",+ relativePath: "SKILL.md",+ sandbox: sandbox.session,+ }),+ ).resolves.toEqual(["/home/agent/.agents/skills/research/SKILL.md"]);+ });++ it("reads from /workspace/skills only when that root is selected", async () => {+ const sandbox = mockSandbox({+ commands: {+ [HOME_PROBE_COMMAND]: { exitCode: 0, stderr: "", stdout: "\n" },+ },+ });++ await expect(+ resolveSandboxSkillReadPaths({+ name: "research",+ relativePath: "SKILL.md",+ sandbox: sandbox.session,+ }),+ ).resolves.toEqual(["/workspace/skills/research/SKILL.md"]);+ });++ it("resolves model-facing seed paths before writing to the sandbox", async () => {+ const sandbox = mockSandbox({+ commands: {+ [HOME_PROBE_COMMAND]: { exitCode: 0, stderr: "", stdout: "/home/agent\n" },+ },+ });++ await expect(+ resolveSandboxSeedFilePath({+ path: `${MODEL_SKILL_ROOT}/research/references/catalog.md`,+ sandbox: sandbox.session,+ }),+ ).resolves.toBe("/home/agent/.agents/skills/research/references/catalog.md");+ });+});diff --git a/packages/eve/src/shared/skill-paths.ts b/packages/eve/src/shared/skill-paths.tsnew file mode 100644index 000000000..fd5b91fc1--- /dev/null+++ b/packages/eve/src/shared/skill-paths.ts@@ -0,0 +1,122 @@+import type { SandboxSession } from "#shared/sandbox-session.js";++export const MODEL_SKILL_ROOT = "$HOME/.agents/skills";+export const FALLBACK_SKILL_ROOT = "/workspace/skills";++const HOME_SKILL_SUFFIX = ".agents/skills";+const HOME_PROBE_COMMAND = `printf '%s\\n' "$HOME"`;+const skillRootCache = new WeakMap<SandboxSession, Promise<string>>();++export function formatSkillModelPath(input: {+ readonly name: string;+ readonly relativePath: string;+}): string {+ return formatSkillPath({+ name: input.name,+ relativePath: input.relativePath,+ root: MODEL_SKILL_ROOT,+ });+}++export function formatFallbackSkillPath(input: {+ readonly name: string;+ readonly relativePath: string;+}): string {+ return formatSkillPath({+ name: input.name,+ relativePath: input.relativePath,+ root: FALLBACK_SKILL_ROOT,+ });+}++export async function resolveSandboxSkillRoot(input: {+ readonly sandbox: SandboxSession;+}): Promise<string> {+ const cached = skillRootCache.get(input.sandbox);+ if (cached !== undefined) {+ return await cached;+ }++ const next = probeSandboxSkillRoot(input.sandbox);+ skillRootCache.set(input.sandbox, next);+ return await next;+}++export async function resolveSandboxSkillReadPaths(input: {+ readonly name: string;+ readonly relativePath: string;+ readonly sandbox: SandboxSession;+}): Promise<readonly string[]> {+ return [+ formatSkillPath({+ name: input.name,+ relativePath: input.relativePath,+ root: await resolveSandboxSkillRoot({ sandbox: input.sandbox }),+ }),+ ];+}++export async function resolveSandboxSkillWritePath(input: {+ readonly name: string;+ readonly relativePath: string;+ readonly sandbox: SandboxSession;+}): Promise<string> {+ return formatSkillPath({+ name: input.name,+ relativePath: input.relativePath,+ root: await resolveSandboxSkillRoot({ sandbox: input.sandbox }),+ });+}++export async function resolveSandboxSeedFilePath(input: {+ readonly path: string;+ readonly sandbox: SandboxSession;+}): Promise<string> {+ if (!input.path.startsWith(`${MODEL_SKILL_ROOT}/`)) {+ return input.path;+ }++ const root = await resolveSandboxSkillRoot({ sandbox: input.sandbox });+ return `${root}${input.path.slice(MODEL_SKILL_ROOT.length)}`;+}++function formatSkillPath(input: {+ readonly name: string;+ readonly relativePath: string;+ readonly root: string;+}): string {+ return `${input.root}/${input.name}/${input.relativePath}`;+}++async function probeSandboxSkillRoot(sandbox: SandboxSession): Promise<string> {+ try {+ const result = await sandbox.run({ command: HOME_PROBE_COMMAND });+ if (result.exitCode !== 0) {+ return FALLBACK_SKILL_ROOT;+ }++ const home = result.stdout.trim();+ if (!isUsableSandboxHome(home)) {+ return FALLBACK_SKILL_ROOT;+ }++ return joinHomeSkillRoot(home);+ } catch {+ return FALLBACK_SKILL_ROOT;+ }+}++function isUsableSandboxHome(path: string): boolean {+ return (+ path.length > 0 &&+ path.startsWith("/") &&+ !path.includes("\0") &&+ !path.includes("\n") &&+ !path.includes("\r")+ );+}++function joinHomeSkillRoot(home: string): string {+ const normalizedHome = home === "/" ? "" : home.replace(/\/+$/, "");+ return `${normalizedHome}/${HOME_SKILL_SUFFIX}`;+}diff --git a/packages/eve/test/resolve-agent.test.ts b/packages/eve/test/resolve-agent.test.tsindex 924eebeb9..55a483140 100644--- a/packages/eve/test/resolve-agent.test.ts+++ b/packages/eve/test/resolve-agent.test.ts@@ -250,7 +250,7 @@ describe("resolveAgent", () => {},]);expect(resolved.workspaceSpec).toEqual({- rootEntries: ["skills/"],+ rootEntries: [],});expect(resolved.tools).toHaveLength(1);expect(resolved.tools[0]).toMatchObject({diff --git a/packages/eve/test/scenarios/runtime-loaders.scenario.test.ts b/packages/eve/test/scenarios/runtime-loaders.scenario.test.tsindex 8b110a7dc..a1540b719 100644--- a/packages/eve/test/scenarios/runtime-loaders.scenario.test.ts+++ b/packages/eve/test/scenarios/runtime-loaders.scenario.test.ts@@ -434,7 +434,7 @@ describe("runtime compiled artifact loaders", () => {});expect(resolvedAgent.instructions).toEqual(manifest.instructions);expect(resolvedAgent.workspaceSpec).toEqual({- rootEntries: ["skills/"],+ rootEntries: [],});expect(Object.keys(moduleMap.nodes)).toEqual([ROOT_COMPILED_AGENT_NODE_ID]);});diff --git a/packages/eve/test/scenarios/vercel-build-prewarm.scenario.test.ts b/packages/eve/test/scenarios/vercel-build-prewarm.scenario.test.tsindex 370b9d214..706781d7e 100644--- a/packages/eve/test/scenarios/vercel-build-prewarm.scenario.test.ts+++ b/packages/eve/test/scenarios/vercel-build-prewarm.scenario.test.ts@@ -114,8 +114,8 @@ describe("Vercel build-time sandbox prewarm", () => {expect(events.seededTemplates).toEqual(["default", "default"]);expect([...events.writtenFilePaths].sort()).toEqual([- "/workspace/skills/research/SKILL.md",- "/workspace/skills/route-weather/SKILL.md",+ "$HOME/.agents/skills/research/SKILL.md",+ "$HOME/.agents/skills/route-weather/SKILL.md",]);});});