import { ThreadStream } from "../client/stream/index.cjs";
import { StreamStore } from "./store.cjs";
import { RootSnapshot, StreamControllerOptions, StreamSubmitOptions } from "./types.cjs";
import { ChannelRegistry } from "./channel-registry.cjs";
import { SubagentMap } from "./discovery/subagents.cjs";
import { SubgraphByNodeMap, SubgraphMap } from "./discovery/subgraphs.cjs";
import { MessageMetadata as MessageMetadata$1, MessageMetadataMap } from "./message-metadata-tracker.cjs";
import { SubmissionQueueEntry, SubmissionQueueSnapshot } from "./submit-coordinator.cjs";
import { Channel } from "@langchain/protocol";

//#region src/stream/controller.d.ts
/**
 * Channel set covered by the always-on root subscription. Exported so
 * projections (and transports) can reason about what the root pump
 * already delivers before opening additional server subscriptions.
 */
declare const ROOT_PUMP_CHANNELS: readonly Channel[];
/**
 * Coordinates one thread's protocol-v2 stream and exposes stable
 * observable projections for framework bindings.
 *
 * The controller owns the root subscription, lazily binds scoped
 * projections through {@link ChannelRegistry}, and normalizes protocol
 * events into class-message, tool-call, discovery, interrupt, and queue
 * stores.
 *
 * @typeParam StateType - Shape of the graph state exposed on `values`.
 * @typeParam InterruptType - Shape of protocol interrupt payloads.
 * @typeParam ConfigurableType - Shape of `config.configurable` accepted by submit.
 */
declare class StreamController<StateType extends object = Record<string, unknown>, InterruptType = unknown, ConfigurableType extends object = Record<string, unknown>> {
  #private;
  readonly rootStore: StreamStore<RootSnapshot<StateType, InterruptType>>;
  readonly subagentStore: StreamStore<SubagentMap>;
  readonly subgraphStore: StreamStore<SubgraphMap>;
  readonly subgraphByNodeStore: StreamStore<SubgraphByNodeMap>;
  readonly messageMetadataStore: StreamStore<MessageMetadataMap>;
  readonly queueStore: StreamStore<SubmissionQueueSnapshot<StateType>>;
  readonly registry: ChannelRegistry;
  /**
   * Create a controller around a LangGraph client and optional initial thread.
   *
   * @param options - Runtime configuration, client, thread id, and initial state.
   */
  constructor(options: StreamControllerOptions<StateType>);
  /**
   * Promise that settles the first time {@link hydrate} finishes on
   * the current thread. Resolves on a clean hydration, rejects when
   * the thread-state fetch errors. A fresh promise is installed on
   * every thread swap so `<Suspense>` wrappers re-suspend on
   * `switchThread`.
   */
  get hydrationPromise(): Promise<void>;
  /**
   * Fetch the checkpointed thread state and seed the root snapshot.
   * Re-calling with a different `threadId` swaps the underlying
   * {@link ThreadStream}, rewires the registry to the new thread, and
   * resets assemblers.
   *
   * @param threadId - Optional replacement thread id; `null` clears the active thread.
   */
  hydrate(threadId?: string | null): Promise<void>;
  /**
   * Submit input or a resume command to the active thread.
   *
   * @param input - Input payload for a new run; `null`/`undefined` submits no input.
   * @param options - Per-run config, metadata, multitask behavior, and callbacks.
   */
  submit(input: unknown, options?: StreamSubmitOptions<StateType, ConfigurableType>): Promise<void>;
  /**
   * Abort the currently tracked run and mark the controller idle.
   */
  stop(): Promise<void>;
  /**
   * Cancel a queued submission by id. Returns `true` when the entry
   * was found and removed, `false` otherwise.
   *
   * Today this only removes the entry from the client-side mirror —
   * once the server exposes queue cancel (roadmap A0.3) the
   * controller will additionally issue a cancel call against the
   * active transport.
   *
   * @param id - Client-side queue entry id to remove.
   */
  cancelQueued(id: string): Promise<boolean>;
  /**
   * Drop every queued submission. Server-side cancel arrives with A0.3.
   */
  clearQueue(): Promise<void>;
  /**
   * Respond to a pending protocol interrupt.
   *
   * @param response - Payload to send back to the interrupted namespace.
   * @param target - Optional explicit interrupt id and namespace; defaults to the latest unresolved interrupt.
   */
  respond(response: unknown, target?: {
    interruptId: string;
    namespace?: string[];
  }): Promise<void>;
  /**
   * Dispose the active thread, subscriptions, registry entries, and listeners.
   */
  dispose(): Promise<void>;
  /**
   * StrictMode-safe lifecycle hook for framework bindings.
   *
   * React 18+ `StrictMode` intentionally mounts → unmounts → remounts
   * components in dev to surface effect-cleanup bugs. A naive
   * `useEffect(() => () => controller.dispose())` would permanently
   * tear the controller down on that first synthetic unmount, leaving
   * every subsequent `submit()` a silent no-op.
   *
   * Call {@link activate} from the bind site's effect and return the
   * result as the effect's cleanup. The controller uses deferred
   * disposal: a `release()` only schedules a dispose on the next
   * microtask, which is cancelled if another `activate()` arrives
   * before it fires (the normal StrictMode remount path).
   */
  activate(): () => void;
  /**
   * Returns the bound {@link ThreadStream}, if one exists. Prefer
   * {@link StreamController.rootStore} and selector projections for
   * UI work; use this for low-level protocol access.
   */
  getThread(): ThreadStream | undefined;
  /**
   * Listen for `ThreadStream` lifecycle (swap on thread-id change,
   * detach on dispose). The listener fires immediately with the
   * current thread (may be `undefined`).
   *
   * @param listener - Callback invoked immediately and on every thread swap.
   */
  subscribeThread(listener: (thread: ThreadStream | undefined) => void): () => void;
}
//#endregion
export { ROOT_PUMP_CHANNELS, StreamController };
//# sourceMappingURL=controller.d.cts.map