mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 20:34:18 +01:00
- 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
45 lines
1.5 KiB
TypeScript
45 lines
1.5 KiB
TypeScript
import { z } from "zod";
|
|
|
|
export const SessionSandboxResourcesSchema = z.object({
|
|
cpus: z.number().int().min(1).max(64),
|
|
memoryMib: z.number().int().min(1024).max(1048576),
|
|
});
|
|
|
|
export type SessionSandboxResources = z.infer<typeof SessionSandboxResourcesSchema>;
|
|
|
|
export const SessionSandboxSourceSchema = z.enum(['default', 'user']);
|
|
|
|
export type SessionSandboxSource = z.infer<typeof SessionSandboxSourceSchema>;
|
|
|
|
export const SetSessionSandboxRequestSchema = z
|
|
.object({
|
|
sandboxed: z.boolean().optional(),
|
|
resources: SessionSandboxResourcesSchema.nullable().optional(),
|
|
})
|
|
.refine((value) => value.sandboxed !== undefined || value.resources !== undefined, {
|
|
message: 'At least one of sandboxed or resources is required',
|
|
});
|
|
|
|
export type SetSessionSandboxRequest = z.infer<typeof SetSessionSandboxRequestSchema>;
|
|
|
|
export const SessionSandboxStateSchema = z.object({
|
|
sessionId: z.string(),
|
|
rootSessionId: z.string(),
|
|
sandboxed: z.boolean(),
|
|
source: SessionSandboxSourceSchema,
|
|
resources: SessionSandboxResourcesSchema.nullable(),
|
|
effectiveResources: SessionSandboxResourcesSchema,
|
|
lockedReason: z.enum(["child"]).nullable(),
|
|
available: z.boolean(),
|
|
});
|
|
|
|
export type SessionSandboxState = z.infer<typeof SessionSandboxStateSchema>;
|
|
|
|
export const SessionSandboxClaimSchema = z.object({
|
|
sandboxed: z.boolean(),
|
|
source: SessionSandboxSourceSchema,
|
|
since: z.number(),
|
|
});
|
|
|
|
export type SessionSandboxClaim = z.infer<typeof SessionSandboxClaimSchema>;
|