@rool-dev/sdk 0.9.0 → 0.10.0-dev.2e3d7c6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +359 -166
- package/dist/channel.d.ts +94 -184
- package/dist/channel.d.ts.map +1 -1
- package/dist/channel.js +360 -351
- package/dist/channel.js.map +1 -1
- package/dist/client.d.ts +32 -5
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +59 -57
- package/dist/client.js.map +1 -1
- package/dist/graphql.d.ts +35 -19
- package/dist/graphql.d.ts.map +1 -1
- package/dist/graphql.js +114 -128
- package/dist/graphql.js.map +1 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -4
- package/dist/index.js.map +1 -1
- package/dist/locations.d.ts +34 -0
- package/dist/locations.d.ts.map +1 -0
- package/dist/locations.js +90 -0
- package/dist/locations.js.map +1 -0
- package/dist/machine.d.ts +16 -0
- package/dist/machine.d.ts.map +1 -0
- package/dist/machine.js +51 -0
- package/dist/machine.js.map +1 -0
- package/dist/rest.d.ts +18 -0
- package/dist/rest.d.ts.map +1 -0
- package/dist/rest.js +46 -0
- package/dist/rest.js.map +1 -0
- package/dist/space.d.ts +20 -4
- package/dist/space.d.ts.map +1 -1
- package/dist/space.js +31 -45
- package/dist/space.js.map +1 -1
- package/dist/subscription.d.ts.map +1 -1
- package/dist/subscription.js +11 -12
- package/dist/subscription.js.map +1 -1
- package/dist/types.d.ts +79 -59
- package/dist/types.d.ts.map +1 -1
- package/dist/webdav.d.ts +153 -0
- package/dist/webdav.d.ts.map +1 -0
- package/dist/webdav.js +458 -0
- package/dist/webdav.js.map +1 -0
- package/package.json +1 -1
- package/dist/media.d.ts +0 -70
- package/dist/media.d.ts.map +0 -1
- package/dist/media.js +0 -228
- package/dist/media.js.map +0 -1
package/README.md
CHANGED
|
@@ -4,13 +4,14 @@ The TypeScript SDK for Rool, a persistent and collaborative environment for orga
|
|
|
4
4
|
|
|
5
5
|
> **Building a new Rool extension?** Start with [`@rool-dev/extension`](/extension/) — it handles hosting, dev server, and gives you a reactive Svelte channel out of the box. This SDK is for advanced use cases: integrating Rool into an existing application, building Node.js scripts, or working outside the extension sandbox.
|
|
6
6
|
|
|
7
|
-
The SDK manages authentication, real-time synchronization, and
|
|
7
|
+
The SDK manages authentication, real-time synchronization, and per-space file storage. Core primitives:
|
|
8
8
|
|
|
9
|
-
- **Spaces** — Containers for objects, schema, metadata, and
|
|
9
|
+
- **Spaces** — Containers for objects, schema, metadata, channels, and files
|
|
10
10
|
- **Channels** — Named contexts within a space. All object and AI operations go through a channel.
|
|
11
11
|
- **Conversations** — Independent interaction histories within a channel.
|
|
12
|
-
- **Objects** —
|
|
12
|
+
- **Objects** — Records addressed by a **location** path (`/space/<collection>/<basename>.json`). The body holds user-defined fields. References between objects are body fields whose values are location strings.
|
|
13
13
|
- **AI operations** — Create, update, or query objects using natural language and `{{placeholders}}`
|
|
14
|
+
- **File storage** — Every space has WebDAV file storage
|
|
14
15
|
|
|
15
16
|
## Installation
|
|
16
17
|
|
|
@@ -42,24 +43,19 @@ await channel.createCollection('body', [
|
|
|
42
43
|
{ name: 'orbits', type: { kind: 'maybe', inner: { kind: 'ref' } } },
|
|
43
44
|
]);
|
|
44
45
|
|
|
45
|
-
// Create objects with AI-generated content using {{placeholders}}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
name: 'Earth',
|
|
59
|
-
mass: '{{mass in Earth masses}}',
|
|
60
|
-
radius: '{{radius in km}}',
|
|
61
|
-
orbits: sun.id // Reference to the sun object
|
|
62
|
-
}
|
|
46
|
+
// Create objects with AI-generated content using {{placeholders}}.
|
|
47
|
+
// First arg is the collection, second is the body.
|
|
48
|
+
const { object: sun } = await channel.createObject('body', {
|
|
49
|
+
name: 'Sun',
|
|
50
|
+
mass: '{{mass in solar masses}}',
|
|
51
|
+
radius: '{{radius in km}}',
|
|
52
|
+
}, { basename: 'sun' });
|
|
53
|
+
|
|
54
|
+
const { object: earth } = await channel.createObject('body', {
|
|
55
|
+
name: 'Earth',
|
|
56
|
+
mass: '{{mass in Earth masses}}',
|
|
57
|
+
radius: '{{radius in km}}',
|
|
58
|
+
orbits: sun.location, // Reference to the sun via its location
|
|
63
59
|
});
|
|
64
60
|
|
|
65
61
|
// Use the AI agent to work with your data
|
|
@@ -67,7 +63,7 @@ const { message, objects } = await channel.prompt(
|
|
|
67
63
|
'Add the other planets in our solar system, each referencing the Sun'
|
|
68
64
|
);
|
|
69
65
|
console.log(message); // AI explains what it did
|
|
70
|
-
console.log(`
|
|
66
|
+
console.log(`Modified ${objects.length} objects`);
|
|
71
67
|
|
|
72
68
|
// Query with natural language
|
|
73
69
|
const { objects: innerPlanets } = await channel.findObjects({
|
|
@@ -82,11 +78,11 @@ channel.close();
|
|
|
82
78
|
|
|
83
79
|
### Spaces and Channels
|
|
84
80
|
|
|
85
|
-
A **space** is a container that holds objects, schema, metadata, and
|
|
81
|
+
A **space** is a container that holds objects, schema, metadata, channels, and files. A **channel** is a named context within a space — it's the handle you use for all object and AI operations. Each channel contains one or more **conversations**, each with independent interaction history.
|
|
86
82
|
|
|
87
83
|
There are two main handles:
|
|
88
|
-
- **`RoolSpace`** — Live handle with SSE subscription for user management, link access, channel management, export, and channel lifecycle events. Extends `EventEmitter`.
|
|
89
|
-
- **`RoolChannel`** — Full real-time handle for objects, AI prompts,
|
|
84
|
+
- **`RoolSpace`** — Live handle with SSE subscription for user management, link access, channel management, file storage, export, and channel lifecycle events. Extends `EventEmitter`.
|
|
85
|
+
- **`RoolChannel`** — Full real-time handle for objects, AI prompts, schema, and undo/redo.
|
|
90
86
|
|
|
91
87
|
```typescript
|
|
92
88
|
// Open a space — live handle with SSE subscription
|
|
@@ -186,52 +182,105 @@ thread.getInteractions(); // Returns the blue branch (root → leaf)
|
|
|
186
182
|
- `prompt()` with no `parentInteractionId` auto-continues from `activeLeafId`
|
|
187
183
|
- `prompt()` with `parentInteractionId: null` starts a new root-level branch
|
|
188
184
|
|
|
189
|
-
### Objects
|
|
185
|
+
### Objects, Locations, and References
|
|
190
186
|
|
|
191
|
-
|
|
187
|
+
Every object lives at a **location** — a path of the form `/space/<collection>/<basename>.json`. The collection is the parent directory, the basename is the filename without `.json`, and together they fully identify the object.
|
|
192
188
|
|
|
193
189
|
```typescript
|
|
194
|
-
{
|
|
190
|
+
{
|
|
191
|
+
location: '/space/article/welcome.json',
|
|
192
|
+
collection: 'article',
|
|
193
|
+
basename: 'welcome',
|
|
194
|
+
body: { title: 'Hello World', status: 'draft' },
|
|
195
|
+
}
|
|
195
196
|
```
|
|
196
197
|
|
|
197
|
-
**
|
|
198
|
+
The **body** holds the user-defined data.
|
|
199
|
+
|
|
200
|
+
**References** between objects are body fields whose values are location strings:
|
|
198
201
|
|
|
199
202
|
```typescript
|
|
200
|
-
// A planet references a star
|
|
201
|
-
{
|
|
203
|
+
// A planet references a star
|
|
204
|
+
{
|
|
205
|
+
location: '/space/body/earth.json',
|
|
206
|
+
collection: 'body',
|
|
207
|
+
basename: 'earth',
|
|
208
|
+
body: { name: 'Earth', orbits: '/space/body/sun.json' },
|
|
209
|
+
}
|
|
202
210
|
|
|
203
211
|
// An array of references
|
|
204
|
-
{
|
|
212
|
+
{
|
|
213
|
+
location: '/space/team/alpha.json',
|
|
214
|
+
collection: 'team',
|
|
215
|
+
basename: 'alpha',
|
|
216
|
+
body: {
|
|
217
|
+
name: 'Alpha',
|
|
218
|
+
members: [
|
|
219
|
+
'/space/user/alice.json',
|
|
220
|
+
'/space/user/bob.json',
|
|
221
|
+
'/space/user/carol.json',
|
|
222
|
+
],
|
|
223
|
+
},
|
|
224
|
+
}
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
References are just data — no special API is needed to create or remove them. Set a field to a location string to create a reference; clear it to remove it.
|
|
228
|
+
|
|
229
|
+
#### Location helpers
|
|
230
|
+
|
|
231
|
+
```typescript
|
|
232
|
+
import { loc, parseLocation, normalizeLocation, generateBasename } from '@rool-dev/sdk';
|
|
233
|
+
|
|
234
|
+
loc('article', 'welcome'); // '/space/article/welcome.json'
|
|
235
|
+
parseLocation('/space/article/welcome.json'); // { collection: 'article', basename: 'welcome' }
|
|
236
|
+
|
|
237
|
+
// normalizeLocation accepts canonical or short form and returns canonical
|
|
238
|
+
normalizeLocation('article/welcome'); // '/space/article/welcome.json'
|
|
239
|
+
normalizeLocation('/space/article/welcome.json'); // unchanged
|
|
240
|
+
|
|
241
|
+
// 6-char random basename — same generator the SDK uses by default
|
|
242
|
+
generateBasename(); // e.g., 'X7kQ9p'
|
|
205
243
|
```
|
|
206
244
|
|
|
207
|
-
|
|
245
|
+
SDK methods that accept a location (`getObject`, `updateObject`, `deleteObjects`, `moveObject`, etc.) accept either form and normalize internally. SDK return values always use the canonical full form.
|
|
246
|
+
|
|
247
|
+
#### Machine resource links
|
|
248
|
+
|
|
249
|
+
```typescript
|
|
250
|
+
import { resolveMachineResource } from '@rool-dev/sdk';
|
|
251
|
+
|
|
252
|
+
const objectResource = resolveMachineResource('/space/article/welcome.json');
|
|
253
|
+
// { kind: 'object', path: '/space/article/welcome.json' }
|
|
254
|
+
|
|
255
|
+
const fileResource = resolveMachineResource('/rool-drive/docs/readme.md');
|
|
256
|
+
// { kind: 'file', path: '/rool-drive/docs/readme.md' }
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
`rool-machine:` is the canonical URI scheme for user-visible resources from the Rool machine filesystem. `resolveMachineResource()` accepts either canonical `rool-machine:/...` URIs or bare machine paths such as `/rool-drive/...`, and returns the resource kind plus machine path. Fetch file resources through `space.fetchMachineResource(resource)`.
|
|
208
260
|
|
|
209
261
|
### AI Placeholder Pattern
|
|
210
262
|
|
|
211
|
-
Use `{{description}}` in field values to have AI generate content:
|
|
263
|
+
Use `{{description}}` in body field values to have AI generate content:
|
|
212
264
|
|
|
213
265
|
```typescript
|
|
214
266
|
// Create with AI-generated content
|
|
215
|
-
await channel.createObject({
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
headline: '{{catchy headline about coffee}}',
|
|
219
|
-
body: '{{informative paragraph}}'
|
|
220
|
-
}
|
|
267
|
+
await channel.createObject('article', {
|
|
268
|
+
headline: '{{catchy headline about coffee}}',
|
|
269
|
+
body: '{{informative paragraph}}',
|
|
221
270
|
});
|
|
222
271
|
|
|
223
272
|
// Update existing content with AI
|
|
224
|
-
await channel.updateObject('
|
|
273
|
+
await channel.updateObject('/space/article/welcome.json', {
|
|
225
274
|
prompt: 'Make the body shorter and more casual'
|
|
226
275
|
});
|
|
227
276
|
|
|
228
277
|
// Add new AI-generated field to existing object
|
|
229
|
-
await channel.updateObject('
|
|
278
|
+
await channel.updateObject('/space/article/welcome.json', {
|
|
230
279
|
data: { summary: '{{one-sentence summary}}' }
|
|
231
280
|
});
|
|
232
281
|
```
|
|
233
282
|
|
|
234
|
-
When resolving placeholders, the agent has access to the full
|
|
283
|
+
When resolving placeholders, the agent has access to the full body and the surrounding space context (except for `_`-prefixed fields). Placeholders are instructions, not templates, and do not need to repeat information already present in other fields.
|
|
235
284
|
|
|
236
285
|
Placeholders are resolved by the AI during the mutation and replaced with concrete values. The `{{...}}` syntax is never stored — it only guides the agent while creating or updating the object.
|
|
237
286
|
|
|
@@ -242,7 +291,7 @@ Undo/redo works on **checkpoints**, not individual operations. Call `checkpoint(
|
|
|
242
291
|
```typescript
|
|
243
292
|
// Create a checkpoint before user action
|
|
244
293
|
await channel.checkpoint('Delete object');
|
|
245
|
-
await channel.deleteObjects([
|
|
294
|
+
await channel.deleteObjects([location]);
|
|
246
295
|
|
|
247
296
|
// User can now undo back to the checkpoint
|
|
248
297
|
if (await channel.canUndo()) {
|
|
@@ -259,16 +308,13 @@ Checkpoints are **space-wide**: one shared stack across all channels and users.
|
|
|
259
308
|
|
|
260
309
|
### Hidden Fields
|
|
261
310
|
|
|
262
|
-
|
|
311
|
+
Body fields starting with `_` (e.g., `_ui`, `_cache`) are hidden from AI and ignored by the schema — you can add them to any object regardless of its collection definition. Otherwise they behave like normal fields: they sync in real-time, persist to the server, support undo/redo, and are visible to all users of the space. Use them for UI state, positions, or other data the AI shouldn't see or modify:
|
|
263
312
|
|
|
264
313
|
```typescript
|
|
265
|
-
await channel.createObject({
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
author: "John Doe",
|
|
270
|
-
_ui: { x: 100, y: 200, collapsed: false }
|
|
271
|
-
}
|
|
314
|
+
await channel.createObject('article', {
|
|
315
|
+
title: 'My Article',
|
|
316
|
+
author: 'John Doe',
|
|
317
|
+
_ui: { x: 100, y: 200, collapsed: false }
|
|
272
318
|
});
|
|
273
319
|
```
|
|
274
320
|
|
|
@@ -283,42 +329,50 @@ Events fire for both local and remote changes. The `source` field indicates orig
|
|
|
283
329
|
|
|
284
330
|
```typescript
|
|
285
331
|
// All UI updates happen in one place, regardless of change source
|
|
286
|
-
channel.on('objectUpdated', ({
|
|
287
|
-
renderObject(
|
|
332
|
+
channel.on('objectUpdated', ({ location, object, source }) => {
|
|
333
|
+
renderObject(location, object);
|
|
288
334
|
if (source === 'remote_agent') {
|
|
289
335
|
doLayout(); // AI might have added content
|
|
290
336
|
}
|
|
291
337
|
});
|
|
292
338
|
|
|
293
339
|
// Caller just makes the change - event handler does the UI work
|
|
294
|
-
channel.updateObject(
|
|
340
|
+
channel.updateObject(location, { prompt: 'expand this' });
|
|
295
341
|
```
|
|
296
342
|
|
|
297
|
-
###
|
|
343
|
+
### Locations & Basenames
|
|
298
344
|
|
|
299
|
-
By default, `createObject`
|
|
345
|
+
By default, `createObject` mints a 6-character alphanumeric basename. Provide your own via `options.basename` for meaningful identifiers:
|
|
300
346
|
|
|
301
347
|
```typescript
|
|
302
|
-
await channel.createObject(
|
|
348
|
+
await channel.createObject('article',
|
|
349
|
+
{ title: 'The Meaning of Life' },
|
|
350
|
+
{ basename: 'meaning-of-life' },
|
|
351
|
+
);
|
|
352
|
+
// → location: /space/article/meaning-of-life.json
|
|
303
353
|
```
|
|
304
354
|
|
|
305
|
-
**Why
|
|
306
|
-
- **Fire-and-forget creation** — Know the
|
|
307
|
-
- **Meaningful
|
|
355
|
+
**Why pin a basename?**
|
|
356
|
+
- **Fire-and-forget creation** — Know the location immediately without awaiting the response.
|
|
357
|
+
- **Meaningful identifiers** — Use domain-specific names like `welcome` or `2026-budget` for easier debugging and external references.
|
|
308
358
|
|
|
309
359
|
```typescript
|
|
310
360
|
// Fire-and-forget: create and reference without waiting
|
|
311
|
-
const
|
|
312
|
-
|
|
313
|
-
|
|
361
|
+
const basename = RoolClient.generateBasename();
|
|
362
|
+
const location = loc('note', basename);
|
|
363
|
+
|
|
364
|
+
channel.createObject('note', { text: '{{expand this idea}}' }, { basename });
|
|
365
|
+
channel.updateObject(parentLocation, {
|
|
366
|
+
data: { notes: [...existingNotes, location] },
|
|
367
|
+
}); // Add reference immediately
|
|
314
368
|
```
|
|
315
369
|
|
|
316
|
-
**
|
|
317
|
-
- Must
|
|
318
|
-
-
|
|
319
|
-
-
|
|
370
|
+
**Basename constraints:**
|
|
371
|
+
- Must start with an alphanumeric character.
|
|
372
|
+
- Other characters may be alphanumeric, hyphens (`-`), or underscores (`_`).
|
|
373
|
+
- Must be unique within its collection (throws if the location already exists).
|
|
320
374
|
|
|
321
|
-
Use `
|
|
375
|
+
Use `moveObject` to rename an object or move it to a different collection — see [Moving and Renaming](#moving-and-renaming).
|
|
322
376
|
|
|
323
377
|
## Authentication
|
|
324
378
|
|
|
@@ -365,7 +419,7 @@ if (!authenticated) {
|
|
|
365
419
|
|
|
366
420
|
## AI Agent
|
|
367
421
|
|
|
368
|
-
The `prompt()` method is the primary way to invoke the AI agent. The agent has editor-level capabilities — it can create, modify, and delete objects — but cannot see or modify `_`-prefixed fields.
|
|
422
|
+
The `prompt()` method is the primary way to invoke the AI agent. The agent has editor-level capabilities — it can create, modify, move, and delete objects — but cannot see or modify `_`-prefixed fields.
|
|
369
423
|
|
|
370
424
|
```typescript
|
|
371
425
|
const { message, objects } = await channel.prompt(
|
|
@@ -389,13 +443,13 @@ Returns a message (the AI's response) and the list of objects that were created
|
|
|
389
443
|
|
|
390
444
|
| Option | Description |
|
|
391
445
|
|--------|-------------|
|
|
392
|
-
| `
|
|
446
|
+
| `locations` | Focus the AI on specific objects, identified by location (given primary attention in context). |
|
|
393
447
|
| `responseSchema` | Request structured JSON instead of text summary |
|
|
394
448
|
| `effort` | Effort level: `'QUICK'`, `'STANDARD'` (default), `'REASONING'`, or `'RESEARCH'` |
|
|
395
449
|
| `ephemeral` | If true, don't record in interaction history (useful for tab completion) |
|
|
396
|
-
| `readOnly` | If true, disable mutation tools (create, update, delete). Use for questions. |
|
|
450
|
+
| `readOnly` | If true, disable mutation tools (create, update, move, delete). Use for questions. |
|
|
397
451
|
| `parentInteractionId` | Parent interaction in the conversation tree. Omit to auto-continue from the active leaf. Pass `null` to start a new root-level branch. Pass a specific ID to branch from that point (edit/reroll). |
|
|
398
|
-
| `attachments` | Files to attach (`File`, `Blob`, or `{ data, contentType }`).
|
|
452
|
+
| `attachments` | Files to attach (`File`, `Blob`, or `{ data, contentType }`). Stored as authenticated space files; resulting `rool-machine:/rool-drive/...` references are stored on the interaction's `attachments` field for UI rendering. The AI can interpret images (JPEG, PNG, GIF, WebP, SVG), PDFs, text-based files (plain text, Markdown, CSV, HTML, XML, JSON), and DOCX documents. Other file types are uploaded and stored but the AI cannot natively consume their contents, only use shell tools on them. |
|
|
399
453
|
| `signal` | `AbortSignal` to stop the prompt mid-flight. When aborted, the agent loop halts and the streaming response closes. Note that any LLM turn already in flight on Vertex keeps generating server-side and is billed. |
|
|
400
454
|
|
|
401
455
|
### Effort Levels
|
|
@@ -418,7 +472,7 @@ const { objects } = await channel.prompt(
|
|
|
418
472
|
// Work with specific objects
|
|
419
473
|
const result = await channel.prompt(
|
|
420
474
|
"Summarize these articles",
|
|
421
|
-
{
|
|
475
|
+
{ locations: ['/space/article/intro.json', '/space/article/conclusion.json'] }
|
|
422
476
|
);
|
|
423
477
|
|
|
424
478
|
// Quick question without mutations (fast model + read-only)
|
|
@@ -455,7 +509,11 @@ Use `responseSchema` to get structured JSON instead of a text message:
|
|
|
455
509
|
|
|
456
510
|
```typescript
|
|
457
511
|
const { message } = await channel.prompt("Categorize these items", {
|
|
458
|
-
|
|
512
|
+
locations: [
|
|
513
|
+
'/space/item/widget.json',
|
|
514
|
+
'/space/item/gadget.json',
|
|
515
|
+
'/space/item/gizmo.json',
|
|
516
|
+
],
|
|
459
517
|
responseSchema: {
|
|
460
518
|
type: 'object',
|
|
461
519
|
properties: {
|
|
@@ -477,7 +535,7 @@ console.log(result.categories, result.summary);
|
|
|
477
535
|
AI operations automatically receive context:
|
|
478
536
|
- **Interaction history** — Previous interactions and their results from this channel
|
|
479
537
|
- **Recently modified objects** — Objects created or changed recently
|
|
480
|
-
- **Selected objects** — Objects passed via `
|
|
538
|
+
- **Selected objects** — Objects passed via `locations` are given primary focus
|
|
481
539
|
|
|
482
540
|
This context flows automatically — no configuration needed. The AI sees enough history to maintain coherent interactions while respecting the `_`-prefixed field hiding rules.
|
|
483
541
|
|
|
@@ -505,7 +563,7 @@ await space.addUser(user.id, 'editor');
|
|
|
505
563
|
|------|--------------|
|
|
506
564
|
| `owner` | Full control, can delete space and manage all users |
|
|
507
565
|
| `admin` | All editor capabilities, plus can manage users (except other admins/owners) |
|
|
508
|
-
| `editor` | Can create, modify, and delete objects |
|
|
566
|
+
| `editor` | Can create, modify, move, and delete objects |
|
|
509
567
|
| `viewer` | Read-only access (can query with `prompt` and `findObjects`) |
|
|
510
568
|
|
|
511
569
|
### Space Collaboration Methods
|
|
@@ -548,6 +606,7 @@ When a user accesses a space via URL, they're granted the corresponding role (`v
|
|
|
548
606
|
| `currentUser: CurrentUser \| null` | Cached user profile from `initialize()`. Use for sync access to user info (id, email, name, etc.). Returns `null` before `initialize()` is called. |
|
|
549
607
|
| `getCurrentUser(): Promise<CurrentUser>` | Fetch fresh user profile from server (id, email, name, photoUrl, slug, plan, creditsBalance, totalCreditsUsed, createdAt, lastActivity, processedAt, storage) |
|
|
550
608
|
| `updateCurrentUser(input): Promise<CurrentUser>` | Update the current user's profile (`name`, `slug`). Returns the updated user. Slug must be 3–32 chars, start with a letter, and contain only lowercase alphanumeric characters, hyphens, and underscores. |
|
|
609
|
+
| `deleteCurrentUser(): Promise<void>` | Mark the current user's account for deletion (10-minute grace period before irreversible). Logs out the client. |
|
|
551
610
|
| `searchUser(email): Promise<UserResult \| null>` | Find user by exact email address (no partial matching) |
|
|
552
611
|
|
|
553
612
|
### Real-time Collaboration
|
|
@@ -555,7 +614,7 @@ When a user accesses a space via URL, they're granted the corresponding role (`v
|
|
|
555
614
|
When multiple users have a space open, changes sync in real-time. The `source` field in events tells you who made the change:
|
|
556
615
|
|
|
557
616
|
```typescript
|
|
558
|
-
channel.on('objectUpdated', ({
|
|
617
|
+
channel.on('objectUpdated', ({ location, object, source }) => {
|
|
559
618
|
if (source === 'remote_user') {
|
|
560
619
|
// Another user made this change
|
|
561
620
|
showCollaboratorActivity(object);
|
|
@@ -591,8 +650,11 @@ const client = new RoolClient({
|
|
|
591
650
|
| `listSpaces(): Promise<RoolSpaceInfo[]>` | List available spaces |
|
|
592
651
|
| `openSpace(spaceId): Promise<RoolSpace>` | Open a space with live SSE subscription. Caches and reuses open spaces. Call `space.openChannel(channelId)` to get a channel. |
|
|
593
652
|
| `createSpace(name): Promise<RoolSpace>` | Create a new space, returns live handle with SSE subscription |
|
|
653
|
+
| `duplicateSpace(sourceSpaceId, name): Promise<RoolSpace>` | Duplicate an existing space. Returns a handle to the new space. |
|
|
594
654
|
| `deleteSpace(id): Promise<void>` | Permanently delete a space (cannot be undone) |
|
|
595
655
|
| `importArchive(name, archive): Promise<RoolSpace>` | Import from a zip archive, creating a new space |
|
|
656
|
+
| `webdav(spaceId): RoolWebDAV` | Open a WebDAV client for a space's file storage |
|
|
657
|
+
| `getSpaceStorageUsage(spaceId): Promise<SpaceFileStorageUsage>` | Get WebDAV quota usage for a space |
|
|
596
658
|
|
|
597
659
|
### Channel Management
|
|
598
660
|
|
|
@@ -676,7 +738,8 @@ Discover and install extensions published by other users.
|
|
|
676
738
|
|
|
677
739
|
| Method | Description |
|
|
678
740
|
|--------|-------------|
|
|
679
|
-
| `RoolClient.
|
|
741
|
+
| `RoolClient.generateBasename(): string` | Generate a 6-char alphanumeric basename for new object identities. |
|
|
742
|
+
| `RoolClient.generateId(): string` | Same as `generateBasename()`; retained for callers minting non-object IDs (interactions, conversations, channels). |
|
|
680
743
|
| `destroy(): void` | Clean up resources |
|
|
681
744
|
|
|
682
745
|
### Client Events
|
|
@@ -710,7 +773,7 @@ client.on('spaceRenamed', (id, name) => {
|
|
|
710
773
|
|
|
711
774
|
## RoolSpace API
|
|
712
775
|
|
|
713
|
-
A space handle with a live SSE subscription. Extends `EventEmitter`. Manages user access, link sharing, channels, and export. The `channels` property auto-updates via SSE, and channel lifecycle events fire in real-time.
|
|
776
|
+
A space handle with a live SSE subscription. Extends `EventEmitter`. Manages user access, link sharing, channels, file storage, and export. The `channels` property auto-updates via SSE, and channel lifecycle events fire in real-time.
|
|
714
777
|
|
|
715
778
|
`openSpace()` caches and reuses open spaces — calling it twice with the same ID returns the same instance. Call `close()` when done to stop the subscription and close all open channels.
|
|
716
779
|
|
|
@@ -724,6 +787,7 @@ A space handle with a live SSE subscription. Extends `EventEmitter`. Manages use
|
|
|
724
787
|
| `linkAccess: LinkAccess` | URL sharing level |
|
|
725
788
|
| `memberCount: number` | Number of users with access to the space |
|
|
726
789
|
| `channels: ChannelInfo[]` | Live channel list (auto-updates via SSE) |
|
|
790
|
+
| `webdav: RoolWebDAV` | WebDAV client for this space's file storage |
|
|
727
791
|
|
|
728
792
|
### Methods
|
|
729
793
|
|
|
@@ -742,6 +806,8 @@ A space handle with a live SSE subscription. Extends `EventEmitter`. Manages use
|
|
|
742
806
|
| `deleteChannel(channelId): Promise<void>` | Delete a channel |
|
|
743
807
|
| `installExtension(extensionId, channelId): Promise<string>` | Install an extension into a channel of this space. If you own it, wires it directly. If it's a marketplace extension, copies and builds a new extension in your library. Returns the channel ID. |
|
|
744
808
|
| `exportArchive(): Promise<Blob>` | Export space as zip archive |
|
|
809
|
+
| `getStorageUsage(): Promise<SpaceFileStorageUsage>` | Get WebDAV quota usage for this space |
|
|
810
|
+
| `fetchMachineResource(resource): Promise<Response>` | Fetch a resolved file `MachineResource` through this space |
|
|
745
811
|
| `refresh(): Promise<void>` | Refresh space data from server |
|
|
746
812
|
|
|
747
813
|
### Space Events
|
|
@@ -782,49 +848,124 @@ A channel is a named context within a space. All object operations, AI prompts,
|
|
|
782
848
|
|
|
783
849
|
### Object Operations
|
|
784
850
|
|
|
785
|
-
Objects are
|
|
851
|
+
Objects are records addressed by location (`/space/<collection>/<basename>.json`). Every object must belong to a collection — create the collection first (see [Collection Schema](#collection-schema)). The body holds the user-defined fields.
|
|
852
|
+
|
|
853
|
+
All methods that accept a location accept either the canonical form or the short form (`collection/basename`).
|
|
786
854
|
|
|
787
855
|
| Method | Description |
|
|
788
856
|
|--------|-------------|
|
|
789
|
-
| `getObject(
|
|
790
|
-
| `stat(
|
|
791
|
-
| `findObjects(options): Promise<{ objects, message }>` | Find objects using structured filters and natural language. Results sorted by modifiedAt (desc by default). |
|
|
792
|
-
| `
|
|
793
|
-
| `createObject(options): Promise<{ object, message }>` | Create a new object
|
|
794
|
-
| `updateObject(
|
|
795
|
-
| `
|
|
857
|
+
| `getObject(location): Promise<RoolObject \| undefined>` | Get an object, or undefined if not found. |
|
|
858
|
+
| `stat(location): RoolObjectStat \| undefined` | Get audit info for an object: when it was last modified, by whom, and where (channel/conversation/interaction). Sync read from local cache. |
|
|
859
|
+
| `findObjects(options): Promise<{ objects, message }>` | Find objects using structured filters and/or natural language. Results sorted by modifiedAt (desc by default). |
|
|
860
|
+
| `getObjectLocations(options?): string[]` | Get all object locations. Sorted by modifiedAt (desc by default). Options: `{ limit?, order? }`. |
|
|
861
|
+
| `createObject(collection, body, options?): Promise<{ object, message }>` | Create a new object in `collection`. The SDK mints a random basename unless you pass `options.basename`. |
|
|
862
|
+
| `updateObject(location, options): Promise<{ object, message }>` | Update an existing object's body. |
|
|
863
|
+
| `moveObject(from, to, options?): Promise<{ object, message }>` | Rename or relocate an object. See [Moving and Renaming](#moving-and-renaming). |
|
|
864
|
+
| `deleteObjects(locations): Promise<void>` | Delete objects by location. Other objects' refs become stale. |
|
|
796
865
|
|
|
797
|
-
#### createObject
|
|
866
|
+
#### createObject
|
|
867
|
+
|
|
868
|
+
```typescript
|
|
869
|
+
// Auto-generated basename
|
|
870
|
+
const { object } = await channel.createObject('article', {
|
|
871
|
+
title: 'Hello',
|
|
872
|
+
body: 'World',
|
|
873
|
+
});
|
|
874
|
+
// → object.location: '/space/article/X7kQ9p.json'
|
|
875
|
+
|
|
876
|
+
// Pinned basename
|
|
877
|
+
await channel.createObject('article',
|
|
878
|
+
{ title: 'Welcome' },
|
|
879
|
+
{ basename: 'welcome' },
|
|
880
|
+
);
|
|
881
|
+
// → location: '/space/article/welcome.json'
|
|
882
|
+
|
|
883
|
+
// AI placeholders
|
|
884
|
+
await channel.createObject('article', {
|
|
885
|
+
headline: '{{catchy headline}}',
|
|
886
|
+
body: '{{long-form intro}}',
|
|
887
|
+
});
|
|
888
|
+
```
|
|
798
889
|
|
|
799
890
|
| Option | Description |
|
|
800
891
|
|--------|-------------|
|
|
801
|
-
| `
|
|
802
|
-
| `ephemeral` | If true, the operation won't be recorded in interaction history.
|
|
892
|
+
| `basename` | Specific basename to use. If omitted, the SDK generates a random 6-char one. |
|
|
893
|
+
| `ephemeral` | If true, the operation won't be recorded in interaction history. |
|
|
894
|
+
| `parentInteractionId` | Conversation tree parent. Omit to auto-continue; pass `null` for a new root. |
|
|
895
|
+
|
|
896
|
+
#### updateObject
|
|
897
|
+
|
|
898
|
+
```typescript
|
|
899
|
+
// Add/update fields
|
|
900
|
+
await channel.updateObject('/space/article/welcome.json', {
|
|
901
|
+
data: { status: 'published' },
|
|
902
|
+
});
|
|
803
903
|
|
|
804
|
-
|
|
904
|
+
// Delete a field (pass null)
|
|
905
|
+
await channel.updateObject('/space/article/welcome.json', {
|
|
906
|
+
data: { draft: null },
|
|
907
|
+
});
|
|
908
|
+
|
|
909
|
+
// AI-driven rewrite
|
|
910
|
+
await channel.updateObject('/space/article/welcome.json', {
|
|
911
|
+
prompt: 'Tighten the intro by 30%.',
|
|
912
|
+
});
|
|
913
|
+
```
|
|
805
914
|
|
|
806
915
|
| Option | Description |
|
|
807
916
|
|--------|-------------|
|
|
808
|
-
| `data` |
|
|
917
|
+
| `data` | Body fields to add, update, or delete. `null` removes the field. Use `{{placeholder}}` for AI-generated content. Fields prefixed with `_` are hidden from AI. |
|
|
809
918
|
| `prompt` | Natural language instruction for AI to modify content. |
|
|
810
|
-
| `ephemeral` | If true, the operation won't be recorded in interaction history.
|
|
919
|
+
| `ephemeral` | If true, the operation won't be recorded in interaction history. |
|
|
920
|
+
| `parentInteractionId` | Conversation tree parent. Omit to auto-continue; pass `null` for a new root. |
|
|
921
|
+
|
|
922
|
+
Use `moveObject` to change an object's location (collection or basename).
|
|
923
|
+
|
|
924
|
+
#### Moving and Renaming
|
|
925
|
+
|
|
926
|
+
`moveObject` is how you rename an object (new basename in the same collection) or move it across collections. Pass `options.body` to atomically rewrite the body as part of the move.
|
|
927
|
+
|
|
928
|
+
```typescript
|
|
929
|
+
// Rename within the same collection
|
|
930
|
+
await channel.moveObject(
|
|
931
|
+
'/space/article/welcome.json',
|
|
932
|
+
'/space/article/hello-world.json',
|
|
933
|
+
);
|
|
934
|
+
|
|
935
|
+
// Move into a different collection
|
|
936
|
+
await channel.moveObject(
|
|
937
|
+
'/space/draft/post-42.json',
|
|
938
|
+
'/space/article/post-42.json',
|
|
939
|
+
);
|
|
940
|
+
|
|
941
|
+
// Move and replace body in one go
|
|
942
|
+
await channel.moveObject(from, to, {
|
|
943
|
+
body: { title: 'Hello, world', status: 'published' },
|
|
944
|
+
});
|
|
945
|
+
```
|
|
946
|
+
|
|
947
|
+
| Option | Description |
|
|
948
|
+
|--------|-------------|
|
|
949
|
+
| `body` | Replace the body atomically as part of the move. If omitted, the body is preserved. |
|
|
950
|
+
| `ephemeral` | If true, the operation won't be recorded in interaction history. |
|
|
951
|
+
| `parentInteractionId` | Conversation tree parent. Omit to auto-continue; pass `null` for a new root. |
|
|
811
952
|
|
|
812
|
-
#### findObjects
|
|
953
|
+
#### findObjects
|
|
813
954
|
|
|
814
955
|
Find objects using structured filters and/or natural language.
|
|
815
956
|
|
|
816
957
|
- **`where` only** — exact-match filtering, no AI, no credits.
|
|
817
|
-
- **`collection` only** — filter by collection name
|
|
958
|
+
- **`collection` only** — filter by collection name, no AI, no credits.
|
|
818
959
|
- **`prompt` only** — AI-powered semantic query over all objects.
|
|
819
|
-
- **`where` + `prompt`** — `where` (and `
|
|
960
|
+
- **`where` + `prompt`** — `where` (and `locations`) narrow the data set first, then the AI queries within the constrained set.
|
|
820
961
|
|
|
821
962
|
| Option | Description |
|
|
822
963
|
|--------|-------------|
|
|
823
|
-
| `where` | Exact-match field filter (e.g. `{ status: 'published' }`). Values must match literally — no operators or `{{placeholders}}`. When combined with `prompt`, constrains which objects the AI can see. |
|
|
824
|
-
| `collection` | Filter by collection name.
|
|
964
|
+
| `where` | Exact-match body-field filter (e.g. `{ status: 'published' }`). Values must match literally — no operators or `{{placeholders}}`. When combined with `prompt`, constrains which objects the AI can see. |
|
|
965
|
+
| `collection` | Filter by collection name. |
|
|
825
966
|
| `prompt` | Natural language query. Triggers AI evaluation (uses credits). |
|
|
826
967
|
| `limit` | Maximum number of results. |
|
|
827
|
-
| `
|
|
968
|
+
| `locations` | Scope to specific object locations. Constrains the candidate set in both structured and AI queries. |
|
|
828
969
|
| `order` | Sort order by modifiedAt: `'asc'` or `'desc'` (default: `'desc'`). |
|
|
829
970
|
| `ephemeral` | If true, the query won't be recorded in interaction history. Useful for responsive search. |
|
|
830
971
|
|
|
@@ -860,7 +1001,7 @@ const { objects } = await channel.findObjects({
|
|
|
860
1001
|
});
|
|
861
1002
|
```
|
|
862
1003
|
|
|
863
|
-
When `where` or `
|
|
1004
|
+
When `where` or `locations` are provided with a `prompt`, the AI only sees the filtered subset — not the full space. The returned `message` explains the query result.
|
|
864
1005
|
|
|
865
1006
|
### Undo/Redo
|
|
866
1007
|
|
|
@@ -877,7 +1018,7 @@ See [Checkpoints & Undo/Redo](#checkpoints--undoredo) for semantics.
|
|
|
877
1018
|
|
|
878
1019
|
### Space Metadata
|
|
879
1020
|
|
|
880
|
-
Store arbitrary data alongside the
|
|
1021
|
+
Store arbitrary data alongside the space without it being part of an object's body (e.g., viewport state, user preferences).
|
|
881
1022
|
|
|
882
1023
|
| Method | Description |
|
|
883
1024
|
|--------|-------------|
|
|
@@ -885,35 +1026,77 @@ Store arbitrary data alongside the Space without it being part of the object dat
|
|
|
885
1026
|
| `getMetadata(key): unknown` | Get metadata value, or undefined if key not set |
|
|
886
1027
|
| `getAllMetadata(): Record<string, unknown>` | Get all metadata |
|
|
887
1028
|
|
|
888
|
-
###
|
|
1029
|
+
### Space File Storage
|
|
889
1030
|
|
|
890
|
-
|
|
1031
|
+
Every space has authenticated file storage. WebDAV is the SDK surface for that storage: paths are relative to the space root and collection operations use WebDAV collection semantics. Human/AI file links use `rool-machine:/rool-drive/...`; resolve those links with `resolveMachineResource()` and fetch file resources with `space.fetchMachineResource(resource)`.
|
|
891
1032
|
|
|
892
|
-
|
|
893
|
-
|--------|-------------|
|
|
894
|
-
| `uploadMedia(file): Promise<string>` | Upload file, returns URL |
|
|
895
|
-
| `fetchMedia(url, options?): Promise<MediaResponse>` | Fetch any URL, returns headers and blob() method (adds auth for backend URLs, works for external URLs too). Pass `{ forceProxy: true }` to skip the direct fetch and route through the server proxy immediately. |
|
|
896
|
-
| `deleteMedia(url): Promise<void>` | Delete media file by URL |
|
|
897
|
-
| `listMedia(): Promise<MediaInfo[]>` | List all media with metadata |
|
|
1033
|
+
Use `client.webdav(spaceId)` when you only have an ID, or `space.webdav` when you already have an open space.
|
|
898
1034
|
|
|
899
1035
|
```typescript
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
1036
|
+
import { resolveMachineResource } from '@rool-dev/sdk';
|
|
1037
|
+
|
|
1038
|
+
const webdav = client.webdav('space-id');
|
|
903
1039
|
|
|
904
|
-
|
|
905
|
-
await
|
|
906
|
-
|
|
1040
|
+
await webdav.mkcol('docs');
|
|
1041
|
+
await webdav.put('docs/readme.md', '# Hello', {
|
|
1042
|
+
contentType: 'text/markdown',
|
|
1043
|
+
ifNoneMatch: '*',
|
|
907
1044
|
});
|
|
908
1045
|
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
1046
|
+
const listing = await webdav.propfind('docs/', {
|
|
1047
|
+
depth: '1',
|
|
1048
|
+
props: ['displayname', 'getcontentlength', 'getcontenttype', 'getetag'],
|
|
1049
|
+
});
|
|
1050
|
+
|
|
1051
|
+
const file = await webdav.get('docs/readme.md');
|
|
1052
|
+
console.log(await file.text());
|
|
1053
|
+
|
|
1054
|
+
const resource = resolveMachineResource('/rool-drive/docs/read me.md');
|
|
1055
|
+
if (!resource || resource.kind !== 'file') throw new Error('not a file');
|
|
1056
|
+
const sameFile = await space.fetchMachineResource(resource);
|
|
1057
|
+
|
|
1058
|
+
const usage = await space.getStorageUsage();
|
|
1059
|
+
console.log(usage.usedBytes);
|
|
1060
|
+
console.log(usage.availableBytes); // null means unlimited
|
|
1061
|
+
console.log(usage.limitBytes); // null means unlimited
|
|
915
1062
|
```
|
|
916
1063
|
|
|
1064
|
+
Paths are space-relative (`docs/readme.md`, not `/docs/readme.md`). WebDAV methods accept WebDAV paths only. User-facing file links should use `rool-machine:/rool-drive/...`; resolve either that URI or a bare `/rool-drive/...` machine path with `resolveMachineResource()` and fetch the resulting file resource with `space.fetchMachineResource(resource)`. `PUT` writes an exact path and does not create parent collections; create parents with `mkcol()` first. Helpers preserve WebDAV status semantics: non-success responses throw `WebDAVError` with `status`, `statusText`, and `body`.
|
|
1065
|
+
|
|
1066
|
+
| Method | Description |
|
|
1067
|
+
|--------|-------------|
|
|
1068
|
+
| `client.webdav(spaceId)` | Create a WebDAV client for a space |
|
|
1069
|
+
| `client.getSpaceStorageUsage(spaceId)` | Get WebDAV quota usage for a space |
|
|
1070
|
+
| `space.webdav` | WebDAV client for an open space |
|
|
1071
|
+
| `space.getStorageUsage()` | Get WebDAV quota usage for an open space |
|
|
1072
|
+
| `webdav.getStorageUsage()` | Get WebDAV quota usage through the WebDAV client |
|
|
1073
|
+
| `webdav.path(path)` | Normalize a WebDAV path |
|
|
1074
|
+
| `webdav.propfind(path, options)` | Read properties/list collections; explicit `depth` required |
|
|
1075
|
+
| `webdav.get(path, options?)` / `webdav.head(path)` | Read a file, including optional byte ranges for `get` |
|
|
1076
|
+
| `webdav.put(path, body, options?)` | Write an exact file path; parents must already exist |
|
|
1077
|
+
| `webdav.mkcol(path)` | Create one collection |
|
|
1078
|
+
| `webdav.copy(source, destination, options?)` | Copy a file or collection within the same space |
|
|
1079
|
+
| `webdav.move(source, destination, options?)` | Move a file or collection within the same space |
|
|
1080
|
+
| `webdav.delete(path, options?)` | Delete a file or collection |
|
|
1081
|
+
| `webdav.lock(path, options)` / `webdav.refreshLock(path, token)` / `webdav.unlock(token)` | WebDAV Class 2 write locks |
|
|
1082
|
+
| `webdav.request(method, path, init?)` | Raw authenticated WebDAV request escape hatch |
|
|
1083
|
+
|
|
1084
|
+
> **Note**: `resolveMachineResource()` returns either a file resource or an object resource. File resources point at user-visible files in the space's WebDAV storage and can be fetched with `space.fetchMachineResource(resource)`. Object resources identify records inside the space. They're not interchangeable.
|
|
1085
|
+
|
|
1086
|
+
#### File references from AI responses
|
|
1087
|
+
|
|
1088
|
+
When an agent refers to a user-visible file, the SDK contract is `rool-machine:/rool-drive/path/to/file.ext`. That prefix makes a file reference unambiguous without exposing the authenticated WebDAV URL. In free text, ambiguous characters such as spaces are percent-encoded (`rool-machine:/rool-drive/docs/read%20me.md`).
|
|
1089
|
+
|
|
1090
|
+
```typescript
|
|
1091
|
+
const resource = resolveMachineResource('rool-machine:/rool-drive/docs/readme.md');
|
|
1092
|
+
if (!resource || resource.kind !== 'file') throw new Error('not a file');
|
|
1093
|
+
const response = await space.fetchMachineResource(resource);
|
|
1094
|
+
const blob = await response.blob();
|
|
1095
|
+
img.src = URL.createObjectURL(blob);
|
|
1096
|
+
```
|
|
1097
|
+
|
|
1098
|
+
Plain relative strings like `docs/readme.md` are valid WebDAV paths when you already know you are working with file storage. In user text or agent output, use `rool-machine:/rool-drive/docs/readme.md` so clients do not have to guess whether a string is a file.
|
|
1099
|
+
|
|
917
1100
|
### Proxied Fetch
|
|
918
1101
|
|
|
919
1102
|
Fetch external URLs via the server, bypassing CORS restrictions. Requires editor role or above. Private/internal IP ranges are blocked (SSRF protection).
|
|
@@ -937,7 +1120,7 @@ const response = await channel.fetch('https://api.example.com/submit', {
|
|
|
937
1120
|
|
|
938
1121
|
### Collection Schema
|
|
939
1122
|
|
|
940
|
-
Collections are the types you use to group objects in a space. Every object
|
|
1123
|
+
Collections are the types you use to group objects in a space. Every object belongs to exactly one collection: the collection is the parent directory of its location, and the server validates the object's body against that collection's definition. Renaming a collection changes the location of every object bound to it; dropping a collection is blocked while any object still lives there.
|
|
941
1124
|
|
|
942
1125
|
Collections make up the schema and are stored in the space data, syncing in real time. The schema is visible to the AI agent so it knows which collections exist and what fields they contain, producing more consistent objects.
|
|
943
1126
|
|
|
@@ -982,7 +1165,7 @@ await channel.dropCollection('article');
|
|
|
982
1165
|
| `string` | Text value | `{ kind: 'string' }` |
|
|
983
1166
|
| `number` | Numeric value | `{ kind: 'number' }` |
|
|
984
1167
|
| `boolean` | True/false | `{ kind: 'boolean' }` |
|
|
985
|
-
| `ref` | Reference to another object | `{ kind: 'ref' }` |
|
|
1168
|
+
| `ref` | Reference to another object (location string) | `{ kind: 'ref' }` |
|
|
986
1169
|
| `enum` | One of a set of values | `{ kind: 'enum', values: ['a', 'b'] }` |
|
|
987
1170
|
| `literal` | Exact value | `{ kind: 'literal', value: 'fixed' }` |
|
|
988
1171
|
| `array` | List of values | `{ kind: 'array', inner: { kind: 'string' } }` |
|
|
@@ -994,7 +1177,7 @@ Export and import space data as zip archives for backup, portability, or migrati
|
|
|
994
1177
|
|
|
995
1178
|
| Method | Description |
|
|
996
1179
|
|--------|-------------|
|
|
997
|
-
| `space.exportArchive(): Promise<Blob>` | Export objects, metadata, channels, and
|
|
1180
|
+
| `space.exportArchive(): Promise<Blob>` | Export objects, metadata, channels, and files as a zip archive |
|
|
998
1181
|
| `client.importArchive(name, archive): Promise<RoolSpace>` | Import from a zip archive, creating a new space |
|
|
999
1182
|
|
|
1000
1183
|
**Export:**
|
|
@@ -1011,7 +1194,7 @@ const space = await client.importArchive('Imported Data', archiveBlob);
|
|
|
1011
1194
|
const channel = await space.openChannel('main');
|
|
1012
1195
|
```
|
|
1013
1196
|
|
|
1014
|
-
The archive
|
|
1197
|
+
The archive bundles `data.json` (objects, metadata, and channels) together with the space file storage. File references are rewritten to relative paths within the archive and restored on import.
|
|
1015
1198
|
|
|
1016
1199
|
### Channel Events
|
|
1017
1200
|
|
|
@@ -1024,10 +1207,11 @@ Semantic events describe what changed. Events fire for both local changes and re
|
|
|
1024
1207
|
// - 'remote_agent': AI agent made the change
|
|
1025
1208
|
// - 'system': Resync after error
|
|
1026
1209
|
|
|
1027
|
-
// Object events
|
|
1028
|
-
channel.on('objectCreated', ({
|
|
1029
|
-
channel.on('objectUpdated', ({
|
|
1030
|
-
channel.on('objectDeleted', ({
|
|
1210
|
+
// Object events — payload includes the full RoolObject
|
|
1211
|
+
channel.on('objectCreated', ({ location, object, source }) => void)
|
|
1212
|
+
channel.on('objectUpdated', ({ location, object, source }) => void)
|
|
1213
|
+
channel.on('objectDeleted', ({ location, source }) => void)
|
|
1214
|
+
channel.on('objectMoved', ({ from, to, object, source }) => void)
|
|
1031
1215
|
|
|
1032
1216
|
// Space metadata
|
|
1033
1217
|
channel.on('metadataUpdated', ({ metadata, source }) => void)
|
|
@@ -1054,7 +1238,7 @@ AI operations may fail due to rate limiting or other transient errors. Check `er
|
|
|
1054
1238
|
|
|
1055
1239
|
```typescript
|
|
1056
1240
|
try {
|
|
1057
|
-
await channel.updateObject(
|
|
1241
|
+
await channel.updateObject(location, { prompt: 'expand this' });
|
|
1058
1242
|
} catch (error) {
|
|
1059
1243
|
if (error.message.includes('temporarily unavailable')) {
|
|
1060
1244
|
showToast('Service busy, please try again in a moment');
|
|
@@ -1088,11 +1272,11 @@ Channel management (listing, renaming, deleting channels) is done via the client
|
|
|
1088
1272
|
|
|
1089
1273
|
The `ai` field in interactions distinguishes AI-generated responses from synthetic confirmations:
|
|
1090
1274
|
- `ai: true` — AI processed this operation (prompt, or createObject/updateObject with placeholders)
|
|
1091
|
-
- `ai: false` — System confirmation only (e.g., "Created object
|
|
1275
|
+
- `ai: false` — System confirmation only (e.g., "Created object /space/note/welcome.json")
|
|
1092
1276
|
|
|
1093
1277
|
### Tool Calls
|
|
1094
1278
|
|
|
1095
|
-
The `toolCalls` array captures what the AI agent did during execution. The `conversationUpdated` event fires when each tool starts and completes. A tool call
|
|
1279
|
+
The `toolCalls` array captures what the AI agent did during execution. The `conversationUpdated` event fires when each tool starts and completes. A tool call with `status: 'running'` has no result; once `status: 'done'`, `result` contains the truncated result string.
|
|
1096
1280
|
|
|
1097
1281
|
## Data Types
|
|
1098
1282
|
|
|
@@ -1126,17 +1310,18 @@ type SpaceSchema = Record<string, CollectionDef>;
|
|
|
1126
1310
|
### Object Data
|
|
1127
1311
|
|
|
1128
1312
|
```typescript
|
|
1129
|
-
//
|
|
1130
|
-
//
|
|
1131
|
-
// Fields prefixed with _ are hidden from AI
|
|
1132
|
-
// References between objects are fields whose values are object IDs
|
|
1313
|
+
// An object addressed by location. References between objects are body
|
|
1314
|
+
// fields whose values are location strings.
|
|
1133
1315
|
interface RoolObject {
|
|
1134
|
-
|
|
1135
|
-
|
|
1316
|
+
location: string; // "/space/<collection>/<basename>.json"
|
|
1317
|
+
collection: string;
|
|
1318
|
+
basename: string;
|
|
1319
|
+
body: Record<string, unknown>;
|
|
1136
1320
|
}
|
|
1137
1321
|
|
|
1138
|
-
// Object stat
|
|
1322
|
+
// Object stat — audit information returned by channel.stat()
|
|
1139
1323
|
interface RoolObjectStat {
|
|
1324
|
+
location: string;
|
|
1140
1325
|
modifiedAt: number;
|
|
1141
1326
|
modifiedBy: string;
|
|
1142
1327
|
modifiedByName: string | null;
|
|
@@ -1199,28 +1384,37 @@ Note: `Channel` and `ChannelInfo` are data types describing the stored channel m
|
|
|
1199
1384
|
### Interaction Types
|
|
1200
1385
|
|
|
1201
1386
|
```typescript
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1387
|
+
type ToolCall =
|
|
1388
|
+
| {
|
|
1389
|
+
id: string;
|
|
1390
|
+
name: string; // Tool name (e.g., "create_object", "update_object", "search_web")
|
|
1391
|
+
input: unknown; // Arguments passed to the tool
|
|
1392
|
+
status: 'running';
|
|
1393
|
+
}
|
|
1394
|
+
| {
|
|
1395
|
+
id: string;
|
|
1396
|
+
name: string;
|
|
1397
|
+
input: unknown;
|
|
1398
|
+
status: 'done';
|
|
1399
|
+
result: string; // Truncated result
|
|
1400
|
+
};
|
|
1207
1401
|
|
|
1208
1402
|
type InteractionStatus = 'pending' | 'streaming' | 'done' | 'error';
|
|
1209
1403
|
|
|
1210
1404
|
interface Interaction {
|
|
1211
|
-
id: string;
|
|
1212
|
-
parentId: string | null;
|
|
1405
|
+
id: string; // Unique ID for this interaction
|
|
1406
|
+
parentId: string | null; // Parent in conversation tree (null = root)
|
|
1213
1407
|
timestamp: number;
|
|
1214
|
-
userId: string;
|
|
1215
|
-
userName?: string | null;
|
|
1216
|
-
operation: 'prompt' | 'createObject' | 'updateObject' | 'deleteObjects';
|
|
1217
|
-
input: string;
|
|
1218
|
-
output: string | null;
|
|
1219
|
-
status: InteractionStatus;
|
|
1220
|
-
ai: boolean;
|
|
1221
|
-
|
|
1222
|
-
toolCalls: ToolCall[];
|
|
1223
|
-
attachments?: string[];
|
|
1408
|
+
userId: string; // Who performed this interaction
|
|
1409
|
+
userName?: string | null; // Display name at time of interaction
|
|
1410
|
+
operation: 'prompt' | 'createObject' | 'updateObject' | 'moveObject' | 'deleteObjects';
|
|
1411
|
+
input: string; // What the user did: prompt text or action description
|
|
1412
|
+
output: string | null; // AI response or confirmation message (may be partial when streaming)
|
|
1413
|
+
status: InteractionStatus; // Lifecycle status (pending → streaming → done/error)
|
|
1414
|
+
ai: boolean; // Whether AI was invoked (vs synthetic confirmation)
|
|
1415
|
+
modifiedObjectLocations: string[]; // Locations of objects affected by this interaction
|
|
1416
|
+
toolCalls: ToolCall[]; // Tools called during this interaction (for AI prompts)
|
|
1417
|
+
attachments?: string[]; // rool-machine:/rool-drive/... file references attached by the user
|
|
1224
1418
|
}
|
|
1225
1419
|
```
|
|
1226
1420
|
|
|
@@ -1230,12 +1424,10 @@ interface Interaction {
|
|
|
1230
1424
|
type RoolUserRole = 'owner' | 'admin' | 'editor' | 'viewer';
|
|
1231
1425
|
type LinkAccess = 'none' | 'viewer' | 'editor';
|
|
1232
1426
|
|
|
1233
|
-
interface RoolSpaceInfo { id: string; name: string; role: RoolUserRole; ownerId: string; size: number; createdAt: string; updatedAt: string; linkAccess: LinkAccess; memberCount: number; }
|
|
1427
|
+
interface RoolSpaceInfo { id: string; name: string; inboundEmailAddress: string; role: RoolUserRole; ownerId: string; size: number; createdAt: string; updatedAt: string; linkAccess: LinkAccess; memberCount: number; }
|
|
1234
1428
|
interface SpaceMember { id: string; email: string; role: RoolUserRole; photoUrl: string | null; }
|
|
1235
1429
|
interface UserResult { id: string; email: string; name: string | null; photoUrl: string | null; }
|
|
1236
1430
|
interface CurrentUser { id: string; email: string; name: string | null; photoUrl: string | null; slug: string; plan: string; creditsBalance: number; totalCreditsUsed: number; createdAt: string; lastActivity: string; processedAt: string; storage: Record<string, unknown>; }
|
|
1237
|
-
interface MediaInfo { url: string; contentType: string; size: number; createdAt: string; }
|
|
1238
|
-
interface MediaResponse { contentType: string; size: number | null; blob(): Promise<Blob>; }
|
|
1239
1431
|
type ChangeSource = 'local_user' | 'remote_user' | 'remote_agent' | 'system';
|
|
1240
1432
|
```
|
|
1241
1433
|
|
|
@@ -1245,13 +1437,14 @@ type ChangeSource = 'local_user' | 'remote_user' | 'remote_agent' | 'system';
|
|
|
1245
1437
|
type PromptEffort = 'QUICK' | 'STANDARD' | 'REASONING' | 'RESEARCH';
|
|
1246
1438
|
|
|
1247
1439
|
interface PromptOptions {
|
|
1248
|
-
|
|
1440
|
+
locations?: string[]; // Scope to specific objects
|
|
1249
1441
|
responseSchema?: Record<string, unknown>;
|
|
1250
|
-
effort?: PromptEffort;
|
|
1251
|
-
ephemeral?: boolean;
|
|
1252
|
-
readOnly?: boolean;
|
|
1253
|
-
parentInteractionId?: string | null;
|
|
1254
|
-
attachments?: Array<File | Blob | { data: string; contentType: string }>;
|
|
1442
|
+
effort?: PromptEffort; // Effort level (default: 'STANDARD')
|
|
1443
|
+
ephemeral?: boolean; // Don't record in interaction history
|
|
1444
|
+
readOnly?: boolean; // Disable mutation tools (default: false)
|
|
1445
|
+
parentInteractionId?: string | null; // Branch from a specific interaction (omit to auto-continue)
|
|
1446
|
+
attachments?: Array<File | Blob | { data: string; contentType: string }>; // Files to attach
|
|
1447
|
+
signal?: AbortSignal; // Cancel an in-flight prompt
|
|
1255
1448
|
}
|
|
1256
1449
|
```
|
|
1257
1450
|
|