@recursiv/sdk 0.7.14 → 0.7.15

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 (275) hide show
  1. package/README.md +23 -4
  2. package/dist/client.d.ts +0 -1
  3. package/dist/client.js +0 -1
  4. package/dist/errors.d.ts +0 -1
  5. package/dist/errors.js +0 -1
  6. package/dist/index.d.ts +1 -2
  7. package/dist/index.js +0 -1
  8. package/dist/lib/sse.d.ts +0 -1
  9. package/dist/lib/sse.js +0 -1
  10. package/dist/lib/webhooks.d.ts +0 -1
  11. package/dist/lib/webhooks.js +0 -1
  12. package/dist/next/index.d.ts +0 -1
  13. package/dist/next/index.js +0 -1
  14. package/dist/next/scopes.d.ts +0 -1
  15. package/dist/next/scopes.js +0 -1
  16. package/dist/next/server-auth.d.ts +0 -1
  17. package/dist/next/server-auth.js +0 -1
  18. package/dist/react/index.d.ts +0 -1
  19. package/dist/react/index.js +0 -1
  20. package/dist/react/useChat.d.ts +0 -1
  21. package/dist/react/useChat.js +0 -1
  22. package/dist/realtime.d.ts +1 -2
  23. package/dist/realtime.js +23 -11
  24. package/dist/resources/accounts.d.ts +0 -1
  25. package/dist/resources/accounts.js +0 -1
  26. package/dist/resources/admin.d.ts +0 -1
  27. package/dist/resources/admin.js +0 -1
  28. package/dist/resources/agents.d.ts +11 -2
  29. package/dist/resources/agents.js +12 -1
  30. package/dist/resources/app-subscriptions.d.ts +0 -1
  31. package/dist/resources/app-subscriptions.js +0 -1
  32. package/dist/resources/auth.d.ts +25 -1
  33. package/dist/resources/auth.js +75 -4
  34. package/dist/resources/billing.d.ts +0 -1
  35. package/dist/resources/billing.js +0 -1
  36. package/dist/resources/brain.d.ts +0 -1
  37. package/dist/resources/brain.js +0 -1
  38. package/dist/resources/brief.d.ts +0 -1
  39. package/dist/resources/brief.js +0 -1
  40. package/dist/resources/chat.d.ts +0 -1
  41. package/dist/resources/chat.js +0 -1
  42. package/dist/resources/commands.d.ts +0 -1
  43. package/dist/resources/commands.js +0 -1
  44. package/dist/resources/communities.d.ts +66 -4
  45. package/dist/resources/communities.js +62 -2
  46. package/dist/resources/curator.d.ts +0 -1
  47. package/dist/resources/curator.js +0 -1
  48. package/dist/resources/databases.d.ts +0 -1
  49. package/dist/resources/databases.js +0 -1
  50. package/dist/resources/deployments.d.ts +0 -1
  51. package/dist/resources/deployments.js +0 -1
  52. package/dist/resources/dispatcher.d.ts +18 -2
  53. package/dist/resources/dispatcher.js +6 -2
  54. package/dist/resources/email.d.ts +0 -1
  55. package/dist/resources/email.js +0 -1
  56. package/dist/resources/env-vars.d.ts +0 -1
  57. package/dist/resources/env-vars.js +0 -1
  58. package/dist/resources/evidence.d.ts +26 -4
  59. package/dist/resources/evidence.js +8 -1
  60. package/dist/resources/free-tier.d.ts +0 -1
  61. package/dist/resources/free-tier.js +0 -1
  62. package/dist/resources/github.d.ts +0 -1
  63. package/dist/resources/github.js +0 -1
  64. package/dist/resources/goals.d.ts +0 -1
  65. package/dist/resources/goals.js +0 -1
  66. package/dist/resources/human-asks.d.ts +0 -1
  67. package/dist/resources/human-asks.js +0 -1
  68. package/dist/resources/human-input.d.ts +0 -1
  69. package/dist/resources/human-input.js +0 -1
  70. package/dist/resources/inbox.d.ts +0 -1
  71. package/dist/resources/inbox.js +0 -1
  72. package/dist/resources/integrations.d.ts +0 -1
  73. package/dist/resources/integrations.js +0 -1
  74. package/dist/resources/invite-codes-admin.d.ts +0 -1
  75. package/dist/resources/invite-codes-admin.js +0 -1
  76. package/dist/resources/invite-codes.d.ts +0 -1
  77. package/dist/resources/invite-codes.js +0 -1
  78. package/dist/resources/jobs.d.ts +0 -1
  79. package/dist/resources/jobs.js +0 -1
  80. package/dist/resources/link-preview.d.ts +0 -1
  81. package/dist/resources/link-preview.js +0 -1
  82. package/dist/resources/media.d.ts +0 -1
  83. package/dist/resources/media.js +0 -1
  84. package/dist/resources/memory.d.ts +0 -1
  85. package/dist/resources/memory.js +0 -1
  86. package/dist/resources/moderation.d.ts +0 -1
  87. package/dist/resources/moderation.js +0 -1
  88. package/dist/resources/network.d.ts +0 -1
  89. package/dist/resources/network.js +0 -1
  90. package/dist/resources/notifications.d.ts +14 -2
  91. package/dist/resources/notifications.js +5 -3
  92. package/dist/resources/organization-security.d.ts +0 -1
  93. package/dist/resources/organization-security.js +0 -1
  94. package/dist/resources/organization-settings.d.ts +18 -1
  95. package/dist/resources/organization-settings.js +4 -1
  96. package/dist/resources/organizations.d.ts +0 -1
  97. package/dist/resources/organizations.js +0 -1
  98. package/dist/resources/posts.d.ts +0 -1
  99. package/dist/resources/posts.js +0 -1
  100. package/dist/resources/profiles.d.ts +8 -1
  101. package/dist/resources/profiles.js +8 -1
  102. package/dist/resources/project-brain.d.ts +18 -1
  103. package/dist/resources/project-brain.js +11 -1
  104. package/dist/resources/project-settings.d.ts +0 -1
  105. package/dist/resources/project-settings.js +0 -1
  106. package/dist/resources/projects.d.ts +0 -1
  107. package/dist/resources/projects.js +0 -1
  108. package/dist/resources/protocols.d.ts +54 -1
  109. package/dist/resources/protocols.js +29 -1
  110. package/dist/resources/reports.d.ts +0 -1
  111. package/dist/resources/reports.js +0 -1
  112. package/dist/resources/sandbox.d.ts +0 -1
  113. package/dist/resources/sandbox.js +0 -1
  114. package/dist/resources/settings.d.ts +0 -1
  115. package/dist/resources/settings.js +0 -1
  116. package/dist/resources/simulator.d.ts +0 -1
  117. package/dist/resources/simulator.js +0 -1
  118. package/dist/resources/storage.d.ts +0 -1
  119. package/dist/resources/storage.js +0 -1
  120. package/dist/resources/swarms.d.ts +0 -1
  121. package/dist/resources/swarms.js +0 -1
  122. package/dist/resources/tags.d.ts +0 -1
  123. package/dist/resources/tags.js +0 -1
  124. package/dist/resources/templates.d.ts +0 -1
  125. package/dist/resources/templates.js +0 -1
  126. package/dist/resources/uploads.d.ts +0 -1
  127. package/dist/resources/uploads.js +0 -1
  128. package/dist/resources/users.d.ts +0 -1
  129. package/dist/resources/users.js +0 -1
  130. package/dist/resources/video.d.ts +0 -1
  131. package/dist/resources/video.js +0 -1
  132. package/dist/resources/wallet.d.ts +16 -1
  133. package/dist/resources/wallet.js +12 -1
  134. package/dist/resources/webhooks.d.ts +0 -1
  135. package/dist/resources/webhooks.js +0 -1
  136. package/dist/types.d.ts +34 -1
  137. package/dist/types.js +0 -1
  138. package/llm.md +29 -2
  139. package/package.json +13 -7
  140. package/dist/client.d.ts.map +0 -1
  141. package/dist/client.js.map +0 -1
  142. package/dist/errors.d.ts.map +0 -1
  143. package/dist/errors.js.map +0 -1
  144. package/dist/index.d.ts.map +0 -1
  145. package/dist/index.js.map +0 -1
  146. package/dist/lib/sse.d.ts.map +0 -1
  147. package/dist/lib/sse.js.map +0 -1
  148. package/dist/lib/webhooks.d.ts.map +0 -1
  149. package/dist/lib/webhooks.js.map +0 -1
  150. package/dist/next/index.d.ts.map +0 -1
  151. package/dist/next/index.js.map +0 -1
  152. package/dist/next/scopes.d.ts.map +0 -1
  153. package/dist/next/scopes.js.map +0 -1
  154. package/dist/next/server-auth.d.ts.map +0 -1
  155. package/dist/next/server-auth.js.map +0 -1
  156. package/dist/react/index.d.ts.map +0 -1
  157. package/dist/react/index.js.map +0 -1
  158. package/dist/react/useChat.d.ts.map +0 -1
  159. package/dist/react/useChat.js.map +0 -1
  160. package/dist/realtime.d.ts.map +0 -1
  161. package/dist/realtime.js.map +0 -1
  162. package/dist/resources/accounts.d.ts.map +0 -1
  163. package/dist/resources/accounts.js.map +0 -1
  164. package/dist/resources/admin.d.ts.map +0 -1
  165. package/dist/resources/admin.js.map +0 -1
  166. package/dist/resources/agents.d.ts.map +0 -1
  167. package/dist/resources/agents.js.map +0 -1
  168. package/dist/resources/app-subscriptions.d.ts.map +0 -1
  169. package/dist/resources/app-subscriptions.js.map +0 -1
  170. package/dist/resources/auth.d.ts.map +0 -1
  171. package/dist/resources/auth.js.map +0 -1
  172. package/dist/resources/billing.d.ts.map +0 -1
  173. package/dist/resources/billing.js.map +0 -1
  174. package/dist/resources/brain.d.ts.map +0 -1
  175. package/dist/resources/brain.js.map +0 -1
  176. package/dist/resources/brief.d.ts.map +0 -1
  177. package/dist/resources/brief.js.map +0 -1
  178. package/dist/resources/chat.d.ts.map +0 -1
  179. package/dist/resources/chat.js.map +0 -1
  180. package/dist/resources/commands.d.ts.map +0 -1
  181. package/dist/resources/commands.js.map +0 -1
  182. package/dist/resources/communities.d.ts.map +0 -1
  183. package/dist/resources/communities.js.map +0 -1
  184. package/dist/resources/curator.d.ts.map +0 -1
  185. package/dist/resources/curator.js.map +0 -1
  186. package/dist/resources/databases.d.ts.map +0 -1
  187. package/dist/resources/databases.js.map +0 -1
  188. package/dist/resources/deployments.d.ts.map +0 -1
  189. package/dist/resources/deployments.js.map +0 -1
  190. package/dist/resources/dispatcher.d.ts.map +0 -1
  191. package/dist/resources/dispatcher.js.map +0 -1
  192. package/dist/resources/email.d.ts.map +0 -1
  193. package/dist/resources/email.js.map +0 -1
  194. package/dist/resources/env-vars.d.ts.map +0 -1
  195. package/dist/resources/env-vars.js.map +0 -1
  196. package/dist/resources/evidence.d.ts.map +0 -1
  197. package/dist/resources/evidence.js.map +0 -1
  198. package/dist/resources/free-tier.d.ts.map +0 -1
  199. package/dist/resources/free-tier.js.map +0 -1
  200. package/dist/resources/github.d.ts.map +0 -1
  201. package/dist/resources/github.js.map +0 -1
  202. package/dist/resources/goals.d.ts.map +0 -1
  203. package/dist/resources/goals.js.map +0 -1
  204. package/dist/resources/human-asks.d.ts.map +0 -1
  205. package/dist/resources/human-asks.js.map +0 -1
  206. package/dist/resources/human-input.d.ts.map +0 -1
  207. package/dist/resources/human-input.js.map +0 -1
  208. package/dist/resources/inbox.d.ts.map +0 -1
  209. package/dist/resources/inbox.js.map +0 -1
  210. package/dist/resources/integrations.d.ts.map +0 -1
  211. package/dist/resources/integrations.js.map +0 -1
  212. package/dist/resources/invite-codes-admin.d.ts.map +0 -1
  213. package/dist/resources/invite-codes-admin.js.map +0 -1
  214. package/dist/resources/invite-codes.d.ts.map +0 -1
  215. package/dist/resources/invite-codes.js.map +0 -1
  216. package/dist/resources/jobs.d.ts.map +0 -1
  217. package/dist/resources/jobs.js.map +0 -1
  218. package/dist/resources/link-preview.d.ts.map +0 -1
  219. package/dist/resources/link-preview.js.map +0 -1
  220. package/dist/resources/media.d.ts.map +0 -1
  221. package/dist/resources/media.js.map +0 -1
  222. package/dist/resources/memory.d.ts.map +0 -1
  223. package/dist/resources/memory.js.map +0 -1
  224. package/dist/resources/moderation.d.ts.map +0 -1
  225. package/dist/resources/moderation.js.map +0 -1
  226. package/dist/resources/network.d.ts.map +0 -1
  227. package/dist/resources/network.js.map +0 -1
  228. package/dist/resources/notifications.d.ts.map +0 -1
  229. package/dist/resources/notifications.js.map +0 -1
  230. package/dist/resources/organization-security.d.ts.map +0 -1
  231. package/dist/resources/organization-security.js.map +0 -1
  232. package/dist/resources/organization-settings.d.ts.map +0 -1
  233. package/dist/resources/organization-settings.js.map +0 -1
  234. package/dist/resources/organizations.d.ts.map +0 -1
  235. package/dist/resources/organizations.js.map +0 -1
  236. package/dist/resources/posts.d.ts.map +0 -1
  237. package/dist/resources/posts.js.map +0 -1
  238. package/dist/resources/profiles.d.ts.map +0 -1
  239. package/dist/resources/profiles.js.map +0 -1
  240. package/dist/resources/project-brain.d.ts.map +0 -1
  241. package/dist/resources/project-brain.js.map +0 -1
  242. package/dist/resources/project-settings.d.ts.map +0 -1
  243. package/dist/resources/project-settings.js.map +0 -1
  244. package/dist/resources/projects.d.ts.map +0 -1
  245. package/dist/resources/projects.js.map +0 -1
  246. package/dist/resources/protocols.d.ts.map +0 -1
  247. package/dist/resources/protocols.js.map +0 -1
  248. package/dist/resources/reports.d.ts.map +0 -1
  249. package/dist/resources/reports.js.map +0 -1
  250. package/dist/resources/sandbox.d.ts.map +0 -1
  251. package/dist/resources/sandbox.js.map +0 -1
  252. package/dist/resources/settings.d.ts.map +0 -1
  253. package/dist/resources/settings.js.map +0 -1
  254. package/dist/resources/simulator.d.ts.map +0 -1
  255. package/dist/resources/simulator.js.map +0 -1
  256. package/dist/resources/storage.d.ts.map +0 -1
  257. package/dist/resources/storage.js.map +0 -1
  258. package/dist/resources/swarms.d.ts.map +0 -1
  259. package/dist/resources/swarms.js.map +0 -1
  260. package/dist/resources/tags.d.ts.map +0 -1
  261. package/dist/resources/tags.js.map +0 -1
  262. package/dist/resources/templates.d.ts.map +0 -1
  263. package/dist/resources/templates.js.map +0 -1
  264. package/dist/resources/uploads.d.ts.map +0 -1
  265. package/dist/resources/uploads.js.map +0 -1
  266. package/dist/resources/users.d.ts.map +0 -1
  267. package/dist/resources/users.js.map +0 -1
  268. package/dist/resources/video.d.ts.map +0 -1
  269. package/dist/resources/video.js.map +0 -1
  270. package/dist/resources/wallet.d.ts.map +0 -1
  271. package/dist/resources/wallet.js.map +0 -1
  272. package/dist/resources/webhooks.d.ts.map +0 -1
  273. package/dist/resources/webhooks.js.map +0 -1
  274. package/dist/types.d.ts.map +0 -1
  275. package/dist/types.js.map +0 -1
