@frumu/tandem-client 0.3.22

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,161 @@
1
+ # @frumu/tandem-client
2
+
3
+ TypeScript / Node.js client for the [Tandem](https://tandem.frumu.ai/) autonomous agent engine HTTP + SSE API.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install @frumu/tandem-client
9
+ ```
10
+
11
+ Requires **Node 18+** (uses built-in `fetch` and `ReadableStream`).
12
+
13
+ ## Quick start
14
+
15
+ ```typescript
16
+ import { TandemClient } from "@frumu/tandem-client";
17
+
18
+ const client = new TandemClient({
19
+ baseUrl: "http://localhost:39731", // engine URL
20
+ token: "your-engine-token", // from `tandem-engine token generate`
21
+ });
22
+
23
+ // 1. Create a session
24
+ const sessionId = await client.sessions.create({
25
+ title: "My agent session",
26
+ directory: "/path/to/my/project",
27
+ });
28
+
29
+ // 2. Start an async run
30
+ const { runId } = await client.sessions.promptAsync(
31
+ sessionId,
32
+ "Summarize the README and list the top 3 TODOs"
33
+ );
34
+
35
+ // 3. Stream the response
36
+ for await (const event of client.stream(sessionId, runId)) {
37
+ if (event.type === "session.response") {
38
+ process.stdout.write(String(event.properties.delta ?? ""));
39
+ }
40
+ if (event.type === "run.complete" || event.type === "run.failed") break;
41
+ }
42
+ ```
43
+
44
+ ## API
45
+
46
+ ### `new TandemClient(options)`
47
+
48
+ | Option | Type | Description |
49
+ |--------|------|-------------|
50
+ | `baseUrl` | `string` | Engine base URL (e.g. `http://localhost:39731`) |
51
+ | `token` | `string` | Engine API token |
52
+ | `timeoutMs` | `number` | Request timeout in ms (default 20000) |
53
+
54
+ ### `client.health()` → `SystemHealth`
55
+
56
+ Check engine readiness.
57
+
58
+ ### `client.stream(sessionId, runId?, options?)` → `AsyncGenerator<EngineEvent>`
59
+
60
+ Stream events from a session run. Yields typed `EngineEvent` objects.
61
+
62
+ ### `client.globalStream(options?)` → `AsyncGenerator<EngineEvent>`
63
+
64
+ Stream all engine events across all sessions.
65
+
66
+ ---
67
+
68
+ ### `client.sessions`
69
+
70
+ | Method | Description |
71
+ |--------|-------------|
72
+ | `create(options?)` | Create a session, returns `sessionId` |
73
+ | `list(options?)` | List sessions |
74
+ | `get(sessionId)` | Get session details |
75
+ | `delete(sessionId)` | Delete a session |
76
+ | `messages(sessionId)` | Get message history |
77
+ | `activeRun(sessionId)` | Get the currently active run |
78
+ | `promptAsync(sessionId, prompt)` | Start an async run, returns `{ runId }` |
79
+
80
+ ### `client.routines`
81
+
82
+ | Method | Description |
83
+ |--------|-------------|
84
+ | `list(family?)` | List routines or automations |
85
+ | `create(options, family?)` | Create a scheduled routine |
86
+ | `delete(id, family?)` | Delete a routine |
87
+ | `runNow(id, family?)` | Trigger a routine immediately |
88
+ | `listRuns(family?, limit?)` | List recent run records |
89
+ | `listArtifacts(runId, family?)` | List artifacts from a run |
90
+
91
+ **Create a scheduled routine:**
92
+ ```typescript
93
+ await client.routines.create({
94
+ name: "Daily digest",
95
+ schedule: "0 8 * * *", // cron expression
96
+ prompt: "Summarize today's activity and write a report",
97
+ allowed_tools: ["read", "websearch", "webfetch"],
98
+ });
99
+ ```
100
+
101
+ ### `client.mcp`
102
+
103
+ | Method | Description |
104
+ |--------|-------------|
105
+ | `list()` | List registered MCP servers |
106
+ | `listTools()` | List all discovered tools |
107
+ | `add(options)` | Register an MCP server |
108
+ | `connect(name)` | Connect and discover tools |
109
+ | `disconnect(name)` | Disconnect |
110
+ | `refresh(name)` | Re-discover tools |
111
+ | `setEnabled(name, enabled)` | Enable/disable |
112
+
113
+ ```typescript
114
+ await client.mcp.add({ name: "arcade", transport: "https://mcp.arcade.ai/mcp" });
115
+ await client.mcp.connect("arcade");
116
+ const tools = await client.mcp.listTools();
117
+ ```
118
+
119
+ ### `client.channels`
120
+
121
+ | Method | Description |
122
+ |--------|-------------|
123
+ | `config()` | Get channel configuration |
124
+ | `status()` | Get live connection status |
125
+ | `put(channel, payload)` | Configure a channel |
126
+ | `delete(channel)` | Remove a channel configuration |
127
+
128
+ ### `client.permissions`
129
+
130
+ | Method | Description |
131
+ |--------|-------------|
132
+ | `list()` | List pending requests and rules |
133
+ | `reply(requestId, reply)` | Approve/deny a permission request |
134
+
135
+ ### `client.providers`
136
+
137
+ | Method | Description |
138
+ |--------|-------------|
139
+ | `catalog()` | List available providers |
140
+ | `config()` | Get current provider configuration |
141
+ | `setDefaults(providerId, modelId)` | Set default provider and model |
142
+ | `setApiKey(providerId, apiKey)` | Store an API key |
143
+
144
+ ---
145
+
146
+ ## Engine events reference
147
+
148
+ Common `event.type` values:
149
+
150
+ | Type | Description |
151
+ |------|-------------|
152
+ | `session.response` | Streaming text delta in `event.properties.delta` |
153
+ | `session.tool_call` | Tool invocation in `event.properties` |
154
+ | `session.tool_result` | Tool result |
155
+ | `run.complete` | Run finished successfully |
156
+ | `run.failed` | Run failed |
157
+ | `permission.request` | Approval needed — use `client.permissions.reply()` |
158
+
159
+ ## License
160
+
161
+ MIT