import { type DesktopOperationIntent, type ProviderOperationIntent, type ProviderOperationReceipt, type ClientEndpointMessage, type EndpointToolContent, type EndpointToolDescriptor, type EndpointToolErrorCode } from '@xopcai/endpoint-tools-protocol'; import { EndpointRegistry } from './registry.js'; import { EndpointToolPolicy } from './policy.js'; import type { EndpointInvocationScope, EndpointUploadService } from './upload-service.js'; import type { EndpointWakeProvider } from './wake-provider.js'; type ToolClientMessage = Exclude; type PendingState = 'sent' | 'running'; type DeviceInteraction = Extract['payload']; type InteractionOrigin = EndpointInvocationScope & { runId: string; targetRef?: string; }; interface PendingInvocation { id: string; endpointId: string; toolName: string; gatewayCapabilityPrincipalId?: string; descriptor: EndpointToolDescriptor; providerDigest?: string; resourceKey?: string; arguments: Record; deadlineAt: number; interactionScope?: EndpointInvocationScope; interaction?: DeviceInteraction; interactionRequests?: Set; interactionOrigin?: InteractionOrigin; recovered?: boolean; state: PendingState; operationQuery?: DesktopOperationIntent; providerExecution?: ProviderOperationIntent; execution?: { intent: DesktopOperationIntent; connectionInstanceId: string; }; stopTimer?: ReturnType; receiptTimer?: ReturnType; deadlineTimer: ReturnType; abortSignal?: AbortSignal; abortHandler?: () => void; onProgress?: (progress: { message?: string; percent?: number; }) => void; onTerminal?: (invocationId: string, event: Extract['payload']['event']) => void; resolve: (result: EndpointInvocationResult) => void; reject: (error: Error) => void; } export interface EndpointInvocationAuditSink { started(params: { id: string; principalId: string; endpointId: string; toolCallId: string; toolName: string; effect: 'read' | 'write' | 'destructive'; confirmationRequired: boolean; argumentsSha256: string; operationId?: string; startedAt: number; }): void; finished(params: { id: string; status: 'succeeded' | 'failed'; errorCode?: EndpointToolErrorCode; errorMessage?: string; completedAt: number; recovered?: true; }): void; } export interface EndpointInvocationServiceOptions { authorizeProvider?: (endpointId: string, toolName: string) => void; audit?: EndpointInvocationAuditSink; uploads?: EndpointUploadService; policy?: EndpointToolPolicy; wakeProvider?: EndpointWakeProvider; authorizeInteractionRecovery?: (origin: InteractionOrigin, endpointId: string) => boolean; } export interface EndpointInvocationResult { invocationId?: string; providerReceipt?: ProviderOperationReceipt; content: EndpointToolContent[]; details?: Record; } export declare class EndpointToolExecutionError extends Error { readonly code: EndpointToolErrorCode; readonly confirmedNoEffect: boolean; constructor(code: EndpointToolErrorCode, message: string, confirmedNoEffect?: boolean); } export declare class EndpointInvocationService { private readonly registry; private readonly options; private readonly interactionCheckpoints; private nextInteractionPruneAt; private readonly pending; private readonly policy; private readonly ajv; private readonly validators; constructor(registry: EndpointRegistry, options?: EndpointInvocationServiceOptions); private validator; private formatSchemaValidationError; invoke(params: { endpointId: string; toolCallId: string; toolName: string; arguments: Record; descriptorRevision: string; gatewayCapability?: true; operationId?: string; invocationScope?: EndpointInvocationScope; interactionOrigin?: InteractionOrigin; signal?: AbortSignal; onProgress?: (progress: { message?: string; percent?: number; }) => void; onTerminal?: PendingInvocation['onTerminal']; }): Promise; requestInteraction(endpointId: string, request: DeviceInteraction): void; private reattachInteraction; listInteractions(scope: EndpointInvocationScope, activeActor?: boolean): { endpointId: string; toolName: string; deadlineAt: number; invocationId: string; requestId: string; message: string; inputSchema: Record; }[]; answerInteraction(scope: EndpointInvocationScope, requestId: string, action: 'accept' | 'decline' | 'cancel', content?: Record, activeActor?: boolean): boolean; private interactionMatches; handleMessage(endpointId: string, message: ToolClientMessage): void; failEndpoint(endpointId: string): void; invalidateContracts(endpointId: string): void; close(): void; discardDetachedInteractions(): void; private pruneInteractionCheckpoints; private markInteractionUnknown; revokeDeviceCapability(deviceId: string, toolName: string): void; private cancel; private verifyExecutionReceipt; private succeed; private fail; private finishAudit; private abortUploads; private take; private error; } export {};