package/README.md CHANGED
@@ -8,7 +8,7 @@
8
8
  npm install @recursiv/sdk
9
9
  ```
10
10
 
11
- Node.js >= 18. ESM only. Zero runtime dependencies.
11
+ Node.js >= 18. ESM only (`import` works on 18+; `require()` needs Node >= 22, which can require ES modules). Zero runtime dependencies; realtime and the Next.js helpers each declare one optional peer, installed only if you use them.
12
12
 
13
13
  ## 60-second quickstart
14
14
 
@@ -109,10 +109,27 @@ for await (const chunk of r.agents.chatStream(agent.id, { message: 'Hello!' }))
109
109
  | `r.admin` | User management, stats, content reports (`listReports`, `resolveReport`, `dismissReport`) |
110
110
  | `r.dispatcher` | Task queue, claims, signals, outcomes, webhooks |
111
111
  | `r.goals` | Org goals with task rollups (group dispatcher tasks) |
112
- | `r.protocols` | `list` returns bounded adapter `maturity`, `limitations`, and exhaustive `supported`/`planned`/`unsupported` implementation capabilities (not provider health or enablement); settings, candidate refresh/status, and search |
112
+ | `r.protocols` | `list` returns bounded adapter `maturity`, `limitations`, and exhaustive `supported`/`planned`/`unsupported` implementation capabilities (not provider health or enablement); settings, candidate refresh/status, search, and read-only quarantined candidate review via `listCandidates` / `getCandidate` |
113
113
 
114
114
  Full reference: see [llm.md](./llm.md) (ships with this package) or the type definitions in `dist/`.
115
115
 
116
+ ### Quarantined protocol candidates
117
+
118
+ `r.protocols.listCandidates({ protocol?, limit?, cursor? })` and
119
+ `r.protocols.getCandidate(id)` read unpublished candidates, not feed posts.
120
+ Both require an `admin`-scoped, project-bound key, a live admin role, and
121
+ existing project-admin access. App/network scope is not a caller parameter.
122
+ These GET methods do not collect content, update settings, or publish anything.
123
+
124
+ Lists return `{ data, meta: { limit, has_more, next_cursor } }` with no offset;
125
+ the API defaults to 20 rows and permits at most 50. Details return `{ data }`.
126
+ Render candidate `content` as plain text and respect
127
+ `content_truncated`. Safe source IDs are preserved byte-exact. A null
128
+ `external_id` means unsafe or malformed provenance was withheld; an author's
129
+ `native_id` may likewise be absent or withheld. Do not invent replacement IDs.
130
+ API failures, including routes absent from an older
131
+ deployment, throw the normal SDK errors; do not present them as an empty queue.
132
+
116
133
  ## Configuration
117
134
 
118
135
  ```typescript
