@asaidimu/utils-workspace 1.0.0
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/LICENSE.md +21 -0
- package/README.md +443 -0
- package/index.d.mts +899 -0
- package/index.d.ts +899 -0
- package/index.js +1 -0
- package/index.mjs +1 -0
- package/package.json +48 -0
package/index.d.mts
ADDED
|
@@ -0,0 +1,899 @@
|
|
|
1
|
+
type UUID = string;
|
|
2
|
+
type Timestamp = string;
|
|
3
|
+
type URI = string;
|
|
4
|
+
type SHA256 = string;
|
|
5
|
+
type Result<T, E = WorkspaceError> = {
|
|
6
|
+
ok: true;
|
|
7
|
+
value: T;
|
|
8
|
+
} | {
|
|
9
|
+
ok: false;
|
|
10
|
+
error: E;
|
|
11
|
+
};
|
|
12
|
+
declare function ok<T>(value: T): Result<T, never>;
|
|
13
|
+
declare function err<E = WorkspaceError>(error: E): Result<never, E>;
|
|
14
|
+
type WorkspaceError = {
|
|
15
|
+
code: 'DUPLICATE_KEY';
|
|
16
|
+
resource: string;
|
|
17
|
+
key: string;
|
|
18
|
+
} | {
|
|
19
|
+
code: 'NOT_FOUND';
|
|
20
|
+
resource: string;
|
|
21
|
+
id: string;
|
|
22
|
+
} | {
|
|
23
|
+
code: 'INVALID_COMMAND';
|
|
24
|
+
reason: string;
|
|
25
|
+
} | {
|
|
26
|
+
code: 'BACKEND_ERROR';
|
|
27
|
+
reason: string;
|
|
28
|
+
} | {
|
|
29
|
+
code: 'BLOB_ERROR';
|
|
30
|
+
reason: string;
|
|
31
|
+
};
|
|
32
|
+
interface Settings {
|
|
33
|
+
language: string;
|
|
34
|
+
defaultRole: string;
|
|
35
|
+
prompt?: string;
|
|
36
|
+
}
|
|
37
|
+
interface Project {
|
|
38
|
+
name: string;
|
|
39
|
+
owner: string;
|
|
40
|
+
repository?: string;
|
|
41
|
+
metadata?: Record<string, any>;
|
|
42
|
+
}
|
|
43
|
+
type ImageMediaType = 'image/jpeg' | 'image/png' | 'image/gif' | 'image/webp';
|
|
44
|
+
type DocumentMediaType = 'application/pdf' | 'application/json' | 'text/plain' | 'text/html' | 'text/markdown' | 'text/csv' | 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' | 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
|
|
45
|
+
type BlobMediaType = ImageMediaType | DocumentMediaType;
|
|
46
|
+
interface BlobRef {
|
|
47
|
+
sha256: SHA256;
|
|
48
|
+
mediaType: BlobMediaType;
|
|
49
|
+
sizeBytes: number;
|
|
50
|
+
filename?: string;
|
|
51
|
+
previewUrl?: string;
|
|
52
|
+
}
|
|
53
|
+
type ResolvedBlob = {
|
|
54
|
+
kind: 'inline';
|
|
55
|
+
sha256: SHA256;
|
|
56
|
+
mediaType: BlobMediaType;
|
|
57
|
+
data: Uint8Array;
|
|
58
|
+
} | {
|
|
59
|
+
kind: 'remote';
|
|
60
|
+
sha256: SHA256;
|
|
61
|
+
mediaType: BlobMediaType;
|
|
62
|
+
fileId: string;
|
|
63
|
+
providerId: string;
|
|
64
|
+
};
|
|
65
|
+
interface BlobRecord {
|
|
66
|
+
sha256: SHA256;
|
|
67
|
+
mediaType: BlobMediaType;
|
|
68
|
+
sizeBytes: number;
|
|
69
|
+
filename?: string;
|
|
70
|
+
refCount: number;
|
|
71
|
+
remoteIds: Record<string, string>;
|
|
72
|
+
createdAt: Timestamp;
|
|
73
|
+
lastUsedAt: Timestamp;
|
|
74
|
+
}
|
|
75
|
+
interface BlobSummary {
|
|
76
|
+
sha256: SHA256;
|
|
77
|
+
mediaType: BlobMediaType;
|
|
78
|
+
sizeBytes: number;
|
|
79
|
+
filename?: string;
|
|
80
|
+
refCount: number;
|
|
81
|
+
createdAt: Timestamp;
|
|
82
|
+
lastUsedAt: Timestamp;
|
|
83
|
+
}
|
|
84
|
+
interface TextBlock {
|
|
85
|
+
type: 'text';
|
|
86
|
+
text: string;
|
|
87
|
+
}
|
|
88
|
+
interface ImageBlock {
|
|
89
|
+
type: 'image';
|
|
90
|
+
blob: ResolvedBlob;
|
|
91
|
+
altText?: string;
|
|
92
|
+
}
|
|
93
|
+
interface DocumentBlock {
|
|
94
|
+
type: 'document';
|
|
95
|
+
blob: ResolvedBlob;
|
|
96
|
+
title?: string;
|
|
97
|
+
}
|
|
98
|
+
interface ToolUseBlock {
|
|
99
|
+
type: 'tool_use';
|
|
100
|
+
toolUseId: string;
|
|
101
|
+
name: string;
|
|
102
|
+
input: Record<string, unknown>;
|
|
103
|
+
}
|
|
104
|
+
interface ToolResultBlock {
|
|
105
|
+
type: 'tool_result';
|
|
106
|
+
toolUseId: string;
|
|
107
|
+
content: string | Record<string, unknown>;
|
|
108
|
+
isError?: boolean;
|
|
109
|
+
}
|
|
110
|
+
interface ThinkingBlock {
|
|
111
|
+
type: 'thinking';
|
|
112
|
+
thinking: string;
|
|
113
|
+
}
|
|
114
|
+
type ContentBlock = TextBlock | ImageBlock | DocumentBlock | ToolUseBlock | ToolResultBlock | ThinkingBlock;
|
|
115
|
+
type TurnRole = 'user' | 'assistant' | 'tool';
|
|
116
|
+
interface Turn {
|
|
117
|
+
id: UUID;
|
|
118
|
+
version: number;
|
|
119
|
+
role: TurnRole;
|
|
120
|
+
blocks: ContentBlock[];
|
|
121
|
+
timestamp: Timestamp;
|
|
122
|
+
roleSnapshot?: string;
|
|
123
|
+
parent: {
|
|
124
|
+
id: UUID;
|
|
125
|
+
version: number;
|
|
126
|
+
} | null;
|
|
127
|
+
}
|
|
128
|
+
interface SessionSummary {
|
|
129
|
+
id: UUID;
|
|
130
|
+
label: string;
|
|
131
|
+
role: string;
|
|
132
|
+
topics: string[];
|
|
133
|
+
created: Timestamp;
|
|
134
|
+
updated: Timestamp;
|
|
135
|
+
turns: number;
|
|
136
|
+
}
|
|
137
|
+
interface RoleSummary {
|
|
138
|
+
name: string;
|
|
139
|
+
label: string;
|
|
140
|
+
description?: string;
|
|
141
|
+
preferences: number;
|
|
142
|
+
}
|
|
143
|
+
interface PreferenceSummary {
|
|
144
|
+
id: UUID;
|
|
145
|
+
topics: string[];
|
|
146
|
+
timestamp: Timestamp;
|
|
147
|
+
snippet?: string;
|
|
148
|
+
}
|
|
149
|
+
interface ContextSummary {
|
|
150
|
+
key: string;
|
|
151
|
+
topics: string[];
|
|
152
|
+
timestamp: Timestamp;
|
|
153
|
+
mime?: string;
|
|
154
|
+
size?: number;
|
|
155
|
+
preview?: string;
|
|
156
|
+
source?: string;
|
|
157
|
+
metadata?: Record<string, any>;
|
|
158
|
+
}
|
|
159
|
+
interface TopicIndex {
|
|
160
|
+
topic: string;
|
|
161
|
+
contextKeys: string[];
|
|
162
|
+
preferences: UUID[];
|
|
163
|
+
metadata?: {
|
|
164
|
+
created?: Timestamp;
|
|
165
|
+
updated?: Timestamp;
|
|
166
|
+
entries?: number;
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
interface Indexes {
|
|
170
|
+
sessions: Record<UUID, SessionSummary>;
|
|
171
|
+
roles: Record<string, RoleSummary>;
|
|
172
|
+
preferences: Record<UUID, PreferenceSummary>;
|
|
173
|
+
context: Record<string, ContextSummary>;
|
|
174
|
+
topics: Record<string, TopicIndex>;
|
|
175
|
+
}
|
|
176
|
+
interface Workspace {
|
|
177
|
+
id: UUID;
|
|
178
|
+
settings: Settings;
|
|
179
|
+
project: Project;
|
|
180
|
+
indexes: Indexes;
|
|
181
|
+
}
|
|
182
|
+
interface IndexState {
|
|
183
|
+
format: string;
|
|
184
|
+
workspace: Workspace;
|
|
185
|
+
roles: Record<string, RoleSummary>;
|
|
186
|
+
preferences: Record<UUID, PreferenceSummary>;
|
|
187
|
+
context: Record<string, ContextSummary>;
|
|
188
|
+
sessions: Record<UUID, SessionMeta>;
|
|
189
|
+
blobs: Record<SHA256, BlobSummary>;
|
|
190
|
+
}
|
|
191
|
+
interface SessionMeta {
|
|
192
|
+
id: UUID;
|
|
193
|
+
label: string;
|
|
194
|
+
role: string;
|
|
195
|
+
topics: string[];
|
|
196
|
+
preferences: UUID[];
|
|
197
|
+
metadata: {
|
|
198
|
+
created?: Timestamp;
|
|
199
|
+
updated?: Timestamp;
|
|
200
|
+
};
|
|
201
|
+
flushedTurnCount: number;
|
|
202
|
+
head: {
|
|
203
|
+
id: UUID;
|
|
204
|
+
version: number;
|
|
205
|
+
} | null;
|
|
206
|
+
}
|
|
207
|
+
interface Role {
|
|
208
|
+
id: UUID;
|
|
209
|
+
name: string;
|
|
210
|
+
label: string;
|
|
211
|
+
persona: string;
|
|
212
|
+
description?: string;
|
|
213
|
+
preferences: UUID[];
|
|
214
|
+
}
|
|
215
|
+
interface Preference {
|
|
216
|
+
id: UUID;
|
|
217
|
+
content: string;
|
|
218
|
+
topics: string[];
|
|
219
|
+
timestamp: Timestamp;
|
|
220
|
+
}
|
|
221
|
+
interface Context {
|
|
222
|
+
key: string;
|
|
223
|
+
content: string | object | URI;
|
|
224
|
+
topics: string[];
|
|
225
|
+
timestamp: Timestamp;
|
|
226
|
+
metadata?: Record<string, any>;
|
|
227
|
+
attachments?: BlobRef[];
|
|
228
|
+
}
|
|
229
|
+
interface Session {
|
|
230
|
+
id: UUID;
|
|
231
|
+
label: string;
|
|
232
|
+
role: string;
|
|
233
|
+
topics: string[];
|
|
234
|
+
preferences: UUID[];
|
|
235
|
+
turns: Turn[];
|
|
236
|
+
metadata: {
|
|
237
|
+
created?: Timestamp;
|
|
238
|
+
updated?: Timestamp;
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
interface WorkspaceBundle {
|
|
242
|
+
format: 'aiworkspace/4.0';
|
|
243
|
+
workspace: Workspace;
|
|
244
|
+
roles: Record<string, Role>;
|
|
245
|
+
preferences: Record<UUID, Preference>;
|
|
246
|
+
context: Record<string, Context>;
|
|
247
|
+
sessions: Record<UUID, Session>;
|
|
248
|
+
blobs: Record<SHA256, BlobRecord>;
|
|
249
|
+
}
|
|
250
|
+
interface TranscriptWindow {
|
|
251
|
+
sessionId: UUID;
|
|
252
|
+
turns: Turn[];
|
|
253
|
+
flushedCount: number;
|
|
254
|
+
hasMore: boolean;
|
|
255
|
+
}
|
|
256
|
+
interface EffectiveSession {
|
|
257
|
+
session: SessionMeta;
|
|
258
|
+
role: Role;
|
|
259
|
+
preferences: Preference[];
|
|
260
|
+
context: Context[];
|
|
261
|
+
transcript: Turn[];
|
|
262
|
+
systemPrompt?: string;
|
|
263
|
+
}
|
|
264
|
+
interface CacheConfig {
|
|
265
|
+
roles?: number;
|
|
266
|
+
preferences?: number;
|
|
267
|
+
contextEntries?: number;
|
|
268
|
+
transcriptWindows?: number;
|
|
269
|
+
}
|
|
270
|
+
interface FlushConfig {
|
|
271
|
+
maxBufferSize: number;
|
|
272
|
+
flushIntervalMs: number;
|
|
273
|
+
}
|
|
274
|
+
interface ContentStoreConfig {
|
|
275
|
+
cache?: CacheConfig;
|
|
276
|
+
flush?: FlushConfig;
|
|
277
|
+
transcriptWindowSize?: number;
|
|
278
|
+
}
|
|
279
|
+
interface BaseCommand {
|
|
280
|
+
type: string;
|
|
281
|
+
timestamp: Timestamp;
|
|
282
|
+
actor?: string;
|
|
283
|
+
}
|
|
284
|
+
interface CreateWorkspace extends BaseCommand {
|
|
285
|
+
type: 'workspace:create';
|
|
286
|
+
payload: {
|
|
287
|
+
id: UUID;
|
|
288
|
+
settings: Settings;
|
|
289
|
+
project: Project;
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
interface AddRole extends BaseCommand {
|
|
293
|
+
type: 'role:add';
|
|
294
|
+
payload: Role;
|
|
295
|
+
}
|
|
296
|
+
interface UpdateRole extends BaseCommand {
|
|
297
|
+
type: 'role:update';
|
|
298
|
+
payload: Partial<Role> & {
|
|
299
|
+
name: string;
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
interface DeleteRole extends BaseCommand {
|
|
303
|
+
type: 'role:delete';
|
|
304
|
+
payload: {
|
|
305
|
+
name: string;
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
interface AddPreference extends BaseCommand {
|
|
309
|
+
type: 'preference:add';
|
|
310
|
+
payload: Preference;
|
|
311
|
+
}
|
|
312
|
+
interface UpdatePreference extends BaseCommand {
|
|
313
|
+
type: 'preference:update';
|
|
314
|
+
payload: Partial<Preference> & {
|
|
315
|
+
id: UUID;
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
interface DeletePreference extends BaseCommand {
|
|
319
|
+
type: 'preference:delete';
|
|
320
|
+
payload: {
|
|
321
|
+
id: UUID;
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
interface CreateSession extends BaseCommand {
|
|
325
|
+
type: 'session:create';
|
|
326
|
+
payload: {
|
|
327
|
+
id: UUID;
|
|
328
|
+
label: string;
|
|
329
|
+
role: string;
|
|
330
|
+
topics: string[];
|
|
331
|
+
preferences?: UUID[];
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
interface AddContext extends BaseCommand {
|
|
335
|
+
type: 'context:add';
|
|
336
|
+
payload: Context;
|
|
337
|
+
}
|
|
338
|
+
interface UpdateContext extends BaseCommand {
|
|
339
|
+
type: 'context:update';
|
|
340
|
+
payload: Partial<Context> & {
|
|
341
|
+
key: string;
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
interface DeleteContext extends BaseCommand {
|
|
345
|
+
type: 'context:delete';
|
|
346
|
+
payload: {
|
|
347
|
+
key: string;
|
|
348
|
+
};
|
|
349
|
+
}
|
|
350
|
+
interface AddTurn extends BaseCommand {
|
|
351
|
+
type: 'turn:add';
|
|
352
|
+
payload: {
|
|
353
|
+
sessionId: UUID;
|
|
354
|
+
turn: Turn;
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
interface EditTurn extends BaseCommand {
|
|
358
|
+
type: 'turn:edit';
|
|
359
|
+
payload: {
|
|
360
|
+
sessionId: UUID;
|
|
361
|
+
turnId: UUID;
|
|
362
|
+
newBlocks: ContentBlock[];
|
|
363
|
+
newVersion: number;
|
|
364
|
+
roleSnapshot?: string;
|
|
365
|
+
};
|
|
366
|
+
}
|
|
367
|
+
interface BranchTurn extends BaseCommand {
|
|
368
|
+
type: 'turn:branch';
|
|
369
|
+
payload: {
|
|
370
|
+
sessionId: UUID;
|
|
371
|
+
parentTurnId: UUID;
|
|
372
|
+
parentVersion: number;
|
|
373
|
+
newTurn: Turn;
|
|
374
|
+
};
|
|
375
|
+
}
|
|
376
|
+
interface DeleteTurn extends BaseCommand {
|
|
377
|
+
type: 'turn:delete';
|
|
378
|
+
payload: {
|
|
379
|
+
sessionId: UUID;
|
|
380
|
+
turnId: UUID;
|
|
381
|
+
version: number;
|
|
382
|
+
newHead: {
|
|
383
|
+
id: UUID;
|
|
384
|
+
version: number;
|
|
385
|
+
} | null;
|
|
386
|
+
};
|
|
387
|
+
}
|
|
388
|
+
interface AddInteraction extends BaseCommand {
|
|
389
|
+
type: 'turn:add';
|
|
390
|
+
payload: {
|
|
391
|
+
sessionId: UUID;
|
|
392
|
+
turn: Turn;
|
|
393
|
+
};
|
|
394
|
+
}
|
|
395
|
+
interface SwitchRole extends BaseCommand {
|
|
396
|
+
type: 'session:role:switch';
|
|
397
|
+
payload: {
|
|
398
|
+
sessionId: UUID;
|
|
399
|
+
role: string;
|
|
400
|
+
};
|
|
401
|
+
}
|
|
402
|
+
interface AddSessionTopics extends BaseCommand {
|
|
403
|
+
type: 'session:topics:add';
|
|
404
|
+
payload: {
|
|
405
|
+
sessionId: UUID;
|
|
406
|
+
topics: string[];
|
|
407
|
+
};
|
|
408
|
+
}
|
|
409
|
+
interface OverrideSessionPreferences extends BaseCommand {
|
|
410
|
+
type: 'session:preferences:override';
|
|
411
|
+
payload: {
|
|
412
|
+
sessionId: UUID;
|
|
413
|
+
preferences: UUID[];
|
|
414
|
+
};
|
|
415
|
+
}
|
|
416
|
+
interface ForkSession extends BaseCommand {
|
|
417
|
+
type: 'session:fork';
|
|
418
|
+
payload: {
|
|
419
|
+
sourceSessionId: UUID;
|
|
420
|
+
newSessionId: UUID;
|
|
421
|
+
label: string;
|
|
422
|
+
role?: string;
|
|
423
|
+
topics?: string[];
|
|
424
|
+
};
|
|
425
|
+
}
|
|
426
|
+
interface DeleteSession extends BaseCommand {
|
|
427
|
+
type: 'session:delete';
|
|
428
|
+
payload: {
|
|
429
|
+
sessionId: UUID;
|
|
430
|
+
};
|
|
431
|
+
}
|
|
432
|
+
interface RegisterBlob extends BaseCommand {
|
|
433
|
+
type: 'blob:register';
|
|
434
|
+
payload: BlobRecord;
|
|
435
|
+
}
|
|
436
|
+
interface RecordBlobRemoteId extends BaseCommand {
|
|
437
|
+
type: 'blob:remote_id';
|
|
438
|
+
payload: {
|
|
439
|
+
sha256: SHA256;
|
|
440
|
+
providerId: string;
|
|
441
|
+
fileId: string;
|
|
442
|
+
};
|
|
443
|
+
}
|
|
444
|
+
interface ReleaseBlob extends BaseCommand {
|
|
445
|
+
type: 'blob:release';
|
|
446
|
+
payload: {
|
|
447
|
+
sha256: SHA256;
|
|
448
|
+
};
|
|
449
|
+
}
|
|
450
|
+
type Command = CreateWorkspace | AddRole | UpdateRole | DeleteRole | AddPreference | UpdatePreference | DeletePreference | CreateSession | AddContext | UpdateContext | DeleteContext | AddTurn | EditTurn | BranchTurn | DeleteTurn | SwitchRole | AddSessionTopics | OverrideSessionPreferences | ForkSession | DeleteSession | RegisterBlob | RecordBlobRemoteId | ReleaseBlob;
|
|
451
|
+
interface TokenBudget {
|
|
452
|
+
total: number;
|
|
453
|
+
estimator?: (text: string) => number;
|
|
454
|
+
blobTokensPerKB?: number;
|
|
455
|
+
}
|
|
456
|
+
interface PreferenceConflict {
|
|
457
|
+
topic: string;
|
|
458
|
+
kept: UUID;
|
|
459
|
+
dropped: UUID;
|
|
460
|
+
reason: 'superseded_by_newer';
|
|
461
|
+
}
|
|
462
|
+
interface ContextRelevanceConfig {
|
|
463
|
+
recentMessageWindow?: number;
|
|
464
|
+
minScore?: number;
|
|
465
|
+
freshnessHalfLifeDays?: number;
|
|
466
|
+
}
|
|
467
|
+
interface BuiltTurn {
|
|
468
|
+
role: TurnRole;
|
|
469
|
+
blocks: ContentBlock[];
|
|
470
|
+
}
|
|
471
|
+
interface Prompt {
|
|
472
|
+
system: string | null;
|
|
473
|
+
turns: BuiltTurn[];
|
|
474
|
+
blobs: BlobRef[];
|
|
475
|
+
truncated: {
|
|
476
|
+
preferences: number;
|
|
477
|
+
interactions: number;
|
|
478
|
+
contextEntries: number;
|
|
479
|
+
};
|
|
480
|
+
conflicts: PreferenceConflict[];
|
|
481
|
+
warnings: string[];
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
interface ContentStorage {
|
|
485
|
+
saveRole(role: Role): Promise<void>;
|
|
486
|
+
loadRole(name: string): Promise<Role | null>;
|
|
487
|
+
deleteRole(name: string): Promise<void>;
|
|
488
|
+
savePreference(preference: Preference): Promise<void>;
|
|
489
|
+
loadPreference(id: UUID): Promise<Preference | null>;
|
|
490
|
+
deletePreference(id: UUID): Promise<void>;
|
|
491
|
+
saveContext(context: Context): Promise<void>;
|
|
492
|
+
loadContext(key: string): Promise<Context | null>;
|
|
493
|
+
deleteContext(key: string): Promise<void>;
|
|
494
|
+
saveTurn(sessionId: UUID, turn: Turn): Promise<void>;
|
|
495
|
+
loadTurn(sessionId: UUID, turnId: UUID, version: number): Promise<Turn | null>;
|
|
496
|
+
loadAllTurns(sessionId: UUID, limit?: number): Promise<Turn[]>;
|
|
497
|
+
setSessionHead(sessionId: UUID, head: {
|
|
498
|
+
id: UUID;
|
|
499
|
+
version: number;
|
|
500
|
+
} | null): Promise<void>;
|
|
501
|
+
getSessionHead(sessionId: UUID): Promise<{
|
|
502
|
+
id: UUID;
|
|
503
|
+
version: number;
|
|
504
|
+
} | null>;
|
|
505
|
+
deleteTurnSubtree(sessionId: UUID, turnId: UUID, version: number): Promise<void>;
|
|
506
|
+
getActiveChain(sessionId: UUID): Promise<Turn[]>;
|
|
507
|
+
countChainedTurns(sessionId: UUID): Promise<number>;
|
|
508
|
+
copyTranscript(sourceSessionId: UUID, targetSessionId: UUID): Promise<void>;
|
|
509
|
+
}
|
|
510
|
+
declare class MemoryStorage implements ContentStorage {
|
|
511
|
+
private readonly roles;
|
|
512
|
+
private readonly preferences;
|
|
513
|
+
private readonly contexts;
|
|
514
|
+
private readonly turnVersions;
|
|
515
|
+
private readonly sessionHeads;
|
|
516
|
+
saveRole(role: Role): Promise<void>;
|
|
517
|
+
loadRole(name: string): Promise<Role | null>;
|
|
518
|
+
deleteRole(name: string): Promise<void>;
|
|
519
|
+
savePreference(preference: Preference): Promise<void>;
|
|
520
|
+
loadPreference(id: UUID): Promise<Preference | null>;
|
|
521
|
+
deletePreference(id: UUID): Promise<void>;
|
|
522
|
+
saveContext(context: Context): Promise<void>;
|
|
523
|
+
loadContext(key: string): Promise<Context | null>;
|
|
524
|
+
deleteContext(key: string): Promise<void>;
|
|
525
|
+
saveTurn(sessionId: UUID, turn: Turn): Promise<void>;
|
|
526
|
+
loadTurn(sessionId: UUID, turnId: UUID, version: number): Promise<Turn | null>;
|
|
527
|
+
loadAllTurns(sessionId: UUID, limit?: number): Promise<Turn[]>;
|
|
528
|
+
setSessionHead(sessionId: UUID, head: {
|
|
529
|
+
id: UUID;
|
|
530
|
+
version: number;
|
|
531
|
+
} | null): Promise<void>;
|
|
532
|
+
getSessionHead(sessionId: UUID): Promise<{
|
|
533
|
+
id: UUID;
|
|
534
|
+
version: number;
|
|
535
|
+
} | null>;
|
|
536
|
+
getActiveChain(sessionId: UUID): Promise<Turn[]>;
|
|
537
|
+
deleteTurnSubtree(sessionId: UUID, turnId: UUID, version: number): Promise<void>;
|
|
538
|
+
countChainedTurns(sessionId: UUID): Promise<number>;
|
|
539
|
+
copyTranscript(sourceSessionId: UUID, targetSessionId: UUID): Promise<void>;
|
|
540
|
+
static fromBundle(bundle: WorkspaceBundle): {
|
|
541
|
+
backend: MemoryStorage;
|
|
542
|
+
indexState: IndexState;
|
|
543
|
+
};
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
/**
|
|
547
|
+
* Utility type for representing partial updates to the state, allowing deep nesting.
|
|
548
|
+
* It makes all properties optional and applies the same transformation recursively
|
|
549
|
+
* to nested objects and array elements, allowing for selective updates while
|
|
550
|
+
* preserving the original structure. It also includes the original type T and
|
|
551
|
+
* undefined as possibilities for the top level and nested values.
|
|
552
|
+
*/
|
|
553
|
+
type DeepPartial<T> = T extends object ? T extends readonly (infer U)[] ? readonly (DeepPartial<U> | undefined)[] | undefined | T : T extends (infer U)[] ? (DeepPartial<U> | undefined)[] | undefined | T : {
|
|
554
|
+
[K in keyof T]?: T[K] extends object ? DeepPartial<T[K]> | undefined : T[K] | undefined;
|
|
555
|
+
} | undefined | T : T | undefined;
|
|
556
|
+
|
|
557
|
+
declare function del<T>(): T;
|
|
558
|
+
declare const merge: <T extends object>(original: T, changes: DeepPartial<T> | symbol) => T;
|
|
559
|
+
|
|
560
|
+
interface IndexedDBConfig {
|
|
561
|
+
dbName?: string;
|
|
562
|
+
}
|
|
563
|
+
declare class IndexedDBStorage implements ContentStorage {
|
|
564
|
+
private readonly dbName;
|
|
565
|
+
private db;
|
|
566
|
+
constructor(config?: IndexedDBConfig);
|
|
567
|
+
open(): Promise<void>;
|
|
568
|
+
private createSchema;
|
|
569
|
+
close(): void;
|
|
570
|
+
deleteDatabase(): Promise<void>;
|
|
571
|
+
private getDB;
|
|
572
|
+
private readTx;
|
|
573
|
+
private writeTx;
|
|
574
|
+
saveRole(role: Role): Promise<void>;
|
|
575
|
+
loadRole(name: string): Promise<Role | null>;
|
|
576
|
+
deleteRole(name: string): Promise<void>;
|
|
577
|
+
savePreference(preference: Preference): Promise<void>;
|
|
578
|
+
loadPreference(id: UUID): Promise<Preference | null>;
|
|
579
|
+
deletePreference(id: UUID): Promise<void>;
|
|
580
|
+
saveContext(context: Context): Promise<void>;
|
|
581
|
+
loadContext(key: string): Promise<Context | null>;
|
|
582
|
+
deleteContext(key: string): Promise<void>;
|
|
583
|
+
saveTurn(sessionId: UUID, turn: Turn): Promise<void>;
|
|
584
|
+
loadAllTurns(sessionId: UUID, limit?: number): Promise<Turn[]>;
|
|
585
|
+
countChainedTurns(sessionId: UUID): Promise<number>;
|
|
586
|
+
loadTurn(sessionId: UUID, turnId: UUID, version: number): Promise<Turn | null>;
|
|
587
|
+
setSessionHead(sessionId: UUID, head: {
|
|
588
|
+
id: UUID;
|
|
589
|
+
version: number;
|
|
590
|
+
} | null): Promise<void>;
|
|
591
|
+
getSessionHead(sessionId: UUID): Promise<{
|
|
592
|
+
id: UUID;
|
|
593
|
+
version: number;
|
|
594
|
+
} | null>;
|
|
595
|
+
getActiveChain(sessionId: UUID): Promise<Turn[]>;
|
|
596
|
+
deleteTurnSubtree(sessionId: UUID, turnId: UUID, version: number): Promise<void>;
|
|
597
|
+
copyTranscript(sourceSessionId: UUID, targetSessionId: UUID): Promise<void>;
|
|
598
|
+
saveIndexState(state: IndexState): Promise<void>;
|
|
599
|
+
loadIndexState(): Promise<IndexState | null>;
|
|
600
|
+
exportBundle(): Promise<{
|
|
601
|
+
roles: Record<string, Role>;
|
|
602
|
+
preferences: Record<UUID, Preference>;
|
|
603
|
+
context: Record<string, Context>;
|
|
604
|
+
transcripts: Record<UUID, Turn[]>;
|
|
605
|
+
indexState: IndexState | null;
|
|
606
|
+
}>;
|
|
607
|
+
importBundle(data: {
|
|
608
|
+
roles: Record<string, Role>;
|
|
609
|
+
preferences: Record<UUID, Preference>;
|
|
610
|
+
context: Record<string, Context>;
|
|
611
|
+
transcripts: Record<UUID, Turn[]>;
|
|
612
|
+
indexState?: IndexState;
|
|
613
|
+
}): Promise<void>;
|
|
614
|
+
private getAllFromStore;
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
/**
|
|
618
|
+
* Persistence contract for binary blob content and blob registry records.
|
|
619
|
+
*
|
|
620
|
+
* Two concerns live here together deliberately:
|
|
621
|
+
* 1. Raw bytes — stored and retrieved by SHA-256.
|
|
622
|
+
* 2. BlobRecord — the registry entry that tracks ref counts and remote IDs.
|
|
623
|
+
*
|
|
624
|
+
* Keeping them in the same backend ensures atomicity: registering a blob and
|
|
625
|
+
* storing its bytes happen in the same transaction boundary.
|
|
626
|
+
*/
|
|
627
|
+
interface BlobStorage {
|
|
628
|
+
/**
|
|
629
|
+
* Store raw bytes for a blob. Idempotent — if the SHA-256 already exists
|
|
630
|
+
* the bytes are not re-written (content-addressed, so they are identical).
|
|
631
|
+
*/
|
|
632
|
+
storeBytes(sha256: SHA256, data: Uint8Array): Promise<void>;
|
|
633
|
+
/** Load raw bytes. Returns null if the blob is not stored locally. */
|
|
634
|
+
loadBytes(sha256: SHA256): Promise<Uint8Array | null>;
|
|
635
|
+
/** Returns true if bytes are stored locally for this SHA-256. */
|
|
636
|
+
hasBytes(sha256: SHA256): Promise<boolean>;
|
|
637
|
+
/**
|
|
638
|
+
* Delete raw bytes. Called by BlobStore when refCount reaches 0 and
|
|
639
|
+
* the blob has been evicted from the local store.
|
|
640
|
+
*/
|
|
641
|
+
deleteBytes(sha256: SHA256): Promise<void>;
|
|
642
|
+
/** Persist a BlobRecord (registry metadata, not bytes). */
|
|
643
|
+
saveRecord(record: BlobRecord): Promise<void>;
|
|
644
|
+
/** Load a BlobRecord by SHA-256. Returns null if not found. */
|
|
645
|
+
loadRecord(sha256: SHA256): Promise<BlobRecord | null>;
|
|
646
|
+
/** Delete a BlobRecord. Called when a blob is fully evicted. */
|
|
647
|
+
deleteRecord(sha256: SHA256): Promise<void>;
|
|
648
|
+
/** Return all stored BlobRecords. Used for bundle export and GC sweeps. */
|
|
649
|
+
listRecords(): Promise<BlobRecord[]>;
|
|
650
|
+
/**
|
|
651
|
+
* Export all bytes as an iterable of [sha256, Uint8Array] pairs.
|
|
652
|
+
* Used for workspace export / migration.
|
|
653
|
+
*/
|
|
654
|
+
exportAllBytes(): Promise<Array<[SHA256, Uint8Array]>>;
|
|
655
|
+
}
|
|
656
|
+
/**
|
|
657
|
+
* In-process implementation backed by plain Maps.
|
|
658
|
+
* Suitable for development, testing, and server-side runtimes without
|
|
659
|
+
* access to IndexedDB.
|
|
660
|
+
*/
|
|
661
|
+
declare class MemoryBlobStorage implements BlobStorage {
|
|
662
|
+
private readonly bytes;
|
|
663
|
+
private readonly records;
|
|
664
|
+
storeBytes(sha256: SHA256, data: Uint8Array): Promise<void>;
|
|
665
|
+
loadBytes(sha256: SHA256): Promise<Uint8Array | null>;
|
|
666
|
+
hasBytes(sha256: SHA256): Promise<boolean>;
|
|
667
|
+
deleteBytes(sha256: SHA256): Promise<void>;
|
|
668
|
+
saveRecord(record: BlobRecord): Promise<void>;
|
|
669
|
+
loadRecord(sha256: SHA256): Promise<BlobRecord | null>;
|
|
670
|
+
deleteRecord(sha256: SHA256): Promise<void>;
|
|
671
|
+
listRecords(): Promise<BlobRecord[]>;
|
|
672
|
+
exportAllBytes(): Promise<Array<[SHA256, Uint8Array]>>;
|
|
673
|
+
}
|
|
674
|
+
interface IndexedDBBlobConfig {
|
|
675
|
+
/** Name of the IndexedDB database. Defaults to 'aiworkspace-blobs'. */
|
|
676
|
+
dbName?: string;
|
|
677
|
+
}
|
|
678
|
+
/**
|
|
679
|
+
* IndexedDB-backed blob storage.
|
|
680
|
+
*
|
|
681
|
+
* Bytes are stored as raw Uint8Array — IndexedDB handles binary natively,
|
|
682
|
+
* no base64 encoding at rest. This is important for large files.
|
|
683
|
+
*
|
|
684
|
+
* Transaction discipline matches IndexedDBBlobStorage: never await inside an
|
|
685
|
+
* active transaction. All multi-step operations chain synchronous IDB
|
|
686
|
+
* request handlers inside a single Promise.
|
|
687
|
+
*/
|
|
688
|
+
declare class IndexedDBBlobStorage implements BlobStorage {
|
|
689
|
+
private readonly dbName;
|
|
690
|
+
private db;
|
|
691
|
+
constructor(config?: IndexedDBBlobConfig);
|
|
692
|
+
open(): Promise<void>;
|
|
693
|
+
private createSchema;
|
|
694
|
+
close(): void;
|
|
695
|
+
deleteDatabase(): Promise<void>;
|
|
696
|
+
private getDB;
|
|
697
|
+
private readTx;
|
|
698
|
+
private writeTx;
|
|
699
|
+
storeBytes(sha256: SHA256, data: Uint8Array): Promise<void>;
|
|
700
|
+
loadBytes(sha256: SHA256): Promise<Uint8Array | null>;
|
|
701
|
+
hasBytes(sha256: SHA256): Promise<boolean>;
|
|
702
|
+
deleteBytes(sha256: SHA256): Promise<void>;
|
|
703
|
+
saveRecord(record: BlobRecord): Promise<void>;
|
|
704
|
+
loadRecord(sha256: SHA256): Promise<BlobRecord | null>;
|
|
705
|
+
deleteRecord(sha256: SHA256): Promise<void>;
|
|
706
|
+
listRecords(): Promise<BlobRecord[]>;
|
|
707
|
+
exportAllBytes(): Promise<Array<[SHA256, Uint8Array]>>;
|
|
708
|
+
/**
|
|
709
|
+
* Atomically stores bytes and saves a record together.
|
|
710
|
+
* Preferred over calling storeBytes + saveRecord separately when both
|
|
711
|
+
* are new — avoids a window where bytes exist without a record.
|
|
712
|
+
*/
|
|
713
|
+
registerBlob(record: BlobRecord, data: Uint8Array): Promise<void>;
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
declare function computeSHA256(data: Uint8Array): Promise<SHA256>;
|
|
717
|
+
interface BlobStoreConfig {
|
|
718
|
+
/**
|
|
719
|
+
* When true, blobs with refCount === 0 are deleted from the backend
|
|
720
|
+
* immediately on release. When false (default), they are retained until
|
|
721
|
+
* an explicit GC sweep via gc(). Lazy GC is safer for offline-first apps
|
|
722
|
+
* that may need blobs for re-upload after a crash.
|
|
723
|
+
*/
|
|
724
|
+
eagerEviction?: boolean;
|
|
725
|
+
}
|
|
726
|
+
declare class BlobStore {
|
|
727
|
+
private readonly backend;
|
|
728
|
+
private readonly config;
|
|
729
|
+
/**
|
|
730
|
+
* In-memory cache of BlobRecords. Kept consistent with the backend on
|
|
731
|
+
* every write. Records are small (no bytes), so we cache all of them.
|
|
732
|
+
*/
|
|
733
|
+
private readonly recordCache;
|
|
734
|
+
/**
|
|
735
|
+
* Called after any operation that changes the blob registry.
|
|
736
|
+
* The integration layer wires this to an IndexState patch that updates
|
|
737
|
+
* IndexState.blobs with the new BlobSummary.
|
|
738
|
+
*/
|
|
739
|
+
onRegistryChanged?: (sha256: SHA256, summary: BlobSummary | null) => void;
|
|
740
|
+
constructor(backend: BlobStorage, config?: BlobStoreConfig);
|
|
741
|
+
init(): Promise<void>;
|
|
742
|
+
/**
|
|
743
|
+
* Register a binary blob and return a BlobRef.
|
|
744
|
+
*
|
|
745
|
+
* If the same bytes have been registered before (same SHA-256), only the
|
|
746
|
+
* ref count is incremented — bytes are not written again.
|
|
747
|
+
*
|
|
748
|
+
* @param data Raw binary content.
|
|
749
|
+
* @param mediaType MIME type of the content.
|
|
750
|
+
* @param filename Optional original filename for UI display.
|
|
751
|
+
*/
|
|
752
|
+
register(data: Uint8Array, mediaType: BlobMediaType, filename?: string): Promise<Result<BlobRef, WorkspaceError>>;
|
|
753
|
+
/**
|
|
754
|
+
* Increment the ref count for a blob that is being referenced by a new
|
|
755
|
+
* turn or context entry. Safe to call multiple times for the same sha256.
|
|
756
|
+
*/
|
|
757
|
+
retain(sha256: SHA256): Promise<Result<void, WorkspaceError>>;
|
|
758
|
+
/**
|
|
759
|
+
* Decrement the ref count. When it reaches 0, the blob is eligible for
|
|
760
|
+
* eviction. With eagerEviction=true, bytes are deleted immediately.
|
|
761
|
+
* With eagerEviction=false, bytes are retained until gc() is called.
|
|
762
|
+
*/
|
|
763
|
+
release(sha256: SHA256): Promise<Result<void, WorkspaceError>>;
|
|
764
|
+
/**
|
|
765
|
+
* Record that a blob has been uploaded to a provider and assigned a file ID.
|
|
766
|
+
* Idempotent — calling with the same providerId + fileId has no effect.
|
|
767
|
+
*/
|
|
768
|
+
recordRemoteId(sha256: SHA256, providerId: string, fileId: string): Promise<Result<void, WorkspaceError>>;
|
|
769
|
+
/**
|
|
770
|
+
* Get the remote file ID for a blob on a specific provider, if known.
|
|
771
|
+
*/
|
|
772
|
+
getRemoteId(sha256: SHA256, providerId: string): string | null;
|
|
773
|
+
/**
|
|
774
|
+
* Resolve a BlobRef to a ResolvedBlob.
|
|
775
|
+
*
|
|
776
|
+
* If a remote file ID is known for the given providerId, returns
|
|
777
|
+
* { kind: 'remote' } — no bytes transferred to the model call.
|
|
778
|
+
* Otherwise loads bytes from the backend and returns { kind: 'inline' }.
|
|
779
|
+
*
|
|
780
|
+
* @param ref The BlobRef to resolve.
|
|
781
|
+
* @param providerId The provider the resolved blob will be sent to
|
|
782
|
+
* (e.g. 'anthropic', 'openai'). Used to look up
|
|
783
|
+
* known remote file IDs. Pass null for local-only use.
|
|
784
|
+
*/
|
|
785
|
+
resolveRef(ref: BlobRef, providerId: string | null): Promise<Result<ResolvedBlob, WorkspaceError>>;
|
|
786
|
+
/**
|
|
787
|
+
* Resolve multiple BlobRefs, collecting all results.
|
|
788
|
+
* Returns a map of sha256 → ResolvedBlob for successes and a list of
|
|
789
|
+
* errors for failures, so partial failures don't block the whole build.
|
|
790
|
+
*/
|
|
791
|
+
resolveRefs(refs: BlobRef[], providerId: string | null): Promise<{
|
|
792
|
+
resolved: Map<SHA256, ResolvedBlob>;
|
|
793
|
+
errors: Array<{
|
|
794
|
+
ref: BlobRef;
|
|
795
|
+
error: WorkspaceError;
|
|
796
|
+
}>;
|
|
797
|
+
}>;
|
|
798
|
+
/**
|
|
799
|
+
* Delete bytes for all blobs with refCount === 0.
|
|
800
|
+
* Records are kept so re-registration is cheap (no re-hash needed).
|
|
801
|
+
* Call this periodically or on app startup to reclaim storage.
|
|
802
|
+
*
|
|
803
|
+
* Returns the number of blobs whose bytes were evicted.
|
|
804
|
+
*/
|
|
805
|
+
gc(): Promise<number>;
|
|
806
|
+
/**
|
|
807
|
+
* Fully purge a blob — delete both bytes and record regardless of refCount.
|
|
808
|
+
* Only use this for explicit user-initiated deletion or during workspace
|
|
809
|
+
* destruction. In normal operation, use release() and let GC handle it.
|
|
810
|
+
*/
|
|
811
|
+
purge(sha256: SHA256): Promise<Result<void, WorkspaceError>>;
|
|
812
|
+
getRecord(sha256: SHA256): BlobRecord | null;
|
|
813
|
+
getSummary(sha256: SHA256): BlobSummary | null;
|
|
814
|
+
/** All summaries — used to seed IndexState.blobs on init. */
|
|
815
|
+
getAllSummaries(): Record<SHA256, BlobSummary>;
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
declare class ContentStore {
|
|
819
|
+
private readonly storage;
|
|
820
|
+
private readonly cache;
|
|
821
|
+
private readonly config;
|
|
822
|
+
private activeSession;
|
|
823
|
+
private pinnedPreferenceIds;
|
|
824
|
+
onFlushed?: (sessionId: UUID, flushedCount: number) => void;
|
|
825
|
+
onSessionInvalidated?: (sessionId: UUID) => void;
|
|
826
|
+
constructor(backend: ContentStorage, config?: ContentStoreConfig);
|
|
827
|
+
getActiveSessionId(): UUID | null;
|
|
828
|
+
getRole(name: string): Promise<Result<Role, WorkspaceError>>;
|
|
829
|
+
getPreference(id: UUID): Promise<Result<Preference, WorkspaceError>>;
|
|
830
|
+
getContext(key: string): Promise<Result<Context, WorkspaceError>>;
|
|
831
|
+
getContextByTopics(indexState: IndexState, topics: string[]): Promise<Context[]>;
|
|
832
|
+
getTranscriptWindow(sessionId: UUID, windowSize?: number): Promise<TranscriptWindow>;
|
|
833
|
+
saveRole(role: Role): Promise<void>;
|
|
834
|
+
savePreference(preference: Preference): Promise<void>;
|
|
835
|
+
saveContext(context: Context): Promise<void>;
|
|
836
|
+
copyTranscript(sourceSessionId: UUID, targetSessionId: UUID): Promise<void>;
|
|
837
|
+
deleteRole(name: string): Promise<void>;
|
|
838
|
+
deletePreference(id: UUID): Promise<void>;
|
|
839
|
+
deleteContext(key: string): Promise<void>;
|
|
840
|
+
recordTurn(sessionId: UUID, turn: Turn): Promise<Result<void, WorkspaceError>>;
|
|
841
|
+
editTurn(sessionId: UUID, turnId: UUID, newBlocks: ContentBlock[], newVersion: number, roleSnapshot?: string): Promise<Result<void, WorkspaceError>>;
|
|
842
|
+
branchTurn(sessionId: UUID, newTurn: Turn): Promise<Result<void, WorkspaceError>>;
|
|
843
|
+
deleteTurnSubtree(sessionId: UUID, turnId: UUID, version: number, newHead: {
|
|
844
|
+
id: UUID;
|
|
845
|
+
version: number;
|
|
846
|
+
} | null): Promise<Result<void, WorkspaceError>>;
|
|
847
|
+
activateSession(meta: SessionMeta): Promise<Result<void, WorkspaceError>>;
|
|
848
|
+
deactivateSession(meta?: SessionMeta): Promise<void>;
|
|
849
|
+
resolveSession(indexState: IndexState, sessionId: UUID): Promise<Result<EffectiveSession, WorkspaceError>>;
|
|
850
|
+
flush(): Promise<void>;
|
|
851
|
+
dispose(): Promise<void>;
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
declare function workspaceReducer(state: IndexState, command: Command): Result<DeepPartial<IndexState>, WorkspaceError>;
|
|
855
|
+
|
|
856
|
+
declare class WorkspaceManager {
|
|
857
|
+
private readonly contentStore;
|
|
858
|
+
constructor(contentStore: ContentStore);
|
|
859
|
+
reduce(indexState: IndexState, command: Command): Result<DeepPartial<IndexState>, WorkspaceError>;
|
|
860
|
+
dispatch(indexState: IndexState, command: Command): Promise<Result<DeepPartial<IndexState>, WorkspaceError>>;
|
|
861
|
+
resolveSession(indexState: IndexState, sessionId: UUID): Promise<Result<EffectiveSession, WorkspaceError>>;
|
|
862
|
+
activateSession(indexState: IndexState, sessionId: UUID): Promise<Result<void, WorkspaceError>>;
|
|
863
|
+
deactivateSession(indexState?: IndexState): Promise<void>;
|
|
864
|
+
flush(): Promise<void>;
|
|
865
|
+
dispose(): Promise<void>;
|
|
866
|
+
private handleContentSideEffects;
|
|
867
|
+
}
|
|
868
|
+
|
|
869
|
+
interface Summarizer {
|
|
870
|
+
summarize(transcript: Turn[], tokenBudget: number): Promise<{
|
|
871
|
+
summary: string;
|
|
872
|
+
remaining: Turn[];
|
|
873
|
+
}>;
|
|
874
|
+
}
|
|
875
|
+
|
|
876
|
+
declare class PromptBuilder {
|
|
877
|
+
private readonly summarizer?;
|
|
878
|
+
constructor(summarizer?: Summarizer);
|
|
879
|
+
/**
|
|
880
|
+
* Build a provider-agnostic BuildResult from an EffectiveSession.
|
|
881
|
+
*
|
|
882
|
+
* IMPORTANT: blobs in the session's turns must be pre-resolved before
|
|
883
|
+
* calling build(). Pass the resolved map via options.resolvedBlobs.
|
|
884
|
+
* Any blob whose SHA-256 is not in resolvedBlobs will be omitted from
|
|
885
|
+
* the output with a warning.
|
|
886
|
+
*
|
|
887
|
+
* @param effectiveSession The resolved session (from ContentStore.resolveSession).
|
|
888
|
+
* @param options.resolvedBlobs Map of sha256 → ResolvedBlob from BlobStore.resolveRefs().
|
|
889
|
+
* @param options.tokenBudget Optional token budget for truncation.
|
|
890
|
+
* @param options.relevanceConfig Optional context ranking config.
|
|
891
|
+
*/
|
|
892
|
+
build(effectiveSession: EffectiveSession, options?: {
|
|
893
|
+
resolvedBlobs?: Map<SHA256, ResolvedBlob>;
|
|
894
|
+
tokenBudget?: TokenBudget;
|
|
895
|
+
relevanceConfig?: ContextRelevanceConfig;
|
|
896
|
+
}): Promise<Prompt>;
|
|
897
|
+
}
|
|
898
|
+
|
|
899
|
+
export { type AddContext, type AddInteraction, type AddPreference, type AddRole, type AddSessionTopics, type AddTurn, type BaseCommand, type BlobMediaType, type BlobRecord, type BlobRef, type BlobStorage, BlobStore, type BlobStoreConfig, type BlobSummary, type BranchTurn, type BuiltTurn, type CacheConfig, type Command, type ContentBlock, type ContentStorage, ContentStore, type ContentStoreConfig, type Context, type ContextRelevanceConfig, type ContextSummary, type CreateSession, type CreateWorkspace, type DeleteContext, type DeletePreference, type DeleteRole, type DeleteSession, type DeleteTurn, type DocumentBlock, type DocumentMediaType, type EditTurn, type EffectiveSession, type FlushConfig, type ForkSession, type ImageBlock, type ImageMediaType, type IndexState, type IndexedDBBlobConfig, IndexedDBBlobStorage, type IndexedDBConfig, IndexedDBStorage, type Indexes, MemoryBlobStorage, MemoryStorage, type OverrideSessionPreferences, type Preference, type PreferenceConflict, type PreferenceSummary, type Project, type Prompt, PromptBuilder, type RecordBlobRemoteId, type RegisterBlob, type ReleaseBlob, type ResolvedBlob, type Result, type Role, type RoleSummary, type SHA256, type Session, type SessionMeta, type SessionSummary, type Settings, type SwitchRole, type TextBlock, type ThinkingBlock, type Timestamp, type TokenBudget, type ToolResultBlock, type ToolUseBlock, type TopicIndex, type TranscriptWindow, type Turn, type TurnRole, type URI, type UUID, type UpdateContext, type UpdatePreference, type UpdateRole, type Workspace, type WorkspaceBundle, type WorkspaceError, WorkspaceManager, computeSHA256, del, err, merge, ok, workspaceReducer };
|