@rool-dev/sdk 0.11.15-dev.2ccbb96 → 0.12.0-dev.2daa829
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 +23 -48
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +2 -6
- package/dist/client.js.map +1 -1
- package/dist/graphql.d.ts +6 -11
- package/dist/graphql.d.ts.map +1 -1
- package/dist/graphql.js +4 -25
- package/dist/graphql.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/space-session.d.ts +17 -252
- package/dist/space-session.d.ts.map +1 -1
- package/dist/space-session.js +53 -758
- package/dist/space-session.js.map +1 -1
- package/dist/space.d.ts +106 -88
- package/dist/space.d.ts.map +1 -1
- package/dist/space.js +524 -216
- package/dist/space.js.map +1 -1
- package/dist/types.d.ts +1 -18
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/space-session.d.ts
CHANGED
|
@@ -1,265 +1,30 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type {
|
|
3
|
-
import type { RestClient } from './rest.js';
|
|
4
|
-
import { type RoolWebDAV } from './webdav.js';
|
|
5
|
-
import type { Logger } from './logger.js';
|
|
6
|
-
import type { RoolObject, GetObjectsResult, RoolSpaceEvents, RoolUserRole, PromptOptions, UpdateObjectOptions, MoveObjectOptions, SpaceEvent, Interaction, Conversation, ConversationMeta, ConversationVisibility, SpaceSchema, CollectionDef, FieldDef, CollectionOptions } from './types.js';
|
|
1
|
+
import type { RoolSpace } from './space.js';
|
|
2
|
+
import type { Conversation, Interaction, PromptOptions, RoolObject } from './types.js';
|
|
7
3
|
export declare function generateEntityId(): string;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
userId: string;
|
|
14
|
-
/** Conversation metadata list (from openSpace). Contents are fetched on demand. */
|
|
15
|
-
conversationMeta: ConversationMeta[];
|
|
16
|
-
graphqlClient: GraphQLClient;
|
|
17
|
-
restClient: RestClient;
|
|
18
|
-
webdav: RoolWebDAV;
|
|
19
|
-
logger: Logger;
|
|
20
|
-
onClose: () => void;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* A thin handle over a space's raw APIs (GraphQL, WebDAV, REST) plus the
|
|
24
|
-
* conversation roster the server pushes over SSE. It holds no schema, metadata,
|
|
25
|
-
* or conversation *content* state — schema and meta live in the filesystem
|
|
26
|
-
* (`/space/<collection>/.schema.json`, `/space/.meta.json`) and are read on
|
|
27
|
-
* demand via {@link readSchema} / {@link readMeta}; conversation contents live
|
|
28
|
-
* on {@link ConversationHandle} objects acquired on demand via
|
|
29
|
-
* {@link conversation}. The lightweight conversation meta list (ids + names +
|
|
30
|
-
* counts) is maintained here from openSpace + SSE. Reactive consumers (e.g. the
|
|
31
|
-
* Svelte wrapper) own any cached presentation of that state; this class just
|
|
32
|
-
* wraps the wire.
|
|
33
|
-
*
|
|
34
|
-
* Objects are addressed by machine path (`/space/.../*.json`). Conversation
|
|
35
|
-
* handles carry attribution headers for WebDAV writes. Object/file reactivity
|
|
36
|
-
* is exposed via `filesChanged` / `filesReset` plus WebDAV `syncCollection()`.
|
|
37
|
-
*/
|
|
38
|
-
export declare class SpaceOperations extends EventEmitter<RoolSpaceEvents> {
|
|
39
|
-
protected _id: string;
|
|
40
|
-
protected _name: string;
|
|
41
|
-
protected _role: RoolUserRole;
|
|
42
|
-
protected _userId: string;
|
|
43
|
-
protected _closed: boolean;
|
|
44
|
-
protected _graphqlClient: GraphQLClient;
|
|
45
|
-
protected _restClient: RestClient;
|
|
46
|
-
protected _webdav: RoolWebDAV;
|
|
47
|
-
protected _onCloseCallback: () => void;
|
|
48
|
-
protected _logger: Logger;
|
|
49
|
-
protected _conversationMeta: ConversationMeta[];
|
|
50
|
-
constructor(config: SpaceOperationsConfig);
|
|
51
|
-
/**
|
|
52
|
-
* Handle an event from the shared space subscription.
|
|
53
|
-
* Called by the client's event router.
|
|
54
|
-
* @internal
|
|
55
|
-
*/
|
|
56
|
-
_handleEvent(event: SpaceEvent): void;
|
|
57
|
-
get id(): string;
|
|
58
|
-
get name(): string;
|
|
59
|
-
get role(): RoolUserRole;
|
|
60
|
-
/** Current user's ID (for identifying own interactions) */
|
|
61
|
-
get userId(): string;
|
|
62
|
-
get isReadOnly(): boolean;
|
|
63
|
-
/**
|
|
64
|
-
* Lightweight conversation roster (no interaction bodies). Maintained from
|
|
65
|
-
* openSpace + SSE; reactive consumers mirror this list.
|
|
66
|
-
*/
|
|
67
|
-
getConversations(): ConversationMeta[];
|
|
68
|
-
/**
|
|
69
|
-
* Delete a conversation. The server confirms via SSE (`conversation_updated`
|
|
70
|
-
* with a null conversation), which updates the roster and any live handle.
|
|
71
|
-
*/
|
|
72
|
-
deleteConversation(conversationId: string): Promise<void>;
|
|
73
|
-
/**
|
|
74
|
-
* Create a conversation under an agent. The server mints the id (unique
|
|
75
|
-
* across the space's agents) and creates the folder with the requested
|
|
76
|
-
* visibility; prompt the returned id to start talking.
|
|
77
|
-
*/
|
|
78
|
-
createConversation(agent: string, visibility: ConversationVisibility): Promise<string>;
|
|
79
|
-
/**
|
|
80
|
-
* The space's agents (folder names under /agents). Always includes the stock
|
|
81
|
-
* agent `rool`.
|
|
82
|
-
*/
|
|
83
|
-
listAgents(): Promise<string[]>;
|
|
84
|
-
/**
|
|
85
|
-
* Delete a custom agent and all its conversations. The stock agent `rool`
|
|
86
|
-
* cannot be deleted.
|
|
87
|
-
*/
|
|
88
|
-
deleteAgent(agent: string): Promise<void>;
|
|
89
|
-
/**
|
|
90
|
-
* Get a handle for a conversation. The handle holds its own interaction tree
|
|
91
|
-
* + cursor; call {@link ConversationHandle.load} to fetch an existing
|
|
92
|
-
* conversation's contents, or just {@link ConversationHandle.prompt} to start
|
|
93
|
-
* a new one (SSE fills the tree). Consumers feed SSE updates into the handle
|
|
94
|
-
* via {@link ConversationHandle.applyUpdate}.
|
|
95
|
-
*/
|
|
96
|
-
conversation(conversationId: string): ConversationHandle;
|
|
97
|
-
/** @internal — fetch a conversation's full contents from the server. */
|
|
98
|
-
_fetchConversationImpl(conversationId: string): Promise<Conversation | null>;
|
|
99
|
-
/**
|
|
100
|
-
* Close this space session and clean up resources.
|
|
101
|
-
*/
|
|
102
|
-
close(): void;
|
|
103
|
-
/**
|
|
104
|
-
* @deprecated Checkpoints are now managed by the server; this is a no-op.
|
|
105
|
-
*/
|
|
106
|
-
checkpoint(_label?: string): Promise<string>;
|
|
107
|
-
/** Check if undo is available for this space. */
|
|
108
|
-
canUndo(): Promise<boolean>;
|
|
109
|
-
/** Check if redo is available for this space. */
|
|
110
|
-
canRedo(): Promise<boolean>;
|
|
111
|
-
/** Restore the space to the most recent checkpoint. */
|
|
112
|
-
undo(): Promise<boolean>;
|
|
113
|
-
/** Reapply the most recently undone checkpoint. */
|
|
114
|
-
redo(): Promise<boolean>;
|
|
115
|
-
/**
|
|
116
|
-
* @deprecated Checkpoint history is now managed by the server; this is a no-op.
|
|
117
|
-
*/
|
|
118
|
-
clearHistory(): Promise<void>;
|
|
119
|
-
private davHeaders;
|
|
120
|
-
private readObject;
|
|
121
|
-
/** Get an object JSON file by machine path. Fetches from the server on each call. */
|
|
122
|
-
getObject(path: string): Promise<RoolObject | undefined>;
|
|
123
|
-
/** Get object JSON files by machine path in bulk. Duplicate paths are fetched once. */
|
|
124
|
-
getObjects(paths: string[]): Promise<GetObjectsResult>;
|
|
125
|
-
/** Create or replace an object JSON file. */
|
|
126
|
-
putObject(path: string, body: Record<string, unknown>): Promise<{
|
|
127
|
-
object: RoolObject;
|
|
128
|
-
message: string;
|
|
129
|
-
}>;
|
|
130
|
-
/** Patch an existing object JSON file. */
|
|
131
|
-
patchObject(path: string, options: UpdateObjectOptions): Promise<{
|
|
132
|
-
object: RoolObject;
|
|
133
|
-
message: string;
|
|
134
|
-
}>;
|
|
135
|
-
/** Move (rename/relocate) an object. */
|
|
136
|
-
moveObject(from: string, to: string, options?: MoveObjectOptions): Promise<{
|
|
137
|
-
object: RoolObject;
|
|
138
|
-
message: string;
|
|
139
|
-
}>;
|
|
140
|
-
/** Delete object JSON files by path. */
|
|
141
|
-
deleteObjects(paths: string[]): Promise<void>;
|
|
142
|
-
/**
|
|
143
|
-
* Read space metadata from `/space/.meta.json`. Returns `{}` when the space has
|
|
144
|
-
* no metadata file yet. Stateless — callers (e.g. a reactive wrapper) cache and
|
|
145
|
-
* re-fetch this on their own schedule, typically when a file-tree sync reports
|
|
146
|
-
* the node changed.
|
|
147
|
-
*/
|
|
148
|
-
readMeta(): Promise<Record<string, unknown>>;
|
|
149
|
-
/**
|
|
150
|
-
* Write the full metadata blob to `/space/.meta.json`, attributed to a
|
|
151
|
-
* conversation. Callers compose the blob (e.g. read-merge-write) — this does no
|
|
152
|
-
* merging.
|
|
153
|
-
*/
|
|
154
|
-
writeMeta(meta: Record<string, unknown>): Promise<void>;
|
|
155
|
-
/**
|
|
156
|
-
* Read the collection schema: one `/space/<name>/.schema.json` per collection
|
|
157
|
-
* directory under `/space`. Returns `{}` for a space with no collections.
|
|
158
|
-
* Stateless — reactive callers re-fetch when a `.schema.json` node changes.
|
|
159
|
-
*/
|
|
160
|
-
readSchema(): Promise<SpaceSchema>;
|
|
161
|
-
/** Create a new collection (MKCOL + schema JSON). */
|
|
162
|
-
createCollection(name: string, fields: FieldDef[] | CollectionDef, options?: CollectionOptions): Promise<CollectionDef>;
|
|
163
|
-
/** Alter an existing collection's schema JSON. */
|
|
164
|
-
alterCollection(name: string, fields: FieldDef[] | CollectionDef, options?: CollectionOptions): Promise<CollectionDef>;
|
|
165
|
-
/** Drop a collection (DELETE). */
|
|
166
|
-
dropCollection(name: string): Promise<void>;
|
|
167
|
-
/** @internal */
|
|
168
|
-
_setSystemInstructionImpl(instruction: string | null, conversationId: string): Promise<void>;
|
|
169
|
-
/** @internal */
|
|
170
|
-
_renameConversationImpl(name: string, conversationId: string): Promise<void>;
|
|
171
|
-
/** @internal */
|
|
172
|
-
_promptImpl(prompt: string, options: PromptOptions | undefined, conversationId: string): Promise<{
|
|
173
|
-
message: string;
|
|
174
|
-
objects: RoolObject[];
|
|
175
|
-
creditsUsed: number;
|
|
176
|
-
}>;
|
|
177
|
-
/**
|
|
178
|
-
* Request that the server stop a specific in-flight interaction by ID.
|
|
179
|
-
*
|
|
180
|
-
* @deprecated Reaches only a prompt the server is still awaiting; use
|
|
181
|
-
* {@link stopConversation}, which stops the run regardless of how or where
|
|
182
|
-
* it was started.
|
|
183
|
-
*/
|
|
184
|
-
stopInteraction(interactionId: string): Promise<boolean>;
|
|
185
|
-
/**
|
|
186
|
-
* Stop whatever is running in a conversation. A conversation processes one
|
|
187
|
-
* run at a time, so no interaction handle is needed.
|
|
188
|
-
*
|
|
189
|
-
* Returns whether anything was actually running.
|
|
190
|
-
*/
|
|
191
|
-
stopConversation(conversationId: string): Promise<boolean>;
|
|
192
|
-
/**
|
|
193
|
-
* Fetch an external URL via the server proxy, bypassing CORS restrictions.
|
|
194
|
-
*/
|
|
195
|
-
fetch(url: string, init?: {
|
|
196
|
-
method?: string;
|
|
197
|
-
headers?: Record<string, string>;
|
|
198
|
-
body?: unknown;
|
|
199
|
-
}): Promise<Response>;
|
|
200
|
-
private uploadAttachment;
|
|
201
|
-
/**
|
|
202
|
-
* Handle a space event from the subscription.
|
|
203
|
-
* @internal
|
|
204
|
-
*/
|
|
205
|
-
private applySpaceContentEvent;
|
|
206
|
-
/** Maintain the conversation meta list from an SSE update. */
|
|
207
|
-
private _updateConversationMeta;
|
|
208
|
-
}
|
|
209
|
-
/**
|
|
210
|
-
* A stateful handle for a single conversation. Holds the interaction tree and a
|
|
211
|
-
* client-side branch cursor (active leaf). Acquired on demand via
|
|
212
|
-
* {@link SpaceOperations.conversation}; a fresh handle each call — the SDK
|
|
213
|
-
* holds no handle map. The handle starts unloaded; call {@link load} to fetch
|
|
214
|
-
* an existing conversation's contents, or just {@link prompt} to start a new
|
|
215
|
-
* one. Feed SSE updates via {@link applyUpdate}.
|
|
216
|
-
*/
|
|
4
|
+
/** Find the most recently updated leaf in a conversation tree. */
|
|
5
|
+
export declare function defaultConversationLeaf(conversation: Conversation | null): string | undefined;
|
|
6
|
+
/** Return one conversation branch in root-to-leaf order. */
|
|
7
|
+
export declare function conversationBranch(conversation: Conversation | null, leafId?: string | undefined): Interaction[];
|
|
8
|
+
/** An imperative API scoped to one conversation. It retains no conversation state. */
|
|
217
9
|
export declare class ConversationHandle {
|
|
218
|
-
private
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
/** The conversation ID this handle is scoped to. */
|
|
225
|
-
get conversationId(): string;
|
|
226
|
-
/** Whether the conversation contents have been loaded. */
|
|
227
|
-
get loaded(): boolean;
|
|
228
|
-
/** Fetch the full conversation from the server. Skips the overwrite if SSE
|
|
229
|
-
* already filled the tree during the fetch (SSE is the real-time source of
|
|
230
|
-
* truth). Pass `true` to force a reload — used after a reconnect `reset`,
|
|
231
|
-
* where we may have missed SSE updates while disconnected. */
|
|
232
|
-
load(force?: boolean): Promise<void>;
|
|
233
|
-
/** Apply an SSE conversation update — updates the tree + cursor. Pass `null`
|
|
234
|
-
* for a deletion. */
|
|
235
|
-
applyUpdate(conversation: Conversation | null): void;
|
|
236
|
-
/** Get the active branch as a flat array (root → leaf). Empty until loaded. */
|
|
237
|
-
getInteractions(): Interaction[];
|
|
238
|
-
/** Get the full interaction tree as a record. Empty until loaded. */
|
|
239
|
-
getTree(): Record<string, Interaction>;
|
|
240
|
-
/** Get the active leaf interaction ID, or undefined if empty. */
|
|
241
|
-
get activeLeafId(): string | undefined;
|
|
242
|
-
/** Switch to a different branch by setting the active leaf. */
|
|
243
|
-
setActiveLeaf(interactionId: string): void;
|
|
244
|
-
/** Get the system instruction for this conversation. */
|
|
245
|
-
getSystemInstruction(): string | undefined;
|
|
246
|
-
/** Set the system instruction for this conversation. Pass null to clear. */
|
|
10
|
+
private space;
|
|
11
|
+
readonly conversationId: string;
|
|
12
|
+
constructor(space: RoolSpace, conversationId: string);
|
|
13
|
+
/** Fetch the current conversation contents. */
|
|
14
|
+
get(): Promise<Conversation | null>;
|
|
15
|
+
/** Set the conversation system instruction. Pass null to clear it. */
|
|
247
16
|
setSystemInstruction(instruction: string | null): Promise<void>;
|
|
248
|
-
/** Rename this conversation. */
|
|
249
17
|
rename(name: string): Promise<void>;
|
|
250
|
-
/** Delete this conversation. */
|
|
251
18
|
delete(): Promise<void>;
|
|
252
|
-
/**
|
|
253
|
-
*
|
|
19
|
+
/**
|
|
20
|
+
* Prompt this conversation. With no explicit parent, continue from the
|
|
21
|
+
* current default leaf without retaining a client-side cursor.
|
|
22
|
+
*/
|
|
254
23
|
prompt(text: string, options?: PromptOptions): Promise<{
|
|
255
24
|
message: string;
|
|
256
25
|
objects: RoolObject[];
|
|
257
26
|
creditsUsed: number;
|
|
258
27
|
}>;
|
|
259
|
-
/**
|
|
260
|
-
* Stop this conversation's running work, if any. No-op returning `false`
|
|
261
|
-
* when nothing is running. See {@link RoolSpace.stopConversation}.
|
|
262
|
-
*/
|
|
263
28
|
stop(): Promise<boolean>;
|
|
264
29
|
}
|
|
265
30
|
//# sourceMappingURL=space-session.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"space-session.d.ts","sourceRoot":"","sources":["../src/space-session.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"space-session.d.ts","sourceRoot":"","sources":["../src/space-session.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAIvF,wBAAgB,gBAAgB,IAAI,MAAM,CAMzC;AAED,kEAAkE;AAClE,wBAAgB,uBAAuB,CAAC,YAAY,EAAE,YAAY,GAAG,IAAI,GAAG,MAAM,GAAG,SAAS,CAc7F;AAED,4DAA4D;AAC5D,wBAAgB,kBAAkB,CAChC,YAAY,EAAE,YAAY,GAAG,IAAI,EACjC,MAAM,qBAAwC,GAC7C,WAAW,EAAE,CAYf;AAED,sFAAsF;AACtF,qBAAa,kBAAkB;IAE3B,OAAO,CAAC,KAAK;IACb,QAAQ,CAAC,cAAc,EAAE,MAAM;gBADvB,KAAK,EAAE,SAAS,EACf,cAAc,EAAE,MAAM;IAGjC,+CAA+C;IACzC,GAAG,IAAI,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC;IAIzC,sEAAsE;IAChE,oBAAoB,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAI/D,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAInC,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAI7B;;;OAGG;IACG,MAAM,CACV,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,aAAa,GACtB,OAAO,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,UAAU,EAAE,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC;IAarE,IAAI,IAAI,OAAO,CAAC,OAAO,CAAC;CAG/B"}
|