/** * Worker API Client * * HTTP client for communicating with the backend worker API endpoints. * Updated for V1 integration platform: runs-based job model. */ export declare function trimTrailingSlashes(value: string): string; /** * Interface for job execution clients. * Implemented by WorkerClient (HTTP). * Allows the executor to work without coupling to a specific transport. */ export interface ExecutorClient { readonly id: string; poll(capacityAvailable?: number, options?: { waitSeconds?: number; signal?: AbortSignal; }): Promise; /** * Beat, and read what the gateway says back. The response is the only channel * into a run this worker already holds: `continue: false` means stop. */ heartbeat(runId: number, progress?: { items_collected_so_far?: number; current_page?: number; elapsed_ms?: number; }, agentSession?: NonNullable, turnDelta?: NonNullable, turnToolEvents?: NonNullable): Promise; stream(batch: StreamBatch): Promise; complete(req: CompleteRequest): Promise; completeAction(req: CompleteActionRequest): Promise; fetchEventsForEmbedding(eventIds: number[]): Promise; completeEmbeddings(req: CompleteEmbeddingsRequest): Promise; emitAuthArtifact(req: EmitAuthArtifactRequest): Promise; pollAuthSignal(req: PollAuthSignalRequest): Promise; completeAuth(req: CompleteAuthRequest): Promise; /** * Forward a chrome-extension action call from the running connector to the * gateway, which enqueues a chrome connector action run, waits for the * paired Owletto extension to claim/complete, and returns the observation * — multi-replica safe because the wait is Postgres-mediated. */ dispatchChromeAction(req: DispatchChromeActionRequest): Promise>; /** * Post a device-side automation exit report and read the server's decision. * `status: "resume"` means the run is still claimed and the caller should * re-spawn with the returned nudge. */ completeAutomation(runId: number, req: CompleteAutomationRequest): Promise; completeDeviceChat(runId: number, req: CompleteDeviceChatRequest): Promise; /** * Report an agent turn. Fleet-only, so it posts to the shared worker route * rather than the device-scoped `/me/runs/...` family. */ completeAgentTurn(req: CompleteAgentTurnRequest): Promise; /** MCP endpoint + bearer the automation arm wires into the spawned CLI. */ readonly mcpWiring?: { url: string; bearer?: string; }; /** Terminal ACP transcript upload authenticated by the per-run agent token. */ writeAutomationTranscript(runId: number, bearer: string, terminalStatus: 'completed' | 'failed' | 'timeout' | 'cancelled', snapshotJsonl: string): Promise; } /** * The worker⇄gateway wire payloads are the SINGLE SOURCE in * `@lobu/core/contracts/worker/protocol` (TypeBox). Re-exported here so this * module's public surface is unchanged for importers, while the server annotates * its request-body reads with the same shapes from that file. */ export type { CompleteActionRequest, CompleteAgentTurnRequest, CompleteAgentTurnResponse, CompleteAuthRequest, CompleteAutomationRequest, CompleteAutomationResponse, CompleteDeviceChatRequest, CompleteDeviceChatResponse, CompleteEmbeddingsRequest, CompleteRequest, ContentItem, DispatchChromeActionRequest, DispatchChromeActionResponse, EmbedEvent, EmitAuthArtifactRequest, HeartbeatRequest, HeartbeatResponse, OAuthCredentials, PollAuthSignalRequest, PollAuthSignalResponse, PollResponse, StreamBatch, } from "@lobu/core/contracts/worker/protocol"; import type { CompleteActionRequest, CompleteAgentTurnRequest, CompleteAgentTurnResponse, CompleteAuthRequest, CompleteAutomationRequest, CompleteAutomationResponse, CompleteDeviceChatRequest, CompleteDeviceChatResponse, CompleteEmbeddingsRequest, CompleteRequest, DispatchChromeActionRequest, EmbedEvent, EmitAuthArtifactRequest, HeartbeatRequest, HeartbeatResponse, PollAuthSignalRequest, PollAuthSignalResponse, PollResponse, StreamBatch } from "@lobu/core/contracts/worker/protocol"; import type { AgentKind } from "@lobu/core/contracts/worker/device-automation"; /** Capability strings the worker advertises, keyed by name (e.g. `browser.debugger`). */ export type WorkerCapabilities = Record; export interface WorkerAdvertisementSnapshot { capabilities: WorkerCapabilities; manifests: unknown[]; generation: number; } export interface WorkerAdvertisementProvider { snapshot(): WorkerAdvertisementSnapshot; } export declare class MutableWorkerAdvertisementProvider implements WorkerAdvertisementProvider { private current; constructor(snapshot: Omit & { generation?: number; }); snapshot(): WorkerAdvertisementSnapshot; update(snapshot: Omit & { generation: number; }): void; } /** HTTP error carrying the status code for retry and terminal-conflict policy. */ export declare class WorkerHttpError extends Error { readonly status: number; readonly path: string; constructor(status: number, path: string, body: string); } /** * A 2xx body we could not read as a completion decision. The server answered, * so re-sending would only mangle the same body — non-retriable. */ export declare class WorkerDecodeError extends Error { constructor(message: string); } /** * Worker API Client */ export declare class WorkerClient implements ExecutorClient { private apiUrl; private workerId; private capabilities; private authToken?; private version; private platform?; private label?; private manifests; private binaryOverrides?; private fixedAgentKinds?; private advertisementProvider?; private agentKindsCache; private backendCapacity; constructor(config: { apiUrl: string; workerId: string; authToken?: string; capabilities: WorkerCapabilities; version?: string; /** Host platform for server-side device registration and capability authorization. */ platform?: string; /** Human-readable device name for the Devices page. */ label?: string; /** Device-manifest connector definitions to register on each poll. */ manifests?: unknown[]; /** Executor binary overrides, so advertised kinds match what the arm spawns. */ binaryOverrides?: Partial>; /** Exact session workers advertise only the one CLI they can receive. */ agentKinds?: AgentKind[]; /** Mutable device capability/manifest snapshot, updated by the native bridge. */ advertisementProvider?: WorkerAdvertisementProvider; /** Static readiness/capacity per execution backend. */ backendCapacity?: Record; }); /** * Agent kinds this machine can spawn, re-discovered at most every * `AGENT_KIND_DISCOVERY_TTL_MS`. Installing a CLI mid-session must start * attracting runs without a daemon restart, but a filesystem sweep on every * poll (default 10s) buys nothing. */ private runnableAgentKinds; /** * Capabilities this poll advertises. On the headless platform the daemon adds * `automations.execute` itself: the gateway hands `run_type='automation'` runs * only to devices advertising it, so the string is the build signal that keeps * an older daemon — one whose executor mishandles the automation lane — from * claiming and wedging a run. Whether this host can actually launch the * Automation's CLI is a separate gate: the `agent_kinds` discovered below. */ private advertisedCapabilities; private authHeaders; replaceAuthToken(authToken: string): void; private post; private requestJson; private requestVoid; /** * Poll for available runs */ poll(capacityAvailable?: number, options?: { waitSeconds?: number; signal?: AbortSignal; }): Promise; /** * Send heartbeat for active run */ heartbeat(runId: number, progress?: { items_collected_so_far?: number; current_page?: number; elapsed_ms?: number; }, agentSession?: NonNullable, /** * The next span of an agent turn's reply. Rides the heartbeat because the * turn already beats to say it is alive, and this is that statement * carrying its evidence — see `HeartbeatRequestSchema.turn_delta`. * * The reply's `turn_delta_ack` is what lets the caller retire the span it * sent; without one it must send the same span, under the same sequence, * on the next beat. */ turnDelta?: NonNullable, /** Tool calls the turn finished since the last beat. */ turnToolEvents?: NonNullable): Promise; writeAutomationTranscript(runId: number, bearer: string, terminalStatus: 'completed' | 'failed' | 'timeout' | 'cancelled', snapshotJsonl: string): Promise; /** * Stream content batch to backend */ stream(batch: StreamBatch): Promise; /** * Report sync run completion */ complete(req: CompleteRequest): Promise; /** * Report action run completion */ completeAction(req: CompleteActionRequest): Promise; /** * Fetch events needing embeddings */ fetchEventsForEmbedding(eventIds: number[]): Promise; /** * Submit generated embeddings */ completeEmbeddings(req: CompleteEmbeddingsRequest): Promise; /** * Emit an auth artifact (QR, redirect URL, prompt) for the UI to render. */ emitAuthArtifact(req: EmitAuthArtifactRequest): Promise; /** * Poll for a signal sent by the UI (OAuth callback, form submit, cancel). */ pollAuthSignal(req: PollAuthSignalRequest): Promise; /** * Report auth run completion — writes credentials + metadata to auth_profiles. */ completeAuth(req: CompleteAuthRequest): Promise; /** * Forward a chrome connector action call to the gateway. Blocks until the * paired Owletto extension completes the run or the gateway-side budget * times out. Throws on failure/timeout with the gateway's error message. */ dispatchChromeAction(req: DispatchChromeActionRequest): Promise>; /** * Health check */ healthCheck(): Promise; /** * Device-side EXIT REPORT for an automation run. Posts the process exit * metadata and returns the server's decision; see * `interpretCompleteAutomationResponse` for how a 2xx body is read without * inventing an outcome. */ completeAutomation(runId: number, req: CompleteAutomationRequest): Promise; completeAgentTurn(req: CompleteAgentTurnRequest): Promise; completeDeviceChat(runId: number, req: CompleteDeviceChatRequest): Promise; get mcpWiring(): { url: string; bearer?: string; } | undefined; get id(): string; } /** * A 2xx body from `complete-automation`, read without inventing an outcome. * Anything not recognised throws `WorkerDecodeError` — the server answered, so * the caller must not re-send and must not report a fabricated outcome. */ export declare function interpretCompleteAutomationResponse(body: unknown): CompleteAutomationResponse; //# sourceMappingURL=client.d.ts.map