/** * Development Workspace Connection * * Public API for clients (browser, IDE, agent) to discover and connect * to a FeltDB Development Workspace. */ import type { ClientType, RuntimeInvestigation, RuntimeRequestObservation } from './workspace-types.js'; import type { WorkspaceEventPayload } from './workspace-types.js'; import { type RuntimeObservationInput } from './runtime-observation.js'; export interface WorkspaceConnectionOptions { pairingCode?: string; workspaceId?: string; projectDir?: string; clientId?: string; clientType?: ClientType; endpoint?: string; discoveryEndpoint?: string; /** Development-session identity supplied by FeltDB, never derived locally. */ sessionId?: string; /** Runtime registration identity supplied by FeltDB, never derived locally. */ runtimeInstanceId?: string; auth?: { token: string; apiKey?: string; }; } export interface WorkspaceMetadata { workspaceId: string; projectId: string; version: number; } export interface PairingTokenData { token: string; workspaceId: string; expiresAt: number; endpoint?: string; authorityEndpoint?: string; namespace?: string; sessionId?: string; runtimeInstanceId?: string; } export interface BrowserPairingResolution { workspaceId: string; endpoint: string; expiresAt: number; namespace: string; sessionId?: string; runtimeInstanceId?: string; } export interface CreateRuntimeInvestigationInput { investigationId?: string; observationId: string; changeId?: string; verificationId?: string; } export interface PairingDiscoveryOptions { endpoint?: string; } export interface ClientInfo { clientId: string; clientType: ClientType; connectedAt: number; capabilities: string[]; } /** * Discover workspace from .feltdb/workspace.json * * Usage: * ``` * const workspace = await discoverDevelopmentWorkspace({ * projectDir: process.cwd() * }) * ``` */ export declare function discoverDevelopmentWorkspace(options: { projectDir: string; }): Promise; /** * Resolve pairing code to workspace ID * * Pairing codes are short-lived tokens (FELT-XXXX) that resolve to * workspace IDs. They expire after 15 minutes. * * Used by clients to auto-discover workspace without manual entry. */ export declare function resolvePairingCode(pairingCode: string, projectDir: string): Promise; export declare function resolvePairingCode(pairingCode: string, options?: PairingDiscoveryOptions): Promise; /** * Connect to a Development Workspace * * Canonical API for clients to establish connection to shared workspace. * * Usage via pairing code (browser/IDE discovery): * ``` * const workspace = await connectDevelopmentWorkspace({ * pairingCode: "FELT-7K3P", * clientId: "vscode-randy", * clientType: "ide" * }) * ``` * * Usage via workspace ID (agent/CLI): * ``` * const workspace = await connectDevelopmentWorkspace({ * workspaceId: "ws_myapp_1234567890_abc123", * projectDir: process.cwd(), * clientId: "claude-code", * clientType: "agent" * }) * ``` * * Usage via endpoint (remote connection): * ``` * const workspace = await connectDevelopmentWorkspace({ * workspaceId: "ws_...", * endpoint: "http://localhost:7700", * auth: { token: "..." } * }) * ``` */ export declare function connectDevelopmentWorkspace(options: WorkspaceConnectionOptions): Promise; /** * Development Workspace Connection * * Represents an active connection to a shared development workspace. * Provides methods to publish, subscribe, and query shared state. */ export declare class DevelopmentWorkspaceConnection { workspaceId: string; /** Canonical `feltdb dev` session identity, when supplied by pairing/session configuration. */ sessionId?: string; /** Canonical active runtime identity, when supplied by pairing/session configuration. */ runtimeInstanceId?: string; clientId: string; clientType: ClientType; private options; private subscriptions; connectedAt: number; private transport; private unsubscribeEvents; constructor(workspaceId: string, clientId: string, clientType: ClientType, options: WorkspaceConnectionOptions); /** * Establish connection to workspace */ connect(): Promise; /** * Close connection to workspace */ disconnect(): Promise; /** * Get capabilities for this client type */ private getCapabilities; /** * List connected clients in workspace */ clients(): Promise; /** * Subscribe to workspace entity changes * * Usage: * ``` * workspace.subscribe("development_task", (event) => { * console.log(`Task ${event.entityId}: ${event.type}`) * }) * ``` */ subscribe(collection: string, handler: (event: WorkspaceEventPayload) => void): () => void; /** * Publish entity to workspace * * Creates new entity in workspace collection. */ publish(collection: string, entity: T): Promise; /** * Get entity from workspace */ get(collection: string, entityId: string): Promise; /** * Query entities in workspace collection */ query(collection: string): Promise; /** Record a redacted canonical observation under its FeltDB observation id. */ recordRuntimeObservation(input: RuntimeObservationInput): Promise; getRuntimeObservation(observationId: string): Promise; /** Create the canonical shared-workspace investigation for an existing observation. */ createRuntimeInvestigation(input: CreateRuntimeInvestigationInput): Promise; getRuntimeInvestigation(investigationId: string): Promise; linkRuntimeObservationToInvestigation(observationId: string, investigationId: string): Promise; getRuntimeInvestigationForObservation(observationId: string): Promise; linkRuntimeInvestigation(input: { investigationId: string; changeId?: string; verificationId?: string; }): Promise; /** * Update entity in workspace */ update(collection: string, entityId: string, updates: Partial): Promise; /** * Notify subscribers of entity changes */ private notifySubscribers; private requireTransport; private resolveEndpoint; } //# sourceMappingURL=workspace-connection.d.ts.map