feat(runner): replace server-side bash sandbox with remote runner (#530)

* feat(runner): replace server-side bash sandbox with remote runner

* fix(runner): address review findings for output bounds, key rotation, defaults, and generated uploads

* chore(docker): remove sandbox privileges and env vars from remaining compose files

* 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

* chore(cli): upgrade @anthropic-ai/sandbox-runtime to 0.0.83

* feat(cli): discover Bash for Windows runners

Use Pi-style Bash discovery and launch behavior, exercise the packaged CLI shell, and wait for pending ZIP metadata reads before closing cancelled downloads.

* fix(runner): enforce ownership and safe reconnects

Gate dispatch on reconciliation, retain cancellations across disconnects, and stop replaced clients. Guard the single-server runner topology with a database lease. Restage missing generated inputs, report signal exits, and bound generated-file cleanup.

* feat(webui): add Korean translations for agent runners

* feat(cli): add runner event logging and --verbose flag (#536)

* feat(cli): add runner event logging and --verbose flag

* fix(cli): log runner capacity rejections accurately and use monotonic duration
This commit is contained in:
Yiling-J
2026-11-18 15:58:57 +08:00
committed by GitHub
parent eea844320d
commit 4ac274cdd4
121 changed files with 11600 additions and 5503 deletions
+2
View File
@@ -36,6 +36,7 @@ export const agentInfoSchema = z.object({
avatarPreset: z.string().optional(),
providerId: z.string().optional(),
modelId: z.string().optional(),
runnerId: z.string().nullable().optional(),
thinkingLevel: thinkingLevelSchema.optional().default('off'),
systemPrompt: z.string().optional(),
soul: z.string().optional(),
@@ -54,6 +55,7 @@ const baseAgentRequest = z.object({
avatar: z.string().optional(),
providerId: z.string().optional(),
modelId: z.string().optional(),
runnerId: z.string().nullable().optional(),
thinkingLevel: thinkingLevelSchema.optional().default('off'),
systemPrompt: z.string().optional(),
soul: z.string().optional(),
+1
View File
@@ -20,6 +20,7 @@ export * from './project'
export * from './provider'
export * from './quota'
export * from './recents'
export * from './runner'
export * from './s3'
export * from './search'
export * from './share'
+210
View File
@@ -0,0 +1,210 @@
import { z } from 'zod'
export const runnerStatusSchema = z.enum(['connected', 'disconnected'])
export type RunnerStatus = z.infer<typeof runnerStatusSchema>
export const runnerInfoSchema = z.object({
id: z.string(),
teamId: z.string(),
name: z.string(),
description: z.string().nullable().optional(),
keyPrefix: z.string(),
isDefault: z.boolean(),
status: runnerStatusSchema,
lastConnectedAt: z.union([z.string(), z.date()]).nullable().optional(),
lastDisconnectedAt: z.union([z.string(), z.date()]).nullable().optional(),
createdAt: z.union([z.string(), z.date()]),
updatedAt: z.union([z.string(), z.date()]),
})
export type RunnerInfo = z.infer<typeof runnerInfoSchema>
export const createRunnerRequestSchema = z.object({
name: z.string().trim().min(1).max(64),
description: z.string().trim().max(256).optional(),
isDefault: z.boolean().optional(),
})
export type CreateRunnerRequest = z.infer<typeof createRunnerRequestSchema>
export const createRunnerResponseSchema = z.object({
runner: runnerInfoSchema,
key: z.string(),
})
export type CreateRunnerResponse = z.infer<typeof createRunnerResponseSchema>
export const updateRunnerRequestSchema = z.object({
name: z.string().trim().min(1).max(64).optional(),
description: z.string().trim().max(256).nullable().optional(),
isDefault: z.boolean().optional(),
})
export type UpdateRunnerRequest = z.infer<typeof updateRunnerRequestSchema>
export const rotateRunnerKeyResponseSchema = z.object({
runner: runnerInfoSchema,
key: z.string(),
})
export type RotateRunnerKeyResponse = z.infer<typeof rotateRunnerKeyResponseSchema>
// ----------------------------------------------------------------------
// WebSocket Wire Protocol Schemas
// ----------------------------------------------------------------------
export const RUNNER_REPLACED_CLOSE_CODE = 4000
export const runnerWelcomeMessageSchema = z.object({
type: z.literal('welcome'),
runnerId: z.string(),
runnerName: z.string(),
serverTime: z.number(),
inFlightExecutionIds: z.array(z.string()),
})
export type RunnerWelcomeMessage = z.infer<typeof runnerWelcomeMessageSchema>
export const runnerExecStartMessageSchema = z.object({
type: z.literal('exec.start'),
executionId: z.string(),
command: z.string(),
timeoutSec: z.number().optional(),
env: z.record(z.string(), z.string()).optional(),
})
export type RunnerExecStartMessage = z.infer<typeof runnerExecStartMessageSchema>
export const runnerExecCancelMessageSchema = z.object({
type: z.literal('exec.cancel'),
executionId: z.string(),
})
export type RunnerExecCancelMessage = z.infer<typeof runnerExecCancelMessageSchema>
export const runnerFileDownloadMessageSchema = z.object({
type: z.literal('file.download'),
executionId: z.string(),
url: z.string(),
destPath: z.string(),
extractZip: z.boolean().optional(),
expectedHash: z.string().optional(),
})
export type RunnerFileDownloadMessage = z.infer<typeof runnerFileDownloadMessageSchema>
export const runnerFileUploadMessageSchema = z.object({
type: z.literal('file.upload'),
executionId: z.string(),
srcPath: z.string(),
url: z.string(),
contentType: z.string().optional(),
})
export type RunnerFileUploadMessage = z.infer<typeof runnerFileUploadMessageSchema>
export const runnerFileStatMessageSchema = z.object({
type: z.literal('file.stat'),
executionId: z.string(),
srcPath: z.string(),
})
export type RunnerFileStatMessage = z.infer<typeof runnerFileStatMessageSchema>
export const runnerPingMessageSchema = z.object({
type: z.literal('ping'),
ts: z.number(),
})
export type RunnerPingMessage = z.infer<typeof runnerPingMessageSchema>
export const serverToRunnerMessageSchema = z.discriminatedUnion('type', [
runnerWelcomeMessageSchema,
runnerExecStartMessageSchema,
runnerExecCancelMessageSchema,
runnerFileDownloadMessageSchema,
runnerFileUploadMessageSchema,
runnerFileStatMessageSchema,
runnerPingMessageSchema,
])
export type ServerToRunnerMessage = z.infer<typeof serverToRunnerMessageSchema>
export const runnerExecOutputMessageSchema = z.object({
type: z.literal('exec.output'),
executionId: z.string(),
stream: z.enum(['stdout', 'stderr']),
data: z.string(),
offset: z.number().int().nonnegative(),
})
export type RunnerExecOutputMessage = z.infer<typeof runnerExecOutputMessageSchema>
export const runnerExecResultMessageSchema = z.object({
type: z.literal('exec.result'),
executionId: z.string(),
exitCode: z.number().int().nullable(),
signal: z.string().nullable(),
timedOut: z.boolean(),
aborted: z.boolean().optional(),
fullOutputPath: z.string().optional(),
error: z.string().optional(),
})
export type RunnerExecResultMessage = z.infer<typeof runnerExecResultMessageSchema>
export const runnerEnvironmentSchema = z.object({
platform: z.enum(['darwin', 'linux', 'win32']),
shell: z.string().min(1).max(1024),
})
export type RunnerEnvironment = z.infer<typeof runnerEnvironmentSchema>
export const runnerReconcileMessageSchema = z.object({
type: z.literal('reconcile'),
environment: runnerEnvironmentSchema,
activeExecutions: z.array(
z.object({
executionId: z.string(),
nextOffset: z.number().int().nonnegative(),
}),
),
completedExecutions: z.array(runnerExecResultMessageSchema),
})
export type RunnerReconcileMessage = z.infer<typeof runnerReconcileMessageSchema>
export const runnerFileDownloadResultMessageSchema = z.object({
type: z.literal('file.download.result'),
executionId: z.string(),
ok: z.boolean(),
size: z.number().optional(),
mimeType: z.string().optional(),
cached: z.boolean().optional(),
error: z.string().optional(),
})
export type RunnerFileDownloadResultMessage = z.infer<typeof runnerFileDownloadResultMessageSchema>
export const runnerFileUploadResultMessageSchema = z.object({
type: z.literal('file.upload.result'),
executionId: z.string(),
ok: z.boolean(),
size: z.number().optional(),
mimeType: z.string().optional(),
name: z.string().optional(),
error: z.string().optional(),
})
export type RunnerFileUploadResultMessage = z.infer<typeof runnerFileUploadResultMessageSchema>
export const runnerFileStatResultMessageSchema = z.object({
type: z.literal('file.stat.result'),
executionId: z.string(),
ok: z.boolean(),
exists: z.boolean(),
isFile: z.boolean().optional(),
size: z.number().optional(),
mimeType: z.string().optional(),
name: z.string().optional(),
error: z.string().optional(),
})
export type RunnerFileStatResultMessage = z.infer<typeof runnerFileStatResultMessageSchema>
export const runnerPongMessageSchema = z.object({
type: z.literal('pong'),
ts: z.number(),
})
export type RunnerPongMessage = z.infer<typeof runnerPongMessageSchema>
export const runnerToServerMessageSchema = z.discriminatedUnion('type', [
runnerReconcileMessageSchema,
runnerExecOutputMessageSchema,
runnerExecResultMessageSchema,
runnerFileDownloadResultMessageSchema,
runnerFileUploadResultMessageSchema,
runnerFileStatResultMessageSchema,
runnerPongMessageSchema,
])
export type RunnerToServerMessage = z.infer<typeof runnerToServerMessageSchema>
-14
View File
@@ -235,20 +235,6 @@ export interface TeamSettingsResponse {
[key: string]: unknown
}
export const sandboxSettingsSchema = z.object({
networkSandboxEnabled: z.boolean(),
allowedDomains: z.array(z.string()),
pendingDomains: z.array(z.string()).default([]),
})
export type SandboxSettings = z.infer<typeof sandboxSettingsSchema>
export const updateSandboxSettingsRequestSchema = z.object({
networkSandboxEnabled: z.boolean().optional(),
allowedDomains: z.array(z.string()).optional(),
pendingDomains: z.array(z.string()).optional(),
})
export type UpdateSandboxSettingsRequest = z.infer<typeof updateSandboxSettingsRequestSchema>
export const updateTeamMemberRoleRequestSchema = z.object({
role: z.enum(['editor', 'reviewer']),
})