@@ -281,6 +298,8 @@ with the returned API key; omit it for flows that still need the cookie session.
281
298
 
282
299
  Cookie-session helpers for the App Router (Next 14 and 15). Each user signs in once, gets a **project-scoped per-user API key** in an httpOnly cookie, and every request acts as that user — no platform key on the server.
283
300
 
301
+ This subpath uses the optional `server-only` peer to keep its exports out of Client Components. Install it alongside the SDK in Next.js apps: `npm install server-only`.
302
+
284
303
  ```typescript
285
304
  // src/lib/recursiv.ts (server-only module)
286
305
  import 'server-only';
@@ -359,9 +378,9 @@ if (page1.meta.has_more) {
359
378
 
360
379
  | Environment | Status | Notes |
361
380
  |-------------|--------|-------|
362
- | Node.js >= 18 | Full support | ESM only. Uses native fetch. |
381
+ | Node.js >= 18 | Full support | ESM only (`require()` needs Node >= 22). Uses native fetch. |
363
382
  | Next.js | Full support | Server components, server actions, and route handlers. Use `@recursiv/sdk/next` for cookie-session auth (Next 14 and 15). |
364
- | React (Vite, CRA) | Full support | Bundle-friendly, zero dependencies |
383
+ | React (Vite, CRA) | Full support | Bundle-friendly, zero dependencies. Realtime needs the optional `socket.io-client` peer. |
365
384
  | React Native / Expo | Supported with caveats | `chatStream()` requires manual SSE handling. See [React Native guide](./docs/guide-react-native.md). |
366
385
  | Deno | Full support | ESM native, fetch native |
367
386
  | Bun | Full support | ESM native, fetch native |
package/dist/client.d.ts CHANGED
@@ -36,4 +36,3 @@ export declare class HttpClient {
36
36
  delete<T>(path: string): Promise<T>;
37
37
  fetchRaw(path: string, options: RequestInit): Promise<Response>;
38
38
  }
39
- //# sourceMappingURL=client.d.ts.map
package/dist/client.js CHANGED
@@ -220,4 +220,3 @@ export class HttpClient {
220
220
  });
221
221
  }
222
222
  }
223
- //# sourceMappingURL=client.js.map
package/dist/errors.d.ts CHANGED
@@ -33,4 +33,3 @@ export declare class RateLimitError extends RecursivError {
33
33
  export declare class ConflictError extends RecursivError {
34
34
  constructor(body: ApiErrorBody['error']);
35
35
  }
36
- //# sourceMappingURL=errors.d.ts.map
package/dist/errors.js CHANGED
@@ -86,4 +86,3 @@ export class ConflictError extends RecursivError {
86
86
  this.name = 'ConflictError';
87
87
  }
88
88
  }
89
- //# sourceMappingURL=errors.js.map
package/dist/index.d.ts CHANGED
@@ -186,7 +186,7 @@ export type { UploadMediaInput, UploadUrlInput, UploadUrlResult } from './resour
186
186
  export { WalletResource } from './resources/wallet.js';
187
187
  export { ProtocolsResource } from './resources/protocols.js';
188
188
  export { PROTOCOL_ADAPTER_MATURITIES, PROTOCOL_CAPABILITY_OPERATIONS, PROTOCOL_CAPABILITY_STATUSES, } from './resources/protocols.js';
189
- export type { ProtocolAdapterMaturity, ProtocolAdapterMetadata, ProtocolCapabilityOperation, ProtocolCapabilityStatus, ProtocolCollectionStatus, ProtocolRefreshResult, ProtocolSettings, ProtocolSettingsUpdateResult, UpdateSettingsInput as UpdateProtocolSettingsInput, } from './resources/protocols.js';
189
+ export type { ListProtocolCandidatesParams, ProtocolAdapterMaturity, ProtocolAdapterMetadata, ProtocolCandidateListResponse, ProtocolCandidatePageMeta, ProtocolCapabilityOperation, ProtocolCapabilityStatus, ProtocolCollectionStatus, ProtocolQuarantinedCandidate, ProtocolRefreshResult, ProtocolSettings, ProtocolSettingsUpdateResult, UpdateSettingsInput as UpdateProtocolSettingsInput, } from './resources/protocols.js';
190
190
  export { InboxResource } from './resources/inbox.js';
191
191
  export { NetworkResource } from './resources/network.js';
192
192
  export { SimulatorResource } from './resources/simulator.js';
@@ -213,4 +213,3 @@ export { RecursivError, AuthenticationError, AuthorizationError, NotFoundError,
213
213
  export { parseSSE } from './lib/sse.js';
214
214
  export * from './lib/webhooks.js';
215
215
  export type * from './types.js';
216
- //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -252,4 +252,3 @@ export { MediaResource } from './resources/media.js';
252
252
  export { RecursivError, AuthenticationError, AuthorizationError, NotFoundError, ValidationError, InsufficientCreditsError, RateLimitError, ConflictError, } from './errors.js';
253
253
  export { parseSSE } from './lib/sse.js';
254
254
  export * from './lib/webhooks.js';
255
- //# sourceMappingURL=index.js.map
package/dist/lib/sse.d.ts CHANGED
@@ -3,4 +3,3 @@ import type { StreamChunk } from '../types.js';
3
3
  * Parse a Server-Sent Events stream into StreamChunk objects.
4
4
  */
5
5
  export declare function parseSSE(body: ReadableStream<Uint8Array> | null): AsyncGenerator<StreamChunk>;
6
- //# sourceMappingURL=sse.d.ts.map
package/dist/lib/sse.js CHANGED
@@ -49,4 +49,3 @@ export async function* parseSSE(body) {
49
49
  reader.releaseLock();
50
50
  }
51
51
  }
52
- //# sourceMappingURL=sse.js.map
@@ -38,4 +38,3 @@ export declare function constructWebhookEvent<T = any>(payload: string | Uint8Ar
38
38
  event: RecursivWebhookEvent<T>;
39
39
  idempotencyKey: string;
40
40
  }>;
41
- //# sourceMappingURL=webhooks.d.ts.map
@@ -88,4 +88,3 @@ function hexToBytes(hex) {
88
88
  }
89
89
  return bytes;
90
90
  }
91
- //# sourceMappingURL=webhooks.js.map
@@ -8,4 +8,3 @@ import 'server-only';
8
8
  export { createRecursivAuth, RecursivNextAuth } from './server-auth.js';
9
9
  export { DEFAULT_USER_KEY_SCOPES } from './scopes.js';
10
10
  export type { RecursivNextAuthConfig, SessionUser, AuthResult, WriteOptions, SessionCookieOptions, SessionCookieDescriptor, CookieWriter, RequestCookiesLike, } from './server-auth.js';
11
- //# sourceMappingURL=index.d.ts.map
@@ -7,4 +7,3 @@
7
7
  import 'server-only';
8
8
  export { createRecursivAuth, RecursivNextAuth } from './server-auth.js';
9
9
  export { DEFAULT_USER_KEY_SCOPES } from './scopes.js';
10
- //# sourceMappingURL=index.js.map
@@ -32,4 +32,3 @@
32
32
  * re-authenticate.
33
33
  */
34
34
  export declare const DEFAULT_USER_KEY_SCOPES: string[];
35
- //# sourceMappingURL=scopes.d.ts.map
@@ -45,4 +45,3 @@ export const DEFAULT_USER_KEY_SCOPES = [
45
45
  'databases:read', 'databases:write',
46
46
  'storage:read', 'storage:write',
47
47
  ];
48
- //# sourceMappingURL=scopes.js.map
@@ -184,4 +184,3 @@ export declare class RecursivNextAuth {
184
184
  * ```
