import type { Tool } from '@earendil-works/pi-ai'; import { z } from 'zod'; import { type ComputerAction, type ComputerProfile } from '@xopcai/computer-control-contract'; import type { ComputerHistoryEntry, ComputerExpectation } from './task-state.js'; import { ComputerDiagnosticSchema } from './errors.js'; export declare const ComputerProposalSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{ kind: z.ZodLiteral<"action">; action: z.ZodDiscriminatedUnion<[z.ZodObject<{ kind: z.ZodLiteral<"activate">; ref: z.ZodString; }, z.core.$strict>, z.ZodObject<{ kind: z.ZodLiteral<"showMenu">; ref: z.ZodString; }, z.core.$strict>, z.ZodObject<{ kind: z.ZodLiteral<"click">; point: z.ZodObject<{ x: z.ZodNumber; y: z.ZodNumber; }, z.core.$strict>; button: z.ZodEnum<{ left: "left"; right: "right"; }>; count: z.ZodUnion, z.ZodLiteral<2>]>; }, z.core.$strict>, z.ZodObject<{ kind: z.ZodLiteral<"drag">; from: z.ZodObject<{ x: z.ZodNumber; y: z.ZodNumber; }, z.core.$strict>; to: z.ZodObject<{ x: z.ZodNumber; y: z.ZodNumber; }, z.core.$strict>; }, z.core.$strict>, z.ZodObject<{ kind: z.ZodLiteral<"setValue">; ref: z.ZodString; text: z.ZodString; }, z.core.$strict>, z.ZodObject<{ kind: z.ZodLiteral<"typeText">; text: z.ZodString; point: z.ZodOptional>; }, z.core.$strict>, z.ZodObject<{ kind: z.ZodLiteral<"pressKeys">; keys: z.ZodArray; }, z.core.$strict>, z.ZodObject<{ kind: z.ZodLiteral<"scroll">; point: z.ZodObject<{ x: z.ZodNumber; y: z.ZodNumber; }, z.core.$strict>; deltaX: z.ZodNumber; deltaY: z.ZodNumber; }, z.core.$strict>, z.ZodObject<{ kind: z.ZodLiteral<"wait">; durationMs: z.ZodNumber; }, z.core.$strict>, z.ZodObject<{ kind: z.ZodLiteral<"activateSequence">; refs: z.ZodArray; }, z.core.$strict>, z.ZodObject<{ kind: z.ZodLiteral<"batch">; actions: z.ZodArray; ref: z.ZodString; }, z.core.$strict>, z.ZodObject<{ kind: z.ZodLiteral<"showMenu">; ref: z.ZodString; }, z.core.$strict>, z.ZodObject<{ kind: z.ZodLiteral<"click">; point: z.ZodObject<{ x: z.ZodNumber; y: z.ZodNumber; }, z.core.$strict>; button: z.ZodEnum<{ left: "left"; right: "right"; }>; count: z.ZodUnion, z.ZodLiteral<2>]>; }, z.core.$strict>, z.ZodObject<{ kind: z.ZodLiteral<"drag">; from: z.ZodObject<{ x: z.ZodNumber; y: z.ZodNumber; }, z.core.$strict>; to: z.ZodObject<{ x: z.ZodNumber; y: z.ZodNumber; }, z.core.$strict>; }, z.core.$strict>, z.ZodObject<{ kind: z.ZodLiteral<"setValue">; ref: z.ZodString; text: z.ZodString; }, z.core.$strict>, z.ZodObject<{ kind: z.ZodLiteral<"typeText">; text: z.ZodString; point: z.ZodOptional>; }, z.core.$strict>, z.ZodObject<{ kind: z.ZodLiteral<"pressKeys">; keys: z.ZodArray; }, z.core.$strict>, z.ZodObject<{ kind: z.ZodLiteral<"scroll">; point: z.ZodObject<{ x: z.ZodNumber; y: z.ZodNumber; }, z.core.$strict>; deltaX: z.ZodNumber; deltaY: z.ZodNumber; }, z.core.$strict>, z.ZodObject<{ kind: z.ZodLiteral<"wait">; durationMs: z.ZodNumber; }, z.core.$strict>], "kind">>; }, z.core.$strict>], "kind">; }, z.core.$strict>, z.ZodObject<{ kind: z.ZodLiteral<"finished">; claimedSuccess: z.ZodBoolean; }, z.core.$strict>, z.ZodObject<{ kind: z.ZodLiteral<"answer">; text: z.ZodString; }, z.core.$strict>, z.ZodObject<{ kind: z.ZodLiteral<"takeover">; reason: z.ZodString; }, z.core.$strict>], "kind">; export type ComputerProposal = z.infer; declare const ObservationNoteSchema: z.ZodObject<{ kind: z.ZodEnum<{ progress: "progress"; requirement: "requirement"; }>; text: z.ZodString; }, z.core.$strict>; export declare const ComputerObservationNotesSchema: z.ZodArray; text: z.ZodString; step: z.ZodNumber; }, z.core.$strict>>; type ObservationNote = z.infer; export declare const GUI_PLUS_SYSTEM_PROMPT: string; export declare const GUI_PLUS_OBSERVATION_PROMPT: string; export declare function parseGuiPlusProposal(content: string, width: number, height: number): ComputerProposal; type ValidationReason = NonNullable['validationReason']>; export interface ComputerModelConnection { api?: string; modelId: string; baseUrl: string; apiKey: string; profile: ComputerProfile; deploymentRevision?: string; maxOutputTokens?: number; headers?: Record; } export interface ComputerPredictionInput { goal: string; image: Uint8Array; mimeType: 'image/png' | 'image/jpeg'; width: number; height: number; summary: string; stateDigest?: string; formatCorrection?: boolean; validationReason?: ValidationReason; validation?: NonNullable['validation']>; correctionReply?: string; readOnly?: boolean; interactionOnly?: boolean; /** Whitelist of actions implemented by a constrained structured-tool executor. */ actionKinds?: readonly ComputerAction['kind'][]; /** The isolated Linux executor has a provisioned Super+E file-manager binding. */ desktopFileManagerShortcut?: true; /** The isolated Linux executor has a provisioned Super+Space application menu. */ desktopApplicationMenuShortcut?: true; /** The disposable guest includes bounded excerpts of visible document text. */ desktopDocumentEvidence?: true; /** The disposable guest retains bounded observations of previously viewed notes pages. */ desktopPresentationReview?: true; history?: readonly ComputerHistoryEntry[]; expectation?: ComputerExpectation; flowHint?: string; /** Bounded historical JPEG used only as supplementary visual evidence. */ visualFeedback?: { image: Uint8Array; description: string; }; /** Episode-local notes from earlier observations, never input authorization. */ observationMemory?: { notes: z.infer; capture: (note: ObservationNote) => void; }; maxPlanActions?: number; onModelRequest?: () => void; onInteractionNormalized?: () => void; } export interface ComputerStepAdapter { readonly supportsFormatRetry?: boolean; readonly hasPendingPlan?: boolean; predict(input: ComputerPredictionInput, signal?: AbortSignal): Promise; reset?(): void; } export type StructuredComputerCompletion = (input: { systemPrompt: string; context: string; image: ComputerPredictionInput['image']; mimeType: ComputerPredictionInput['mimeType']; visualFeedback?: ComputerPredictionInput['visualFeedback']; tool: Tool; maxTokens: number; }, signal?: AbortSignal) => Promise; /** One format-only re-prediction is safe before any input has been proposed or dispatched. */ export declare function predictComputerStep(adapter: ComputerStepAdapter, input: ComputerPredictionInput, reserveAttempt: () => void, signal?: AbortSignal): Promise; export declare function readComputerJson(response: Response, maxBytes: number): Promise; /** Only a complete Responses event can authorize a proposal; deltas never reach the broker. */ export declare function readComputerResponsesStream(response: Response, maxBytes: number): Promise; /** A frozen single-recipient connection; never retries, redirects or changes billing sources. */ export declare class ChatCompletionsComputerAdapter implements ComputerStepAdapter { private readonly fetchImpl; private readonly completeStructured?; private readonly plan; get hasPendingPlan(): boolean; reset(): void; private readonly connection; constructor(connection: ComputerModelConnection, fetchImpl?: typeof fetch, completeStructured?: StructuredComputerCompletion | undefined); predict(input: ComputerPredictionInput, signal?: AbortSignal): Promise; } /** Native Responses Computer tool adapter. Execution remains exclusively in the local broker. */ export declare class OpenAIResponsesComputerAdapter implements ComputerStepAdapter { private readonly fetchImpl; readonly supportsFormatRetry = false; private readonly connection; private responseId?; private callId?; private queued; get hasPendingPlan(): boolean; private awaitingAction?; private batchGoal?; constructor(connection: ComputerModelConnection, fetchImpl?: typeof fetch); predict(input: ComputerPredictionInput, signal?: AbortSignal): Promise; private observe; private nextQueued; private mapActions; reset(): void; private resetTurn; } export declare function createComputerModelAdapter(connection: ComputerModelConnection, fetchImpl?: typeof fetch): ComputerStepAdapter; export {};