mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 21:04:23 +01:00
refactor(sandbox): pin shell shim to sandbox agent bash without rewriting commands
This commit is contained in:
1 parent
681181ef4c
commit
098816f7cc
14 files changed
+1041
-1357
No files matched your search
@@ -283,7 +283,7 @@ describe('MessagePart', () => {
|
||||
})
|
||||
|
||||
describe('sandbox indicator', () => {
|
||||
const createBashPart = (command: string): MessagePartType => ({
|
||||
const createBashPart = (command: string, metadata?: Record<string, unknown>): MessagePartType => ({
|
||||
type: 'tool',
|
||||
tool: 'bash',
|
||||
sessionID: 'test-session',
|
||||
@@ -291,13 +291,21 @@ describe('MessagePart', () => {
|
||||
status: 'completed',
|
||||
input: { command },
|
||||
output: 'ok',
|
||||
...(metadata === undefined ? {} : { metadata }),
|
||||
time: { start: Date.now(), end: Date.now() + 100 },
|
||||
},
|
||||
})
|
||||
|
||||
const wrapped = "'/usr/local/bin/msb' exec ocm-workspace --no-tty -q -u '1001:1001' -w '/workspace/repos/ai-test' --timeout 600s -- sh -c 'git status'"
|
||||
|
||||
it('shows the sandbox badge and the unwrapped command for a sandboxed bash call', () => {
|
||||
it('shows the sandbox badge for a bash call the sandbox plugin marked', () => {
|
||||
render(<MessagePart part={createBashPart('git status', { sandbox: true })} />)
|
||||
|
||||
expect(screen.getByText('sandbox')).toBeInTheDocument()
|
||||
expect(screen.getByText('git status')).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('shows the sandbox badge and the unwrapped command for a legacy recorded sandbox call', () => {
|
||||
render(<MessagePart part={createBashPart(wrapped)} />)
|
||||
|
||||
expect(screen.getByText('sandbox')).toBeInTheDocument()
|
||||
|
||||
@@ -80,7 +80,10 @@ export function ToolCallPart({ part, onFileClick, onChildSessionClick }: ToolCal
|
||||
? part.state.input.command
|
||||
: undefined
|
||||
const displayCommand = rawCommand === undefined ? undefined : unwrapSandboxExecCommand(rawCommand)
|
||||
const isSandboxedCommand = rawCommand !== undefined && displayCommand !== rawCommand
|
||||
const isSandboxedCommand = rawCommand !== undefined && (
|
||||
displayCommand !== rawCommand ||
|
||||
(part.state.status === 'completed' && (part.state.metadata as Record<string, unknown> | undefined)?.sandbox === true)
|
||||
)
|
||||
const isUserBashCommand = part.state.status === 'completed' &&
|
||||
typeof displayCommand === 'string' &&
|
||||
userBashCommands.has(displayCommand)
|
||||
@@ -160,7 +163,11 @@ export function ToolCallPart({ part, onFileClick, onChildSessionClick }: ToolCal
|
||||
const previewText = getPreviewText()
|
||||
const isFileTool = ['read', 'write', 'edit'].includes(part.tool)
|
||||
const sandboxIndicator = isSandboxedCommand ? (
|
||||
<Badge variant="secondary" className="shrink-0 gap-1" title="Executed inside the sandbox microVM">
|
||||
<Badge
|
||||
variant="outline"
|
||||
className="shrink-0 gap-1 border-green-600/40 bg-green-500/15 text-green-700 dark:text-green-400"
|
||||
title="Executed inside the sandbox microVM"
|
||||
>
|
||||
<Shield className="w-3 h-3" />
|
||||
sandbox
|
||||
</Badge>
|
||||
|
||||
Reference in new issue
Block a user