openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
78 lines (77 loc) • 3.86 kB
JavaScript
import { r as executionTitleSchema, s as optionalStringEnum } from "./typebox-BdE5GwKs.js";
import { Type } from "typebox";
//#region src/agents/bash-tools.schemas.ts
/**
* TypeBox schemas for shell/process tools exposed to model providers.
*
* Keep these schemas provider-friendly: flat fields, string enums, and explicit
* descriptions that match runtime validation.
*/
const EXEC_TOOL_HOST_VALUES = [
"auto",
"sandbox",
"gateway",
"node"
];
const PROCESS_TOOL_ACTIONS = [
"list",
"poll",
"log",
"write",
"send-keys",
"submit",
"paste",
"kill",
"clear",
"remove"
];
/** Parameters accepted by the exec tool. */
const execSchema = Type.Object({
title: executionTitleSchema(),
command: Type.String({ description: "Shell command." }),
workdir: Type.Optional(Type.String({ description: "Omit/empty string: default; whitespace-only invalid." })),
env: Type.Optional(Type.Record(Type.String(), Type.String(), { description: "Env overrides. Literal values; no expansion. Omit to inherit." })),
yieldMs: Type.Optional(Type.Number({ description: "Milliseconds before backgrounding; default 10000." })),
background: Type.Optional(Type.Boolean({ description: "Background now." })),
timeoutSeconds: Type.Optional(Type.Number({ description: "Timeout in seconds." })),
pty: Type.Optional(Type.Boolean({ description: "Use PTY for TTY-required CLIs and coding agents." })),
elevated: Type.Optional(Type.Boolean({ description: "Run on host with elevated permissions if allowed." })),
host: optionalStringEnum(EXEC_TOOL_HOST_VALUES, { description: "Omit/auto: inherit configured host." }),
ask: Type.Optional(Type.String({ description: "Requests stricter approvals under tools.exec.mode and host policy; channel-origin calls cannot override host ask=off." })),
node: Type.Optional(Type.String({ description: "Node id/name for host=node." }))
});
/** Exec parameters when no process-control continuation is authorized. */
const execCompletionSchema = Type.Omit(execSchema, ["yieldMs", "background"]);
/** Parameters exposed by node-only exec surfaces. */
const nodeExecSchema = Type.Object({
title: execSchema.properties.title,
command: execSchema.properties.command,
workdir: execSchema.properties.workdir,
env: execSchema.properties.env,
timeoutSeconds: execSchema.properties.timeoutSeconds,
host: optionalStringEnum(["node"], { description: "Exec target. Only node is available on this tool surface." }),
node: execSchema.properties.node
});
/** Parameters accepted by the process-control tool. */
const processSchema = Type.Object({
action: Type.String({
enum: [...PROCESS_TOOL_ACTIONS],
description: "Process action (list|poll|log|write|send-keys|submit|paste|kill|clear|remove)"
}),
sessionId: Type.Optional(Type.String({ description: "Required for every action except list." })),
data: Type.Optional(Type.String({ description: "Data to write for write" })),
keys: Type.Optional(Type.Array(Type.String(), { description: "Key tokens to send for send-keys" })),
hex: Type.Optional(Type.Array(Type.String(), { description: "Hex bytes to send for send-keys" })),
literal: Type.Optional(Type.String({ description: "Literal string for send-keys" })),
text: Type.Optional(Type.String({ description: "Text to paste for paste" })),
bracketed: Type.Optional(Type.Boolean({ description: "Wrap paste in bracketed mode" })),
eof: Type.Optional(Type.Boolean({ description: "Close stdin after write" })),
offset: Type.Optional(Type.Number({ description: "Log offset" })),
limit: Type.Optional(Type.Number({ description: "Log length" })),
timeout: Type.Optional(Type.Number({
description: "For poll: wait up to this many milliseconds before returning; max 30000 ms, higher values are clamped to 30000",
minimum: 0
}))
});
//#endregion
export { processSchema as i, execSchema as n, nodeExecSchema as r, execCompletionSchema as t };