UNPKG

@langchain/langgraph-sdk

Version:

Client library for interacting with the LangGraph API

54 lines (53 loc) • 2.44 kB
import { StreamStore } from "../store.cjs"; import { SubagentDiscoverySnapshot } from "../types.cjs"; import { Event } from "@langchain/protocol"; //#region src/stream/discovery/subagents.d.ts type SubagentMap = ReadonlyMap<string, SubagentDiscoverySnapshot>; declare class SubagentDiscovery { #private; readonly store: StreamStore<SubagentMap>; /** Feed a single root event. Non-discovery events are ignored. */ push(event: Event): void; /** * Seed discovery from a checkpoint's root `messages` array (as * returned by `client.threads.getState().values.messages`) so deep * agent cards render on thread refresh without waiting for SSE * replay. * * Drives the existing root `values` path via a synthetic event so it * reuses task discovery + completion marking with no new parsing * logic. Root namespace `[]` keeps namespaces at the default * `tools:<toolCallId>`; the always-on root pump (and {@link * applyExecutionNamespace}) promote them to the execution namespace * later. Idempotent by construction: re-driving root values for * already-discovered tasks is a no-op (the FIFO `taskInput` queue is * only populated on first discovery), so no `snapshot.size` guard is * needed. */ seedFromCheckpointMessages(messages: unknown[]): void; /** * Promote a discovered subagent to its execution namespace, derived * from checkpoint history (see `namespace-from-history`). * * Routes through the same guarded promotion machinery the live SSE * replay uses ({@link #recordTaskNamespaceCandidate} + the * `#observedOwnNamespaces` no-demote rule) so a getHistory-derived * namespace and an SSE-derived one cannot disagree. A no-op when the * subagent is unknown or already sits on the target namespace. * * @param toolCallId - Parent `task` tool-call id (the subagent's discovery key). * @param executionSegment - Single execution namespace segment, e.g. `tools:<uuid>`. */ applyExecutionNamespace(toolCallId: string, executionSegment: string): void; /** Current snapshot map. */ get snapshot(): SubagentMap; /** * Drop all discovery state. Called on thread rebind / dispose so a * new thread's subagents cannot bleed into the previous UI. */ reset(): void; discoverFromMessage(message: unknown, namespace: readonly string[]): void; } //#endregion export { SubagentDiscovery, SubagentMap }; //# sourceMappingURL=subagents.d.cts.map