10xgraph-client 0.0.0-stage → 0.6.0
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/CHANGELOG.md +276 -0
- package/LICENSE +21 -0
- package/README.md +400 -2
- package/dist/agent.d.ts +22 -0
- package/dist/agent.d.ts.map +1 -0
- package/dist/client.d.ts +479 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/compat.d.ts +28 -0
- package/dist/compat.d.ts.map +1 -0
- package/dist/endpoints/addThreadMessages.d.ts +22 -0
- package/dist/endpoints/addThreadMessages.d.ts.map +1 -0
- package/dist/endpoints/clearThreadState.d.ts +15 -0
- package/dist/endpoints/clearThreadState.d.ts.map +1 -0
- package/dist/endpoints/deleteMemory.d.ts +19 -0
- package/dist/endpoints/deleteMemory.d.ts.map +1 -0
- package/dist/endpoints/deleteThread.d.ts +19 -0
- package/dist/endpoints/deleteThread.d.ts.map +1 -0
- package/dist/endpoints/deleteThreadMessage.d.ts +20 -0
- package/dist/endpoints/deleteThreadMessage.d.ts.map +1 -0
- package/dist/endpoints/files.d.ts +83 -0
- package/dist/endpoints/files.d.ts.map +1 -0
- package/dist/endpoints/fixGraph.d.ts +29 -0
- package/dist/endpoints/fixGraph.d.ts.map +1 -0
- package/dist/endpoints/forgetMemories.d.ts +22 -0
- package/dist/endpoints/forgetMemories.d.ts.map +1 -0
- package/dist/endpoints/getMemory.d.ts +19 -0
- package/dist/endpoints/getMemory.d.ts.map +1 -0
- package/dist/endpoints/graph.d.ts +39 -0
- package/dist/endpoints/graph.d.ts.map +1 -0
- package/dist/endpoints/graphTools.d.ts +32 -0
- package/dist/endpoints/graphTools.d.ts.map +1 -0
- package/dist/endpoints/invoke.d.ts +59 -0
- package/dist/endpoints/invoke.d.ts.map +1 -0
- package/dist/endpoints/listMemories.d.ts +19 -0
- package/dist/endpoints/listMemories.d.ts.map +1 -0
- package/dist/endpoints/metadata.d.ts +6 -0
- package/dist/endpoints/metadata.d.ts.map +1 -0
- package/dist/endpoints/observability.d.ts +58 -0
- package/dist/endpoints/observability.d.ts.map +1 -0
- package/dist/endpoints/ping.d.ts +10 -0
- package/dist/endpoints/ping.d.ts.map +1 -0
- package/dist/endpoints/realtime.d.ts +134 -0
- package/dist/endpoints/realtime.d.ts.map +1 -0
- package/dist/endpoints/searchMemory.d.ts +57 -0
- package/dist/endpoints/searchMemory.d.ts.map +1 -0
- package/dist/endpoints/stateSchema.d.ts +50 -0
- package/dist/endpoints/stateSchema.d.ts.map +1 -0
- package/dist/endpoints/stopGraph.d.ts +26 -0
- package/dist/endpoints/stopGraph.d.ts.map +1 -0
- package/dist/endpoints/storeMemory.d.ts +33 -0
- package/dist/endpoints/storeMemory.d.ts.map +1 -0
- package/dist/endpoints/stream.d.ts +60 -0
- package/dist/endpoints/stream.d.ts.map +1 -0
- package/dist/endpoints/threadDetails.d.ts +19 -0
- package/dist/endpoints/threadDetails.d.ts.map +1 -0
- package/dist/endpoints/threadMessage.d.ts +17 -0
- package/dist/endpoints/threadMessage.d.ts.map +1 -0
- package/dist/endpoints/threadMessages.d.ts +23 -0
- package/dist/endpoints/threadMessages.d.ts.map +1 -0
- package/dist/endpoints/threadState.d.ts +14 -0
- package/dist/endpoints/threadState.d.ts.map +1 -0
- package/dist/endpoints/threads.d.ts +30 -0
- package/dist/endpoints/threads.d.ts.map +1 -0
- package/dist/endpoints/updateMemory.d.ts +21 -0
- package/dist/endpoints/updateMemory.d.ts.map +1 -0
- package/dist/endpoints/updateThreadState.d.ts +18 -0
- package/dist/endpoints/updateThreadState.d.ts.map +1 -0
- package/dist/endpoints/wsStream.d.ts +33 -0
- package/dist/endpoints/wsStream.d.ts.map +1 -0
- package/dist/errors.d.ts +155 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/index.cjs +6 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +39 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2664 -0
- package/dist/index.js.map +1 -0
- package/dist/message.d.ts +174 -0
- package/dist/message.d.ts.map +1 -0
- package/dist/request.d.ts +33 -0
- package/dist/request.d.ts.map +1 -0
- package/dist/tools.d.ts +67 -0
- package/dist/tools.d.ts.map +1 -0
- package/dist/ws.d.ts +48 -0
- package/dist/ws.d.ts.map +1 -0
- package/package.json +99 -4
- package/src/agent.ts +43 -0
- package/src/client.ts +1044 -0
- package/src/compat.ts +35 -0
- package/src/endpoints/addThreadMessages.ts +83 -0
- package/src/endpoints/clearThreadState.ts +75 -0
- package/src/endpoints/deleteMemory.ts +91 -0
- package/src/endpoints/deleteThread.ts +78 -0
- package/src/endpoints/deleteThreadMessage.ts +83 -0
- package/src/endpoints/files.ts +274 -0
- package/src/endpoints/fixGraph.ts +91 -0
- package/src/endpoints/forgetMemories.ts +95 -0
- package/src/endpoints/getMemory.ts +82 -0
- package/src/endpoints/graph.ts +97 -0
- package/src/endpoints/graphTools.ts +90 -0
- package/src/endpoints/invoke.ts +318 -0
- package/src/endpoints/listMemories.ts +97 -0
- package/src/endpoints/metadata.ts +6 -0
- package/src/endpoints/observability.ts +107 -0
- package/src/endpoints/ping.ts +58 -0
- package/src/endpoints/realtime.ts +326 -0
- package/src/endpoints/searchMemory.ts +132 -0
- package/src/endpoints/stateSchema.ts +106 -0
- package/src/endpoints/stopGraph.ts +85 -0
- package/src/endpoints/storeMemory.ts +98 -0
- package/src/endpoints/stream.ts +440 -0
- package/src/endpoints/threadDetails.ts +78 -0
- package/src/endpoints/threadMessage.ts +76 -0
- package/src/endpoints/threadMessages.ts +97 -0
- package/src/endpoints/threadState.ts +74 -0
- package/src/endpoints/threads.ts +112 -0
- package/src/endpoints/updateMemory.ts +90 -0
- package/src/endpoints/updateThreadState.ts +82 -0
- package/src/endpoints/wsStream.ts +251 -0
- package/src/errors.ts +553 -0
- package/src/index.ts +108 -0
- package/src/message.ts +436 -0
- package/src/request.ts +168 -0
- package/src/tools.ts +225 -0
- package/src/ws.ts +100 -0
package/README.md
CHANGED
|
@@ -1,3 +1,401 @@
|
|
|
1
|
-
#
|
|
1
|
+
# 10xGraph Client
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/10xgraph-client)
|
|
4
|
+
[](https://www.typescriptlang.org/)
|
|
5
|
+
[](https://opensource.org/licenses/MIT)
|
|
6
|
+
|
|
7
|
+
The TypeScript client for the **10xGraph** API server. Build conversational AI applications with
|
|
8
|
+
streaming responses, realtime audio, client-side tool execution, and dynamic state management.
|
|
9
|
+
|
|
10
|
+
10xGraph by 10xScale: graph engineering for production AI agents.
|
|
11
|
+
|
|
12
|
+
> **Coming from `@10xscale/agentflow-client`?** This is the same client under its new name.
|
|
13
|
+
> Change the import and you are done; the old `AgentFlow*` names still work until 2.0. See
|
|
14
|
+
> [Migrating from `@10xscale/agentflow-client`](#migrating-from-10xscaleagentflow-client).
|
|
15
|
+
|
|
16
|
+
## Features
|
|
17
|
+
|
|
18
|
+
- **Simple API**: one client class with a method per server endpoint
|
|
19
|
+
- **Streaming**: HTTP and WebSocket streaming for chat UIs
|
|
20
|
+
- **Tool execution**: run browser-side tools locally, with recursion handling
|
|
21
|
+
- **State management**: dynamic state schema with validation
|
|
22
|
+
- **Realtime audio**: WebSocket audio-to-audio via `/v1/graph/live`
|
|
23
|
+
- **TypeScript first**: full type definitions, dual ESM + CJS
|
|
24
|
+
|
|
25
|
+
## Installation
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
npm install 10xgraph-client
|
|
29
|
+
# or
|
|
30
|
+
yarn add 10xgraph-client
|
|
31
|
+
# or
|
|
32
|
+
pnpm add 10xgraph-client
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Version compatibility
|
|
36
|
+
|
|
37
|
+
The client versions independently of the Python packages. Pick versions by this table rather than
|
|
38
|
+
by matching numbers:
|
|
39
|
+
|
|
40
|
+
| `10xgraph-client` (npm) | API server | Core framework |
|
|
41
|
+
| -------------------------------------- | ------------------------------------------------- | ------------------------------ |
|
|
42
|
+
| 0.6.x | `10xgraph-api` >= 0.7.0 | `10xgraph` >= 0.10.0 |
|
|
43
|
+
| `@10xscale/agentflow-client` 0.5.x | `10xscale-agentflow-cli` >= 0.6.0, `10xgraph-api` | `10xscale-agentflow` >= 0.10.0 |
|
|
44
|
+
| `@10xscale/agentflow-client` 0.3-0.4.x | `10xscale-agentflow-cli` >= 0.5.0 | `10xscale-agentflow` >= 0.9.0 |
|
|
45
|
+
|
|
46
|
+
The client tracks the **API server**, which is what it talks to. Client 0.6.x authenticates
|
|
47
|
+
WebSockets with the `10xgraph-bearer` subprotocol, which `10xgraph-api` 0.7.0 introduced. Against
|
|
48
|
+
an older `10xscale-agentflow-cli` server, HTTP endpoints still work, but `wsStream()` and
|
|
49
|
+
`realtime()` with bearer auth do not; stay on `@10xscale/agentflow-client@0.5.0` until the server
|
|
50
|
+
is upgraded.
|
|
51
|
+
|
|
52
|
+
## Quick Start
|
|
53
|
+
|
|
54
|
+
### Basic usage
|
|
55
|
+
|
|
56
|
+
```typescript
|
|
57
|
+
import { TenxGraphClient, Message } from '10xgraph-client';
|
|
58
|
+
|
|
59
|
+
const client = new TenxGraphClient({
|
|
60
|
+
baseUrl: 'http://localhost:8000',
|
|
61
|
+
authToken: 'your-token', // optional bearer auth
|
|
62
|
+
debug: true, // optional
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
const result = await client.invoke([Message.text_message('Hello, how can you help me?', 'user')]);
|
|
66
|
+
|
|
67
|
+
console.log(result.messages);
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Start a local server with `10xgraph api` (from the `10xgraph-api` package).
|
|
71
|
+
|
|
72
|
+
### Authentication options
|
|
73
|
+
|
|
74
|
+
```typescript
|
|
75
|
+
import { TenxGraphClient, basicAuth, headerAuth } from '10xgraph-client';
|
|
76
|
+
|
|
77
|
+
const bearerClient = new TenxGraphClient({
|
|
78
|
+
baseUrl: 'https://api.example.com',
|
|
79
|
+
authToken: process.env.TENXGRAPH_TOKEN,
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
const basicClient = new TenxGraphClient({
|
|
83
|
+
baseUrl: 'https://api.example.com',
|
|
84
|
+
auth: basicAuth('service-user', 'service-password'),
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
const apiKeyClient = new TenxGraphClient({
|
|
88
|
+
baseUrl: 'https://api.example.com',
|
|
89
|
+
auth: headerAuth('X-API-Key', process.env.TENXGRAPH_API_KEY!),
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
const sessionClient = new TenxGraphClient({
|
|
93
|
+
baseUrl: 'https://api.example.com',
|
|
94
|
+
credentials: 'include',
|
|
95
|
+
});
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### Streaming chat
|
|
99
|
+
|
|
100
|
+
```typescript
|
|
101
|
+
const stream = client.stream([Message.text_message('Tell me a story', 'user')]);
|
|
102
|
+
|
|
103
|
+
for await (const chunk of stream) {
|
|
104
|
+
if (chunk.event === 'message') {
|
|
105
|
+
console.log(chunk.message?.content);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## Realtime audio (`/v1/graph/live`)
|
|
111
|
+
|
|
112
|
+
Transport-only: you stream PCM16 in and get PCM16 out. Mic capture and playback are yours to wire.
|
|
113
|
+
|
|
114
|
+
```ts
|
|
115
|
+
import { TenxGraphClient } from '10xgraph-client';
|
|
116
|
+
|
|
117
|
+
const client = new TenxGraphClient({ baseUrl: 'http://localhost:8000', authToken });
|
|
118
|
+
|
|
119
|
+
const session = client.realtime(
|
|
120
|
+
{ model: 'gemini-2.5-flash-live', modalities: 'AUDIO' },
|
|
121
|
+
{ reconnect: { maxAttempts: 5 } }
|
|
122
|
+
);
|
|
123
|
+
|
|
124
|
+
session.on('audio', (pcm16, sampleRate) => playback(pcm16, sampleRate)); // PCM16 @ 24 kHz
|
|
125
|
+
session.on('output_transcript', (e) => console.log(e.text));
|
|
126
|
+
session.on('tool_call', (e) => console.log('tool', e.name, e.args));
|
|
127
|
+
session.on('error', (e) => console.error(e.message));
|
|
128
|
+
|
|
129
|
+
await session.ready; // socket open + init sent
|
|
130
|
+
session.sendAudio(micChunk); // PCM16 @ 16 kHz (Uint8Array | ArrayBuffer)
|
|
131
|
+
// push-to-talk: session.activityStart() / session.activityEnd()
|
|
132
|
+
session.close(); // graceful end; disables reconnect
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
Auth uses the browser-safe `10xgraph-bearer` subprotocol automatically. In Node < 21 (no global
|
|
136
|
+
`WebSocket`), pass an implementation:
|
|
137
|
+
|
|
138
|
+
```ts
|
|
139
|
+
import WebSocket from 'ws';
|
|
140
|
+
const client = new TenxGraphClient({ baseUrl, authToken, webSocketImpl: WebSocket });
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### File uploads and access URLs
|
|
144
|
+
|
|
145
|
+
```typescript
|
|
146
|
+
const upload = await client.uploadFile(file);
|
|
147
|
+
|
|
148
|
+
// Best URL for rendering/downloading in the UI.
|
|
149
|
+
// Cloud-backed deployments typically return a signed URL here.
|
|
150
|
+
const accessUrl = upload.data.direct_url ?? upload.data.url;
|
|
151
|
+
|
|
152
|
+
const fileInfo = await client.getFileInfo(upload.data.file_id);
|
|
153
|
+
const fileUrl = await client.getFileAccessUrl(upload.data.file_id);
|
|
154
|
+
|
|
155
|
+
const msg = Message.withFile('Summarize this document', upload.data.file_id, upload.data.mime_type);
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### Tool registration
|
|
159
|
+
|
|
160
|
+
**Important:** remote tools (registered client-side) should **only** be used for browser-level APIs
|
|
161
|
+
like `localStorage` or `navigator.geolocation`. For most operations (database queries, external API
|
|
162
|
+
calls, calculations), define your tools in the Python backend instead. See
|
|
163
|
+
[Remote tools](https://10xgraph.com/docs/client/remote-tools) for details.
|
|
164
|
+
|
|
165
|
+
```typescript
|
|
166
|
+
// Matching trusted schema must be declared in the server's 10xgraph.json.
|
|
167
|
+
client.registerToolHandler('get_weather', async ({ location }) => {
|
|
168
|
+
return { temperature: 72, conditions: 'sunny' };
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
// Tools execute automatically during invoke
|
|
172
|
+
const result = await client.invoke([Message.text_message('What is the weather in NYC?', 'user')]);
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
Declare model-facing metadata in the server's `10xgraph.json`, never from an untrusted client:
|
|
176
|
+
|
|
177
|
+
```json
|
|
178
|
+
{
|
|
179
|
+
"remote_tools": [
|
|
180
|
+
{
|
|
181
|
+
"node": "assistant",
|
|
182
|
+
"name": "get_weather",
|
|
183
|
+
"description": "Get current weather for a location",
|
|
184
|
+
"parameters": {
|
|
185
|
+
"type": "object",
|
|
186
|
+
"properties": { "location": { "type": "string" } },
|
|
187
|
+
"required": ["location"]
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
]
|
|
191
|
+
}
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
No client setup call is required or available.
|
|
195
|
+
|
|
196
|
+
## Documentation
|
|
197
|
+
|
|
198
|
+
Full documentation lives at **[10xgraph.com/docs](https://10xgraph.com/docs/client)**.
|
|
199
|
+
|
|
200
|
+
### Guides
|
|
201
|
+
|
|
202
|
+
- **[Create a client](https://10xgraph.com/docs/client/create-client)**: setup and first request
|
|
203
|
+
- **[Invoke an agent](https://10xgraph.com/docs/client/invoke-agent)**: request/response with tool execution
|
|
204
|
+
- **[Stream responses](https://10xgraph.com/docs/client/stream-responses)**: real-time streaming
|
|
205
|
+
- **[Remote tools](https://10xgraph.com/docs/client/remote-tools)**: when to use client-side tools
|
|
206
|
+
- **[Realtime audio](https://10xgraph.com/docs/client/realtime-audio)**: the `/v1/graph/live` session
|
|
207
|
+
- **[Error handling](https://10xgraph.com/docs/client/error-handling)**: error classes and recovery
|
|
208
|
+
|
|
209
|
+
### Reference
|
|
210
|
+
|
|
211
|
+
- **[`TenxGraphClient`](https://10xgraph.com/docs/reference/client/client)**: constructor config and every method
|
|
212
|
+
- **[`Message` and content blocks](https://10xgraph.com/docs/reference/client/message)**
|
|
213
|
+
- **[Auth](https://10xgraph.com/docs/reference/client/auth)** and **[Errors](https://10xgraph.com/docs/reference/client/errors)**
|
|
214
|
+
- **[Troubleshooting](https://10xgraph.com/docs/troubleshooting/client)**: common issues and solutions
|
|
215
|
+
|
|
216
|
+
## Key APIs
|
|
217
|
+
|
|
218
|
+
### `invoke()`: batch processing
|
|
219
|
+
|
|
220
|
+
Execute the agent with an automatic tool execution loop:
|
|
221
|
+
|
|
222
|
+
```typescript
|
|
223
|
+
const result = await client.invoke(messages, {
|
|
224
|
+
recursion_limit: 25,
|
|
225
|
+
response_granularity: 'full',
|
|
226
|
+
});
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
### `stream()`: real-time streaming
|
|
230
|
+
|
|
231
|
+
```typescript
|
|
232
|
+
const stream = client.stream(messages);
|
|
233
|
+
for await (const chunk of stream) {
|
|
234
|
+
// Process chunks in real-time
|
|
235
|
+
}
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
### `graphStateSchema()`: dynamic schema
|
|
239
|
+
|
|
240
|
+
Get the agent state schema for form generation and validation:
|
|
241
|
+
|
|
242
|
+
```typescript
|
|
243
|
+
const schema = await client.graphStateSchema();
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
### `graphTools()`: tool inventory
|
|
247
|
+
|
|
248
|
+
List the tools the graph's tool nodes expose, grouped by node. Each tool is tagged with its
|
|
249
|
+
source (`local`, `mcp`, or `remote`):
|
|
250
|
+
|
|
251
|
+
```typescript
|
|
252
|
+
const { data } = await client.graphTools();
|
|
253
|
+
// data.nodes[].tools[] -> { name, description, source, parameters }
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
### `observability(threadId, runId?)`: run traces
|
|
257
|
+
|
|
258
|
+
Fetch the reconstructed trace for a run (spans, events, and cost). Defaults to the thread's
|
|
259
|
+
latest run:
|
|
260
|
+
|
|
261
|
+
```typescript
|
|
262
|
+
const trace = await client.observability(threadId);
|
|
263
|
+
const specific = await client.observability(threadId, runId);
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
## Examples
|
|
267
|
+
|
|
268
|
+
The [`examples/`](examples/) directory has complete working examples:
|
|
269
|
+
|
|
270
|
+
- **[invoke-example.ts](examples/invoke-example.ts)**: basic invoke with tool execution
|
|
271
|
+
- **[stream-example.ts](examples/stream-example.ts)**: streaming responses
|
|
272
|
+
- **[state-schema-examples.ts](examples/state-schema-examples.ts)**: form generation and validation
|
|
273
|
+
|
|
274
|
+
## Architecture
|
|
275
|
+
|
|
276
|
+
```
|
|
277
|
+
┌──────────────────────┐
|
|
278
|
+
│ Your application │
|
|
279
|
+
└──────────┬───────────┘
|
|
280
|
+
│ TenxGraphClient
|
|
281
|
+
▼
|
|
282
|
+
┌──────────────────────┐
|
|
283
|
+
│ 10xgraph-client │ <- this library
|
|
284
|
+
│ client, tools, │
|
|
285
|
+
│ messages │
|
|
286
|
+
└──────────┬───────────┘
|
|
287
|
+
│ HTTP/HTTPS + WebSocket
|
|
288
|
+
▼
|
|
289
|
+
┌──────────────────────┐
|
|
290
|
+
│ 10xgraph-api │ <- your backend
|
|
291
|
+
│ (10xgraph api) │
|
|
292
|
+
└──────────────────────┘
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
## Configuration
|
|
296
|
+
|
|
297
|
+
```typescript
|
|
298
|
+
const client = new TenxGraphClient({
|
|
299
|
+
baseUrl: string, // Required: API base URL
|
|
300
|
+
authToken?: string, // Optional: bearer token
|
|
301
|
+
auth?: TenxGraphAuth, // Optional: bearer/basic/custom header auth
|
|
302
|
+
headers?: HeadersInit, // Optional: extra headers for every request
|
|
303
|
+
credentials?: RequestCredentials, // Optional: cookie/session auth
|
|
304
|
+
timeout?: number, // Optional: request timeout (default: 5 min)
|
|
305
|
+
debug?: boolean, // Optional: enable debug logging
|
|
306
|
+
webSocketImpl?: typeof WebSocket // Node < 21 (pass the 'ws' package)
|
|
307
|
+
});
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
## Migrating from `@10xscale/agentflow-client`
|
|
311
|
+
|
|
312
|
+
The project was renamed from Agentflow to **10xGraph** because "Agentflow" is shared by several
|
|
313
|
+
unrelated projects and was hard to find. The client, license and maintainers are the same.
|
|
314
|
+
|
|
315
|
+
| Before | After |
|
|
316
|
+
| ------------------------------------------------------ | ------------------------------------ |
|
|
317
|
+
| `npm install @10xscale/agentflow-client` | `npm install 10xgraph-client` |
|
|
318
|
+
| `AgentFlowClient`, `AgentFlowConfig` | `TenxGraphClient`, `TenxGraphConfig` |
|
|
319
|
+
| `AgentFlowError` | `TenxGraphError` |
|
|
320
|
+
| `AgentFlowAuth` (+ `Bearer`/`Basic`/`Header` variants) | `TenxGraphAuth` (+ same variants) |
|
|
321
|
+
| WS subprotocol `agentflow-bearer` | `10xgraph-bearer` |
|
|
322
|
+
| Server `10xscale-agentflow-cli`, `agentflow.json` | `10xgraph-api`, `10xgraph.json` |
|
|
323
|
+
|
|
324
|
+
Steps:
|
|
325
|
+
|
|
326
|
+
1. `npm uninstall @10xscale/agentflow-client && npm install 10xgraph-client`
|
|
327
|
+
2. Replace `'@10xscale/agentflow-client'` with `'10xgraph-client'` in your imports.
|
|
328
|
+
3. Upgrade the server to `10xgraph-api` >= 0.7.0 if you use `wsStream()` or `realtime()`.
|
|
329
|
+
4. Optionally rename `AgentFlow*` identifiers to `TenxGraph*`. The old names are exported as
|
|
330
|
+
deprecated aliases of the same classes and types, so `instanceof AgentFlowError` keeps working.
|
|
331
|
+
They are removed in 2.0.
|
|
332
|
+
|
|
333
|
+
One observable difference: errors now report `error.name === 'TenxGraphError'` instead of
|
|
334
|
+
`'AgentFlowError'`. Use `instanceof` rather than comparing names.
|
|
335
|
+
|
|
336
|
+
## Module formats
|
|
337
|
+
|
|
338
|
+
Ships dual ESM + CJS with types. `import` resolves `dist/index.js` (ESM); `require` resolves
|
|
339
|
+
`dist/index.cjs`. Tree-shakeable (`"sideEffects": false`).
|
|
340
|
+
|
|
341
|
+
## Testing
|
|
342
|
+
|
|
343
|
+
```bash
|
|
344
|
+
npm test # watch mode
|
|
345
|
+
npm run test:run # run once
|
|
346
|
+
npm run build # build the library
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
## TypeScript support
|
|
350
|
+
|
|
351
|
+
```typescript
|
|
352
|
+
import type {
|
|
353
|
+
TenxGraphClient,
|
|
354
|
+
Message,
|
|
355
|
+
ToolRegistration,
|
|
356
|
+
InvokeResult,
|
|
357
|
+
StreamChunk,
|
|
358
|
+
AgentState,
|
|
359
|
+
AgentStateSchema,
|
|
360
|
+
} from '10xgraph-client';
|
|
361
|
+
```
|
|
362
|
+
|
|
363
|
+
## Contributing
|
|
364
|
+
|
|
365
|
+
**Be the first community contributor on this wall.**
|
|
366
|
+
|
|
367
|
+
<a href="https://github.com/10xGraph/10xgraph-client/graphs/contributors">
|
|
368
|
+
<img src="https://contrib.rocks/image?repo=10xGraph/10xgraph-client" alt="People who have contributed to the 10xGraph TypeScript client" />
|
|
369
|
+
</a>
|
|
370
|
+
|
|
371
|
+
So far only the lead maintainer has committed here, so the first community spot is open. Merge one pull request and your avatar is the next one on this wall and on the contributor page at [10xgraph.com/maintainers](https://10xgraph.com/maintainers). This client is how frontends talk to production agents, so the work is used from day one.
|
|
372
|
+
|
|
373
|
+
Your first pull request can be small. These are real, self-contained, and useful today:
|
|
374
|
+
|
|
375
|
+
- **Add an example for your framework.** [`examples/`](examples/) has plain TypeScript and React. Vue, Svelte, Next.js and Node scripts are all missing.
|
|
376
|
+
- **Test an edge case you hit.** A stream that drops mid-response, an error body the client should map, an auth header that should win.
|
|
377
|
+
- **Sharpen a type or a doc comment.** If your editor's autocomplete misled you once, it will mislead the next person too.
|
|
378
|
+
- **Turn a bug into a failing test.** Open it as a draft pull request; the fix can come later.
|
|
379
|
+
|
|
380
|
+
From clone to a passing check (Node 18 or newer):
|
|
381
|
+
|
|
382
|
+
```bash
|
|
383
|
+
git clone https://github.com/10xGraph/10xgraph-client.git
|
|
384
|
+
cd 10xgraph-client
|
|
385
|
+
npm ci
|
|
386
|
+
npm run check # lint, typecheck and tests: the same gate as CI
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
Draft pull requests are welcome, so open early and ask questions in the PR. For bigger changes, start a thread in the core repository's [Discussions](https://github.com/10xGraph/10xGraph/discussions) first. [CONTRIBUTING.md](CONTRIBUTING.md) has every check and the release notes rules.
|
|
390
|
+
|
|
391
|
+
## License
|
|
392
|
+
|
|
393
|
+
10xGraph is [MIT licensed](LICENSE) and made by [10xScale](https://10xscale.ai). Contributions are
|
|
394
|
+
accepted under the same license.
|
|
395
|
+
|
|
396
|
+
## Support
|
|
397
|
+
|
|
398
|
+
- [Documentation](https://10xgraph.com/docs/client)
|
|
399
|
+
- [Issue tracker](https://github.com/10xGraph/10xgraph-client/issues)
|
|
400
|
+
- [npm package](https://www.npmjs.com/package/10xgraph-client)
|
|
401
|
+
- [10xgraph.com](https://10xgraph.com) and [github.com/10xGraph](https://github.com/10xGraph)
|
package/dist/agent.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Message } from './message.js';
|
|
2
|
+
interface ExecutionMeta {
|
|
3
|
+
current_node: string;
|
|
4
|
+
step: number;
|
|
5
|
+
interrupt?: {
|
|
6
|
+
node: string;
|
|
7
|
+
reason: string;
|
|
8
|
+
status: string;
|
|
9
|
+
data?: Record<string, any>;
|
|
10
|
+
};
|
|
11
|
+
is_running: boolean;
|
|
12
|
+
is_interrupted: boolean;
|
|
13
|
+
is_stopped_requested: boolean;
|
|
14
|
+
}
|
|
15
|
+
export declare class AgentState {
|
|
16
|
+
context: Message[];
|
|
17
|
+
context_summary: string | null;
|
|
18
|
+
execution_meta: ExecutionMeta;
|
|
19
|
+
constructor(initialData?: Partial<Record<string, any>>);
|
|
20
|
+
}
|
|
21
|
+
export {};
|
|
22
|
+
//# sourceMappingURL=agent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAGvC,UAAU,aAAa;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE;QACV,IAAI,EAAE,MAAM,CAAC;QACb,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;KAC5B,CAAC;IACF,UAAU,EAAE,OAAO,CAAC;IACpB,cAAc,EAAE,OAAO,CAAC;IACxB,oBAAoB,EAAE,OAAO,CAAC;CAC/B;AAmBD,qBAAa,UAAU;IACrB,OAAO,EAAE,OAAO,EAAE,CAAM;IACxB,eAAe,EAAE,MAAM,GAAG,IAAI,CAAQ;IACtC,cAAc,EAAE,aAAa,CAA8B;gBAE/C,WAAW,GAAE,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAM;CAG3D"}
|