@ag-ui/encoder 0.0.34 → 0.0.35
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 +53 -0
- package/package.json +3 -3
package/README.md
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# @ag-ui/encoder
|
|
2
|
+
|
|
3
|
+
Event encoding utilities for the **Agent-User Interaction (AG-UI) Protocol**.
|
|
4
|
+
|
|
5
|
+
`@ag-ui/encoder` handles content negotiation and format encoding for AG-UI events. It automatically chooses between Server-Sent Events (JSON) and Protocol Buffers based on client `Accept` headers, ensuring optimal transport efficiency.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @ag-ui/encoder
|
|
11
|
+
pnpm add @ag-ui/encoder
|
|
12
|
+
yarn add @ag-ui/encoder
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Features
|
|
16
|
+
|
|
17
|
+
- 🎯 **Content negotiation** – Automatic format selection based on `Accept` headers
|
|
18
|
+
- 📦 **Dual encoding** – SSE (JSON) and Protocol Buffer support
|
|
19
|
+
- ⚡ **Efficient binary** – Length-prefixed protobuf encoding for high-throughput scenarios
|
|
20
|
+
- 🔄 **Seamless fallback** – Graceful degradation to SSE when protobuf isn't supported
|
|
21
|
+
|
|
22
|
+
## Quick example
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
import { EventEncoder } from "@ag-ui/encoder";
|
|
26
|
+
import { EventType } from "@ag-ui/core";
|
|
27
|
+
|
|
28
|
+
const encoder = new EventEncoder({
|
|
29
|
+
accept: "application/vnd.ag-ui.event+proto, text/event-stream",
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
const event = {
|
|
33
|
+
type: EventType.TEXT_MESSAGE_CONTENT,
|
|
34
|
+
messageId: "msg_123",
|
|
35
|
+
delta: "Hello, world!",
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
// Returns protobuf-encoded binary data
|
|
39
|
+
const encoded = encoder.encodeBinary(event);
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Documentation
|
|
43
|
+
|
|
44
|
+
- Concepts & architecture: [`docs/concepts`](https://docs.ag-ui.com/concepts/architecture)
|
|
45
|
+
- Full API reference: [`docs/sdk/js/encoder`](https://docs.ag-ui.com/sdk/js/encoder)
|
|
46
|
+
|
|
47
|
+
## Contributing
|
|
48
|
+
|
|
49
|
+
Bug reports and pull requests are welcome! Please read our [contributing guide](https://docs.ag-ui.com/development/contributing) first.
|
|
50
|
+
|
|
51
|
+
## License
|
|
52
|
+
|
|
53
|
+
MIT © 2025 AG-UI Protocol Contributors
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ag-ui/encoder",
|
|
3
3
|
"author": "Markus Ecker <markus.ecker@gmail.com>",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.35",
|
|
5
5
|
"private": false,
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
"module": "./dist/index.mjs",
|
|
11
11
|
"types": "./dist/index.d.ts",
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@ag-ui/core": "0.0.
|
|
14
|
-
"@ag-ui/proto": "0.0.
|
|
13
|
+
"@ag-ui/core": "0.0.35",
|
|
14
|
+
"@ag-ui/proto": "0.0.35"
|
|
15
15
|
},
|
|
16
16
|
"devDependencies": {
|
|
17
17
|
"@types/jest": "^29.5.12",
|