185
185
  */
186
186
  export declare function createRecursivAuth(config?: RecursivNextAuthConfig): RecursivNextAuth;
187
- //# sourceMappingURL=server-auth.d.ts.map
@@ -246,4 +246,3 @@ export class RecursivNextAuth {
246
246
  export function createRecursivAuth(config = {}) {
247
247
  return new RecursivNextAuth(config);
248
248
  }
249
- //# sourceMappingURL=server-auth.js.map
@@ -1,2 +1 @@
1
1
  export * from './useChat.js';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1,2 +1 @@
1
1
  export * from './useChat.js';
2
- //# sourceMappingURL=index.js.map
@@ -23,4 +23,3 @@ export declare function useChat(recursiv: Recursiv, options?: UseChatOptions): {
23
23
  fetchHistory: (limit?: number, cursor?: string) => Promise<import("../types.js").PaginatedResponse<import("../types.js").Message>>;
24
24
  sendMessage: (content: string, replyToId?: string) => Promise<import("../types.js").SingleResponse<import("../types.js").SentMessage>>;
25
25
  };
26
- //# sourceMappingURL=useChat.d.ts.map
@@ -108,4 +108,3 @@ export function useChat(recursiv, options = {}) {
108
108
  }
109
109
  };
110
110
  }
111
- //# sourceMappingURL=useChat.js.map
@@ -1,4 +1,4 @@
1
- import { Socket } from 'socket.io-client';
1
+ import type { Socket } from 'socket.io-client';
2
2
  import { HttpClient } from './client.js';
