refactor: normalize cli command hints
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { spawn } from "node:child_process";
|
||||
|
||||
import { defaultRuntime } from "../../runtime.js";
|
||||
import { formatCliCommand } from "../../cli/command-format.js";
|
||||
import { DEFAULT_SANDBOX_IMAGE, SANDBOX_AGENT_WORKSPACE_MOUNT } from "./constants.js";
|
||||
import { readRegistry, updateRegistry } from "./registry.js";
|
||||
import { computeSandboxConfigHash } from "./config-hash.js";
|
||||
@@ -214,13 +215,13 @@ async function readContainerConfigHash(containerName: string): Promise<string |
|
||||
|
||||
function formatSandboxRecreateHint(params: { scope: SandboxConfig["scope"]; sessionKey: string }) {
|
||||
if (params.scope === "session") {
|
||||
return `clawdbot sandbox recreate --session ${params.sessionKey}`;
|
||||
return formatCliCommand(`clawdbot sandbox recreate --session ${params.sessionKey}`);
|
||||
}
|
||||
if (params.scope === "agent") {
|
||||
const agentId = resolveSandboxAgentId(params.sessionKey) ?? "main";
|
||||
return `clawdbot sandbox recreate --agent ${agentId}`;
|
||||
return formatCliCommand(`clawdbot sandbox recreate --agent ${agentId}`);
|
||||
}
|
||||
return "clawdbot sandbox recreate --all";
|
||||
return formatCliCommand("clawdbot sandbox recreate --all");
|
||||
}
|
||||
|
||||
export async function ensureSandboxContainer(params: {
|
||||
|
||||
@@ -2,6 +2,7 @@ import type { ClawdbotConfig } from "../../config/config.js";
|
||||
import { canonicalizeMainSessionAlias, resolveAgentMainSessionKey } from "../../config/sessions.js";
|
||||
import { resolveSessionAgentId } from "../agent-scope.js";
|
||||
import { expandToolGroups } from "../tool-policy.js";
|
||||
import { formatCliCommand } from "../../cli/command-format.js";
|
||||
import { resolveSandboxConfigForAgent } from "./config.js";
|
||||
import { resolveSandboxToolPolicyForAgent } from "./tool-policy.js";
|
||||
import type { SandboxConfig, SandboxToolPolicyResolved } from "./types.js";
|
||||
@@ -115,7 +116,9 @@ export function formatSandboxToolPolicyBlockedMessage(params: {
|
||||
if (runtime.mode === "non-main") {
|
||||
lines.push(`- Use main session key (direct): ${runtime.mainSessionKey}`);
|
||||
}
|
||||
lines.push(`- See: clawdbot sandbox explain --session ${runtime.sessionKey}`);
|
||||
lines.push(
|
||||
`- See: ${formatCliCommand(`clawdbot sandbox explain --session ${runtime.sessionKey}`)}`,
|
||||
);
|
||||
|
||||
return lines.join("\n");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user