@threadplane/ag-ui 0.0.47 → 0.0.50

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 CHANGED
@@ -1,8 +1,33 @@
1
1
  # @threadplane/ag-ui
2
2
 
3
- Adapter that wraps an [AG-UI](https://github.com/ag-ui-protocol/ag-ui) `AbstractAgent` into the runtime-neutral `Agent` contract from `@threadplane/chat`. Works with any AG-UI-compatible backend — LangGraph, CrewAI, Mastra, Microsoft Agent Framework, AG2, Pydantic AI, AWS Strands, CopilotKit runtime.
3
+ Adapter that wraps an [AG-UI](https://github.com/ag-ui-protocol/ag-ui) `AbstractAgent` into the runtime-neutral `Agent` contract from `@threadplane/chat`. Works with any AG-UI-compatible backend.
4
4
 
5
- Part of [Threadplane](https://github.com/cacheplane/angular-agent-framework). MIT licensed.
5
+ <p align="center">
6
+ <a href="https://www.npmjs.com/package/@threadplane/ag-ui">
7
+ <img alt="npm version" src="https://img.shields.io/npm/v/@threadplane%2Fag-ui?color=6C8EFF&labelColor=080B14&style=flat-square" />
8
+ </a>
9
+ <a href="https://angular.dev">
10
+ <img alt="Angular 20+" src="https://img.shields.io/badge/Angular-20%2B%20%7C%2021-6C8EFF?labelColor=080B14&style=flat-square" />
11
+ </a>
12
+ <a href="../../LICENSE">
13
+ <img alt="MIT" src="https://img.shields.io/badge/License-MIT-6C8EFF?labelColor=080B14&style=flat-square" />
14
+ </a>
15
+ </p>
16
+
17
+ Part of [Threadplane](https://github.com/cacheplane/angular-agent-framework).
18
+
19
+ > Talking to LangGraph Platform directly? See [`@threadplane/langgraph`](https://www.npmjs.com/package/@threadplane/langgraph) — same API shape, LangGraph SDK underneath.
20
+
21
+ ---
22
+
23
+ ## What it does
24
+
25
+ - Bridges any AG-UI-compatible backend into the Threadplane chat surface via `toAgent()`.
26
+ - Supports: LangGraph, CrewAI, Mastra, Microsoft Agent Framework, AG2, Pydantic AI, AWS Strands, CopilotKit runtime.
27
+ - Exposes messages, status, tool calls, and raw AG-UI state as Angular Signals, plus `submit()`/`stop()`/`regenerate()` actions — coverage depends on what the AG-UI backend emits.
28
+ - Ships `FakeAgent` and `provideFakeAgent` test doubles for unit testing without a live backend.
29
+
30
+ ---
6
31
 
7
32
  ## Install
8
33
 
@@ -10,32 +35,95 @@ Part of [Threadplane](https://github.com/cacheplane/angular-agent-framework). MI
10
35
  npm install @threadplane/ag-ui @threadplane/chat @ag-ui/client
11
36
  ```
12
37
 
38
+ **Peer dependencies:** `@threadplane/chat: *`, `@angular/core: ^20.0.0 || ^21.0.0`, `@ag-ui/client: *`, `rxjs: ~7.8.0`
39
+
40
+ ---
41
+
13
42
  ## Quick start
14
43
 
15
- ```ts
16
- import { provideAgUiAgent, AG_UI_AGENT } from '@threadplane/ag-ui';
17
- import { ChatComponent } from '@threadplane/chat';
44
+ Register the agent in your `ApplicationConfig`, then inject it into a component and bind it to `<chat>`.
18
45
 
46
+ ```ts
19
47
  // app.config.ts
48
+ import { provideAgent } from '@threadplane/ag-ui';
49
+
20
50
  export const appConfig: ApplicationConfig = {
21
- providers: [provideAgUiAgent({ url: 'https://your.agent.endpoint' })],
51
+ providers: [provideAgent({ url: 'https://your.agent.endpoint' })],
22
52
  };
53
+ ```
54
+
55
+ ```ts
56
+ // app.component.ts
57
+ import { Component } from '@angular/core';
58
+ import { ChatComponent } from '@threadplane/chat';
59
+ import { injectAgent } from '@threadplane/ag-ui';
23
60
 
24
- // component
25
61
  @Component({
26
62
  imports: [ChatComponent],
27
63
  template: `<chat [agent]="agent" />`,
28
64
  })
65
+ export class AppComponent {
66
+ protected readonly agent = injectAgent();
67
+ }
68
+ ```
69
+
70
+ Both `@threadplane/langgraph` and `@threadplane/ag-ui` expose `provideAgent`/`injectAgent` with the same shape — consumer code is identical regardless of which adapter is wired in.
71
+
72
+ ---
73
+
74
+ ## Capabilities
75
+
76
+ `toAgent()` translates AG-UI events into Angular Signals on the runtime-neutral `Agent` contract:
77
+
78
+ | Signal | Description |
79
+ |---|---|
80
+ | `messages()` | Chat message history |
81
+ | `status()` | `'idle' \| 'running' \| 'error'` |
82
+ | `isLoading()` | True while a run is active |
83
+ | `toolCalls()` | In-progress and completed tool calls |
84
+ | `error()` | Last run error, if any |
85
+ | `state()` | Raw AG-UI state snapshot |
86
+
87
+ Which capabilities populate depends on the events the AG-UI backend emits. `submit()`, `stop()`, and `regenerate()` are supported.
88
+
89
+ ### Interrupts (human-in-the-loop)
90
+
91
+ `agent.interrupt()` is a `Signal<AgentInterrupt | undefined>` populated from AG-UI `CUSTOM` events with `name: 'on_interrupt'`. The reducer JSON-parses string-serialized `value` payloads automatically (e.g. `ag-ui-langgraph` ships interrupts via `dump_json_safe`), so consumers see the structured object directly.
92
+
93
+ Resume with `agent.submit({ resume })` — this calls `runAgent({ forwardedProps: { command: { resume } } })`, and the server reads `forwarded_props.command.resume` (the `ag-ui-langgraph` convention).
94
+
95
+ Pair with `<chat-approval-card>` from `@threadplane/chat` for the approve/reject/edit UX:
96
+
97
+ ```ts
98
+ import { Component } from '@angular/core';
99
+ import { ChatComponent, ChatApprovalCardComponent } from '@threadplane/chat';
100
+ import { injectAgent } from '@threadplane/ag-ui';
101
+
102
+ @Component({
103
+ imports: [ChatComponent, ChatApprovalCardComponent],
104
+ template: `
105
+ <chat [agent]="agent" />
106
+ <chat-approval-card
107
+ [agent]="agent"
108
+ matchKind="refund_approval"
109
+ (action)="onAction($event)" />
110
+ `,
111
+ })
29
112
  export class App {
30
- protected readonly agent = inject(AG_UI_AGENT);
113
+ protected readonly agent = injectAgent();
114
+ onAction(a: 'approve' | 'cancel') {
115
+ void this.agent.submit({ resume: { approved: a === 'approve' } });
116
+ }
31
117
  }
32
118
  ```
33
119
 
34
- ## Citations
120
+ See `cockpit/ag-ui/interrupts` for a complete working example, and the [LangGraph interrupts guide](https://threadplane.ai/docs/langgraph/guides/interrupts) for the broader HITL contract — the same `Agent.interrupt` / `submit({ resume })` API works across both adapters.
121
+
122
+ ### Citations
35
123
 
36
- The `bridgeCitationsState()` function populates `Message.citations` from AG-UI STATE_DELTA events. Citations are located at JSON Pointer `/citations/{messageId}`.
124
+ `bridgeCitationsState(thread, messages)` populates `Message.citations` from AG-UI state. Citations live under the `citations` key of the agent state, keyed by message ID (`state.citations[messageId]`).
37
125
 
38
- ### Example: AG-UI citations state shape
126
+ Example state shape:
39
127
 
40
128
  ```json
41
129
  {
@@ -55,14 +143,40 @@ The `bridgeCitationsState()` function populates `Message.citations` from AG-UI S
55
143
  }
56
144
  ```
57
145
 
58
- Each citation object in the array supports `id`, `index`, `title`, `url`, `snippet`, and custom `extra` fields. The messageId key matches the corresponding message in the chat history.
146
+ Each citation supports `id`, `index`, `title`, `url`, `snippet`, and custom `extra` fields. The message ID key matches the corresponding message in the chat history.
147
+
148
+ ---
149
+
150
+ ## Testing
151
+
152
+ ```ts
153
+ // Fake backend — streams canned tokens, no server:
154
+ import { provideFakeAgent } from '@threadplane/ag-ui';
155
+ providers: [provideFakeAgent({ tokens: ['Hello', ' world'] })];
156
+ ```
157
+
158
+ For component/unit tests, use the neutral writable-signal mock `mockAgent()`
159
+ from `@threadplane/chat` — the ag-ui agent _is_ the neutral `Agent` contract,
160
+ so there is no adapter-specific mock. See
161
+ [Choosing an adapter → Testing](https://threadplane.ai/docs/choosing-an-adapter#testing).
162
+
163
+ ---
164
+
165
+ ## Reliability
166
+
167
+ `@threadplane/ag-ui` shares the same runtime-neutral `Agent` contract as `@threadplane/langgraph`, making it interchangeable at the `<chat [agent]>` binding. The library follows a patch-only `0.0.x` release policy. The CI job "Library — lint / test / build" runs lint, test, and build on every pull request.
168
+
169
+ ---
59
170
 
60
171
  ## Documentation
61
172
 
62
- - [Quickstart](https://threadplane.ai/docs/agent/getting-started/quickstart)
173
+ - [Quickstart](https://threadplane.ai/docs/ag-ui/getting-started/quickstart)
63
174
  - [AG-UI adapter guide](https://threadplane.ai/docs/chat/guides/writing-an-adapter)
64
175
  - [AG-UI protocol](https://github.com/ag-ui-protocol/ag-ui)
176
+ - [Choosing an adapter (LangGraph vs AG-UI)](https://threadplane.ai/docs/choosing-an-adapter)
177
+
178
+ ---
65
179
 
66
180
  ## License
67
181
 
68
- MIT — free for any use. See [LICENSE](../../LICENSE).
182
+ MIT. See [LICENSE](../../LICENSE).