@langchain/langgraph-api 1.2.2 → 1.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/dist/experimental/embed/protocol.mjs +86 -15
  2. package/dist/graph/load.d.mts +1 -1
  3. package/dist/graph/load.utils.d.mts +1 -1
  4. package/dist/protocol/service.d.mts +9 -1
  5. package/dist/protocol/service.mjs +65 -25
  6. package/package.json +7 -7
  7. package/dist/src/api/assistants.d.mts +0 -3
  8. package/dist/src/api/assistants.mjs +0 -194
  9. package/dist/src/api/meta.d.mts +0 -3
  10. package/dist/src/api/meta.mjs +0 -65
  11. package/dist/src/api/protocol.d.mts +0 -7
  12. package/dist/src/api/protocol.mjs +0 -157
  13. package/dist/src/api/runs.d.mts +0 -3
  14. package/dist/src/api/runs.mjs +0 -335
  15. package/dist/src/api/store.d.mts +0 -3
  16. package/dist/src/api/store.mjs +0 -111
  17. package/dist/src/api/threads.d.mts +0 -3
  18. package/dist/src/api/threads.mjs +0 -143
  19. package/dist/src/graph/load.utils.d.mts +0 -22
  20. package/dist/src/graph/load.utils.mjs +0 -59
  21. package/dist/src/protocol/service.d.mts +0 -101
  22. package/dist/src/protocol/service.mjs +0 -568
  23. package/dist/src/protocol/session/event-normalizers.d.mts +0 -52
  24. package/dist/src/protocol/session/index.d.mts +0 -261
  25. package/dist/src/protocol/session/index.mjs +0 -826
  26. package/dist/src/protocol/session/namespace.d.mts +0 -47
  27. package/dist/src/protocol/session/namespace.mjs +0 -62
  28. package/dist/src/protocol/types.d.mts +0 -121
  29. package/dist/src/protocol/types.mjs +0 -1
  30. package/dist/src/schemas.d.mts +0 -1552
  31. package/dist/src/semver/index.d.mts +0 -15
  32. package/dist/src/semver/index.mjs +0 -46
  33. package/dist/src/semver/satisfiesPeerRange.d.mts +0 -1
  34. package/dist/src/semver/satisfiesPeerRange.mjs +0 -19
  35. package/dist/src/state.d.mts +0 -3
  36. package/dist/src/state.mjs +0 -30
  37. package/dist/src/storage/context.d.mts +0 -3
  38. package/dist/src/storage/context.mjs +0 -11
  39. package/dist/src/storage/ops.mjs +0 -1281
  40. package/dist/src/stream.d.mts +0 -64
  41. package/dist/src/stream.mjs +0 -427
  42. package/dist/src/utils/hono.d.mts +0 -5
  43. package/dist/src/utils/hono.mjs +0 -24
  44. package/dist/src/utils/runnableConfig.d.mts +0 -3
  45. package/dist/src/utils/runnableConfig.mjs +0 -45
  46. package/dist/src/webhook.d.mts +0 -11
  47. package/dist/src/webhook.mjs +0 -30
