@tangleai/store 0.20.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/CHANGELOG.md +16 -0
- package/LICENSE +21 -0
- package/README.md +7 -0
- package/package.json +84 -0
- package/src/db.d.ts +27 -0
- package/src/db.js +28 -0
- package/src/document-store.d.ts +3 -0
- package/src/document-store.js +124 -0
- package/src/identities.d.ts +27 -0
- package/src/identities.js +43 -0
- package/src/index.d.ts +16 -0
- package/src/index.js +10 -0
- package/src/ledger-storage.d.ts +3 -0
- package/src/ledger-storage.js +46 -0
- package/src/mas-jobs.d.ts +121 -0
- package/src/mas-jobs.js +194 -0
- package/src/mas-store.d.ts +28 -0
- package/src/mas-store.js +524 -0
- package/src/memory-store.d.ts +28 -0
- package/src/memory-store.js +52 -0
- package/src/model.d.ts +446 -0
- package/src/model.js +242 -0
- package/src/runs.d.ts +74 -0
- package/src/runs.js +104 -0
package/src/model.d.ts
ADDED
|
@@ -0,0 +1,446 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Tangle database model — a `jaren-model` 0.1 document for
|
|
3
|
+
* @jarenjs/db `openStore`.
|
|
4
|
+
*
|
|
5
|
+
* The core collections, one decision each:
|
|
6
|
+
*
|
|
7
|
+
* memories — the MemoryUnit records. The db-level schema is
|
|
8
|
+
* deliberately minimal: the REAL write gate is
|
|
9
|
+
* `MEMORY_UNIT_SCHEMA`, enforced by `createDbMemoryStore`
|
|
10
|
+
* at the MemoryStore boundary (same rule as the in-memory
|
|
11
|
+
* store). Validating twice with two schemas invites drift.
|
|
12
|
+
* runs — one record per pipeline run: kind, status, summary.
|
|
13
|
+
* events — one record per DAG node record per run; this is the
|
|
14
|
+
* "historical DAG state" the desktop surface renders.
|
|
15
|
+
* chats — the conversation transcript with citations.
|
|
16
|
+
* documents — folder-sync state: content hash per file, so an
|
|
17
|
+
* unchanged file is skipped on re-sync.
|
|
18
|
+
* sources / document_versions / document_elements / document_chunks —
|
|
19
|
+
* the independent, replaceable web-document corpus lane.
|
|
20
|
+
* settings — key/value host configuration (folder, provider).
|
|
21
|
+
* config_identities — the content-addressed, credential-free run
|
|
22
|
+
* identities runs and chats refer to by id. Stored once
|
|
23
|
+
* per identity; a run row carries only the reference.
|
|
24
|
+
*
|
|
25
|
+
* Keys are JSON Pointers into the document (`key: '/id'`), so the id
|
|
26
|
+
* lives IN the record — a row is self-describing when exported.
|
|
27
|
+
*/
|
|
28
|
+
import type { JsonSchema } from '@tangleai/core/schemas/memory';
|
|
29
|
+
export declare const TANGLE_DB_MODEL: {
|
|
30
|
+
readonly $model: "0.1";
|
|
31
|
+
readonly collections: {
|
|
32
|
+
readonly memories: {
|
|
33
|
+
readonly schema: {
|
|
34
|
+
readonly type: "object";
|
|
35
|
+
readonly required: readonly ["id"];
|
|
36
|
+
readonly properties: {
|
|
37
|
+
readonly id: JsonSchema;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
readonly key: "/id";
|
|
41
|
+
};
|
|
42
|
+
readonly runs: {
|
|
43
|
+
readonly schema: {
|
|
44
|
+
readonly type: "object";
|
|
45
|
+
readonly required: readonly ["id", "kind", "startedAt", "status"];
|
|
46
|
+
readonly properties: {
|
|
47
|
+
readonly id: JsonSchema;
|
|
48
|
+
readonly kind: {
|
|
49
|
+
readonly type: "string";
|
|
50
|
+
};
|
|
51
|
+
readonly startedAt: {
|
|
52
|
+
readonly type: "string";
|
|
53
|
+
};
|
|
54
|
+
readonly finishedAt: {
|
|
55
|
+
readonly type: readonly ["string", "null"];
|
|
56
|
+
};
|
|
57
|
+
readonly status: {
|
|
58
|
+
readonly enum: readonly ["running", "ok", "error"];
|
|
59
|
+
};
|
|
60
|
+
readonly summary: {};
|
|
61
|
+
readonly identityId: {
|
|
62
|
+
readonly type: "string";
|
|
63
|
+
readonly pattern: "^[0-9a-f]{64}$";
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
readonly key: "/id";
|
|
68
|
+
};
|
|
69
|
+
readonly events: {
|
|
70
|
+
readonly schema: {
|
|
71
|
+
readonly type: "object";
|
|
72
|
+
readonly required: readonly ["id", "runId", "seq", "node", "status", "at"];
|
|
73
|
+
readonly properties: {
|
|
74
|
+
readonly id: JsonSchema;
|
|
75
|
+
readonly runId: {
|
|
76
|
+
readonly type: "string";
|
|
77
|
+
};
|
|
78
|
+
readonly seq: {
|
|
79
|
+
readonly type: "integer";
|
|
80
|
+
};
|
|
81
|
+
readonly node: {
|
|
82
|
+
readonly type: "string";
|
|
83
|
+
};
|
|
84
|
+
readonly status: {
|
|
85
|
+
readonly type: "string";
|
|
86
|
+
};
|
|
87
|
+
readonly ms: {
|
|
88
|
+
readonly type: "number";
|
|
89
|
+
};
|
|
90
|
+
readonly at: {
|
|
91
|
+
readonly type: "string";
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
readonly key: "/id";
|
|
96
|
+
};
|
|
97
|
+
readonly chats: {
|
|
98
|
+
readonly schema: {
|
|
99
|
+
readonly type: "object";
|
|
100
|
+
readonly required: readonly ["id", "role", "text", "at"];
|
|
101
|
+
readonly properties: {
|
|
102
|
+
readonly id: JsonSchema;
|
|
103
|
+
readonly role: {
|
|
104
|
+
readonly enum: readonly ["user", "assistant"];
|
|
105
|
+
};
|
|
106
|
+
readonly text: {
|
|
107
|
+
readonly type: "string";
|
|
108
|
+
};
|
|
109
|
+
readonly at: {
|
|
110
|
+
readonly type: "string";
|
|
111
|
+
};
|
|
112
|
+
readonly citations: {
|
|
113
|
+
readonly type: "array";
|
|
114
|
+
readonly items: {
|
|
115
|
+
readonly type: "string";
|
|
116
|
+
};
|
|
117
|
+
};
|
|
118
|
+
readonly provider: {
|
|
119
|
+
readonly type: readonly ["string", "null"];
|
|
120
|
+
};
|
|
121
|
+
readonly identityId: {
|
|
122
|
+
readonly type: readonly ["string", "null"];
|
|
123
|
+
};
|
|
124
|
+
readonly usage: {
|
|
125
|
+
readonly type: readonly ["object", "null"];
|
|
126
|
+
};
|
|
127
|
+
};
|
|
128
|
+
};
|
|
129
|
+
readonly key: "/id";
|
|
130
|
+
};
|
|
131
|
+
readonly documents: {
|
|
132
|
+
readonly schema: {
|
|
133
|
+
readonly type: "object";
|
|
134
|
+
readonly required: readonly ["path", "hash", "chunks", "ingestedAt"];
|
|
135
|
+
readonly properties: {
|
|
136
|
+
readonly path: {
|
|
137
|
+
readonly type: "string";
|
|
138
|
+
readonly minLength: 1;
|
|
139
|
+
};
|
|
140
|
+
readonly hash: {
|
|
141
|
+
readonly type: "string";
|
|
142
|
+
};
|
|
143
|
+
readonly chunks: {
|
|
144
|
+
readonly type: "integer";
|
|
145
|
+
};
|
|
146
|
+
readonly ingestedAt: {
|
|
147
|
+
readonly type: "string";
|
|
148
|
+
};
|
|
149
|
+
};
|
|
150
|
+
};
|
|
151
|
+
readonly key: "/path";
|
|
152
|
+
};
|
|
153
|
+
readonly sources: {
|
|
154
|
+
readonly schema: {
|
|
155
|
+
readonly type: "object";
|
|
156
|
+
readonly required: readonly ["id", "requestedUrl", "finalUrl", "canonicalUrl", "title", "mimeType", "fetchMode", "status", "fetchedAt"];
|
|
157
|
+
readonly properties: {
|
|
158
|
+
readonly id: JsonSchema;
|
|
159
|
+
readonly requestedUrl: {
|
|
160
|
+
readonly type: "string";
|
|
161
|
+
};
|
|
162
|
+
readonly finalUrl: {
|
|
163
|
+
readonly type: "string";
|
|
164
|
+
};
|
|
165
|
+
readonly canonicalUrl: {
|
|
166
|
+
readonly type: "string";
|
|
167
|
+
};
|
|
168
|
+
readonly title: {
|
|
169
|
+
readonly type: readonly ["string", "null"];
|
|
170
|
+
};
|
|
171
|
+
readonly mimeType: {
|
|
172
|
+
readonly type: "string";
|
|
173
|
+
};
|
|
174
|
+
readonly fetchMode: {
|
|
175
|
+
readonly enum: readonly ["static", "bun-webview", "remote-playwright"];
|
|
176
|
+
};
|
|
177
|
+
readonly status: {
|
|
178
|
+
readonly enum: readonly ["ready", "failed", "blocked", "dynamic-unavailable"];
|
|
179
|
+
};
|
|
180
|
+
readonly fetchedAt: {
|
|
181
|
+
readonly type: "string";
|
|
182
|
+
};
|
|
183
|
+
readonly activeVersionId: {
|
|
184
|
+
readonly type: "string";
|
|
185
|
+
};
|
|
186
|
+
};
|
|
187
|
+
};
|
|
188
|
+
readonly key: "/id";
|
|
189
|
+
};
|
|
190
|
+
readonly document_versions: {
|
|
191
|
+
readonly schema: {
|
|
192
|
+
readonly type: "object";
|
|
193
|
+
readonly required: readonly ["id", "sourceId", "contentHash", "extractionVersion", "chunkerVersion", "chunkerConfig", "embeddedBy", "status", "fetchedAt", "metrics"];
|
|
194
|
+
readonly properties: {
|
|
195
|
+
readonly id: JsonSchema;
|
|
196
|
+
readonly sourceId: JsonSchema;
|
|
197
|
+
readonly contentHash: {
|
|
198
|
+
readonly type: "string";
|
|
199
|
+
};
|
|
200
|
+
readonly extractionVersion: {
|
|
201
|
+
readonly type: "string";
|
|
202
|
+
};
|
|
203
|
+
readonly chunkerVersion: {
|
|
204
|
+
readonly type: "string";
|
|
205
|
+
};
|
|
206
|
+
readonly chunkerConfig: {
|
|
207
|
+
readonly type: "object";
|
|
208
|
+
};
|
|
209
|
+
readonly embeddedBy: {
|
|
210
|
+
readonly type: "object";
|
|
211
|
+
};
|
|
212
|
+
readonly status: {
|
|
213
|
+
readonly enum: readonly ["staging", "active", "failed", "superseded"];
|
|
214
|
+
};
|
|
215
|
+
readonly fetchedAt: {
|
|
216
|
+
readonly type: "string";
|
|
217
|
+
};
|
|
218
|
+
readonly metrics: {
|
|
219
|
+
readonly type: "object";
|
|
220
|
+
};
|
|
221
|
+
};
|
|
222
|
+
};
|
|
223
|
+
readonly key: "/id";
|
|
224
|
+
};
|
|
225
|
+
readonly document_elements: {
|
|
226
|
+
readonly schema: {
|
|
227
|
+
readonly type: "object";
|
|
228
|
+
readonly required: readonly ["id", "sourceId", "versionId", "text", "role", "order", "headingPath"];
|
|
229
|
+
readonly properties: {
|
|
230
|
+
readonly id: JsonSchema;
|
|
231
|
+
readonly sourceId: JsonSchema;
|
|
232
|
+
readonly versionId: JsonSchema;
|
|
233
|
+
readonly text: {
|
|
234
|
+
readonly type: "string";
|
|
235
|
+
};
|
|
236
|
+
readonly role: {
|
|
237
|
+
readonly type: "string";
|
|
238
|
+
};
|
|
239
|
+
readonly order: {
|
|
240
|
+
readonly type: "integer";
|
|
241
|
+
};
|
|
242
|
+
readonly headingPath: {
|
|
243
|
+
readonly type: "array";
|
|
244
|
+
readonly items: {
|
|
245
|
+
readonly type: "string";
|
|
246
|
+
};
|
|
247
|
+
};
|
|
248
|
+
};
|
|
249
|
+
};
|
|
250
|
+
readonly key: "/id";
|
|
251
|
+
};
|
|
252
|
+
readonly document_chunks: {
|
|
253
|
+
readonly schema: {
|
|
254
|
+
readonly type: "object";
|
|
255
|
+
readonly required: readonly ["id", "sourceId", "versionId", "elementIds", "text", "tokenCount", "order", "headingPath", "embedding", "embeddedBy"];
|
|
256
|
+
readonly properties: {
|
|
257
|
+
readonly id: JsonSchema;
|
|
258
|
+
readonly sourceId: JsonSchema;
|
|
259
|
+
readonly versionId: JsonSchema;
|
|
260
|
+
readonly elementIds: {
|
|
261
|
+
readonly type: "array";
|
|
262
|
+
readonly items: {
|
|
263
|
+
readonly type: "string";
|
|
264
|
+
};
|
|
265
|
+
};
|
|
266
|
+
readonly text: {
|
|
267
|
+
readonly type: "string";
|
|
268
|
+
};
|
|
269
|
+
readonly tokenCount: {
|
|
270
|
+
readonly type: "integer";
|
|
271
|
+
};
|
|
272
|
+
readonly order: {
|
|
273
|
+
readonly type: "integer";
|
|
274
|
+
};
|
|
275
|
+
readonly headingPath: {
|
|
276
|
+
readonly type: "array";
|
|
277
|
+
readonly items: {
|
|
278
|
+
readonly type: "string";
|
|
279
|
+
};
|
|
280
|
+
};
|
|
281
|
+
readonly embedding: {
|
|
282
|
+
readonly type: "array";
|
|
283
|
+
readonly items: {
|
|
284
|
+
readonly type: "number";
|
|
285
|
+
};
|
|
286
|
+
};
|
|
287
|
+
readonly embeddedBy: {
|
|
288
|
+
readonly type: "object";
|
|
289
|
+
};
|
|
290
|
+
};
|
|
291
|
+
};
|
|
292
|
+
readonly key: "/id";
|
|
293
|
+
};
|
|
294
|
+
readonly settings: {
|
|
295
|
+
readonly schema: {
|
|
296
|
+
readonly type: "object";
|
|
297
|
+
readonly required: readonly ["key"];
|
|
298
|
+
readonly properties: {
|
|
299
|
+
readonly key: JsonSchema;
|
|
300
|
+
readonly value: {};
|
|
301
|
+
};
|
|
302
|
+
};
|
|
303
|
+
readonly key: "/key";
|
|
304
|
+
};
|
|
305
|
+
readonly config_identities: {
|
|
306
|
+
readonly schema: {
|
|
307
|
+
readonly type: "object";
|
|
308
|
+
readonly required: readonly ["id", "value"];
|
|
309
|
+
readonly properties: {
|
|
310
|
+
readonly id: {
|
|
311
|
+
readonly type: "string";
|
|
312
|
+
readonly pattern: "^[0-9a-f]{64}$";
|
|
313
|
+
};
|
|
314
|
+
readonly value: {
|
|
315
|
+
readonly type: "object";
|
|
316
|
+
};
|
|
317
|
+
};
|
|
318
|
+
};
|
|
319
|
+
readonly key: "/id";
|
|
320
|
+
};
|
|
321
|
+
readonly mas_workflows: {
|
|
322
|
+
readonly schema: {
|
|
323
|
+
readonly type: "object";
|
|
324
|
+
readonly required: readonly ["id"];
|
|
325
|
+
readonly properties: {
|
|
326
|
+
readonly id: JsonSchema;
|
|
327
|
+
};
|
|
328
|
+
};
|
|
329
|
+
readonly key: "/id";
|
|
330
|
+
};
|
|
331
|
+
readonly mas_workflow_versions: {
|
|
332
|
+
readonly schema: {
|
|
333
|
+
readonly type: "object";
|
|
334
|
+
readonly required: readonly ["versionId"];
|
|
335
|
+
readonly properties: {
|
|
336
|
+
readonly versionId: {
|
|
337
|
+
readonly type: "string";
|
|
338
|
+
readonly pattern: "^[0-9a-f]{64}$";
|
|
339
|
+
};
|
|
340
|
+
};
|
|
341
|
+
};
|
|
342
|
+
readonly key: "/versionId";
|
|
343
|
+
};
|
|
344
|
+
readonly mas_templates: {
|
|
345
|
+
readonly schema: {
|
|
346
|
+
readonly type: "object";
|
|
347
|
+
readonly required: readonly ["id"];
|
|
348
|
+
readonly properties: {
|
|
349
|
+
readonly id: JsonSchema;
|
|
350
|
+
};
|
|
351
|
+
};
|
|
352
|
+
readonly key: "/id";
|
|
353
|
+
};
|
|
354
|
+
readonly mas_template_versions: {
|
|
355
|
+
readonly schema: {
|
|
356
|
+
readonly type: "object";
|
|
357
|
+
readonly required: readonly ["versionId"];
|
|
358
|
+
readonly properties: {
|
|
359
|
+
readonly versionId: {
|
|
360
|
+
readonly type: "string";
|
|
361
|
+
readonly pattern: "^[0-9a-f]{64}$";
|
|
362
|
+
};
|
|
363
|
+
};
|
|
364
|
+
};
|
|
365
|
+
readonly key: "/versionId";
|
|
366
|
+
};
|
|
367
|
+
readonly mas_registry_snapshots: {
|
|
368
|
+
readonly schema: {
|
|
369
|
+
readonly type: "object";
|
|
370
|
+
readonly required: readonly ["revision"];
|
|
371
|
+
readonly properties: {
|
|
372
|
+
readonly revision: {
|
|
373
|
+
readonly type: "string";
|
|
374
|
+
readonly pattern: "^[0-9a-f]{64}$";
|
|
375
|
+
};
|
|
376
|
+
};
|
|
377
|
+
};
|
|
378
|
+
readonly key: "/revision";
|
|
379
|
+
};
|
|
380
|
+
readonly mas_runs: {
|
|
381
|
+
readonly schema: {
|
|
382
|
+
readonly type: "object";
|
|
383
|
+
readonly required: readonly ["id"];
|
|
384
|
+
readonly properties: {
|
|
385
|
+
readonly id: JsonSchema;
|
|
386
|
+
};
|
|
387
|
+
};
|
|
388
|
+
readonly key: "/id";
|
|
389
|
+
};
|
|
390
|
+
readonly mas_node_attempts: {
|
|
391
|
+
readonly schema: {
|
|
392
|
+
readonly type: "object";
|
|
393
|
+
readonly required: readonly ["id", "runId"];
|
|
394
|
+
readonly properties: {
|
|
395
|
+
readonly id: JsonSchema;
|
|
396
|
+
readonly runId: JsonSchema;
|
|
397
|
+
};
|
|
398
|
+
};
|
|
399
|
+
readonly key: "/id";
|
|
400
|
+
};
|
|
401
|
+
readonly mas_messages: {
|
|
402
|
+
readonly schema: {
|
|
403
|
+
readonly type: "object";
|
|
404
|
+
readonly required: readonly ["id", "runId"];
|
|
405
|
+
readonly properties: {
|
|
406
|
+
readonly id: JsonSchema;
|
|
407
|
+
readonly runId: JsonSchema;
|
|
408
|
+
};
|
|
409
|
+
};
|
|
410
|
+
readonly key: "/id";
|
|
411
|
+
};
|
|
412
|
+
readonly mas_state_revisions: {
|
|
413
|
+
readonly schema: {
|
|
414
|
+
readonly type: "object";
|
|
415
|
+
readonly required: readonly ["id", "runId"];
|
|
416
|
+
readonly properties: {
|
|
417
|
+
readonly id: JsonSchema;
|
|
418
|
+
readonly runId: JsonSchema;
|
|
419
|
+
};
|
|
420
|
+
};
|
|
421
|
+
readonly key: "/id";
|
|
422
|
+
};
|
|
423
|
+
readonly mas_interactions: {
|
|
424
|
+
readonly schema: {
|
|
425
|
+
readonly type: "object";
|
|
426
|
+
readonly required: readonly ["id", "runId"];
|
|
427
|
+
readonly properties: {
|
|
428
|
+
readonly id: JsonSchema;
|
|
429
|
+
readonly runId: JsonSchema;
|
|
430
|
+
};
|
|
431
|
+
};
|
|
432
|
+
readonly key: "/id";
|
|
433
|
+
};
|
|
434
|
+
readonly mas_trace_artifacts: {
|
|
435
|
+
readonly schema: {
|
|
436
|
+
readonly type: "object";
|
|
437
|
+
readonly required: readonly ["id", "runId"];
|
|
438
|
+
readonly properties: {
|
|
439
|
+
readonly id: JsonSchema;
|
|
440
|
+
readonly runId: JsonSchema;
|
|
441
|
+
};
|
|
442
|
+
};
|
|
443
|
+
readonly key: "/id";
|
|
444
|
+
};
|
|
445
|
+
};
|
|
446
|
+
};
|
package/src/model.js
ADDED
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Tangle database model — a `jaren-model` 0.1 document for
|
|
3
|
+
* @jarenjs/db `openStore`.
|
|
4
|
+
*
|
|
5
|
+
* The core collections, one decision each:
|
|
6
|
+
*
|
|
7
|
+
* memories — the MemoryUnit records. The db-level schema is
|
|
8
|
+
* deliberately minimal: the REAL write gate is
|
|
9
|
+
* `MEMORY_UNIT_SCHEMA`, enforced by `createDbMemoryStore`
|
|
10
|
+
* at the MemoryStore boundary (same rule as the in-memory
|
|
11
|
+
* store). Validating twice with two schemas invites drift.
|
|
12
|
+
* runs — one record per pipeline run: kind, status, summary.
|
|
13
|
+
* events — one record per DAG node record per run; this is the
|
|
14
|
+
* "historical DAG state" the desktop surface renders.
|
|
15
|
+
* chats — the conversation transcript with citations.
|
|
16
|
+
* documents — folder-sync state: content hash per file, so an
|
|
17
|
+
* unchanged file is skipped on re-sync.
|
|
18
|
+
* sources / document_versions / document_elements / document_chunks —
|
|
19
|
+
* the independent, replaceable web-document corpus lane.
|
|
20
|
+
* settings — key/value host configuration (folder, provider).
|
|
21
|
+
* config_identities — the content-addressed, credential-free run
|
|
22
|
+
* identities runs and chats refer to by id. Stored once
|
|
23
|
+
* per identity; a run row carries only the reference.
|
|
24
|
+
*
|
|
25
|
+
* Keys are JSON Pointers into the document (`key: '/id'`), so the id
|
|
26
|
+
* lives IN the record — a row is self-describing when exported.
|
|
27
|
+
*/
|
|
28
|
+
const ID = { type: 'string', minLength: 1 };
|
|
29
|
+
export const TANGLE_DB_MODEL = {
|
|
30
|
+
$model: '0.1',
|
|
31
|
+
collections: {
|
|
32
|
+
memories: {
|
|
33
|
+
schema: { type: 'object', required: ['id'], properties: { id: ID } },
|
|
34
|
+
key: '/id',
|
|
35
|
+
},
|
|
36
|
+
runs: {
|
|
37
|
+
schema: {
|
|
38
|
+
type: 'object',
|
|
39
|
+
required: ['id', 'kind', 'startedAt', 'status'],
|
|
40
|
+
properties: {
|
|
41
|
+
id: ID,
|
|
42
|
+
kind: { type: 'string' },
|
|
43
|
+
startedAt: { type: 'string' },
|
|
44
|
+
finishedAt: { type: ['string', 'null'] },
|
|
45
|
+
status: { enum: ['running', 'ok', 'error'] },
|
|
46
|
+
summary: {},
|
|
47
|
+
identityId: { type: 'string', pattern: '^[0-9a-f]{64}$' },
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
key: '/id',
|
|
51
|
+
},
|
|
52
|
+
events: {
|
|
53
|
+
schema: {
|
|
54
|
+
type: 'object',
|
|
55
|
+
required: ['id', 'runId', 'seq', 'node', 'status', 'at'],
|
|
56
|
+
properties: {
|
|
57
|
+
id: ID,
|
|
58
|
+
runId: { type: 'string' },
|
|
59
|
+
seq: { type: 'integer' },
|
|
60
|
+
node: { type: 'string' },
|
|
61
|
+
status: { type: 'string' },
|
|
62
|
+
ms: { type: 'number' },
|
|
63
|
+
at: { type: 'string' },
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
key: '/id',
|
|
67
|
+
},
|
|
68
|
+
chats: {
|
|
69
|
+
schema: {
|
|
70
|
+
type: 'object',
|
|
71
|
+
required: ['id', 'role', 'text', 'at'],
|
|
72
|
+
properties: {
|
|
73
|
+
id: ID,
|
|
74
|
+
role: { enum: ['user', 'assistant'] },
|
|
75
|
+
text: { type: 'string' },
|
|
76
|
+
at: { type: 'string' },
|
|
77
|
+
citations: { type: 'array', items: { type: 'string' } },
|
|
78
|
+
provider: { type: ['string', 'null'] },
|
|
79
|
+
identityId: { type: ['string', 'null'] },
|
|
80
|
+
usage: { type: ['object', 'null'] },
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
key: '/id',
|
|
84
|
+
},
|
|
85
|
+
documents: {
|
|
86
|
+
schema: {
|
|
87
|
+
type: 'object',
|
|
88
|
+
required: ['path', 'hash', 'chunks', 'ingestedAt'],
|
|
89
|
+
properties: {
|
|
90
|
+
path: { type: 'string', minLength: 1 },
|
|
91
|
+
hash: { type: 'string' },
|
|
92
|
+
chunks: { type: 'integer' },
|
|
93
|
+
ingestedAt: { type: 'string' },
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
key: '/path',
|
|
97
|
+
},
|
|
98
|
+
sources: {
|
|
99
|
+
schema: {
|
|
100
|
+
type: 'object',
|
|
101
|
+
required: ['id', 'requestedUrl', 'finalUrl', 'canonicalUrl', 'title', 'mimeType', 'fetchMode', 'status', 'fetchedAt'],
|
|
102
|
+
properties: {
|
|
103
|
+
id: ID,
|
|
104
|
+
requestedUrl: { type: 'string' },
|
|
105
|
+
finalUrl: { type: 'string' },
|
|
106
|
+
canonicalUrl: { type: 'string' },
|
|
107
|
+
title: { type: ['string', 'null'] },
|
|
108
|
+
mimeType: { type: 'string' },
|
|
109
|
+
fetchMode: { enum: ['static', 'bun-webview', 'remote-playwright'] },
|
|
110
|
+
status: { enum: ['ready', 'failed', 'blocked', 'dynamic-unavailable'] },
|
|
111
|
+
fetchedAt: { type: 'string' },
|
|
112
|
+
activeVersionId: { type: 'string' },
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
key: '/id',
|
|
116
|
+
},
|
|
117
|
+
document_versions: {
|
|
118
|
+
schema: {
|
|
119
|
+
type: 'object',
|
|
120
|
+
required: ['id', 'sourceId', 'contentHash', 'extractionVersion', 'chunkerVersion', 'chunkerConfig', 'embeddedBy', 'status', 'fetchedAt', 'metrics'],
|
|
121
|
+
properties: {
|
|
122
|
+
id: ID,
|
|
123
|
+
sourceId: ID,
|
|
124
|
+
contentHash: { type: 'string' },
|
|
125
|
+
extractionVersion: { type: 'string' },
|
|
126
|
+
chunkerVersion: { type: 'string' },
|
|
127
|
+
chunkerConfig: { type: 'object' },
|
|
128
|
+
embeddedBy: { type: 'object' },
|
|
129
|
+
status: { enum: ['staging', 'active', 'failed', 'superseded'] },
|
|
130
|
+
fetchedAt: { type: 'string' },
|
|
131
|
+
metrics: { type: 'object' },
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
key: '/id',
|
|
135
|
+
},
|
|
136
|
+
document_elements: {
|
|
137
|
+
schema: {
|
|
138
|
+
type: 'object',
|
|
139
|
+
required: ['id', 'sourceId', 'versionId', 'text', 'role', 'order', 'headingPath'],
|
|
140
|
+
properties: {
|
|
141
|
+
id: ID,
|
|
142
|
+
sourceId: ID,
|
|
143
|
+
versionId: ID,
|
|
144
|
+
text: { type: 'string' },
|
|
145
|
+
role: { type: 'string' },
|
|
146
|
+
order: { type: 'integer' },
|
|
147
|
+
headingPath: { type: 'array', items: { type: 'string' } },
|
|
148
|
+
},
|
|
149
|
+
},
|
|
150
|
+
key: '/id',
|
|
151
|
+
},
|
|
152
|
+
document_chunks: {
|
|
153
|
+
schema: {
|
|
154
|
+
type: 'object',
|
|
155
|
+
required: ['id', 'sourceId', 'versionId', 'elementIds', 'text', 'tokenCount', 'order', 'headingPath', 'embedding', 'embeddedBy'],
|
|
156
|
+
properties: {
|
|
157
|
+
id: ID,
|
|
158
|
+
sourceId: ID,
|
|
159
|
+
versionId: ID,
|
|
160
|
+
elementIds: { type: 'array', items: { type: 'string' } },
|
|
161
|
+
text: { type: 'string' },
|
|
162
|
+
tokenCount: { type: 'integer' },
|
|
163
|
+
order: { type: 'integer' },
|
|
164
|
+
headingPath: { type: 'array', items: { type: 'string' } },
|
|
165
|
+
embedding: { type: 'array', items: { type: 'number' } },
|
|
166
|
+
embeddedBy: { type: 'object' },
|
|
167
|
+
},
|
|
168
|
+
},
|
|
169
|
+
key: '/id',
|
|
170
|
+
},
|
|
171
|
+
settings: {
|
|
172
|
+
schema: {
|
|
173
|
+
type: 'object',
|
|
174
|
+
required: ['key'],
|
|
175
|
+
properties: { key: ID, value: {} },
|
|
176
|
+
},
|
|
177
|
+
key: '/key',
|
|
178
|
+
},
|
|
179
|
+
config_identities: {
|
|
180
|
+
schema: {
|
|
181
|
+
type: 'object',
|
|
182
|
+
required: ['id', 'value'],
|
|
183
|
+
properties: {
|
|
184
|
+
id: { type: 'string', pattern: '^[0-9a-f]{64}$' },
|
|
185
|
+
value: { type: 'object' },
|
|
186
|
+
},
|
|
187
|
+
},
|
|
188
|
+
key: '/id',
|
|
189
|
+
},
|
|
190
|
+
// The eleven MAS semantic collections. The db-level schemas are
|
|
191
|
+
// deliberately minimal (the same rule as `memories`): the REAL write
|
|
192
|
+
// gate is the generated mas-runtime/mas-workflow contracts, enforced by
|
|
193
|
+
// `createMasStore` at the MasStore boundary — validating twice with two
|
|
194
|
+
// schemas invites drift. There is deliberately no mas_jobs, lease,
|
|
195
|
+
// retry, dead-letter or generic checkpoint collection: durable work is
|
|
196
|
+
// the suite's own `_jaren_jobs` / `_jaren_job_checkpoints`.
|
|
197
|
+
mas_workflows: {
|
|
198
|
+
schema: { type: 'object', required: ['id'], properties: { id: ID } },
|
|
199
|
+
key: '/id',
|
|
200
|
+
},
|
|
201
|
+
mas_workflow_versions: {
|
|
202
|
+
schema: { type: 'object', required: ['versionId'], properties: { versionId: { type: 'string', pattern: '^[0-9a-f]{64}$' } } },
|
|
203
|
+
key: '/versionId',
|
|
204
|
+
},
|
|
205
|
+
mas_templates: {
|
|
206
|
+
schema: { type: 'object', required: ['id'], properties: { id: ID } },
|
|
207
|
+
key: '/id',
|
|
208
|
+
},
|
|
209
|
+
mas_template_versions: {
|
|
210
|
+
schema: { type: 'object', required: ['versionId'], properties: { versionId: { type: 'string', pattern: '^[0-9a-f]{64}$' } } },
|
|
211
|
+
key: '/versionId',
|
|
212
|
+
},
|
|
213
|
+
mas_registry_snapshots: {
|
|
214
|
+
schema: { type: 'object', required: ['revision'], properties: { revision: { type: 'string', pattern: '^[0-9a-f]{64}$' } } },
|
|
215
|
+
key: '/revision',
|
|
216
|
+
},
|
|
217
|
+
mas_runs: {
|
|
218
|
+
schema: { type: 'object', required: ['id'], properties: { id: ID } },
|
|
219
|
+
key: '/id',
|
|
220
|
+
},
|
|
221
|
+
mas_node_attempts: {
|
|
222
|
+
schema: { type: 'object', required: ['id', 'runId'], properties: { id: ID, runId: ID } },
|
|
223
|
+
key: '/id',
|
|
224
|
+
},
|
|
225
|
+
mas_messages: {
|
|
226
|
+
schema: { type: 'object', required: ['id', 'runId'], properties: { id: ID, runId: ID } },
|
|
227
|
+
key: '/id',
|
|
228
|
+
},
|
|
229
|
+
mas_state_revisions: {
|
|
230
|
+
schema: { type: 'object', required: ['id', 'runId'], properties: { id: ID, runId: ID } },
|
|
231
|
+
key: '/id',
|
|
232
|
+
},
|
|
233
|
+
mas_interactions: {
|
|
234
|
+
schema: { type: 'object', required: ['id', 'runId'], properties: { id: ID, runId: ID } },
|
|
235
|
+
key: '/id',
|
|
236
|
+
},
|
|
237
|
+
mas_trace_artifacts: {
|
|
238
|
+
schema: { type: 'object', required: ['id', 'runId'], properties: { id: ID, runId: ID } },
|
|
239
|
+
key: '/id',
|
|
240
|
+
},
|
|
241
|
+
},
|
|
242
|
+
};
|