Skip to content

Commit 5e9a6c6

Browse files
feat: add support for aws strands typescript
1 parent 9938082 commit 5e9a6c6

32 files changed

+7770
-81
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
dist
2+
node_modules
3+
coverage
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
.turbo
2+
.DS_Store
3+
.env
4+
.idea
5+
.vscode
6+
node_modules
7+
coverage
8+
__tests__
9+
src
10+
tsup.config.ts
11+
tsconfig.json
12+
examples
13+
*.log
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# AWS Strands Integration for AG-UI (TypeScript)
2+
3+
`@ag-ui/strands-server` is the TypeScript twin of the Python adapter. Give us any `@strands-agents/sdk` agent, wrap it with `StrandsAgent`, and wire it to HTTP via `createStrandsServer` or `addStrandsEndpoint`. The config surface, event ordering, and helper APIs all mirror the Python version so you can switch languages without relearning the integration.
4+
5+
## Prerequisites
6+
7+
- Node.js 18+
8+
- `pnpm` (recommended) or npm
9+
- A Strands-compatible model key (Gemini, Bedrock, etc.)
10+
11+
## Quick Start
12+
13+
Run the bundled demo to see shared-state + tool behaviors in action:
14+
15+
```bash
16+
cd integrations/aws-strands/typescript-server/examples
17+
pnpm install
18+
pnpm dev
19+
```
20+
21+
It mounts `http://localhost:8000/runs` and streams AG-UI events for a Strands agent that owns three tools (`get_weather`, `set_theme_color`, `update_proverbs`). The demo highlights `stateContextBuilder`, `stateFromArgs`, and `skipMessagesSnapshot`.
22+
23+
To embed it directly:
24+
25+
```ts
26+
const baseAgent = new Agent({ systemPrompt: "Be helpful.", tools: [...] });
27+
const aguiAgent = new StrandsAgent(baseAgent, "demo_agent", "Demo agent", config);
28+
const server = createStrandsServer(aguiAgent, "/runs");
29+
server.listen(8000);
30+
```
31+
32+
## Architecture Overview
33+
34+
- **StrandsAgent** – wraps `agent.streamAsync` / `stream` and emits AG-UI events (`run_started`, deltas, tool calls, PredictState, snapshots, finish/error) identically to the Python adapter.
35+
- **Configuration layer**`StrandsAgentConfig`, `ToolBehavior`, and `PredictStateMapping` expose the same hooks: `stateContextBuilder`, `argsStreamer`, `stateFromArgs`, `stateFromResult`, `customResultHandler`, etc.
36+
- **Transport helpers**`createStrandsServer`, `createStrandsHandler`, and `addStrandsEndpoint` reuse the shared `EventEncoder` to deliver SSE or newline-delimited JSON from Express-compatible apps.
37+
38+
## Key Files
39+
40+
| File | Purpose |
41+
| -------------------------------- | -------------------------------------------------------------------------------------- |
42+
| `src/agent.ts` | Converts Strands streaming events into AG-UI protocol events |
43+
| `src/config.ts` | Configuration primitives (`StrandsAgentConfig`, `ToolBehavior`, `PredictStateMapping`) |
44+
| `src/endpoint.ts` | HTTP/SSE helpers |
45+
| `examples/src/proverbs-agent.ts` | Runnable demo showcasing shared-state behaviors |
46+
47+
## Development
48+
49+
```bash
50+
pnpm install
51+
pnpm run build # tsup build (CJS + ESM + d.ts)
52+
pnpm run typecheck # tsc --noEmit
53+
pnpm run dev # tsup --watch
54+
```
55+
56+
Only `dist/` and this README ship in the npm package; everything else stays ignored via `.npmignore`.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Strands server example
2+
3+
This folder shows how to wrap a Strands SDK agent with the AG-UI server adapter and expose it over HTTP.
4+
5+
```bash
6+
pnpm install
7+
pnpm dev
8+
```
9+
10+
The script starts an example server on `http://localhost:8000/runs` that streams AG-UI events with state synchronization helpers.

0 commit comments

Comments
 (0)