3
3
  export interface ChatMessageEvent {
4
4
  id: string;
@@ -88,4 +88,3 @@ export declare class RealtimeClient {
88
88
  onTyping(callback: (event: TypingEvent) => void): (() => void) | undefined;
89
89
  onAgentThinking(callback: (event: AgentThinkingEvent) => void): (() => void) | undefined;
90
90
  }
91
- //# sourceMappingURL=realtime.d.ts.map
package/dist/realtime.js CHANGED
@@ -1,4 +1,21 @@
1
- import { io } from 'socket.io-client';
1
+ // socket.io-client is an optional peer: only realtime needs it, so importing
2
+ // the SDK must not require it. The type-only import above erases at build;
3
+ // the factory loads here, on first connect, with an actionable error when
4
+ // the peer is absent.
5
+ let cachedIo;
6
+ async function loadIo() {
7
+ if (cachedIo)
8
+ return cachedIo;
9
+ try {
10
+ const mod = await import('socket.io-client');
11
+ cachedIo = mod.io;
12
+ }
13
+ catch {
14
+ throw new Error("Realtime requires the optional peer dependency 'socket.io-client'. " +
15
+ 'Install it alongside the SDK: npm install socket.io-client');
16
+ }
17
+ return cachedIo;
18
+ }
2
19
  export class RealtimeClient {
3
20
  socket = null;
4
21
  client;
@@ -8,17 +25,12 @@ export class RealtimeClient {
8
25
  this.client = client;
9
26
  }
10
27
  async fetchTokenWithClientKey() {
28
+ // Only the REST route can mint a token. The old fallback asked for a tRPC
29
+ // procedure under the REST base URL, which no API host serves, so every
30
+ // failed token fetch also logged a 404 in the browser console.
11
31
  try {
12
32
  const response = await this.client.get('/realtime/ws-token');
13
- if (response.data?.token)
14
- return response.data.token;
15
- }
16
- catch {
17
- // Fall through to the tRPC endpoint for session-based auth.
18
- }
19
- try {
20
- const response = await this.client.get('/trpc/sessionManagement.getWebSocketToken');
21
- return response.result?.data?.token;
33
+ return response.data?.token || undefined;
22
34
  }
23
35
  catch {
24
36
  return undefined;
@@ -54,6 +66,7 @@ export class RealtimeClient {
54
66
  return this.connectionPromise;
55
67
  }
56
68
  this.connectionPromise = (async () => {
69
+ const io = await loadIo();
57
70
  const provider = this.tokenProvider ?? (() => this.fetchTokenWithClientKey());
58
71
  const token = await provider();
59
72
  if (!token) {
@@ -150,4 +163,3 @@ export class RealtimeClient {
150
163
  return () => this.socket?.off('agent_thinking', callback);
151
164
  }
152
165
  }
153
- //# sourceMappingURL=realtime.js.map
@@ -41,4 +41,3 @@ export declare class AccountsResource {
41
41
  /** Mint a replacement key for a sibling account in the caller's project. */
42
42
  switchAccount(targetUserId: string): Promise<SingleResponse<SwitchAccountResult>>;
43
43
  }
44
- //# sourceMappingURL=accounts.d.ts.map
@@ -20,4 +20,3 @@ export class AccountsResource {
20
20
  return this.client.post('/accounts/switch', { target_user_id: targetUserId });
21
21
  }
22
22
  }
23
- //# sourceMappingURL=accounts.js.map
@@ -320,4 +320,3 @@ export declare class AdminResource {
320
320
  }): Promise<PaginatedResponse<WaitlistEntry>>;
321
321
  }
322
322
  export {};
323
- //# sourceMappingURL=admin.d.ts.map
@@ -124,4 +124,3 @@ export class AdminResource {
124
124
  return this.client.get('/invite-codes-admin/waitlist', params);
125
125
  }
126
126
  }
127
- //# sourceMappingURL=admin.js.map
@@ -1,5 +1,5 @@
1
1
  import type { HttpClient } from '../client.js';
2
- import type { PaginatedResponse, SingleResponse, DeleteResponse, Agent, AgentDetail, CreateAgentInput, CreatedAgent, UpdateAgentInput, UpdatedAgent, AgentChatInput, AgentChatResult, AgentConversation, PaginationParams, StreamChunk } from '../types.js';
2
+ import type { PaginatedResponse, SingleResponse, DeleteResponse, Agent, AgentDetail, CreateAgentInput, CreatedAgent, UpdateAgentInput, UpdatedAgent, AgentChatInput, AgentChatResult, AgentConversation, AgentConversationMessage, PaginationParams, StreamChunk } from '../types.js';
3
3
  export interface AgentMessage {
4
4
  id: string;
5
5
  networkId: string;
@@ -127,6 +127,16 @@ export declare class AgentsResource {
127
127
  chat(id: string, input: AgentChatInput): Promise<SingleResponse<AgentChatResult>>;
128
128
  /** List an agent's conversations */
129
129
  conversations(id: string, params?: PaginationParams): Promise<PaginatedResponse<AgentConversation>>;
130
+ /**
131
+ * Read the messages in one of an agent's conversations, oldest first.
132
+ *
133
+ * `chat` returns as soon as the message is accepted and the agent works
134
+ * asynchronously, so this is how a caller finds out what happened — including
135
+ * the exact error text when a step failed. Without it the only observable
136
+ * signals are task status and claims, which say that an agent ran and that
137
+ * nothing landed, but never why.
138
+ */
139
+ conversationMessages(id: string, conversationId: string, params?: PaginationParams): Promise<PaginatedResponse<AgentConversationMessage>>;
130
140
  /** List discoverable agents (public + same-org) */
131
141
  listDiscoverable(params?: PaginationParams & {
132
142
  organization_id?: string;
@@ -278,4 +288,3 @@ export declare class AgentsResource {
278
288
  chunks: StreamChunk[];
279
289
  }>;
280
290
  }
281
- //# sourceMappingURL=agents.d.ts.map
@@ -80,6 +80,18 @@ export class AgentsResource {
80
80
  conversations(id, params) {
81
81
  return this.client.get(`/agents/${id}/conversations`, params);
82
82
  }
83
+ /**
84
+ * Read the messages in one of an agent's conversations, oldest first.
85
+ *
86
+ * `chat` returns as soon as the message is accepted and the agent works
87
+ * asynchronously, so this is how a caller finds out what happened — including
88
+ * the exact error text when a step failed. Without it the only observable
89
+ * signals are task status and claims, which say that an agent ran and that
90
+ * nothing landed, but never why.
91
+ */
92
+ conversationMessages(id, conversationId, params) {
93
+ return this.client.get(`/agents/${id}/conversations/${conversationId}/messages`, params);
94
+ }
83
95
  /** List discoverable agents (public + same-org) */
84
96
  listDiscoverable(params) {
85
97
  return this.client.get('/agents/discoverable', params);
@@ -275,4 +287,3 @@ export class AgentsResource {
275
287
  return { content: fullText, conversationId, chunks };
276
288
  }
277
289
  }
278
- //# sourceMappingURL=agents.js.map
@@ -38,4 +38,3 @@ export declare class AppSubscriptionsResource {
38
38
  data: AppSubscriptionStatusResult;
39
39
  }>;
40
40
  }
41
- //# sourceMappingURL=app-subscriptions.d.ts.map
@@ -20,4 +20,3 @@ export class AppSubscriptionsResource {
20
20
  return this.client.get('/app-subscriptions/status');
21
21
  }
22
22
  }
23
- //# sourceMappingURL=app-subscriptions.js.map
@@ -242,6 +242,22 @@ export declare class AuthResource {
242
242
  user: AuthSession['user'];
243
243
  session: AuthSession;
244
244
  }>;
245
+ /**
246
+ * Exchange a legacy Minds session (the OAuth access token or minds_sess JWT
247
+ * the legacy mobile app stored) for a session on this stack. Only answers
248
+ * during the cutover window; every failure means "show the OTP screen".
249
+ */
250
+ legacyHandoff(legacyToken: string, appContext?: {
251
+ projectId?: string;
252
+ organizationId?: string;
253
+ }): Promise<AuthSession>;
254
+ /** legacyHandoff, then the app API key, exactly like verifyOtpAndCreateKey. */
255
+ legacyHandoffAndCreateKey(legacyToken: string, keyInput: CreateApiKeyInput): Promise<{
256
+ apiKey: string;
257
+ apiKeyId: string;
258
+ user: AuthSession['user'];
259
+ session: AuthSession;
260
+ }>;
245
261
  /**
246
262
  * Complete mobile OTP auth flow: verify OTP → create API key → return key.
247
263
  * Combines verifyOtp + createApiKey for passwordless mobile auth.
@@ -259,10 +275,18 @@ export declare class AuthResource {
259
275
  user: AuthSession['user'];
260
276
  session: AuthSession;
261
277
  }>;
278
+ /**
279
+ * The key-mint leg of the `*AndCreateKey` flows. When the mint fails, the
280
+ * caller receives only the thrown error — the session created one step
281
+ * earlier is not in it, so no caller can revoke that session no matter how
282
+ * carefully they handle the failure. Retire it here (best-effort) instead
283
+ * of stranding a live server-side credential; the mint's own error is what
284
+ * surfaces either way.
285
+ */
286
+ private createApiKeyOrRetireSession;
262
287
  /**
263
288
  * Extract session token from response.
264
289
  * Better Auth returns it in Set-Cookie header and/or response body.
265
290
  */
266
291
  private extractToken;
267
292
  }
268
- //# sourceMappingURL=auth.d.ts.map
@@ -574,7 +574,7 @@ export class AuthResource {
574
574
  projectId: keyInput.projectId,
575
575
  organizationId: keyInput.organizationId,
576
576
  });
577
- const key = await this.createApiKey(keyInput, session.token);
577
+ const key = await this.createApiKeyOrRetireSession(keyInput, session);
578
578
  return { apiKey: key.key, apiKeyId: key.id, user: session.user, session };
579
579
  }
580
580
  /**
@@ -590,7 +590,55 @@ export class AuthResource {
590
590
  projectId: keyInput.projectId,
591
591
  organizationId: keyInput.organizationId,
592
592
  });
593
- const key = await this.createApiKey(keyInput, session.token);
593
+ const key = await this.createApiKeyOrRetireSession(keyInput, session);
594
+ return { apiKey: key.key, apiKeyId: key.id, user: session.user, session };
595
+ }
596
+ /**
597
+ * Exchange a legacy Minds session (the OAuth access token or minds_sess JWT
598
+ * the legacy mobile app stored) for a session on this stack. Only answers
599
+ * during the cutover window; every failure means "show the OTP screen".
600
+ */
601
+ async legacyHandoff(legacyToken, appContext) {
602
+ const res = await this.fetchWithTimeout(`${this.baseOrigin}/api/auth/legacy-handoff`, {
603
+ method: 'POST',
604
+ headers: {
605
+ 'Content-Type': 'application/json',
606
+ ...originHeader(this.baseOrigin),
607
+ ...(appContext?.projectId ? { 'x-recursiv-app-project': appContext.projectId } : {}),
608
+ ...(appContext?.organizationId
609
+ ? { 'x-recursiv-app-organization': appContext.organizationId }
610
+ : {}),
611
+ },
612
+ body: JSON.stringify({ legacy_token: legacyToken }),
613
+ });
614
+ let data = null;
615
+ try {
616
+ data = await res.json();
617
+ }
618
+ catch {
619
+ data = null;
620
+ }
621
+ if (!res.ok) {
622
+ const { code, message } = serverErrorInfo(data);
623
+ throw new AuthenticationError({
624
+ type: 'auth_error',
625
+ message: message || `Legacy handoff failed: HTTP ${res.status}`,
626
+ code: code || 'legacy_handoff_failed',
627
+ });
628
+ }
629
+ const token = this.extractToken(res, data);
630
+ if (!token) {
631
+ throw new AuthenticationError({ type: 'auth_error', message: 'Legacy handoff returned no session', code: 'legacy_handoff_failed' });
632
+ }
633
+ return { token, user: data.user };
634
+ }
635
+ /** legacyHandoff, then the app API key, exactly like verifyOtpAndCreateKey. */
636
+ async legacyHandoffAndCreateKey(legacyToken, keyInput) {
637
+ const session = await this.legacyHandoff(legacyToken, {
638
+ projectId: keyInput.projectId,
639
+ organizationId: keyInput.organizationId,
640
+ });
641
+ const key = await this.createApiKeyOrRetireSession(keyInput, session);
594
642
  return { apiKey: key.key, apiKeyId: key.id, user: session.user, session };
595
643
  }
596
644
  /**
@@ -609,9 +657,33 @@ export class AuthResource {
609
657
  projectId: keyInput.projectId,
610
658
  organizationId: keyInput.organizationId,
611
659
  });
612
- const key = await this.createApiKey(keyInput, session.token);
660
+ const key = await this.createApiKeyOrRetireSession(keyInput, session);
613
661
  return { apiKey: key.key, apiKeyId: key.id, user: session.user, session };
614
662
  }
663
+ /**
664
+ * The key-mint leg of the `*AndCreateKey` flows. When the mint fails, the
665
+ * caller receives only the thrown error — the session created one step
666
+ * earlier is not in it, so no caller can revoke that session no matter how
667
+ * carefully they handle the failure. Retire it here (best-effort) instead
668
+ * of stranding a live server-side credential; the mint's own error is what
669
+ * surfaces either way.
670
+ */
671
+ async createApiKeyOrRetireSession(keyInput, session) {
672
+ try {
673
+ return await this.createApiKey(keyInput, session.token);
674
+ }
675
+ catch (err) {
676
+ if (session.token) {
677
+ try {
678
+ await this.signOut(session.token);
679
+ }
680
+ catch {
681
+ // Nothing more can be done from here; the session expires on its own.
682
+ }
683
+ }
684
+ throw err;
685
+ }
686
+ }
615
687
  /**
616
688
  * Extract session token from response.
617
689
  * Better Auth returns it in Set-Cookie header and/or response body.
@@ -636,4 +708,3 @@ export class AuthResource {
636
708
  return null;
637
709
  }
638
710
  }
639
- //# sourceMappingURL=auth.js.map
@@ -139,4 +139,3 @@ export declare class BillingResource {
139
139
  success: true;
140
140
  }>>;
141
141
  }
142
- //# sourceMappingURL=billing.d.ts.map
@@ -52,4 +52,3 @@ export class BillingResource {
52
52
  return this.client.post('/billing/record-ai-usage', input);
53
53
  }
54
54
  }
55
- //# sourceMappingURL=billing.js.map
@@ -23,4 +23,3 @@ export declare class BrainResource {
23
23
  sendMessage(input: SendMessageInput): Promise<SingleResponse<SendMessageResult>>;
24
24
  }
25
25
  export {};
26
- //# sourceMappingURL=brain.d.ts.map
@@ -8,4 +8,3 @@ export class BrainResource {
8
8
  return this.client.post('/brain/message', input);
9
9
  }
10
10
  }
11
- //# sourceMappingURL=brain.js.map
@@ -159,4 +159,3 @@ export declare class BriefResource {
159
159
  /** The brief for one organization. */
160
160
  forOrg(organizationId: string, params?: BriefParams): Promise<SingleResponse<Brief>>;
161
161
  }
