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
@@ -0,0 +1,27 @@
import { describe, expect, it } from 'vitest'
import { OutputAccumulator } from './output-accumulator'
describe('OutputAccumulator', () => {
it('does not accumulate rawChunks in memory when disableTempFile is true', () => {
const acc = new OutputAccumulator({
maxBytes: 1024,
maxLines: 50,
disableTempFile: true,
})
const chunk = Buffer.from(`${'x'.repeat(2047)}\n`, 'utf-8')
for (let i = 0; i < 256; i++) {
acc.append(chunk)
}
acc.finish()
const internal = acc as unknown as { rawChunks: Buffer[]; tailBytes: number }
expect(internal.rawChunks).toEqual([])
expect(internal.tailBytes).toBeLessThanOrEqual(1024 * 4)
const snapshot = acc.snapshot({ persistIfTruncated: false })
expect(snapshot.truncation.truncated).toBe(true)
expect(snapshot.fullOutputPath).toBeUndefined()
expect(Buffer.byteLength(snapshot.content, 'utf-8')).toBeLessThanOrEqual(1024)
})
})
@@ -13,6 +13,7 @@ export interface OutputAccumulatorOptions {
maxLines?: number
maxBytes?: number
tempFilePrefix?: string
disableTempFile?: boolean
}
export interface OutputSnapshot {
@@ -35,6 +36,7 @@ export class OutputAccumulator {
private readonly maxBytes: number
private readonly maxRollingBytes: number
private readonly tempFilePrefix: string
private readonly disableTempFile: boolean
private readonly decoder = new TextDecoder()
private rawChunks: Buffer[] = []
@@ -57,6 +59,7 @@ export class OutputAccumulator {
this.maxBytes = options.maxBytes ?? DEFAULT_MAX_BYTES
this.maxRollingBytes = Math.max(this.maxBytes * 2, 1)
this.tempFilePrefix = options.tempFilePrefix ?? 'shumai-bash'
this.disableTempFile = options.disableTempFile ?? false
}
append(data: Buffer): void {
@@ -70,7 +73,7 @@ export class OutputAccumulator {
if (this.tempFileStream || this.shouldUseTempFile()) {
this.ensureTempFile()
this.tempFileStream?.write(data)
} else if (data.length > 0) {
} else if (!this.disableTempFile && data.length > 0) {
this.rawChunks.push(data)
}
}
@@ -202,6 +205,9 @@ export class OutputAccumulator {
}
private shouldUseTempFile(): boolean {
if (this.disableTempFile) {
return false
}
return (
this.totalRawBytes > this.maxBytes ||
this.totalDecodedBytes > this.maxBytes ||
@@ -210,7 +216,7 @@ export class OutputAccumulator {
}
private ensureTempFile(): void {
if (this.tempFilePath) {
if (this.disableTempFile || this.tempFilePath) {
return
}
this.tempFilePath = defaultTempFilePath(this.tempFilePrefix)