/** * Runtime client core. Connects to the MCP server over WS, executes * commands dispatched by the server, and forwards page events back. * * Started lazily by `auto-start.ts` when the script is imported. */ import { COMMAND } from '@harnessa-fe/protocol'; import type { QueryMethod } from '@harnessa-fe/protocol'; export interface ClientOptions { projectId: string; mcpUrl?: string; /** * Build artifact id, threaded through `window.__HARNESSA_FE__.buildId`. * Stamped on every event so agents can trace "what code was running". */ buildId?: string; /** * Parent project's id. Set by the plugin when the host app declares it, * or auto-inferred at runtime via `tryInheritFromParent()` when this * runtime is loaded inside a same-origin iframe. */ parentProjectId?: string; /** Optional human-readable name; mostly used by the project tree. */ displayName?: string; /** * App-supplied user identifier (e.g. supabase.user.id, auth0 sub, …). * Optional. When absent, traffic is treated as anonymous (only stitched * by visitorId). Propagated by HarnessaScript via window.__HARNESSA_FE__.userId. */ userId?: string; } export { tryInheritFromParent } from './parent-inherit.js'; export type { ParentInheritance } from './parent-inherit.js'; export declare class RuntimeClient { private readonly opts; private ws?; readonly tabId: string; readonly sessionId: string; readonly visitorId: string; readonly parentProjectId?: string; /** Read-only accessors exposed for the in-page info panel. */ get projectId(): string; get buildId(): string | undefined; get displayName(): string | undefined; get userId(): string | undefined; /** WebSocket state: 'connecting' | 'open' | 'closed'. */ getConnectionState(): 'connecting' | 'open' | 'closed'; private pageLoadSent; private readonly ctx; private readonly recorder; private reconnectAttempts; private closed; private static readonly MAX_OUTBOX_FRAMES; private static readonly MAX_OUTBOX_BYTES; private readonly outbox; constructor(opts: ClientOptions); start(): void; stop(): void; private connect; private onOpen; private onClose; private onMessage; private onQueryResponse; private onHelloAck; private handleCommand; sendEvent(name: string, payload: unknown): void; /** * Request/reply RPC to the daemon. Currently used by the in-page * overlay to fetch / mutate the visitor's own tasks. Resolves with the * remote `result`, rejects with the remote `error.message` (or a * timeout after 10 s). */ query(method: QueryMethod, args?: unknown, timeoutMs?: number): Promise; private pendingQueries; private send; private drainOutbox; } /** Pull the well-known config object planted by the Vite plugin on window. */ export declare function readInjectedConfig(): ClientOptions; /** Re-export command names for outside callers. */ export { COMMAND };