Skip to content
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/manage-sandboxes/workspace-files.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ Deep Agents Code creates them when you start the first `dcode` session.
| `/sandbox/.deepagents/.state/` | Deep Agents Code runtime state, including persisted session and MCP-related state. |
| `/sandbox/.deepagents/agent/AGENTS.md` | Global memory file for the default Deep Agents Code agent, loaded at session start. |
| `/sandbox/.deepagents/agent/memories/` | Topic-specific markdown memories that Deep Agents Code can read and update across sessions. |
| `/sandbox/.deepagents/skills/` | User-level skills available to Deep Agents Code in the sandbox. |
| `/sandbox/.deepagents/agent/skills/` | Default-agent skills created by the built-in skill creator and preserved by NemoClaw snapshots. |
| `/sandbox/.deepagents/skills/` | Legacy NemoClaw skill-upload state. Deep Agents Code does not load skills from this path, and `$$nemoclaw <name> skill install` leaves it untouched. |
| `/sandbox/.deepagents/agent/skills/` | Skills that Deep Agents Code loads at session start, including skills created by the built-in skill creator and fresh-name skills installed directly by `skill install`. Preserved by NemoClaw snapshots. |
| `/sandbox/.deepagents/.nemoclaw-mcp.json` | NemoClaw-generated managed MCP projection with OpenShell credential placeholders. NemoClaw reconstructs it from host-side registry state. |
| `/sandbox/.deepagents/.state/auth.json` | Upstream auth state. The managed launchers refuse to start when this file contains credentials. |
| `/sandbox/.deepagents/.state/chatgpt-auth.json` | Upstream ChatGPT auth state. The managed launchers refuse to start when this file exists. |
Expand Down
29 changes: 21 additions & 8 deletions docs/reference/commands.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2329,6 +2329,7 @@ To install an OpenClaw plugin, refer to [Install OpenClaw Plugins](../manage-san
For OpenClaw, the command uploads the skill to the OpenClaw state directory and mirrors it into `$HOME/.openclaw/skills/<name>` when the agent home directory differs from the state directory.
That mirror makes skills listed by `openclaw skills list` available at session startup.
If mirror creation fails, NemoClaw prints a warning so you can reinstall or inspect the home directory permissions.
OpenClaw caches skill content per session, so the command also refreshes the OpenClaw session index after every install and update to avoid stale `SKILL.md` data.

</AgentOnly>
<AgentOnly variant="hermes">
Expand All @@ -2339,8 +2340,17 @@ Hermes plugins are different from NemoClaw skills.
</AgentOnly>
<AgentOnly variant="deepagents">

For Deep Agents, the command uploads skills under `/sandbox/.deepagents/skills/<name>` and mirrors agent-facing skills under `/sandbox/.deepagents/agent/skills/<name>` when the manifest requires that view.
The managed `dcode` launchers discover those skills on the next session without accepting executable hook configuration.
For Deep Agents, the command installs a fresh skill directly into `/sandbox/.deepagents/agent/skills/<name>`, the directory Deep Agents Code loads at session start.
The command creates an archive from the selected regular files and records their paths and hashes.
It rejects symlinks and special files.
Inside the sandbox, it stages the archive and verifies the same path-and-byte manifest.
It then moves the staged directory into place only if the destination is still absent.
Because Deep Agents and its built-in skill creator also own this directory, the command refuses any name whose file, directory, or symlink already exists.
Updates are not automatic.
Inspect the existing skill and use the agent's native or manual lifecycle after confirming ownership.
The legacy `/sandbox/.deepagents/skills/<name>` path is not written or treated as ownership proof.
The managed `dcode` launchers discover newly installed skills on the next session without accepting executable hook configuration.
Installation does not enable project hooks or unmanaged MCP files.

</AgentOnly>

Expand All @@ -2349,18 +2359,20 @@ If you pass a plugin-shaped directory to `skill install`, the CLI prints a plugi

Files with names starting with `.` (dotfiles) are skipped and listed in the output.
Files with unsafe path characters are rejected to prevent shell injection.
Symlinks and other non-regular paths are rejected rather than followed or copied.

If the skill already exists on the sandbox, the command updates it in place and preserves chat history.
For new installs, the agent session index is refreshed so the agent discovers the skill on the next session.
For OpenClaw and Hermes, an existing sandbox skill is updated in place and chat history is preserved.
Deep Agents supports only fresh-name installs because its active skill directory is shared with agent-authored content.
Follow the agent-specific activation guidance above after installation.

### `$$nemoclaw <name> skill remove <skill>`

Remove an installed skill from a running sandbox by skill name.
The command validates the skill name, removes the sandbox upload directory, and refreshes the agent session index so the remaining skills are rediscovered on the next session.
The command validates the skill name before it applies the agent-specific removal behavior below.

<AgentOnly variant="openclaw">

For OpenClaw, the command also removes the OpenClaw home-directory mirror when present.
For OpenClaw, the command also removes the OpenClaw home-directory mirror when present and refreshes the OpenClaw session index.

</AgentOnly>
<AgentOnly variant="hermes">
Expand All @@ -2370,8 +2382,9 @@ Run `$$nemoclaw <name> gateway restart` if prompted so the removal takes effect.
</AgentOnly>
<AgentOnly variant="deepagents">

For Deep Agents, the command removes the uploaded skill from the managed `/sandbox/.deepagents` skill paths and refreshes the session index for future `dcode` sessions.
It does not enable project hooks or unmanaged MCP files.
For Deep Agents, automatic removal is refused before any sandbox files change.
The active `/sandbox/.deepagents/agent/skills/<name>` directory is shared with agent-authored content, so its presence alone cannot prove NemoClaw owns it.
Inspect the skill and use the agent's native or manual lifecycle after confirming ownership.

</AgentOnly>

Expand Down
121 changes: 121 additions & 0 deletions src/lib/actions/sandbox/skill-install.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const skillInstall = vi.hoisted(() => ({
parseFrontmatter: vi.fn(),
collectFiles: vi.fn(),
uploadDirectory: vi.fn(),
installFreshSharedSkill: vi.fn(),
postInstall: vi.fn(),
verifyInstall: vi.fn(),
}));
Expand All @@ -39,13 +40,27 @@ vi.mock("./gateway-state", () => ({
import { installSandboxSkill, removeSandboxSkill } from "./skill-install";

const paths = {
stateDir: "/sandbox/.openclaw",
uploadDir: "/sandbox/.openclaw/skills/demo-skill",
mirrorDir: "$HOME/.openclaw/skills/demo-skill",
uploadDirSharedWithAgent: false,
sessionFile: "/sandbox/.openclaw/agents/main/sessions/sessions.json",
isOpenClaw: true,
};

const agent = { name: "openclaw", configPaths: { dir: "/sandbox/.openclaw" } };
const deepAgent = {
name: "langchain-deepagents-code",
configPaths: { dir: "/sandbox/.deepagents" },
};
const sharedPaths = {
stateDir: "/sandbox/.deepagents",
uploadDir: "/sandbox/.deepagents/agent/skills/demo-skill",
mirrorDir: null,
uploadDirSharedWithAgent: true,
sessionFile: null,
isOpenClaw: false,
};

function makeSkillDir(): string {
const dir = fs.mkdtempSync(path.join(os.tmpdir(), "nemoclaw-action-skill-"));
Expand Down Expand Up @@ -92,13 +107,19 @@ describe("sandbox skill action orchestration", () => {
files: ["SKILL.md"],
skippedDotfiles: [],
unsafePaths: [],
unsupportedPaths: [],
});
skillInstall.uploadDirectory.mockReturnValue({
uploaded: 1,
failed: [],
skippedDotfiles: [],
unsafePaths: [],
});
skillInstall.installFreshSharedSkill.mockReturnValue({
success: true,
uploaded: 1,
contentDigest: "a".repeat(64),
});
skillInstall.postInstall.mockReturnValue({ success: true, messages: [] });
skillInstall.verifyInstall.mockReturnValue(true);
});
Expand Down Expand Up @@ -193,6 +214,22 @@ describe("sandbox skill action orchestration", () => {
expect(process.exitCode).toBeUndefined();
});

it("refuses Deep Agents removal before obtaining SSH configuration", async () => {
getSessionAgent.mockReturnValue(deepAgent);
skillInstall.resolveSkillPaths.mockReturnValue(sharedPaths);
const error = vi.spyOn(console, "error").mockImplementation(() => undefined);

await removeSandboxSkill("alpha", { name: "demo-skill" });

expect(process.exitCode).toBe(1);
expect(error).toHaveBeenCalledWith(
expect.stringContaining("Automatic removal is unavailable for Deep Agents skills"),
);
expect(captureSandboxSshConfig).not.toHaveBeenCalled();
expect(skillInstall.checkExisting).not.toHaveBeenCalled();
expect(skillInstall.removeSkill).not.toHaveBeenCalled();
});

it("stops skill installation at the shared gateway liveness guard (#2276)", async () => {
const skillDir = makeSkillDir();
ensureLiveSandboxOrExit.mockRejectedValueOnce(new Error("wrong gateway active"));
Expand Down Expand Up @@ -247,6 +284,90 @@ describe("sandbox skill action orchestration", () => {
expect(process.exitCode).toBeUndefined();
});

it("fresh-installs and verifies Deep Agents content without generic upload mutation", async () => {
const skillDir = makeSkillDir();
getSessionAgent.mockReturnValue(deepAgent);
skillInstall.resolveSkillPaths.mockReturnValue(sharedPaths);
let tempConfig = "";
skillInstall.installFreshSharedSkill.mockImplementation((ctx) => {
tempConfig = ctx.configFile;
return { success: true, uploaded: 1, contentDigest: "a".repeat(64) };
});
const log = vi.spyOn(console, "log").mockImplementation(() => undefined);

try {
await installSandboxSkill("alpha", { command: "install", path: skillDir });
} finally {
fs.rmSync(skillDir, { recursive: true, force: true });
}

expect(skillInstall.installFreshSharedSkill).toHaveBeenCalledWith(
expect.objectContaining({ configFile: tempConfig, sandboxName: "alpha" }),
skillDir,
sharedPaths,
);
expect(skillInstall.checkExisting).not.toHaveBeenCalled();
expect(skillInstall.uploadDirectory).not.toHaveBeenCalled();
expect(skillInstall.postInstall).not.toHaveBeenCalled();
expect(log).toHaveBeenCalledWith(expect.stringContaining("Skill 'demo-skill' installed"));
expectTempSshConfigCleanedUp(tempConfig);
expect(process.exitCode).toBeUndefined();
});

it("refuses a colliding Deep Agents destination without generic mutation", async () => {
const skillDir = makeSkillDir();
getSessionAgent.mockReturnValue(deepAgent);
skillInstall.resolveSkillPaths.mockReturnValue(sharedPaths);
skillInstall.installFreshSharedSkill.mockReturnValue({
success: false,
uploaded: 0,
reason: "destination_exists",
});
const error = vi.spyOn(console, "error").mockImplementation(() => undefined);

try {
await installSandboxSkill("alpha", { command: "install", path: skillDir });
} finally {
fs.rmSync(skillDir, { recursive: true, force: true });
}

expect(process.exitCode).toBe(1);
expect(error).toHaveBeenCalledWith(
expect.stringContaining("the Deep Agents skill destination already exists"),
);
expect(skillInstall.checkExisting).not.toHaveBeenCalled();
expect(skillInstall.uploadDirectory).not.toHaveBeenCalled();
expect(skillInstall.postInstall).not.toHaveBeenCalled();
});

it("reports unknown Deep Agents commit state with inspect-before-retry guidance", async () => {
const skillDir = makeSkillDir();
getSessionAgent.mockReturnValue(deepAgent);
skillInstall.resolveSkillPaths.mockReturnValue(sharedPaths);
skillInstall.installFreshSharedSkill.mockReturnValue({
success: false,
uploaded: 0,
reason: "remote_state_unknown",
});
const error = vi.spyOn(console, "error").mockImplementation(() => undefined);

try {
await installSandboxSkill("alpha", { command: "install", path: skillDir });
} finally {
fs.rmSync(skillDir, { recursive: true, force: true });
}

const output = error.mock.calls.map((args) => args.join(" ")).join("\n");
expect(process.exitCode).toBe(1);
expect(output).toContain("did not confirm whether the Deep Agents skill was committed");
expect(output).toContain(
"Inspect /sandbox/.deepagents/agent/skills/demo-skill before retrying",
);
expect(skillInstall.checkExisting).not.toHaveBeenCalled();
expect(skillInstall.uploadDirectory).not.toHaveBeenCalled();
expect(skillInstall.postInstall).not.toHaveBeenCalled();
});

it("adds shields recovery guidance when skill upload fails (#6859)", async () => {
const skillDir = makeSkillDir();
skillInstall.uploadDirectory.mockReturnValue({
Expand Down
55 changes: 54 additions & 1 deletion src/lib/actions/sandbox/skill-install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,16 @@

const agent = agentRuntime.getSessionAgent(sandboxName);
const paths = skillInstall.resolveSkillPaths(agent, skillName);
if (paths.uploadDirSharedWithAgent) {
console.error(
" Automatic removal is unavailable for Deep Agents skills because the destination is shared with agent-authored content.",
);
console.error(
" Inspect and remove the skill with the agent's native or manual workflow after confirming ownership.",
);
process.exitCode = 1;
return;
}

const sshConfigResult = captureSandboxSshConfig(sandboxName, {
ignoreError: true,
Expand Down Expand Up @@ -221,6 +231,10 @@
}

const resolvedPath = path.resolve(skillPath);
if (fs.existsSync(resolvedPath) && fs.lstatSync(resolvedPath).isSymbolicLink()) {
console.error(` Skill path '${resolvedPath}' must not be a symbolic link.`);
process.exit(1);
}

// Accept a directory containing SKILL.md, or a direct path to SKILL.md.
let skillDir: string;
Expand Down Expand Up @@ -248,11 +262,16 @@
}
process.exit(1);
}
const skillMdStat = fs.lstatSync(skillMdPath);
if (!skillMdStat.isFile() || skillMdStat.isSymbolicLink()) {
console.error(` SKILL.md at '${skillMdPath}' must be a regular file, not a symbolic link.`);
process.exit(1);
}

// 1. Validate frontmatter
let frontmatter;
try {
const content = fs.readFileSync(skillMdPath, "utf-8");

Check failure

Code scanning / CodeQL

Potential file system race condition High

The file may have changed since it
was checked
.
frontmatter = skillInstall.parseFrontmatter(content);
} catch (err) {
const errorMessage = err instanceof Error ? err.message : String(err);
Expand All @@ -267,6 +286,12 @@
console.error(" File names must match [A-Za-z0-9._-/]. Rename or remove them.");
process.exit(1);
}
if (collected.unsupportedPaths.length > 0) {
console.error(" Skill directory contains unsupported non-regular paths:");
for (const p of collected.unsupportedPaths) console.error(` ${p}`);
console.error(" Skills may contain only regular files and directories.");
process.exit(1);
}
if (collected.skippedDotfiles.length > 0) {
console.log(
` ${D}Skipping ${collected.skippedDotfiles.length} hidden path(s): ${collected.skippedDotfiles.join(", ")}${R}`,
Expand Down Expand Up @@ -297,6 +322,34 @@
try {
const ctx = { configFile: tmpSshConfig.file, sandboxName };

if (paths.uploadDirSharedWithAgent) {
const fresh = skillInstall.installFreshSharedSkill(ctx, skillDir, paths);
if (!fresh.success || !fresh.contentDigest) {
if (fresh.reason === "destination_exists") {
console.error(
` Refusing to replace '${frontmatter.name}': the Deep Agents skill destination already exists.`,
);
console.error(
" Deep Agents skill install supports fresh names only because that directory also contains agent-authored skills.",
);
} else if (fresh.reason === "snapshot_failed") {
console.error(" Failed to create an exact regular-file snapshot of the local skill.");
} else {
console.error(
" The remote install did not confirm whether the Deep Agents skill was committed.",
);
console.error(
` Inspect ${paths.uploadDir} before retrying; NemoClaw will not replace or delete shared agent content.`,
);
}
process.exitCode = 1;
return;
}
console.log(` ${G}✓${R} Installed ${fresh.uploaded} file(s) into the agent skill directory`);
console.log(` ${G}✓${R} Skill '${frontmatter.name}' installed`);
return;
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
}

// 5. Check if skill already exists (update vs fresh install). This probe is
// advisory for install only: stale SSH config files and transient remote
// shell startup failures can make the stat probe inconclusive even when a
Expand Down Expand Up @@ -342,7 +395,7 @@
} else {
console.error(
` Skill uploaded but verification failed: SKILL.md missing at ${paths.uploadDir}` +
(paths.isOpenClaw && paths.mirrorDir ? ` or its agent mirror ${paths.mirrorDir}` : ""),
(paths.mirrorDir ? ` or its agent mirror ${paths.mirrorDir}` : ""),
);
process.exit(1);
}
Expand Down
Loading
Loading