style: biome format
This commit is contained in:
@@ -197,9 +197,13 @@ export function createBashTool(
|
||||
const runtime = defaults?.sandbox ? "sandboxed" : "direct";
|
||||
const gates: string[] = [];
|
||||
if (!elevatedDefaults?.enabled) {
|
||||
gates.push("enabled (tools.elevated.enabled / agents.list[].tools.elevated.enabled)");
|
||||
gates.push(
|
||||
"enabled (tools.elevated.enabled / agents.list[].tools.elevated.enabled)",
|
||||
);
|
||||
} else {
|
||||
gates.push("allowFrom (tools.elevated.allowFrom.<provider> / agents.list[].tools.elevated.allowFrom.<provider>)");
|
||||
gates.push(
|
||||
"allowFrom (tools.elevated.allowFrom.<provider> / agents.list[].tools.elevated.allowFrom.<provider>)",
|
||||
);
|
||||
}
|
||||
throw new Error(
|
||||
[
|
||||
|
||||
@@ -6,14 +6,13 @@ import type {
|
||||
AgentToolResult,
|
||||
} from "@mariozechner/pi-agent-core";
|
||||
import type { AssistantMessage } from "@mariozechner/pi-ai";
|
||||
import type { ClawdbotConfig } from "../config/config.js";
|
||||
import {
|
||||
normalizeThinkLevel,
|
||||
type ThinkLevel,
|
||||
} from "../auto-reply/thinking.js";
|
||||
|
||||
import { sanitizeContentBlocksImages } from "./tool-images.js";
|
||||
import type { ClawdbotConfig } from "../config/config.js";
|
||||
import { formatSandboxToolPolicyBlockedMessage } from "./sandbox.js";
|
||||
import { sanitizeContentBlocksImages } from "./tool-images.js";
|
||||
import type { WorkspaceBootstrapFile } from "./workspace.js";
|
||||
|
||||
export type EmbeddedContextFile = { path: string; content: string };
|
||||
|
||||
@@ -64,4 +64,3 @@ describe("sandbox explain helpers", () => {
|
||||
expect(msg).toContain("Use main session key (direct): agent:main:main");
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -219,7 +219,11 @@ function resolveElevatedPermissions(params: {
|
||||
agentId: string;
|
||||
ctx: MsgContext;
|
||||
provider: string;
|
||||
}): { enabled: boolean; allowed: boolean; failures: Array<{ gate: string; key: string }> } {
|
||||
}): {
|
||||
enabled: boolean;
|
||||
allowed: boolean;
|
||||
failures: Array<{ gate: string; key: string }>;
|
||||
} {
|
||||
const globalConfig = params.cfg.tools?.elevated;
|
||||
const agentConfig = resolveAgentConfig(params.cfg, params.agentId)?.tools
|
||||
?.elevated;
|
||||
@@ -227,9 +231,13 @@ function resolveElevatedPermissions(params: {
|
||||
const agentEnabled = agentConfig?.enabled !== false;
|
||||
const enabled = globalEnabled && agentEnabled;
|
||||
const failures: Array<{ gate: string; key: string }> = [];
|
||||
if (!globalEnabled) failures.push({ gate: "enabled", key: "tools.elevated.enabled" });
|
||||
if (!globalEnabled)
|
||||
failures.push({ gate: "enabled", key: "tools.elevated.enabled" });
|
||||
if (!agentEnabled)
|
||||
failures.push({ gate: "enabled", key: "agents.list[].tools.elevated.enabled" });
|
||||
failures.push({
|
||||
gate: "enabled",
|
||||
key: "agents.list[].tools.elevated.enabled",
|
||||
});
|
||||
if (!enabled) return { enabled, allowed: false, failures };
|
||||
if (!params.provider) {
|
||||
failures.push({ gate: "provider", key: "ctx.Provider" });
|
||||
|
||||
@@ -31,10 +31,7 @@ import {
|
||||
} from "../../agents/model-selection.js";
|
||||
import { resolveSandboxRuntimeStatus } from "../../agents/sandbox.js";
|
||||
import type { ClawdbotConfig } from "../../config/config.js";
|
||||
import {
|
||||
type SessionEntry,
|
||||
saveSessionStore,
|
||||
} from "../../config/sessions.js";
|
||||
import { type SessionEntry, saveSessionStore } from "../../config/sessions.js";
|
||||
import { enqueueSystemEvent } from "../../infra/system-events.js";
|
||||
import { applyVerboseOverride } from "../../sessions/level-overrides.js";
|
||||
import { shortenHomePath } from "../../utils.js";
|
||||
|
||||
@@ -144,7 +144,10 @@ export function registerSandboxCli(program: Command) {
|
||||
sandbox
|
||||
.command("explain")
|
||||
.description("Explain effective sandbox/tool policy for a session/agent")
|
||||
.option("--session <key>", "Session key to inspect (defaults to agent main)")
|
||||
.option(
|
||||
"--session <key>",
|
||||
"Session key to inspect (defaults to agent main)",
|
||||
)
|
||||
.option("--agent <id>", "Agent id to inspect (defaults to derived agent)")
|
||||
.option("--json", "Output result as JSON", false)
|
||||
.addHelpText("after", EXAMPLES.explain)
|
||||
|
||||
@@ -28,14 +28,11 @@ describe("sandbox explain command", () => {
|
||||
const { sandboxExplainCommand } = await import("./sandbox-explain.js");
|
||||
|
||||
const logs: string[] = [];
|
||||
await sandboxExplainCommand(
|
||||
{ json: true, session: "agent:main:main" },
|
||||
{
|
||||
log: (msg: string) => logs.push(msg),
|
||||
error: (msg: string) => logs.push(msg),
|
||||
exit: (_code: number) => {},
|
||||
} as unknown as Parameters<typeof sandboxExplainCommand>[1],
|
||||
);
|
||||
await sandboxExplainCommand({ json: true, session: "agent:main:main" }, {
|
||||
log: (msg: string) => logs.push(msg),
|
||||
error: (msg: string) => logs.push(msg),
|
||||
exit: (_code: number) => {},
|
||||
} as unknown as Parameters<typeof sandboxExplainCommand>[1]);
|
||||
|
||||
const out = logs.join("");
|
||||
const parsed = JSON.parse(out);
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
import { resolveAgentConfig } from "../agents/agent-scope.js";
|
||||
import {
|
||||
resolveSandboxConfigForAgent,
|
||||
resolveSandboxToolPolicyForAgent,
|
||||
} from "../agents/sandbox.js";
|
||||
import type { ClawdbotConfig } from "../config/config.js";
|
||||
import { loadConfig } from "../config/config.js";
|
||||
import {
|
||||
@@ -14,11 +19,6 @@ import {
|
||||
resolveAgentIdFromSessionKey,
|
||||
} from "../routing/session-key.js";
|
||||
import type { RuntimeEnv } from "../runtime.js";
|
||||
import { resolveAgentConfig } from "../agents/agent-scope.js";
|
||||
import {
|
||||
resolveSandboxConfigForAgent,
|
||||
resolveSandboxToolPolicyForAgent,
|
||||
} from "../agents/sandbox.js";
|
||||
|
||||
type SandboxExplainOptions = {
|
||||
session?: string;
|
||||
@@ -71,7 +71,9 @@ function inferProviderFromSessionKey(params: {
|
||||
const configuredMainKey = normalizeMainKey(params.cfg.session?.mainKey);
|
||||
if (parts[0] === configuredMainKey) return undefined;
|
||||
const candidate = parts[0]?.trim().toLowerCase();
|
||||
return candidate && KNOWN_PROVIDER_KEYS.has(candidate) ? candidate : undefined;
|
||||
return candidate && KNOWN_PROVIDER_KEYS.has(candidate)
|
||||
? candidate
|
||||
: undefined;
|
||||
}
|
||||
|
||||
function resolveActiveProvider(params: {
|
||||
@@ -135,7 +137,9 @@ export async function sandboxExplainCommand(
|
||||
): Promise<void> {
|
||||
const cfg = loadConfig();
|
||||
|
||||
const defaultAgentId = resolveAgentIdFromSessionKey(resolveMainSessionKey(cfg));
|
||||
const defaultAgentId = resolveAgentIdFromSessionKey(
|
||||
resolveMainSessionKey(cfg),
|
||||
);
|
||||
const resolvedAgentId = normalizeAgentId(
|
||||
opts.agent?.trim()
|
||||
? opts.agent
|
||||
@@ -277,7 +281,8 @@ export async function sandboxExplainCommand(
|
||||
alwaysAllowedByConfig: elevatedAlwaysAllowedByConfig,
|
||||
allowFrom: {
|
||||
global: provider ? globalAllowTokens : undefined,
|
||||
agent: elevatedAgent?.allowFrom && provider ? agentAllowTokens : undefined,
|
||||
agent:
|
||||
elevatedAgent?.allowFrom && provider ? agentAllowTokens : undefined,
|
||||
},
|
||||
failures: elevatedFailures,
|
||||
},
|
||||
@@ -323,7 +328,10 @@ export async function sandboxExplainCommand(
|
||||
.join(", ")}`,
|
||||
);
|
||||
}
|
||||
if (payload.sandbox.mode === "non-main" && payload.sandbox.sessionIsSandboxed) {
|
||||
if (
|
||||
payload.sandbox.mode === "non-main" &&
|
||||
payload.sandbox.sessionIsSandboxed
|
||||
) {
|
||||
lines.push("");
|
||||
lines.push(
|
||||
`Hint: sandbox mode is non-main; use main session key to run direct: ${payload.mainSessionKey}`,
|
||||
|
||||
Reference in New Issue
Block a user