@rool-dev/sdk 0.12.4 → 2.0.0-dev.03df95a

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 (108) hide show
  1. package/README.md +462 -758
  2. package/dist/agents.d.ts +138 -0
  3. package/dist/agents.d.ts.map +1 -0
  4. package/dist/agents.js +563 -0
  5. package/dist/agents.js.map +1 -0
  6. package/dist/auth-base.d.ts +43 -88
  7. package/dist/auth-base.d.ts.map +1 -1
  8. package/dist/auth-base.js +178 -298
  9. package/dist/auth-base.js.map +1 -1
  10. package/dist/auth-browser.d.ts +7 -25
  11. package/dist/auth-browser.d.ts.map +1 -1
  12. package/dist/auth-browser.js +45 -82
  13. package/dist/auth-browser.js.map +1 -1
  14. package/dist/auth-native.d.ts +9 -56
  15. package/dist/auth-native.d.ts.map +1 -1
  16. package/dist/auth-native.js +88 -177
  17. package/dist/auth-native.js.map +1 -1
  18. package/dist/auth-node.d.ts +32 -32
  19. package/dist/auth-node.d.ts.map +1 -1
  20. package/dist/auth-node.js +339 -255
  21. package/dist/auth-node.js.map +1 -1
  22. package/dist/auth-url.d.ts +6 -0
  23. package/dist/auth-url.d.ts.map +1 -0
  24. package/dist/auth-url.js +30 -0
  25. package/dist/auth-url.js.map +1 -0
  26. package/dist/client.d.ts +37 -277
  27. package/dist/client.d.ts.map +1 -1
  28. package/dist/client.js +331 -618
  29. package/dist/client.js.map +1 -1
  30. package/dist/events.d.ts +40 -0
  31. package/dist/events.d.ts.map +1 -0
  32. package/dist/events.js +175 -0
  33. package/dist/events.js.map +1 -0
  34. package/dist/files.d.ts +174 -0
  35. package/dist/files.d.ts.map +1 -0
  36. package/dist/files.js +846 -0
  37. package/dist/files.js.map +1 -0
  38. package/dist/index.d.ts +16 -17
  39. package/dist/index.d.ts.map +1 -1
  40. package/dist/index.js +7 -19
  41. package/dist/index.js.map +1 -1
  42. package/dist/machine.d.ts +51 -0
  43. package/dist/machine.d.ts.map +1 -0
  44. package/dist/machine.js +142 -0
  45. package/dist/machine.js.map +1 -0
  46. package/dist/problem.d.ts +11 -0
  47. package/dist/problem.d.ts.map +1 -0
  48. package/dist/problem.js +20 -0
  49. package/dist/problem.js.map +1 -0
  50. package/dist/structured.d.ts +84 -0
  51. package/dist/structured.d.ts.map +1 -0
  52. package/dist/structured.js +405 -0
  53. package/dist/structured.js.map +1 -0
  54. package/dist/types.d.ts +131 -520
  55. package/dist/types.d.ts.map +1 -1
  56. package/package.json +11 -16
  57. package/dist/auth.d.ts +0 -85
  58. package/dist/auth.d.ts.map +0 -1
  59. package/dist/auth.js +0 -181
  60. package/dist/auth.js.map +0 -1
  61. package/dist/client-info.d.ts +0 -18
  62. package/dist/client-info.d.ts.map +0 -1
  63. package/dist/client-info.js +0 -25
  64. package/dist/client-info.js.map +0 -1
  65. package/dist/event-emitter.d.ts +0 -45
  66. package/dist/event-emitter.d.ts.map +0 -1
  67. package/dist/event-emitter.js +0 -86
  68. package/dist/event-emitter.js.map +0 -1
  69. package/dist/graphql.d.ts +0 -90
  70. package/dist/graphql.d.ts.map +0 -1
  71. package/dist/graphql.js +0 -463
  72. package/dist/graphql.js.map +0 -1
  73. package/dist/logger.d.ts +0 -13
  74. package/dist/logger.d.ts.map +0 -1
  75. package/dist/logger.js +0 -17
  76. package/dist/logger.js.map +0 -1
  77. package/dist/path.d.ts +0 -6
  78. package/dist/path.d.ts.map +0 -1
  79. package/dist/path.js +0 -47
  80. package/dist/path.js.map +0 -1
  81. package/dist/reroute.d.ts +0 -22
  82. package/dist/reroute.d.ts.map +0 -1
  83. package/dist/reroute.js +0 -70
  84. package/dist/reroute.js.map +0 -1
  85. package/dist/rest.d.ts +0 -54
  86. package/dist/rest.d.ts.map +0 -1
  87. package/dist/rest.js +0 -171
  88. package/dist/rest.js.map +0 -1
  89. package/dist/router.d.ts +0 -20
  90. package/dist/router.d.ts.map +0 -1
  91. package/dist/router.js +0 -54
  92. package/dist/router.js.map +0 -1
  93. package/dist/space-session.d.ts +0 -30
  94. package/dist/space-session.d.ts.map +0 -1
  95. package/dist/space-session.js +0 -83
  96. package/dist/space-session.js.map +0 -1
  97. package/dist/space.d.ts +0 -161
  98. package/dist/space.d.ts.map +0 -1
  99. package/dist/space.js +0 -618
  100. package/dist/space.js.map +0 -1
  101. package/dist/subscription.d.ts +0 -36
  102. package/dist/subscription.d.ts.map +0 -1
  103. package/dist/subscription.js +0 -419
  104. package/dist/subscription.js.map +0 -1
  105. package/dist/webdav.d.ts +0 -171
  106. package/dist/webdav.d.ts.map +0 -1
  107. package/dist/webdav.js +0 -481
  108. package/dist/webdav.js.map +0 -1
package/README.md CHANGED
@@ -1,15 +1,6 @@
1
1
  # Rool SDK
2
2
 
