import { z } from "zod"; /** A new protocol: this does not extend control.v2 or the existing workload v1. */ export declare const SIDEKICK_PROTOCOL_VERSION: 1; /** Transport ceilings, not permission to spend. Hosts may impose lower policy limits. */ export declare const SIDEKICK_LIMITS: Readonly<{ taskBytes: 65536; summaryBytes: 65536; patchBytes: number; warningBytes: 1024; commandBytes: 1024; modelChars: 512; maxFiles: 500; maxTests: 100; maxWarnings: 100; maxAttempts: 2; maxPageSize: 100; maxProviderCalls: 100; maxWallTimeMs: number; maxCostMicrousd: 1000000000000; maxCapabilityLifetimeMs: number; resumeBytes: 16384; }>; export declare const boundedUtf8: (maximum: number) => z.ZodString; export declare const taskSchema: z.ZodString; export declare const uuidSchema: z.ZodUUID; export declare const identitySchema: z.ZodString; export declare const digestSchema: z.ZodString; export declare const commitShaSchema: z.ZodString; export declare const generationSchema: z.ZodString; export declare const timestampSchema: z.ZodISODateTime; export declare const modelSchema: z.ZodString; export declare const repositorySchema: z.ZodString; export declare const repositoryIdSchema: z.ZodString; export declare const modeSchema: z.ZodEnum<{ local: "local"; cloud: "cloud"; }>; /** Exact native harness vocabulary, not launcher display labels. */ export declare const leadHarnessSchema: z.ZodEnum<{ codex: "codex"; claude_code: "claude_code"; }>; export declare const roleSchema: z.ZodEnum<{ lead: "lead"; sidekick: "sidekick"; }>; export declare const modelPolicySchema: z.ZodObject<{ mode: z.ZodLiteral<"explicit">; leadModel: z.ZodString; sidekickModel: z.ZodString; }, z.core.$strict>; export declare const budgetSchema: z.ZodObject<{ maxProviderCalls: z.ZodNumber; wallTimeMs: z.ZodNumber; maxCostMicrousd: z.ZodNumber; }, z.core.$strict>; export declare const capabilitySchema: z.ZodEnum<{ "repository.read": "repository.read"; "repository.write.worktree": "repository.write.worktree"; "tests.run": "tests.run"; "inference.use": "inference.use"; }>; export declare const capabilitiesSchema: z.ZodArray>; /** Supplied by the authenticated host, never taken from tool input. Null org is local-only. */ export declare const sessionScopeSchema: z.ZodObject<{ sessionId: z.ZodUUID; organizationId: z.ZodNullable; userId: z.ZodString; }, z.core.$strict>; export type SessionScope = z.infer; export declare const delegationInputSchema: z.ZodObject<{ protocolVersion: z.ZodLiteral<1>; sessionId: z.ZodUUID; operationId: z.ZodUUID; task: z.ZodString; mode: z.ZodEnum<{ local: "local"; cloud: "cloud"; }>; leadHarness: z.ZodEnum<{ codex: "codex"; claude_code: "claude_code"; }>; repository: z.ZodString; baseCommitSha: z.ZodString; modelPolicy: z.ZodObject<{ mode: z.ZodLiteral<"explicit">; leadModel: z.ZodString; sidekickModel: z.ZodString; }, z.core.$strict>; capabilities: z.ZodArray>; budget: z.ZodObject<{ maxProviderCalls: z.ZodNumber; wallTimeMs: z.ZodNumber; maxCostMicrousd: z.ZodNumber; }, z.core.$strict>; }, z.core.$strict>; export type DelegationInput = z.infer; /** Git-relative paths only. Filesystem adapters additionally reject symlinks and case aliases. */ export declare const filePathSchema: z.ZodString; export declare const changedFileSchema: z.ZodObject<{ path: z.ZodString; status: z.ZodEnum<{ added: "added"; modified: "modified"; deleted: "deleted"; }>; beforeSha256: z.ZodNullable; afterSha256: z.ZodNullable; }, z.core.$strict>; export declare const changedFilesSchema: z.ZodArray; beforeSha256: z.ZodNullable; afterSha256: z.ZodNullable; }, z.core.$strict>>; export declare const testOutcomeSchema: z.ZodObject<{ command: z.ZodString; outcome: z.ZodEnum<{ passed: "passed"; failed: "failed"; skipped: "skipped"; not_run: "not_run"; }>; exitCode: z.ZodNullable; }, z.core.$strict>; export type TestOutcome = z.infer; export declare const patchDescriptorSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{ kind: z.ZodLiteral<"no_change">; }, z.core.$strict>, z.ZodObject<{ kind: z.ZodLiteral<"patch">; sha256: z.ZodString; bytes: z.ZodNumber; }, z.core.$strict>], "kind">; export declare const resultBodySchema: z.ZodObject<{ protocolVersion: z.ZodLiteral<1>; delegationId: z.ZodUUID; attemptId: z.ZodUUID; generation: z.ZodString; baseCommitSha: z.ZodString; summary: z.ZodString; patch: z.ZodDiscriminatedUnion<[z.ZodObject<{ kind: z.ZodLiteral<"no_change">; }, z.core.$strict>, z.ZodObject<{ kind: z.ZodLiteral<"patch">; sha256: z.ZodString; bytes: z.ZodNumber; }, z.core.$strict>], "kind">; changedFiles: z.ZodArray; beforeSha256: z.ZodNullable; afterSha256: z.ZodNullable; }, z.core.$strict>>; tests: z.ZodArray; exitCode: z.ZodNullable; }, z.core.$strict>>; warnings: z.ZodArray; complete: z.ZodBoolean; }, z.core.$strict>; export type ResultBody = z.infer; /** Only use with schema-decoded JSON. Object-key order is irrelevant; array order is significant. */ export declare function canonicalJson(value: unknown): string; export declare const contentDigest: (value: string | Uint8Array) => string; export declare const canonicalDigest: (value: unknown) => string; export declare const resultSchema: z.ZodObject<{ protocolVersion: z.ZodLiteral<1>; delegationId: z.ZodUUID; attemptId: z.ZodUUID; generation: z.ZodString; baseCommitSha: z.ZodString; summary: z.ZodString; patch: z.ZodDiscriminatedUnion<[z.ZodObject<{ kind: z.ZodLiteral<"no_change">; }, z.core.$strict>, z.ZodObject<{ kind: z.ZodLiteral<"patch">; sha256: z.ZodString; bytes: z.ZodNumber; }, z.core.$strict>], "kind">; changedFiles: z.ZodArray; beforeSha256: z.ZodNullable; afterSha256: z.ZodNullable; }, z.core.$strict>>; tests: z.ZodArray; exitCode: z.ZodNullable; }, z.core.$strict>>; warnings: z.ZodArray; complete: z.ZodBoolean; digest: z.ZodString; }, z.core.$strict>; export type SidekickResult = z.infer; export declare const makeResult: (input: ResultBody) => SidekickResult; export declare const attemptStateSchema: z.ZodEnum<{ failed: "failed"; queued: "queued"; running: "running"; succeeded: "succeeded"; cancelled: "cancelled"; timed_out: "timed_out"; }>; export type AttemptState = z.infer; export declare const isTerminalAttemptState: (state: AttemptState) => boolean; export declare const delegationStateSchema: z.ZodEnum<{ failed: "failed"; queued: "queued"; running: "running"; succeeded: "succeeded"; cancelled: "cancelled"; timed_out: "timed_out"; awaiting_review: "awaiting_review"; taken_over: "taken_over"; discarded: "discarded"; expired: "expired"; }>; export type DelegationState = z.infer; export declare const isTerminalDelegationState: (state: DelegationState) => boolean; export declare const failureCodeSchema: z.ZodEnum<{ cancelled: "cancelled"; timed_out: "timed_out"; invalid_request: "invalid_request"; conflict: "conflict"; sidekick_limit: "sidekick_limit"; unauthorized: "unauthorized"; not_found: "not_found"; stale_generation: "stale_generation"; terminal_replay: "terminal_replay"; expired_result: "expired_result"; result_not_ready: "result_not_ready"; review_required: "review_required"; follow_up_limit: "follow_up_limit"; incomplete_result: "incomplete_result"; stale_base: "stale_base"; working_tree_conflict: "working_tree_conflict"; digest_mismatch: "digest_mismatch"; policy_denied: "policy_denied"; budget_exceeded: "budget_exceeded"; repository_unavailable: "repository_unavailable"; worker_lost: "worker_lost"; unavailable: "unavailable"; caller_identity_forbidden: "caller_identity_forbidden"; model_auto_disallowed: "model_auto_disallowed"; event_conflict: "event_conflict"; }>; export type FailureCode = z.infer; /** Fixed safe messages: never serialize a ZodError, native exception, token or prompt. */ export declare class SidekickProtocolError extends Error { readonly code: FailureCode; constructor(code: FailureCode); } export declare function decode(schema: z.ZodType, input: unknown): T; export declare const assertGeneration: (expected: string, actual: string) => void; export declare const sameScope: (left: SessionScope, right: SessionScope) => boolean; export declare const attemptSchema: z.ZodObject<{ attemptId: z.ZodUUID; attemptNumber: z.ZodNumber; generation: z.ZodString; taskDigest: z.ZodString; state: z.ZodEnum<{ failed: "failed"; queued: "queued"; running: "running"; succeeded: "succeeded"; cancelled: "cancelled"; timed_out: "timed_out"; }>; startedAt: z.ZodNullable; terminalAt: z.ZodNullable; result: z.ZodNullable; delegationId: z.ZodUUID; attemptId: z.ZodUUID; generation: z.ZodString; baseCommitSha: z.ZodString; summary: z.ZodString; patch: z.ZodDiscriminatedUnion<[z.ZodObject<{ kind: z.ZodLiteral<"no_change">; }, z.core.$strict>, z.ZodObject<{ kind: z.ZodLiteral<"patch">; sha256: z.ZodString; bytes: z.ZodNumber; }, z.core.$strict>], "kind">; changedFiles: z.ZodArray; beforeSha256: z.ZodNullable; afterSha256: z.ZodNullable; }, z.core.$strict>>; tests: z.ZodArray; exitCode: z.ZodNullable; }, z.core.$strict>>; warnings: z.ZodArray; complete: z.ZodBoolean; digest: z.ZodString; }, z.core.$strict>>; failureCode: z.ZodNullable>; }, z.core.$strict>; export type Attempt = z.infer; export declare const cleanupStateSchema: z.ZodEnum<{ error: "error"; complete: "complete"; running: "running"; pending: "pending"; }>; export declare const delegationSchema: z.ZodObject<{ protocolVersion: z.ZodLiteral<1>; delegationId: z.ZodUUID; scope: z.ZodObject<{ sessionId: z.ZodUUID; organizationId: z.ZodNullable; userId: z.ZodString; }, z.core.$strict>; input: z.ZodObject<{ protocolVersion: z.ZodLiteral<1>; sessionId: z.ZodUUID; operationId: z.ZodUUID; task: z.ZodString; mode: z.ZodEnum<{ local: "local"; cloud: "cloud"; }>; leadHarness: z.ZodEnum<{ codex: "codex"; claude_code: "claude_code"; }>; repository: z.ZodString; baseCommitSha: z.ZodString; modelPolicy: z.ZodObject<{ mode: z.ZodLiteral<"explicit">; leadModel: z.ZodString; sidekickModel: z.ZodString; }, z.core.$strict>; capabilities: z.ZodArray>; budget: z.ZodObject<{ maxProviderCalls: z.ZodNumber; wallTimeMs: z.ZodNumber; maxCostMicrousd: z.ZodNumber; }, z.core.$strict>; }, z.core.$strict>; state: z.ZodEnum<{ failed: "failed"; queued: "queued"; running: "running"; succeeded: "succeeded"; cancelled: "cancelled"; timed_out: "timed_out"; awaiting_review: "awaiting_review"; taken_over: "taken_over"; discarded: "discarded"; expired: "expired"; }>; attempt: z.ZodObject<{ attemptId: z.ZodUUID; attemptNumber: z.ZodNumber; generation: z.ZodString; taskDigest: z.ZodString; state: z.ZodEnum<{ failed: "failed"; queued: "queued"; running: "running"; succeeded: "succeeded"; cancelled: "cancelled"; timed_out: "timed_out"; }>; startedAt: z.ZodNullable; terminalAt: z.ZodNullable; result: z.ZodNullable; delegationId: z.ZodUUID; attemptId: z.ZodUUID; generation: z.ZodString; baseCommitSha: z.ZodString; summary: z.ZodString; patch: z.ZodDiscriminatedUnion<[z.ZodObject<{ kind: z.ZodLiteral<"no_change">; }, z.core.$strict>, z.ZodObject<{ kind: z.ZodLiteral<"patch">; sha256: z.ZodString; bytes: z.ZodNumber; }, z.core.$strict>], "kind">; changedFiles: z.ZodArray; beforeSha256: z.ZodNullable; afterSha256: z.ZodNullable; }, z.core.$strict>>; tests: z.ZodArray; exitCode: z.ZodNullable; }, z.core.$strict>>; warnings: z.ZodArray; complete: z.ZodBoolean; digest: z.ZodString; }, z.core.$strict>>; failureCode: z.ZodNullable>; }, z.core.$strict>; createdAt: z.ZodISODateTime; terminalAt: z.ZodNullable; resultExpiresAt: z.ZodNullable; tombstoneExpiresAt: z.ZodISODateTime; cleanup: z.ZodEnum<{ error: "error"; complete: "complete"; running: "running"; pending: "pending"; }>; }, z.core.$strict>; export type Delegation = z.infer; export declare const canonicalInputDigest: (input: DelegationInput) => string; export type AdmissionRecord = { scope: SessionScope; operationId: string; inputDigest: string; state: DelegationState; }; /** Must run inside the host's single-session admission transaction, not as a process-local lock. */ export declare function admitSingleSidekick(existing: readonly AdmissionRecord[], raw: DelegationInput, scope: SessionScope): "admitted" | "duplicate"; export declare function checkAttemptTransition(current: Attempt, next: Attempt): "accepted" | "duplicate"; export declare function assertResultReadable(delegation: Delegation, nowMs: number): SidekickResult; export declare function assertFollowUpAllowed(delegation: Delegation, generation: string, resultDigest: string, nowMs: number): void;