@threadplane/langgraph 0.0.46

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/README.md ADDED
@@ -0,0 +1,92 @@
1
+ # @threadplane/langgraph
2
+
3
+ Adapter that wraps a LangGraph agent into the runtime-neutral `Agent` contract from `@threadplane/chat`. The Angular equivalent of LangGraph's React `useStream()` hook — signal-driven access to messages, status, tool calls, interrupts, subagents, regenerate, and thread history.
4
+
5
+ Part of [Threadplane](https://github.com/cacheplane/angular-agent-framework). MIT licensed.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npm install @threadplane/langgraph @threadplane/chat
11
+ ```
12
+
13
+ **Peer dependencies:** `@angular/core ^20.0.0 || ^21.0.0`, `@langchain/core ^1.1.0`, `@langchain/langgraph-sdk ^1.7.0`, `rxjs ~7.8.0`
14
+
15
+ ## What it does
16
+
17
+ - **`agent()`** — Angular Signal-based handle to a LangGraph streaming run. Returns `messages()`, `status()`, `isLoading()`, `error()`, `interrupt()`, `toolCalls()`, plus actions (`submit`, `stop`, `regenerate`, `reload`).
18
+ - **`provideAgent()`** — configure the LangGraph endpoint once in `app.config.ts`. Per-call overrides are accepted by `agent()` itself.
19
+ - **Thread persistence** — pass `threadId: signal(...)` + `onThreadId` to round-trip thread IDs through your own storage (localStorage, URL, etc.).
20
+ - **`MockAgentTransport`** — deterministic in-memory transport for tests. Never mock `agent()` itself; swap the transport instead.
21
+ - **`extractCitations()`** — populates `Message.citations` from LangGraph message metadata. Reads from `additional_kwargs.citations` (preferred) or `additional_kwargs.sources` (fallback).
22
+
23
+ ## Quick start
24
+
25
+ ```ts
26
+ // app.config.ts
27
+ import { provideAgent } from '@threadplane/langgraph';
28
+
29
+ export const appConfig: ApplicationConfig = {
30
+ providers: [
31
+ provideAgent({
32
+ apiUrl: 'https://your-langgraph-platform.com',
33
+ }),
34
+ ],
35
+ };
36
+ ```
37
+
38
+ ```ts
39
+ // chat.component.ts
40
+ import { Component } from '@angular/core';
41
+ import { agent } from '@threadplane/langgraph';
42
+ import { ChatComponent } from '@threadplane/chat';
43
+
44
+ @Component({
45
+ imports: [ChatComponent],
46
+ template: `<chat [agent]="chat" />`,
47
+ })
48
+ export class ChatComponentHost {
49
+ chat = agent({
50
+ apiUrl: 'https://your-langgraph-platform.com',
51
+ assistantId: 'my-agent',
52
+ });
53
+ }
54
+ ```
55
+
56
+ > `agent()` must be called within an Angular injection context (component field initializer or constructor). Calling it in `ngOnInit` or any async context throws `NG0203: inject() must be called from an injection context`.
57
+
58
+ ## Citations example
59
+
60
+ ```ts
61
+ // In your LangGraph node:
62
+ const response = await llm.invoke([...]);
63
+
64
+ return new AIMessage({
65
+ content: response.content,
66
+ additional_kwargs: {
67
+ citations: [
68
+ {
69
+ id: 'doc-1',
70
+ index: 1,
71
+ title: 'Example Article',
72
+ url: 'https://example.com/article',
73
+ snippet: 'Relevant excerpt...',
74
+ },
75
+ ],
76
+ },
77
+ });
78
+
79
+ // Message.citations auto-populates in @threadplane/chat via extractCitations()
80
+ ```
81
+
82
+ ## Documentation
83
+
84
+ - [Quickstart](https://threadplane.ai/docs/agent/getting-started/quickstart)
85
+ - [`agent()` API reference](https://threadplane.ai/docs/agent/api/agent)
86
+ - [Human-in-the-loop / interrupts](https://threadplane.ai/docs/agent/guides/interrupts)
87
+ - [Thread persistence](https://threadplane.ai/docs/agent/guides/persistence)
88
+ - [Testing with `MockAgentTransport`](https://threadplane.ai/docs/agent/guides/testing)
89
+
90
+ ## License
91
+
92
+ MIT — free for any use. See [LICENSE](../../LICENSE).