3
- TypeScript SDK for programmatic access to [Rool Machines](https://rool.dev) — private AI computers holding objects, files, conversations, and memory, with AI-assisted editing built in.
4
-
5
- > **Naming note:** the SDK predates the Rool Machine branding and calls a Machine a **space** (`createSpace`, `RoolSpace`, `/space/...` paths). The API keeps this legacy naming until v2; read "space" as "Machine" throughout.
6
-
7
- Core primitives:
8
-
9
- - **Spaces** — Machines: containers for objects, schema, metadata, conversations, collaborators, and files.
10
- - **Conversations** — independent interaction histories in a space.
11
- - **Objects** — JSON records addressed by object paths such as `/space/article/welcome.json`.
12
- - **Files** — user-visible files stored under `/rool-drive/...` through WebDAV.
3
+ TypeScript SDK for Rool Machines.
13
4
 
14
5
  ## Installation
15
6
 
@@ -17,964 +8,677 @@ Core primitives:
17
8
  npm install @rool-dev/sdk
18
9
  ```
19
10
 
20
- ## Quick Start
11
+ ## User and session API
21
12
 
22
13
  ```typescript
23
- import { RoolClient } from '@rool-dev/sdk';
14
+ import { RoolClient } from "@rool-dev/sdk";
15
+
16
+ const client = new RoolClient({
17
+ getTokens: () => ({
18
+ accessToken: currentAccessToken,
19
+ roolToken: currentRoolToken,
20
+ }),
21
+ });
24
22
 
25
- async function main() {
26
- const client = new RoolClient();
23
+ const session = await client.getSession();
24
+ const account = await client.getAccount();
25
+ const profile = await client.getProfile();
26
+ const userAppData = await client.getUserAppData();
27
+ const greeting = await client.getGreeting("en");
27
28
 
28
- if (!(await client.initialize())) {
29
- await client.login('My App');
30
- // Browser auth redirects away. Run startup again after the auth callback.
31
- return;
29
+ await client.replaceProfile({
30
+ name: "Ada",
31
+ marketingOptIn: true,
32
+ });
33
+ await client.setUserAppData("theme", "dark");
34
+ await client.deleteUserAppData("theme");
35
+ await client.deleteAccount();
36
+ ```
37
+
38
+ `UserAppData` is an opaque cross-device JSON object. App data is changed one key at a time so unrelated settings cannot overwrite each other.
39
+
40
+ ## Account events
41
+
42
+ ```typescript
43
+ const unsubscribe = client.events.subscribe(async (event) => {
44
+ if (event.type === "session") {
45
+ renderSession(event.session);
46
+ } else if (event.type === "account_changed") {
47
+ renderAccount(await client.getAccount());
48
+ } else if (event.type === "profile_changed") {
49
+ renderProfile(await client.getProfile());
50
+ } else if (event.type === "user_app_data_changed") {
51
+ renderUserAppData(await client.getUserAppData());
52
+ } else if (event.type === "machines_changed") {
53
+ renderMachines(await client.listMachines());
54
+ } else if (event.type === "machine_members_changed") {
55
+ renderMembers(
56
+ event.machineId,
57
+ await client.machine(event.machineId).members.list(),
58
+ );
32
59
  }
60
+ });
33
61
 
34
- const space = await client.createSpace('Solar System');
35
- const conversation = space.conversation('main');
62
+ unsubscribe();
63
+ ```
36
64
 
37
- await space.createCollection('body', [
38
- { name: 'name', type: { kind: 'string' } },
39
- { name: 'mass', type: { kind: 'string' } },
40
- { name: 'radius', type: { kind: 'string' } },
41
- { name: 'orbits', type: { kind: 'maybe', inner: { kind: 'ref' } } },
42
- ]);
65
+ Account events tell the client when something changed. Fetch the relevant route to get the latest data. The SDK starts with `/v2/session`, then long-polls for changes using its account sync token. Empty polls and network retries do not produce events or refresh the session. If a token expires, the SDK fetches a new session and sends another `session` event.
43
66
 
44
- const { object: sun } = await space.putObject('/space/body/sun.json', {
45
- name: 'Sun',
46
- mass: '1 solar mass',
47
- radius: '696,340 km',
48
- });
67
+ `getTokens` may return tokens synchronously or asynchronously. The SDK sends the access token as `Authorization: Bearer …` and the Rool token as `X-Rool-Token`. Bearer-only integrations can use `getAccessToken` instead. Use `apiUrl` to target a non-production server and `fetch` to provide a custom transport.
49
68
 
50
- const { object: earth } = await space.putObject('/space/body/earth.json', {
51
- name: 'Earth',
52
- mass: '1 Earth mass',
53
- radius: '6,371 km',
54
- orbits: sun.path,
55
- });
69
+ ## Authentication
56
70
 
57
- const { message, objects } = await conversation.prompt(
58
- 'Add the other planets in our solar system, each referencing the Sun.'
59
- );
71
+ Auth clients own login, credential storage, and refresh. `RoolClient` only asks one for tokens and tells it when authentication is invalidated.
60
72
 
61
- console.log(message);
62
- console.log(`Modified ${objects.length} objects`);
73
+ ### Browser authentication
63
74
 
64
- const loadedEarth = await space.getObject(earth.path);
65
- console.log(loadedEarth?.body.name);
75
+ ```typescript
76
+ import { BrowserAuth, RoolClient } from "@rool-dev/sdk";
66
77
 
67
- space.close();
68
- }
78
+ const auth = new BrowserAuth();
79
+ const client = new RoolClient({
80
+ getTokens: auth.getTokens,
81
+ onAuthInvalidated: auth.logout,
82
+ });
69
83
 
70
- void main();
84
+ auth.onAuthStateChanged(renderSignedInState);
85
+ if (!(await auth.initialize())) {
86
+ await auth.login("My App");
87
+ }
71
88
  ```
72
89
 
73
- ## Paths and Resource URIs
90
+ `initialize()` processes an auth callback in the URL. Tokens are stored in endpoint-scoped browser storage and refreshed when requested.
74
91
 
75
- Most SDK methods take plain path strings:
92
+ ### Native authentication
76
93
 
77
- - Object paths: `/space/<collection>/<name>.json` (exactly three segments; no dotfile collection or object names)
78
- - File paths: `/rool-drive/<path/to/file>`
79
-
80
- `rool-machine:/...` URIs are the user-facing/canonical form for resource references in prompt attachments and interaction history. The exported helpers normalize between these forms when you need them.
94
+ `NativeAuth` uses system-browser PKCE for Google and Apple while also supporting password and magic-link sign-in.
81
95
 
82
96
  ```typescript
83
- import { machinePath, machineUri, isObjectPath } from '@rool-dev/sdk';
84
-
85
- machinePath('rool-machine:/rool-drive/docs/read%20me.md');
86
- // '/rool-drive/docs/read me.md'
97
+ import { App } from "@capacitor/app";
98
+ import { Browser } from "@capacitor/browser";
99
+ import { NativeAuth, RoolClient } from "@rool-dev/sdk";
100
+
101
+ const auth = new NativeAuth({
102
+ redirectUri: "roolandroidauth://auth/callback",
103
+ defaultProvider: "google",
104
+ openExternal: (url) => Browser.open({ url }),
105
+ });
106
+ const client = new RoolClient({
107
+ getTokens: auth.getTokens,
108
+ onAuthInvalidated: auth.logout,
109
+ });
87
110
 
88
- machineUri('/space/article/welcome.json');
89
- // 'rool-machine:/space/article/welcome.json'
111
+ App.addListener("appUrlOpen", async ({ url }) => {
112
+ await Browser.close();
113
+ await auth.handleRedirect(url);
114
+ });
90
115
 
91
- isObjectPath('/space/article/welcome.json'); // true
116
+ if (!(await auth.initialize())) await auth.login("My App");
92
117
  ```
93
118
 
94
- Object APIs require full object paths. References between objects are ordinary body fields containing object paths:
119
+ The redirect URI must exactly match the app setup and auth server allowlist. Pass `{ provider: "apple" }` to `login()` or `signup()` to override the default provider.
95
120
 
96
121
  ```typescript
97
- {
98
- path: '/space/body/earth.json',
99
- body: { name: 'Earth', orbits: '/space/body/sun.json' },
100
- }
122
+ const result = await auth.signInWithPassword(email, password);
123
+ if (result.status === "verify_required") showCheckYourEmailMessage();
124
+
125
+ await auth.requestMagicLink(email);
126
+ await auth.verify(verifyToken);
101
127
  ```
102
128
 
103
- ## Authentication
129
+ On native, an HTTPS magic link only returns to the app when Universal Links or App Links are configured for that domain.
104
130
 
105
- ### Browser
131
+ ### Password and account methods
106
132
 
107
- The default auth provider stores tokens in browser storage and redirects to the Rool auth page.
133
+ Browser and native auth clients also provide:
108
134
 
109
- ```typescript
110
- async function start() {
111
- const client = new RoolClient();
135
+ - `setPassword(password)`
136
+ - `requestEmailChange(newEmail)`
137
+ - `verify(token)`
138
+ - `logout()`
139
+ - `isAuthenticated()`
112
140
 
113
- if (!(await client.initialize())) {
114
- await client.login('My App');
115
- // Browser auth redirects; stop startup until the callback reloads the app.
116
- return;
117
- }
141
+ ### Node.js authentication
118
142
 
119
- // Use the authenticated client here.
120
- }
143
+ ```typescript
144
+ import { RoolClient } from "@rool-dev/sdk";
145
+ import { NodeAuth } from "@rool-dev/sdk/node";
121
146
 
122
- void start();
147
+ const auth = new NodeAuth();
148
+ if (!(await auth.initialize())) await auth.login("My CLI");
149
+
150
+ const client = new RoolClient({
151
+ getTokens: auth.getTokens,
152
+ onAuthInvalidated: auth.logout,
153
+ });
123
154
  ```
124
155
 
125
- ### Node.js
156
+ `NodeAuth` opens the system browser for login and stores endpoint-scoped credentials under `~/.config/rool/`. It refreshes the access and Rool tokens when requested. Pass `apiUrl` to select another deployed environment; the corresponding auth URL is derived from it. When the API uses a loopback URL, pass `authUrl` explicitly.
126
157
 
127
- Use the Node auth provider for CLIs and scripts. It stores endpoint-scoped credentials under `~/.config/rool/` by default (for example, `credentials-<hash>.json`) and opens a browser for login.
158
+ Use `profile` or `credentialsPath` when an application needs multiple independent accounts:
128
159
 
129
160
  ```typescript
130
- import { RoolClient } from '@rool-dev/sdk';
131
- import { NodeAuthProvider } from '@rool-dev/sdk/node';
132
-
133
- const client = new RoolClient({ authProvider: new NodeAuthProvider() });
134
- let authenticated = await client.initialize();
135
-
136
- if (!authenticated) {
137
- await client.login('My CLI Tool');
138
- // Re-run initialize after the non-redirect login to hydrate currentUser,
139
- // user storage, and client-level event subscriptions.
140
- authenticated = await client.initialize();
141
- }
142
-
143
- if (!authenticated) throw new Error('Login required');
161
+ const auth = new NodeAuth({
162
+ apiUrl: "https://api.example.com",
163
+ profile: "automation",
164
+ });
144
165
  ```
145
166
 
146
- ### Native (Capacitor, Cordova, Tauri, ...)
167
+ API errors are thrown as `RoolProblem` with the server's stable `code`, HTTP `status`, `title`, and `detail`.
147
168
 
148
- Use the native PKCE provider for JS app shells that sign in through an external
149
- system browser. `login()`/`signup()` open the auth server's `/authorize` page
150
- via the `openExternal` callback you supply; when the deep link returns, feed it
151
- to `client.handleAuthRedirect(url)` from your platform's deep-link handler. The
152
- code is exchanged for a session at `/token` and tokens are stored like the
153
- browser provider.
169
+ ## Machine API
154
170
 
155
171
  ```typescript
156
- import { RoolClient, NativePkceAuthProvider } from '@rool-dev/sdk';
157
- import { Browser } from '@capacitor/browser';
158
- import { App } from '@capacitor/app';
172
+ const created = await client.createMachine({ name: "Research" });
173
+ const machine = client.machine(created.id);
174
+
175
+ const details = await machine.get();
176
+ await machine.settings.replace({ name: "Field research" });
177
+ const copy = await machine.duplicate({ name: "Research copy" });
178
+ const response = await machine.fetchUrl("https://example.com/data.json");
179
+ await client.machine(copy.id).delete();
180
+ ```
159
181
 
160
- const client = new RoolClient({
161
- authProvider: new NativePkceAuthProvider({
162
- redirectUri: 'roolandroidauth://auth/callback', // must match the server allowlist
163
- defaultProvider: 'google', // 'google' | 'apple'
164
- openExternal: (url) => Browser.open({ url }),
165
- }),
166
- });
182
+ `client.machine(id)` returns a stable machine handle that owns machine-scoped APIs and synchronization state. Creation, listing, sessions, duplication, and `machine.get()` all return the same point-in-time `MachineSummary`; bind its ID to a handle before performing machine operations. Summaries include the machine's inbound email address, lifecycle `state`, and an opaque `meta` JSON object. `fetchUrl()` returns the upstream `Response`, including non-success statuses.
167
183
 
168
- // Complete sign-in when the OS hands the app its deep link.
169
- App.addListener('appUrlOpen', async ({ url }) => {
170
- if (await client.handleAuthRedirect(url)) {
171
- await Browser.close();
172
- // Now authenticated — refresh your UI.
173
- }
174
- });
184
+ ## Machine checkpoints
175
185
 
176
- if (!(await client.initialize())) {
177
- // Opens the system browser; completion arrives via the listener above.
178
- await client.login('My App'); // pass { provider: 'apple' } to override the default
186
+ ```typescript
187
+ const history = await machine.checkpoints.list();
188
+ const checkpoint = history.checkpoints.at(-1);
189
+ if (checkpoint) {
190
+ await machine.checkpoints.restore(checkpoint.id);
179
191
  }
180
192
  ```
181
193
 
182
- #### Email + password and magic links (native)
194
+ The checkpoint collection contains the currently restorable timeline and the `baseCheckpointId` underlying the live filesystem. The live filesystem can contain newer uncheckpointed changes. Restoring a checkpoint preserves those changes as a new checkpoint and causes a watched machine file tree to reconcile completely. Moving backward does not discard later checkpoints, but modifying the filesystem from that earlier position replaces the later timeline.
183
195
 
184
- The native provider also supports email/password sign-in and magic links —
185
- no system browser, the server returns the token set as JSON directly.
196
+ ## Machine files
186
197
 
187
198
  ```typescript
188
- // Password sign-in
189
- const result = await client.signInWithPassword(email, password);
190
- if (result.status === 'signed_in') {
191
- // authenticated refresh your UI
192
- } else {
193
- // status === 'verify_required': the email isn't verified yet and the server
194
- // has emailed a magic link. Tell the user to check their inbox.
199
+ const files = machine.files;
200
+ const path = "/rool-drive/documents/report.pdf";
201
+
202
+ const storage = await files.getStorageUsage();
203
+ console.log(storage.usedBytes, storage.availableBytes);
204
+ await files.createDirectory("/rool-drive/documents");
205
+ const written = await files.write(path, reportBlob, {
206
+ contentType: "application/pdf",
207
+ ifNoneMatch: "*",
208
+ onUploadProgress: ({ transferredBytes, totalBytes }) => {
209
+ if (totalBytes) renderUploadProgress(transferredBytes / totalBytes);
210
+ },
211
+ });
212
+ await files.write(
213
+ "/rool-drive/documents/archive.bin",
214
+ () => createArchiveStream(),
215
+ { contentType: "application/octet-stream" },
216
+ );
217
+ const info = await files.stat(path);
218
+ const documents = await files.list("/rool-drive/documents");
219
+ const response = await files.read(path, {
220
+ range: { start: 0, end: 1023 },
221
+ ifMatch: info.etag,
222
+ });
223
+ const hydrated = await files.readMultiple([
224
+ "/space/.meta.json",
225
+ "/rool-drive/documents/notes.json",
226
+ ]);
227
+ await files.copy(path, "/rool-drive/documents/report-backup.pdf", {
228
+ overwrite: false,
229
+ ifMatch: written.etag,
230
+ });
231
+ await files.move(path, "/rool-drive/documents/final-report.pdf");
232
+ const deleted = await files.deleteMultiple([
233
+ "/rool-drive/documents/final-report.pdf",
234
+ { path: "/rool-drive/documents/notes.json", ifMatch: '"notes-etag"' },
235
+ ]);
236
+ for (const result of deleted) {
237
+ if (!result.ok)
238
+ console.error(`Failed to delete ${result.path}`, result.error);
195
239
  }
196
-
197
- // Or request a magic link explicitly
198
- await client.requestMagicLink(email);
199
240
  ```
200
241
 
201
- The magic link carries a `?verify=<token>` param; complete sign-in by passing
202
- that token to `client.verify(token)` once the link lands back in the app.
203
-
204
- > **⚠️ Magic links open the website, not the app, until Universal Links / App
205
- > Links are configured.** The emailed link is an `https://` URL for the Rool
206
- > web app. On native, an `https` link only re-opens your app if you've set up
207
- > [iOS Universal Links](https://developer.apple.com/ios/universal-links/) /
208
- > [Android App Links](https://developer.android.com/training/app-links) for that
209
- > domain (custom-scheme deep links don't apply to email links). **Without that
210
- > setup the magic link completes sign-in in the browser/website, not in the
211
- > native app** — so for now treat magic links on native as a website hand-off,
212
- > and prefer password or social sign-in for an in-app experience.
213
-
214
- ### Auth API
242
+ Paths are absolute machine paths under `/space` or `/rool-drive`. `list()` without a path enumerates those storage roots; pass `{ recursive: true }` to enumerate a complete subtree. File and directory metadata has a discriminating `kind` field. Reads return the native `Response` so callers can stream the body. `readMultiple()` hydrates ordered small files in one request and returns an `ok` result with binary-safe bytes and validators, or a per-file HTTP failure. A batch accepts at most 128 paths, 2 MiB per successful file, and 16 MiB across successful files. Writes accept any `BodyInit`, including `Blob` and `ReadableStream`, and return the same complete file metadata as `stat()` and `list()`. Pass a function that creates a fresh `ReadableStream` when an upload must be replayable after a machine route change; a directly passed stream remains one-shot. `onUploadProgress` reports transferred bytes and includes the total size when it is known; successful completion is confirmed by the `write()` promise. Copy and move operations overwrite by default; pass `{ overwrite: false }` for create-only behavior.
215
243
 
216
- | Method | Description |
217
- | --- | --- |
218
- | `initialize(): Promise<boolean>` | Call on startup. Initializes auth, refreshes user/storage state, and starts client events when authenticated. |
219
- | `login(appName, params?): Promise<void>` | Start login flow. |
220
- | `signup(appName, params?): Promise<void>` | Start signup flow. |
221
- | `verify(token): Promise<boolean>` | Complete email verification token flow; returns `false` when the active auth provider does not implement verification. |
222
- | `handleAuthRedirect(url): Promise<boolean>` | Complete a native PKCE sign-in from a deep-link callback URL. Returns `false` when the active auth provider does not implement it. |
223
- | `signInWithPassword(email, password): Promise<PasswordSignInResult>` | Email + password sign-in (native provider). Resolves `{ status: 'signed_in' }`, or `{ status: 'verify_required' }` when the email is unverified (a magic link was emailed). Rejects on bad credentials. |
224
- | `requestMagicLink(email): Promise<void>` | Email the user a magic sign-in link (native provider). See the caveat below — on native the link opens the **website**, not the app, until Universal Links / App Links are configured. |
225
- | `logout(): void` | Clear auth state and close open spaces. |
226
- | `isAuthenticated(): Promise<boolean>` | Whether credentials are held locally. No network call — a server outage does not read as logged out. |
227
- | `getAuthUser(): AuthUser` | Return auth identity decoded from the token. |
228
- | `setPassword(password): Promise<void>` | Set/change password and sign out the user's other sessions. |
244
+ `deleteMultiple()` sends independent DAV requests with at most eight in flight. It accepts plain paths and targets carrying their own HTTP preconditions, and returns one ordered success or failure result per target. The requests are not atomic. A directory target recursively deletes its contents, so callers should omit redundant descendants; duplicate and overlapping targets otherwise remain independent and can race.
229
245
 
230
- ### Offline behavior
246
+ Every file and directory has protected `access` metadata. `currentUser` says whether the requesting user can read or write it. `readableBy` and `writableBy` describe its filesystem audiences as `resource-owner`, `machine-admins`, `machine-editors`, and `machine-members`. For a file, write means changing its contents. For a directory, write means adding, removing, or renaming entries. Members without read access to a directory do not receive that directory through listing, direct lookup, or synchronization.
231
247
 
232
- A temporarily unreachable server never reads as "logged out". `initialize()` reports authentication from stored credentials, so on an offline start it can return `true` while `currentUser` is still `null` and user storage is empty the SDK keeps reconnecting in the background and hydrates both automatically once the server is reachable, emitting `currentUserChanged`. Only an invalid or expired refresh token ends the session, via `authStateChanged(false)`.
248
+ `getStorageUsage()` reports the used and writable bytes on the machine's complete live persistent filesystem, including public files and private runtime or system state. It excludes checkpoint history and the ephemeral operating-system overlay.
233
249
 
234
- ## Spaces and Conversations
235
-
236
- Open a space to receive live events and manage objects, schema, metadata, collaborators, file storage, and conversations. Use a conversation handle for conversation metadata and AI.
250
+ Watch the files when an application needs a live machine file tree:
237
251
 
238
252
  ```typescript
239
- const space = await client.openSpace('space-id');
253
+ await files.watch();
240
254
 
241
- const conversation = space.conversation('main');
242
- space.on('filesChanged', () => console.log('files changed'));
255
+ const unsubscribe = files.tree.subscribe(({ reset, changed, deleted }) => {
256
+ renderFileChanges({ reset, changed, deleted });
257
+ });
243
258
 
244
- await conversation.prompt('Summarize this space');
259
+ const cached = files.tree.get("/rool-drive/documents/final-report.pdf");
260
+ const etag = files.tree.etag("/rool-drive/documents/final-report.pdf");
261
+ const allDocuments = files.tree.list("/rool-drive/documents", {
262
+ recursive: true,
263
+ });
264
+
265
+ unsubscribe();
266
+ files.unwatch();
245
267
  ```
246
268
 
247
- Conversation IDs must be 1–32 characters and contain only letters, numbers, `_`, and `-`.
269
+ `files.watch()` performs a complete `sync-collection`, then keeps the machine's file metadata and ETag cache current with long-poll incremental reports. DAV writes and guest-program changes enter the same tree. An invalid or expired sync token causes an atomic complete reconciliation and a change event with `reset: true`. Transient sync errors are retried and available as `files.watchError`; `files.unwatch()` aborts the active long poll.
248
270
 
249
- ## Object Operations
271
+ ## Rool Object Collections
250
272
 
251
- Objects are JSON files under `/space`. Create the collection before writing objects in it.
273
+ Objects are JSON stored under `/space`. Collections are directories with a `.schema.json` definition and objects are schema-checked JSON files.
252
274
 
253
275
  ```typescript
254
- await space.createCollection('article', [
255
- { name: 'title', type: { kind: 'string' } },
256
- { name: 'status', type: { kind: 'string' } },
257
- ]);
276
+ await machine.files.watch();
258
277
 
259
- // Create or replace an exact object path
260
- const { object } = await space.putObject('/space/article/welcome.json', {
261
- title: 'Welcome',
262
- status: 'draft',
278
+ const task = await machine.collections.create("task", {
279
+ fields: [
280
+ { name: "title", type: { kind: "string" } },
281
+ { name: "done", type: { kind: "boolean" } },
282
+ ],
263
283
  });
264
284
 
265
- // Patch fields; null or undefined deletes a field
266
- await space.patchObject(object.path, {
267
- data: { status: 'published', obsoleteField: null },
285
+ const first = await machine.objects.create("/space/task/first.json", {
286
+ title: "First task",
287
+ done: false,
268
288
  });
289
+ const objectPaths = machine.objects.list({ collection: "task" });
290
+ const object = await machine.objects.get(first.path);
291
+ const [sameObject, missing] = await machine.objects.getMultiple([
292
+ first.path,
293
+ "/space/task/missing.json",
294
+ ]);
269
295
 
270
- // Read one or many objects
271
- await space.getObject('/space/article/welcome.json');
272
- await space.getObjects([
273
- '/space/article/welcome.json',
274
- '/space/article/intro.json',
296
+ await machine.objects.patch(first.path, { done: true });
297
+ await machine.objects.move(first.path, "/space/task/renamed.json");
298
+ const [removal] = await machine.objects.removeMultiple([
299
+ "/space/task/renamed.json",
275
300
  ]);
301
+ if (!removal) throw new Error("Object removal returned no result");
302
+ if (!removal.ok) throw removal.error;
303
+ await machine.collections.remove(task.name);
304
+ ```
276
305
 
277
- // Rename or move an object
278
- await space.moveObject(
279
- '/space/article/welcome.json',
280
- '/space/article/hello-world.json'
281
- );
306
+ `machine.objects.list()` returns object paths from the synchronized file tree without reading their bodies. `get()` reads one object and `getMultiple()` preserves the input positions and returns `undefined` for missing objects. Every call reads the current bodies from DAV, with multiple reads using bounded `read-multiple` batches. Collection schemas are read in the same way and schema replacement follows the guest's lazy-migration rule: existing objects are checked again only when edited.
282
307
 
283
- // Delete objects
284
- await space.deleteObjects(['/space/article/hello-world.json']);
285
- ```
308
+ Creates are create-only. Metadata, schema, and object replacements plus object patches, moves, and removals use ETags and report status `412` when state changed concurrently. `removeMultiple()` uses a separate conditional DAV request for each object and returns ordered per-object results. Removing a collection recursively deletes its contents. Object moves do not overwrite by default; pass `{ overwrite: true }` explicitly. Patch values of `null` or `undefined` remove fields.
286
309
 
287
- | Method | Description |
288
- | --- | --- |
289
- | `getObject(path): Promise<RoolObject | undefined>` | Fetch one object by object path. |
290
- | `getObjects(paths): Promise<GetObjectsResult>` | Fetch objects in bulk; returns `objects` and `missing`. |
291
- | `space.putObject(path, body): Promise<{ object, message }>` | Create or replace an object at an exact path. |
292
- | `space.patchObject(path, { data }): Promise<{ object, message }>` | Patch an object's body; `null`/`undefined` deletes fields. |
293
- | `space.moveObject(from, to, options?): Promise<{ object, message }>` | Rename or relocate an object; `options.body` can replace the body after moving. |
294
- | `space.deleteObjects(paths): Promise<void>` | Delete object files. |
310
+ The semantic APIs use the machine's shared file tree and sync loop. They do not create separate synchronization state. Body reads and mutations also work without `machine.files.watch()` by reading current DAV state directly; `objects.list()` reflects the shared file tree, so watch the machine's files before enumerating paths.
295
311
 
296
- ## AI Agent
312
+ ## Agents
297
313
 
298
- `prompt()` invokes the AI agent. The agent can inspect space context and, unless `readOnly` or a read-only effort is used, create/modify/move/delete objects.
314
+ Agents and conversations use stable JSON routes; their private machine files are not part of the SDK. Prompting does not require `machine.files.watch()`.
299
315
 
300
316
  ```typescript
301
- const { message, objects } = await conversation.prompt(
302
- 'Create a topic node for the solar system, then child nodes for each planet.'
303
- );
317
+ const defaultAgent = await machine.agents.get("rool");
318
+ if (!defaultAgent) throw new Error("Rool agent is unavailable");
319
+
320
+ const conversation = defaultAgent.conversation("research-chat");
321
+ const stopWatching = conversation.watch((view) => {
322
+ renderConversation({
323
+ turns: view.turns,
324
+ output: view.output,
325
+ isRunning: view.isRunning,
326
+ loading: view.loading,
327
+ error: view.error,
328
+ });
329
+ });
330
+
331
+ await conversation.prompt("Explain the result.", { effort: "reasoning" });
304
332
 
305
- console.log(message);
306
- console.log(objects.map((object) => object.path));
333
+ // When this conversation leaves the UI:
334
+ stopWatching();
307
335
  ```
308
336
 
309
- ### Prompt Options
337
+ `prompt()` starts the conversation's current run and resolves once the server accepts it. The agent runs as a detached job. A conversation can only have one current run; call `cancel()` and wait for `follow()` to finish before prompting again. The `readOnly` option is accepted for compatibility with legacy prompting but currently has no effect.
310
338
 
311
- | Option | Description |
312
- | --- | --- |
313
- | `responseSchema` | Request structured JSON text matching a JSON-schema-like shape. |
314
- | `effort` | `'QUICK'` (fast/read-only), `'STANDARD'` (default), `'REASONING'`, or `'RESEARCH'`. |
315
- | `ephemeral` | Do not record the prompt in interaction history. |
316
- | `readOnly` | Disable mutation tools. |
317
- | `parentInteractionId` | Conversation-tree parent. Omit to fetch and continue from the current default leaf; pass `null` for a new root branch. |
318
- | `attachments` | Existing object/file paths or `rool-machine:/...` URIs, plus local files (`File`, `Blob`, or `{ data, contentType, filename? }`). |
319
- | `signal` | AbortSignal used to request that the server stop an in-flight prompt. |
320
- | `eventName` | Optional telemetry event name. Defaults to `'prompt_user'`. |
339
+ `watch()` is the normal UI API. It fetches only turns after the last turn it has seen, follows the current run, and refreshes the durable turns when that stream ends. `turns` contains saved history through the current user message while a run is active; `output` contains that run's replayed and live output. The first listener starts the work and removing the last listener stops it. Saved turns remain cached on the conversation handle for the next listener.
321
340
 
322
- ```typescript
323
- // Read-only quick question
324
- await conversation.prompt('What topics are covered?', {
325
- effort: 'QUICK', // fast/read-only
326
- });
341
+ `follow()` is the lower-level streaming API. It performs one `GET` of the conversation's current run. It receives the complete current-run output and then continues with new events until that response ends. Tool calls and their results arrive as `output.delta` events with matching IDs. A tool result contains nested content parts and an optional `error` flag. `follow()` returns `false` when there is no current run. Aborting `follow()` only stops that request; call `cancel()` to stop the detached job.
327
342
 
328
- // Focus on existing objects and files
329
- await conversation.prompt('Compare these resources', {
330
- attachments: [
331
- '/space/article/intro.json',
332
- 'rool-machine:/rool-drive/docs/report.pdf',
333
- ],
334
- });
343
+ The SDK uses `conversation_changed` account events to wake active watchers. A watcher also refreshes after prompting, cancellation, stream completion, connection failure, and account event-token replacement.
335
344
 
336
- // Upload a local file as an attachment
337
- await conversation.prompt('Describe this image', {
338
- attachments: [fileInput.files![0]],
339
- });
345
+ Prompt attachments are existing `/space` or `/rool-drive` paths. Pass a durable user turn's `id` as `replaceTurnId` to replace that message and everything after it. This supports edits and rerolls, including the first message. A replacement gets a new user turn ID; use that ID to edit it again.
346
+
347
+ Pass a JSON Schema as `responseSchema` to request structured output. Tools are skipped for that run. The successful assistant turn contains one JSON content part; the value is JSON directly, not a JSON string.
340
348
 
341
- // Structured response
342
- const { message } = await conversation.prompt('Categorize these items', {
349
+ ```typescript
350
+ await conversation.prompt("Return the number of records.", {
343
351
  responseSchema: {
344
- type: 'object',
345
- properties: {
346
- categories: { type: 'array', items: { type: 'string' } },
347
- summary: { type: 'string' },
348
- },
352
+ type: "object",
353
+ properties: { count: { type: "integer" } },
354
+ required: ["count"],
355
+ additionalProperties: false,
349
356
  },
350
357
  });
351
- const result = JSON.parse(message);
358
+ await conversation.follow();
352
359
 
353
- // Stop a long prompt with a signal (when the caller holds the controller)
354
- const ac = new AbortController();
355
- const promptPromise = conversation.prompt('Do a deep analysis', {
356
- effort: 'RESEARCH',
357
- signal: ac.signal,
360
+ const turns = await conversation.listTurns();
361
+ const part = turns.at(-1)?.content[0];
362
+ if (part?.type !== "json") throw new Error("No structured result");
363
+ console.log(part.value); // { count: ... }
364
+ ```
365
+
366
+ Custom agent definitions currently contain one plain system prompt. The server owns the executable agent implementation.
367
+
368
+ ```typescript
369
+ const researcher = await machine.agents.create("researcher", {
370
+ system: "Investigate carefully and distinguish facts from uncertainty.",
371
+ });
372
+ const customConversation = await researcher.createConversation({
373
+ name: "Climate report",
374
+ visibility: "private",
358
375
  });
359
- ac.abort(); // asks the server to stop the in-flight interaction
360
- await promptPromise;
376
+ await customConversation.prompt("Investigate this claim.");
361
377
  ```
362
378
 
363
- ### Stopping a conversation
379
+ Agents expose `replace()` and `delete()`. Conversations expose metadata replacement, listing, durable turn reads, rename, and deletion. Listed and fetched conversation metadata includes server-managed ISO 8601 `createdAt` and `updatedAt` timestamps plus `isRunning`, which can drive a running indicator without opening every run stream. Visibility defaults to private. The built-in `rool` agent cannot be replaced or deleted.
364
380
 
365
- Use `signal` when the same call site cancels the prompt. When the Stop button
366
- lives elsewhere — a different component, after a reload, or a prompt another
367
- client started — stop the conversation itself. A conversation processes one
368
- run at a time, so no interaction ID is needed. Stopping is best-effort: the
369
- server halts the agent loop and closes the stream, but an LLM turn already in
370
- flight keeps generating server-side and is billed.
381
+ ## Members and invites
371
382
 
372
383
  ```typescript
373
- // Stop whatever is running in a conversation. Returns whether anything was
374
- // actually running.
375
- await space.stopConversation('thread-42');
384
+ const invite = await machine.invites.create({
385
+ role: "editor",
386
+ maxUses: 1,
387
+ });
388
+ const token = invite.url.split("/").at(-1)!;
376
389
 
377
- // Conversation handles stop their own running work.
378
- const thread = space.conversation('thread-42');
379
- await thread.stop();
390
+ await client.getInvitePreview(token);
391
+ await client.redeemInvite(token);
392
+
393
+ const members = await machine.members.list();
394
+ console.log(members[1].name ?? members[1].email);
395
+ await machine.members.replaceRole(members[1].userId, { role: "viewer" });
396
+ await machine.members.remove(members[1].userId);
397
+ await machine.invites.revoke(invite.id);
380
398
  ```
381
399
 
382
- | Method | Description |
383
- | --- | --- |
384
- | `stopConversation(conversationId): Promise<boolean>` | Stop whatever is running in a conversation. |
385
- | `conversation.stop(): Promise<boolean>` | Stop this conversation's running work. |
400
+ Invite URLs contain a secret token and are returned only when an invite is created. Invites can optionally be bound to an email address. Role replacement never creates membership or transfers ownership.
386
401
 
387
- ## Conversations
402
+ ## Gifts
388
403
 
389
- Use `space.conversation(id)` for an imperative API scoped to one conversation. The handle retains no conversation contents or branch cursor; fetch contents when needed. With no explicit parent, `prompt()` fetches the current conversation and continues from its default leaf.
404
+ A gift carries something of value in a short code. Users receive gifts from Rool and give the codes away themselves. Claiming a gift is single-use, and claiming your own gift is allowed.
390
405
 
391
406
  ```typescript
392
- import { conversationBranch, defaultConversationLeaf } from '@rool-dev/sdk';
407
+ const { gifts } = await client.listGifts();
408
+ for (const gift of gifts) {
409
+ console.log(gift.code, gift.url, gift.description, gift.claimedAt);
410
+ }
393
411
 
394
- const thread = space.conversation('thread-42');
395
- await thread.prompt('Hello from another thread');
396
- await thread.setSystemInstruction('Answer in haiku');
412
+ const preview = await client.previewGift(code); // no auth required
413
+ console.log(
414
+ `${preview.holderName ?? "Someone"} gave you ${preview.description}`,
415
+ );
397
416
 
398
- const conversation = await thread.get();
399
- const leaf = defaultConversationLeaf(conversation);
400
- const branch = conversationBranch(conversation, leaf);
417
+ const { gift } = await client.claimGift(code);
418
+ if (gift.kind === "credits") console.log(`+${gift.credits} credits`);
401
419
  ```
402
420
 
403
- | Method/property | Description |
404
- | --- | --- |
405
- | `space.conversation(id): ConversationHandle` | Get a stateless conversation-scoped API handle. |
406
- | `conversation.get(): Promise<Conversation | null>` | Fetch current conversation contents. |
407
- | `conversation.prompt(text, options?)` | Prompt the conversation. Pass `parentInteractionId` to choose a branch explicitly. |
408
- | `conversation.setSystemInstruction(value)` | Set or clear the system instruction. |
409
- | `conversation.rename(name)` / `conversation.delete()` / `conversation.stop()` | Manage the scoped conversation. |
410
- | `listConversations(): Promise<ConversationMeta[]>` | Fetch the conversation roster. |
411
- | `createConversation(agent, visibility): Promise<string>` | Create a conversation under an agent; returns the server-minted conversation ID. |
412
- | `deleteConversation(id): Promise<void>` | Delete a conversation by ID. |
421
+ Codes are case-insensitive and the dash is optional. Prefer the server-rendered `description` for display. Narrow `gift.kind` when using the structured payload because new gift kinds may be added.
413
422
 
414
- ### Agents
423
+ A holder can add a note, archive a gift, or replace an unclaimed gift's code. These actions do not change what the gift grants. Archiving only hides it from the holder's normal view.
415
424
 
416
- Conversations belong to an agent. Every space has the stock agent `rool`; spaces can also host custom agents. `createConversation` creates a conversation under any agent — including `rool` — with a server-minted ID and the visibility you choose; prompt the returned ID through a normal handle. Stock (`rool`) conversations can also spring into existence from a client-minted ID on first prompt (as in the examples above); custom-agent conversations are only created explicitly.
425
+ ```typescript
426
+ await client.updateGift(giftId, { note: "sent to Peter" });
427
+ await client.updateGift(giftId, { archived: true });
428
+ await client.updateGift(giftId, { note: null });
429
+ const updated = await client.rotateGiftCode(giftId);
430
+ ```
417
431
 
418
- Each conversation has a visibility: `'shared'` (every space member), `'private'` (only you), or `'temporary'` (private, and auto-deleted after sitting idle). A conversation's agent and visibility are reported on its `ConversationMeta`.
432
+ Gift failures are `RoolProblem` errors. `gift_invalid` means the code or gift is unavailable to the caller. `gift_claimed` means it was already claimed.
419
433
 
420
- ```typescript
421
- const agents = await space.listAgents(); // always includes 'rool'
434
+ ## Speechmatics
422
435
 
423
- const id = await space.createConversation('research-bot', 'private');
424
- await space.conversation(id).prompt('Hello');
436
+ Voice input transcribes the user's speech with Speechmatics' real-time API. Rool mints a short-lived key without exposing its long-lived provider key; hand the temporary key to the Speechmatics real-time SDK and stream the user's mic audio to it.
425
437
 
426
- await space.deleteAgent('research-bot'); // removes the agent and all its conversations
438
+ ```typescript
439
+ const { token, expiresAt, ttl } = await client.getSpeechmaticsToken({
440
+ ttl: 300,
441
+ });
442
+ // speechmaticsRealtimeClient.start(token, { transcription_config: { language: "en" } })
427
443
  ```
428
444
 
429
- | Method | Description |
430
- | --- | --- |
431
- | `listAgents(): Promise<string[]>` | The space's agents. Always includes the stock agent `rool`. |
432
- | `createConversation(agent, visibility): Promise<string>` | Create a conversation under an agent with the given visibility. |
433
- | `deleteAgent(agent): Promise<void>` | Delete a custom agent and all its conversations. The stock agent `rool` cannot be deleted. |
445
+ The key expires after `ttl` seconds (60–3600, default 300). `expiresAt` is the epoch-milliseconds moment the key stops being accepted. A token request fails with `insufficient_credits` when the account's balance is too low and with `speechmatics_unavailable` when Speechmatics cannot issue a key.
434
446
 
435
- ## Schema and Metadata
447
+ ## API problems
436
448
 
437
- Collections define the schema visible to the AI agent. Hidden body fields whose names start with `_` are useful for app/UI state that should not be considered by AI.
449
+ Each problem `type` links to its entry below.
438
450
 
439
- ```typescript
440
- await space.createCollection('article', {
441
- schemaOrgType: 'Article',
442
- fields: [
443
- { name: 'title', type: { kind: 'string' } },
444
- { name: 'status', type: { kind: 'enum', values: ['draft', 'published'] } },
445
- { name: 'tags', type: { kind: 'array', inner: { kind: 'string' } } },
446
- { name: 'author', type: { kind: 'ref' } },
447
- ],
448
- });
451
+ <a id="problem-authentication_required"></a>
449
452
 
450
- const schema = await space.readSchema();
453
+ ### `authentication_required`
451
454
 
452
- await space.alterCollection('article', [
453
- { name: 'title', type: { kind: 'string' } },
454
- { name: 'status', type: { kind: 'string' } },
455
- ]);
455
+ **Documentation placeholder.**
456
456
 
457
- await space.writeMeta({ viewport: { x: 0, y: 0, zoom: 1 } });
458
- const meta = await space.readMeta();
459
- ```
457
+ <a id="problem-invalid_authentication"></a>
460
458
 
461
- | Method | Description |
462
- | --- | --- |
463
- | `readSchema(): Promise<SpaceSchema>` | Collection definitions, read from `/space/<name>/.schema.json`. |
464
- | `createCollection(name, fieldsOrDef, options?): Promise<CollectionDef>` | Create a collection. |
465
- | `alterCollection(name, fieldsOrDef, options?): Promise<CollectionDef>` | Replace a collection definition. |
466
- | `dropCollection(name): Promise<void>` | Remove a collection and its object directory. |
467
- | `readMeta(): Promise<Record<string, unknown>>` | Read metadata from `/space/.meta.json`. |
468
- | `writeMeta(meta): Promise<void>` | Write the full metadata blob to `/space/.meta.json`. |
459
+ ### `invalid_authentication`
469
460
 
470
- Field kinds: `string`, `number`, `boolean`, `ref`, `enum`, `literal`, `array`, and `maybe`.
461
+ **Documentation placeholder.**
471
462
 
472
- ## Undo/Redo
463
+ <a id="problem-email_unverified"></a>
473
464
 
474
- Undo/redo works over the whole space. Checkpoints are managed automatically by the server, so you don't need to create them yourself — just call `undo()`/`redo()`.
465
+ ### `email_unverified`
475
466
 
476
- ```typescript
477
- await space.deleteObjects(['/space/article/welcome.json']);
467
+ **Documentation placeholder.**
478
468
 
479
- if (await space.canUndo()) {
480
- await space.undo();
481
- }
482
- ```
469
+ <a id="problem-account_suspended"></a>
483
470
 
484
- | Method | Description |
485
- | --- | --- |
486
- | `canUndo(): Promise<boolean>` | Check whether undo is available. |
487
- | `canRedo(): Promise<boolean>` | Check whether redo is available. |
488
- | `undo(): Promise<boolean>` | Restore the latest checkpoint. |
489
- | `redo(): Promise<boolean>` | Reapply undone work. |
471
+ ### `account_suspended`
490
472
 
491
- Undo/redo availability is scoped to the space.
473
+ **Documentation placeholder.**
492
474
 
493
- ## File Storage and WebDAV
475
+ <a id="problem-invalid_profile"></a>
494
476
 
495
- Every space has authenticated WebDAV storage. WebDAV methods take SDK machine paths such as `/space/...`, `/rool-drive/...`, or `/` for the root collection.
477
+ ### `invalid_profile`
496
478
 
497
- ```typescript
498
- const webdav = space.webdav;
479
+ **Documentation placeholder.**
499
480
 
500
- await webdav.mkcol('/rool-drive/docs');
501
- await webdav.put('/rool-drive/docs/readme.md', '# Hello', {
502
- contentType: 'text/markdown',
503
- ifNoneMatch: '*',
504
- });
481
+ <a id="problem-invalid_user_app_data"></a>
505
482
 
506
- const listing = await webdav.propfind('/rool-drive/docs', {
507
- depth: '1',
508
- props: ['displayname', 'getcontentlength', 'getcontenttype', 'getetag'],
509
- });
483
+ ### `invalid_user_app_data`
510
484
 
511
- const response = await webdav.get('/rool-drive/docs/readme.md');
512
- console.log(await response.text());
485
+ **Documentation placeholder.**
513
486
 
514
- const file = await space.fetchPath('/rool-drive/docs/readme.md');
515
- console.log(file.headers.get('Content-Type'));
487
+ <a id="problem-invalid_json"></a>
516
488
 
517
- ```
489
+ ### `invalid_json`
518
490
 
519
- ### Real-time file sync
491
+ **Documentation placeholder.**
520
492
 
521
- Object and file changes are announced at the space level. Use WebDAV `syncCollection()` to reconcile changes.
493
+ <a id="problem-payload_too_large"></a>
522
494
 
523
- ```typescript
524
- let token: string | null = null;
495
+ ### `payload_too_large`
525
496
 
526
- async function syncFiles() {
527
- const result = await space.webdav.syncCollection('/', {
528
- token,
529
- level: 'infinite',
530
- props: ['displayname', 'getetag', 'getlastmodified', 'resourcetype'],
531
- });
532
- token = result.token;
533
- updateFileTree(result.responses);
534
- }
497
+ **Documentation placeholder.**
535
498
 
536
- space.on('filesChanged', syncFiles);
537
- space.on('filesReset', () => {
538
- token = null;
539
- void syncFiles();
540
- });
499
+ <a id="problem-user_app_data_too_large"></a>
541
500
 
542
- await syncFiles();
543
- ```
501
+ ### `user_app_data_too_large`
544
502
 
545
- | Method | Description |
546
- | --- | --- |
547
- | `webdav.href(path)` / `webdav.url(path)` | Return WebDAV href/URL for an absolute SDK path. |
548
- | `webdav.options(path)` | Send `OPTIONS`. |
549
- | `webdav.propfind(path, options)` | Read properties/list collections. `depth` is required. |
550
- | `webdav.syncCollection(path, options)` | WebDAV `REPORT sync-collection`; returns changed responses and next token. |
551
- | `webdav.get(path, options?)` / `webdav.head(path)` | Read a file; `get` supports byte ranges. |
552
- | `webdav.put(path, body, options?)` | Write a file/object at an exact path. Parent collection must exist unless `createParents: true` is passed, which creates missing parent collections atomically (intended for `/rool-drive` paths). |
553
- | `webdav.mkcol(path)` | Create one collection. |
554
- | `webdav.copy(source, destination, options?)` | Copy a file or collection. |
555
- | `webdav.move(source, destination, options?)` | Move a file or collection. |
556
- | `webdav.delete(path, options?)` | Delete a file or collection. |
557
- | `webdav.lock(path, options)` / `refreshLock(path, token)` / `unlock(token)` | WebDAV write locks. |
558
- | `webdav.request(method, path, init?)` | Raw authenticated WebDAV request. |
559
- | `space.fetchPath(path, options?)` | Fetch a `/rool-drive/...` file path or `rool-machine:` file URI. |
503
+ **Documentation placeholder.**
560
504
 
561
- High-level WebDAV methods that validate response status throw `WebDAVError` with `status`, `statusText`, and `body`; raw `request()` and `options()` return `Response`.
505
+ <a id="problem-not_found"></a>
562
506
 
563
- ## Collaboration
507
+ ### `not_found`
564
508
 
565
- New members join a space by redeeming an invite. Owners and admins mint invites; the returned `url` contains the secret token and is only available at mint time.
509
+ **Documentation placeholder.**
566
510
 
567
- ```typescript
568
- // Shareable invite link
569
- const invite = await space.createInvite('editor', { expiresInDays: 7 });
570
- console.log(invite.url);
571
-
572
- // Email-guarded invite: single-use, locked to that address, sent by mail
573
- const emailed = await space.createInvite('viewer', { email: 'colleague@example.com' });
574
- if (emailed.emailStatus !== 'sent') {
575
- // Mail did not go out (e.g. no mail provider configured) — share emailed.url yourself
576
- }
511
+ <a id="problem-checkpoint_not_found"></a>
577
512
 
578
- // Manage outstanding invites
579
- const invites = await space.listInvites();
580
- await space.revokeInvite(invites[0].inviteId);
513
+ ### `checkpoint_not_found`
581
514
 
582
- // Change an existing member's role, or remove them
583
- await space.setUserRole(userId, 'admin');
584
- await space.removeUser(userId);
585
- ```
515
+ **Documentation placeholder.**
586
516
 
587
- On the join page, look up the invite before sign-in and redeem it once authenticated:
517
+ <a id="problem-sync_token_required"></a>
588
518
 
589
- ```typescript
590
- const preview = await client.previewInvite(token); // no auth required
591
- console.log(preview.spaceName, preview.role, preview.inviterName);
519
+ ### `sync_token_required`
592
520
 
593
- const result = await client.redeemInvite(token);
594
- console.log(result.spaceId, result.status); // 'joined' | 'upgraded' | 'already_member'
595
- ```
521
+ The account event route requires the sync token returned by `/v2/session`.
596
522
 
597
- Invalid, expired, revoked, exhausted, or email-mismatched invites throw `InviteError` with a `code` of `'INVITE_INVALID' | 'INVITE_EXPIRED' | 'INVITE_REVOKED' | 'INVITE_EXHAUSTED' | 'INVITE_EMAIL_MISMATCH'`.
523
+ <a id="problem-invalid_sync_token"></a>
598
524
 
599
- ```typescript
600
- import { InviteError } from '@rool-dev/sdk';
525
+ ### `invalid_sync_token`
601
526
 
602
- try {
603
- await client.redeemInvite(token);
604
- } catch (error) {
605
- if (error instanceof InviteError && error.code === 'INVITE_EXPIRED') {
606
- // Ask for a fresh invite
607
- }
608
- }
609
- ```
527
+ The account event history no longer contains everything after this token. Fetch `/v2/session` and continue with its new token.
610
528
 
611
- Roles (invites grant `admin`, `editor`, or `viewer` — never `owner`):
529
+ <a id="problem-invalid_wait_preference"></a>
612
530
 
613
- | Role | Capabilities |
614
- | --- | --- |
615
- | `owner` | Full control. |
616
- | `admin` | Editor capabilities plus user/link management. |
617
- | `editor` | Create, modify, move, and delete objects/files. |
618
- | `viewer` | Read-only access. |
531
+ ### `invalid_wait_preference`
619
532
 
620
- ## Gifts
533
+ The account event wait must be an integer from 0 through 50 seconds.
621
534
 
622
- A gift is something of value carried by a short code, e.g. `K7M2-9QRT`. Users are issued gifts server-side and give them away in their own words; whoever claims one gets what it holds. Claiming your own gift is a legitimate use. A gift is unclaimed or claimed, and claiming is single-use.
535
+ <a id="problem-internal_error"></a>
623
536
 
624
- What a gift grants is in its `gift` field, discriminated by `kind`. Every gift also carries a server-rendered `description` such as `"10,000 AI credits"`, so UI can display any gift without knowing its kind. Prefer `description` unless you need the numbers.
537
+ ### `internal_error`
625
538
 
626
- Narrow on `kind` before reading any other payload field. Kinds are added over time, and un-narrowed access becomes a compile error when the next one lands.
539
+ **Documentation placeholder.**
627
540
 
628
- Users hold no gifts by default, so `listGifts()` returning an empty list is the normal state for most accounts, not an error.
541
+ <a id="problem-server_misconfigured"></a>
629
542
 
630
- ```typescript
631
- // The current user's gifts, spent and unspent
632
- const { gifts } = await client.listGifts();
633
- for (const gift of gifts) {
634
- console.log(gift.code, gift.url, gift.description, gift.claimedAt);
635
- }
636
- ```
543
+ ### `server_misconfigured`
637
544
 
638
- On the claim page, look up the gift before sign-up and claim it once authenticated:
545
+ **Documentation placeholder.**
639
546
 
640
- ```typescript
641
- const preview = await client.previewGift(code); // no auth required
642
- console.log(`${preview.holderName} gave you ${preview.description}`);
547
+ <a id="problem-current_run_exists"></a>
643
548
 
644
- const { gift } = await client.claimGift(code);
645
- if (gift.kind === 'credits') console.log(`+${gift.credits} credits`);
646
- ```
549
+ ### `current_run_exists`
647
550
 
648
- Codes are case-insensitive, and the dash is optional on input.
551
+ The conversation is already running. Cancel or follow that run before prompting again. This also applies to prompts with `replaceTurnId`.
649
552
 
650
- When a gift is claimed, `claimedByName` carries the claimer's display name — the reciprocal of the claim page showing the holder's name to the claimer. The claim page tells the claimer this will happen.
553
+ <a id="problem-replace_turn_not_found"></a>
651
554
 
652
- A holder can annotate a gift with a note ("sent this to Peter") and archive it to hide it from their default view. Both are bookkeeping only: an archived gift's code still claims.
555
+ ### `replace_turn_not_found`
653
556
 
654
- A holder can also rotate a gift's code: a fresh code is minted and the old one stops working. Use it to take back a code that was given away but never claimed — the gift itself is untouched.
557
+ The user turn supplied as `replaceTurnId` is no longer in the conversation. Fetch the turns again before retrying the edit.
655
558
 
656
- ```typescript
657
- await client.updateGift(gift.id, { note: 'sent to Peter' });
658
- await client.updateGift(gift.id, { archived: true });
659
- await client.updateGift(gift.id, { note: null }); // clear the note
559
+ <a id="problem-invalid_member_role"></a>
660
560
 
661
- const updated = await client.rotateGiftCode(gift.id);
662
- console.log(updated.code, updated.url); // the old code and link are dead
663
- ```
561
+ ### `invalid_member_role`
664
562
 
665
- Failed gift operations throw `GiftError` with a `code`:
563
+ **Documentation placeholder.**
666
564
 
667
- | Code | Meaning |
668
- | --- | --- |
669
- | `gift_invalid` | No gift matches that code. |
670
- | `gift_claimed` | The gift has already been claimed. |
565
+ <a id="problem-role_not_replaceable"></a>
671
566
 
672
- ```typescript
673
- import { GiftError } from '@rool-dev/sdk';
567
+ ### `role_not_replaceable`
674
568
 
675
- try {
676
- await client.claimGift(code);
677
- } catch (error) {
678
- if (error instanceof GiftError && error.code === 'gift_claimed') {
679
- // Offer a plain signup instead
680
- }
681
- }
682
- ```
569
+ **Documentation placeholder.**
683
570
 
684
- ## RoolClient API
571
+ <a id="problem-membership_not_removable"></a>
685
572
 
686
- ### Constructor config
573
+ ### `membership_not_removable`
687
574
 
688
- ```typescript
689
- const client = new RoolClient({
690
- apiUrl: 'https://api.rool.dev',
691
- authUrl: 'https://rool.dev/auth',
692
- graphqlUrl: 'https://api.rool.dev/graphql',
693
- client: {
694
- appName: 'com.example.app',
695
- appVersion: '1.4.2',
696
- osVersion: 'iOS 17.5',
697
- },
698
- logger: console,
699
- });
700
- ```
575
+ **Documentation placeholder.**
701
576
 
702
- `apiUrl` defaults to `https://api.rool.dev`; `authUrl` is derived by stripping the `api.` hostname prefix unless provided. `baseUrl` is still accepted as a deprecated alias for `apiUrl`. Pass `authProvider` for Node.js, Electron, or custom auth flows.
703
-
704
- `client` is optional application identity sent on requests alongside the SDK package name/version. Compatibility is based only on the SDK version.
705
-
706
- | Method/property | Description |
707
- | --- | --- |
708
- | `currentUser: CurrentUser | null` | Cached user profile from initialization/fetch. |
709
- | `getCurrentUser(): Promise<CurrentUser>` | Fetch current user. |
710
- | `updateCurrentUser(input): Promise<CurrentUser>` | Update `name`, `slug`, or `marketingOptIn`. |
711
- | `deleteCurrentUser(): Promise<void>` | Mark account for deletion and log out. |
712
- | `previewInvite(token): Promise<InvitePreview>` | Look up an invite link without redeeming it. No auth required. |
713
- | `redeemInvite(token): Promise<InviteRedeemResult>` | Redeem an invite, joining (or upgrading in) its space. |
714
- | `previewGift(code): Promise<GiftPreview>` | Look up a gift without claiming it. No auth required. |
715
- | `claimGift(code): Promise<GiftClaimResult>` | Claim a gift, granting what it holds to the current account. |
716
- | `listGifts(): Promise<GiftList>` | The current user's gifts, spent and unspent. |
717
- | `updateGift(giftId, changes): Promise<Gift>` | Set or clear a gift's note, or change its archived state. |
718
- | `rotateGiftCode(giftId): Promise<Gift>` | Mint a new code for a gift; the old code and link stop working. |
719
- | `listSpaces(): Promise<RoolSpaceInfo[]>` | List accessible spaces. |
720
- | `openSpace(id): Promise<RoolSpace>` | Open/cached live space handle. |
721
- | `createSpace(name): Promise<RoolSpace>` | Create and open a space. |
722
- | `duplicateSpace(sourceId, name): Promise<RoolSpace>` | Duplicate a space. |
723
- | `deleteSpace(id): Promise<void>` | Permanently delete a space. |
724
- | `importArchive(name, archive): Promise<RoolSpace>` | Import a zip archive as a new space. |
725
- | `getUserStorage<T>(key): T | undefined` | Sync read from user-storage cache. |
726
- | `setUserStorage(key, value): void` | Update user storage; `null`/`undefined` deletes. |
727
- | `getAllUserStorage(): Record<string, unknown>` | Copy all cached user storage. |
728
- | `reportEvent(event, url?): void` | Fire-and-forget telemetry event. |
729
- | `destroy(): void` | Close subscriptions, spaces, auth resources, and listeners. |
730
- | `generateId(): string` | Generate a unique ID suitable for conversation IDs. |
731
-
732
- ### Client events
577
+ <a id="problem-invalid_invite"></a>
733
578
 
734
- ```typescript
735
- client.on('authStateChanged', (authenticated) => void 0);
736
- client.on('currentUserChanged', (user) => void 0); // CurrentUser | null; null on sign-out
737
- client.on('spaceAdded', (space) => void 0);
738
- client.on('spaceRemoved', (spaceId) => void 0);
739
- client.on('spaceRenamed', (spaceId, newName) => void 0);
740
- client.on('userStorageChanged', ({ key, value, source }) => void 0);
741
- client.on('connectionStateChanged', (state) => void 0);
742
- client.on('error', (error, context) => void 0);
743
- client.on('serverInfoChanged', (info) => void 0);
744
- client.on('unsupported', (info) => void 0); // SDK older than server minimum
745
- ```
579
+ ### `invalid_invite`
746
580
 
747
- ## RoolSpace API
748
-
749
- Properties: `id`, `name`, `role`, `memberCount`, `openSpaceResult`, `route`, `webdav`.
750
-
751
- | Method | Description |
752
- | --- | --- |
753
- | `conversation(conversationId): ConversationHandle` | Get a stateless conversation-scoped handle. |
754
- | `getObject`, `getObjects` | Read object data. |
755
- | `listConversations`, `createConversation`, `deleteConversation` | Fetch, create, and delete conversations. |
756
- | `listAgents`, `deleteAgent` | List the space's agents and delete a custom agent. |
757
- | `readMeta`, `writeMeta`, `readSchema` | Read and write WebDAV-backed metadata and schema. |
758
- | `canUndo`, `canRedo`, `undo`, `redo` | Space history controls. |
759
- | `stopConversation(conversationId): Promise<boolean>` | Stop whatever is running in a conversation. |
760
- | `fetch(url, init?): Promise<Response>` | Proxy an external HTTP request through the server to bypass browser CORS. |
761
- | `close(): void` | Stop the space subscription. |
762
- | `rename(newName): Promise<void>` | Rename the space. |
763
- | `delete(): Promise<void>` | Permanently delete the space. |
764
- | `listUsers(): Promise<SpaceMember[]>` | List collaborators. |
765
- | `setUserRole(userId, role): Promise<void>` | Change an existing member's role. |
766
- | `removeUser(userId): Promise<void>` | Remove collaborator. |
767
- | `createInvite(role, options?): Promise<SpaceInviteCreated>` | Mint an invite link; `options` takes `email`, `expiresInDays`, `maxUses`. |
768
- | `listInvites(): Promise<SpaceInvite[]>` | List currently redeemable invites. |
769
- | `revokeInvite(inviteId): Promise<boolean>` | Revoke an invite so its link stops working. |
770
- | `exportArchive(): Promise<Blob>` | Export a space archive. |
771
- | `refresh(): Promise<OpenSpaceResult>` | Refresh identity, access, member count, and conversation metadata. |
772
- | `fetchPath(path, options?): Promise<Response>` | Fetch a `/rool-drive/...` file. |
773
-
774
- Events:
581
+ **Documentation placeholder.**
775
582
 
776
- ```typescript
777
- space.on('conversationUpdated', ({ conversationId, conversation, source, timestamp }) => void 0);
778
- space.on('syncError', (error) => void 0);
779
- space.on('filesChanged', ({ spaceId, source, timestamp }) => void 0);
780
- space.on('filesReset', ({ spaceId, source, timestamp }) => void 0);
781
- space.on('connectionStateChanged', (state) => void 0);
782
- ```
783
- ## Import/Export
583
+ <a id="problem-invite_invalid"></a>
784
584
 
785
- ```typescript
786
- const archive = await space.exportArchive();
787
- const imported = await client.importArchive('Imported Data', archive);
788
- ```
585
+ ### `invite_invalid`
789
586
 
790
- Archives include objects, metadata, conversations, and file storage.
587
+ **Documentation placeholder.**
791
588
 
792
- ## Data Types
589
+ <a id="problem-invite_expired"></a>
793
590
 
794
- ```typescript
795
- // Outcome of signInWithPassword. 'verify_required' means the account's email
796
- // isn't verified yet and the server has emailed a magic link.
797
- type PasswordSignInResult = { status: 'signed_in' | 'verify_required' };
798
-
799
- type FieldType =
800
- | { kind: 'string' }
801
- | { kind: 'number' }
802
- | { kind: 'boolean' }
803
- | { kind: 'array'; inner?: FieldType }
804
- | { kind: 'maybe'; inner: FieldType }
805
- | { kind: 'enum'; values: string[] }
806
- | { kind: 'literal'; value: string | number | boolean }
807
- | { kind: 'ref' };
808
-
809
- interface FieldDef {
810
- name: string;
811
- type: FieldType;
812
- }
591
+ ### `invite_expired`
813
592
 
814
- interface CollectionDef {
815
- fields: FieldDef[];
816
- schemaOrgType?: string;
817
- }
593
+ **Documentation placeholder.**
818
594
 
819
- type SpaceSchema = Record<string, CollectionDef>;
595
+ <a id="problem-invite_revoked"></a>
820
596
 
821
- interface RoolObject {
822
- path: string;
823
- body: Record<string, unknown>;
824
- }
597
+ ### `invite_revoked`
825
598
 
826
- interface GetObjectsResult {
827
- objects: RoolObject[];
828
- missing: string[];
829
- }
599
+ **Documentation placeholder.**
830
600
 
831
- // Who may see a conversation: 'shared' is every space member; 'private' is
832
- // owner-only; 'temporary' is private plus auto-delete once it sits idle.
833
- type ConversationVisibility = 'shared' | 'private' | 'temporary';
834
-
835
- // Lightweight conversation roster entry (no interaction bodies), returned by
836
- // openSpace/listConversations. `updatedAt` drives last-activity display.
837
- interface ConversationMeta {
838
- id: string;
839
- agent: string; // owning agent ('rool' is the stock agent)
840
- visibility: ConversationVisibility;
841
- name: string | null;
842
- systemInstruction: string | null;
843
- createdAt: number;
844
- createdBy: string;
845
- interactionCount: number;
846
- updatedAt: number;
847
- }
601
+ <a id="problem-invite_exhausted"></a>
848
602
 
849
- type InviteRole = 'admin' | 'editor' | 'viewer';
850
-
851
- interface SpaceInvite {
852
- inviteId: string;
853
- spaceId: string;
854
- role: InviteRole;
855
- email: string | null;
856
- createdBy: string;
857
- createdAt: string;
858
- expiresAt: string;
859
- maxUses: number | null;
860
- useCount: number;
861
- }
603
+ ### `invite_exhausted`
862
604
 
863
- // Outcome of the invite email send. Null when no email was involved (open link).
864
- // The invite is always minted and its `url` is usable regardless of this value;
865
- // only the email delivery is reflected here.
866
- // - 'sent': email dispatched
867
- // - 'not_configured': server has no mail provider (local dev)
868
- // - 'failed': provider rejected the send
869
- // - 'cooldown': a recent invite to this same address was already emailed
870
- // - 'rate_limited': the inviter hit their daily email-invite cap
871
- // Treat unknown values as not sent.
872
- type InviteEmailStatus =
873
- | 'sent'
874
- | 'not_configured'
875
- | 'failed'
876
- | 'cooldown'
877
- | 'rate_limited'
878
- | (string & {});
879
-
880
- interface SpaceInviteCreated {
881
- inviteId: string;
882
- spaceId: string;
883
- role: InviteRole;
884
- email: string | null;
885
- expiresAt: string;
886
- maxUses: number | null;
887
- url: string; // contains the secret token; only available at mint time
888
- emailStatus: InviteEmailStatus | null;
889
- }
605
+ **Documentation placeholder.**
890
606
 
891
- interface InvitePreview {
892
- spaceId: string;
893
- spaceName: string;
894
- role: InviteRole;
895
- email: string | null;
896
- inviterName: string | null;
897
- }
607
+ <a id="problem-invite_email_mismatch"></a>
898
608
 
899
- interface InviteRedeemResult {
900
- spaceId: string;
901
- role: RoolUserRole;
902
- status: 'joined' | 'upgraded' | 'already_member';
903
- }
609
+ ### `invite_email_mismatch`
904
610
 
905
- type GiftPayload = { kind: 'credits'; credits: number };
906
-
907
- interface Gift {
908
- id: string;
909
- code: string; // display form, e.g. "K7M2-9QRT"
910
- url: string; // claim URL carrying the code
911
- gift: GiftPayload;
912
- description: string; // e.g. "10,000 AI credits"
913
- claimedAt: string | null; // null while unspent
914
- claimedByName: string | null; // claimer's display name, when they have one
915
- createdAt: string;
916
- note: string | null; // the holder's own reminder
917
- archivedAt: string | null; // set when hidden; the code still claims
918
- }
611
+ **Documentation placeholder.**
919
612
 
920
- interface GiftUpdate {
921
- note?: string | null; // undefined leaves as-is, null clears
922
- archived?: boolean;
923
- }
613
+ <a id="problem-gift_invalid"></a>
924
614
 
925
- interface GiftList {
926
- gifts: Gift[];
927
- }
615
+ ### `gift_invalid`
928
616
 
929
- interface GiftPreview {
930
- holderName: string | null;
931
- gift: GiftPayload;
932
- description: string;
933
- }
617
+ The code is not valid, or the requested gift does not belong to the current user.
934
618
 
935
- interface GiftClaimResult {
936
- gift: GiftPayload;
937
- description: string;
938
- }
619
+ <a id="problem-gift_claimed"></a>
939
620
 
940
- type PromptAttachment =
941
- | File
942
- | Blob
943
- | { data: string; contentType: string; filename?: string }
944
- | string;
945
-
946
- type PromptEffort = 'QUICK' | 'STANDARD' | 'REASONING' | 'RESEARCH';
947
-
948
- interface PromptOptions {
949
- responseSchema?: Record<string, unknown>;
950
- effort?: PromptEffort;
951
- parentInteractionId?: string | null;
952
- ephemeral?: boolean;
953
- readOnly?: boolean;
954
- attachments?: PromptAttachment[];
955
- signal?: AbortSignal;
956
- eventName?: string;
957
- }
621
+ ### `gift_claimed`
958
622
 
959
- type InteractionStatus = 'pending' | 'streaming' | 'done' | 'error';
960
-
961
- interface Interaction {
962
- id: string;
963
- parentId: string | null;
964
- timestamp: number;
965
- userId: string;
966
- userName?: string | null;
967
- operation: 'prompt' | 'putObject' | 'patchObject' | 'moveObject' | 'deleteObjects' | 'deletePaths' | string;
968
- input: string;
969
- output: string | null;
970
- status: InteractionStatus;
971
- ai: boolean;
972
- modifiedObjectPaths: string[];
973
- toolCalls: ToolCall[];
974
- attachments?: string[];
975
- }
623
+ The gift has already been claimed. A claimed gift cannot be claimed again or given a new code.
624
+
625
+ <a id="problem-invalid_input"></a>
626
+
627
+ ### `invalid_input`
628
+
629
+ The gift update is empty or contains an invalid note or archived value.
630
+
631
+ <a id="problem-insufficient_credits"></a>
632
+
633
+ ### `insufficient_credits`
634
+
635
+ The account's credit balance is too low to mint a speech transcription key. Top up the balance and try again.
636
+
637
+ <a id="problem-speechmatics_unavailable"></a>
638
+
639
+ ### `speechmatics_unavailable`
640
+
641
+ Speechmatics could not issue a transcription key right now. Try again shortly.
642
+
643
+ ## Development
644
+
645
+ ```bash
646
+ pnpm build
647
+ pnpm typecheck
648
+ ```
649
+
650
+ The user-route smoke test must target a dedicated non-production account. It replaces profile and app data, then schedules and cancels account deletion. The member-route smoke test requires a second non-production account to exercise invite redemption and membership changes. The local gift fixture accounts are deleted after the gift smoke test.
651
+
652
+ Copy `.env.example` to the ignored `.env` file and configure the local endpoints and expected primary account ID.
653
+
654
+ | Variable | Purpose |
655
+ | ------------------------------- | ---------------------------------------------------------------------- |
656
+ | `ROOL_TEST_API_URL` | API origin. HTTPS is required except for loopback development servers. |
657
+ | `ROOL_TEST_AUTH_URL` | Auth endpoint override required for a loopback API. |
658
+ | `ROOL_TEST_ROUTER_URL` | Local machine-router origin. |
659
+ | `ROOL_TEST_USER_ID` | Expected primary account ID, preventing mutation of the wrong account. |
660
+ | `ROOL_TEST_GIFT_HOLDER_EMAIL` | Local fixture account that holds a gift. |
661
+ | `ROOL_TEST_GIFT_CLAIMANT_EMAIL` | Local fixture account that claims the gift. |
662
+ | `ROOL_TEST_INTERNAL_SECRET` | Local rool-server secret used to create and remove fixtures. |
663
+
664
+ Log the `sdk-v2-primary` and `sdk-v2-member` Node profiles into two dedicated accounts:
665
+
666
+ ```bash
667
+ node --env-file=.env --import tsx test/integration/v2/login.ts
668
+ ```
669
+
670
+ Then run the complete v2 smoke-test suite:
671
+
672
+ ```bash
673
+ pnpm test:v2
674
+ ```
675
+
676
+ To run one smoke test manually, invoke its script directly, for example:
677
+
678
+ ```bash
679
+ node --env-file=.env --import tsx test/integration/v2/machine-routes.test.ts
976
680
  ```
977
681
 
978
682
  ## License
979
683
 
980
- MIT - see [LICENSE](../../LICENSE) for details.
684
+ MIT see [LICENSE](../../LICENSE).