@rool-dev/client 0.4.6 → 0.4.7
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 +45 -4
- package/dist/client.d.ts +18 -14
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +38 -74
- package/dist/client.js.map +1 -1
- package/dist/graphql.d.ts +12 -13
- package/dist/graphql.d.ts.map +1 -1
- package/dist/graphql.js +58 -50
- package/dist/graphql.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/space.d.ts +23 -17
- package/dist/space.d.ts.map +1 -1
- package/dist/space.js +66 -33
- package/dist/space.js.map +1 -1
- package/dist/subscription.d.ts +34 -7
- package/dist/subscription.d.ts.map +1 -1
- package/dist/subscription.js +152 -18
- package/dist/subscription.js.map +1 -1
- package/dist/types.d.ts +10 -4
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/graphql.js
CHANGED
|
@@ -34,69 +34,77 @@ export class GraphQLClient {
|
|
|
34
34
|
const response = await this.request(query, { id: spaceId });
|
|
35
35
|
return JSON.parse(response.getSpace);
|
|
36
36
|
}
|
|
37
|
-
|
|
37
|
+
// ===========================================================================
|
|
38
|
+
// Space Lifecycle Operations (called from RoolClient)
|
|
39
|
+
// These use a placeholder sessionId since client events aren't filtered
|
|
40
|
+
// ===========================================================================
|
|
41
|
+
async createSpace(spaceId, name, sessionId) {
|
|
38
42
|
const mutation = `
|
|
39
|
-
mutation CreateSpace($id: String!, $name: String!, $
|
|
40
|
-
createSpace(id: $id, name: $name,
|
|
43
|
+
mutation CreateSpace($id: String!, $name: String!, $sessionId: String!) {
|
|
44
|
+
createSpace(id: $id, name: $name, sessionId: $sessionId)
|
|
41
45
|
}
|
|
42
46
|
`;
|
|
43
47
|
await this.request(mutation, {
|
|
44
48
|
id: spaceId,
|
|
45
49
|
name,
|
|
46
|
-
|
|
50
|
+
sessionId,
|
|
47
51
|
});
|
|
48
52
|
}
|
|
49
|
-
async
|
|
53
|
+
async deleteSpace(spaceId, sessionId) {
|
|
50
54
|
const mutation = `
|
|
51
|
-
mutation
|
|
52
|
-
|
|
55
|
+
mutation DeleteSpace($id: String!, $sessionId: String!) {
|
|
56
|
+
deleteSpace(id: $id, sessionId: $sessionId)
|
|
53
57
|
}
|
|
54
58
|
`;
|
|
55
59
|
await this.request(mutation, {
|
|
56
60
|
id: spaceId,
|
|
57
|
-
|
|
58
|
-
connectionId: this.config.getConnectionId(),
|
|
61
|
+
sessionId,
|
|
59
62
|
});
|
|
60
63
|
}
|
|
61
|
-
async
|
|
64
|
+
async renameSpace(spaceId, name, sessionId) {
|
|
62
65
|
const mutation = `
|
|
63
|
-
mutation
|
|
64
|
-
|
|
66
|
+
mutation RenameSpace($id: String!, $name: String!, $sessionId: String!) {
|
|
67
|
+
renameSpace(id: $id, name: $name, sessionId: $sessionId)
|
|
65
68
|
}
|
|
66
69
|
`;
|
|
67
70
|
await this.request(mutation, {
|
|
68
71
|
id: spaceId,
|
|
69
|
-
|
|
72
|
+
name,
|
|
73
|
+
sessionId,
|
|
70
74
|
});
|
|
71
75
|
}
|
|
72
|
-
|
|
76
|
+
// ===========================================================================
|
|
77
|
+
// Space Content Operations (called from RoolSpace)
|
|
78
|
+
// These require sessionId for echo suppression
|
|
79
|
+
// ===========================================================================
|
|
80
|
+
async setSpace(spaceId, space, sessionId) {
|
|
73
81
|
const mutation = `
|
|
74
|
-
mutation
|
|
75
|
-
|
|
82
|
+
mutation SetSpace($id: String!, $spaceData: String!, $sessionId: String!) {
|
|
83
|
+
setSpace(id: $id, spaceData: $spaceData, sessionId: $sessionId)
|
|
76
84
|
}
|
|
77
85
|
`;
|
|
78
86
|
await this.request(mutation, {
|
|
79
87
|
id: spaceId,
|
|
80
|
-
|
|
81
|
-
|
|
88
|
+
spaceData: JSON.stringify(space),
|
|
89
|
+
sessionId,
|
|
82
90
|
});
|
|
83
91
|
}
|
|
84
|
-
async setSpaceMeta(spaceId, meta) {
|
|
92
|
+
async setSpaceMeta(spaceId, meta, sessionId) {
|
|
85
93
|
const mutation = `
|
|
86
|
-
mutation SetSpaceMeta($id: String!, $meta: String!, $
|
|
87
|
-
setSpaceMeta(id: $id, meta: $meta,
|
|
94
|
+
mutation SetSpaceMeta($id: String!, $meta: String!, $sessionId: String!) {
|
|
95
|
+
setSpaceMeta(id: $id, meta: $meta, sessionId: $sessionId)
|
|
88
96
|
}
|
|
89
97
|
`;
|
|
90
98
|
await this.request(mutation, {
|
|
91
99
|
id: spaceId,
|
|
92
100
|
meta: JSON.stringify(meta),
|
|
93
|
-
|
|
101
|
+
sessionId,
|
|
94
102
|
});
|
|
95
103
|
}
|
|
96
|
-
async link(spaceId, source, target, type) {
|
|
104
|
+
async link(spaceId, source, target, type, sessionId) {
|
|
97
105
|
const mutation = `
|
|
98
|
-
mutation Link($spaceId: String!, $source: String!, $target: String!, $type: String!, $
|
|
99
|
-
link(spaceId: $spaceId, source: $source, target: $target, type: $type,
|
|
106
|
+
mutation Link($spaceId: String!, $source: String!, $target: String!, $type: String!, $sessionId: String!) {
|
|
107
|
+
link(spaceId: $spaceId, source: $source, target: $target, type: $type, sessionId: $sessionId)
|
|
100
108
|
}
|
|
101
109
|
`;
|
|
102
110
|
await this.request(mutation, {
|
|
@@ -104,52 +112,52 @@ export class GraphQLClient {
|
|
|
104
112
|
source,
|
|
105
113
|
target,
|
|
106
114
|
type,
|
|
107
|
-
|
|
115
|
+
sessionId,
|
|
108
116
|
});
|
|
109
117
|
}
|
|
110
|
-
async unlink(spaceId, source, target) {
|
|
118
|
+
async unlink(spaceId, source, target, sessionId) {
|
|
111
119
|
const mutation = `
|
|
112
|
-
mutation Unlink($spaceId: String!, $source: String!, $target: String!, $
|
|
113
|
-
unlink(spaceId: $spaceId, source: $source, target: $target,
|
|
120
|
+
mutation Unlink($spaceId: String!, $source: String!, $target: String!, $sessionId: String!) {
|
|
121
|
+
unlink(spaceId: $spaceId, source: $source, target: $target, sessionId: $sessionId)
|
|
114
122
|
}
|
|
115
123
|
`;
|
|
116
124
|
await this.request(mutation, {
|
|
117
125
|
spaceId,
|
|
118
126
|
source,
|
|
119
127
|
target,
|
|
120
|
-
|
|
128
|
+
sessionId,
|
|
121
129
|
});
|
|
122
130
|
}
|
|
123
|
-
async deleteObjects(spaceId, ids) {
|
|
131
|
+
async deleteObjects(spaceId, ids, sessionId) {
|
|
124
132
|
const mutation = `
|
|
125
|
-
mutation DeleteObjects($spaceId: String!, $ids: [String!]!, $
|
|
126
|
-
deleteObjects(spaceId: $spaceId, ids: $ids,
|
|
133
|
+
mutation DeleteObjects($spaceId: String!, $ids: [String!]!, $sessionId: String!) {
|
|
134
|
+
deleteObjects(spaceId: $spaceId, ids: $ids, sessionId: $sessionId)
|
|
127
135
|
}
|
|
128
136
|
`;
|
|
129
137
|
await this.request(mutation, {
|
|
130
138
|
spaceId,
|
|
131
139
|
ids,
|
|
132
|
-
|
|
140
|
+
sessionId,
|
|
133
141
|
});
|
|
134
142
|
}
|
|
135
|
-
async createObject(spaceId, data, prompt) {
|
|
143
|
+
async createObject(spaceId, data, sessionId, prompt) {
|
|
136
144
|
const mutation = `
|
|
137
|
-
mutation CreateObject($spaceId: String!, $data: String!, $prompt: String, $
|
|
138
|
-
createObject(spaceId: $spaceId, data: $data, prompt: $prompt,
|
|
145
|
+
mutation CreateObject($spaceId: String!, $data: String!, $prompt: String, $sessionId: String!) {
|
|
146
|
+
createObject(spaceId: $spaceId, data: $data, prompt: $prompt, sessionId: $sessionId)
|
|
139
147
|
}
|
|
140
148
|
`;
|
|
141
149
|
const result = await this.request(mutation, {
|
|
142
150
|
spaceId,
|
|
143
151
|
data: JSON.stringify(data),
|
|
144
152
|
prompt,
|
|
145
|
-
|
|
153
|
+
sessionId,
|
|
146
154
|
});
|
|
147
155
|
return result.createObject;
|
|
148
156
|
}
|
|
149
|
-
async updateObject(spaceId, id, data, prompt) {
|
|
157
|
+
async updateObject(spaceId, id, sessionId, data, prompt) {
|
|
150
158
|
const mutation = `
|
|
151
|
-
mutation UpdateObject($spaceId: String!, $id: String!, $data: String, $prompt: String, $
|
|
152
|
-
updateObject(spaceId: $spaceId, id: $id, data: $data, prompt: $prompt,
|
|
159
|
+
mutation UpdateObject($spaceId: String!, $id: String!, $data: String, $prompt: String, $sessionId: String!) {
|
|
160
|
+
updateObject(spaceId: $spaceId, id: $id, data: $data, prompt: $prompt, sessionId: $sessionId)
|
|
153
161
|
}
|
|
154
162
|
`;
|
|
155
163
|
const result = await this.request(mutation, {
|
|
@@ -157,14 +165,14 @@ export class GraphQLClient {
|
|
|
157
165
|
id,
|
|
158
166
|
data: data ? JSON.stringify(data) : undefined,
|
|
159
167
|
prompt,
|
|
160
|
-
|
|
168
|
+
sessionId,
|
|
161
169
|
});
|
|
162
170
|
return result.updateObject;
|
|
163
171
|
}
|
|
164
|
-
async findObjects(spaceId, options) {
|
|
172
|
+
async findObjects(spaceId, options, sessionId) {
|
|
165
173
|
const query = `
|
|
166
|
-
query FindObjects($spaceId: String!, $where: String, $prompt: String, $limit: Int, $objectIds: [String!], $
|
|
167
|
-
findObjects(spaceId: $spaceId, where: $where, prompt: $prompt, limit: $limit, objectIds: $objectIds,
|
|
174
|
+
query FindObjects($spaceId: String!, $where: String, $prompt: String, $limit: Int, $objectIds: [String!], $sessionId: String!) {
|
|
175
|
+
findObjects(spaceId: $spaceId, where: $where, prompt: $prompt, limit: $limit, objectIds: $objectIds, sessionId: $sessionId) {
|
|
168
176
|
objects
|
|
169
177
|
message
|
|
170
178
|
}
|
|
@@ -176,7 +184,7 @@ export class GraphQLClient {
|
|
|
176
184
|
prompt: options.prompt,
|
|
177
185
|
limit: options.limit,
|
|
178
186
|
objectIds: options.objectIds ?? [],
|
|
179
|
-
|
|
187
|
+
sessionId,
|
|
180
188
|
});
|
|
181
189
|
return {
|
|
182
190
|
objects: JSON.parse(result.findObjects.objects),
|
|
@@ -186,10 +194,10 @@ export class GraphQLClient {
|
|
|
186
194
|
// ===========================================================================
|
|
187
195
|
// AI Operations
|
|
188
196
|
// ===========================================================================
|
|
189
|
-
async prompt(spaceId, prompt, options = {}) {
|
|
197
|
+
async prompt(spaceId, prompt, sessionId, options = {}) {
|
|
190
198
|
const mutation = `
|
|
191
|
-
mutation Prompt($spaceId: String!, $prompt: String!, $objectIds: [String!], $responseSchema: JSON, $
|
|
192
|
-
prompt(spaceId: $spaceId, prompt: $prompt, objectIds: $objectIds, responseSchema: $responseSchema,
|
|
199
|
+
mutation Prompt($spaceId: String!, $prompt: String!, $objectIds: [String!], $responseSchema: JSON, $sessionId: String!) {
|
|
200
|
+
prompt(spaceId: $spaceId, prompt: $prompt, objectIds: $objectIds, responseSchema: $responseSchema, sessionId: $sessionId)
|
|
193
201
|
}
|
|
194
202
|
`;
|
|
195
203
|
const response = await this.request(mutation, {
|
|
@@ -197,7 +205,7 @@ export class GraphQLClient {
|
|
|
197
205
|
prompt,
|
|
198
206
|
objectIds: options.objectIds ?? [],
|
|
199
207
|
responseSchema: options.responseSchema,
|
|
200
|
-
|
|
208
|
+
sessionId,
|
|
201
209
|
});
|
|
202
210
|
return response.prompt ?? null;
|
|
203
211
|
}
|
package/dist/graphql.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graphql.js","sourceRoot":"","sources":["../src/graphql.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,iBAAiB;AACjB,6DAA6D;AAC7D,gFAAgF;AAEhF,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAalC,MAAM,qBAAqB,GAAG,IAAI,CAAC,CAAC,0BAA0B;
|
|
1
|
+
{"version":3,"file":"graphql.js","sourceRoot":"","sources":["../src/graphql.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,iBAAiB;AACjB,6DAA6D;AAC7D,gFAAgF;AAEhF,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAalC,MAAM,qBAAqB,GAAG,IAAI,CAAC,CAAC,0BAA0B;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CAAC;QACZ,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;QACnD,CAAC;QAED,OAAO,MAAM,CAAC,IAAI,CAAC;IACrB,CAAC;CACF"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { RoolClient } from './client.js';
|
|
2
2
|
export { RoolSpace, generateEntityId } from './space.js';
|
|
3
3
|
export { EventEmitter } from './event-emitter.js';
|
|
4
|
-
export type { RoolObject, RoolObjectEntry, RoolSpaceData, RoolSpaceInfo,
|
|
4
|
+
export type { RoolObject, RoolObjectEntry, RoolSpaceData, RoolSpaceInfo, JSONPatchOp, ClientEvent, ClientEventType, SpaceEvent, SpaceEventType, RoolEventSource, RoolUser, RoolUserRole, UserResult, MediaInfo, PromptOptions, FindObjectsOptions, ConnectionState, SpaceEvents, ObjectCreatedEvent, ObjectUpdatedEvent, ObjectDeletedEvent, LinkedEvent, UnlinkedEvent, MetadataUpdatedEvent, SpaceResetEvent, RoolClientConfig, RoolClientEvents, AuthTokens, AuthProvider, } from './types.js';
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGzC,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAGzD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGlD,YAAY,EAEV,UAAU,EACV,eAAe,EACf,aAAa,EACb,aAAa,EACb,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGzC,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAGzD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGlD,YAAY,EAEV,UAAU,EACV,eAAe,EACf,aAAa,EACb,aAAa,EACb,WAAW,EAGX,WAAW,EACX,eAAe,EACf,UAAU,EACV,cAAc,EACd,eAAe,EAGf,QAAQ,EACR,YAAY,EACZ,UAAU,EAGV,SAAS,EAGT,aAAa,EACb,kBAAkB,EAGlB,eAAe,EAGf,WAAW,EACX,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,WAAW,EACX,aAAa,EACb,oBAAoB,EACpB,eAAe,EAGf,gBAAgB,EAChB,gBAAgB,EAChB,UAAU,EACV,YAAY,GACb,MAAM,YAAY,CAAC"}
|
package/dist/space.d.ts
CHANGED
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
import { EventEmitter } from './event-emitter.js';
|
|
2
2
|
import type { GraphQLClient } from './graphql.js';
|
|
3
3
|
import type { MediaClient } from './media.js';
|
|
4
|
-
import type {
|
|
4
|
+
import type { AuthManager } from './auth.js';
|
|
5
|
+
import type { RoolSpaceData, RoolObject, SpaceEvents, RoolUserRole, RoolUser, PromptOptions, FindObjectsOptions, MediaInfo } from './types.js';
|
|
5
6
|
export declare function generateEntityId(): string;
|
|
6
|
-
interface SpaceConfig {
|
|
7
|
+
export interface SpaceConfig {
|
|
7
8
|
id: string;
|
|
8
9
|
name: string;
|
|
9
10
|
role: RoolUserRole;
|
|
10
11
|
initialData: RoolSpaceData;
|
|
12
|
+
/** Optional session ID for AI context continuity. If not provided, a new session is created. */
|
|
13
|
+
sessionId?: string;
|
|
11
14
|
graphqlClient: GraphQLClient;
|
|
12
15
|
mediaClient: MediaClient;
|
|
16
|
+
graphqlUrl: string;
|
|
17
|
+
authManager: AuthManager;
|
|
13
18
|
onClose: (spaceId: string) => void;
|
|
14
19
|
}
|
|
15
20
|
/**
|
|
@@ -20,22 +25,29 @@ interface SpaceConfig {
|
|
|
20
25
|
* - Built-in undo/redo with checkpoints
|
|
21
26
|
* - Metadata management
|
|
22
27
|
* - Event emission for state changes
|
|
23
|
-
* - Real-time updates
|
|
28
|
+
* - Real-time updates via space-specific subscription
|
|
24
29
|
*/
|
|
25
30
|
export declare class RoolSpace extends EventEmitter<SpaceEvents> {
|
|
26
31
|
private _id;
|
|
27
32
|
private _name;
|
|
28
33
|
private _role;
|
|
34
|
+
private _sessionId;
|
|
29
35
|
private _data;
|
|
30
36
|
private graphqlClient;
|
|
31
37
|
private mediaClient;
|
|
32
|
-
private
|
|
38
|
+
private subscriptionManager;
|
|
39
|
+
private onCloseCallback;
|
|
33
40
|
private undoStack;
|
|
34
41
|
private redoStack;
|
|
35
42
|
constructor(config: SpaceConfig);
|
|
36
43
|
get id(): string;
|
|
37
44
|
get name(): string;
|
|
38
45
|
get role(): RoolUserRole;
|
|
46
|
+
/**
|
|
47
|
+
* Get the connection ID for this space instance.
|
|
48
|
+
* Used for AI context tracking and echo suppression.
|
|
49
|
+
*/
|
|
50
|
+
get sessionId(): string;
|
|
39
51
|
get isReadOnly(): boolean;
|
|
40
52
|
/**
|
|
41
53
|
* Rename this space.
|
|
@@ -43,7 +55,7 @@ export declare class RoolSpace extends EventEmitter<SpaceEvents> {
|
|
|
43
55
|
rename(newName: string): Promise<void>;
|
|
44
56
|
/**
|
|
45
57
|
* Close this space and clean up resources.
|
|
46
|
-
*
|
|
58
|
+
* Stops real-time subscription and unregisters from client.
|
|
47
59
|
*/
|
|
48
60
|
close(): void;
|
|
49
61
|
/**
|
|
@@ -233,26 +245,20 @@ export declare class RoolSpace extends EventEmitter<SpaceEvents> {
|
|
|
233
245
|
*/
|
|
234
246
|
getData(): RoolSpaceData;
|
|
235
247
|
/**
|
|
236
|
-
* Handle a
|
|
248
|
+
* Handle a space event from the subscription.
|
|
237
249
|
* @internal
|
|
238
250
|
*/
|
|
239
|
-
|
|
251
|
+
private handleSpaceEvent;
|
|
240
252
|
/**
|
|
241
|
-
*
|
|
242
|
-
* @internal
|
|
243
|
-
*/
|
|
244
|
-
private emitSemanticEventsFromPatch;
|
|
245
|
-
/**
|
|
246
|
-
* Handle a full reload from server.
|
|
253
|
+
* Handle a patch event from another client.
|
|
247
254
|
* @internal
|
|
248
255
|
*/
|
|
249
|
-
|
|
256
|
+
private handleRemotePatch;
|
|
250
257
|
/**
|
|
251
|
-
*
|
|
258
|
+
* Parse JSON patch operations and emit semantic events.
|
|
252
259
|
* @internal
|
|
253
260
|
*/
|
|
254
|
-
|
|
261
|
+
private emitSemanticEventsFromPatch;
|
|
255
262
|
private resyncFromServer;
|
|
256
263
|
}
|
|
257
|
-
export {};
|
|
258
264
|
//# sourceMappingURL=space.d.ts.map
|
package/dist/space.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"space.d.ts","sourceRoot":"","sources":["../src/space.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,KAAK,EACV,aAAa,EACb,UAAU,
|
|
1
|
+
{"version":3,"file":"space.d.ts","sourceRoot":"","sources":["../src/space.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAE7C,OAAO,KAAK,EACV,aAAa,EACb,UAAU,EAGV,WAAW,EACX,YAAY,EACZ,QAAQ,EACR,aAAa,EACb,kBAAkB,EAClB,SAAS,EAIV,MAAM,YAAY,CAAC;AAOpB,wBAAgB,gBAAgB,IAAI,MA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QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,GACxD,OAAO,CAAC,MAAM,CAAC;IAIlB;;;OAGG;IACG,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI5C;;OAEG;IACG,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQ7C;;;OAGG;IACH,OAAO,IAAI,aAAa;IAQxB;;;OAGG;IACH,OAAO,CAAC,gBAAgB;IAkBxB;;;OAGG;IACH,OAAO,CAAC,iBAAiB;IAezB;;;OAGG;IACH,OAAO,CAAC,2BAA2B;YA+DrB,gBAAgB;CAc/B"}
|
package/dist/space.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { immutableJSONPatch } from 'immutable-json-patch';
|
|
2
2
|
import { EventEmitter } from './event-emitter.js';
|
|
3
|
+
import { SpaceSubscriptionManager } from './subscription.js';
|
|
3
4
|
const MAX_UNDO_STACK_SIZE = 50;
|
|
4
5
|
// 6-character alphanumeric ID (62^6 = 56.8 billion possible values)
|
|
5
6
|
const ID_CHARS = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
|
|
@@ -18,16 +19,18 @@ export function generateEntityId() {
|
|
|
18
19
|
* - Built-in undo/redo with checkpoints
|
|
19
20
|
* - Metadata management
|
|
20
21
|
* - Event emission for state changes
|
|
21
|
-
* - Real-time updates
|
|
22
|
+
* - Real-time updates via space-specific subscription
|
|
22
23
|
*/
|
|
23
24
|
export class RoolSpace extends EventEmitter {
|
|
24
25
|
_id;
|
|
25
26
|
_name;
|
|
26
27
|
_role;
|
|
28
|
+
_sessionId;
|
|
27
29
|
_data;
|
|
28
30
|
graphqlClient;
|
|
29
31
|
mediaClient;
|
|
30
|
-
|
|
32
|
+
subscriptionManager;
|
|
33
|
+
onCloseCallback;
|
|
31
34
|
// Undo/redo stacks
|
|
32
35
|
undoStack = [];
|
|
33
36
|
redoStack = [];
|
|
@@ -36,10 +39,27 @@ export class RoolSpace extends EventEmitter {
|
|
|
36
39
|
this._id = config.id;
|
|
37
40
|
this._name = config.name;
|
|
38
41
|
this._role = config.role;
|
|
42
|
+
this._sessionId = config.sessionId ?? generateEntityId();
|
|
39
43
|
this._data = config.initialData;
|
|
40
44
|
this.graphqlClient = config.graphqlClient;
|
|
41
45
|
this.mediaClient = config.mediaClient;
|
|
42
|
-
this.
|
|
46
|
+
this.onCloseCallback = config.onClose;
|
|
47
|
+
// Create space-level subscription
|
|
48
|
+
this.subscriptionManager = new SpaceSubscriptionManager({
|
|
49
|
+
graphqlUrl: config.graphqlUrl,
|
|
50
|
+
authManager: config.authManager,
|
|
51
|
+
spaceId: this._id,
|
|
52
|
+
sessionId: this._sessionId,
|
|
53
|
+
onEvent: (event) => this.handleSpaceEvent(event),
|
|
54
|
+
onConnectionStateChanged: () => {
|
|
55
|
+
// Space-level connection state (could emit events if needed)
|
|
56
|
+
},
|
|
57
|
+
onError: (error) => {
|
|
58
|
+
console.error(`[RoolSpace ${this._id}] Subscription error:`, error);
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
// Start subscription
|
|
62
|
+
void this.subscriptionManager.subscribe();
|
|
43
63
|
}
|
|
44
64
|
// ===========================================================================
|
|
45
65
|
// Properties
|
|
@@ -53,6 +73,13 @@ export class RoolSpace extends EventEmitter {
|
|
|
53
73
|
get role() {
|
|
54
74
|
return this._role;
|
|
55
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* Get the connection ID for this space instance.
|
|
78
|
+
* Used for AI context tracking and echo suppression.
|
|
79
|
+
*/
|
|
80
|
+
get sessionId() {
|
|
81
|
+
return this._sessionId;
|
|
82
|
+
}
|
|
56
83
|
get isReadOnly() {
|
|
57
84
|
return this._role === 'viewer';
|
|
58
85
|
}
|
|
@@ -66,7 +93,7 @@ export class RoolSpace extends EventEmitter {
|
|
|
66
93
|
const oldName = this._name;
|
|
67
94
|
this._name = newName;
|
|
68
95
|
try {
|
|
69
|
-
await this.graphqlClient.renameSpace(this._id, newName);
|
|
96
|
+
await this.graphqlClient.renameSpace(this._id, newName, this._sessionId);
|
|
70
97
|
}
|
|
71
98
|
catch (error) {
|
|
72
99
|
this._name = oldName;
|
|
@@ -75,10 +102,11 @@ export class RoolSpace extends EventEmitter {
|
|
|
75
102
|
}
|
|
76
103
|
/**
|
|
77
104
|
* Close this space and clean up resources.
|
|
78
|
-
*
|
|
105
|
+
* Stops real-time subscription and unregisters from client.
|
|
79
106
|
*/
|
|
80
107
|
close() {
|
|
81
|
-
this.
|
|
108
|
+
this.subscriptionManager.destroy();
|
|
109
|
+
this.onCloseCallback(this._id);
|
|
82
110
|
this.undoStack = [];
|
|
83
111
|
this.redoStack = [];
|
|
84
112
|
this.removeAllListeners();
|
|
@@ -135,7 +163,7 @@ export class RoolSpace extends EventEmitter {
|
|
|
135
163
|
this._data = previousEntry.data;
|
|
136
164
|
// Sync to server - resync on failure
|
|
137
165
|
try {
|
|
138
|
-
await this.graphqlClient.setSpace(this._id, this._data);
|
|
166
|
+
await this.graphqlClient.setSpace(this._id, this._data, this._sessionId);
|
|
139
167
|
this.emit('reset', { source: 'local_user' });
|
|
140
168
|
}
|
|
141
169
|
catch (error) {
|
|
@@ -163,7 +191,7 @@ export class RoolSpace extends EventEmitter {
|
|
|
163
191
|
this._data = nextEntry.data;
|
|
164
192
|
// Sync to server - resync on failure
|
|
165
193
|
try {
|
|
166
|
-
await this.graphqlClient.setSpace(this._id, this._data);
|
|
194
|
+
await this.graphqlClient.setSpace(this._id, this._data, this._sessionId);
|
|
167
195
|
this.emit('reset', { source: 'local_user' });
|
|
168
196
|
}
|
|
169
197
|
catch (error) {
|
|
@@ -253,7 +281,7 @@ export class RoolSpace extends EventEmitter {
|
|
|
253
281
|
};
|
|
254
282
|
}
|
|
255
283
|
// Otherwise, use server (with AI)
|
|
256
|
-
return this.graphqlClient.findObjects(this._id, options);
|
|
284
|
+
return this.graphqlClient.findObjects(this._id, options, this._sessionId);
|
|
257
285
|
}
|
|
258
286
|
/**
|
|
259
287
|
* Get all object IDs.
|
|
@@ -290,7 +318,7 @@ export class RoolSpace extends EventEmitter {
|
|
|
290
318
|
this.emit('objectCreated', { objectId, object: entry.data, source: 'local_user' });
|
|
291
319
|
// Await server call (may trigger AI processing that updates local state via patches)
|
|
292
320
|
try {
|
|
293
|
-
const message = await this.graphqlClient.createObject(this.id, dataWithId, prompt);
|
|
321
|
+
const message = await this.graphqlClient.createObject(this.id, dataWithId, this._sessionId, prompt);
|
|
294
322
|
// Return current state (may have been updated by AI patches)
|
|
295
323
|
return { object: this._data.objects[objectId].data, message };
|
|
296
324
|
}
|
|
@@ -327,7 +355,7 @@ export class RoolSpace extends EventEmitter {
|
|
|
327
355
|
}
|
|
328
356
|
// Await server call (may trigger AI processing that updates local state via patches)
|
|
329
357
|
try {
|
|
330
|
-
const message = await this.graphqlClient.updateObject(this.id, objectId, data, options.prompt);
|
|
358
|
+
const message = await this.graphqlClient.updateObject(this.id, objectId, this._sessionId, data, options.prompt);
|
|
331
359
|
// Return current state (may have been updated by AI patches)
|
|
332
360
|
return { object: this._data.objects[objectId].data, message };
|
|
333
361
|
}
|
|
@@ -375,7 +403,7 @@ export class RoolSpace extends EventEmitter {
|
|
|
375
403
|
}
|
|
376
404
|
// Await server call
|
|
377
405
|
try {
|
|
378
|
-
await this.graphqlClient.deleteObjects(this.id, objectIds);
|
|
406
|
+
await this.graphqlClient.deleteObjects(this.id, objectIds, this._sessionId);
|
|
379
407
|
}
|
|
380
408
|
catch (error) {
|
|
381
409
|
console.error('[Space] Failed to delete objects:', error);
|
|
@@ -404,7 +432,7 @@ export class RoolSpace extends EventEmitter {
|
|
|
404
432
|
this.emit('linked', { sourceId, targetId, linkType, linkData, source: 'local_user' });
|
|
405
433
|
// Await server call
|
|
406
434
|
try {
|
|
407
|
-
await this.graphqlClient.link(this.id, sourceId, targetId, linkType);
|
|
435
|
+
await this.graphqlClient.link(this.id, sourceId, targetId, linkType, this._sessionId);
|
|
408
436
|
}
|
|
409
437
|
catch (error) {
|
|
410
438
|
console.error('[Space] Failed to create link:', error);
|
|
@@ -446,7 +474,7 @@ export class RoolSpace extends EventEmitter {
|
|
|
446
474
|
}
|
|
447
475
|
// Await server call
|
|
448
476
|
try {
|
|
449
|
-
await this.graphqlClient.unlink(this.id, sourceId, targetId);
|
|
477
|
+
await this.graphqlClient.unlink(this.id, sourceId, targetId, this._sessionId);
|
|
450
478
|
}
|
|
451
479
|
catch (error) {
|
|
452
480
|
console.error('[Space] Failed to remove link:', error);
|
|
@@ -524,7 +552,7 @@ export class RoolSpace extends EventEmitter {
|
|
|
524
552
|
this._data.meta[key] = value;
|
|
525
553
|
this.emit('metadataUpdated', { metadata: this._data.meta, source: 'local_user' });
|
|
526
554
|
// Fire-and-forget server call - errors trigger resync
|
|
527
|
-
this.graphqlClient.setSpaceMeta(this.id, this._data.meta)
|
|
555
|
+
this.graphqlClient.setSpaceMeta(this.id, this._data.meta, this._sessionId)
|
|
528
556
|
.catch((error) => {
|
|
529
557
|
console.error('[Space] Failed to set meta:', error);
|
|
530
558
|
this.resyncFromServer(error instanceof Error ? error : new Error(String(error)));
|
|
@@ -549,7 +577,7 @@ export class RoolSpace extends EventEmitter {
|
|
|
549
577
|
* Send a prompt to the AI agent for space manipulation.
|
|
550
578
|
*/
|
|
551
579
|
async prompt(prompt, options) {
|
|
552
|
-
return this.graphqlClient.prompt(this._id, prompt, options);
|
|
580
|
+
return this.graphqlClient.prompt(this._id, prompt, this._sessionId, options);
|
|
553
581
|
}
|
|
554
582
|
// ===========================================================================
|
|
555
583
|
// Collaboration
|
|
@@ -611,13 +639,33 @@ export class RoolSpace extends EventEmitter {
|
|
|
611
639
|
return this._data;
|
|
612
640
|
}
|
|
613
641
|
// ===========================================================================
|
|
614
|
-
// Event Handlers (
|
|
642
|
+
// Event Handlers (internal - handles space subscription events)
|
|
615
643
|
// ===========================================================================
|
|
644
|
+
/**
|
|
645
|
+
* Handle a space event from the subscription.
|
|
646
|
+
* @internal
|
|
647
|
+
*/
|
|
648
|
+
handleSpaceEvent(event) {
|
|
649
|
+
switch (event.type) {
|
|
650
|
+
case 'space_patched':
|
|
651
|
+
if (event.patch) {
|
|
652
|
+
this.handleRemotePatch(event.patch, event.source);
|
|
653
|
+
}
|
|
654
|
+
break;
|
|
655
|
+
case 'space_changed':
|
|
656
|
+
// Full reload needed
|
|
657
|
+
void this.graphqlClient.getSpace(this._id).then((data) => {
|
|
658
|
+
this._data = data;
|
|
659
|
+
this.emit('reset', { source: 'remote_user' });
|
|
660
|
+
});
|
|
661
|
+
break;
|
|
662
|
+
}
|
|
663
|
+
}
|
|
616
664
|
/**
|
|
617
665
|
* Handle a patch event from another client.
|
|
618
666
|
* @internal
|
|
619
667
|
*/
|
|
620
|
-
handleRemotePatch(patch, source
|
|
668
|
+
handleRemotePatch(patch, source) {
|
|
621
669
|
try {
|
|
622
670
|
this._data = immutableJSONPatch(this._data, patch);
|
|
623
671
|
}
|
|
@@ -694,21 +742,6 @@ export class RoolSpace extends EventEmitter {
|
|
|
694
742
|
}
|
|
695
743
|
}
|
|
696
744
|
}
|
|
697
|
-
/**
|
|
698
|
-
* Handle a full reload from server.
|
|
699
|
-
* @internal
|
|
700
|
-
*/
|
|
701
|
-
handleRemoteChange(newData) {
|
|
702
|
-
this._data = newData;
|
|
703
|
-
this.emit('reset', { source: 'remote_user' });
|
|
704
|
-
}
|
|
705
|
-
/**
|
|
706
|
-
* Update the name from external source.
|
|
707
|
-
* @internal
|
|
708
|
-
*/
|
|
709
|
-
handleRemoteRename(newName) {
|
|
710
|
-
this._name = newName;
|
|
711
|
-
}
|
|
712
745
|
// ===========================================================================
|
|
713
746
|
// Private Methods
|
|
714
747
|
// ===========================================================================
|