import { startOpenCodeServer, type OpenCodeServer } from "@sapiom/opencode"; import { type AssistantAccess, type AssistantAccessFailureCode } from "./assistant-access.js"; import { type OpenCodeTransportFailure } from "../shared/opencode-errors.js"; import type { OpenCodeBridge } from "../server/opencode-bridge.js"; import type { StudioProjectIdentity } from "@sapiom/agent-map/node/studio-project-catalog"; import type { OpenCodeObserver } from "./opencode-observer.js"; import { type AssistantObservation, type AssistantStateSnapshot } from "../shared/assistant-state.js"; type ObserverHandle = Pick; export interface OpenCodeWorkspace { harnessSessionId: string; cwd: string; } export interface HostedOpenCode extends OpenCodeWorkspace { model: { providerID: "sapiom"; modelID: string; }; stateRoot: string; server: OpenCodeServer; signal: AbortSignal; isCurrent: () => boolean; } interface Options { access: Pick; bridge: Pick; origin: () => string; stateRoot: string; authorize: (id: string) => Promise; start?: typeof startOpenCodeServer; now?: () => number; createObserver: (hosted: HostedOpenCode, id: string, update: (state: AssistantObservation) => void) => ObserverHandle; } export declare class OpenCodeTransportError extends Error { readonly failure: OpenCodeTransportFailure; constructor(failure: OpenCodeTransportFailure); } export declare class OpenCodeAccessError extends OpenCodeTransportError { constructor(message: string, code?: AssistantAccessFailureCode); } /** The project's map chat: an OpenCode host that is never a Studio session. */ export declare const mapChatHostKey: (projectId: string) => string; export declare const mapChatProjectId: (id: string) => string | null; /** A map chat with no request for this long stops its process (design Q4). */ export declare const mapChatIdleMs: number; /** A map chat runs at its project's first active root, or nowhere. */ export declare function authorizeMapChat(id: string, resolveProject: (projectId: string) => Promise): Promise; /** Owned by startServer, not by React mounts or browser connections. */ export declare class OpenCodeHost { private readonly options; private readonly hostInstanceId; private assistantRevision; private assistantAccess; private readonly summaries; private readonly assistantListeners; private entries; private closing; private closed; private cleanupFailed; private workspaceTimer; private unsubscribe; constructor(options: Options); /** Read derived state only; never start or inspect an inactive native runtime. */ getAssistantState(): AssistantStateSnapshot; subscribeAssistantState(listener: () => void): () => void; private assistantChanged; private syncAssistantAccess; /** Keeps a map chat's process alive until the returned release runs. */ hold(hosted: HostedOpenCode): () => void; /** * Stops map chats with no open request for mapChatIdleMs whose native * runtime is not still answering: a prompt_async returns on admission, so * an answer can outlive every request that holds the host. */ retireIdle(): Promise; /** Ends the current observation so a reset conversation can be observed. */ forget(hosted: HostedOpenCode): void; private now; private removeSummary; observe(hosted: HostedOpenCode, conversationId: string): void; ensure(id: string): Promise; retire(id: string, failure?: OpenCodeTransportFailure): Promise; close(): Promise; private workspace; private validate; private unlock; private start; private accessFailure; private accessError; } export {}; //# sourceMappingURL=opencode-host.d.ts.map