10xgraph-client 1.0.0-rc.1 → 1.0.0-rc.3

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.
Files changed (162) hide show
  1. package/CHANGELOG.md +160 -1
  2. package/README.md +170 -226
  3. package/dist/agent.d.ts +17 -5
  4. package/dist/agent.d.ts.map +1 -1
  5. package/dist/cjs/agent.d.ts +33 -0
  6. package/dist/cjs/client.d.ts +569 -0
  7. package/dist/cjs/compat.d.ts +27 -0
  8. package/dist/cjs/endpoints/clearThreadState.d.ts +14 -0
  9. package/dist/cjs/endpoints/deleteFile.d.ts +13 -0
  10. package/dist/cjs/endpoints/deleteMemory.d.ts +18 -0
  11. package/dist/cjs/endpoints/deleteThread.d.ts +18 -0
  12. package/dist/cjs/endpoints/deleteThreadMessage.d.ts +19 -0
  13. package/dist/cjs/endpoints/files.d.ts +115 -0
  14. package/dist/cjs/endpoints/fixGraph.d.ts +33 -0
  15. package/dist/cjs/endpoints/forgetMemories.d.ts +23 -0
  16. package/dist/cjs/endpoints/getMemory.d.ts +18 -0
  17. package/dist/cjs/endpoints/graph.d.ts +50 -0
  18. package/dist/cjs/endpoints/graphTools.d.ts +31 -0
  19. package/dist/cjs/endpoints/invoke.d.ts +66 -0
  20. package/dist/cjs/endpoints/listMemories.d.ts +27 -0
  21. package/dist/cjs/endpoints/me.d.ts +25 -0
  22. package/dist/cjs/endpoints/metadata.d.ts +5 -0
  23. package/dist/cjs/endpoints/observability.d.ts +111 -0
  24. package/dist/cjs/endpoints/ping.d.ts +9 -0
  25. package/dist/cjs/endpoints/realtime.d.ts +154 -0
  26. package/dist/cjs/endpoints/searchMemory.d.ts +58 -0
  27. package/dist/cjs/endpoints/stateSchema.d.ts +49 -0
  28. package/dist/cjs/endpoints/stopGraph.d.ts +35 -0
  29. package/dist/cjs/endpoints/storeMemory.d.ts +32 -0
  30. package/dist/cjs/endpoints/stream.d.ts +67 -0
  31. package/dist/cjs/endpoints/tasks.d.ts +95 -0
  32. package/dist/cjs/endpoints/threadDetails.d.ts +18 -0
  33. package/dist/cjs/endpoints/threadMessage.d.ts +16 -0
  34. package/dist/cjs/endpoints/threadMessages.d.ts +28 -0
  35. package/dist/cjs/endpoints/threadState.d.ts +13 -0
  36. package/dist/cjs/endpoints/threads.d.ts +38 -0
  37. package/dist/cjs/endpoints/updateMemory.d.ts +20 -0
  38. package/dist/cjs/endpoints/updateThreadMessageFeedback.d.ts +19 -0
  39. package/dist/cjs/endpoints/updateThreadState.d.ts +22 -0
  40. package/dist/cjs/endpoints/wsStream.d.ts +34 -0
  41. package/dist/cjs/errors.d.ts +212 -0
  42. package/dist/cjs/filters.d.ts +27 -0
  43. package/dist/cjs/index.d.ts +43 -0
  44. package/dist/cjs/interrupt.d.ts +45 -0
  45. package/dist/cjs/message.d.ts +176 -0
  46. package/dist/cjs/package.json +1 -0
  47. package/dist/cjs/request.d.ts +60 -0
  48. package/dist/cjs/tools.d.ts +80 -0
  49. package/dist/cjs/ws.d.ts +47 -0
  50. package/dist/client.d.ts +113 -58
  51. package/dist/client.d.ts.map +1 -1
  52. package/dist/endpoints/clearThreadState.d.ts.map +1 -1
  53. package/dist/endpoints/deleteFile.d.ts.map +1 -1
  54. package/dist/endpoints/deleteMemory.d.ts.map +1 -1
  55. package/dist/endpoints/deleteThread.d.ts.map +1 -1
  56. package/dist/endpoints/deleteThreadMessage.d.ts.map +1 -1
  57. package/dist/endpoints/files.d.ts +33 -0
  58. package/dist/endpoints/files.d.ts.map +1 -1
  59. package/dist/endpoints/fixGraph.d.ts.map +1 -1
  60. package/dist/endpoints/forgetMemories.d.ts +3 -1
  61. package/dist/endpoints/forgetMemories.d.ts.map +1 -1
  62. package/dist/endpoints/getMemory.d.ts.map +1 -1
  63. package/dist/endpoints/graph.d.ts +20 -8
  64. package/dist/endpoints/graph.d.ts.map +1 -1
  65. package/dist/endpoints/graphTools.d.ts.map +1 -1
  66. package/dist/endpoints/invoke.d.ts +2 -0
  67. package/dist/endpoints/invoke.d.ts.map +1 -1
  68. package/dist/endpoints/listMemories.d.ts +9 -0
  69. package/dist/endpoints/listMemories.d.ts.map +1 -1
  70. package/dist/endpoints/me.d.ts +26 -0
  71. package/dist/endpoints/me.d.ts.map +1 -0
  72. package/dist/endpoints/observability.d.ts +54 -0
  73. package/dist/endpoints/observability.d.ts.map +1 -1
  74. package/dist/endpoints/ping.d.ts.map +1 -1
  75. package/dist/endpoints/realtime.d.ts +25 -4
  76. package/dist/endpoints/realtime.d.ts.map +1 -1
  77. package/dist/endpoints/searchMemory.d.ts +3 -1
  78. package/dist/endpoints/searchMemory.d.ts.map +1 -1
  79. package/dist/endpoints/stateSchema.d.ts.map +1 -1
  80. package/dist/endpoints/stopGraph.d.ts +13 -3
  81. package/dist/endpoints/stopGraph.d.ts.map +1 -1
  82. package/dist/endpoints/storeMemory.d.ts.map +1 -1
  83. package/dist/endpoints/stream.d.ts +2 -0
  84. package/dist/endpoints/stream.d.ts.map +1 -1
  85. package/dist/endpoints/tasks.d.ts +96 -0
  86. package/dist/endpoints/tasks.d.ts.map +1 -0
  87. package/dist/endpoints/threadDetails.d.ts.map +1 -1
  88. package/dist/endpoints/threadMessage.d.ts.map +1 -1
  89. package/dist/endpoints/threadMessages.d.ts +6 -0
  90. package/dist/endpoints/threadMessages.d.ts.map +1 -1
  91. package/dist/endpoints/threadState.d.ts.map +1 -1
  92. package/dist/endpoints/threads.d.ts +9 -0
  93. package/dist/endpoints/threads.d.ts.map +1 -1
  94. package/dist/endpoints/updateMemory.d.ts.map +1 -1
  95. package/dist/endpoints/updateThreadMessageFeedback.d.ts.map +1 -1
  96. package/dist/endpoints/updateThreadState.d.ts +6 -1
  97. package/dist/endpoints/updateThreadState.d.ts.map +1 -1
  98. package/dist/endpoints/wsStream.d.ts +2 -0
  99. package/dist/endpoints/wsStream.d.ts.map +1 -1
  100. package/dist/errors.d.ts +52 -2
  101. package/dist/errors.d.ts.map +1 -1
  102. package/dist/filters.d.ts +28 -0
  103. package/dist/filters.d.ts.map +1 -0
  104. package/dist/index.cjs +3 -3
  105. package/dist/index.cjs.map +1 -1
  106. package/dist/index.d.ts +4 -1
  107. package/dist/index.d.ts.map +1 -1
  108. package/dist/index.js +1835 -1359
  109. package/dist/index.js.map +1 -1
  110. package/dist/interrupt.d.ts +46 -0
  111. package/dist/interrupt.d.ts.map +1 -0
  112. package/dist/message.d.ts +3 -0
  113. package/dist/message.d.ts.map +1 -1
  114. package/dist/request.d.ts +28 -0
  115. package/dist/request.d.ts.map +1 -1
  116. package/dist/tools.d.ts +14 -0
  117. package/dist/tools.d.ts.map +1 -1
  118. package/package.json +12 -7
  119. package/src/agent.ts +17 -4
  120. package/src/client.ts +282 -170
  121. package/src/endpoints/clearThreadState.ts +19 -20
  122. package/src/endpoints/deleteFile.ts +7 -12
  123. package/src/endpoints/deleteMemory.ts +9 -13
  124. package/src/endpoints/deleteThread.ts +9 -13
  125. package/src/endpoints/deleteThreadMessage.ts +9 -13
  126. package/src/endpoints/files.ts +164 -131
  127. package/src/endpoints/fixGraph.ts +7 -13
  128. package/src/endpoints/forgetMemories.ts +53 -61
  129. package/src/endpoints/getMemory.ts +9 -9
  130. package/src/endpoints/graph.ts +28 -21
  131. package/src/endpoints/graphTools.ts +7 -13
  132. package/src/endpoints/invoke.ts +84 -83
  133. package/src/endpoints/listMemories.ts +24 -13
  134. package/src/endpoints/me.ts +71 -0
  135. package/src/endpoints/observability.ts +77 -34
  136. package/src/endpoints/ping.ts +7 -13
  137. package/src/endpoints/realtime.ts +101 -39
  138. package/src/endpoints/searchMemory.ts +22 -14
  139. package/src/endpoints/stateSchema.ts +7 -13
  140. package/src/endpoints/stopGraph.ts +20 -16
  141. package/src/endpoints/storeMemory.ts +7 -8
  142. package/src/endpoints/stream.ts +158 -60
  143. package/src/endpoints/tasks.ts +170 -0
  144. package/src/endpoints/threadDetails.ts +9 -14
  145. package/src/endpoints/threadMessage.ts +9 -9
  146. package/src/endpoints/threadMessages.ts +15 -9
  147. package/src/endpoints/threadState.ts +19 -20
  148. package/src/endpoints/threads.ts +23 -12
  149. package/src/endpoints/updateMemory.ts +9 -9
  150. package/src/endpoints/updateThreadMessageFeedback.ts +9 -15
  151. package/src/endpoints/updateThreadState.ts +28 -22
  152. package/src/endpoints/wsStream.ts +163 -45
  153. package/src/errors.ts +319 -105
  154. package/src/filters.ts +32 -0
  155. package/src/index.ts +14 -1
  156. package/src/interrupt.ts +60 -0
  157. package/src/message.ts +4 -0
  158. package/src/request.ts +134 -0
  159. package/src/tools.ts +103 -0
  160. package/dist/endpoints/addThreadMessages.d.ts +0 -26
  161. package/dist/endpoints/addThreadMessages.d.ts.map +0 -1
  162. package/src/endpoints/addThreadMessages.ts +0 -87
