import { type HostProbeTarget, type VerifiedSandboxHostApproval } from "./baseline.ts"; import type { ConcreteSandboxPreparation, ExecutionOwner, HostBaselinePolicy, MutationPermit, PreparedSandboxPlan, ResolveOnlyPreparation, SandboxActivation, SandboxExecutionTarget, SandboxPlan, SandboxPolicyPlan, WorkspaceBackendCapabilities } from "./backend.ts"; export interface ConcreteSandboxAdapter { /** * Prepare and verify this exact concrete policy using the native adapter. * Merely echoing WorkspaceBackendCapabilities is not a valid implementation. */ prepareConcreteSandbox(policy: Readonly, owner: Readonly): Promise; } export interface ResolveOnlyAdapter { /** Performs path-only preparation and must return the explicit low-assurance tag. */ prepareResolveOnly(policy: Readonly, owner: Readonly): Promise; } export interface SandboxPolicyFactoryOptions { capabilities: WorkspaceBackendCapabilities; executionTarget: SandboxExecutionTarget; /** Exact process-local host approval minted by the trusted evidence loader. * Required for every native target; clone/JSON/spread copies are rejected. */ sandboxApproval?: VerifiedSandboxHostApproval; /** Independently observed live Host/OS/binary/backend tuple. Native execution * requires an exact all-field match with the approved target. */ liveTarget?: HostProbeTarget; /** Expected checked-in host-support baseline identity. */ hostSupportBaselineId?: string; /** Complete trusted baseline policies. bodyDigest is recomputed from the * canonical full body (excluding bodyDigest) during registration. */ baselineBindings: readonly HostBaselinePolicy[]; /** At least 256 bits of process-local host key material. */ key: Uint8Array; keyId: string; preparedPlanTtlMs?: number; now?: () => Date; concreteAdapter?: ConcreteSandboxAdapter; resolveOnlyAdapter?: ResolveOnlyAdapter; /** Host authorization decision made outside flow data. Default is deny. */ authorizeResolveOnly?: (owner: Readonly, policy: Readonly) => boolean; } export interface SandboxActivationHooks { /** Journal CAS: issued -> active. Required for every plan carrying permits. */ activateMutationPermits?: (permits: readonly MutationPermit[], owner: Readonly) => Promise; /** Always called after an activation callback was entered. */ settleMutationPermits?: (permits: readonly MutationPermit[], owner: Readonly, outcome: "completed" | "failed") => Promise; } /** Build the path-free portable policy digest specified by the Workspace RFC. */ export declare function computeSandboxPolicyDigest(plan: Omit | SandboxPolicyPlan, backend: Pick): string; /** Canonical baseline body digest. The digest field itself is excluded; every * other policy field, including identity/version, is bound. */ export declare function computeHostBaselineBodyDigest(baseline: Omit | HostBaselinePolicy): string; /** Content address the complete advertised backend capability record. */ export declare function computeWorkspaceBackendCapabilitiesSha256(capabilities: WorkspaceBackendCapabilities): string; /** Attach the computed portable digest without changing the concrete plan inputs. */ export declare function createSandboxPolicyPlan(plan: Omit, backend: Pick): SandboxPolicyPlan; /** * Process-local policy factory. It negotiates and authenticates plans, but delegates * real native preparation to an adapter and therefore never pretends to be a sandbox. */ export declare class SandboxPolicyFactory { #private; constructor(options: SandboxPolicyFactoryOptions); capabilities(): WorkspaceBackendCapabilities; prepareSandbox(plan: SandboxPolicyPlan, owner: ExecutionOwner): Promise; sealSandbox(prepared: PreparedSandboxPlan, permits: readonly MutationPermit[]): SandboxPlan; /** * Activate exactly once and keep permit activation/settlement around the actual * execution callback. Callers must put native spawn/open inside `execute`. */ activateOnce(plan: SandboxPlan, hooks: SandboxActivationHooks, execute: (activation: SandboxActivation) => Promise): Promise; } declare function validateCapabilities(capabilities: WorkspaceBackendCapabilities): void; export declare const validateWorkspaceBackendCapabilities: typeof validateCapabilities; export {}; //# sourceMappingURL=sandbox.d.ts.map