162
- //# sourceMappingURL=brief.d.ts.map
@@ -21,4 +21,3 @@ export class BriefResource {
21
21
  return this.client.get(`/organizations/${encodeURIComponent(organizationId)}/brief`, params);
22
22
  }
23
23
  }
24
- //# sourceMappingURL=brief.js.map
@@ -64,4 +64,3 @@ export declare class ChatResource {
64
64
  unread_count: number;
65
65
  }>>;
66
66
  }
67
- //# sourceMappingURL=chat.d.ts.map
@@ -66,4 +66,3 @@ export class ChatResource {
66
66
  return this.client.get('/chat/unread-count', { conversation_id: conversationId });
67
67
  }
68
68
  }
69
- //# sourceMappingURL=chat.js.map
@@ -38,4 +38,3 @@ export declare class CommandsResource {
38
38
  execute(input: ExecutePromptInput): Promise<SingleResponse<ExecutePromptResult>>;
39
39
  }
40
40
  export {};
41
- //# sourceMappingURL=commands.d.ts.map
@@ -12,4 +12,3 @@ export class CommandsResource {
12
12
  return this.client.post('/commands/execute', input);
13
13
  }
14
14
  }
15
- //# sourceMappingURL=commands.js.map
@@ -1,10 +1,10 @@
1
1
  import type { HttpClient } from '../client.js';
