@threadplane/langgraph 0.0.50 → 0.0.52

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@threadplane/langgraph",
3
- "version": "0.0.50",
3
+ "version": "0.0.52",
4
4
  "description": "LangGraph adapter for @threadplane/chat — Angular bindings for LangGraph Platform.",
5
5
  "keywords": [
6
6
  "angular",
@@ -4,7 +4,7 @@ import { BaseMessage, AIMessage } from '@langchain/core/messages';
4
4
  import * as _langchain_langgraph_sdk from '@langchain/langgraph-sdk';
5
5
  import { ThreadState, Config, Checkpoint, Command, Metadata, StreamMode, BagTemplate, Interrupt, ToolCallWithResult, ToolProgress, Client } from '@langchain/langgraph-sdk';
6
6
  export { BagTemplate, InferBag, Interrupt, ThreadState } from '@langchain/langgraph-sdk';
7
- import { AgentRuntimeTelemetrySink, AgentWithHistory, AgentSubmitInput, AgentSubmitOptions, ClientToolsCapability, Message, AgentStatus, ToolCall, AgentInterrupt, Subagent, AgentCheckpoint, MockAgent, MockAgentOptions, Citation, Thread } from '@threadplane/chat';
7
+ import { AgentRuntimeTelemetrySink, AgentWithHistory, AgentSubmitInput, AgentSubmitOptions, ClientToolsCapability, AgentRef, Message, AgentStatus, AgentError, ToolCall, AgentInterrupt, Subagent, AgentCheckpoint, MockAgent, MockAgentOptions, Citation, Thread } from '@threadplane/chat';
8
8
  import { MessageMetadata } from '@langchain/langgraph-sdk/ui';
9
9
  export { SubmitOptions } from '@langchain/langgraph-sdk/ui';
10
10
  import { FakeAgentConfig } from '@threadplane/chat/testing';
@@ -230,7 +230,7 @@ interface SubagentStreamRef {
230
230
  * any LangGraph-specific demo. Raw LangGraph signals are prefixed with
231
231
  * `langGraph` to avoid collision with the runtime-neutral names.
232
232
  */
233
- interface LangGraphAgent<T = unknown, ResolvedBag extends BagTemplate = BagTemplate> extends AgentWithHistory {
233
+ interface LangGraphAgent<T = unknown, ResolvedBag extends BagTemplate = BagTemplate> extends AgentWithHistory<T> {
234
234
  /** Raw LangChain BaseMessage list. Use `messages` for chat rendering. */
235
235
  langGraphMessages: Signal<BaseMessage[]>;
236
236
  /** All interrupts received during the current run (raw LangGraph shape). */
@@ -351,8 +351,13 @@ interface AgentConfig<T = Record<string, unknown>, _Bag extends BagTemplate = Ba
351
351
  * config is known up front. Pass a `() => AgentConfig` factory when the config
352
352
  * depends on runtime/DI state — the factory runs inside an Angular injection
353
353
  * context, so it may call `inject()` to read services, route params, or
354
- * component-scoped signals:
354
+ * component-scoped signals.
355
355
  *
356
+ * **Typed state via AgentRef.** Pass a typed ref as the first argument to flow
357
+ * the state shape from `provideAgent` to `injectAgent` without repeating the
358
+ * generic at every call site.
359
+ *
360
+ * @example Factory config reading route params
356
361
  * ```ts
357
362
  * providers: [
358
363
  * provideAgent(() => {
@@ -361,7 +366,16 @@ interface AgentConfig<T = Record<string, unknown>, _Bag extends BagTemplate = Ba
361
366
  * }),
362
367
  * ];
363
368
  * ```
369
+ * @example Typed state via AgentRef
370
+ * ```ts
371
+ * export const TRIP = createAgentRef<TripState>('trip');
372
+ * // app.config.ts:
373
+ * providers: [provideAgent(TRIP, { assistantId: 'trip-graph' })]
374
+ * // component:
375
+ * const agent = injectAgent(TRIP); // LangGraphAgent<TripState>
376
+ * ```
364
377
  */
378
+ declare function provideAgent<T = Record<string, unknown>>(ref: AgentRef<T>, configOrFactory: AgentConfig<T> | (() => AgentConfig<T>)): Provider[];
365
379
  declare function provideAgent<T = Record<string, unknown>>(configOrFactory: AgentConfig<T> | (() => AgentConfig<T>)): Provider[];
366
380
 
367
381
  /**
@@ -372,8 +386,19 @@ declare function provideAgent<T = Record<string, unknown>>(configOrFactory: Agen
372
386
  * singleton scoped to the injector that called `provideAgent()` — re-provide
373
387
  * in a child component's `providers: []` to scope a different agent to that
374
388
  * subtree (Angular's hierarchical DI handles the rest).
389
+ *
390
+ * **Typed state via AgentRef.** Pass the same ref that was supplied to
391
+ * `provideAgent(ref, …)` to carry the state type through DI without repeating
392
+ * the generic at every call site. The no-arg form defaults to
393
+ * `LangGraphAgent<Record<string, unknown>>`.
394
+ *
395
+ * @example Typed state via AgentRef
396
+ * ```ts
397
+ * const agent = injectAgent(TRIP); // LangGraphAgent<TripState>
398
+ * ```
375
399
  */
376
- declare function injectAgent<T = Record<string, unknown>, ResolvedBag extends BagTemplate = BagTemplate>(): LangGraphAgent<T, ResolvedBag>;
400
+ declare function injectAgent(): LangGraphAgent<Record<string, unknown>>;
401
+ declare function injectAgent<T, ResolvedBag extends BagTemplate = BagTemplate>(ref: AgentRef<T>): LangGraphAgent<T, ResolvedBag>;
377
402
 
378
403
  /**
379
404
  * Optional registry that collects per-instance agent lifecycles within
@@ -504,7 +529,7 @@ interface MockLangGraphAgent extends LangGraphAgent<any, any> {
504
529
  messages: WritableSignal<Message[]>;
505
530
  status: WritableSignal<AgentStatus>;
506
531
  isLoading: WritableSignal<boolean>;
507
- error: WritableSignal<unknown>;
532
+ error: WritableSignal<AgentError | undefined>;
508
533
  toolCalls: WritableSignal<ToolCall[]>;
509
534
  interrupt: WritableSignal<AgentInterrupt | undefined>;
510
535
  subagents: WritableSignal<Map<string, Subagent>>;
@@ -574,6 +599,19 @@ declare class FakeStreamTransport implements AgentTransport {
574
599
  interface KwargsLike {
575
600
  additional_kwargs?: Record<string, unknown> | undefined;
576
601
  }
602
+ /**
603
+ * Normalize {@link Citation}s out of a message's `additional_kwargs` (reading
604
+ * `citations` or `sources`). Exposed for advanced consumers building custom
605
+ * adapters or bridging non-LangGraph message shapes into the neutral
606
+ * `Citation[]` form.
607
+ *
608
+ * @param msg Any object with an `additional_kwargs` bag (e.g. a LangChain message).
609
+ * @returns The normalized citations, or `undefined` when none are present.
610
+ * @example
611
+ * ```ts
612
+ * const citations = extractCitations(lcMessage);
613
+ * ```
614
+ */
577
615
  declare function extractCitations(msg: KwargsLike): Citation[] | undefined;
578
616
 
579
617
  /**