@langchain/langgraph-sdk 1.9.17 → 1.9.18
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.
- package/dist/stream/projections/channel.cjs +1 -0
- package/dist/stream/projections/channel.cjs.map +1 -1
- package/dist/stream/projections/channel.d.cts.map +1 -1
- package/dist/stream/projections/channel.d.ts.map +1 -1
- package/dist/stream/projections/channel.js +1 -0
- package/dist/stream/projections/channel.js.map +1 -1
- package/package.json +1 -1
|
@@ -38,6 +38,7 @@ function channelProjection(channels, namespace, options = {}) {
|
|
|
38
38
|
thread,
|
|
39
39
|
channels: chs,
|
|
40
40
|
namespace: ns,
|
|
41
|
+
resumeOnPause: true,
|
|
41
42
|
onEvent(event) {
|
|
42
43
|
const current = store.getSnapshot();
|
|
43
44
|
const next = current.length >= bufferSize ? [...current.slice(current.length - bufferSize + 1), event] : [...current, event];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"channel.cjs","names":["namespaceKey","isRootNamespace","openProjectionSubscription"],"sources":["../../../src/stream/projections/channel.ts"],"sourcesContent":["/**\n * Raw channel escape hatch.\n *\n * Subscribes to an arbitrary list of channels at an arbitrary\n * namespace and retains a bounded buffer of events.
|
|
1
|
+
{"version":3,"file":"channel.cjs","names":["namespaceKey","isRootNamespace","openProjectionSubscription"],"sources":["../../../src/stream/projections/channel.ts"],"sourcesContent":["/**\n * Raw channel escape hatch.\n *\n * Subscribes to an arbitrary list of channels at an arbitrary\n * namespace and retains a bounded buffer of events. The subscription\n * resumes across serial runs, so the buffer keeps accumulating events\n * for the lifetime of the thread (use `extensionProjection` instead when\n * you only need the most-recent payload of a single `custom:<name>`\n * channel). Consumers that need assembly semantics should use\n * `messagesProjection`, `toolCallsProjection`, etc. instead; this one is\n * for inspection, custom reducers, or niche use-cases.\n */\nimport type { Channel, Event } from \"@langchain/protocol\";\nimport type { ProjectionSpec, ProjectionRuntime } from \"../types.js\";\nimport { isRootNamespace, namespaceKey } from \"../namespace.js\";\nimport { openProjectionSubscription } from \"./runtime.js\";\n\n/** Max events retained per raw subscription. Older events are dropped. */\nconst DEFAULT_BUFFER = 4096;\n\nexport interface ChannelProjectionOptions {\n /**\n * Maximum number of events retained in the projection snapshot.\n * Defaults to 4096 so replay-backed discovery hooks can tolerate\n * bursty token/media streams without dropping early lifecycle events.\n */\n bufferSize?: number;\n /**\n * Whether to open a real subscription and receive replayed history.\n * Defaults to true. Set false for live-only root-bus inspection when\n * replay is unnecessary.\n */\n replay?: boolean;\n}\n\nexport function channelProjection(\n channels: readonly Channel[],\n namespace: readonly string[],\n options: ChannelProjectionOptions = {}\n): ProjectionSpec<Event[]> {\n const chs = [...channels].sort();\n const ns = [...namespace];\n const bufferSize = options.bufferSize ?? DEFAULT_BUFFER;\n const replay = options.replay ?? true;\n const key = `channel|${bufferSize}|${replay ? \"replay\" : \"live\"}|${chs.join(\",\")}|${namespaceKey(ns)}`;\n\n return {\n key,\n namespace: ns,\n initial: [],\n open({ thread, store, rootBus }): ProjectionRuntime {\n // If this projection is scoped to the root namespace AND every\n // requested channel is already covered by the controller's root\n // pump, attach to the shared fan-out instead of opening a\n // second server subscription. This is the common case for\n // lightweight event-trace / debug panels.\n const covered =\n !replay &&\n isRootNamespace(ns) &&\n chs.every((c) => rootBus.channels.includes(c));\n\n if (covered) {\n const requestedSet = new Set(chs as Channel[]);\n // Pre-compute `custom:<name>` sub-filters so incoming events\n // can be matched in O(1). The server delivers named custom\n // events as `{ method: \"custom\", params: { data: { name } } }`,\n // so matching purely on `event.method` would miss them — we\n // need to peek at `data.name` when the caller asked for a\n // specific `custom:<name>` channel.\n const namedCustom = new Set<string>();\n for (const channel of chs) {\n if (channel.startsWith(\"custom:\")) {\n namedCustom.add(channel.slice(\"custom:\".length));\n }\n }\n const matches = (event: Event): boolean => {\n if (requestedSet.has(event.method as Channel)) return true;\n if (event.method !== \"custom\" || namedCustom.size === 0) {\n return false;\n }\n const data = (event.params as Record<string, unknown>).data as\n | { name?: unknown }\n | undefined;\n return typeof data?.name === \"string\" && namedCustom.has(data.name);\n };\n const push = (event: Event): void => {\n if (!matches(event)) return;\n const current = store.getSnapshot();\n const next =\n current.length >= bufferSize\n ? [...current.slice(current.length - bufferSize + 1), event]\n : [...current, event];\n store.setValue(next);\n };\n const unsubscribe = rootBus.subscribe(push);\n return {\n dispose() {\n unsubscribe();\n },\n };\n }\n\n return openProjectionSubscription({\n thread,\n channels: chs as Channel[],\n namespace: ns,\n // Keep the buffer alive across serial runs. Some transports pause a\n // subscription on each run's terminal lifecycle event; without\n // resuming, the channel would go silent after the first run and a\n // second prompt on the same thread would emit no further events.\n resumeOnPause: true,\n onEvent(event) {\n const current = store.getSnapshot();\n const next =\n current.length >= bufferSize\n ? [...current.slice(current.length - bufferSize + 1), event]\n : [...current, event];\n store.setValue(next);\n },\n });\n },\n };\n}\n"],"mappings":";;;;AAkBA,MAAM,iBAAiB;AAiBvB,SAAgB,kBACd,UACA,WACA,UAAoC,EAAE,EACb;CACzB,MAAM,MAAM,CAAC,GAAG,SAAS,CAAC,MAAM;CAChC,MAAM,KAAK,CAAC,GAAG,UAAU;CACzB,MAAM,aAAa,QAAQ,cAAc;CACzC,MAAM,SAAS,QAAQ,UAAU;AAGjC,QAAO;EACL,KAHU,WAAW,WAAW,GAAG,SAAS,WAAW,OAAO,GAAG,IAAI,KAAK,IAAI,CAAC,GAAGA,kBAAAA,aAAa,GAAG;EAIlG,WAAW;EACX,SAAS,EAAE;EACX,KAAK,EAAE,QAAQ,OAAO,WAA8B;AAWlD,OAJE,CAAC,UACDC,kBAAAA,gBAAgB,GAAG,IACnB,IAAI,OAAO,MAAM,QAAQ,SAAS,SAAS,EAAE,CAAC,EAEnC;IACX,MAAM,eAAe,IAAI,IAAI,IAAiB;IAO9C,MAAM,8BAAc,IAAI,KAAa;AACrC,SAAK,MAAM,WAAW,IACpB,KAAI,QAAQ,WAAW,UAAU,CAC/B,aAAY,IAAI,QAAQ,MAAM,EAAiB,CAAC;IAGpD,MAAM,WAAW,UAA0B;AACzC,SAAI,aAAa,IAAI,MAAM,OAAkB,CAAE,QAAO;AACtD,SAAI,MAAM,WAAW,YAAY,YAAY,SAAS,EACpD,QAAO;KAET,MAAM,OAAQ,MAAM,OAAmC;AAGvD,YAAO,OAAO,MAAM,SAAS,YAAY,YAAY,IAAI,KAAK,KAAK;;IAErE,MAAM,QAAQ,UAAuB;AACnC,SAAI,CAAC,QAAQ,MAAM,CAAE;KACrB,MAAM,UAAU,MAAM,aAAa;KACnC,MAAM,OACJ,QAAQ,UAAU,aACd,CAAC,GAAG,QAAQ,MAAM,QAAQ,SAAS,aAAa,EAAE,EAAE,MAAM,GAC1D,CAAC,GAAG,SAAS,MAAM;AACzB,WAAM,SAAS,KAAK;;IAEtB,MAAM,cAAc,QAAQ,UAAU,KAAK;AAC3C,WAAO,EACL,UAAU;AACR,kBAAa;OAEhB;;AAGH,UAAOC,gBAAAA,2BAA2B;IAChC;IACA,UAAU;IACV,WAAW;IAKX,eAAe;IACf,QAAQ,OAAO;KACb,MAAM,UAAU,MAAM,aAAa;KACnC,MAAM,OACJ,QAAQ,UAAU,aACd,CAAC,GAAG,QAAQ,MAAM,QAAQ,SAAS,aAAa,EAAE,EAAE,MAAM,GAC1D,CAAC,GAAG,SAAS,MAAM;AACzB,WAAM,SAAS,KAAK;;IAEvB,CAAC;;EAEL"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"channel.d.cts","names":[],"sources":["../../../src/stream/projections/channel.ts"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"channel.d.cts","names":[],"sources":["../../../src/stream/projections/channel.ts"],"mappings":";;;;UAoBiB,wBAAA;EAmBd;;;;;EAbD,UAAA;EAYS;;;;;EANT,MAAA;AAAA;AAAA,iBAGc,iBAAA,CACd,QAAA,WAAmB,OAAA,IACnB,SAAA,qBACA,OAAA,GAAS,wBAAA,GACR,cAAA,CAAe,KAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"channel.d.ts","names":[],"sources":["../../../src/stream/projections/channel.ts"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"channel.d.ts","names":[],"sources":["../../../src/stream/projections/channel.ts"],"mappings":";;;;UAoBiB,wBAAA;EAmBd;;;;;EAbD,UAAA;EAYS;;;;;EANT,MAAA;AAAA;AAAA,iBAGc,iBAAA,CACd,QAAA,WAAmB,OAAA,IACnB,SAAA,qBACA,OAAA,GAAS,wBAAA,GACR,cAAA,CAAe,KAAA"}
|
|
@@ -38,6 +38,7 @@ function channelProjection(channels, namespace, options = {}) {
|
|
|
38
38
|
thread,
|
|
39
39
|
channels: chs,
|
|
40
40
|
namespace: ns,
|
|
41
|
+
resumeOnPause: true,
|
|
41
42
|
onEvent(event) {
|
|
42
43
|
const current = store.getSnapshot();
|
|
43
44
|
const next = current.length >= bufferSize ? [...current.slice(current.length - bufferSize + 1), event] : [...current, event];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"channel.js","names":[],"sources":["../../../src/stream/projections/channel.ts"],"sourcesContent":["/**\n * Raw channel escape hatch.\n *\n * Subscribes to an arbitrary list of channels at an arbitrary\n * namespace and retains a bounded buffer of events.
|
|
1
|
+
{"version":3,"file":"channel.js","names":[],"sources":["../../../src/stream/projections/channel.ts"],"sourcesContent":["/**\n * Raw channel escape hatch.\n *\n * Subscribes to an arbitrary list of channels at an arbitrary\n * namespace and retains a bounded buffer of events. The subscription\n * resumes across serial runs, so the buffer keeps accumulating events\n * for the lifetime of the thread (use `extensionProjection` instead when\n * you only need the most-recent payload of a single `custom:<name>`\n * channel). Consumers that need assembly semantics should use\n * `messagesProjection`, `toolCallsProjection`, etc. instead; this one is\n * for inspection, custom reducers, or niche use-cases.\n */\nimport type { Channel, Event } from \"@langchain/protocol\";\nimport type { ProjectionSpec, ProjectionRuntime } from \"../types.js\";\nimport { isRootNamespace, namespaceKey } from \"../namespace.js\";\nimport { openProjectionSubscription } from \"./runtime.js\";\n\n/** Max events retained per raw subscription. Older events are dropped. */\nconst DEFAULT_BUFFER = 4096;\n\nexport interface ChannelProjectionOptions {\n /**\n * Maximum number of events retained in the projection snapshot.\n * Defaults to 4096 so replay-backed discovery hooks can tolerate\n * bursty token/media streams without dropping early lifecycle events.\n */\n bufferSize?: number;\n /**\n * Whether to open a real subscription and receive replayed history.\n * Defaults to true. Set false for live-only root-bus inspection when\n * replay is unnecessary.\n */\n replay?: boolean;\n}\n\nexport function channelProjection(\n channels: readonly Channel[],\n namespace: readonly string[],\n options: ChannelProjectionOptions = {}\n): ProjectionSpec<Event[]> {\n const chs = [...channels].sort();\n const ns = [...namespace];\n const bufferSize = options.bufferSize ?? DEFAULT_BUFFER;\n const replay = options.replay ?? true;\n const key = `channel|${bufferSize}|${replay ? \"replay\" : \"live\"}|${chs.join(\",\")}|${namespaceKey(ns)}`;\n\n return {\n key,\n namespace: ns,\n initial: [],\n open({ thread, store, rootBus }): ProjectionRuntime {\n // If this projection is scoped to the root namespace AND every\n // requested channel is already covered by the controller's root\n // pump, attach to the shared fan-out instead of opening a\n // second server subscription. This is the common case for\n // lightweight event-trace / debug panels.\n const covered =\n !replay &&\n isRootNamespace(ns) &&\n chs.every((c) => rootBus.channels.includes(c));\n\n if (covered) {\n const requestedSet = new Set(chs as Channel[]);\n // Pre-compute `custom:<name>` sub-filters so incoming events\n // can be matched in O(1). The server delivers named custom\n // events as `{ method: \"custom\", params: { data: { name } } }`,\n // so matching purely on `event.method` would miss them — we\n // need to peek at `data.name` when the caller asked for a\n // specific `custom:<name>` channel.\n const namedCustom = new Set<string>();\n for (const channel of chs) {\n if (channel.startsWith(\"custom:\")) {\n namedCustom.add(channel.slice(\"custom:\".length));\n }\n }\n const matches = (event: Event): boolean => {\n if (requestedSet.has(event.method as Channel)) return true;\n if (event.method !== \"custom\" || namedCustom.size === 0) {\n return false;\n }\n const data = (event.params as Record<string, unknown>).data as\n | { name?: unknown }\n | undefined;\n return typeof data?.name === \"string\" && namedCustom.has(data.name);\n };\n const push = (event: Event): void => {\n if (!matches(event)) return;\n const current = store.getSnapshot();\n const next =\n current.length >= bufferSize\n ? [...current.slice(current.length - bufferSize + 1), event]\n : [...current, event];\n store.setValue(next);\n };\n const unsubscribe = rootBus.subscribe(push);\n return {\n dispose() {\n unsubscribe();\n },\n };\n }\n\n return openProjectionSubscription({\n thread,\n channels: chs as Channel[],\n namespace: ns,\n // Keep the buffer alive across serial runs. Some transports pause a\n // subscription on each run's terminal lifecycle event; without\n // resuming, the channel would go silent after the first run and a\n // second prompt on the same thread would emit no further events.\n resumeOnPause: true,\n onEvent(event) {\n const current = store.getSnapshot();\n const next =\n current.length >= bufferSize\n ? [...current.slice(current.length - bufferSize + 1), event]\n : [...current, event];\n store.setValue(next);\n },\n });\n },\n };\n}\n"],"mappings":";;;;AAkBA,MAAM,iBAAiB;AAiBvB,SAAgB,kBACd,UACA,WACA,UAAoC,EAAE,EACb;CACzB,MAAM,MAAM,CAAC,GAAG,SAAS,CAAC,MAAM;CAChC,MAAM,KAAK,CAAC,GAAG,UAAU;CACzB,MAAM,aAAa,QAAQ,cAAc;CACzC,MAAM,SAAS,QAAQ,UAAU;AAGjC,QAAO;EACL,KAHU,WAAW,WAAW,GAAG,SAAS,WAAW,OAAO,GAAG,IAAI,KAAK,IAAI,CAAC,GAAG,aAAa,GAAG;EAIlG,WAAW;EACX,SAAS,EAAE;EACX,KAAK,EAAE,QAAQ,OAAO,WAA8B;AAWlD,OAJE,CAAC,UACD,gBAAgB,GAAG,IACnB,IAAI,OAAO,MAAM,QAAQ,SAAS,SAAS,EAAE,CAAC,EAEnC;IACX,MAAM,eAAe,IAAI,IAAI,IAAiB;IAO9C,MAAM,8BAAc,IAAI,KAAa;AACrC,SAAK,MAAM,WAAW,IACpB,KAAI,QAAQ,WAAW,UAAU,CAC/B,aAAY,IAAI,QAAQ,MAAM,EAAiB,CAAC;IAGpD,MAAM,WAAW,UAA0B;AACzC,SAAI,aAAa,IAAI,MAAM,OAAkB,CAAE,QAAO;AACtD,SAAI,MAAM,WAAW,YAAY,YAAY,SAAS,EACpD,QAAO;KAET,MAAM,OAAQ,MAAM,OAAmC;AAGvD,YAAO,OAAO,MAAM,SAAS,YAAY,YAAY,IAAI,KAAK,KAAK;;IAErE,MAAM,QAAQ,UAAuB;AACnC,SAAI,CAAC,QAAQ,MAAM,CAAE;KACrB,MAAM,UAAU,MAAM,aAAa;KACnC,MAAM,OACJ,QAAQ,UAAU,aACd,CAAC,GAAG,QAAQ,MAAM,QAAQ,SAAS,aAAa,EAAE,EAAE,MAAM,GAC1D,CAAC,GAAG,SAAS,MAAM;AACzB,WAAM,SAAS,KAAK;;IAEtB,MAAM,cAAc,QAAQ,UAAU,KAAK;AAC3C,WAAO,EACL,UAAU;AACR,kBAAa;OAEhB;;AAGH,UAAO,2BAA2B;IAChC;IACA,UAAU;IACV,WAAW;IAKX,eAAe;IACf,QAAQ,OAAO;KACb,MAAM,UAAU,MAAM,aAAa;KACnC,MAAM,OACJ,QAAQ,UAAU,aACd,CAAC,GAAG,QAAQ,MAAM,QAAQ,SAAS,aAAa,EAAE,EAAE,MAAM,GAC1D,CAAC,GAAG,SAAS,MAAM;AACzB,WAAM,SAAS,KAAK;;IAEvB,CAAC;;EAEL"}
|