2
- import type { PaginatedResponse, SingleResponse, Community, CommunityDetail, CommunityMember, CreateCommunityInput, CreatedCommunity, JoinResult, LeaveResult, PaginationParams } from '../types.js';
2
+ import type { Community, CommunityBannedMember, CommunityDetail, CommunityMember, CreateCommunityInput, CreatedCommunity, JoinResult, LeaveResult, ListCommunitiesParams, PaginatedResponse, PaginationParams, SingleResponse } from '../types.js';
3
3
  export declare class CommunitiesResource {
4
4
  private client;
5
5
  constructor(client: HttpClient);
6
- /** List public communities */
7
- list(params?: PaginationParams): Promise<PaginatedResponse<Community>>;
6
+ /** List public communities, or only the authenticated caller's memberships. */
7
+ list(params?: ListCommunitiesParams): Promise<PaginatedResponse<Community>>;
8
8
  /** Get a community by ID */
9
9
  get(id: string): Promise<SingleResponse<CommunityDetail>>;
10
10
  /** List members of a community */
@@ -15,5 +15,67 @@ export declare class CommunitiesResource {
15
15
  join(id: string): Promise<SingleResponse<JoinResult>>;
16
16
  /** Leave a community */
17
17
  leave(id: string): Promise<SingleResponse<LeaveResult>>;
18
+ /** Update name, description, image, banner or privacy. Owner or admin. */
19
+ update(id: string, input: Partial<Pick<CreateCommunityInput, 'name' | 'description' | 'privacy'>> & {
20
+ image?: string | null;
21
+ banner?: string | null;
22
+ }): Promise<SingleResponse<CommunityDetail>>;
23
+ /** Delete a community. Owner only. */
24
+ delete(id: string): Promise<SingleResponse<{
25
+ deleted: boolean;
26
+ }>>;
27
+ /** People waiting to join a private group. Moderator or higher. */
28
+ requests(id: string, params?: PaginationParams): Promise<PaginatedResponse<CommunityMember>>;
29
+ /** Active bans an admin can review and lift. Admin or higher. */
30
+ bans(id: string, params?: PaginationParams): Promise<PaginatedResponse<CommunityBannedMember>>;
31
+ /** Let a pending member in. Admin or higher. */
32
+ approveMember(id: string, userId: string): Promise<SingleResponse<{
33
+ status: string;
34
+ }>>;
35
+ /** Turn a pending member away. Admin or higher. */
36
+ declineMember(id: string, userId: string): Promise<SingleResponse<{
37
+ declined: boolean;
38
+ }>>;
39
+ /** Remove a member. Moderator or higher, and only members below your role. */
40
+ removeMember(id: string, userId: string): Promise<SingleResponse<{
41
+ removed: boolean;
42
+ }>>;
43
+ /** Ban a member, with an optional reason. Moderator or higher. */
44
+ banMember(id: string, userId: string, reason?: string): Promise<SingleResponse<{
45
+ banned: boolean;
46
+ }>>;
47
+ /** Lift a ban. Admin or higher. */
48
+ unbanMember(id: string, userId: string): Promise<SingleResponse<{
49
+ banned: boolean;
50
+ }>>;
51
+ /** Change a member's role. Admin or higher; only the owner makes admins. */
52
+ setMemberRole(id: string, userId: string, role: 'admin' | 'moderator' | 'member'): Promise<SingleResponse<{
53
+ role: string;
54
+ }>>;
55
+ /** Pin a post to the top of the group. Moderator or higher. */
56
+ pinPost(id: string, postId: string): Promise<SingleResponse<{
57
+ pinned: boolean;
58
+ }>>;
59
+ /** Unpin a post. Moderator or higher. */
60
+ unpinPost(id: string, postId: string): Promise<SingleResponse<{
61
+ pinned: boolean;
62
+ }>>;
63
+ /** Remove a post from the group. Moderator or higher. */
64
+ removePost(id: string, postId: string): Promise<SingleResponse<{
65
+ removed: boolean;
66
+ }>>;
67
+ /**
68
+ * Mint an invite code that joins the redeemer to this group. Any member of
69
+ * a public group; moderator or higher for a private one. Admins can mint a
70
+ * code that joins people as moderators.
71
+ */
72
+ createInvite(id: string, input?: {
73
+ role?: 'member' | 'moderator';
74
+ expires_days?: number;
75
+ }): Promise<SingleResponse<{
76
+ code: string;
77
+ community_id: string;
78
+ role: string;
79
+ expires_at: string | null;
80
+ }>>;
18
81
  }
19
- //# sourceMappingURL=communities.d.ts.map