@@ -1,47 +0,0 @@
1
- import type { Namespace } from "../types.mjs";
2
- /**
3
- * Converts a namespace array into a stable internal lookup key.
4
- *
5
- * @param namespace - Namespace segments to encode.
6
- * @returns A string key that preserves segment boundaries.
7
- */
8
- export declare const toNamespaceKey: (namespace: Namespace) => string;
9
- /**
10
- * Strips dynamic suffixes from a namespace segment for display purposes.
11
- *
12
- * @param segment - Raw namespace segment.
13
- * @returns The stable graph-oriented portion of the segment.
14
- */
15
- export declare const normalizeNamespaceSegment: (segment: string) => string;
16
- /**
17
- * Preserves raw namespace segments in protocol events.
18
- *
19
- * @param namespace - Namespace segments parsed from the source event.
20
- * @returns The namespace exactly as it should be exposed to clients.
21
- */
22
- export declare const normalizeNamespace: (namespace: string[]) => Namespace;
23
- /**
24
- * Splits a stream event name into its method and namespace components.
25
- *
26
- * @param event - Raw event name emitted by the source stream.
27
- * @returns The parsed method plus namespace segments.
28
- */
29
- export declare const parseEventName: (event: string) => {
30
- method: string;
31
- namespace: string[];
32
- };
33
- /**
34
- * Checks whether a namespace starts with a requested prefix.
35
- *
36
- * @param namespace - Event namespace to test.
37
- * @param prefix - Subscription namespace prefix.
38
- * @returns Whether the namespace matches the prefix semantics.
39
- */
40
- export declare const isPrefixMatch: (namespace: Namespace, prefix: Namespace) => boolean;
41
- /**
42
- * Guesses a human-readable graph name from a namespace.
43
- *
44
- * @param namespace - Namespace segments for a graph or subgraph.
45
- * @returns The derived graph name, or `root` when no segments exist.
46
- */
47
- export declare const guessGraphName: (namespace: Namespace) => string;
@@ -1,62 +0,0 @@
1
- /**
2
- * Converts a namespace array into a stable internal lookup key.
3
- *
4
- * @param namespace - Namespace segments to encode.
5
- * @returns A string key that preserves segment boundaries.
6
- */
7
- export const toNamespaceKey = (namespace) => namespace.join("\0");
8
- /**
9
- * Strips dynamic suffixes from a namespace segment for display purposes.
10
- *
11
- * @param segment - Raw namespace segment.
12
- * @returns The stable graph-oriented portion of the segment.
13
- */
14
- export const normalizeNamespaceSegment = (segment) => segment.split(":")[0];
15
- /**
16
- * Preserves raw namespace segments in protocol events.
17
- *
18
- * @param namespace - Namespace segments parsed from the source event.
19
- * @returns The namespace exactly as it should be exposed to clients.
20
- */
21
- export const normalizeNamespace = (namespace) => namespace;
22
- /**
23
- * Splits a stream event name into its method and namespace components.
24
- *
25
- * @param event - Raw event name emitted by the source stream.
26
- * @returns The parsed method plus namespace segments.
27
- */
28
- export const parseEventName = (event) => {
29
- const [method, ...namespace] = event.split("|");
30
- return { method, namespace };
31
- };
32
- /**
33
- * Checks whether a namespace starts with a requested prefix.
34
- *
35
- * @param namespace - Event namespace to test.
36
- * @param prefix - Subscription namespace prefix.
37
- * @returns Whether the namespace matches the prefix semantics.
38
- */
39
- export const isPrefixMatch = (namespace, prefix) => {
40
- if (prefix.length > namespace.length)
41
- return false;
42
- return prefix.every((segment, index) => {
43
- const candidate = namespace[index];
44
- if (candidate === segment)
45
- return true;
46
- if (segment.includes(":"))
47
- return false;
48
- return normalizeNamespaceSegment(candidate) === segment;
49
- });
50
- };
51
- /**
52
- * Guesses a human-readable graph name from a namespace.
53
- *
54
- * @param namespace - Namespace segments for a graph or subgraph.
55
- * @returns The derived graph name, or `root` when no segments exist.
56
- */
57
- export const guessGraphName = (namespace) => {
58
- const last = namespace.at(-1);
59
- if (last == null)
60
- return "root";
61
- return normalizeNamespaceSegment(last);
62
- };
@@ -1,121 +0,0 @@
1
- import type { AgentResult, AgentStatus, AgentTreeNode, Channel, Checkpoint, CheckpointSource, Command, CommandResponse, ContentBlockDeltaData, ContentBlockFinishData, ContentBlockStartData, CustomData, ErrorCode, ErrorResponse, Event, LifecycleCause, MessageErrorData, MessageFinishData, MessageMetadata, MessageStartData, MessagesData, Namespace, ResponseMeta, RunStartParams, RunResult, StateGetResult, SubscribeParams, SubscribeResult, ToolErrorData, ToolFinishedData, ToolOutputDeltaData, ToolStartedData, ToolsData, UnsubscribeParams, UpdatesEvent } from "@langchain/protocol";
2
- export type { LifecycleCause };
3
- import type { AuthContext } from "../auth/index.mjs";
4
- import type { RunProtocolSession } from "./session/index.mjs";
5
- /**
6
- * Raw events emitted by the existing LangGraph run stream implementation
7
- * before they are normalized into protocol-framed events.
8
- *
9
- * The session emits two independent events per persisted checkpoint:
10
- * - `event: "values"` carries the full state snapshot on the `values`
11
- * protocol channel.
12
- * - `event: "checkpoints"` carries the lightweight {@link Checkpoint}
13
- * envelope on the dedicated `checkpoints` channel, paired with the
14
- * adjacent `values` event by `(namespace, step)` so fork/time-travel
15
- * UIs can subscribe without also paying for full-state payloads.
16
- *
17
- * When {@link normalized} is `true` the payload has already been converted
18
- * to its protocol shape by the in-process streaming layer
19
- * (`streamEvents(..., { version: "v3" })`) and should be passed through
20
- * without re-normalization.
21
- */
22
- export type SourceStreamEvent = {
23
- id?: string;
24
- event: string;
25
- data: unknown;
26
- normalized?: boolean;
27
- };
28
- /**
29
- * Transport profiles currently exposed by the LangGraph API implementation.
30
- */
31
- export type ProtocolTransportName = "websocket" | "sse-http";
32
- export type SupportedChannel = Extract<Channel, "values" | "updates" | "checkpoints" | "messages" | "tools" | "custom" | "lifecycle" | "input" | "tasks">;
33
- export type EventMethodByChannel = {
34
- values: "values";
35
- updates: "updates";
36
- checkpoints: "checkpoints";
37
- messages: "messages";
38
- tools: "tools";
39
- custom: "custom";
40
- lifecycle: "lifecycle";
41
- input: "input.requested";
42
- tasks: "tasks";
43
- };
44
- export type ProtocolResponseMeta = ResponseMeta;
45
- export type ProtocolSuccess = CommandResponse;
46
- export type ProtocolError = ErrorResponse;
47
- export type ProtocolEvent = Event;
48
- export type ProtocolCommand = Command;
49
- export type ProtocolCommandByMethod<Method extends ProtocolCommand["method"]> = Extract<ProtocolCommand, {
50
- method: Method;
51
- }>;
52
- export type ProtocolEventByMethod<Method extends SupportedChannel> = Extract<ProtocolEvent, {
53
- method: EventMethodByChannel[Method];
54
- }>;
55
- export type ProtocolEventDataByMethod<Method extends SupportedChannel> = ProtocolEventByMethod<Method>["params"]["data"];
56
- export type { AgentResult, AgentStatus, AgentTreeNode, Checkpoint, CheckpointSource, ContentBlockDeltaData, ContentBlockFinishData, ContentBlockStartData, CustomData, ErrorCode, MessageErrorData, MessageFinishData, MessageMetadata, MessagesData, MessageStartData, Namespace, RunStartParams, RunResult, StateGetResult, SubscribeParams, SubscribeResult, ToolErrorData, ToolFinishedData, ToolOutputDeltaData, ToolStartedData, ToolsData, UnsubscribeParams, UpdatesEvent, };
57
- /**
58
- * Per-connection filter for SSE event sinks.
59
- *
60
- * Each SSE `POST .../events` connection carries its own filter so the server
61
- * can deliver only matching events without persisting subscription state.
62
- */
63
- export type EventSinkFilter = {
64
- channels: Set<string>;
65
- namespaces?: string[][];
66
- depth?: number;
67
- since?: number;
68
- };
69
- /**
70
- * A single SSE event sink attached to a thread.
71
- *
72
- * `pendingReplay` is true while {@link ProtocolService.attachFilteredEventSink}
73
- * is draining buffered events into this sink. While true, the live `send`
74
- * callback must skip this sink so that the replay loop — not the live path —
75
- * owns strict in-order delivery.
76
- */
77
- export type EventSinkEntry = {
78
- id: string;
79
- filter: EventSinkFilter;
80
- send: (message: ProtocolEvent) => Promise<void> | void;
81
- pendingReplay?: boolean;
82
- };
83
- /**
84
- * Runtime state tracked for an active thread connection.
85
- *
86
- * In the thread-centric protocol, threads are durable but ephemeral
87
- * connection state lives here: the active run session, attached SSE
88
- * sinks, and a queue of events waiting for a sink.
89
- */
90
- export type ThreadRecord = {
91
- threadId: string;
92
- transport: ProtocolTransportName;
93
- auth?: AuthContext;
94
- assistantId?: string;
95
- seq: number;
96
- session?: RunProtocolSession;
97
- currentRunId?: string;
98
- /** WebSocket-only: single event delivery callback. */
99
- sendEvent?: ((message: ProtocolEvent) => Promise<void> | void) | undefined;
100
- /** SSE: per-connection filtered event sinks. */
101
- eventSinks: Map<string, EventSinkEntry>;
102
- /** Events buffered when no sink is attached yet. */
103
- queuedEvents: ProtocolEvent[];
104
- /** WebSocket-only: subscription commands replayed on new run sessions. */
105
- activeSubscriptions: ProtocolCommand[];
106
- /**
107
- * WebSocket-only: subscribes that arrived before a run session was bound.
108
- *
109
- * The SDK opens its root-pump subscription (and legacy lifecycle/values
110
- * subs) eagerly on thread creation so that no events are missed on fast
111
- * runs. On WebSocket those subscribes can race ahead of the concurrent
112
- * `run.start` and hit the service before `ensureRunSession` has bound a
113
- * session. Rather than rejecting them with `no_such_run`, we park each
114
- * command's response promise here and resolve it once the first session
115
- * is bound — mirroring the cross-run `activeSubscriptions` replay path.
116
- */
117
- pendingSubscribes: Array<{
118
- command: ProtocolCommand;
119
- resolve: (response: ProtocolSuccess | ProtocolError | null) => void;
120
- }>;
121
- };
@@ -1 +0,0 @@
1
- export {};