package/CHANGELOG.md CHANGED
@@ -26,7 +26,166 @@ project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
26
26
 
27
27
  ---
28
28
 
29
- ## [Unreleased]
29
+ ## [1.0.0-rc.3] - 2026-11-11
30
+
31
+ The third release candidate of `10xgraph-client` 1.0. Use it with `10xgraph-api` 1.0.0rc6. New
32
+ response fields are typed optional, so the client still works against older servers; a
33
+ `ToolResultBlock.name` sent to an older server is ignored there.
34
+
35
+ ### Added
36
+
37
+ - `ToolResultBlock.name?: string`: the name of the tool that produced the result. The server sets it on results from `10xgraph` 1.0.0rc6 or later; older results have none. Results the client builds for client-side tools (`ToolExecutor`: success, thrown error, unknown tool, rejected arguments, duplicate call id) set it too.
38
+ - `me()` for `GET /v1/me` of `10xgraph-api`: who the caller is and what they may do. `data` is
39
+ `{ user_id, tenant, roles, permissions, reach }` (`reach` is `own`, `tenant` or `all`; `permissions` is
40
+ `['*']` for an unrestricted identity) or `{ auth: 'off' }` when the server runs without auth. New exported
41
+ types and helper: `MeResponse`, `MeData`, `MeIdentity`, `MeAuthOff`, `MeReach`, `isAuthOff`. Needs a
42
+ `10xgraph-api` with RBAC.
43
+ - Background task methods for the `/v1/tasks` routes of `10xgraph-api`: `runTask(name, { args, kwargs })`,
44
+ `scheduleTask(name, { args, kwargs, schedule })`, `getTask(id)`, `rescheduleTask(scheduleId, schedule)`
45
+ and `cancelTask(id)`. `schedule` is exactly one of `{ cron }`, `{ at }` or `{ every }` (seconds); the
46
+ client does not validate it, the server answers 422. New exported types: `TaskStatus`, `TaskSchedule`,
47
+ `TaskRecord`, `ScheduleRecord`, `TaskCallOptions`, `RunTaskResponse`, `ScheduleTaskRequest`,
48
+ `ScheduleTaskResponse`, `GetTaskResponse`, `RescheduleTaskResponse`, `CancelTaskResponse`. Needs a
49
+ `10xgraph-api` with background tasks.
50
+ - Filter support. `threads()` takes `filters` (sent as a JSON `filters` query parameter);
51
+ `searchMemory()`, `listMemories()` and `forgetMemories()` take `filters` in the request body.
52
+ A filter is `{ column: value }` (equality) or `{ column: { op: value } }` with the operators
53
+ `eq`, `ne`, `in`, `nin`, `like`, `ilike`, `is_null`, `gt`, `gte`, `lt`, `lte`. New exported
54
+ types: `Filters`, `FilterCondition`, `FilterOperator`, `FilterScalar`. `listMemories()` gains
55
+ `filters`. The client does not validate columns; the server answers 422. Needs a `10xgraph-api`
56
+ with filter support.
57
+
58
+ ### Changed
59
+
60
+ - `forgetMemories()` now throws a `TenxGraphError` subclass on a failed request (`ValidationError`
61
+ for 422, with the server message) instead of a plain `Error`. When the response has no JSON
62
+ error body the message is still `Forget memories failed: <status> <statusText>`.
63
+
64
+ ### Removed
65
+
66
+ - `addThreadMessages` and its `AddThreadMessages*` types. The `POST /v1/threads/{thread_id}/messages` route was removed from `10xgraph-api`, so the method had nothing to call. Send messages through `invoke` or `stream`, and use `updateThreadMessageFeedback` for feedback.
67
+
68
+ ## [1.0.0-rc.2] - 2026-10-30
69
+
70
+ The second release candidate of `10xgraph-client` 1.0, aligned with `10xgraph` and `10xgraph-api`
71
+ 1.0.0rc2. It is `1.0.0-rc.1` below plus the changes here. Use it with `10xgraph-api` 1.0.0rc2. New
72
+ response fields are typed optional, so the client still works against older servers. The client
73
+ API is source compatible with 0.6.0; the one hard requirement change is Node.js 20.
74
+
75
+ ### Breaking
76
+
77
+ - **Node.js 18 is no longer supported.** `engines` is `node >= 20.0.0` and Node 18 is removed
78
+ from CI (CI runs Node 20 and 22). Node 18 is past end of life.
79
+
80
+ ### Upgrade notes
81
+
82
+ - With `10xgraph-api` 1.0 a client that invents a thread id for a new conversation gets HTTP 403. Omit `thread_id` on the first request and reuse the id the server returns (see
83
+ `1.0.0-rc.1` below).
84
+ - Behaviour you may notice, none of it a signature change:
85
+ - `stream()` and `wsStream()` now throw (`StreamError`, `WebSocketError`) when a stream is cut
86
+ or the server closes the socket mid-run. Before, they ended as if the run had succeeded.
87
+ - The `timeout` option is an idle timeout on `stream()` and `wsStream()`: it limits how long the
88
+ client waits on the network, not how long the whole run takes.
89
+ - A `baseUrl` with a trailing slash is accepted; the slashes are stripped.
90
+ - Errors from timeouts and network failures are `RequestTimeoutError` and `NetworkError`, not
91
+ plain `Error`. Code that matched on message text should check the class.
92
+
93
+ ### Added
94
+
95
+ - `Interrupt` type, `getInterrupt(chunk)`, `approveInterrupt(interrupt, value?)` and
96
+ `rejectInterrupt(interrupt)`. `getInterrupt` reads the pending interrupt from an `updates`
97
+ chunk; the helpers return `{ resume, interrupt_id }` to spread into the options of
98
+ `invoke()`, `stream()` or `wsStream()`.
99
+ - `authToken` accepts a function `() => string | null | undefined`, called on every request and
100
+ on every realtime reconnect, so short-lived tokens refresh without rebuilding the client.
101
+ `setAuthToken(token)` replaces it, and `clearAuth()` drops the bearer token and `auth`
102
+ credentials.
103
+ - Every method that makes a request takes a `signal` option (`RequestOptions`), not only
104
+ `invoke()`, `stream()` and `wsStream()`.
105
+ - New error classes and fields: `RequestTimeoutError`, `NetworkError`, `WebSocketError`,
106
+ `StreamError` and `RateLimitError`. `RateLimitError` carries `retryAfterSeconds` from the
107
+ `Retry-After` header or the body. Errors carry `cause`, `endpoint` and `method`, and
108
+ `requestId` reads the `x-request-id` header.
109
+ - Remote tool registrations take `validate(args)` (throw or return `false` to refuse the call)
110
+ and `maxArgsBytes` (default 1 MiB). The declared `parameters` are checked against the
111
+ server-sent arguments before the handler runs, and a repeated call id is rejected.
112
+ - `listMemories` takes `offset`, and its response has `has_more` and `next_offset`, so a user with
113
+ many memories can page. Needs `10xgraph-api` 1.0.
114
+ - CommonJS consumers get their own type declarations (`dist/cjs/index.d.ts`) through the
115
+ `exports` map, so `require` works with `nodenext` type checking.
116
+ - `signal?: AbortSignal` option on `invoke()`, `stream()` and `wsStream()`. Aborting it cancels the
117
+ in-flight request (and the open stream body or WebSocket). The call rejects with the abort error
118
+ (`name === 'AbortError'`), not the "Request timeout" error. A signal that is already aborted
119
+ rejects before any request is sent.
120
+ - `listFiles(params?)` for `GET /v1/files` (`{ limit?, offset? }`), with `ListFilesRequest`,
121
+ `ListFilesResponse`, `FileListItem`. A media store that cannot enumerate files answers 501,
122
+ thrown as a `TenxGraphError`.
123
+ - `has_more`, `offset` and `limit` on the `threads()` and `threadMessages()` response data.
124
+ - Observability types for the run trace: per-span `status`, `error`, `inputs`, `outputs`, `step`,
125
+ `visit`, `total_tokens`, `reasoning_tokens`, `tool_name`, `tool_call_id`; run-level `error`,
126
+ `model`, `models`, `notes`; payload-level `enabled` and `reason` (`ObsEmptyReason`), so a UI can
127
+ tell "tracing is off" from "no runs yet". New `ObsMessageSummary` type.
128
+ - `GraphInfo.realtime_options` (`GraphRealtimeOptions`): the Live init options the server honors, null
129
+ for non-realtime graphs.
130
+ - Eval report types for the extended report: case `error` and `error` status, rubric
131
+ `kind`, `passed`, `threshold`, `details`, `error`, case `expected_detail`, run `counts`, and
132
+ `errors` on run summaries.
133
+
134
+ ### Changed
135
+
136
+ - Live sessions without a `thread_id` now use the server-created id. The client no longer invents one: it sends none, reads the id from the new `session_started` event (`{ type: 'session_started', thread_id }`, the first server event) into `session.threadId` (`string | null`, set once the event arrives), and sends it back on reconnect so the same thread continues. A caller-supplied `thread_id` works as before. Needs `10xgraph-api` 1.0, where an invented id gets 403.
137
+ - **Typed change:** `RealtimeSession.threadId` is `string | null`. It is `null` until the
138
+ `session_started` event arrives when you passed no `thread_id`, so code that read it as a
139
+ `string` right after `realtime()` must handle `null` (or wait for `session_started`).
140
+ `session.ready` still resolves when the socket opens, not on `session_started`, and the event is
141
+ part of the `RealtimeEvent` union.
142
+ - The `timeout` is an idle timeout on `stream()` and `wsStream()`: it runs while the client waits
143
+ for headers or the next piece of data and is paused while your code handles a chunk.
144
+ - `invoke()` and the other REST methods apply the timeout and your `signal` to the response body
145
+ as well, not only to the response headers.
146
+ - Realtime reconnects use jittered backoff, restore the attempt budget only after a connection
147
+ stayed open for 10 s, go straight to the longest delay on close code 1013, and stop with a fatal
148
+ `policy_violation` error on close code 1008 (an expired or rejected token).
149
+ - Path ids (thread, message, memory) are percent-encoded in every endpoint.
150
+ - Header-type credentials other than `Authorization` (for example `X-API-Key`) are not forwarded
151
+ on a cross-origin redirect; the call fails instead.
152
+ - The HTTP error mapping covers every JSON error body, including the real server's 409
153
+ `state_conflict` body, and maps the server's codes (`RECURSION_001`, `STORAGE_TRANSIENT_000`,
154
+ `STORAGE_SCHEMA_000`, `STORAGE_SERIALIZATION_000`) to `GraphRecursionError`,
155
+ `TransientStorageError`, `SchemaVersionError` and `SerializationError`.
156
+ - Response and request types match what the server sends: fields the server never sends were
157
+ removed from `AgentState` and `StopGraphResponse`, nullable fields are typed nullable, and
158
+ `updateThreadState` no longer accepts keys the server rejects.
159
+ - `stream()` and `wsStream()` stop a client-tool loop at `recursion_limit`; `recursion_limit: 0`
160
+ is honoured and not turned into 25.
161
+
162
+ ### Fixed
163
+
164
+ - Leaving a `for await` loop over `stream()` early (`break`, `return` or a throw) cancels the
165
+ request. Before, the connection and the server run stayed open and the thread answered 409.
166
+ - `wsStream()` no longer hangs when the server answers a frame with an error chunk, and it
167
+ throws when the server closes the socket before the run finishes (1012, 1008, 1011).
168
+ - A truncated or unparseable stream line throws `StreamError` and a reset connection throws a
169
+ `StreamError` with code `STREAM_INTERRUPTED`, not a raw `TypeError: terminated`.
170
+ - A conflict (HTTP 409) throws `ConflictError` against the real server. It used to throw a
171
+ `TypeError`.
172
+ - `client.realtime()` no longer crashes the Node process with an unhandled rejection when the
173
+ connection fails and `session.ready` was not awaited.
174
+ - Realtime: `close()` during a pending reconnect no longer reopens the session, `send*` before
175
+ the socket is open is dropped and does not throw, and a failing reconnect does not end the
176
+ process.
177
+ - Failed requests no longer leave the timeout timer running, so a script that catches a
178
+ `ping()` error exits at once instead of after the timeout.
179
+ - Empty arrays are no longer stripped from messages and tool results, so a tool result with
180
+ `output: []` reaches the model as an empty list.
181
+ - `recursion_limit_reached` is true only when the limit stopped the run, and a limit stop is
182
+ reported to the caller instead of ending silently.
183
+ - Endpoint calls that time out throw `RequestTimeoutError`, not a raw `AbortError`, and
184
+ `forgetMemories()` throws a typed error, not a plain `Error`.
185
+ - `searchMemory()` no longer sends `memory_type: 'episodic'`, `category: ''` and
186
+ `score_threshold: 0` when you leave them unset. They are omitted so the server applies no filter,
187
+ and a search without a type now covers all memory types. Pass `memory_type` explicitly to keep
188
+ the old episodic-only behavior.
30
189
 
31
190
  ---
32
191