From 3e24fe593e70fbc10a22c2d573b0f2e34824269e Mon Sep 17 00:00:00 2001 From: Yiling-J Date: Wed, 18 Nov 2026 09:44:54 +0800 Subject: [PATCH] feat(cli): add runner start with bundled SRT sandboxing (#535) * refactor(agent): expose runner bash without skill gating * feat(cli): add runner start with optional SRT sandboxing * refactor(cli): remove runner Python dependency * feat(cli): bundle SRT and use platform-native runner shells * refactor(cli): delegate runner processes to Execa --- CHANGELOG.md | 2 + apps/cli/README.md | 38 ++ apps/cli/package.json | 10 + apps/cli/src/program.ts | 12 + apps/cli/src/runner/client.test.ts | 169 +++++++++ apps/cli/src/runner/client.ts | 311 +++++++++++++++++ apps/cli/src/runner/config.test.ts | 71 ++++ apps/cli/src/runner/config.ts | 75 ++++ apps/cli/src/runner/files.test.ts | 325 ++++++++++++++++++ apps/cli/src/runner/files.ts | 287 ++++++++++++++++ apps/cli/src/runner/shell.test.ts | 298 ++++++++++++++++ apps/cli/src/runner/shell.ts | 220 ++++++++++++ apps/cli/src/runner/srt-vendor.ts | 2 + apps/cli/src/runner/srt.test.ts | 59 ++++ apps/cli/src/runner/srt.ts | 59 ++++ bun.lock | 142 +++++++- docs/using-shumai/agent-sandbox.mdx | 102 ++++-- docs/zh/using-shumai/agent-sandbox.mdx | 100 ++++-- ...dbox.test.ts => concurrent-runner.test.ts} | 26 +- packages/agent/src/index.test.ts | 38 +- .../operation-extensions/download-asset.ts | 2 +- .../agent/src/operation-extensions/upload.ts | 2 +- packages/agent/src/runtime.ts | 52 +-- packages/agent/src/tools/read-skill.ts | 2 +- ...boxed-bash.test.ts => runner-bash.test.ts} | 121 +++---- .../{sandboxed-bash.ts => runner-bash.ts} | 55 +-- .../core/src/runner/runner-service.test.ts | 36 ++ packages/core/src/runner/runner-service.ts | 11 +- packages/dtos/src/runner.ts | 7 + .../components/settings/RunnerSettings.tsx | 8 +- packages/webui/messages/en.json | 8 +- packages/webui/messages/zh.json | 8 +- scripts/build-cli.ts | 2 + scripts/build-npm.ts | 2 + scripts/srt-bundle.ts | 36 ++ 35 files changed, 2414 insertions(+), 284 deletions(-) create mode 100644 apps/cli/src/runner/client.test.ts create mode 100644 apps/cli/src/runner/client.ts create mode 100644 apps/cli/src/runner/config.test.ts create mode 100644 apps/cli/src/runner/config.ts create mode 100644 apps/cli/src/runner/files.test.ts create mode 100644 apps/cli/src/runner/files.ts create mode 100644 apps/cli/src/runner/shell.test.ts create mode 100644 apps/cli/src/runner/shell.ts create mode 100644 apps/cli/src/runner/srt-vendor.ts create mode 100644 apps/cli/src/runner/srt.test.ts create mode 100644 apps/cli/src/runner/srt.ts rename packages/agent/src/{concurrent-sandbox.test.ts => concurrent-runner.test.ts} (90%) rename packages/agent/src/tools/{sandboxed-bash.test.ts => runner-bash.test.ts} (67%) rename packages/agent/src/tools/{sandboxed-bash.ts => runner-bash.ts} (74%) create mode 100644 scripts/srt-bundle.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index c06e648b..733e7988 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). ### Added +- **cli**: Run remote shell commands and exchange files with `shumai-cli runner start` on macOS, Linux, and Windows, with bundled SRT sandboxing enabled through a JSON configuration file. - **agent**: Support binding external Runners per team so agents can execute shell commands and exchange files securely over WebSocket without requiring a built-in server sandbox, and allow assigning a default or dedicated Runner per agent in Team Settings. - **i18n**: Add Korean as a display language, selectable on the sign-up page and in team settings. @@ -17,6 +18,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). ### Changed +- **agent**: Make bash available to editors and reviewers as soon as a runner is configured, without first reading a skill. - **agent**: ⚠️ **Behavior Change**: Replace the built-in server-side bash sandbox and domain allowlist settings with external team Runners; agent `bash` and `download_asset` tools are enabled automatically once at least one Runner is configured for the team, while domain and OS-level sandboxing rules move to the Runner side. - **cli**: Show copyable commands and shell configuration instructions when the standalone CLI installation directory is missing from PATH. diff --git a/apps/cli/README.md b/apps/cli/README.md index 26e12170..56581a11 100644 --- a/apps/cli/README.md +++ b/apps/cli/README.md @@ -86,6 +86,44 @@ export SHUMAI_ALLOW_DELETE="true" --- +## Agent runner + +Create a runner in **Settings → Agent Runners** and copy its one-time key. On macOS, Linux, or Windows, start it in an existing dedicated workspace: + +```sh +export SHUMAI_API_SERVER="https://shumai.example.com" +export SHUMAI_RUNNER_KEY="your-runner-key" +shumai-cli runner start --cwd /path/to/workspace +``` + +For Windows PowerShell: + +```powershell +$env:SHUMAI_API_SERVER = "https://shumai.example.com" +$env:SHUMAI_RUNNER_KEY = "your-runner-key" +shumai-cli runner start --cwd C:\workspace +``` + +Use `--url` or `--key` to override those variables. A runner key is separate from `SHUMAI_API_KEY`. The runner stays in the foreground; Ctrl+C stops it and its active commands. Remote servers require HTTPS; localhost and `host.docker.internal` support HTTP for development. No inbound port is opened. + +Commands use `/bin/sh` on macOS/Linux and `cmd.exe` on Windows. The agent receives the runner's OS and shell so it can use the appropriate syntax. Commands run with the local user's permissions unless SRT is requested. + +[Anthropic Sandbox Runtime](https://github.com/anthropics/sandbox-runtime) is bundled with the CLI. Install its platform prerequisites (Linux: bubblewrap, socat, and ripgrep; macOS: ripgrep), then pass its native JSON settings: + +```sh +shumai-cli runner start --srt sandbox.json +``` + +Windows sandboxing uses SRT's alpha Windows support. Run its one-time setup before starting a sandboxed runner (it requests administrator permission): + +```powershell +npx @anthropic-ai/sandbox-runtime windows-install +``` + +SRT settings are read and validated at startup. Invalid settings or unavailable sandbox prerequisites stop startup; commands never fall back to unrestricted execution. Only shell commands and their children are sandboxed. Runner connections and server-directed file transfers stay outside SRT, and no server domain is automatically allowed. The shared SRT runtime is cleaned up when the runner stops. + +See [Agent Runners](../../docs/using-shumai/agent-sandbox.mdx) for configuration, Docker usage, limits, and security boundaries. + ## Usage > [!IMPORTANT] diff --git a/apps/cli/package.json b/apps/cli/package.json index f5eb7c82..8d17b7f5 100644 --- a/apps/cli/package.json +++ b/apps/cli/package.json @@ -7,13 +7,23 @@ "shumai-cli": "./src/index.ts" }, "dependencies": { + "@anthropic-ai/sandbox-runtime": "0.0.82", "@shumai/api": "workspace:*", "@shumai/dtos": "workspace:*", "@shumai/operations": "workspace:*", "@shumai/tableprinter": "workspace:*", "commander": "15.0.0", + "execa": "10.2.1", "hono": "4.13.5", "ulid": "3.0.2", + "ws": "8.22.2", + "yauzl": "3.4.0", "zod": "4.5.4" + }, + "devDependencies": { + "@types/adm-zip": "0.5.8", + "@types/ws": "8.18.2", + "@types/yauzl": "3.4.0", + "adm-zip": "0.6.1" } } diff --git a/apps/cli/src/program.ts b/apps/cli/src/program.ts index 28a11bfa..57e8de81 100644 --- a/apps/cli/src/program.ts +++ b/apps/cli/src/program.ts @@ -7,6 +7,7 @@ import { cliExtensions } from './operations/extensions' import { registerOperationCommands } from './operations/generate' import type { Output } from './operations/render' import { version } from '../package.json' +import { startRunner } from './runner/client' export interface ProgramOptions { callOperation?: CallOperation @@ -43,6 +44,17 @@ export function createProgram(options: ProgramOptions = {}): Command { extensions: cliExtensions, }) + program + .command('runner') + .description('Connect a local command runner to Shumai.') + .command('start') + .description('Run in the foreground using a key created in Settings → Agent Runners.') + .option('--url ', 'Shumai server URL (or SHUMAI_API_SERVER).') + .option('--key ', 'Runner key (prefer SHUMAI_RUNNER_KEY to avoid shell history).') + .option('--cwd ', 'Runner workspace directory (defaults to the current directory).') + .option('--srt ', 'Sandbox commands with bundled SRT using this JSON settings file.') + .action(startRunner) + program .command('upload') .description('Upload a local file or folder to a parent folder.') diff --git a/apps/cli/src/runner/client.test.ts b/apps/cli/src/runner/client.test.ts new file mode 100644 index 00000000..9dc276cc --- /dev/null +++ b/apps/cli/src/runner/client.test.ts @@ -0,0 +1,169 @@ +import { mkdtemp, rm } from 'node:fs/promises' +import { tmpdir } from 'node:os' +import path from 'node:path' +import { WebSocketServer, type WebSocket } from 'ws' +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' +import { runnerToServerMessageSchema, type RunnerToServerMessage } from '@shumai/dtos' +import { RunnerClient } from './client' +import { RunnerFiles } from './files' +import { RunnerShell } from './shell' + +describe('runner WebSocket client', () => { + let cwd: string + let server: WebSocketServer + let runner: RunnerClient + let running: Promise + let socket: WebSocket + let messages: RunnerToServerMessage[] + let welcomeInFlight: string[] + let connections: number + beforeEach(async () => { + cwd = await mkdtemp(path.join(tmpdir(), 'shumai-client-test-')) + messages = [] + welcomeInFlight = [] + connections = 0 + server = new WebSocketServer({ host: '127.0.0.1', port: 0 }) + await new Promise((resolve) => server.once('listening', resolve)) + const address = server.address() + if (!address || typeof address === 'string') throw new Error('No WebSocket address') + server.on('connection', (connection, request) => { + expect(request.headers.authorization).toBe('Bearer runner-key') + socket = connection + connections++ + connection.on('message', (raw) => + messages.push(runnerToServerMessageSchema.parse(JSON.parse(raw.toString()))), + ) + connection.send( + JSON.stringify({ + type: 'welcome', + runnerId: 'runner', + runnerName: 'Test', + serverTime: Date.now(), + inFlightExecutionIds: welcomeInFlight, + }), + ) + }) + const files = new RunnerFiles(cwd) + runner = new RunnerClient( + { + url: new URL(`ws://127.0.0.1:${address.port}/api/runners/ws`), + key: 'runner-key', + cwd, + srt: undefined, + }, + files, + new RunnerShell(files), + () => {}, + ) + running = runner.run() + // Attach an error handler immediately, including for tests exercising terminal errors. + void running.catch(() => {}) + await vi.waitFor(() => + expect(messages.some((message) => message.type === 'reconcile')).toBe(true), + ) + }) + afterEach(async () => { + runner.stop() + await running.catch(() => {}) + for (const connection of server.clients) connection.terminate() + await new Promise((resolve) => server.close(() => resolve())) + await rm(cwd, { recursive: true, force: true }) + }) + const send = (message: unknown) => socket.send(JSON.stringify(message)) + + it('responds to heartbeat, executes a command once and streams byte offsets', async () => { + expect(messages).toContainEqual( + expect.objectContaining({ + type: 'reconcile', + environment: { platform: process.platform, shell: '/bin/sh' }, + }), + ) + send({ type: 'ping', ts: 123 }) + const command = { + type: 'exec.start', + executionId: 'one', + command: 'printf "世界"; printf "error" >&2', + } + send(command) + send(command) + await vi.waitFor(() => + expect(messages.some((message) => message.type === 'exec.result')).toBe(true), + ) + expect(messages).toContainEqual({ type: 'pong', ts: 123 }) + expect(messages.filter((message) => message.type === 'exec.result')).toHaveLength(1) + const chunks = messages.filter((message) => message.type === 'exec.output') + expect(chunks.map((chunk) => chunk.data).join('')).toContain('世界') + let offset = 0 + for (const chunk of chunks) { + expect(chunk.offset).toBe(offset) + offset += Buffer.byteLength(chunk.data) + } + }) + + it('cancels an active command through the protocol', async () => { + send({ type: 'exec.start', executionId: 'cancel', command: 'echo ready; sleep 30' }) + await vi.waitFor(() => + expect(messages.some((message) => message.type === 'exec.output')).toBe(true), + ) + send({ type: 'exec.cancel', executionId: 'cancel' }) + await vi.waitFor(() => + expect(messages).toContainEqual( + expect.objectContaining({ type: 'exec.result', executionId: 'cancel', aborted: true }), + ), + ) + }) + + it('reconnects and replays output before completing an in-flight command', async () => { + send({ + type: 'exec.start', + executionId: 'reconnect', + command: 'echo before; sleep 0.2; echo after', + }) + await vi.waitFor(() => + expect(messages.some((message) => message.type === 'exec.output')).toBe(true), + ) + welcomeInFlight = ['reconnect'] + socket.terminate() + messages = [] + await vi.waitFor(() => expect(connections).toBe(2), { timeout: 5000 }) + await vi.waitFor(() => + expect(messages.some((message) => message.type === 'reconcile')).toBe(true), + ) + const reconciliation = messages.findIndex((message) => message.type === 'reconcile') + expect( + messages + .slice(0, reconciliation) + .filter((message) => message.type === 'exec.output') + .map((message) => message.data) + .join(''), + ).toContain('after') + expect(messages[reconciliation]).toMatchObject({ + completedExecutions: [expect.objectContaining({ executionId: 'reconnect', exitCode: 0 })], + }) + }) + + it('handles file requests and returns a cached result for a duplicate request', async () => { + const request = { type: 'file.stat', executionId: 'stat', srcPath: '.pi/missing' } + send(request) + await vi.waitFor(() => + expect(messages.some((message) => message.type === 'file.stat.result')).toBe(true), + ) + send(request) + await vi.waitFor(() => + expect(messages.filter((message) => message.type === 'file.stat.result')).toHaveLength(2), + ) + expect(messages.at(-1)).toMatchObject({ ok: true, exists: false }) + }) + + it('stops instead of reconnecting when the runner key is revoked', async () => { + socket.close(1008, 'revoked') + await expect(running).rejects.toThrow('revoked') + expect(connections).toBe(1) + }) + + it('rejects invalid messages and path-like execution IDs', async () => { + send({ type: 'exec.start', executionId: '../escape', command: 'echo unsafe' }) + await expect(running).rejects.toThrow('invalid runner protocol') + expect(messages.some((message) => message.type === 'exec.output')).toBe(false) + }) +}) diff --git a/apps/cli/src/runner/client.ts b/apps/cli/src/runner/client.ts new file mode 100644 index 00000000..f7aab77c --- /dev/null +++ b/apps/cli/src/runner/client.ts @@ -0,0 +1,311 @@ +import WebSocket from 'ws' +import { setTimeout as delay } from 'node:timers/promises' +import { + serverToRunnerMessageSchema, + type RunnerExecOutputMessage, + type RunnerExecResultMessage, + type RunnerToServerMessage, + type ServerToRunnerMessage, +} from '@shumai/dtos' +import { CliError } from '../operations/errors' +import { resolveRunnerConfig, type RunnerOptions } from './config' +import { RunnerFiles, type FileMessage } from './files' +import { RunnerShell } from './shell' + +const MAX_REPLAY_BYTES = 1024 * 1024 +const MAX_COMPLETED = 16 +const MAX_ACTIVE = 8 + +interface Execution { + controller: AbortController + chunks: RunnerExecOutputMessage[] + bytes: number + offset: number + result?: RunnerExecResultMessage +} + +export class RunnerClient { + private socket?: WebSocket + private ready = false + private stopped = new AbortController() + private executions = new Map() + private transfers = new Map() + private completedFiles = new Map() + private pending = new Set>() + + constructor( + private readonly config: Awaited>, + private readonly files: RunnerFiles, + private readonly shell: RunnerShell, + private readonly log: (message: string) => void = console.error, + ) {} + + async run(signal?: AbortSignal): Promise { + const stop = () => this.stop() + signal?.addEventListener('abort', stop, { once: true }) + if (signal?.aborted) this.stop() + let attempt = 0 + try { + while (!this.stopped.signal.aborted) { + const wasReady = await this.connect() + if (this.stopped.signal.aborted) break + attempt = wasReady ? 0 : Math.min(attempt + 1, 5) + this.log('Runner disconnected; reconnecting…') + await delay(Math.min(1000 * 2 ** attempt, 30_000), undefined, { + signal: this.stopped.signal, + }).catch(() => {}) + } + } finally { + signal?.removeEventListener('abort', stop) + this.stop() + await Promise.allSettled(this.pending) + } + } + + stop() { + this.stopped.abort() + this.ready = false + this.socket?.terminate() + for (const execution of this.executions.values()) execution.controller.abort() + for (const transfer of this.transfers.values()) transfer.abort() + } + + private connect(): Promise { + return new Promise((resolve, reject) => { + const socket = new WebSocket(this.config.url, { + headers: { authorization: `Bearer ${this.config.key}` }, + handshakeTimeout: 10_000, + maxPayload: 1024 * 1024, + perMessageDeflate: false, + followRedirects: false, + }) + this.socket = socket + let welcomed = false + let lastMessage = Date.now() + const heartbeat = setInterval(() => { + if (Date.now() - lastMessage > (welcomed ? 75_000 : 10_000)) socket.terminate() + }, 5_000) + socket.on('error', () => { + /* Close drives reconnect; never print credential-bearing request errors. */ + }) + socket.on('unexpected-response', (_request, response) => { + response.destroy() + socket.terminate() + if ([401, 403, 404, 426].includes(response.statusCode ?? 0)) + reject( + new CliError( + `Runner connection rejected (HTTP ${response.statusCode}). Check the server URL and runner key.`, + ), + ) + }) + socket.on('close', (code) => { + clearInterval(heartbeat) + this.ready = false + if (code === 1008 && !this.stopped.signal.aborted) + reject( + new CliError('Runner access was revoked or another connection replaced this runner.'), + ) + else resolve(welcomed) + }) + socket.on('message', (raw) => { + try { + const parsed = serverToRunnerMessageSchema.parse(JSON.parse(raw.toString())) + if ('executionId' in parsed && !/^[A-Za-z0-9_-]{1,128}$/.test(parsed.executionId)) + throw new Error('Invalid execution ID.') + lastMessage = Date.now() + if (parsed.type === 'welcome') { + if (welcomed) throw new Error('Duplicate welcome.') + welcomed = true + this.ready = true + this.reconcile(parsed.inFlightExecutionIds) + this.log(`Runner connected: ${parsed.runnerName} (${parsed.runnerId})`) + } else { + if (!welcomed) throw new Error('Expected welcome before runner requests.') + this.handle(parsed) + } + } catch { + reject(new CliError('Server sent an invalid runner protocol message.')) + socket.terminate() + } + }) + if (this.stopped.signal.aborted) socket.terminate() + }) + } + + private send(message: RunnerToServerMessage) { + if (this.ready && this.socket?.readyState === WebSocket.OPEN) + this.socket.send(JSON.stringify(message)) + } + + private reconcile(inFlight: string[]) { + const expected = new Set(inFlight) + for (const [id, execution] of this.executions) { + if (!expected.has(id)) { + execution.controller.abort() + if (execution.result) this.executions.delete(id) + continue + } + // Replay before results: the server deduplicates chunks by UTF-8 byte offset. + for (const chunk of execution.chunks) this.send(chunk) + } + this.send({ + type: 'reconcile', + environment: this.shell.environment, + activeExecutions: [...this.executions] + .filter(([id, execution]) => expected.has(id) && !execution.result) + .map(([executionId, execution]) => ({ executionId, nextOffset: execution.offset })), + completedExecutions: [...this.executions] + .filter(([id, execution]) => expected.has(id) && execution.result) + .map(([, execution]) => execution.result!), + }) + } + + private handle(message: Exclude) { + if (message.type === 'ping') { + this.send({ type: 'pong', ts: message.ts }) + return + } + if (message.type === 'exec.cancel') { + this.executions.get(message.executionId)?.controller.abort() + return + } + if (message.type === 'exec.start') { + const previous = this.executions.get(message.executionId) + if (previous) { + if (previous.result) this.send(previous.result) + return + } + const execution: Execution = { + controller: new AbortController(), + chunks: [], + bytes: 0, + offset: 0, + } + this.executions.set(message.executionId, execution) + this.track( + (async () => { + const busy = this.activeCount() > MAX_ACTIVE + const result = busy + ? { + type: 'exec.result' as const, + executionId: message.executionId, + exitCode: null, + signal: null, + timedOut: false, + error: 'Runner is busy. Try again later.', + } + : await this.shell.run(message, execution.controller.signal, (stream, data) => { + // Small frames keep reconnect replay and WebSocket buffering bounded. + for (const part of data.match(/[\s\S]{1,8192}/gu) ?? []) { + const chunk: RunnerExecOutputMessage = { + type: 'exec.output', + executionId: message.executionId, + stream, + data: part, + offset: execution.offset, + } + const bytes = Buffer.byteLength(part) + execution.offset += bytes + execution.bytes += bytes + execution.chunks.push(chunk) + while (execution.bytes > MAX_REPLAY_BYTES) { + const removed = execution.chunks.shift()! + execution.bytes -= Buffer.byteLength(removed.data) + if (!this.ready) execution.controller.abort() + } + if ((this.socket?.bufferedAmount ?? 0) > MAX_REPLAY_BYTES) { + this.ready = false + this.socket?.terminate() + } + this.send(chunk) + } + }) + execution.result = result + this.send(result) + const completed = [...this.executions].filter(([, value]) => value.result) + for (const [id] of completed.slice(0, -MAX_COMPLETED)) this.executions.delete(id) + })(), + ) + return + } + this.handleFile(message) + } + + private activeCount() { + return ( + [...this.executions.values()].filter((execution) => !execution.result).length + + this.transfers.size + ) + } + + private handleFile(message: FileMessage) { + const previous = this.completedFiles.get(message.executionId) + if (previous) { + this.send(previous) + return + } + if (this.transfers.has(message.executionId)) return + const controller = new AbortController() + this.transfers.set(message.executionId, controller) + const timer = setTimeout(() => controller.abort(), 120_000) + this.track( + (async () => { + try { + const result = + this.activeCount() > MAX_ACTIVE + ? this.fileBusy(message) + : await this.files.handle(message, controller.signal) + this.completedFiles.set(message.executionId, result) + if (this.completedFiles.size > MAX_COMPLETED) + this.completedFiles.delete(this.completedFiles.keys().next().value!) + this.send(result) + } finally { + clearTimeout(timer) + this.transfers.delete(message.executionId) + } + })(), + ) + } + + private fileBusy(message: FileMessage): RunnerToServerMessage { + const result = { + executionId: message.executionId, + ok: false, + error: 'Runner is busy. Try again later.', + } + switch (message.type) { + case 'file.download': + return { ...result, type: 'file.download.result' } + case 'file.upload': + return { ...result, type: 'file.upload.result' } + case 'file.stat': + return { ...result, type: 'file.stat.result', exists: false } + } + } + + private track(task: Promise) { + this.pending.add(task) + void task.finally(() => this.pending.delete(task)).catch(() => this.stop()) + } +} + +export async function startRunner(options: RunnerOptions) { + const config = await resolveRunnerConfig(options) + // SRT resolves relative policy paths against the runner workspace. + process.chdir(config.cwd) + const files = new RunnerFiles(config.cwd) + const shell = new RunnerShell(files, config.srt) + await shell.initialize() + const runner = new RunnerClient(config, files, shell) + const controller = new AbortController() + const shutdown = () => controller.abort() + process.once('SIGINT', shutdown) + process.once('SIGTERM', shutdown) + try { + await runner.run(controller.signal) + } finally { + process.removeListener('SIGINT', shutdown) + process.removeListener('SIGTERM', shutdown) + await shell.close() + } +} diff --git a/apps/cli/src/runner/config.test.ts b/apps/cli/src/runner/config.test.ts new file mode 100644 index 00000000..f8f1f1d1 --- /dev/null +++ b/apps/cli/src/runner/config.test.ts @@ -0,0 +1,71 @@ +import { afterEach, describe, expect, it, vi } from 'vitest' +import { commandEnv, resolveRunnerConfig, runnerShell } from './config' + +afterEach(() => vi.unstubAllEnvs()) + +describe('runner configuration', () => { + it('uses the platform shell without requiring Bash on Windows', () => { + vi.stubEnv('SystemRoot', 'D:\\Windows') + expect(runnerShell('win32')).toBe('D:\\Windows\\System32\\cmd.exe') + expect(runnerShell('linux')).toBe('/bin/sh') + expect(runnerShell('darwin')).toBe('/bin/sh') + }) + + it('preserves Windows OS settings, normalizes explicit overrides, and excludes credentials', () => { + vi.stubEnv('Path', 'C:\\Windows\\System32') + vi.stubEnv('SystemRoot', 'C:\\Windows') + vi.stubEnv('USERPROFILE', 'C:\\Users\\runner') + const env = commandEnv({ PATH: 'C:\\tools', ['shumai_runner_key']: 'secret' }) + expect(env).toMatchObject({ + PATH: 'C:\\tools', + SystemRoot: 'C:\\Windows', + USERPROFILE: 'C:\\Users\\runner', + }) + expect(env).not.toHaveProperty('Path') + expect(env).not.toHaveProperty('shumai_runner_key') + }) + it('uses a dedicated runner key and preserves a server path prefix', async () => { + vi.stubEnv('SHUMAI_API_SERVER', 'https://example.com/shumai/') + vi.stubEnv('SHUMAI_RUNNER_KEY', 'runner-secret') + const config = await resolveRunnerConfig({}) + expect(config.url.href).toBe('wss://example.com/shumai/api/runners/ws') + expect(config.key).toBe('runner-secret') + expect(config.cwd).toBe(process.cwd()) + }) + + it.each([ + 'http://example.com', + 'ftp://localhost', + 'https://user:secret@example.com', + 'https://example.com/?key=secret', + 'not a URL', + ])('rejects unsafe server URL %s', async (url) => { + await expect(resolveRunnerConfig({ url, key: 'key' })).rejects.toThrow() + }) + + it('allows the Docker host development address', async () => { + expect( + (await resolveRunnerConfig({ url: 'http://host.docker.internal:3000', key: 'key' })).url.href, + ).toBe('ws://host.docker.internal:3000/api/runners/ws') + }) + + it('does not accept a personal API token in place of a missing runner key', async () => { + vi.stubEnv('SHUMAI_RUNNER_KEY', '') + vi.stubEnv('SHUMAI_API_KEY', 'personal-secret') + await expect(resolveRunnerConfig({ url: 'https://example.com' })).rejects.toThrow( + 'SHUMAI_RUNNER_KEY', + ) + }) + + it('inherits only baseline environment and explicit skill variables', () => { + vi.stubEnv('SHUMAI_RUNNER_KEY', 'runner-secret') + vi.stubEnv('SHUMAI_API_KEY', 'personal-secret') + vi.stubEnv('AWS_SECRET_ACCESS_KEY', 'aws-secret') + vi.stubEnv('BASH_ENV', '/malicious-startup') + expect( + commandEnv({ SKILL_TOKEN: 'skill-secret', SHUMAI_RUNNER_KEY: 'injected' }), + ).toMatchObject({ SKILL_TOKEN: 'skill-secret' }) + for (const name of ['SHUMAI_RUNNER_KEY', 'SHUMAI_API_KEY', 'AWS_SECRET_ACCESS_KEY', 'BASH_ENV']) + expect(commandEnv()).not.toHaveProperty(name) + }) +}) diff --git a/apps/cli/src/runner/config.ts b/apps/cli/src/runner/config.ts new file mode 100644 index 00000000..03179237 --- /dev/null +++ b/apps/cli/src/runner/config.ts @@ -0,0 +1,75 @@ +import { realpath, stat } from 'node:fs/promises' +import path from 'node:path' +import { CliError } from '../operations/errors' + +export interface RunnerOptions { + url?: string + key?: string + cwd?: string + srt?: string +} + +export async function resolveRunnerConfig(options: RunnerOptions) { + const address = options.url ?? process.env.SHUMAI_API_SERVER + const key = options.key ?? process.env.SHUMAI_RUNNER_KEY + if (!address) throw new CliError('Set SHUMAI_API_SERVER or pass --url.') + if (!key?.trim()) throw new CliError('Set SHUMAI_RUNNER_KEY or pass --key with a runner key.') + let url: URL + try { + url = new URL(address) + } catch { + throw new CliError('Invalid Shumai server URL.') + } + if ( + url.username || + url.password || + url.search || + url.hash || + !['http:', 'https:'].includes(url.protocol) + ) { + throw new CliError( + 'Use an http:// or https:// server URL without credentials, query, or fragment.', + ) + } + const localHosts = ['localhost', '127.0.0.1', '[::1]', 'host.docker.internal'] + if (url.protocol === 'http:' && !localHosts.includes(url.hostname)) { + throw new CliError( + 'Remote runners require HTTPS. HTTP is only supported for local development.', + ) + } + url.protocol = url.protocol === 'https:' ? 'wss:' : 'ws:' + url.pathname = `${url.pathname.replace(/\/+$/, '')}/api/runners/ws` + const cwd = await realpath(path.resolve(options.cwd ?? process.cwd())) + if (!(await stat(cwd)).isDirectory()) throw new CliError('Runner workspace must be a directory.') + return { url, key: key.trim(), cwd, srt: options.srt ? path.resolve(options.srt) : undefined } +} + +export function runnerShell(platform = process.platform): string { + return platform === 'win32' + ? path.win32.join(process.env.SystemRoot ?? 'C:\\Windows', 'System32', 'cmd.exe') + : '/bin/sh' +} + +/** Commands inherit baseline OS settings and explicitly supplied skill variables, never CLI credentials. */ +export function commandEnv(extra: Record = {}, inherit = true): NodeJS.ProcessEnv { + const env: NodeJS.ProcessEnv = {} + for (const [key, value] of Object.entries(inherit ? process.env : {})) { + if ( + /^(PATH|PATHEXT|HOME|USER|LOGNAME|LANG|TERM|TMPDIR|TEMP|TMP|SYSTEMROOT|SYSTEMDRIVE|COMSPEC|USERPROFILE|USERNAME|APPDATA|LOCALAPPDATA|PROGRAMDATA|PROGRAMFILES|PROGRAMFILES\(X86\)|LC_.*)$/i.test( + key, + ) + ) + env[key] = value + } + for (const [key, value] of Object.entries(extra)) { + if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(key)) + throw new Error('Invalid skill environment variable name.') + if (['SHUMAI_RUNNER_KEY', 'SHUMAI_API_KEY'].includes(key.toUpperCase())) continue + // Windows treats environment names as case-insensitive. + for (const existing of Object.keys(env)) { + if (existing.toUpperCase() === key.toUpperCase()) delete env[existing] + } + env[key] = value + } + return env +} diff --git a/apps/cli/src/runner/files.test.ts b/apps/cli/src/runner/files.test.ts new file mode 100644 index 00000000..81eae59b --- /dev/null +++ b/apps/cli/src/runner/files.test.ts @@ -0,0 +1,325 @@ +import { createHash } from 'node:crypto' +import { createServer, type Server } from 'node:http' +import { mkdtemp, mkdir, readFile, readdir, rm, stat, symlink, writeFile } from 'node:fs/promises' +import { tmpdir } from 'node:os' +import path from 'node:path' +import AdmZip from 'adm-zip' +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' +import { RunnerFiles } from './files' + +describe('runner workspace file transfers', () => { + let cwd: string + let files: RunnerFiles + let server: Server + let url: string + let body: Buffer + let uploaded: Buffer + beforeEach(async () => { + cwd = await mkdtemp(path.join(tmpdir(), 'shumai-files-test-')) + files = new RunnerFiles(cwd) + body = Buffer.from('download contents') + uploaded = Buffer.alloc(0) + server = createServer(async (request, response) => { + if (request.method === 'PUT') { + const chunks: Buffer[] = [] + for await (const chunk of request) chunks.push(Buffer.from(chunk)) + uploaded = Buffer.concat(chunks) + response.end() + } else if (request.url === '/slow') { + const timer = setInterval(() => response.write(Buffer.alloc(65536)), 20) + response.once('close', () => clearInterval(timer)) + } else if (request.url === '/redirect') { + response.writeHead(302, { location: '/file' }) + response.end() + } else response.end(body) + }) + await new Promise((resolve) => server.listen(0, '127.0.0.1', resolve)) + const address = server.address() + if (!address || typeof address === 'string') throw new Error('Missing test HTTP address') + url = `http://127.0.0.1:${address.port}` + }) + afterEach(async () => { + server.closeAllConnections() + await new Promise((resolve) => server.close(() => resolve())) + await rm(cwd, { recursive: true, force: true }) + }) + + const signal = () => new AbortController().signal + + it('downloads, checks SHA-256, stats and uploads actual bytes', async () => { + expect( + await files.handle( + { + type: 'file.download', + executionId: 'download', + url, + destPath: '.pi/input/data.bin', + expectedHash: createHash('sha256').update(body).digest('hex'), + }, + signal(), + ), + ).toMatchObject({ ok: true, size: body.length }) + expect(await readFile(path.join(cwd, '.pi/input/data.bin'))).toEqual(body) + expect( + await files.handle( + { type: 'file.stat', executionId: 'stat', srcPath: '.pi/input/data.bin' }, + signal(), + ), + ).toMatchObject({ ok: true, exists: true, isFile: true, size: body.length }) + expect( + await files.handle( + { type: 'file.upload', executionId: 'upload', srcPath: '.pi/input/data.bin', url }, + signal(), + ), + ).toMatchObject({ ok: true, size: body.length, name: 'data.bin' }) + expect(uploaded).toEqual(body) + expect( + await files.handle( + { type: 'file.stat', executionId: 'absent', srcPath: '.pi/absent' }, + signal(), + ), + ).toMatchObject({ ok: true, exists: false }) + }) + + it('does not publish mismatched downloads or follow redirects', async () => { + expect( + await files.handle( + { + type: 'file.download', + executionId: 'bad-hash', + url, + destPath: '.pi/data', + expectedHash: 'bad', + }, + signal(), + ), + ).toMatchObject({ ok: false, error: 'Downloaded file hash does not match.' }) + await expect(readFile(path.join(cwd, '.pi/data'))).rejects.toThrow() + expect( + await files.handle( + { + type: 'file.download', + executionId: 'redirect', + url: `${url}/redirect`, + destPath: '.pi/data', + }, + signal(), + ), + ).toHaveProperty('ok', false) + }) + + it.each([ + '../secret', + '/etc/passwd', + '.pi/../secret', + '.pi/dir/../../secret', + '.pi\\secret', + '.pi//file', + '.pi/a:b', + '.pi/a\0b', + '.pi/.. /outside', + '.pi/folder./file', + '.pi/CON.txt', + '.pi/nul .txt', + '.pi/COM1', + '.pi/lpt¹.log', + '.pi/CONOUT$', + ])('rejects unsafe protocol path %s', async (srcPath) => { + expect( + await files.handle({ type: 'file.stat', executionId: 'unsafe', srcPath }, signal()), + ).toHaveProperty('ok', false) + }) + + it('rejects parent and final symlinks, including a replaced .pi root', async () => { + await mkdir(path.join(cwd, '.pi')) + await writeFile(path.join(cwd, 'secret'), 'secret') + await symlink(cwd, path.join(cwd, '.pi/escape')) + await symlink(path.join(cwd, 'secret'), path.join(cwd, '.pi/link')) + for (const srcPath of ['.pi/escape/secret', '.pi/link']) { + expect( + await files.handle({ type: 'file.upload', executionId: 'symlink', srcPath, url }, signal()), + ).toHaveProperty('ok', false) + } + await rm(path.join(cwd, '.pi'), { recursive: true }) + await symlink(cwd, path.join(cwd, '.pi')) + expect( + await files.handle( + { type: 'file.download', executionId: 'root', destPath: '.pi/file', url }, + signal(), + ), + ).toHaveProperty('ok', false) + }) + + it('extracts skills and safely replaces old contents', async () => { + const zip = new AdmZip() + zip.addFile('SKILL.md', Buffer.from('# Test skill')) + zip.addFile('scripts/run.sh', Buffer.from('echo skill')) + body = zip.toBuffer() + for (let attempt = 0; attempt < 2; attempt++) { + expect( + await files.handle( + { + type: 'file.download', + executionId: `zip-${attempt}`, + url, + destPath: '.pi/skills/test', + extractZip: true, + }, + signal(), + ), + ).toHaveProperty('ok', true) + } + expect(await readFile(path.join(cwd, '.pi/skills/test/SKILL.md'), 'utf8')).toBe('# Test skill') + }) + + it('rejects symlink ZIP entries and zip-slip paths without publishing them', async () => { + const zip = new AdmZip() + zip.addFile('link', Buffer.from('/etc/passwd')) + const entry = zip.getEntry('link')! + entry.header.attr = (0o120777 << 16) >>> 0 + body = zip.toBuffer() + expect( + await files.handle( + { + type: 'file.download', + executionId: 'zip-link', + url, + destPath: '.pi/skills/bad', + extractZip: true, + }, + signal(), + ), + ).toHaveProperty('ok', false) + const normal = new AdmZip() + normal.addFile('aa/secret', Buffer.from('escape')) + body = Buffer.from( + normal.toBuffer().toString('latin1').replaceAll('aa/secret', '../secret'), + 'latin1', + ) + expect( + await files.handle( + { + type: 'file.download', + executionId: 'zip-slip', + url, + destPath: '.pi/skills/bad', + extractZip: true, + }, + signal(), + ), + ).toHaveProperty('ok', false) + await expect(readFile(path.join(cwd, '.pi/skills/bad/link'))).rejects.toThrow() + }) + + it('preserves executable script permissions and rejects oversized ZIP entries', async () => { + const zip = new AdmZip() + zip.addFile('run.sh', Buffer.from('#!/bin/sh\necho executable\n')) + zip.getEntry('run.sh')!.header.attr = (0o100755 << 16) >>> 0 + body = zip.toBuffer() + expect( + await files.handle( + { + type: 'file.download', + executionId: 'exec-zip', + url, + destPath: '.pi/skills/executable', + extractZip: true, + }, + signal(), + ), + ).toHaveProperty('ok', true) + expect((await stat(path.join(cwd, '.pi/skills/executable/run.sh'))).mode & 0o7777).toBe(0o755) + const central = body.indexOf(Buffer.from([0x50, 0x4b, 0x01, 0x02])) + body.writeUInt32LE(256 * 1024 * 1024 + 1, central + 24) + expect( + await files.handle( + { + type: 'file.download', + executionId: 'large-zip', + url, + destPath: '.pi/skills/large', + extractZip: true, + }, + signal(), + ), + ).toMatchObject({ ok: false, error: 'Extracted ZIP exceeds 256 MiB.' }) + }) + + it('cancels a streaming download without publishing partial bytes or leaving staging files', async () => { + await mkdir(path.join(cwd, '.pi/input'), { recursive: true }) + await writeFile(path.join(cwd, '.pi/input/data'), 'original') + const controller = new AbortController() + const transfer = files.handle( + { + type: 'file.download', + executionId: 'stream-cancel', + url: `${url}/slow`, + destPath: '.pi/input/data', + }, + controller.signal, + ) + await vi.waitFor(async () => + expect( + (await readdir(path.join(cwd, '.pi/input'))).some((name) => name.startsWith('.shumai-')), + ).toBe(true), + ) + controller.abort() + expect(await transfer).toHaveProperty('ok', false) + expect(await readFile(path.join(cwd, '.pi/input/data'), 'utf8')).toBe('original') + expect(await readdir(path.join(cwd, '.pi/input'))).toEqual(['data']) + }) + + it('cancels extraction without deleting the installed skill or leaving staging trees', async () => { + await mkdir(path.join(cwd, '.pi/skills/installed'), { recursive: true }) + await writeFile(path.join(cwd, '.pi/skills/installed/SKILL.md'), 'original') + const zip = new AdmZip() + for (let index = 0; index < 2000; index++) + zip.addFile(`file-${index}.txt`, Buffer.alloc(32768, 65)) + body = zip.toBuffer() + const controller = new AbortController() + const transfer = files.handle( + { + type: 'file.download', + executionId: 'extract-cancel', + url, + destPath: '.pi/skills/installed', + extractZip: true, + }, + controller.signal, + ) + await vi.waitFor( + async () => { + const temporary = (await readdir(path.join(cwd, '.pi/skills'))).find((name) => + name.startsWith('.shumai-'), + ) + expect(temporary).toBeDefined() + expect( + (await readdir(path.join(cwd, '.pi/skills', temporary!, 'extracted'))).length, + ).toBeGreaterThan(0) + }, + { interval: 5, timeout: 5000 }, + ) + controller.abort() + expect(await transfer).toHaveProperty('ok', false) + expect(await readFile(path.join(cwd, '.pi/skills/installed/SKILL.md'), 'utf8')).toBe('original') + expect(await readdir(path.join(cwd, '.pi/skills'))).toEqual(['installed']) + }, 10000) + + it('handles cancelled transfers and refuses uploads of directories', async () => { + const controller = new AbortController() + controller.abort() + expect( + await files.handle( + { type: 'file.download', executionId: 'cancelled', url, destPath: '.pi/data' }, + controller.signal, + ), + ).toHaveProperty('ok', false) + expect( + await files.handle( + { type: 'file.upload', executionId: 'directory', url, srcPath: '.pi/transfers' }, + signal(), + ), + ).toHaveProperty('ok', false) + expect(uploaded).toHaveLength(0) + }) +}) diff --git a/apps/cli/src/runner/files.ts b/apps/cli/src/runner/files.ts new file mode 100644 index 00000000..4a17709f --- /dev/null +++ b/apps/cli/src/runner/files.ts @@ -0,0 +1,287 @@ +import { createHash } from 'node:crypto' +import { on } from 'node:events' +import { constants, createWriteStream } from 'node:fs' +import { lstat, mkdir, mkdtemp, open, rename, rm } from 'node:fs/promises' +import path from 'node:path' +import { Readable, Transform } from 'node:stream' +import { pipeline } from 'node:stream/promises' +import yauzl from 'yauzl' +import type { + RunnerFileDownloadMessage, + RunnerFileUploadMessage, + RunnerFileStatMessage, + RunnerToServerMessage, +} from '@shumai/dtos' + +const MAX_FILE_BYTES = 256 * 1024 * 1024 +const MAX_ZIP_ENTRIES = 10_000 +export type FileMessage = + RunnerFileDownloadMessage | RunnerFileUploadMessage | RunnerFileStatMessage + +function pathParts(value: string): string[] { + const parts = value.split('/') + if ( + value.includes('\\') || + value.includes('\0') || + parts.some( + (part) => + !part || + part === '.' || + part === '..' || + part.includes(':') || + /[. ]$/.test(part) || + /^(?:con|prn|aux|nul|conin\$|conout\$|com[1-9¹²³]|lpt[1-9¹²³])(?: *\.|$)/i.test(part), + ) + ) + throw new Error('Invalid workspace path.') + return parts +} + +function isMissing(error: unknown): boolean { + return error instanceof Error && 'code' in error && error.code === 'ENOENT' +} + +function transferUrl(address: string): URL { + const url = new URL(address) + if (!['http:', 'https:'].includes(url.protocol) || url.username || url.password) + throw new Error('Invalid transfer URL.') + return url +} + +export class RunnerFiles { + constructor(readonly cwd: string) {} + + /** Basic workspace validation. Concurrent hostile filesystem mutation is outside v1's scope. */ + private async resolve(relative: string, createParents = false): Promise { + const parts = pathParts(relative) + if (parts[0] !== '.pi' || parts.length < 2) throw new Error('File paths must stay inside .pi/.') + let current = this.cwd + for (let index = 0; index < parts.length; index++) { + current = path.join(current, parts[index]) + const parent = index < parts.length - 1 + if (parent && createParents) await mkdir(current, { recursive: true, mode: 0o700 }) + try { + const info = await lstat(current) + if (info.isSymbolicLink() || (parent && !info.isDirectory())) + throw new Error('Workspace paths cannot contain symlinks or non-directory parents.') + } catch (error) { + if (!isMissing(error)) throw error + } + } + return current + } + + async createWriter(relative: string) { + const file = await open( + await this.resolve(relative, true), + constants.O_CREAT | constants.O_EXCL | constants.O_WRONLY | constants.O_NOFOLLOW, + 0o600, + ) + return { + write: async (data: string) => { + await file.writeFile(data) + }, + close: () => file.close(), + } + } + + async handle(message: FileMessage, signal: AbortSignal): Promise { + try { + signal.throwIfAborted() + if (message.type === 'file.download') + return { + type: 'file.download.result', + executionId: message.executionId, + ok: true, + ...(await this.download(message, signal)), + } + const filename = await this.resolve(message.srcPath) + if (message.type === 'file.upload') return await this.upload(message, filename, signal) + try { + const info = await lstat(filename) + return { + type: 'file.stat.result', + executionId: message.executionId, + ok: true, + exists: true, + isFile: info.isFile(), + size: info.size, + name: path.basename(filename), + } + } catch (error) { + if (!isMissing(error)) throw error + return { + type: 'file.stat.result', + executionId: message.executionId, + ok: true, + exists: false, + } + } + } catch (error) { + const result = { + executionId: message.executionId, + ok: false, + error: error instanceof Error ? error.message : 'File operation failed.', + } + switch (message.type) { + case 'file.download': + return { ...result, type: 'file.download.result' } + case 'file.upload': + return { ...result, type: 'file.upload.result' } + case 'file.stat': + return { ...result, type: 'file.stat.result', exists: false } + } + } + } + + private async upload( + message: RunnerFileUploadMessage, + filename: string, + signal: AbortSignal, + ): Promise { + const file = await open( + filename, + constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK, + ) + try { + const info = await file.stat() + if (!info.isFile() || info.size > MAX_FILE_BYTES) + throw new Error('Upload must be a regular file no larger than 256 MiB.') + // Node and Bun declare different DOM stream types for the same fetch-compatible stream. + const body = info.size + ? (Readable.toWeb( + file.createReadStream({ autoClose: false, end: info.size - 1 }), + ) as unknown as ReadableStream) + : new Uint8Array() + const response = await fetch(transferUrl(message.url), { + method: 'PUT', + body, + ...{ duplex: 'half' }, + headers: { + 'content-type': message.contentType ?? 'application/octet-stream', + 'content-length': String(info.size), + }, + signal, + redirect: 'error', + }) + await response.body?.cancel() + if (!response.ok) throw new Error(`Upload failed (HTTP ${response.status}).`) + return { + type: 'file.upload.result', + executionId: message.executionId, + ok: true, + size: info.size, + name: path.basename(filename), + } + } finally { + await file.close() + } + } + + private async download(message: RunnerFileDownloadMessage, signal: AbortSignal) { + const destination = await this.resolve(message.destPath, true) + const temporary = await mkdtemp(path.join(path.dirname(destination), '.shumai-')) + let preserveBackup = false + try { + const response = await fetch(transferUrl(message.url), { signal, redirect: 'error' }) + if (!response.ok || !response.body) { + await response.body?.cancel() + throw new Error(`Download failed (HTTP ${response.status}).`) + } + const hash = createHash('sha256') + let size = 0 + const archive = path.join(temporary, 'download') + await pipeline( + response.body, + new Transform({ + transform(chunk: Buffer, _encoding, callback) { + size += chunk.length + if (size > MAX_FILE_BYTES) { + callback(new Error('Download exceeds 256 MiB.')) + return + } + hash.update(chunk) + callback(null, chunk) + }, + }), + createWriteStream(archive, { flags: 'wx', mode: 0o600 }), + { signal }, + ) + if (message.expectedHash && hash.digest('hex') !== message.expectedHash) + throw new Error('Downloaded file hash does not match.') + let source = archive + if (message.extractZip) { + source = path.join(temporary, 'extracted') + await mkdir(source, { mode: 0o700 }) + await this.extract(archive, source, signal) + } + signal.throwIfAborted() + await this.resolve(message.destPath) + if (message.extractZip) { + const backup = path.join(temporary, 'previous') + let backedUp = false + try { + await rename(destination, backup) + backedUp = true + } catch (error) { + if (!isMissing(error)) throw error + } + try { + await rename(source, destination) + } catch (error) { + if (backedUp) { + preserveBackup = true + await rename(backup, destination) + preserveBackup = false + } + throw error + } + } else await rename(source, destination) + return { size, cached: false } + } finally { + if (!preserveBackup) await rm(temporary, { recursive: true, force: true }) + } + } + + private async extract(archive: string, directory: string, signal: AbortSignal) { + const zip = await new Promise((resolve, reject) => + yauzl.open( + archive, + { lazyEntries: true, strictFileNames: true, autoClose: false }, + (error, opened) => (error ? reject(error) : resolve(opened)), + ), + ) + let size = 0 + let count = 0 + try { + const entries = on(zip, 'entry', { close: ['end'], signal }) as AsyncIterable<[yauzl.Entry]> + zip.readEntry() + for await (const [entry] of entries) { + if (++count > MAX_ZIP_ENTRIES) throw new Error('ZIP contains too many entries.') + const parts = pathParts(entry.fileName.replace(/\/$/, '')) + const mode = entry.externalFileAttributes >>> 16 + const kind = mode & 0o170000 + if (kind && kind !== 0o100000 && kind !== 0o040000) + throw new Error('ZIP links and special files are forbidden.') + size += entry.uncompressedSize + if (size > MAX_FILE_BYTES) throw new Error('Extracted ZIP exceeds 256 MiB.') + const destination = path.join(directory, ...parts) + if (entry.fileName.endsWith('/')) await mkdir(destination, { recursive: true, mode: 0o700 }) + else { + await mkdir(path.dirname(destination), { recursive: true, mode: 0o700 }) + const input = await new Promise((resolve, reject) => + zip.openReadStream(entry, (error, stream) => (error ? reject(error) : resolve(stream))), + ) + await pipeline( + input, + createWriteStream(destination, { flags: 'wx', mode: 0o600 | (mode & 0o155) }), + { signal }, + ) + } + zip.readEntry() + } + } finally { + zip.close() + } + } +} diff --git a/apps/cli/src/runner/shell.test.ts b/apps/cli/src/runner/shell.test.ts new file mode 100644 index 00000000..744071da --- /dev/null +++ b/apps/cli/src/runner/shell.test.ts @@ -0,0 +1,298 @@ +import { mkdtemp, readFile, rm, writeFile } from 'node:fs/promises' +import { tmpdir } from 'node:os' +import path from 'node:path' +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' +import { SandboxManager } from '@anthropic-ai/sandbox-runtime' +import { RunnerFiles } from './files' +import { RunnerShell } from './shell' + +describe('runner bash execution', () => { + let cwd: string + let shell: RunnerShell + beforeEach(async () => { + cwd = await mkdtemp(path.join(tmpdir(), 'shumai-shell-test-')) + shell = new RunnerShell(new RunnerFiles(cwd)) + vi.spyOn(SandboxManager, 'initialize').mockResolvedValue() + vi.spyOn(SandboxManager, 'reset').mockResolvedValue() + vi.spyOn(SandboxManager, 'wrapWithSandboxArgv').mockImplementation(async (command) => ({ + argv: ['/bin/sh', '-c', command], + env: process.env, + })) + }) + afterEach(async () => { + await shell.close() + vi.restoreAllMocks() + vi.unstubAllEnvs() + await rm(cwd, { recursive: true, force: true }) + }) + + const request = (command: string, executionId = 'test') => ({ + type: 'exec.start' as const, + executionId, + command, + }) + + it('runs with no executables on PATH when SRT is not requested', async () => { + vi.stubEnv('PATH', '') + await shell.initialize() + let output = '' + const result = await shell.run( + request('printf no-extra-runtime'), + new AbortController().signal, + (_stream, data) => { + output += data + }, + ) + expect(result).toMatchObject({ exitCode: 0 }) + expect(output).toBe('no-extra-runtime') + }) + + it('streams both outputs, returns the exit code, and saves a log in the runner workspace', async () => { + const output: string[] = [] + const result = await shell.run( + request('printf "hello 世界"; printf "failure" >&2; exit 7'), + new AbortController().signal, + (stream, data) => output.push(`${stream}:${data}`), + ) + expect(result).toMatchObject({ + exitCode: 7, + signal: null, + timedOut: false, + fullOutputPath: '.pi/logs/bash-test.log', + }) + expect(output.join('|')).toContain('stdout:hello 世界') + expect(output.join('|')).toContain('stderr:failure') + expect(await readFile(path.join(cwd, result.fullOutputPath!), 'utf8')).toContain('hello 世界') + }) + + it('passes skill env without inheriting runner or unrelated credentials', async () => { + vi.stubEnv('SHUMAI_RUNNER_KEY', 'runner-secret') + vi.stubEnv('AWS_SECRET_ACCESS_KEY', 'aws-secret') + let output = '' + await shell.run( + { + ...request( + 'printf "%s|%s|%s" "$SKILL_TOKEN" "$SHUMAI_RUNNER_KEY" "$AWS_SECRET_ACCESS_KEY"', + ), + env: { SKILL_TOKEN: 'skill-secret' }, + }, + new AbortController().signal, + (_stream, data) => { + output += data + }, + ) + expect(output).toBe('skill-secret||') + }) + + it('times out and terminates background children', async () => { + const result = await shell.run( + { ...request('sleep 30 & echo $!; wait'), timeoutSec: 0.1 }, + new AbortController().signal, + () => {}, + ) + expect(result).toMatchObject({ timedOut: true, signal: 'SIGKILL' }) + const pid = Number((await readFile(path.join(cwd, '.pi/logs/bash-test.log'), 'utf8')).trim()) + expect(() => process.kill(pid, 0)).toThrow() + }) + + it('cancels a running command and never starts an already cancelled one', async () => { + const controller = new AbortController() + const running = shell.run(request('echo ready; sleep 30'), controller.signal, () => + controller.abort(), + ) + expect(await running).toMatchObject({ aborted: true, signal: 'SIGKILL' }) + expect( + await shell.run(request('touch unwanted', 'cancelled'), controller.signal, () => {}), + ).toMatchObject({ aborted: true }) + await expect(readFile(path.join(cwd, 'unwanted'))).rejects.toThrow() + }) + + it('finishes draining after a timely root exit even if a background process holds the pipes', async () => { + const source = `const {spawn} = require('node:child_process'); const child = spawn(process.execPath, ['-e', 'setTimeout(() => {}, 30000)'], {detached: true, stdio: ['ignore', 1, 2]}); console.log(child.pid); child.unref()` + const quote = (value: string) => `'${value.replaceAll("'", "'\\''")}'` + const result = await shell.run( + { ...request(`${quote(process.execPath)} -e ${quote(source)}`), timeoutSec: 0.5 }, + new AbortController().signal, + () => {}, + ) + const pid = Number((await readFile(path.join(cwd, '.pi/logs/bash-test.log'), 'utf8')).trim()) + try { + expect(result).toMatchObject({ exitCode: 0, timedOut: false, aborted: false }) + expect(result.error).toBeUndefined() + } finally { + if (pid > 0) process.kill(pid, 'SIGKILL') + } + }) + + it('reports launch failure without including command text or skill secrets', async () => { + shell.environment.shell = path.join(cwd, 'missing-shell') + const result = await shell.run( + request('echo private-command'), + new AbortController().signal, + () => {}, + ) + expect(result).toMatchObject({ + exitCode: null, + signal: null, + error: 'Command execution failed (ENOENT).', + }) + expect(result.error).not.toContain('private-command') + }) + + it('terminates a running process if the output consumer fails', async () => { + let pid = 0 + const result = await shell.run( + request('printf "%s\\n" "$$"; sleep 30'), + new AbortController().signal, + (_stream, data) => { + pid = Number(data.trim()) + throw new Error('Output consumer failed') + }, + ) + expect(result.error).toBe('Output consumer failed') + expect(pid).toBeGreaterThan(0) + expect(() => process.kill(pid, 0)).toThrow() + }) + + it('rejects invalid timeouts and caps runaway output', async () => { + expect( + await shell.run( + { ...request('sleep 30'), timeoutSec: -1 }, + new AbortController().signal, + () => {}, + ), + ).toHaveProperty('error') + expect( + await shell.run( + request('head -c 70000000 /dev/zero', 'large'), + new AbortController().signal, + () => {}, + ), + ).toMatchObject({ error: 'Command exceeded the 64 MiB output limit.' }) + }) + + it('uses the exact SRT JSON snapshot and validates SRT before connecting', async () => { + const settings = path.join(cwd, 'sandbox.json') + const config = { + network: { allowedDomains: [], deniedDomains: [] }, + filesystem: { denyRead: [], allowWrite: ['.pi'], denyWrite: [] }, + } + const json = JSON.stringify(config) + await writeFile(settings, json) + vi.stubEnv('PATH', '') + shell = new RunnerShell(new RunnerFiles(cwd), settings) + await shell.initialize() + await writeFile(settings, '{}') + expect( + await shell.run(request('echo sandboxed'), new AbortController().signal, () => {}), + ).toMatchObject({ exitCode: 0 }) + expect(SandboxManager.initialize).toHaveBeenCalledExactlyOnceWith( + expect.objectContaining(config), + ) + expect(SandboxManager.wrapWithSandboxArgv).toHaveBeenCalledWith( + expect.stringContaining('echo sandboxed'), + '/bin/sh', + undefined, + expect.any(AbortSignal), + cwd, + { commandId: 'test', commandText: 'echo sandboxed' }, + ) + expect(SandboxManager.reset).not.toHaveBeenCalled() + }) + + it('keeps skill PATH and Node startup settings out of the SRT launcher', async () => { + const settings = path.join(cwd, 'sandbox.json') + const marker = path.join(cwd, 'injected') + const evil = path.join(cwd, 'evil.cjs') + await writeFile( + settings, + JSON.stringify({ + network: { allowedDomains: [], deniedDomains: [] }, + filesystem: { denyRead: [], allowWrite: ['.pi'], denyWrite: [] }, + }), + ) + await writeFile(evil, `require('node:fs').writeFileSync('${marker}', 'escaped')`) + shell = new RunnerShell(new RunnerFiles(cwd), settings) + await shell.initialize() + const result = await shell.run( + { + ...request('printf secure'), + env: { PATH: '/evil-srt', NODE_OPTIONS: `--require=${evil}` }, + }, + new AbortController().signal, + () => {}, + ) + expect(result).toMatchObject({ exitCode: 0 }) + await expect(readFile(marker)).rejects.toThrow() + }) + + it('initializes one sandbox for parallel commands and resets only at shutdown', async () => { + const settings = path.join(cwd, 'sandbox.json') + await writeFile( + settings, + JSON.stringify({ + network: { allowedDomains: [], deniedDomains: [] }, + filesystem: { denyRead: [], allowWrite: ['.pi'], denyWrite: [] }, + }), + ) + shell = new RunnerShell(new RunnerFiles(cwd), settings) + await shell.initialize() + const value = "quoted ' value\n$(echo should-not-expand)" + let output = '' + const results = await Promise.all( + ['one', 'two'].map((id) => + shell.run( + { ...request('printf "%s" "$SKILL_TOKEN"', id), env: { SKILL_TOKEN: value } }, + new AbortController().signal, + (_stream, data) => { + output += data + }, + ), + ), + ) + expect(results.every((result) => result.exitCode === 0)).toBe(true) + expect(output).toBe(value.repeat(2)) + expect(SandboxManager.initialize).toHaveBeenCalledTimes(1) + expect(SandboxManager.reset).not.toHaveBeenCalled() + await shell.close() + expect(SandboxManager.reset).toHaveBeenCalledTimes(1) + }) + + it('fails startup and cleans up if sandbox initialization or execution fails', async () => { + const settings = path.join(cwd, 'sandbox.json') + await writeFile( + settings, + JSON.stringify({ + network: { allowedDomains: [], deniedDomains: [] }, + filesystem: { denyRead: [], allowWrite: ['.pi'], denyWrite: [] }, + }), + ) + shell = new RunnerShell(new RunnerFiles(cwd), settings) + vi.mocked(SandboxManager.initialize).mockRejectedValueOnce( + new Error('Run windows-install first'), + ) + await expect(shell.initialize()).rejects.toThrow('windows-install') + expect(SandboxManager.reset).toHaveBeenCalledTimes(1) + expect( + await shell.run(request('echo unsafe'), new AbortController().signal, () => {}), + ).toHaveProperty('error', 'SRT has not been initialized.') + vi.mocked(SandboxManager.wrapWithSandboxArgv).mockRejectedValueOnce( + new Error('sandbox unavailable'), + ) + await expect(shell.initialize()).rejects.toThrow('SRT preflight failed: sandbox unavailable') + }) + + it('fails closed for missing or malformed SRT settings', async () => { + const settings = path.join(cwd, 'sandbox.json') + await expect(new RunnerShell(new RunnerFiles(cwd), settings).initialize()).rejects.toThrow() + await writeFile(settings, 'invalid json') + await expect(new RunnerShell(new RunnerFiles(cwd), settings).initialize()).rejects.toThrow() + await writeFile(settings, '[]') + await expect(new RunnerShell(new RunnerFiles(cwd), settings).initialize()).rejects.toThrow( + /object/, + ) + await writeFile(settings, JSON.stringify({ network: { allowedDomains: 42 } })) + await expect(new RunnerShell(new RunnerFiles(cwd), settings).initialize()).rejects.toThrow() + expect(SandboxManager.initialize).not.toHaveBeenCalled() + }) +}) diff --git a/apps/cli/src/runner/shell.ts b/apps/cli/src/runner/shell.ts new file mode 100644 index 00000000..40493cdc --- /dev/null +++ b/apps/cli/src/runner/shell.ts @@ -0,0 +1,220 @@ +import { randomUUID } from 'node:crypto' +import { execa } from 'execa' +import { SandboxManager } from '@anthropic-ai/sandbox-runtime' +import { + runnerEnvironmentSchema, + type RunnerExecResultMessage, + type RunnerExecStartMessage, +} from '@shumai/dtos' +import { commandEnv, runnerShell } from './config' +import { RunnerFiles } from './files' +import { loadSandbox } from './srt' + +const MAX_OUTPUT_BYTES = 64 * 1024 * 1024 +const MAX_TIMEOUT_SEC = 3600 + +export class RunnerShell { + readonly environment = runnerEnvironmentSchema.parse({ + platform: process.platform, + shell: runnerShell(), + }) + private sandbox?: Awaited> + private initialized = false + private active = 0 + + constructor( + private readonly files: RunnerFiles, + private readonly srtPath?: string, + ) {} + + async initialize() { + if (!this.srtPath) return + // Read and validate once; commands cannot weaken the policy by editing the file. + this.sandbox = await loadSandbox(this.srtPath) + try { + await SandboxManager.initialize(this.sandbox.config) + this.initialized = true + let diagnostic = '' + const probe = await this.run( + { type: 'exec.start', executionId: randomUUID(), command: 'exit 0', timeoutSec: 15 }, + new AbortController().signal, + (_stream, data) => { + diagnostic = (diagnostic + data).slice(-4096) + }, + ) + if (probe.exitCode !== 0 || probe.error || probe.timedOut) + throw new Error( + `SRT preflight failed: ${probe.error || diagnostic.trim() || 'Check settings and local SRT prerequisites.'}`, + ) + } catch (error) { + await this.close() + throw error + } + } + + async close() { + if (!this.sandbox) return + try { + await SandboxManager.reset() + } finally { + await this.sandbox.cleanup() + this.sandbox = undefined + this.initialized = false + } + } + + async run( + message: RunnerExecStartMessage, + signal: AbortSignal, + output: (stream: 'stdout' | 'stderr', data: string) => void, + ): Promise { + const result: RunnerExecResultMessage = { + type: 'exec.result', + executionId: message.executionId, + exitCode: null, + signal: null, + timedOut: false, + aborted: false, + } + if (this.srtPath) this.active++ + try { + if (signal.aborted) return { ...result, aborted: true } + const timeout = message.timeoutSec ?? 120 + if (!Number.isFinite(timeout) || timeout <= 0 || timeout > MAX_TIMEOUT_SEC) + throw new Error(`Command timeout must be between 0 and ${MAX_TIMEOUT_SEC} seconds.`) + const logPath = `.pi/logs/bash-${message.executionId}.log` + const log = await this.files.createWriter(logPath) + try { + const windows = process.platform === 'win32' + let args: string[] = [] + let executable = message.command + let shell: string | false = this.environment.shell + let env = commandEnv(message.env) + if (this.srtPath) { + if (!this.initialized) throw new Error('SRT has not been initialized.') + const skillEnv = commandEnv(message.env, false) + const command = windows + ? message.command + : [ + ...Object.entries(skillEnv).map( + ([key, value]) => `export ${key}='${value!.replaceAll("'", "'\\''")}'`, + ), + message.command, + ].join('\n') + const wrapped = await SandboxManager.wrapWithSandboxArgv( + command, + this.environment.shell, + undefined, + signal, + this.files.cwd, + { commandId: message.executionId, commandText: message.command }, + ) + ;[executable, ...args] = wrapped.argv + shell = false + if (windows) { + // SRT's broker starts a fresh sandbox-user environment. Explicit skill + // values belong in its child overlay, never in the broker's startup env. + const separator = args.indexOf('--') + if (separator < 0) throw new Error('SRT returned an invalid Windows launch command.') + args.splice( + separator, + 0, + ...Object.entries(skillEnv).flatMap(([key, value]) => ['--env', `${key}=${value}`]), + ) + env = wrapped.env + } else env = commandEnv() + } + if (signal.aborted) return { ...result, aborted: true } + const deadline = Date.now() + Math.ceil(timeout * 1000) + const child = execa(executable, args, { + cwd: this.files.cwd, + env, + extendEnv: false, + shell, + stdin: 'ignore', + buffer: false, + reject: false, + stripFinalNewline: false, + verbose: 'none', + windowsHide: true, + killDescendants: true, + killSignal: 'SIGKILL', + cancelSignal: signal, + timeout: Math.ceil(timeout * 1000), + }) + let bytes = 0 + let writes = Promise.resolve() + let drainTimer: ReturnType | undefined + let drainExpired = false + let exitedWithinDeadline = false + child.nodeChildProcess.once('exit', (exitCode) => { + exitedWithinDeadline = exitCode !== null && Date.now() < deadline + // Execa cleans up descendants where the OS still permits it. Bound + // draining if a background child keeps inherited output pipes open. + child.kill('SIGKILL') + drainTimer = setTimeout(() => { + drainExpired = true + child.stdout.destroy() + child.stderr.destroy() + }, 1000) + }) + try { + const readers = (['stdout', 'stderr'] as const).map(async (stream) => { + child[stream].setEncoding('utf8') + try { + for await (const data of child[stream]) { + bytes += Buffer.byteLength(data) + if (bytes > MAX_OUTPUT_BYTES) + throw new Error('Command exceeded the 64 MiB output limit.') + await (writes = writes.then(async () => { + await log.write(data) + output(stream, data) + })) + } + } catch (error) { + if ( + drainExpired && + error instanceof Error && + 'code' in error && + error.code === 'ERR_STREAM_PREMATURE_CLOSE' + ) + return + result.error ??= error instanceof Error ? error.message : 'Output streaming failed.' + child.kill('SIGKILL') + } + }) + const [completed] = await Promise.all([child, Promise.all(readers)]) + await writes + result.exitCode = completed.exitCode ?? null + result.signal = completed.signal ?? null + // Execa's timeout includes stream draining. Report the command's + // runtime, so a timely exit does not become a timeout while draining. + result.timedOut = completed.timedOut && !exitedWithinDeadline + result.aborted = completed.isCanceled + if ( + completed.failed && + completed.exitCode === undefined && + !result.timedOut && + !result.aborted && + !completed.signal + ) + result.error = `Command execution failed (${completed.code ?? 'unknown error'}).` + result.fullOutputPath = logPath + } finally { + clearTimeout(drainTimer) + } + } finally { + await log.close() + } + } catch (error) { + result.aborted = signal.aborted + result.error = error instanceof Error ? error.message : 'Command execution failed.' + } finally { + // SRT's temporary mount resources are shared: clean up only after every + // concurrent command has finished, and keep the proxies until shutdown. + if (this.srtPath && --this.active === 0 && this.initialized) + SandboxManager.cleanupAfterCommand() + } + return result + } +} diff --git a/apps/cli/src/runner/srt-vendor.ts b/apps/cli/src/runner/srt-vendor.ts new file mode 100644 index 00000000..6ead7521 --- /dev/null +++ b/apps/cli/src/runner/srt-vendor.ts @@ -0,0 +1,2 @@ +// Release builds embed SRT's native helpers through scripts/srt-bundle.ts. +export const bundledSrtVendor: Record | undefined = undefined diff --git a/apps/cli/src/runner/srt.test.ts b/apps/cli/src/runner/srt.test.ts new file mode 100644 index 00000000..a8ccea24 --- /dev/null +++ b/apps/cli/src/runner/srt.test.ts @@ -0,0 +1,59 @@ +import { mkdtemp, readFile, rm, stat, writeFile } from 'node:fs/promises' +import { tmpdir } from 'node:os' +import path from 'node:path' +import { afterEach, beforeEach, describe, expect, it } from 'vitest' +import { loadSandbox } from './srt' + +describe('runner SRT configuration', () => { + let directory: string + let settings: string + const config = { + network: { allowedDomains: [], deniedDomains: [] }, + filesystem: { denyRead: [], allowWrite: ['.pi'], denyWrite: [] }, + } + beforeEach(async () => { + directory = await mkdtemp(path.join(tmpdir(), 'shumai-srt-settings-')) + settings = path.join(directory, 'sandbox.json') + }) + afterEach(() => rm(directory, { recursive: true, force: true })) + + it('validates upstream settings, supplies packaged helpers, and removes them on cleanup', async () => { + await writeFile(settings, JSON.stringify(config)) + const sandbox = await loadSandbox(settings) + const helper = sandbox.config.javaAgentJarPath! + expect(sandbox.config).toMatchObject(config) + expect((await readFile(helper)).subarray(0, 2).toString()).toBe('PK') + if (process.platform === 'linux') + expect(await stat(sandbox.config.seccomp!.applyPath!)).toHaveProperty( + 'size', + expect.any(Number), + ) + if (process.platform === 'win32') + expect(await stat(sandbox.config.windows!.srtWin!.path!)).toHaveProperty( + 'size', + expect.any(Number), + ) + await sandbox.cleanup() + await expect(stat(helper)).rejects.toThrow() + }) + + it('preserves explicit upstream helper paths', async () => { + await writeFile( + settings, + JSON.stringify({ + ...config, + javaAgentJarPath: '/custom/proxy.jar', + seccomp: { applyPath: '/custom/seccomp' }, + windows: { srtWin: { path: 'C:\\custom\\srt-win.exe' } }, + }), + ) + const sandbox = await loadSandbox(settings) + try { + expect(sandbox.config.javaAgentJarPath).toBe('/custom/proxy.jar') + expect(sandbox.config.seccomp?.applyPath).toBe('/custom/seccomp') + expect(sandbox.config.windows?.srtWin?.path).toBe('C:\\custom\\srt-win.exe') + } finally { + await sandbox.cleanup() + } + }) +}) diff --git a/apps/cli/src/runner/srt.ts b/apps/cli/src/runner/srt.ts new file mode 100644 index 00000000..4fc0ec70 --- /dev/null +++ b/apps/cli/src/runner/srt.ts @@ -0,0 +1,59 @@ +import { createRequire } from 'node:module' +import { mkdtemp, readFile, rm, writeFile } from 'node:fs/promises' +import { tmpdir } from 'node:os' +import path from 'node:path' +import { + SandboxRuntimeConfigSchema, + type SandboxRuntimeConfig, +} from '@anthropic-ai/sandbox-runtime' +import { bundledSrtVendor } from './srt-vendor' + +/** Load the upstream JSON format and supply the helpers bundled with this CLI. */ +export async function loadSandbox(configPath: string) { + const config = SandboxRuntimeConfigSchema.parse(JSON.parse(await readFile(configPath, 'utf8'))) + const directory = await mkdtemp(path.join(tmpdir(), 'shumai-srt-')) + const cleanup = () => rm(directory, { recursive: true, force: true }) + const asset = async (name: string) => { + const encoded = bundledSrtVendor?.[name] + const bytes = + encoded !== undefined + ? Buffer.from(encoded, 'base64') + : await readFile( + path.join( + path.dirname( + createRequire(import.meta.url).resolve( + '@anthropic-ai/sandbox-runtime/package.json', + ), + ), + 'vendor', + name, + ), + ) + const destination = path.join(directory, path.basename(name)) + await writeFile(destination, bytes, { mode: 0o500 }) + return destination + } + try { + if (process.platform === 'linux' && !config.seccomp?.applyPath) { + config.seccomp = { + ...config.seccomp, + applyPath: await asset(`seccomp/${process.arch}/apply-seccomp`), + } + } + if (process.platform === 'win32' && !config.windows?.srtWin?.path) { + config.windows = { + ...config.windows, + srtWin: { + ...config.windows?.srtWin, + path: await asset(`srt-win/${process.arch}/srt-win.exe`), + }, + } + } + if (!config.javaAgentJarPath) + config.javaAgentJarPath = await asset('java-proxy-agent/srt-proxy-agent.jar') + return { config: config satisfies SandboxRuntimeConfig, cleanup } + } catch (error) { + await cleanup() + throw error + } +} diff --git a/bun.lock b/bun.lock index fc6c371f..4ad0a01b 100644 --- a/bun.lock +++ b/bun.lock @@ -37,15 +37,25 @@ "shumai-cli": "./src/index.ts", }, "dependencies": { + "@anthropic-ai/sandbox-runtime": "0.0.82", "@shumai/api": "workspace:*", "@shumai/dtos": "workspace:*", "@shumai/operations": "workspace:*", "@shumai/tableprinter": "workspace:*", "commander": "15.0.0", + "execa": "10.2.1", "hono": "4.13.5", "ulid": "3.0.2", + "ws": "8.22.2", + "yauzl": "3.4.0", "zod": "4.5.4", }, + "devDependencies": { + "@types/adm-zip": "0.5.8", + "@types/ws": "8.18.2", + "@types/yauzl": "3.4.0", + "adm-zip": "0.6.1", + }, }, "apps/premiere-uxp": { "name": "@shumai/premiere-uxp", @@ -474,6 +484,8 @@ "@alloc/quick-lru": ["@alloc/quick-lru@5.2.0", "", {}, "sha512-UrcABB+4bUrFABwbluTIBErXwvbsU/V7TZWfmbgJfbkwiBuziS9gxdODUyuiecfdGQ85jglMW6juS3+z5TsKLw=="], + "@anthropic-ai/sandbox-runtime": ["@anthropic-ai/sandbox-runtime@0.0.82", "", { "dependencies": { "@pondwader/socks5-server": "^1.0.10", "commander": "^12.1.0", "node-forge": "^1.4.0", "zod": "^3.25.0" }, "optionalDependencies": { "@microsoft/mxc-sdk": "^1.0.1" }, "bin": { "srt": "dist/cli.js" } }, "sha512-SCPWkuhLw4ieL+06Jp72yFevltS0s2GD1kMOZdSJ6XxeuqTcoyAa1EDwiLxuONp6szNEOD7x02+vYxPa0oAWwg=="], + "@anthropic-ai/sdk": ["@anthropic-ai/sdk@0.129.0", "", { "dependencies": { "json-schema-to-ts": "^3.1.1", "standardwebhooks": "^1.0.0" }, "peerDependencies": { "zod": "^3.25.0 || ^4.0.0" }, "optionalPeers": ["zod"], "bin": { "anthropic-ai-sdk": "bin/cli" } }, "sha512-MH7LB20kNpGLUpPTe2OG5XvL/KhX8HUO9XyBaFjgFk6TLS4Xjt0VPIuMKywe7POKKPslX+QxSlVok9e+8kG5Nw=="], "@aws-sdk/checksums": ["@aws-sdk/checksums@3.1000.29", "", { "dependencies": { "@aws-sdk/core": "^3.977.9", "@aws-sdk/types": "^3.974.5", "@smithy/core": "^3.33.3", "@smithy/types": "^4.17.2", "tslib": "^2.6.2" } }, "sha512-Dtu0gr4dnATZAPwEYbpCsG+MpLM7OAliy2gTepEFQwl1vZ6DL3QMH2FveMa3HLvPsOdhJsPRB3KtxVhph9T75A=="], @@ -748,6 +760,46 @@ "@js-sdsl/ordered-map": ["@js-sdsl/ordered-map@4.4.2", "", {}, "sha512-iUKgm52T8HOE/makSxjqoWhe95ZJA1/G1sYsGev2JDKUSS14KAgg1LHb+Ba+IPow0xflbnSkOsZcO08C7w1gYw=="], + "@koromix/koffi-android-arm64": ["@koromix/koffi-android-arm64@3.3.7", "", { "os": "android", "cpu": "arm64" }, "sha512-330J8SnMF48DwADEbPYb5gAIM0mo3dZAsLUkuhyEPTPF49h73hRO7LMVXPkUmeXkK/J5Uvgsaem6Lx86Uev3GA=="], + + "@koromix/koffi-android-x64": ["@koromix/koffi-android-x64@3.3.7", "", { "os": "android", "cpu": "x64" }, "sha512-CE1LEAsMyChQQNjGVDy56lBEdU70zOOD709mdKtxM6Rn2I7srT8Jyj66kSwnl4gO4+2BlTBXMyEIAEyYiNXNEA=="], + + "@koromix/koffi-darwin-arm64": ["@koromix/koffi-darwin-arm64@3.3.7", "", { "os": "darwin", "cpu": "arm64" }, "sha512-xg1nqqhHRo6QxxYZJtYhhEGAbkHCQxvjoId3BCkhIJhRLi7+dDBRpLEi8x/5xrhqjCp+c/XhMrkAvxWy0NEYBg=="], + + "@koromix/koffi-darwin-x64": ["@koromix/koffi-darwin-x64@3.3.7", "", { "os": "darwin", "cpu": "x64" }, "sha512-8KeSrHrxzj+SEvaSMc1ufpgn66AdtorKGGb8HNJN5A435stXZ35oxg2+rsAyhTduvEZ9DkCuU94A0crA8KQ0UA=="], + + "@koromix/koffi-freebsd-arm64": ["@koromix/koffi-freebsd-arm64@3.3.7", "", { "os": "freebsd", "cpu": "arm64" }, "sha512-UTo2xw46ctQdcz55I3b5pP1Gs0mGcYZLGAJg7MpEdr8ZEMmmclTzU/WUwWw/lyj5x2Ld2fscjCt69elqfrUBOQ=="], + + "@koromix/koffi-freebsd-ia32": ["@koromix/koffi-freebsd-ia32@3.3.7", "", { "os": "freebsd", "cpu": "ia32" }, "sha512-5vgirS+XISQHzXiad3KYhZYGvuSbAtyrIm2etO118IjpWi87wbKP8xEdf8s4F+vU0HxGs9hcx5a+blwFMe9TFA=="], + + "@koromix/koffi-freebsd-x64": ["@koromix/koffi-freebsd-x64@3.3.7", "", { "os": "freebsd", "cpu": "x64" }, "sha512-R2POCHtQ46cyhCFtYuq3Uo4MEiMstwLi49fwUgu6Vl38XvqKeje5up5e72LTCXf+ks/y3nua3TYM5oXTBqYAUA=="], + + "@koromix/koffi-linux-arm": ["@koromix/koffi-linux-arm@3.3.7", "", { "os": "linux", "cpu": "arm" }, "sha512-zUb+N1CvsRikXKs93jNdHTAVFt3Njr7ShIA8QwOh2IH/8aV8bkQnkt7AOJvOK/uP0CHd7bxn82YgGUAcZW/pVw=="], + + "@koromix/koffi-linux-arm64": ["@koromix/koffi-linux-arm64@3.3.7", "", { "os": "linux", "cpu": "arm64" }, "sha512-7ttM8GE2gowelTTyTY0+t79rWaoilZMmW4MYgrIXx5NNShLiHtUNfyGGaNzCd1MD+j+bnNZLJ2lh3lkBS9stfw=="], + + "@koromix/koffi-linux-ia32": ["@koromix/koffi-linux-ia32@3.3.7", "", { "os": "linux", "cpu": "ia32" }, "sha512-hM6CtBgyWGkYzXIl+ciCWSCWnYh/6ft2FRi17aw345lK3Syl2OH06PPMxMd+AHkNrnYWT3nyrzl2Rcun9IeAiw=="], + + "@koromix/koffi-linux-loong64": ["@koromix/koffi-linux-loong64@3.3.7", "", { "os": "linux", "cpu": "none" }, "sha512-plmvZGrC2F02AIDNx3+QcjU39Y9XVgHAHMOM17HJCmxc3f5VpKO0d7aln3/Re6TchBW1h2ldFgI6pp/7vN7IQQ=="], + + "@koromix/koffi-linux-ppc64": ["@koromix/koffi-linux-ppc64@3.3.7", "", { "os": "linux", "cpu": "ppc64" }, "sha512-bmVe2k1v7tiOGcuX22+HIyOT39bRBrIJd2v6qzSN9Er/f7XI61cbJUnFYWdXpYecU2Ww1LDSkgIifcRyfpipqw=="], + + "@koromix/koffi-linux-riscv64": ["@koromix/koffi-linux-riscv64@3.3.7", "", { "os": "linux", "cpu": "none" }, "sha512-IG1cp7agL1Od03NrKy8B0UGHomco0sygtWhWIXTTbjkJZkjE9Ic79IWzA5d16XbVtob+247XYBDcaeJJ644Xiw=="], + + "@koromix/koffi-linux-x64": ["@koromix/koffi-linux-x64@3.3.7", "", { "os": "linux", "cpu": "x64" }, "sha512-1cxuG2zsO71wB3RwYt6AjJD9xQW0lUVw4TX4e3Q2DeffEqrVtE3g4IbQsnijTcSeZmmec1kDuuk4CSHUfhAEJQ=="], + + "@koromix/koffi-openbsd-arm64": ["@koromix/koffi-openbsd-arm64@3.3.7", "", { "os": "openbsd", "cpu": "arm64" }, "sha512-8qqafiMgdmOTEeZsLSnuKdg82Id8IwcxG8MowVtk0zJ4iNObmg2Ygd1dTtWRwpMBW0gfXoodwRdRqnUur3R/aA=="], + + "@koromix/koffi-openbsd-ia32": ["@koromix/koffi-openbsd-ia32@3.3.7", "", { "os": "openbsd", "cpu": "ia32" }, "sha512-ZG06vAX5YUyUGAg9brg4maex7uGj1fybhlMrWt5FlocMBlrY05pn84vlCKavHsCficecAVq7yEzU8f+4FC2T7A=="], + + "@koromix/koffi-openbsd-x64": ["@koromix/koffi-openbsd-x64@3.3.7", "", { "os": "openbsd", "cpu": "x64" }, "sha512-jnBD84VCXRmOeJniInO8g5xH2XwVnifp2w35+UbAx8coMIS99YAW9uDNg/U7ooJIyL9hfbatfeNkjNhYhhNpKw=="], + + "@koromix/koffi-win32-arm64": ["@koromix/koffi-win32-arm64@3.3.7", "", { "os": "win32", "cpu": "arm64" }, "sha512-Sal267u6Mi+UK/Lbu5vECQDtvZCfK57BO1zmc+Tar7Kdy+hHZ8Eqx7SyxTP6js4ofavQ83pVp1SWQqK8XJVpcg=="], + + "@koromix/koffi-win32-ia32": ["@koromix/koffi-win32-ia32@3.3.7", "", { "os": "win32", "cpu": "ia32" }, "sha512-kOPimggBxcLjHM/rHOWZp8fyxu+UjeEkWM26Gb9XCnirmM76xDu+GXCSDoBPPqF8s+XkY3NrhUdgfIXcwmWiPA=="], + + "@koromix/koffi-win32-x64": ["@koromix/koffi-win32-x64@3.3.7", "", { "os": "win32", "cpu": "x64" }, "sha512-yVrh4Yzyjm+fH7CGIa8Ts+DSGeU8QrwEtECXxNswh3i86hwZTOKkqojaDFAYJov0B3w4BFcjR4TOKkPOB0ZpZA=="], + "@kwsites/file-exists": ["@kwsites/file-exists@1.1.1", "", { "dependencies": { "debug": "^4.1.1" } }, "sha512-m9/5YGR18lIwxSFDwfE3oA7bWuq9kdau6ugN4H2rJeyhFQZcG9AgSHkQtSD15a8WvTgfz9aikZMrKPHvbpqFiw=="], "@lexical/a11y": ["@lexical/a11y@0.49.0", "", { "dependencies": { "@lexical/extension": "0.49.0", "@lexical/utils": "0.49.0", "lexical": "0.49.0" }, "peerDependencies": { "typescript": ">=5.2" }, "optionalPeers": ["typescript"] }, "sha512-ypvO0SI9DCzEAjxkRLq+gNzRqfjg632RCkwu16Hk94PCBrEmcDhx5iUGg3SRJC7WnM2wXC/F/SB8yWDEfq7tEw=="], @@ -818,6 +870,8 @@ "@lix-js/sdk-win32-x64": ["@lix-js/sdk-win32-x64@0.12.3", "", { "os": "win32", "cpu": "x64" }, "sha512-hnxMI7kPS4ngXs0ZVnOve5CmtC4+vaNIyNDi/yWU0rSvxj7mqw/1RCegTrCB7LjxlX4DG+eg9HruXurk9NDjGg=="], + "@microsoft/mxc-sdk": ["@microsoft/mxc-sdk@1.0.1", "", { "dependencies": { "koffi": "^3.2.1", "node-pty": "^1.1.0", "semver": "^7.7.4" } }, "sha512-2cP925G5+lQyKzjBVha8uNtVd7XESgDBtgi1yCYYSo9M3xiFyZWtCO4SWPGTk509rdI6nqjyGcZxvEP3t6l8Hg=="], + "@modelcontextprotocol/client": ["@modelcontextprotocol/client@2.0.0", "", { "dependencies": { "@modelcontextprotocol/core": "2.0.0", "cross-spawn": "^7.0.5", "eventsource": "^3.0.2", "eventsource-parser": "^3.0.0", "jose": "^6.1.3", "pkce-challenge": "^5.0.0", "zod": "^4.2.0" } }, "sha512-8f1OghQ2rjzIOfqgUCP+8GiUWqRs89njoWLNqAe8kWmDePv3s1fZXseej+QXemssEuuOvLLmLO/kqM3IQHtISw=="], "@modelcontextprotocol/core": ["@modelcontextprotocol/core@2.0.0", "", { "dependencies": { "zod": "^4.2.0" } }, "sha512-pJCEwGG7Lfr/+PQp9ZTwKXNeO5wzbfKL7H3MYpCorM4oFBoQrdjnBgEoqG+RjhsvS1FKrDbKux+M1HhlnGWqcA=="], @@ -886,6 +940,8 @@ "@playwright/test": ["@playwright/test@1.61.1", "", { "dependencies": { "playwright": "1.61.1" }, "bin": { "playwright": "cli.js" } }, "sha512-8nKv6+0RJSL9FE4jYOEGXnPeM/Hg12qZpmqzZjRh3qM0Y7c3z1mrOTfFLids72RDQYVh9WpLEfR5WdpNX4fkig=="], + "@pondwader/socks5-server": ["@pondwader/socks5-server@1.0.10", "", {}, "sha512-bQY06wzzR8D2+vVCUoBsr5QS2U6UgPUQRmErNwtsuI6vLcyRKkafjkr3KxbtGFf9aBBIV2mcvlsKD1UYaIV+sg=="], + "@preact/signals-core": ["@preact/signals-core@1.14.4", "", {}, "sha512-HNB6HYeYKhQbJ1aKl+YRjrS4+QWHLKX6qKoUsfS/m0vqzsVaEBiZiaKbG/e+NKk2ch5ALQr/ihWaMHxiCuuWHA=="], "@prisma/adapter-pg": ["@prisma/adapter-pg@7.10.0", "", { "dependencies": { "@prisma/driver-adapter-utils": "7.10.0", "@types/pg": "^8.16.0", "pg": "^8.16.3", "postgres-array": "3.0.4" } }, "sha512-N7nwSor0HO1Kz6xBv0TPAjAPysKK0fac6p4fVN3ensLOuzc/83Fgmln5k92eK/cvzqdkSR/2kkAqlbcdwVrwpw=="], @@ -1094,6 +1150,8 @@ "@rolldown/pluginutils": ["@rolldown/pluginutils@1.0.1", "", {}, "sha512-2j9bGt5Jh8hj+vPtgzPtl72j0yRxHAyumoo6TNfAjsLB04UtpSvPbPcDcBMxz7n+9CYB0c1GxQFxYRg2jimqGw=="], + "@sec-ant/readable-stream": ["@sec-ant/readable-stream@0.4.1", "", {}, "sha512-831qok9r2t8AlxLko40y2ebgSDhenenCatLVeW/uBtnHPyhHOvG0C7TvfgecV+wHzIm5KUICgzmVpWS+IMEAeg=="], + "@shumai/agent": ["@shumai/agent@workspace:packages/agent"], "@shumai/api": ["@shumai/api@workspace:packages/api"], @@ -1130,6 +1188,8 @@ "@sindresorhus/is": ["@sindresorhus/is@4.6.0", "", {}, "sha512-t09vSN3MdfsyCHoFcTRCH/iUtG7OJ0CsjzB8cjAmKc/va/kIgeDI/TxsigdncE/4be734m0cvIYwNaV4i2XqAw=="], + "@sindresorhus/merge-streams": ["@sindresorhus/merge-streams@4.0.0", "", {}, "sha512-tlqY9xq5ukxTUZBmoOp+m61cqwQD5pHJtFY3Mn8CA8ps6yghLH/Hw8UPdqg4OLmFW3IFlcXnQNmo/dh8HzXYIQ=="], + "@smithy/core": ["@smithy/core@3.33.3", "", { "dependencies": { "@smithy/types": "^4.17.2", "tslib": "^2.6.2" } }, "sha512-CsOeKq/9kA3y6VJHt+/+VTCtBaxJ4OTFpgrjIUhPpDIKxBci1k2bJaQASF2h/ELWrulGp+t97DZ0mevfAD8idg=="], "@smithy/credential-provider-imds": ["@smithy/credential-provider-imds@4.5.2", "", { "dependencies": { "@smithy/core": "^3.33.2", "@smithy/types": "^4.17.2", "tslib": "^2.6.2" } }, "sha512-A9uSdn72ozbRUSit0eib0TW7nXuNPlaeM0zcGkJ+nE6tFcSDbnmtwoxbTCFBukVQcszDAyvsd7+rTduPTXpygg=="], @@ -1514,9 +1574,9 @@ "@types/whatwg-mimetype": ["@types/whatwg-mimetype@3.0.2", "", {}, "sha512-c2AKvDT8ToxLIOUlN51gTiHXflsfIFisS4pO7pDPoKouJCESkhZnEy623gwP9laCy5lnLDAw1vAzu2vM2YLOrA=="], - "@types/ws": ["@types/ws@8.18.1", "", { "dependencies": { "@types/node": "*" } }, "sha512-ThVF6DCVhA8kUGy+aazFQ4kXQ7E1Ty7A3ypFOe0IcJV8O/M511G99AW24irKrW56Wt44yG9+ij8FaqoBGkuBXg=="], + "@types/ws": ["@types/ws@8.18.2", "", { "dependencies": { "@types/node": "*" } }, "sha512-67MQl+fpWKVTT1NYdnmo3U4sc/xPo/zQBncVnI74qmQa0z/b+1g6iYqNmGCPbxO+zz2aklb08a0oHfegiVd0/w=="], - "@types/yauzl": ["@types/yauzl@2.10.3", "", { "dependencies": { "@types/node": "*" } }, "sha512-oJoftv0LSuaDZE3Le4DbKX+KS9G36NzOeSap90UIK0yMA/NhKJhqlSGtNDORNRaIbQfzjXDrQa0ytJ6mNRGz/Q=="], + "@types/yauzl": ["@types/yauzl@3.4.0", "", { "dependencies": { "@types/node": "*" } }, "sha512-NRPn5w6h8dhcnmx3YIRQcqMywY/+nND/uOkJessedcrowO3C0AssHp3tMJpxKAwOhFOo0OV1y9VtsC5hbKKBAw=="], "@typescript-eslint/eslint-plugin": ["@typescript-eslint/eslint-plugin@8.68.0", "", { "dependencies": { "@eslint-community/regexpp": "^4.12.2", "@typescript-eslint/scope-manager": "8.68.0", "@typescript-eslint/type-utils": "8.68.0", "@typescript-eslint/utils": "8.68.0", "@typescript-eslint/visitor-keys": "8.68.0", "ignore": "^7.0.5", "natural-compare": "^1.4.0", "ts-api-utils": "^2.5.0" }, "peerDependencies": { "@typescript-eslint/parser": "^8.68.0", "eslint": "^8.57.0 || ^9.0.0 || ^10.0.0", "typescript": ">=4.8.4 <6.1.0" } }, "sha512-WASHDpCm6qO5jj9g1a+8NiW5+GCkAyLReR56/4VruYmNgfUmqpxOfZ2Yfb8xGfJPWv5Qi6LSD8sXdces3vbp/Q=="], @@ -1974,6 +2034,8 @@ "eventsource-parser": ["eventsource-parser@3.1.1", "", {}, "sha512-EKN1vKAMcZ8MlYMpaNuxN6R9yakzH6uajHcHVTqWJzvu5pWw9DyhbP35HH8MVBQ+dZjAfDxk+A8NiR9KWaXiyQ=="], + "execa": ["execa@10.2.1", "", { "dependencies": { "@sindresorhus/merge-streams": "^4.0.0", "figures": "^6.1.0", "get-stream": "^9.0.1", "human-signals": "^8.0.1", "is-plain-obj": "^4.1.0", "is-stream": "^4.0.1", "npm-run-path": "^6.0.0", "pretty-ms": "^9.3.1", "signal-exit": "^4.1.0", "strip-final-newline": "^4.0.0", "which-command": "^0.1.0", "yoctocolors": "^2.2.0" } }, "sha512-/Bofl3ZBh2Q4/PG0W63qFzP5vDAypi8Zc90UWTBzaDNIYiX7apPOd0N6L8hG8CojUdq4V51adu8BObP+iVsSTw=="], + "exiftool-vendored": ["exiftool-vendored@38.1.0", "", { "dependencies": { "@photostructure/tz-lookup": "^11.7.0", "@types/luxon": "^3.7.5", "batch-cluster": "^19.2.0", "he": "^1.2.0", "luxon": "^3.7.2" }, "optionalDependencies": { "exiftool-vendored.exe": "13.59.2", "exiftool-vendored.pl": "13.59.2" } }, "sha512-LIERqM/Qb0oqJlSswLFKWsxGVH81skp7omsX2BPKA/dEzfLP5syNO5KL7k5UlMCf+m0jqEXrKTQr/xV5vScPow=="], "exiftool-vendored.exe": ["exiftool-vendored.exe@13.59.2", "", { "os": "win32" }, "sha512-U0l0CApIGO+AjpFYCiNCApQsMdlf6sqCyEl4wlKKqvwVAEVcvMRw91k7zj32OPFZE+/+XlLFsc6876MpOqBLiw=="], @@ -2018,6 +2080,8 @@ "fflate": ["fflate@0.8.3", "", {}, "sha512-tbZNuJrLwGUp3zshBtdy4W+ORxZuIh8a5ilyIEQDC5rY1f3U20JMry0Ll3WBzU58EZKsEuJFXhb5gwv8CsPvgA=="], + "figures": ["figures@6.1.0", "", { "dependencies": { "is-unicode-supported": "^2.0.0" } }, "sha512-d+l3qxjSesT4V7v2fh+QnmFnUWv9lSpjarhShNTgBOfA0ttejbQUAlHLitbjkoRiDulW0OPoQPYIGhIC8ohejg=="], + "file-entry-cache": ["file-entry-cache@8.0.0", "", { "dependencies": { "flat-cache": "^4.0.0" } }, "sha512-XXTUwCvisa5oacNGRP9SfNtYBNAMi+RPwBFmblZEF7N7swHYQS6/Zfk7SRwx4D5j3CH211YNRco1DEMNVfZCnQ=="], "find-my-way": ["find-my-way@9.7.0", "", { "dependencies": { "fast-deep-equal": "^3.1.3", "fast-querystring": "^1.0.0", "safe-regex2": "^5.0.0" } }, "sha512-f2JHn75x2JlwUwLenZypgczR7YWMb/uO9BvUXtus+JMgkbIkLADd38cI4EiV+OQqrGo1Zlq6V8wnqMJ8e62wUQ=="], @@ -2074,7 +2138,7 @@ "get-proto": ["get-proto@1.0.1", "", { "dependencies": { "dunder-proto": "^1.0.1", "es-object-atoms": "^1.0.0" } }, "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g=="], - "get-stream": ["get-stream@5.2.0", "", { "dependencies": { "pump": "^3.0.0" } }, "sha512-nBF+F1rAZVCu/p7rjzgA+Yb4lfYXrpl7a6VmJrU8wF9I1CKvP/QwPNZHnOlwbTkY6dvtFIzFMSyQXbLoTQPRpA=="], + "get-stream": ["get-stream@9.0.1", "", { "dependencies": { "@sec-ant/readable-stream": "^0.4.1", "is-stream": "^4.0.1" } }, "sha512-kVCxPF3vQM/N0B1PmoqVUqgHP+EeVjmZSQn+1oCRPxd2P21P2F19lIgbR3HBosbB1PUhOAoctJnfEn2GbN2eZA=="], "get-symbol-description": ["get-symbol-description@1.1.0", "", { "dependencies": { "call-bound": "^1.0.3", "es-errors": "^1.3.0", "get-intrinsic": "^1.2.6" } }, "sha512-w9UMqWwJxHNOvoNzSJ2oPF5wvYcvP7jUvYzhp67yEhTi17ZDBBC1z9pTdGuzjD+EFIqLSYRweZjqfiPzQ06Ebg=="], @@ -2134,6 +2198,8 @@ "https-proxy-agent": ["https-proxy-agent@9.1.0", "", { "dependencies": { "agent-base": "9.0.0", "debug": "^4.3.4", "proxy-agent-negotiate": "1.1.0" } }, "sha512-ag87y7cJJ9/3+GxFr8Oy4O5faDsGRGnBGsJj/YjOSsSx/5eadKLYTMPlzuR6obgoCDDm0abAAZitXXQkMOPSpA=="], + "human-signals": ["human-signals@8.0.1", "", {}, "sha512-eKCa6bwnJhvxj14kZk5NCPc6Hb6BdsU9DZcOnmQKSnO1VKrfV0zCvtttPZUsBvjmNDn8rpcJfpwSYnHBjc95MQ=="], + "iconv-lite": ["iconv-lite@0.7.3", "", { "dependencies": { "safer-buffer": ">= 2.1.2 < 3.0.0" } }, "sha512-IKXpvIzjnC9XTAUbVBcMfGS0EPaIXtW6v+zr+RRp+hqULEpo0owZax6wyRwPOJbWbzjYspQwusTsfVr0ifh4uQ=="], "ieee754": ["ieee754@1.2.1", "", {}, "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA=="], @@ -2208,7 +2274,7 @@ "is-shared-array-buffer": ["is-shared-array-buffer@1.0.4", "", { "dependencies": { "call-bound": "^1.0.3" } }, "sha512-ISWac8drv4ZGfwKl5slpHG9OwPNty4jOWPRIhBpxOoD+hqITiwuipOQ2bNthAzwA3B4fIjO4Nln74N0S9byq8A=="], - "is-stream": ["is-stream@2.0.1", "", {}, "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg=="], + "is-stream": ["is-stream@4.0.1", "", {}, "sha512-Dnz92NInDqYckGEUJv689RbRiTSEHCQ7wOVeALbkOz999YpqT46yMRIGtSNl2iCL1waAZSx40+h59NV/EwzV/A=="], "is-string": ["is-string@1.1.1", "", { "dependencies": { "call-bound": "^1.0.3", "has-tostringtag": "^1.0.2" } }, "sha512-BtEeSsoaQjlSPBemMQIrY1MY0uM6vnS1g5fmufYOtnxLGUZM2178PKbhsk7Ffv58IX+ZtcvoGwccYsh0PglkAA=="], @@ -2216,6 +2282,8 @@ "is-typed-array": ["is-typed-array@1.1.15", "", { "dependencies": { "which-typed-array": "^1.1.16" } }, "sha512-p3EcsicXjit7SaskXHs1hA91QxgTw46Fv6EFKKGS5DRFLD8yKnohjF3hxoju94b/OcMZoQukzpPpBE9uLVKzgQ=="], + "is-unicode-supported": ["is-unicode-supported@2.1.0", "", {}, "sha512-mE00Gnza5EEB3Ds0HfMyllZzbBrmLOX3vfWoj9A9PEnTfratQ/BcaJOuMhnkhjXvb2+FkY3VuHqtAGpTPmglFQ=="], + "is-weakmap": ["is-weakmap@2.0.2", "", {}, "sha512-K5pXYOm9wqY1RgjpL3YTkF39tni1XajUIkawTLUo9EZEVUFga5gSQJF8nNS7ZwJQ02y+1YCNYcMh+HIf1ZqE+w=="], "is-weakref": ["is-weakref@1.1.1", "", { "dependencies": { "call-bound": "^1.0.3" } }, "sha512-6i9mGWSlqzNMEqpCp93KwRS1uUOodk2OJ6b+sq7ZPDSy2WuI5NFIxp/254TytR8ftefexkWn5xNiHUNpPOfSew=="], @@ -2274,6 +2342,8 @@ "keyv": ["keyv@4.5.4", "", { "dependencies": { "json-buffer": "3.0.1" } }, "sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw=="], + "koffi": ["koffi@3.3.7", "", { "optionalDependencies": { "@koromix/koffi-android-arm64": "3.3.7", "@koromix/koffi-android-x64": "3.3.7", "@koromix/koffi-darwin-arm64": "3.3.7", "@koromix/koffi-darwin-x64": "3.3.7", "@koromix/koffi-freebsd-arm64": "3.3.7", "@koromix/koffi-freebsd-ia32": "3.3.7", "@koromix/koffi-freebsd-x64": "3.3.7", "@koromix/koffi-linux-arm": "3.3.7", "@koromix/koffi-linux-arm64": "3.3.7", "@koromix/koffi-linux-ia32": "3.3.7", "@koromix/koffi-linux-loong64": "3.3.7", "@koromix/koffi-linux-ppc64": "3.3.7", "@koromix/koffi-linux-riscv64": "3.3.7", "@koromix/koffi-linux-x64": "3.3.7", "@koromix/koffi-openbsd-arm64": "3.3.7", "@koromix/koffi-openbsd-ia32": "3.3.7", "@koromix/koffi-openbsd-x64": "3.3.7", "@koromix/koffi-win32-arm64": "3.3.7", "@koromix/koffi-win32-ia32": "3.3.7", "@koromix/koffi-win32-x64": "3.3.7" }, "hasInstallScript": true }, "sha512-Vrq4UwAE19HPLMou8m7HGCELiTE3l9D+r1nA7XwVHUTNaRdymPM+kzkkD2VGxlyjI2qZTb9tMDaFn7kfZ72v3Q=="], + "konva": ["konva@10.3.2", "", { "peerDependencies": { "canvas": "^3.0.0", "skia-canvas": "^3.0.0" }, "optionalPeers": ["canvas", "skia-canvas"] }, "sha512-A9GLx+Vj0PNnybjNq/St/S8utrksuSKOR8EzO2RTjA0SlmR9JipahcCXWW0vXz/9wjZCwAEtBtJFCUGe5mD/4g=="], "kysely": ["kysely@0.28.17", "", {}, "sha512-nbD8lB9EB3wNdMhOCdx5Li8DxnLbvKByylRLcJ1h+4SkrowVeECAyZlyiKMThF7xFdRz0jSQ2MoJr+wXux2y0Q=="], @@ -2432,6 +2502,8 @@ "next-themes": ["next-themes@0.4.6", "", { "peerDependencies": { "react": "^16.8 || ^17 || ^18 || ^19 || ^19.0.0-rc", "react-dom": "^16.8 || ^17 || ^18 || ^19 || ^19.0.0-rc" } }, "sha512-pZvgD5L0IEvX5/9GWyHMf3m8BKiVQwsCMHfoFosXtXBMnaS0ZnIJ9ST4b4NqLVKDEm8QBxoNNGNaBv2JNF6XNA=="], + "node-addon-api": ["node-addon-api@7.1.1", "", {}, "sha512-5m3bsyrjFWE1xf7nz7YXdN4udnVtXK6/Yfgn5qnahL6bCkf2yKt4k3nuTKAtT4r3IG8JNR2ncsIMdZuAzJjHQQ=="], + "node-domexception": ["node-domexception@1.0.0", "", {}, "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ=="], "node-emoji": ["node-emoji@2.2.0", "", { "dependencies": { "@sindresorhus/is": "^4.6.0", "char-regex": "^1.0.2", "emojilib": "^2.4.0", "skin-tone": "^2.0.0" } }, "sha512-Z3lTE9pLaJF47NyMhd4ww1yFTAP8YhYI8SleJiHzM46Fgpm5cnNzSl9XfzFNqbaz+VlJrIj3fXQ4DeN1Rjm6cw=="], @@ -2440,12 +2512,18 @@ "node-fetch": ["node-fetch@3.3.2", "", { "dependencies": { "data-uri-to-buffer": "^4.0.0", "fetch-blob": "^3.1.4", "formdata-polyfill": "^4.0.10" } }, "sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA=="], + "node-forge": ["node-forge@1.4.3", "", {}, "sha512-P6wzfh6t70avmV8FrVEAd/36sOPJQ+hkaJVX1Laap9J/77m7M0eyozDvc8SwnDf4P7MP94gwbAAo0rg3YVXT+g=="], + + "node-pty": ["node-pty@1.1.0", "", { "dependencies": { "node-addon-api": "^7.1.0" }, "hasInstallScript": true }, "sha512-20JqtutY6JPXTUnL0ij1uad7Qe1baT46lyolh2sSENDd4sTzKZ4nmAFkeAARDKwmlLjPx6XKRlwRUxwjOy+lUg=="], + "node-releases": ["node-releases@2.0.54", "", {}, "sha512-YHs7BmmcsdAI5Ozuf8JZo6PT0mv2GIWC9vMfvUC3dp65M8hn7Ux8CPL+2oBI7juNuj9d0ndhTcznq2ODBps9cQ=="], "nodemailer": ["nodemailer@10.0.10", "", {}, "sha512-He9XskOFms62SyAKkLu8CcGcYHAo+BSHSsORI8s4PJH8qZgZY4L4lDfvyN0twvmbpyG+eGrxpyBlskj9d9rJ8A=="], "normalize-path": ["normalize-path@3.0.0", "", {}, "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA=="], + "npm-run-path": ["npm-run-path@6.0.0", "", { "dependencies": { "path-key": "^4.0.0", "unicorn-magic": "^0.3.0" } }, "sha512-9qny7Z9DsQU8Ou39ERsPU4OZQlSTP47ShQzuKZ6PRXpYLtIFgl/DEBYEXKlvcEa+9tHVcK8CF81Y2V72qaZhWA=="], + "object-assign": ["object-assign@4.1.1", "", {}, "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg=="], "object-inspect": ["object-inspect@1.13.4", "", {}, "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew=="], @@ -2490,6 +2568,8 @@ "parse-entities": ["parse-entities@4.0.2", "", { "dependencies": { "@types/unist": "^2.0.0", "character-entities-legacy": "^3.0.0", "character-reference-invalid": "^2.0.0", "decode-named-character-reference": "^1.0.0", "is-alphanumerical": "^2.0.0", "is-decimal": "^2.0.0", "is-hexadecimal": "^2.0.0" } }, "sha512-GG2AQYWoLgL877gQIKeRPGO1xF9+eG1ujIb5soS5gPvLQ1y2o8FL90w2QWNdf9I361Mpp7726c+lj3U0qK1uGw=="], + "parse-ms": ["parse-ms@4.0.0", "", {}, "sha512-TXfryirbmq34y8QBwgqCVLi+8oA3oWx2eAnSn62ITyEhEYaWRlVZ2DvMM9eZbMs/RfxPu/PK/aBLyGj4IrqMHw=="], + "partial-json": ["partial-json@0.1.7", "", {}, "sha512-Njv/59hHaokb/hRUjce3Hdv12wd60MtM9Z5Olmn+nehe0QDAsRtRbJPvJ0Z91TusF0SuZRIvnM+S4l6EIP8leA=="], "path-exists": ["path-exists@4.0.0", "", {}, "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w=="], @@ -2572,6 +2652,8 @@ "pretty-format": ["pretty-format@27.5.1", "", { "dependencies": { "ansi-regex": "^5.0.1", "ansi-styles": "^5.0.0", "react-is": "^17.0.1" } }, "sha512-Qb1gy5OrP5+zDf2Bvnzdl3jsTf1qXVMazbvCoKhtKqVs4/YK4ozX4gKQJJVyNe+cajNPn0KoC0MC3FUmaHWEmQ=="], + "pretty-ms": ["pretty-ms@9.3.1", "", { "dependencies": { "parse-ms": "^4.0.0" } }, "sha512-HzMy3Geq23nVALD/M2LliU+F+M+gVNsvkQWWqeBZ8HDiCgzo6YPJ/Omrmtq24EFrIsk0a3EkQGEd7bDOo+IhGA=="], + "prisma": ["prisma@7.10.0", "", { "dependencies": { "@prisma/config": "7.10.0", "@prisma/dev": "0.24.17", "@prisma/engines": "7.10.0", "@prisma/studio-core": "0.33.0", "mysql2": "3.15.3", "postgres": "3.4.7" }, "peerDependencies": { "better-sqlite3": ">=9.0.0", "typescript": ">=5.4.0" }, "optionalPeers": ["better-sqlite3", "typescript"], "bin": { "prisma": "build/index.js" } }, "sha512-o0ornyJOWgygVAzGCpr8PdXV8EJLHyVGDDUr/voBQt8Azzw8cYTByzzPGcA/m4tCkPcnJA8raEOv2CslsKhPEw=="], "prisma-json-types-generator": ["prisma-json-types-generator@5.1.1", "", { "dependencies": { "@prisma/generator-helper": "^7.8.0", "semver": "^7.8.5", "try": "^1.0.3", "tslib": "^2.8.1", "typescript": "npm:typescript@^6.0.3" }, "peerDependencies": { "@prisma/client": "^7.8.0", "prisma": "^7.8.0" }, "bin": { "prisma-json-types-generator": "index.js" } }, "sha512-vtj68YkCla7bEnblC54xzKU3w+H/1uoKxtLU3F2eC9LL8j1Dz8GadVagKhQqQd03KGfHmO7o83Tf3yXxCKQwzQ=="], @@ -2734,7 +2816,7 @@ "siginfo": ["siginfo@2.0.0", "", {}, "sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g=="], - "signal-exit": ["signal-exit@3.0.7", "", {}, "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ=="], + "signal-exit": ["signal-exit@4.1.0", "", {}, "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw=="], "skin-tone": ["skin-tone@2.0.0", "", { "dependencies": { "unicode-emoji-modifier-base": "^1.0.0" } }, "sha512-kUMbT1oBJCpgrnKoSr0o6wPtvRWT9W9UKvGLwfJYO2WuahZRHOpEyL1ckyMGgMWh0UdpmaoFqKKD29WTomNEGA=="], @@ -2790,6 +2872,8 @@ "strip-ansi-cjs": ["strip-ansi@6.0.1", "", { "dependencies": { "ansi-regex": "^5.0.1" } }, "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A=="], + "strip-final-newline": ["strip-final-newline@4.0.0", "", {}, "sha512-aulFJcD6YK8V1G7iRB5tigAP4TsHBZZrOV8pjV++zdUwmeV8uzbY7yn6h9MswN62adStNZFuCIx4haBnRuMDaw=="], + "strip-json-comments": ["strip-json-comments@5.0.3", "", {}, "sha512-1tB5mhVo7U+ETBKNf92xT4hrQa3pm0MZ0PQvuDnWgAAGHDsfp4lPSpiS6psrSiet87wyGPh9ft6wmhOMQ0hDiw=="], "style-to-js": ["style-to-js@1.1.21", "", { "dependencies": { "style-to-object": "1.0.14" } }, "sha512-RjQetxJrrUJLQPHbLku6U/ocGtzyjbJMP9lCNK7Ag0CNh690nSH8woqWH9u16nMjYBAok+i7JO1NP2pOy8IsPQ=="], @@ -2888,6 +2972,8 @@ "unicode-trie": ["unicode-trie@2.0.0", "", { "dependencies": { "pako": "^0.2.5", "tiny-inflate": "^1.0.0" } }, "sha512-x7bc76x0bm4prf1VLg79uhAzKw8DVboClSN5VxJuQ+LKDOVEW9CdH+VY7SP+vX7xCYQqzzgQpFqz15zeLvAtZQ=="], + "unicorn-magic": ["unicorn-magic@0.3.0", "", {}, "sha512-+QBBXBCvifc56fsbuxZQ6Sic3wqqc3WWaqxs58gvJrcOuN83HGTCwz3oS5phzU9LthRNE9VrJCFCLUgHeeFnfA=="], + "unified": ["unified@11.0.5", "", { "dependencies": { "@types/unist": "^3.0.0", "bail": "^2.0.0", "devlop": "^1.0.0", "extend": "^3.0.0", "is-plain-obj": "^4.0.0", "trough": "^2.0.0", "vfile": "^6.0.0" } }, "sha512-xKvGhPWw3k84Qjh8bI3ZeJjqnyadK+GEFtazSfZv/rKeTkTjOJho6mFqh2SM96iIcZokxiOpg78GazTSg8+KHA=="], "unist-util-is": ["unist-util-is@6.0.1", "", { "dependencies": { "@types/unist": "^3.0.0" } }, "sha512-LsiILbtBETkDz8I9p1dQ0uyRUWuaQzd/cuEeS1hoRSyW5E5XGmTzlwY1OrNzzakGowI9Dr/I8HVaw4hTtnxy8g=="], @@ -2950,6 +3036,8 @@ "which-collection": ["which-collection@1.0.2", "", { "dependencies": { "is-map": "^2.0.3", "is-set": "^2.0.3", "is-weakmap": "^2.0.2", "is-weakset": "^2.0.3" } }, "sha512-K4jVyjnBdgvc86Y6BkaLZEN933SwYOuBFkdmBu9ZfkcAbdVbpITnDmjvZ/aQjRXQrv5EPkTnD1s39GiiqbngCw=="], + "which-command": ["which-command@0.1.0", "", { "bin": { "which-command": "cli.js" } }, "sha512-XZyoF5/5hZtXitIwzrU4NKK+Wtbb9aB9CezUEw2Q0wlYK8NUYQxC1rRXgNueYLtBAJwXIb+/tFVk4dozciNJMA=="], + "which-typed-array": ["which-typed-array@1.1.22", "", { "dependencies": { "available-typed-arrays": "^1.0.7", "call-bind": "^1.0.9", "call-bound": "^1.0.4", "for-each": "^0.3.5", "get-proto": "^1.0.1", "gopd": "^1.2.0", "has-tostringtag": "^1.0.2" } }, "sha512-fvO4ExWMFsqyhG3AiPAObMuY1lxaqgYcxbc49CNdWDDECOJNgQyvsOWVwbZc+qf3rzRtxojBK+CMEv0Ld5CYpw=="], "why-is-node-running": ["why-is-node-running@2.3.0", "", { "dependencies": { "siginfo": "^2.0.0", "stackback": "0.0.2" }, "bin": { "why-is-node-running": "cli.js" } }, "sha512-hUrmaWBdVDcxvYqnyh09zunKzROWjbZTiNy8dBEjkS7ehEDQibXJ7XvlmtbwuTclUiIyN+CyXQD4Vmko8fNm8w=="], @@ -2964,7 +3052,7 @@ "wrappy": ["wrappy@1.0.2", "", {}, "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ=="], - "ws": ["ws@8.21.3", "", { "peerDependencies": { "bufferutil": "^4.0.1", "utf-8-validate": ">=5.0.2" }, "optionalPeers": ["bufferutil", "utf-8-validate"] }, "sha512-201TZ/kPWxoPr/OKWjquZR1SWKXcvxdH+e1xrx89b3YbmzLMFCLfnaG1HFIgWzJOEWZ7MvpK++odZufgYR50Rw=="], + "ws": ["ws@8.22.2", "", { "peerDependencies": { "bufferutil": "^4.0.1", "utf-8-validate": ">=5.0.2" }, "optionalPeers": ["bufferutil", "utf-8-validate"] }, "sha512-/rEZ2ejown2N5gxVTHUu9bVVC7ttu0/Tgzf5hbTOixR3Fs7mbbXgn2DbdbcKgJOmpQMtrIUWivtYuVMnp/W/yA=="], "xtend": ["xtend@4.0.2", "", {}, "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ=="], @@ -2978,12 +3066,14 @@ "yargs-parser": ["yargs-parser@21.1.1", "", {}, "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw=="], - "yauzl": ["yauzl@2.10.0", "", { "dependencies": { "buffer-crc32": "~0.2.3", "fd-slicer": "~1.1.0" } }, "sha512-p4a9I6X6nu6IhoGmBqAcbJy1mlC4j27vEPZX9F4L4/vZT3Lyq1VkFHw/V/PUcB9Buo+DG3iHkT0x3Qya58zc3g=="], + "yauzl": ["yauzl@3.4.0", "", { "dependencies": { "pend": "~1.2.0" } }, "sha512-jIH9yLR9wqr0wOS0TpBvo/g/2UgZH5qePVbjgRliiF0BYvOZyaBknKsF+x9Iht0O6sqgnB93rCICdOZFecJuDw=="], "yjs": ["yjs@13.6.32", "", { "dependencies": { "lib0": "^0.2.99" } }, "sha512-lfiJIIC4Xayt5ItynE407ehlE03pCjeOc4hkR4yxxvvNJ4kuiN25B0g+Qp8XagYz361LLL7DCzR5bvFJ81QKtQ=="], "yocto-queue": ["yocto-queue@0.1.0", "", {}, "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q=="], + "yoctocolors": ["yoctocolors@2.2.0", "", {}, "sha512-xYqdZFUK/VYazNl/oCDYN+3WloWQwMfZxBoiNt6qNyk+xfOdi598muWE42rNZFp1kNOiqW936q5RhUdnpqElSg=="], + "zeptomatch": ["zeptomatch@2.1.0", "", { "dependencies": { "grammex": "^3.1.11", "graphmatch": "^1.1.0" } }, "sha512-KiGErG2J0G82LSpniV0CtIzjlJ10E04j02VOudJsPyPwNZgGnRKQy7I1R7GMyg/QswnE4l7ohSGrQbQbjXPPDA=="], "zip-stream": ["zip-stream@6.0.1", "", { "dependencies": { "archiver-utils": "^5.0.0", "compress-commons": "^6.0.2", "readable-stream": "^4.0.0" } }, "sha512-zK7YHHz4ZXpW89AHXUPbQVGKI7uvkd3hzusTdotCg1UxyaVtg0zFJSTfW/Dq5f7OBBVnq6cZIaC8Ti4hb6dtCA=="], @@ -2996,6 +3086,10 @@ "@ai-sdk/provider-utils/undici": ["undici@7.29.0", "", {}, "sha512-IDxfleLmmbSskfWSUATiN1nfn2rDuvnMOqb5CWR92iIfojA0Ud+ulOAAEQ57LPr9rWmsreUyf5lwyao+7GNNVw=="], + "@anthropic-ai/sandbox-runtime/commander": ["commander@12.1.0", "", {}, "sha512-Vw8qHK3bZM9y/P10u3Vib8o/DdkvA2OtPtZvD871QKjy74Wj1WSKFILMPRPSdUSx5RFK1arlJzEtA4PkFgnbuA=="], + + "@anthropic-ai/sandbox-runtime/zod": ["zod@3.25.76", "", {}, "sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ=="], + "@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node": ["@aws-sdk/credential-provider-node@3.972.92", "", { "dependencies": { "@aws-sdk/credential-provider-env": "^3.972.80", "@aws-sdk/credential-provider-http": "^3.972.82", "@aws-sdk/credential-provider-ini": "^3.973.25", "@aws-sdk/credential-provider-process": "^3.972.80", "@aws-sdk/credential-provider-sso": "^3.973.24", "@aws-sdk/credential-provider-web-identity": "^3.972.86", "@aws-sdk/types": "^3.975.0", "@smithy/core": "^3.38.0", "@smithy/credential-provider-imds": "^4.5.2", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-jC3zmOo7Qxlk+oBivvSsS1Ph7sFGm0QfuhqDGbqgRXi4cxUYMG+dWtBwS2XYYXgc8TIVXJiwgQ65sbNpbYupTA=="], "@aws-sdk/client-bedrock-runtime/@smithy/node-http-handler": ["@smithy/node-http-handler@4.11.3", "", { "dependencies": { "@smithy/core": "^3.33.3", "@smithy/types": "^4.17.2", "tslib": "^2.6.2" } }, "sha512-2jY1tSpERfPfWqyBV2pH+iGFaghVsIJszJNsT7hxtQYhVJpWDyc0LqOWI+nXOxOAHaEfZ4PXXtp1wW1TGpHhkA=="], @@ -3012,10 +3106,16 @@ "@dbos-inc/dbos-sdk/commander": ["commander@12.1.0", "", {}, "sha512-Vw8qHK3bZM9y/P10u3Vib8o/DdkvA2OtPtZvD871QKjy74Wj1WSKFILMPRPSdUSx5RFK1arlJzEtA4PkFgnbuA=="], + "@dbos-inc/dbos-sdk/ws": ["ws@8.21.3", "", { "peerDependencies": { "bufferutil": "^4.0.1", "utf-8-validate": ">=5.0.2" }, "optionalPeers": ["bufferutil", "utf-8-validate"] }, "sha512-201TZ/kPWxoPr/OKWjquZR1SWKXcvxdH+e1xrx89b3YbmzLMFCLfnaG1HFIgWzJOEWZ7MvpK++odZufgYR50Rw=="], + + "@earendil-works/chord/ws": ["ws@8.21.3", "", { "peerDependencies": { "bufferutil": "^4.0.1", "utf-8-validate": ">=5.0.2" }, "optionalPeers": ["bufferutil", "utf-8-validate"] }, "sha512-201TZ/kPWxoPr/OKWjquZR1SWKXcvxdH+e1xrx89b3YbmzLMFCLfnaG1HFIgWzJOEWZ7MvpK++odZufgYR50Rw=="], + "@earendil-works/pi-ai/@google/genai": ["@google/genai@2.21.0", "", { "dependencies": { "google-auth-library": "^10.3.0", "p-retry": "^4.6.2", "protobufjs": "^7.5.4", "ws": "^8.18.0" }, "peerDependencies": { "@modelcontextprotocol/sdk": "^1.25.2" }, "optionalPeers": ["@modelcontextprotocol/sdk"], "hasInstallScript": true }, "sha512-+PDtco2/Z0ONdzCGekCoCT+O1VJS9xJQNN4XzQpXG/t3El/SWWMkCWlFRO1KmivOHPa4Q0VjUYu1HBKCZ/v33Q=="], "@eslint-community/eslint-utils/eslint-visitor-keys": ["eslint-visitor-keys@3.4.3", "", {}, "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag=="], + "@google/genai/ws": ["ws@8.21.3", "", { "peerDependencies": { "bufferutil": "^4.0.1", "utf-8-validate": ">=5.0.2" }, "optionalPeers": ["bufferutil", "utf-8-validate"] }, "sha512-201TZ/kPWxoPr/OKWjquZR1SWKXcvxdH+e1xrx89b3YbmzLMFCLfnaG1HFIgWzJOEWZ7MvpK++odZufgYR50Rw=="], + "@grpc/grpc-js/@grpc/proto-loader": ["@grpc/proto-loader@0.8.1", "", { "dependencies": { "lodash.camelcase": "^4.3.0", "long": "^5.0.0", "protobufjs": "^7.5.5", "yargs": "^17.7.2" }, "bin": { "proto-loader-gen-types": "build/bin/proto-loader-gen-types.js" } }, "sha512-wtF6h+DY6M3YaDBPAmvuuA6jV8Sif9MjtOI5euKFWRgCDl5PeDpPsHR9u2l6St5ceY8AZgoNDww5+HvEsXFsGg=="], "@inlang/paraglide-js/commander": ["commander@11.1.0", "", {}, "sha512-yPVavfyCcRhmorC7rWlkHn15b4wDVgVmBA7kV4QVBsF7kv/9TKJAbAXVTxvTnwP8HHKjRCJDClKbciiYS7p0DQ=="], @@ -3028,6 +3128,8 @@ "@isaacs/cliui/wrap-ansi": ["wrap-ansi@8.1.0", "", { "dependencies": { "ansi-styles": "^6.1.0", "string-width": "^5.0.1", "strip-ansi": "^7.0.1" } }, "sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ=="], + "@microsoft/mxc-sdk/semver": ["semver@7.8.5", "", { "bin": { "semver": "bin/semver.js" } }, "sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA=="], + "@prisma/dev/std-env": ["std-env@3.10.0", "", {}, "sha512-5GS12FdOZNliM5mAOxFRg7Ir0pWz8MdpYm6AY6VPkGpbA7ZzmbzNcBJQ0GPvvyWgcY7QAhCgf9Uy89I03faLkg=="], "@prisma/engines/@prisma/get-platform": ["@prisma/get-platform@7.10.0", "", { "dependencies": { "@prisma/debug": "7.10.0" } }, "sha512-0bra1LFYi8xNw0yqV62bHJNQk4BKleOngZiqPWIQc7a3+9q6rqsnqJ15BuepP8943PFMvtmgnP52juZsyYkA6w=="], @@ -3042,6 +3144,8 @@ "@reduxjs/toolkit/reselect": ["reselect@5.3.0", "", {}, "sha512-XGoLeRAVzUTcJ1qkxPQhDJyIZ5d6zzZD9nT7AEZOaaU9UbWclhycElmhO+VD5bFeLuzhPBaOV2oXC8uG35ZSpg=="], + "@shumai/cli/adm-zip": ["adm-zip@0.6.1", "", {}, "sha512-Xwrja8nx9e5o2N1my4DsKCeKpdrnACyr1wtbPxBDgGzKzKyE9kRtBFA8mWldI+RVlD7CBZNWY/wQ2+ydwOR6kQ=="], + "@shumai/webui/@types/react-dom": ["@types/react-dom@19.2.5", "", { "peerDependencies": { "@types/react": "^19.2.0" } }, "sha512-fMPwH9v7r/pp43yUd2/Mbiex5KouJwwR3dzHkhLREUC6764VyDsqxhAxv6OFEYR1RhjOyD1naqba8ECDBe7ZQg=="], "@smithy/node-http-handler/@smithy/types": ["@smithy/types@4.19.0", "", { "dependencies": { "tslib": "^2.6.2" } }, "sha512-r7jh49VJxGerfAcTQA6gXcKc+98zOp/tqRwzYjgOE+iSQsP6cEU1hq2QzbuipmP68QtYdY9wKEhiCQZIzHgZ4Q=="], @@ -3188,6 +3292,8 @@ "@visx/vendor/d3-format": ["d3-format@3.1.0", "", {}, "sha512-YyUI6AEuY/Wpt8KWLgZHsIU86atmikuoOmCfommt0LYHiQSPjvX2AcFc38PX0CBpr2RCyZhjex+NS/LPOv6YqA=="], + "archiver-utils/is-stream": ["is-stream@2.0.1", "", {}, "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg=="], + "bcrypt-pbkdf/tweetnacl": ["tweetnacl@0.14.5", "", {}, "sha512-KXXFFdAbFXY4geFIwoyNK+f5Z1b7swfXABfL7HXCmoIWMKU3dmS26672A4EeQtDzLKy7SXmfBu51JolvEKwtGA=="], "better-call/@better-fetch/fetch": ["@better-fetch/fetch@1.3.1", "", {}, "sha512-ABkD1WhyfPZprKRQI3bhATjeiFuNWC9PXhfGWqL+sg/gKrM977oFrYkdb4msM3hgUGonr7KlOsOFT5TU2rht9g=="], @@ -3196,13 +3302,19 @@ "bl/readable-stream": ["readable-stream@3.6.2", "", { "dependencies": { "inherits": "^2.0.3", "string_decoder": "^1.1.1", "util-deprecate": "^1.0.1" } }, "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA=="], + "compress-commons/is-stream": ["is-stream@2.0.1", "", {}, "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg=="], + "docker-modem/readable-stream": ["readable-stream@3.6.2", "", { "dependencies": { "inherits": "^2.0.3", "string_decoder": "^1.1.1", "util-deprecate": "^1.0.1" } }, "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA=="], "dockerode/tar-fs": ["tar-fs@2.1.5", "", { "dependencies": { "chownr": "^1.1.1", "mkdirp-classic": "^0.5.2", "pump": "^3.0.0", "tar-stream": "^2.1.4" } }, "sha512-OboTd8mmMhZDNPV+UjQcK9yKAatXu2aJ+r1w4im1Otd4M4fl2hwvdoXUxIYHFTHWK/3y3FarBP70v3vwmGlOxw=="], "eslint-plugin-react/minimatch": ["minimatch@3.1.5", "", { "dependencies": { "brace-expansion": "^1.1.7" } }, "sha512-VgjWUsnnT6n+NUk6eZq77zeFdpW2LWDzP6zFGrCbHXiYNul5Dzqk2HHQ5uFH2DNW5Xbp8+jVzaeNt94ssEEl4w=="], - "foreground-child/signal-exit": ["signal-exit@4.1.0", "", {}, "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw=="], + "extract-zip/@types/yauzl": ["@types/yauzl@2.10.3", "", { "dependencies": { "@types/node": "*" } }, "sha512-oJoftv0LSuaDZE3Le4DbKX+KS9G36NzOeSap90UIK0yMA/NhKJhqlSGtNDORNRaIbQfzjXDrQa0ytJ6mNRGz/Q=="], + + "extract-zip/get-stream": ["get-stream@5.2.0", "", { "dependencies": { "pump": "^3.0.0" } }, "sha512-nBF+F1rAZVCu/p7rjzgA+Yb4lfYXrpl7a6VmJrU8wF9I1CKvP/QwPNZHnOlwbTkY6dvtFIzFMSyQXbLoTQPRpA=="], + + "extract-zip/yauzl": ["yauzl@2.10.0", "", { "dependencies": { "buffer-crc32": "~0.2.3", "fd-slicer": "~1.1.0" } }, "sha512-p4a9I6X6nu6IhoGmBqAcbJy1mlC4j27vEPZX9F4L4/vZT3Lyq1VkFHw/V/PUcB9Buo+DG3iHkT0x3Qya58zc3g=="], "gaxios/https-proxy-agent": ["https-proxy-agent@7.0.6", "", { "dependencies": { "agent-base": "^7.1.2", "debug": "4" } }, "sha512-vK9P5/iUfdl95AI+JVyUuIcVtd4ofvtrOr3HNtM2yxC9bnMbEdp3x01OhQNnjb8IJYi38VlTE3mBXwcfvywuSw=="], @@ -3210,6 +3322,10 @@ "glob/minimatch": ["minimatch@9.0.9", "", { "dependencies": { "brace-expansion": "^2.0.2" } }, "sha512-OBwBN9AL4dqmETlpS2zasx+vTeWclWzkblfZk7KTA5j3jeOONz/tRCnZomUyvNg83wL5Zv9Ss6HMJXAgL8R2Yg=="], + "happy-dom/@types/ws": ["@types/ws@8.18.1", "", { "dependencies": { "@types/node": "*" } }, "sha512-ThVF6DCVhA8kUGy+aazFQ4kXQ7E1Ty7A3ypFOe0IcJV8O/M511G99AW24irKrW56Wt44yG9+ij8FaqoBGkuBXg=="], + + "happy-dom/ws": ["ws@8.21.3", "", { "peerDependencies": { "bufferutil": "^4.0.1", "utf-8-validate": ">=5.0.2" }, "optionalPeers": ["bufferutil", "utf-8-validate"] }, "sha512-201TZ/kPWxoPr/OKWjquZR1SWKXcvxdH+e1xrx89b3YbmzLMFCLfnaG1HFIgWzJOEWZ7MvpK++odZufgYR50Rw=="], + "its-fine/@types/react-reconciler": ["@types/react-reconciler@0.28.9", "", { "peerDependencies": { "@types/react": "*" } }, "sha512-HHM3nxyUZ3zAylX8ZEyrDNd2XZOnQ0D5XfunJF5FLQnZbHHYq4UWvW1QfelQNXv1ICNkwYhfxjwfnqivYB6bFg=="], "lazystream/readable-stream": ["readable-stream@2.3.8", "", { "dependencies": { "core-util-is": "~1.0.0", "inherits": "~2.0.3", "isarray": "~1.0.0", "process-nextick-args": "~2.0.0", "safe-buffer": "~5.1.1", "string_decoder": "~1.1.1", "util-deprecate": "~1.0.1" } }, "sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA=="], @@ -3220,6 +3336,8 @@ "lit-element/@lit/reactive-element": ["@lit/reactive-element@1.6.3", "", { "dependencies": { "@lit-labs/ssr-dom-shim": "^1.0.0" } }, "sha512-QuTgnG52Poic7uM1AN5yJ09QMe0O28e10XzSvWDz02TJiiKee4stsiownEIadWm8nYzyDAyT+gKzUoZmiWQtsQ=="], + "npm-run-path/path-key": ["path-key@4.0.0", "", {}, "sha512-haREypq7xkM7ErfgIyA0z+Bj4AGKlMSdlQE2jvJo6huWD1EdkKYV+G/T4nq0YEF2vgTT8kqMFKo1uHn950r4SQ=="], + "p-retry/retry": ["retry@0.13.1", "", {}, "sha512-XQBQ3I8W1Cge0Seh+6gjj03LbmRFWuoszgK9ooCpwYIrhhoO80pfq4cUkU5DkknwfOfFteRwlZ56PYOGYyFWdg=="], "parse-entities/@types/unist": ["@types/unist@2.0.11", "", {}, "sha512-CmBKiL6NNo/OqgmMn95Fk9Whlp2mtvIv+KNpQKN2F4SjvrEesubTRWGYSg+BnWZOnlCaSTU1sMpsBOzgbYhnsA=="], @@ -3238,6 +3356,8 @@ "prop-types/react-is": ["react-is@16.13.1", "", {}, "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ=="], + "proper-lockfile/signal-exit": ["signal-exit@3.0.7", "", {}, "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ=="], + "readdir-glob/minimatch": ["minimatch@5.1.9", "", { "dependencies": { "brace-expansion": "^2.0.1" } }, "sha512-7o1wEA2RyMP7Iu7GNba9vc0RWWGACJOCZBJX2GJWip0ikV+wcOsgVuY9uE8CPiyQhkGFSlhuSkZPavN7u1c2Fw=="], "sharp/semver": ["semver@7.8.5", "", { "bin": { "semver": "bin/semver.js" } }, "sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA=="], @@ -3250,8 +3370,6 @@ "wrap-ansi-cjs/ansi-styles": ["ansi-styles@4.3.0", "", { "dependencies": { "color-convert": "^2.0.1" } }, "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg=="], - "yauzl/buffer-crc32": ["buffer-crc32@0.2.13", "", {}, "sha512-VO9Ht/+p3SN7SKWqcrgEzjGbRSJYTx+Q1pTQC0wrWqHx0vpJraQ6GtHx8tvcg1rlK1byhU5gccxgOgj7B0TDkQ=="], - "@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-env": ["@aws-sdk/credential-provider-env@3.972.80", "", { "dependencies": { "@aws-sdk/core": "^3.979.1", "@aws-sdk/types": "^3.975.0", "@smithy/core": "^3.38.0", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-uO5TiSvb6j1w9RTe5z28OaOmsrOxVQUPaC5+wZl50RfOXcrYD/KgnS8I9lfyGXc7sGbkCopK6VnhNIAoLqfewQ=="], "@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@aws-sdk/credential-provider-http": ["@aws-sdk/credential-provider-http@3.972.82", "", { "dependencies": { "@aws-sdk/core": "^3.979.1", "@aws-sdk/types": "^3.975.0", "@smithy/core": "^3.38.0", "@smithy/fetch-http-handler": "^5.8.0", "@smithy/node-http-handler": "^4.14.0", "@smithy/types": "^4.19.0", "tslib": "^2.6.2" } }, "sha512-vQzlDHlC24Yz42p+rT4NBoP/5VdetkBoujbOLq9h6QYWC8THuZSPYnXIR9OP3XcOrdMgPBBipOrdssfxnIiWUg=="], @@ -3270,6 +3388,8 @@ "@aws-sdk/client-bedrock-runtime/@aws-sdk/credential-provider-node/@smithy/types": ["@smithy/types@4.19.0", "", { "dependencies": { "tslib": "^2.6.2" } }, "sha512-r7jh49VJxGerfAcTQA6gXcKc+98zOp/tqRwzYjgOE+iSQsP6cEU1hq2QzbuipmP68QtYdY9wKEhiCQZIzHgZ4Q=="], + "@earendil-works/pi-ai/@google/genai/ws": ["ws@8.21.3", "", { "peerDependencies": { "bufferutil": "^4.0.1", "utf-8-validate": ">=5.0.2" }, "optionalPeers": ["bufferutil", "utf-8-validate"] }, "sha512-201TZ/kPWxoPr/OKWjquZR1SWKXcvxdH+e1xrx89b3YbmzLMFCLfnaG1HFIgWzJOEWZ7MvpK++odZufgYR50Rw=="], + "@isaacs/cliui/string-width/emoji-regex": ["emoji-regex@9.2.2", "", {}, "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg=="], "@isaacs/cliui/strip-ansi/ansi-regex": ["ansi-regex@6.3.0", "", {}, "sha512-WpDfL7NO6j7tH88IDBNVdUJxDh9nmCteAVW9dsep846XdwF4naCBK+/tGLX3KJgcpgMRXCFlTM2hKGoK9FsdrQ=="], @@ -3372,6 +3492,8 @@ "eslint-plugin-react/minimatch/brace-expansion": ["brace-expansion@1.1.18", "", { "dependencies": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" } }, "sha512-Edep/X9fGqVNmzKBVsDYIOtD+z1tuezV70LBjdCst9Tqu76lsnvRiZ6oTic1n+/BIwX6QDGAO94PN4N2SADvtw=="], + "extract-zip/yauzl/buffer-crc32": ["buffer-crc32@0.2.13", "", {}, "sha512-VO9Ht/+p3SN7SKWqcrgEzjGbRSJYTx+Q1pTQC0wrWqHx0vpJraQ6GtHx8tvcg1rlK1byhU5gccxgOgj7B0TDkQ=="], + "gaxios/https-proxy-agent/agent-base": ["agent-base@7.1.4", "", {}, "sha512-MnA+YT8fwfJPgBx3m60MNqakm30XOkyIoH1y6huTQvC0PwZG7ki8NacLBcrPbNoo8vEZy7Jpuk7+jMO+CUovTQ=="], "glob/minimatch/brace-expansion": ["brace-expansion@2.1.4", "", { "dependencies": { "balanced-match": "^1.0.0" } }, "sha512-hGfVzPxthbf3+2yjg/RBs60cB0FhqBS/zvdV/4wn4/BmN0bNMMHPc4V/BbFieqf1TKAGGAHnY4eSjajCl0f2Xg=="], diff --git a/docs/using-shumai/agent-sandbox.mdx b/docs/using-shumai/agent-sandbox.mdx index 1eb0ba7e..04bde904 100644 --- a/docs/using-shumai/agent-sandbox.mdx +++ b/docs/using-shumai/agent-sandbox.mdx @@ -1,45 +1,97 @@ --- -title: Agent Sandbox -description: Secure execution environment and network domain restrictions for AI agent scripts. +title: Agent Runners +description: Connect an optional command runner and configure sandboxing on its machine. --- -Running automated scripts poses security risks. Shumai resolves this by executing all agent skills inside a secure, isolated **Sandbox** environment. +Agents use Shumai's built-in tools without a runner. To execute shell commands or download assets into a shell workspace, connect a **runner** on a machine you control. The runner opens an authenticated outbound WebSocket connection; no inbound port is needed. ---- +## Connect a runner -## Sandbox Security +1. In **Settings → Agent Runners**, create a runner and copy its one-time key. Only team owners can manage runners and rotate their keys. +2. Install [Shumai CLI](https://github.com/shumaiOne/shumai/tree/main/apps/cli#installation) on macOS, Linux, or Windows. +3. Start it in a dedicated, existing workspace: -The sandbox restricts the execution process from accessing the host filesystem, system processes, and internal networks: +```bash +export SHUMAI_API_SERVER="https://shumai.example.com" +export SHUMAI_RUNNER_KEY="your-runner-key" +shumai-cli runner start --cwd /path/to/workspace +``` -- **Isolation**: Scripts run in a virtualized workspace container that prevents them from modifying critical system files or reading other project data. -- **Network Bridging**: External network calls from inside the sandbox are strictly monitored. +On Windows, set the variables in PowerShell: -### File System Restrictions +```powershell +$env:SHUMAI_API_SERVER = "https://shumai.example.com" +$env:SHUMAI_RUNNER_KEY = "your-runner-key" +shumai-cli runner start --cwd C:\workspace +``` -To protect your workspace environments and sensitive data, the sandbox enforces strict file-level access controls: +Use a runner key, not a personal API token. Prefer the environment variable over `--key` to keep the key out of shell history. The runner stays in the foreground; Ctrl+C stops it and its active commands. Temporary connection losses trigger reconnection. Revoked or replaced connections stop instead of reconnecting. -- **Read Access**: The sandbox is allowed to read files within the workspace, with a strict exception for sensitive environment and certificate files. It cannot read: `['.env', '.env.*', '*.pem', '*.key']`. -- **Write Access**: The sandbox is heavily restricted and may only write to the `.pi` folder located in the current working directory (cwd). Even within this allowed directory, the sandbox is explicitly blocked from writing or creating sensitive files matching: `['.env', '.env.*', '*.pem', '*.key']`. +The first runner becomes the team default. Each agent can use that default or a dedicated runner selected in its settings. Without a configured runner, `bash` and `download_asset` are hidden. With one configured, authorized editors and reviewers can run commands immediately without reading a skill first. Disabled-tool policies still apply. An offline runner produces an execution error. ---- +The `bash` tool uses the runner's native shell: `/bin/sh` on macOS/Linux and `cmd.exe` on Windows. The agent receives the OS and shell information and must use compatible commands. Windows does not require Bash or Git. -## Domain Whitelisting +Commands start in the workspace directory. Skills, downloaded assets, generated files, and output logs live under `.pi`. Commands inherit baseline OS settings and explicit skill variables, rather than the runner's full environment, including its runner key and personal API token. -By default, Network Sandbox is **disabled** (allowing all outbound network requests). Team Owners can toggle Network Sandbox **ON** in Sandbox Settings to enforce strict domain whitelisting: +## Optional SRT sandbox -### Allowed Domains +Without `--srt`, commands have the runner operating-system user's permissions. Connect only to a trusted Shumai server; use a dedicated container, VM, or account when appropriate. -A list of domains that sandboxed scripts are permitted to access. +[Anthropic Sandbox Runtime](https://github.com/anthropics/sandbox-runtime) is bundled as a library in Shumai CLI. Install its platform prerequisites on the runner machine (Linux: bubblewrap, socat, and ripgrep; macOS: ripgrep), then start with its JSON settings: -- Default whitelisted domains include standard package registries (like npm or python package hosts) and repository hosts (like `github.com`). -- If a script needs to call an external API (e.g. `api.slack.com`), the administrator must add it to the allowed list. +```bash +shumai-cli runner start --cwd /path/to/workspace --srt sandbox.json +``` -### Pending Domains +Windows uses SRT's alpha Windows support. Run the one-time setup before starting a sandboxed runner; it requests administrator permission: -When an agent script attempts to reach a domain that is not currently authorized: +```powershell +npx @anthropic-ai/sandbox-runtime windows-install +``` -1. The network connection is blocked immediately. -2. The target domain is logged and added to the **Pending Domains** list. -3. Admins can review this list and click **Approve** to authorize the domain, or **Reject** to keep it blocked. +SRT verifies the setup at startup and reports an error if it is missing. A runner without `--srt` does not need this setup. -![Agent Sandbox Settings](../sandbox.webp) +The JSON uses upstream SRT settings directly. For example: + +```json +{ + "filesystem": { + "denyRead": ["~/.ssh", "~/.aws", ".env", ".env.*"], + "allowWrite": [".pi"], + "denyWrite": [] + }, + "network": { + "allowedDomains": [], + "deniedDomains": [] + } +} +``` + +This example allows writes only in `.pi`, denies reads of the listed credential locations, and blocks command network access. Review read permissions and network rules for your environment using SRT's documentation. Relative filesystem paths use the runner workspace. Settings are snapshotted at startup; restart after changing them. Missing or invalid settings, missing SRT prerequisites, and sandbox initialization failures stop startup. Commands never fall back to unrestricted execution. + +SRT wraps shell commands and their child processes. One shared SRT runtime handles concurrent commands and is reset when the runner stops. The runner's WebSocket and server-directed file transfers operate outside SRT. **The Shumai server address is not automatically added to allowed domains.** If a script itself needs network access, explicitly allow its destination in the JSON. + +Shumai has no server-side sandbox or domain settings. SRT is initialized only on runners that opt into it. SRT in Docker may require namespace permissions on that dedicated runner container; these permissions are not needed by the Shumai server. + +## Runner in Docker + +An ordinary runner can run in its own container without extra capabilities or an exposed port: + +```bash +docker run --rm --init --name shumai-runner \ + --cap-drop ALL --security-opt no-new-privileges \ + -e SHUMAI_API_SERVER -e SHUMAI_RUNNER_KEY \ + -v shumai-runner-workspace:/workspace -w /workspace \ + node:22-bookworm sh -c \ + 'npm install -g @shumai-one/shumai-cli && exec shumai-cli runner start' +``` + +For development, HTTP is accepted for `localhost`, `127.0.0.1`, `[::1]`, and Docker's `host.docker.internal`. Remote servers require HTTPS. Avoid mounting sensitive host directories or the Docker socket into the runner workspace. + +## Limits and lifecycle + +Commands default to 120 seconds and accept a maximum timeout of one hour. Timeout and cancellation attempt to terminate the command and its process tree. Each command saves up to 64 MiB of output in `.pi/logs`; manage retained logs as part of workspace maintenance. Transfers and extracted archives are limited to 256 MiB. Protocol file operations reject paths outside `.pi`, existing symlinks, and unsafe archive entries. V1 assumes commands do not deliberately change workspace paths while transfers are running. + +Temporary reconnects reconcile active and recently completed commands without deliberately executing them again. Restarting the runner process does not resume commands from the previous process. + +Up to eight commands and file transfers can run concurrently in the shared workspace. Additional requests return a busy error. On Windows without SRT, background processes may survive after the command's shell exits; remaining output pipes are closed after one second. Use foreground commands for predictable timeout and cancellation. SRT manages the sandboxed Windows process tree. diff --git a/docs/zh/using-shumai/agent-sandbox.mdx b/docs/zh/using-shumai/agent-sandbox.mdx index 1d341ca6..6d6f052a 100644 --- a/docs/zh/using-shumai/agent-sandbox.mdx +++ b/docs/zh/using-shumai/agent-sandbox.mdx @@ -1,45 +1,95 @@ --- -title: 智能体沙箱 -description: AI 智能体脚本的安全执行环境与网络域名限制规范。 +title: 智能体运行器 +description: 连接可选的命令运行器,并在运行器机器上配置沙箱。 --- -运行自动化脚本存在潜在的安全风险。Shumai 通过在安全且隔离的**沙箱(Sandbox)**环境中执行所有智能体技能来化解这一隐患。 +智能体无需运行器即可使用内置工具。如需执行命令或将素材下载到命令工作区,请在自己管理的机器上连接**运行器**。运行器主动通过经过身份验证的 WebSocket 连接 Shumai,无需开放入站端口。 ---- +## 连接运行器 -## 沙箱安全机制 +1. 在 **设置 → 智能体运行器** 中创建运行器,复制仅显示一次的密钥。只有团队所有者可以管理运行器和轮换密钥。 +2. 在 macOS、Linux 或 Windows 机器上安装 [Shumai CLI](https://github.com/shumaiOne/shumai/tree/main/apps/cli#installation)。 +3. 在已有的专用工作目录中启动: -沙箱严格限制执行进程访问宿主机文件系统、系统进程及内部网络: +```bash +export SHUMAI_API_SERVER="https://shumai.example.com" +export SHUMAI_RUNNER_KEY="your-runner-key" +shumai-cli runner start --cwd /path/to/workspace +``` -- **环境隔离**:脚本在虚拟化的工作区容器中运行,无法篡改系统核心文件或读取其他项目数据。 -- **网络桥接管控**:来自沙箱内部的外部网络请求会受到严格监控。 +Windows 用户可在 PowerShell 中设置变量: -### 文件系统访问限制 +```powershell +$env:SHUMAI_API_SERVER = "https://shumai.example.com" +$env:SHUMAI_RUNNER_KEY = "your-runner-key" +shumai-cli runner start --cwd C:\workspace +``` -为保障工作区环境与敏感数据安全,沙箱实施了严密的文件级访问控制策略: +使用运行器密钥,而非个人 API 令牌。建议通过环境变量传入,避免 `--key` 将密钥留在命令历史中。运行器在前台执行,Ctrl+C 会停止运行器及其活动命令。临时断线后自动重连;密钥撤销或连接被替换时退出。 -- **读取权限**:沙箱允许读取工作区内的普通文件,但严格禁止访问敏感环境配置与证书密钥文件。禁止读取的文件模式包括:`['.env', '.env.*', '*.pem', '*.key']`。 -- **写入权限**:沙箱的写入权限受到极为严苛的限制,仅允许写入当前工作目录(cwd)下的 `.pi` 文件夹。即便在该受信任的目录内部,沙箱也严禁写入或创建匹配以下模式的敏感文件:`['.env', '.env.*', '*.pem', '*.key']`。 +第一个运行器是团队默认运行器,也可在智能体设置中指定专用运行器。未配置运行器时隐藏 `bash` 和 `download_asset`。配置后,具有智能体使用权限的编辑者和审阅者可立即使用 Bash,无需先读取技能;禁用工具设置仍然生效。运行器离线时执行命令会返回错误。 ---- +命令从工作目录启动,技能、下载素材、生成文件和日志位于 `.pi` 中。子进程只继承基础系统环境及明确配置的技能变量,不自动继承运行器密钥、个人 API 令牌或其他任意环境变量。 -## 域名白名单 +## 可选 SRT 沙箱 -默认情况下,网络沙箱处于**关闭**状态(允许所有出站网络请求)。团队所有者可在沙箱设置中开启网络沙箱,以强制推行严格的域名白名单管控: +未使用 `--srt` 时,命令具有运行器系统用户的权限。只连接可信 Shumai 服务器,可按需使用独立容器、虚拟机或账号。 -### 允许的域名 (Allowed Domains) +[Anthropic Sandbox Runtime](https://github.com/anthropics/sandbox-runtime) 已作为库内置于 Shumai CLI。安装平台依赖(Linux:bubblewrap、socat 和 ripgrep;macOS:ripgrep)后传入 JSON 配置: -允许沙箱内脚本正常访问的域名清单。 +```bash +shumai-cli runner start --cwd /path/to/workspace --srt sandbox.json +``` -- 默认白名单包含标准软件包注册表(如 npm、Python 官方源等)以及代码托管平台(如 `github.com`)。 -- 若脚本需要调用外部 API(如 `api.slack.com`),管理员须预先将其添加至白名单中。 +Windows 使用 SRT 的实验性 Windows 支持。启用沙箱前执行一次初始化;此命令会请求管理员权限: -### 待审批域名 (Pending Domains) +```powershell +npx @anthropic-ai/sandbox-runtime windows-install +``` -当智能体脚本尝试访问未经授权的域名时: +SRT 会在启动时检查安装状态,缺少初始化时返回错误。未使用 `--srt` 的运行器不需要此步骤。`bash` 工具使用运行器的原生 Shell:macOS/Linux 为 `/bin/sh`,Windows 为 `cmd.exe`。智能体会收到系统和 Shell 信息,以生成匹配的命令。Windows 无需安装 Bash 或 Git。 -1. 网络连接将被即刻拦截。 -2. 系统会记录目标域名并将其加入**待审批域名**列表。 -3. 管理员可审阅该列表,点击**批准**将其加白,或点击**拒绝**保持拦截。 +直接使用上游 SRT JSON 格式,例如: -![智能体沙箱设置](/sandbox.webp) +```json +{ + "filesystem": { + "denyRead": ["~/.ssh", "~/.aws", ".env", ".env.*"], + "allowWrite": [".pi"], + "denyWrite": [] + }, + "network": { + "allowedDomains": [], + "deniedDomains": [] + } +} +``` + +此例只允许写入 `.pi`,禁止读取所列凭证位置,并禁止命令访问网络。请参考 SRT 文档审查适合自己环境的读取权限和域名规则。相对路径以运行器工作目录为基准。配置在启动时读取并保存快照,修改后需要重启。配置缺失或无效、SRT 依赖缺失、沙箱初始化失败都会阻止启动,不会回退到无沙箱执行。 + +SRT 只包裹 Shell 命令及其子进程。并发命令共享同一个 SRT 运行时,运行器停止时统一清理。运行器 WebSocket 和服务器发起的文件传输在 SRT 外运行。**不会自动将 Shumai 服务器地址添加到允许域名中。** 如果脚本自身需要网络,请在 JSON 中明确允许目标域名。 + +Shumai 服务器不管理沙箱和域名规则。只有启用沙箱的运行器才初始化 SRT。在 Docker 中使用 SRT 可能需要为专用运行器容器增加命名空间权限,Shumai 服务器不需要这些权限。 + +## Docker 运行器 + +普通运行器可在独立容器中执行,无需额外权限或暴露端口: + +```bash +docker run --rm --init --name shumai-runner \ + --cap-drop ALL --security-opt no-new-privileges \ + -e SHUMAI_API_SERVER -e SHUMAI_RUNNER_KEY \ + -v shumai-runner-workspace:/workspace -w /workspace \ + node:22-bookworm sh -c \ + 'npm install -g @shumai-one/shumai-cli && exec shumai-cli runner start' +``` + +本地开发允许 `localhost`、`127.0.0.1`、`[::1]`、Docker 的 `host.docker.internal` HTTP 地址;远程连接必须使用 HTTPS。不要将敏感宿主机目录或 Docker socket 挂载到运行器工作区。 + +## 限制与生命周期 + +默认超时 120 秒,最长一小时。超时或取消会尝试终止命令及其子进程。单条命令最多在 `.pi/logs` 保存 64 MiB 输出,请按工作区维护需求清理日志。文件传输和技能解压限制为 256 MiB。协议文件操作拒绝 `.pi` 外路径、已有符号链接及不安全的压缩包条目。V1 假定命令不会在文件传输期间故意修改工作区路径。 + +临时重连会同步执行中及近期完成的命令,避免主动重复执行。重启运行器进程不会恢复旧进程中的命令。 + +共享工作区最多同时执行八个命令或文件传输,超出时返回繁忙错误。Windows 未启用 SRT 时,后台进程可能在命令 Shell 退出后继续运行,剩余输出管道会在一秒后关闭。请使用前台命令,以确保超时和取消可预测。启用 SRT 时由 SRT 管理 Windows 沙箱进程树。 diff --git a/packages/agent/src/concurrent-sandbox.test.ts b/packages/agent/src/concurrent-runner.test.ts similarity index 90% rename from packages/agent/src/concurrent-sandbox.test.ts rename to packages/agent/src/concurrent-runner.test.ts index cda751ec..92427ec9 100644 --- a/packages/agent/src/concurrent-sandbox.test.ts +++ b/packages/agent/src/concurrent-runner.test.ts @@ -5,7 +5,7 @@ import { setupTestDbHooks } from '@shumai/db/test' import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' import { createAgentSession, type DbProviderInfo } from './index' import { closeAgentSessions } from './runtime' -import { createSandboxedBashTool } from './tools/sandboxed-bash' +import { createRunnerBashTool } from './tools/runner-bash' const mockProviders: DbProviderInfo[] = [ { @@ -92,19 +92,17 @@ describe('Concurrent Runner Sessions', () => { providers: mockProviders, }) - const tool = createSandboxedBashTool('/mock/cwd', {}, { teamId: team.id }) + const tool = createRunnerBashTool({}, { teamId: team.id }) // Note: registerConnection sends a 'welcome' message first (conn.sent[0]) const execA = invokeTool(tool, 'call-a', { command: 'echo session-a', - source: 'skill', }) await vi.waitFor(() => expect(conn.sent.length).toBe(2)) const msgA = JSON.parse(conn.sent[1]) const execB = invokeTool(tool, 'call-b', { command: 'echo session-b', - source: 'skill', }) await vi.waitFor(() => expect(conn.sent.length).toBe(3)) const msgB = JSON.parse(conn.sent[2]) @@ -160,10 +158,12 @@ describe('Concurrent Runner Sessions', () => { ) const [resA, resB] = await Promise.all([execA, execB]) - // eslint-disable-next-line @typescript-eslint/no-explicit-any -- ToolResponse content blocks - expect((resA as any).content[0].text).toContain('out-a') - // eslint-disable-next-line @typescript-eslint/no-explicit-any -- ToolResponse content blocks - expect((resB as any).content[0].text).toContain('out-b') + expect(resA.content).toContainEqual( + expect.objectContaining({ text: expect.stringContaining('out-a') }), + ) + expect(resB.content).toContainEqual( + expect.objectContaining({ text: expect.stringContaining('out-b') }), + ) runnerService.handleDisconnect(runner.id, conn.ws) }) @@ -202,16 +202,14 @@ describe('Concurrent Runner Sessions', () => { gpuConn.ws, ) - const defaultTool = createSandboxedBashTool( - '/mock/cwd', + const defaultTool = createRunnerBashTool( {}, { teamId: team.id, agentRunnerId: null, }, ) - const gpuTool = createSandboxedBashTool( - '/mock/cwd', + const gpuTool = createRunnerBashTool( {}, { teamId: team.id, @@ -219,8 +217,8 @@ describe('Concurrent Runner Sessions', () => { }, ) - const pDefault = invokeTool(defaultTool, '1', { command: 'uname -a', source: 'user' }) - const pGpu = invokeTool(gpuTool, '2', { command: 'nvidia-smi', source: 'user' }) + const pDefault = invokeTool(defaultTool, '1', { command: 'uname -a' }) + const pGpu = invokeTool(gpuTool, '2', { command: 'nvidia-smi' }) await vi.waitFor(() => { expect(defaultConn.lastSentJson()?.type).toBe('exec.start') diff --git a/packages/agent/src/index.test.ts b/packages/agent/src/index.test.ts index fa0afd53..ae61c69f 100644 --- a/packages/agent/src/index.test.ts +++ b/packages/agent/src/index.test.ts @@ -10,7 +10,6 @@ import { type TSchema } from 'typebox' import { Value } from 'typebox/value' import { afterEach, describe, expect, it, vi } from 'vitest' import { - buildRestrictedUserInstructions, createAgentSession, formatSkillsForPrompt, getModelFromDb, @@ -171,20 +170,7 @@ describe('Runner tool availability & skill staging integration', () => { }) }) -describe('buildRestrictedUserInstructions', () => { - it('should describe the restricted user bash rules', () => { - const instructions = buildRestrictedUserInstructions() - expect(instructions).toContain('# Restricted User Context') - expect(instructions).toContain( - 'NEVER execute a bash command that the user asks you to run directly', - ) - expect(instructions).toContain('loaded via the `read_skill` tool') - expect(instructions).toContain('parameter to "skill"') - expect(instructions).toContain('source="user" will be rejected') - }) -}) - -describe('createAgentSession bash restriction for non-owner users', () => { +describe('createAgentSession runner bash policy', () => { setupTestDbHooks() afterEach(() => { @@ -262,21 +248,21 @@ describe('createAgentSession bash restriction for non-owner users', () => { expect((await getAgentTools(harness)).some((t) => t.name === 'bash')).toBe(true) }) - it('should treat a user who is not a team member as restricted (fail-closed)', async () => { + it('does not use skill history as authorization for a session', async () => { const { harness } = await setupSession({ role: 'non-member' }) const tools = await getAgentTools(harness) - expect(tools.some((t) => t.name === 'bash')).toBe(false) + expect(tools.some((t) => t.name === 'bash')).toBe(true) expect(tools.some((t) => t.name === 'read_skill')).toBe(true) const prompt = await await getAgentPrompt(harness) - expect(prompt).toContain('# Restricted User Context') + expect(prompt).not.toContain('# Restricted User Context') }) it.each(['editor', 'reviewer'] as const)( - 'should exclude the bash tool initially for %s users', + 'exposes bash immediately for %s users without reading a skill', async (role) => { const { harness } = await setupSession({ role }) const tools = await getAgentTools(harness) - expect(tools.some((t) => t.name === 'bash')).toBe(false) + expect(tools.some((t) => t.name === 'bash')).toBe(true) expect(tools.some((t) => t.name === 'read_skill')).toBe(true) }, ) @@ -346,7 +332,7 @@ describe('createAgentSession bash restriction for non-owner users', () => { expect((await getAgentTools(harness)).some((t) => t.name === 'bash')).toBe(true) }) - it('should inject the bash tool after a skill is loaded via read_skill for restricted users', async () => { + it('keeps bash available before and after reading a skill', async () => { const { team, harness } = await setupSession({ role: 'reviewer' }) const skill = await prisma.skill.create({ data: { name: 'Inject Skill', assetId: 'asset1', hash: 'inject-hash', teamId: team.id }, @@ -356,14 +342,14 @@ describe('createAgentSession bash restriction for non-owner users', () => { const readSkillTool = (await getAgentTools(harness)).find((t) => t.name === 'read_skill') expect(readSkillTool).toBeDefined() - expect((await getAgentTools(harness)).some((t) => t.name === 'bash')).toBe(false) + expect((await getAgentTools(harness)).some((t) => t.name === 'bash')).toBe(true) await invokeTool(readSkillTool!, '1', { skillId: skill.id }, undefined, undefined) expect((await getAgentTools(harness)).some((t) => t.name === 'bash')).toBe(true) }) - it('should not inject the bash tool for restricted users when bash is in deniedTools', async () => { + it('keeps bash disabled by agent policy after reading a skill', async () => { const { team, harness } = await setupSession({ role: 'editor', deniedTools: ['bash'] }) const skill = await prisma.skill.create({ data: { name: 'Denied Skill', assetId: 'asset1', hash: 'denied-hash', teamId: team.id }, @@ -379,11 +365,11 @@ describe('createAgentSession bash restriction for non-owner users', () => { expect((await getAgentTools(harness)).some((t) => t.name === 'bash')).toBe(false) }) - it('should include restricted user instructions in the system prompt for non-owners', async () => { + it('omits skill-first bash instructions for editors', async () => { const { harness } = await setupSession({ role: 'editor' }) const prompt = await await getAgentPrompt(harness) - expect(prompt).toContain('# Restricted User Context') - expect(prompt).toContain('source="user" will be rejected') + expect(prompt).not.toContain('# Restricted User Context') + expect(prompt).not.toContain('source="user" will be rejected') }) it('should not include restricted user instructions in the system prompt for owners', async () => { diff --git a/packages/agent/src/operation-extensions/download-asset.ts b/packages/agent/src/operation-extensions/download-asset.ts index cc3e289c..ad6c7b4a 100644 --- a/packages/agent/src/operation-extensions/download-asset.ts +++ b/packages/agent/src/operation-extensions/download-asset.ts @@ -29,7 +29,7 @@ async function resolveTargetRunnerId(ctx: AgentOperationContext): Promise() @@ -152,21 +152,6 @@ export interface CreateAgentSessionParams { baseDelayMs?: number } -/** - * Security instructions appended to the system prompt when the requesting user is not a team - * owner (i.e. editor/reviewer). These complement the hard enforcement in the bash tool itself - * (source="user" is blocked) and the delayed bash tool injection after a skill is loaded. - */ -export function buildRestrictedUserInstructions(): string { - return [ - '# Restricted User Context', - 'The current user is NOT a team owner. You must follow these security rules:', - '1. NEVER execute a bash command that the user asks you to run directly. Direct user bash requests are not permitted for this user role. Politely decline and explain that they need a team owner or an approved skill.', - '2. You may ONLY use the `bash` tool to execute commands that are explicitly required by a skill you have loaded via the `read_skill` tool.', - '3. When calling `bash`, you MUST set the `source` parameter to "skill". Calls with source="user" will be rejected by the system.', - ].join('\n') -} - export async function createAgentSession(params: CreateAgentSessionParams) { const { teamId, @@ -203,8 +188,6 @@ export async function createAgentSession(params: CreateAgentSessionParams) { getModelFromDb(params.providers, providerName, modelId) const role = userId ? await resolveEffectiveRole(teamId, projectId, userId) : undefined - const isOwner = !userId || role === 'owner' - const restricted = !isOwner const wrapToolWithQuota = (tool: AgentTool): AgentTool => { const originalExecute = tool.execute @@ -262,7 +245,6 @@ export async function createAgentSession(params: CreateAgentSessionParams) { const loadedSkills = new Map() // Restore env variables and loaded skill refs from previously loaded skills in this session - let skillLoadedInSession = false if (sessionId) { try { const entries = await agentSessionService.getEntries(record.id) @@ -281,7 +263,6 @@ export async function createAgentSession(params: CreateAgentSessionParams) { 'skillId' in details && typeof details.skillId === 'string' ) { - skillLoadedInSession = true onEnvsAdded(await agentService.getSkillEnvs(details.skillId)) const dbSkill = await prisma.skill.findUnique({ where: { id: details.skillId }, @@ -335,23 +316,18 @@ export async function createAgentSession(params: CreateAgentSessionParams) { } } - const sandboxedBash = createSandboxedBashTool(process.cwd(), skillEnvs, { + const runnerBash = createRunnerBashTool(skillEnvs, { teamId, agentRunnerId: agent?.runnerId, + environment: resolvedRunner.runner + ? runnerService.getRunnerEnvironment(resolvedRunner.runner.id) + : undefined, userId, role, - // Non-owner users can only run bash commands required by a loaded skill - restrictedUser: restricted, getLoadedSkills: () => loadedSkills.values(), }) - // When a team has no Runner configured in DB, bash and download_asset are omitted. - // For non-owner users, the bash tool is not injected initially. It becomes available - // only after a skill is successfully loaded via the read_skill tool (or immediately when - // a skill was already loaded earlier in this session). const registry = createRegistry() - const bashIncludedFromStart = hasRunner && (isOwner || skillLoadedInSession) - let bashInjected = bashIncludedFromStart const onSkillLoaded = async (skill: LoadedSkillRef) => { loadedSkills.set(skill.id, skill) if (resolvedRunner.runner && runnerService.isRunnerConnected(resolvedRunner.runner.id)) { @@ -362,18 +338,6 @@ export async function createAgentSession(params: CreateAgentSessionParams) { ) }) } - if (!restricted || !hasRunner || bashInjected || deniedTools.includes('bash')) return - bashInjected = true - registry.install( - defineExtension({ name: 'shumai.bash', tools: [wrapToolWithQuota(sandboxedBash)] }), - ) - await session?.configure( - { - tools: [...enabledTools, wrapToolWithQuota(sandboxedBash)], - modelTools: { add: [sandboxedBash] }, - }, - piContext, - ) } const readSkill = createReadSkillTool( userId, @@ -404,7 +368,7 @@ export async function createAgentSession(params: CreateAgentSessionParams) { ...mediaTools, readSkill, readThread, - ...(bashIncludedFromStart ? [sandboxedBash] : []), + ...(hasRunner ? [runnerBash] : []), ...systemTools, ...customTools, ] @@ -472,10 +436,6 @@ export async function createAgentSession(params: CreateAgentSessionParams) { return prompt } - if (restricted) { - prompt += `\n\n${buildRestrictedUserInstructions()}` - } - if (hasRunner && !deniedTools.includes('bash')) { prompt += '\n\n' + diff --git a/packages/agent/src/tools/read-skill.ts b/packages/agent/src/tools/read-skill.ts index 2902f192..4bd9da18 100644 --- a/packages/agent/src/tools/read-skill.ts +++ b/packages/agent/src/tools/read-skill.ts @@ -67,7 +67,7 @@ export const createReadSkillTool = ( // Retrieve skill content using agentService const skillMdContent = await agentService.getSkillContent(params.skillId) - // Notify that a skill was successfully loaded (e.g. to enable restricted tools and stage skill on runner) + // Notify that a skill was successfully loaded (e.g. to stage the skill on the runner) await onSkillLoaded?.({ id: skill.id, assetId: skill.assetId, hash: skill.hash }) return { diff --git a/packages/agent/src/tools/sandboxed-bash.test.ts b/packages/agent/src/tools/runner-bash.test.ts similarity index 67% rename from packages/agent/src/tools/sandboxed-bash.test.ts rename to packages/agent/src/tools/runner-bash.test.ts index c13a4082..d6dcc9d7 100644 --- a/packages/agent/src/tools/sandboxed-bash.test.ts +++ b/packages/agent/src/tools/runner-bash.test.ts @@ -1,8 +1,7 @@ import { invokeTool } from '@shumai/core/src/agent/tool-test-utils' import { runnerService } from '@shumai/core/src/runner' -import { EventEmitter } from 'node:events' import { beforeEach, describe, expect, it, vi } from 'vitest' -import { createSandboxedBashTool } from './sandboxed-bash' +import { createRunnerBashTool } from './runner-bash' vi.mock('@shumai/core/src/runner', () => ({ runnerService: { @@ -14,8 +13,7 @@ vi.mock('@shumai/core/src/runner', () => ({ }, })) -describe('createSandboxedBashTool', () => { - const mockCwd = '/mock/cwd' +describe('createRunnerBashTool', () => { const mockTeamId = 'team-1' const mockRunner = { id: 'runner-1', @@ -38,24 +36,22 @@ describe('createSandboxedBashTool', () => { ) }) - const createMockSignal = () => { - // eslint-disable-next-line @typescript-eslint/no-explicit-any -- signal needs to be partially compatible with AbortSignal - const signal = new EventEmitter() as any - signal.addEventListener = vi.fn((event: string, cb: (ev: Event) => unknown) => { - signal.on(event, cb) - }) - signal.removeEventListener = vi.fn((event: string, cb: (ev: Event) => unknown) => { - signal.off(event, cb) - }) - signal.aborted = false - return signal - } + const createMockSignal = () => new AbortController().signal const createMockOnUpdate = () => vi.fn() + it('tells the agent to use the runner OS and shell syntax', () => { + const tool = createRunnerBashTool( + {}, + { environment: { platform: 'win32', shell: 'C:\\Windows\\System32\\cmd.exe' } }, + ) + expect(tool.description).toContain('Runner OS: win32') + expect(tool.description).toContain('cmd.exe') + expect(tool.description).toContain('Use syntax and programs compatible with this environment') + }) + it('should execute a command on the runner with injected env vars', async () => { - const tool = createSandboxedBashTool( - mockCwd, + const tool = createRunnerBashTool( { TEST_ENV: 'test-value' }, { teamId: mockTeamId, @@ -78,13 +74,7 @@ describe('createSandboxedBashTool', () => { const onUpdate = createMockOnUpdate() const signal = createMockSignal() - const result = await invokeTool( - tool, - '1', - { command: 'echo hello', source: 'user' }, - signal, - onUpdate, - ) + const result = await invokeTool(tool, '1', { command: 'echo hello' }, signal, onUpdate) expect(runnerService.requireOnlineRunner).toHaveBeenCalledWith(mockTeamId, null) expect(runnerService.exec).toHaveBeenCalledWith( @@ -95,15 +85,15 @@ describe('createSandboxedBashTool', () => { collectOutput: false, }), ) - // eslint-disable-next-line @typescript-eslint/no-explicit-any -- ToolResponse content is an array of content blocks - expect((result as any).content[0].text).toContain('hello output') + expect(result.content).toContainEqual( + expect.objectContaining({ text: expect.stringContaining('hello output') }), + ) expect(onUpdate).toHaveBeenCalled() }) it('should stage loaded skills and inputFiles before executing', async () => { const loadedSkills = [{ id: 'skill-1', assetId: 'asset-1', hash: 'hash-1' }] - const tool = createSandboxedBashTool( - mockCwd, + const tool = createRunnerBashTool( {}, { teamId: mockTeamId, @@ -126,7 +116,6 @@ describe('createSandboxedBashTool', () => { '1', { command: 'ffmpeg -i .pi/generated/gen1/input.png out.mp4', - source: 'user', inputFiles: ['.pi/generated/gen1/input.png'], }, createMockSignal(), @@ -140,31 +129,12 @@ describe('createSandboxedBashTool', () => { ) }) - it('should block user-requested commands when restrictedUser is enabled', async () => { - const tool = createSandboxedBashTool( - mockCwd, + it('allows editor commands without a source classification', async () => { + const tool = createRunnerBashTool( {}, { teamId: mockTeamId, - restrictedUser: true, - }, - ) - - const signal = createMockSignal() - await expect( - invokeTool(tool, '1', { command: 'echo hack', source: 'user' }, signal, createMockOnUpdate()), - ).rejects.toThrow(/not permitted for your role/) - - expect(runnerService.exec).not.toHaveBeenCalled() - }) - - it('should allow skill-requested commands when restrictedUser is enabled', async () => { - const tool = createSandboxedBashTool( - mockCwd, - {}, - { - teamId: mockTeamId, - restrictedUser: true, + role: 'editor', }, ) @@ -181,24 +151,25 @@ describe('createSandboxedBashTool', () => { }) const signal = createMockSignal() - const result = await invokeTool(tool, '1', { command: 'echo skill', source: 'skill' }, signal) - // eslint-disable-next-line @typescript-eslint/no-explicit-any -- ToolResponse content is an array of content blocks - expect((result as any).content[0].text).toContain('skill output') + const result = await invokeTool(tool, '1', { command: 'echo skill' }, signal) + expect(result.content).toContainEqual( + expect.objectContaining({ text: expect.stringContaining('skill output') }), + ) }) it('should handle runner execution errors', async () => { - const tool = createSandboxedBashTool(mockCwd, {}, { teamId: mockTeamId }) + const tool = createRunnerBashTool({}, { teamId: mockTeamId }) vi.mocked(runnerService.exec).mockRejectedValue(new Error('Runner disconnected')) const signal = createMockSignal() await expect( - invokeTool(tool, '1', { command: 'fail', source: 'user' }, signal, createMockOnUpdate()), + invokeTool(tool, '1', { command: 'fail' }, signal, createMockOnUpdate()), ).rejects.toThrow('Runner disconnected') }) it('should handle non-zero exit codes', async () => { - const tool = createSandboxedBashTool(mockCwd, {}, { teamId: mockTeamId }) + const tool = createRunnerBashTool({}, { teamId: mockTeamId }) vi.mocked(runnerService.exec).mockResolvedValue({ executionId: 'exec-1', @@ -211,12 +182,12 @@ describe('createSandboxedBashTool', () => { const signal = createMockSignal() await expect( - invokeTool(tool, '1', { command: 'exit 1', source: 'user' }, signal, createMockOnUpdate()), + invokeTool(tool, '1', { command: 'exit 1' }, signal, createMockOnUpdate()), ).rejects.toThrow(/exited with code 1/) }) it('should handle timeouts', async () => { - const tool = createSandboxedBashTool(mockCwd, {}, { teamId: mockTeamId }) + const tool = createRunnerBashTool({}, { teamId: mockTeamId }) vi.mocked(runnerService.exec).mockImplementation(async (_runnerId, opts) => { opts.onOutput?.('output before timeout\n', 'stdout') @@ -234,7 +205,7 @@ describe('createSandboxedBashTool', () => { const executePromise = invokeTool( tool, '1', - { command: 'sleep 10', timeout: 2, source: 'user' }, + { command: 'sleep 10', timeout: 2 }, signal, createMockOnUpdate(), ) @@ -244,7 +215,7 @@ describe('createSandboxedBashTool', () => { }) it('should handle abort signals', async () => { - const tool = createSandboxedBashTool(mockCwd, {}, { teamId: mockTeamId }) + const tool = createRunnerBashTool({}, { teamId: mockTeamId }) vi.mocked(runnerService.exec).mockResolvedValue({ executionId: 'exec-1', @@ -257,12 +228,12 @@ describe('createSandboxedBashTool', () => { const signal = createMockSignal() await expect( - invokeTool(tool, '1', { command: 'long-run', source: 'user' }, signal, createMockOnUpdate()), + invokeTool(tool, '1', { command: 'long-run' }, signal, createMockOnUpdate()), ).rejects.toThrow(/aborted/) }) it('should truncate output exceeding max lines (2000 lines) and report runner log file path', async () => { - const tool = createSandboxedBashTool(mockCwd, {}, { teamId: mockTeamId }) + const tool = createRunnerBashTool({}, { teamId: mockTeamId }) vi.mocked(runnerService.exec).mockImplementation(async (_runnerId, opts) => { const lines: string[] = [] @@ -283,14 +254,8 @@ describe('createSandboxedBashTool', () => { }) const signal = createMockSignal() - const result = await invokeTool( - tool, - '1', - { command: 'generate lines', source: 'user' }, - signal, - ) - // eslint-disable-next-line @typescript-eslint/no-explicit-any -- content block array - const text = (result as any).content[0].text + const result = await invokeTool(tool, '1', { command: 'generate lines' }, signal) + const text = result.content.map((block) => (block.type === 'text' ? block.text : '')).join('') expect(text).toContain('line-3000') expect(text).toContain( '[Showing lines 1001-3000 of 3000. Full output: .pi/logs/bash-exec1.log]', @@ -305,7 +270,7 @@ describe('createSandboxedBashTool', () => { }) it('should truncate output exceeding max bytes (50KB) and report partial line size', async () => { - const tool = createSandboxedBashTool(mockCwd, {}, { teamId: mockTeamId }) + const tool = createRunnerBashTool({}, { teamId: mockTeamId }) vi.mocked(runnerService.exec).mockImplementation(async (_runnerId, opts) => { const longLine = 'a'.repeat(60000) @@ -322,14 +287,8 @@ describe('createSandboxedBashTool', () => { }) const signal = createMockSignal() - const result = await invokeTool( - tool, - '1', - { command: 'long single line', source: 'user' }, - signal, - ) - // eslint-disable-next-line @typescript-eslint/no-explicit-any -- content block array - const text = (result as any).content[0].text + const result = await invokeTool(tool, '1', { command: 'long single line' }, signal) + const text = result.content.map((block) => (block.type === 'text' ? block.text : '')).join('') expect(text).toMatch( /Showing last 50\.0KB of line 1 \(line is 58\.6KB\)\. Full output: \.pi\/logs\/bash-exec2\.log/, ) diff --git a/packages/agent/src/tools/sandboxed-bash.ts b/packages/agent/src/tools/runner-bash.ts similarity index 74% rename from packages/agent/src/tools/sandboxed-bash.ts rename to packages/agent/src/tools/runner-bash.ts index 71824250..dc216f33 100644 --- a/packages/agent/src/tools/sandboxed-bash.ts +++ b/packages/agent/src/tools/runner-bash.ts @@ -6,6 +6,7 @@ import { logger } from '@shumai/core/src/logger' import { quotaService } from '@shumai/core/src/quota/quota-service' import { runnerService } from '@shumai/core/src/runner' import type { TeamMemberRole } from '@shumai/db' +import type { RunnerEnvironment } from '@shumai/dtos' import { Type } from 'typebox' import { OutputAccumulator } from '../utils/output-accumulator' import { @@ -15,19 +16,9 @@ import { type TruncationResult, } from '../utils/truncate' -const BashSource = Type.String({ - enum: ['user', 'skill'], - description: - 'Indicates who requested this bash command. Set to "user" when the end user directly ' + - 'requested the command. Set to "skill" when the command is required by a skill you loaded ' + - 'via the read_skill tool. Users without the owner role can only execute commands with ' + - 'source="skill"; source="user" will be blocked.', -}) - const BashParameters = Type.Object({ - command: Type.String({ description: 'The bash command to execute.' }), + command: Type.String({ description: "The command to execute using the runner's shell." }), timeout: Type.Optional(Type.Number({ description: 'Maximum execution time in seconds.' })), - source: BashSource, inputFiles: Type.Optional( Type.Union([ Type.Array(Type.String(), { @@ -51,42 +42,31 @@ export interface LoadedSkillRef { hash: string } -export interface SandboxedBashOptions { +export interface RunnerBashOptions { teamId?: string agentRunnerId?: string | null runnerId?: string userId?: string role?: TeamMemberRole | null - /** - * When true, the tool only allows commands requested by a loaded skill (source="skill"). - * Commands requested directly by the end user (source="user") are blocked. - */ - restrictedUser?: boolean + environment?: RunnerEnvironment getLoadedSkills?: () => Iterable } -export const createSandboxedBashTool = ( - _cwd: string, +export const createRunnerBashTool = ( skillEnvs: Record = {}, - options?: SandboxedBashOptions, + options?: RunnerBashOptions, ): AgentTool => { return { name: 'bash', - description: `Execute a bash command on the configured runner environment. Returns stdout and stderr. Output is truncated to last ${DEFAULT_MAX_LINES} lines or ${DEFAULT_MAX_BYTES / 1024}KB (whichever is hit first). If truncated, full output is saved to a log file in .pi/logs/ on the runner. Optionally provide a timeout in seconds, or inputFiles to stage generated files (.pi/generated/...) into the runner workspace before running. When in a restricted (non-owner) user context, only commands required by a skill loaded via the read_skill tool are allowed, and you must set source="skill".`, + description: `Execute a shell command on the configured runner. ${options?.environment ? `Runner OS: ${options.environment.platform}. Shell: ${options.environment.shell}. Use syntax and programs compatible with this environment.` : 'The runner reports its OS and shell when connected.'} Returns stdout and stderr. Output is truncated to last ${DEFAULT_MAX_LINES} lines or ${DEFAULT_MAX_BYTES / 1024}KB (whichever is hit first). If truncated, full output is saved to a log file in .pi/logs/ on the runner. Optionally provide a timeout in seconds, or inputFiles to stage generated files (.pi/generated/...) into the runner workspace before running.`, parameters: BashParameters, outputLimits: { maxBytes: DEFAULT_MAX_BYTES, maxLines: DEFAULT_MAX_LINES, retain: 'tail' }, execute: async ( - { command, timeout, source, inputFiles }, + { command, timeout, inputFiles }, api, context, ): Promise> => { const signal = context.abortSignal - if (options?.restrictedUser && source !== 'skill') { - throw new Error( - 'Bash commands requested directly by the user (source="user") are not permitted for your role. ' + - 'Only commands required by a loaded skill (source="skill") can be executed.', - ) - } if (options?.teamId) { await quotaService.checkQuota( { @@ -104,7 +84,7 @@ export const createSandboxedBashTool = ( if (options?.runnerId) { if (!runnerService.isRunnerConnected(options.runnerId)) { throw new Error( - 'Runner is currently offline. Please start your runner with "shumai runner start" and try again.', + 'Runner is currently offline. Please start your runner with "shumai-cli runner start" and try again.', ) } targetRunnerId = options.runnerId @@ -211,21 +191,19 @@ export const createSandboxedBashTool = ( } if (signal?.aborted || execResult.aborted) { - logger.error({ command, outputText }, 'Sandboxed bash command aborted') + logger.error({ command, outputText }, 'Bash command aborted') throw new Error(appendStatus(outputText, 'Command aborted')) } if (execResult.timedOut) { - logger.error({ timeout, command, outputText }, 'Sandboxed bash command timed out') - throw new Error( - appendStatus(outputText, `Sandboxed bash command timed out after ${timeout} seconds`), - ) + logger.error({ timeout, command, outputText }, 'Bash command timed out') + throw new Error(appendStatus(outputText, `Bash command timed out after ${timeout} seconds`)) } if (execResult.error) { logger.error( { error: execResult.error, command, outputText }, - 'Sandboxed bash command encountered runner error', + 'Bash command encountered runner error', ) throw new Error(appendStatus(outputText, execResult.error)) } @@ -233,13 +211,10 @@ export const createSandboxedBashTool = ( if (execResult.exitCode !== 0 && execResult.exitCode !== null) { logger.error( { exitCode: execResult.exitCode, command, outputText }, - 'Sandboxed bash command exited with failure code', + 'Bash command exited with failure code', ) throw new Error( - appendStatus( - outputText, - `Sandboxed bash command exited with code ${execResult.exitCode}`, - ), + appendStatus(outputText, `Bash command exited with code ${execResult.exitCode}`), ) } diff --git a/packages/core/src/runner/runner-service.test.ts b/packages/core/src/runner/runner-service.test.ts index d63743d6..f6b007c2 100644 --- a/packages/core/src/runner/runner-service.test.ts +++ b/packages/core/src/runner/runner-service.test.ts @@ -55,6 +55,41 @@ describe('RunnerService', () => { }) describe('Key & workspace path helpers', () => { + it('keeps validated OS and shell metadata only for the current connection', async () => { + const { runner, key } = await service.createRunner(teamId, { name: 'Windows runner' }) + const connection = createMockWs() + const authenticated = { + id: runner.id, + teamId, + name: runner.name, + keyHash: hashRunnerKey(key), + } + expect(service.getRunnerEnvironment(runner.id)).toBeUndefined() + await service.registerConnection(authenticated, connection.ws) + const environment = { platform: 'win32', shell: 'C:\\Windows\\System32\\cmd.exe' } + const reconcile = { + type: 'reconcile', + environment, + activeExecutions: [], + completedExecutions: [], + } + service.handleMessage(runner.id, connection.ws, JSON.stringify(reconcile)) + expect(service.getRunnerEnvironment(runner.id)).toEqual(environment) + service.handleMessage( + runner.id, + connection.ws, + JSON.stringify({ ...reconcile, environment: { platform: 'invalid', shell: '' } }), + ) + expect(service.getRunnerEnvironment(runner.id)).toEqual(environment) + const replacement = createMockWs() + await service.registerConnection(authenticated, replacement.ws) + service.handleMessage(runner.id, connection.ws, JSON.stringify(reconcile)) + expect(service.getRunnerEnvironment(runner.id)).toBeUndefined() + service.handleMessage(runner.id, replacement.ws, JSON.stringify(reconcile)) + service.handleDisconnect(runner.id, replacement.ws) + expect(service.getRunnerEnvironment(runner.id)).toBeUndefined() + }) + it('generates and hashes runner keys', () => { const { key, keyPrefix, keyHash } = generateRunnerKey() expect(key).toMatch(/^shm_rn_[0-9a-f]{48}$/) @@ -599,6 +634,7 @@ describe('RunnerService', () => { conn2.ws, JSON.stringify({ type: 'reconcile', + environment: { platform: 'linux', shell: '/bin/sh' }, activeExecutions: [{ executionId: startMsg.executionId, nextOffset: 0 }], completedExecutions: [], }), diff --git a/packages/core/src/runner/runner-service.ts b/packages/core/src/runner/runner-service.ts index 829f405a..c4de6ddd 100644 --- a/packages/core/src/runner/runner-service.ts +++ b/packages/core/src/runner/runner-service.ts @@ -11,6 +11,7 @@ import { RunnerFileStatResultMessage, RunnerFileUploadResultMessage, RunnerInfo, + RunnerEnvironment, RunnerToServerMessage, runnerToServerMessageSchema, ServerToRunnerMessage, @@ -42,6 +43,7 @@ interface ActiveRunnerSession { lastPongAt: number stagedSkills: Map stagedGeneratedFiles: Set + environment?: RunnerEnvironment } interface PendingExecOperation { @@ -174,6 +176,10 @@ export class RunnerService { return this.sessions.has(runnerId) } + getRunnerEnvironment(runnerId: string): RunnerEnvironment | undefined { + return this.sessions.get(runnerId)?.environment + } + // ---------------------------------------------------------------------- // Runner CRUD & Default Runner Invariant // ---------------------------------------------------------------------- @@ -428,11 +434,11 @@ export class RunnerService { if (!this.isRunnerConnected(resolved.runner.id)) { if (resolved.isBoundToAgent) { throw new Error( - `Runner "${resolved.runner.name}" is currently offline. Please start the runner ("shumai runner start") and try again.`, + `Runner "${resolved.runner.name}" is currently offline. Please start the runner ("shumai-cli runner start") and try again.`, ) } throw new Error( - `Default runner "${resolved.runner.name}" is currently offline. Please start the runner ("shumai runner start") and try again.`, + `Default runner "${resolved.runner.name}" is currently offline. Please start the runner ("shumai-cli runner start") and try again.`, ) } @@ -559,6 +565,7 @@ export class RunnerService { case 'pong': break case 'reconcile': + session.environment = msg.environment this.handleReconcileMessage(session, msg) break case 'exec.output': diff --git a/packages/dtos/src/runner.ts b/packages/dtos/src/runner.ts index c87d542d..c8c1b44c 100644 --- a/packages/dtos/src/runner.ts +++ b/packages/dtos/src/runner.ts @@ -136,8 +136,15 @@ export const runnerExecResultMessageSchema = z.object({ }) export type RunnerExecResultMessage = z.infer +export const runnerEnvironmentSchema = z.object({ + platform: z.enum(['darwin', 'linux', 'win32']), + shell: z.string().min(1).max(1024), +}) +export type RunnerEnvironment = z.infer + export const runnerReconcileMessageSchema = z.object({ type: z.literal('reconcile'), + environment: runnerEnvironmentSchema, activeExecutions: z.array( z.object({ executionId: z.string(), diff --git a/packages/webui/components/settings/RunnerSettings.tsx b/packages/webui/components/settings/RunnerSettings.tsx index 204b119a..5b74a933 100644 --- a/packages/webui/components/settings/RunnerSettings.tsx +++ b/packages/webui/components/settings/RunnerSettings.tsx @@ -513,7 +513,7 @@ export function RunnerSettings({ teamId }: { teamId: string }) {