Files
opencode-manager/backend/test/helpers/internal-test-app.ts
T
Chris Scott b21fdf5b94 feat(sandbox): per-session sandbox VMs with resource settings and provider arbitration
- Sandbox new root sessions by default with a per-session composer toggle;
  child sessions inherit their root session's mode (OM-82)
- Run each sandboxed root session in its own microVM that mounts only the
  session's repository, with per-session CPU/memory overrides, Settings
  defaults, idle stop, and a cap on running VMs (OM-89)
- Arbitrate shell sandboxing with other plugins (opencode-forge) through the
  shared opencode.sandbox-arbiter.v1 registry so exactly one provider
  sandboxes each call regardless of load order; fail closed on claim errors
- Throw when another plugin rewrites a pinned sandbox shell setting
- Tag sandboxed tool results with the owning provider and show it in the badge
- Hint the agent to start Docker inside the VM only when OCM owns the session
2026-10-15 16:53:49 -04:00

39 lines
1.7 KiB
TypeScript

import { createInternalRoutes } from '../../src/routes/internal'
import { createStubOpenCodeClient } from './stub-opencode-client'
type CreateInternalRoutesParams = Parameters<typeof createInternalRoutes>
type InternalTestAppOverrides = Partial<{
scheduleService: CreateInternalRoutesParams[1]
notificationService: CreateInternalRoutesParams[2]
settingsService: CreateInternalRoutesParams[3]
openCodeClient: CreateInternalRoutesParams[4]
permissionModes: CreateInternalRoutesParams[5]
repoWorkspaces: CreateInternalRoutesParams[6]
gitAuthService: CreateInternalRoutesParams[7]
sessionGoals: CreateInternalRoutesParams[8]
multiRuns: CreateInternalRoutesParams[9]
changeWalkthroughService: CreateInternalRoutesParams[10]
sessionSandbox: CreateInternalRoutesParams[11]
}>
export function createInternalTestApp(
db: CreateInternalRoutesParams[0],
overrides: InternalTestAppOverrides = {},
) {
return createInternalRoutes(
db,
overrides.scheduleService ?? ({} as CreateInternalRoutesParams[1]),
overrides.notificationService ?? ({} as CreateInternalRoutesParams[2]),
overrides.settingsService ?? ({} as CreateInternalRoutesParams[3]),
overrides.openCodeClient ?? createStubOpenCodeClient(),
overrides.permissionModes ?? ({} as CreateInternalRoutesParams[5]),
overrides.repoWorkspaces ?? ({} as CreateInternalRoutesParams[6]),
overrides.gitAuthService ?? ({} as CreateInternalRoutesParams[7]),
overrides.sessionGoals ?? ({} as CreateInternalRoutesParams[8]),
overrides.multiRuns ?? ({} as CreateInternalRoutesParams[9]),
overrides.changeWalkthroughService ?? ({} as CreateInternalRoutesParams[10]),
overrides.sessionSandbox ?? ({} as CreateInternalRoutesParams[11]),
)
}