@happyvertical/smrt-core 0.40.65 → 0.40.66
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/AGENTS.md +11 -0
- package/dist/knowledge.d.ts.map +1 -1
- package/dist/knowledge.js +98 -11
- package/dist/knowledge.js.map +1 -1
- package/dist/manifest/static-manifest.js +1 -1
- package/dist/manifest/static-manifest.js.map +1 -1
- package/dist/manifest/store.js +1 -1
- package/dist/manifest.json +1 -1
- package/dist/smrt-knowledge.json +587 -6
- package/package.json +10 -10
package/dist/smrt-knowledge.json
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 1,
|
|
3
|
+
"sensitiveFieldsExcluded": true,
|
|
3
4
|
"generatedAt": "1970-01-01T00:00:00.000Z",
|
|
4
5
|
"packageName": "@happyvertical/smrt-core",
|
|
5
|
-
"packageVersion": "0.40.
|
|
6
|
+
"packageVersion": "0.40.66",
|
|
6
7
|
"sourceManifestPath": "dist/manifest.json",
|
|
7
8
|
"agentDocPath": "AGENTS.md",
|
|
8
9
|
"sourceHashes": {
|
|
9
|
-
"manifest": "
|
|
10
|
-
"packageJson": "
|
|
11
|
-
"agents": "
|
|
10
|
+
"manifest": "c5f3ddda3643e02b19c6cf026d0a26ec5b59c6f5f8b791bd26b198c8a96a3036",
|
|
11
|
+
"packageJson": "c8b73d99ef3b13b6372e4096e18e2cea009583d3a2e80e33e270664304ef93e1",
|
|
12
|
+
"agents": "cd549496058522b65d18c2f2bc3492e56eee57b14fefd0d8eea5329a3b0de004",
|
|
12
13
|
"moduleDoc:agents/change-feed.md": "5278797d6c049ea21071b011182a9fcd79d17f9d74e0f90a93caa4c05c25294f",
|
|
13
14
|
"moduleDoc:agents/change-signals.md": "d9cb6a5541728ffea46607a6b1d4fa61d4621849f2b4ea86a0645fbb0af892e9",
|
|
14
15
|
"moduleDoc:agents/generators.md": "2b6ccd5ff557293f2ce84d25cc254ceb518f4c274d93b7e3175985b18f36f564"
|
|
@@ -103,6 +104,36 @@
|
|
|
103
104
|
"resetAiUsage",
|
|
104
105
|
"summarizeAiUsage"
|
|
105
106
|
],
|
|
107
|
+
"methodSignatures": [
|
|
108
|
+
{
|
|
109
|
+
"name": "destroy",
|
|
110
|
+
"returns": "void"
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
"name": "getAiUsageSnapshot",
|
|
114
|
+
"returns": "AiUsageSnapshot | undefined"
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
"name": "listAiUsage",
|
|
118
|
+
"async": true,
|
|
119
|
+
"params": [
|
|
120
|
+
"options?: AiUsageListOptions"
|
|
121
|
+
],
|
|
122
|
+
"returns": "Promise<SmrtAiUsageRecord[]>"
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
"name": "resetAiUsage",
|
|
126
|
+
"returns": "void"
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
"name": "summarizeAiUsage",
|
|
130
|
+
"async": true,
|
|
131
|
+
"params": [
|
|
132
|
+
"options?: AiUsageSummaryOptions"
|
|
133
|
+
],
|
|
134
|
+
"returns": "Promise<Record<string, AiUsageStats>>"
|
|
135
|
+
}
|
|
136
|
+
],
|
|
106
137
|
"surfaces": [],
|
|
107
138
|
"relationshipFeatures": [
|
|
108
139
|
"uuidColumns"
|
|
@@ -151,6 +182,225 @@
|
|
|
151
182
|
"semanticSearch",
|
|
152
183
|
"validate"
|
|
153
184
|
],
|
|
185
|
+
"methodSignatures": [
|
|
186
|
+
{
|
|
187
|
+
"name": "count",
|
|
188
|
+
"async": true,
|
|
189
|
+
"params": [
|
|
190
|
+
"options?: object"
|
|
191
|
+
],
|
|
192
|
+
"returns": "any"
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
"name": "create",
|
|
196
|
+
"async": true,
|
|
197
|
+
"params": [
|
|
198
|
+
"options: SmrtCreateInput<ModelType>"
|
|
199
|
+
],
|
|
200
|
+
"returns": "any"
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
"name": "delete",
|
|
204
|
+
"async": true,
|
|
205
|
+
"params": [
|
|
206
|
+
"id: string"
|
|
207
|
+
],
|
|
208
|
+
"returns": "Promise<boolean>"
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
"name": "ensureStorageReady",
|
|
212
|
+
"async": true,
|
|
213
|
+
"returns": "Promise<void>"
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
"name": "findAll",
|
|
217
|
+
"async": true,
|
|
218
|
+
"params": [
|
|
219
|
+
"options?: object"
|
|
220
|
+
],
|
|
221
|
+
"returns": "Promise<ModelType[]>"
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
"name": "findById",
|
|
225
|
+
"async": true,
|
|
226
|
+
"params": [
|
|
227
|
+
"id: string"
|
|
228
|
+
],
|
|
229
|
+
"returns": "Promise<ModelType | null>"
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
"name": "findOne",
|
|
233
|
+
"async": true,
|
|
234
|
+
"params": [
|
|
235
|
+
"options: object"
|
|
236
|
+
],
|
|
237
|
+
"returns": "Promise<ModelType | null>"
|
|
238
|
+
},
|
|
239
|
+
{
|
|
240
|
+
"name": "findSimilar",
|
|
241
|
+
"async": true,
|
|
242
|
+
"params": [
|
|
243
|
+
"object: ModelType | string",
|
|
244
|
+
"options?: object"
|
|
245
|
+
],
|
|
246
|
+
"returns": "Promise<Array>"
|
|
247
|
+
},
|
|
248
|
+
{
|
|
249
|
+
"name": "findSimilarToEmbedding",
|
|
250
|
+
"async": true,
|
|
251
|
+
"params": [
|
|
252
|
+
"embedding: number[]",
|
|
253
|
+
"options?: object"
|
|
254
|
+
],
|
|
255
|
+
"returns": "Promise<Array>"
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
"name": "forget",
|
|
259
|
+
"async": true,
|
|
260
|
+
"params": [
|
|
261
|
+
"options: object"
|
|
262
|
+
],
|
|
263
|
+
"returns": "Promise<void>"
|
|
264
|
+
},
|
|
265
|
+
{
|
|
266
|
+
"name": "forgetScope",
|
|
267
|
+
"async": true,
|
|
268
|
+
"params": [
|
|
269
|
+
"options: object"
|
|
270
|
+
],
|
|
271
|
+
"returns": "Promise<number>"
|
|
272
|
+
},
|
|
273
|
+
{
|
|
274
|
+
"name": "generateMissingEmbeddings",
|
|
275
|
+
"async": true,
|
|
276
|
+
"params": [
|
|
277
|
+
"options?: object"
|
|
278
|
+
],
|
|
279
|
+
"returns": "Promise<object>"
|
|
280
|
+
},
|
|
281
|
+
{
|
|
282
|
+
"name": "generateSchema",
|
|
283
|
+
"async": true,
|
|
284
|
+
"returns": "any"
|
|
285
|
+
},
|
|
286
|
+
{
|
|
287
|
+
"name": "generateTableName",
|
|
288
|
+
"returns": "any"
|
|
289
|
+
},
|
|
290
|
+
{
|
|
291
|
+
"name": "get",
|
|
292
|
+
"async": true,
|
|
293
|
+
"params": [
|
|
294
|
+
"filter: string | SmrtWhereClause<ModelType>",
|
|
295
|
+
"options?: object"
|
|
296
|
+
],
|
|
297
|
+
"returns": "Promise<ModelType | null>"
|
|
298
|
+
},
|
|
299
|
+
{
|
|
300
|
+
"name": "getDiff",
|
|
301
|
+
"async": true,
|
|
302
|
+
"params": [
|
|
303
|
+
"existing: SmrtObject | Record<string>",
|
|
304
|
+
"data: Record<string>"
|
|
305
|
+
],
|
|
306
|
+
"returns": "Promise<Record<string> | null>"
|
|
307
|
+
},
|
|
308
|
+
{
|
|
309
|
+
"name": "getFields",
|
|
310
|
+
"async": true,
|
|
311
|
+
"returns": "Promise<Record<string, CollectionFieldDefinition>>"
|
|
312
|
+
},
|
|
313
|
+
{
|
|
314
|
+
"name": "getFieldsSync",
|
|
315
|
+
"returns": "Record<string, CollectionFieldDefinition>"
|
|
316
|
+
},
|
|
317
|
+
{
|
|
318
|
+
"name": "getItemClass",
|
|
319
|
+
"returns": "SmrtCollectionItemClass<ModelType>"
|
|
320
|
+
},
|
|
321
|
+
{
|
|
322
|
+
"name": "getOrUpsert",
|
|
323
|
+
"async": true,
|
|
324
|
+
"params": [
|
|
325
|
+
"data: Record<string>",
|
|
326
|
+
"defaults?: Record<string>"
|
|
327
|
+
],
|
|
328
|
+
"returns": "any"
|
|
329
|
+
},
|
|
330
|
+
{
|
|
331
|
+
"name": "getStiChildMetaType",
|
|
332
|
+
"returns": "string | null"
|
|
333
|
+
},
|
|
334
|
+
{
|
|
335
|
+
"name": "initialize",
|
|
336
|
+
"async": true,
|
|
337
|
+
"returns": "Promise"
|
|
338
|
+
},
|
|
339
|
+
{
|
|
340
|
+
"name": "list",
|
|
341
|
+
"async": true,
|
|
342
|
+
"params": [
|
|
343
|
+
"options?: SmrtListOptions<ModelType>"
|
|
344
|
+
],
|
|
345
|
+
"returns": "Promise<ModelType[] | Record<string>[]>"
|
|
346
|
+
},
|
|
347
|
+
{
|
|
348
|
+
"name": "listByIds",
|
|
349
|
+
"async": true,
|
|
350
|
+
"params": [
|
|
351
|
+
"ids: string[]"
|
|
352
|
+
],
|
|
353
|
+
"returns": "Promise<ModelType[]>"
|
|
354
|
+
},
|
|
355
|
+
{
|
|
356
|
+
"name": "query",
|
|
357
|
+
"async": true,
|
|
358
|
+
"params": [
|
|
359
|
+
"sql: string",
|
|
360
|
+
"params?: any",
|
|
361
|
+
"options?: object"
|
|
362
|
+
],
|
|
363
|
+
"returns": "Promise<ModelType[]>"
|
|
364
|
+
},
|
|
365
|
+
{
|
|
366
|
+
"name": "recall",
|
|
367
|
+
"async": true,
|
|
368
|
+
"params": [
|
|
369
|
+
"options: object"
|
|
370
|
+
],
|
|
371
|
+
"returns": "Promise"
|
|
372
|
+
},
|
|
373
|
+
{
|
|
374
|
+
"name": "recallAll",
|
|
375
|
+
"async": true,
|
|
376
|
+
"params": [
|
|
377
|
+
"options?: object"
|
|
378
|
+
],
|
|
379
|
+
"returns": "Promise<Map<string>>"
|
|
380
|
+
},
|
|
381
|
+
{
|
|
382
|
+
"name": "remember",
|
|
383
|
+
"async": true,
|
|
384
|
+
"params": [
|
|
385
|
+
"options: object"
|
|
386
|
+
],
|
|
387
|
+
"returns": "Promise<void>"
|
|
388
|
+
},
|
|
389
|
+
{
|
|
390
|
+
"name": "semanticSearch",
|
|
391
|
+
"async": true,
|
|
392
|
+
"params": [
|
|
393
|
+
"query: string",
|
|
394
|
+
"options?: object"
|
|
395
|
+
],
|
|
396
|
+
"returns": "Promise<Array>"
|
|
397
|
+
},
|
|
398
|
+
{
|
|
399
|
+
"name": "validate",
|
|
400
|
+
"static": true,
|
|
401
|
+
"returns": "void"
|
|
402
|
+
}
|
|
403
|
+
],
|
|
154
404
|
"surfaces": [],
|
|
155
405
|
"relationshipFeatures": [
|
|
156
406
|
"uuidColumns"
|
|
@@ -180,6 +430,41 @@
|
|
|
180
430
|
"getParent",
|
|
181
431
|
"moveTo"
|
|
182
432
|
],
|
|
433
|
+
"methodSignatures": [
|
|
434
|
+
{
|
|
435
|
+
"name": "getAncestors",
|
|
436
|
+
"async": true,
|
|
437
|
+
"returns": "Promise"
|
|
438
|
+
},
|
|
439
|
+
{
|
|
440
|
+
"name": "getChildren",
|
|
441
|
+
"async": true,
|
|
442
|
+
"returns": "Promise"
|
|
443
|
+
},
|
|
444
|
+
{
|
|
445
|
+
"name": "getDescendants",
|
|
446
|
+
"async": true,
|
|
447
|
+
"returns": "Promise"
|
|
448
|
+
},
|
|
449
|
+
{
|
|
450
|
+
"name": "getHierarchy",
|
|
451
|
+
"async": true,
|
|
452
|
+
"returns": "Promise<HierarchyView>"
|
|
453
|
+
},
|
|
454
|
+
{
|
|
455
|
+
"name": "getParent",
|
|
456
|
+
"async": true,
|
|
457
|
+
"returns": "Promise<null>"
|
|
458
|
+
},
|
|
459
|
+
{
|
|
460
|
+
"name": "moveTo",
|
|
461
|
+
"async": true,
|
|
462
|
+
"params": [
|
|
463
|
+
"newParent: string | null"
|
|
464
|
+
],
|
|
465
|
+
"returns": "Promise<void>"
|
|
466
|
+
}
|
|
467
|
+
],
|
|
183
468
|
"surfaces": [],
|
|
184
469
|
"relationshipFeatures": [],
|
|
185
470
|
"tags": [],
|
|
@@ -200,6 +485,56 @@
|
|
|
200
485
|
"detach",
|
|
201
486
|
"setLinks"
|
|
202
487
|
],
|
|
488
|
+
"methodSignatures": [
|
|
489
|
+
{
|
|
490
|
+
"name": "attach",
|
|
491
|
+
"async": true,
|
|
492
|
+
"params": [
|
|
493
|
+
"leftId: string",
|
|
494
|
+
"rightId: string",
|
|
495
|
+
"opts?: JunctionAttachOptions"
|
|
496
|
+
],
|
|
497
|
+
"returns": "Promise<TItem>"
|
|
498
|
+
},
|
|
499
|
+
{
|
|
500
|
+
"name": "byLeft",
|
|
501
|
+
"async": true,
|
|
502
|
+
"params": [
|
|
503
|
+
"leftId: string",
|
|
504
|
+
"opts?: JunctionFilterOptions"
|
|
505
|
+
],
|
|
506
|
+
"returns": "Promise<TItem[]>"
|
|
507
|
+
},
|
|
508
|
+
{
|
|
509
|
+
"name": "byRight",
|
|
510
|
+
"async": true,
|
|
511
|
+
"params": [
|
|
512
|
+
"rightId: string",
|
|
513
|
+
"opts?: JunctionFilterOptions"
|
|
514
|
+
],
|
|
515
|
+
"returns": "Promise<TItem[]>"
|
|
516
|
+
},
|
|
517
|
+
{
|
|
518
|
+
"name": "detach",
|
|
519
|
+
"async": true,
|
|
520
|
+
"params": [
|
|
521
|
+
"leftId: string",
|
|
522
|
+
"rightId: string",
|
|
523
|
+
"opts?: JunctionFilterOptions"
|
|
524
|
+
],
|
|
525
|
+
"returns": "Promise<void>"
|
|
526
|
+
},
|
|
527
|
+
{
|
|
528
|
+
"name": "setLinks",
|
|
529
|
+
"async": true,
|
|
530
|
+
"params": [
|
|
531
|
+
"leftId: string",
|
|
532
|
+
"rightIds: string[]",
|
|
533
|
+
"opts?: JunctionAttachOptions"
|
|
534
|
+
],
|
|
535
|
+
"returns": "Promise<void>"
|
|
536
|
+
}
|
|
537
|
+
],
|
|
203
538
|
"surfaces": [],
|
|
204
539
|
"relationshipFeatures": [],
|
|
205
540
|
"tags": [],
|
|
@@ -265,6 +600,244 @@
|
|
|
265
600
|
"toPlainObject",
|
|
266
601
|
"toPublicJSON"
|
|
267
602
|
],
|
|
603
|
+
"methodSignatures": [
|
|
604
|
+
{
|
|
605
|
+
"name": "_setLoadedRelationship",
|
|
606
|
+
"params": [
|
|
607
|
+
"fieldName: string",
|
|
608
|
+
"value: any"
|
|
609
|
+
],
|
|
610
|
+
"returns": "void"
|
|
611
|
+
},
|
|
612
|
+
{
|
|
613
|
+
"name": "classifyConstraintError",
|
|
614
|
+
"static": true,
|
|
615
|
+
"params": [
|
|
616
|
+
"message: string"
|
|
617
|
+
],
|
|
618
|
+
"returns": "'unique' | 'not_null' | null"
|
|
619
|
+
},
|
|
620
|
+
{
|
|
621
|
+
"name": "clearEmbeddings",
|
|
622
|
+
"async": true,
|
|
623
|
+
"returns": "Promise<void>"
|
|
624
|
+
},
|
|
625
|
+
{
|
|
626
|
+
"name": "delete",
|
|
627
|
+
"async": true,
|
|
628
|
+
"returns": "Promise<void>"
|
|
629
|
+
},
|
|
630
|
+
{
|
|
631
|
+
"name": "describe",
|
|
632
|
+
"async": true,
|
|
633
|
+
"params": [
|
|
634
|
+
"options?: AiOperationOptions"
|
|
635
|
+
],
|
|
636
|
+
"returns": "any"
|
|
637
|
+
},
|
|
638
|
+
{
|
|
639
|
+
"name": "do",
|
|
640
|
+
"async": true,
|
|
641
|
+
"params": [
|
|
642
|
+
"instructions: string",
|
|
643
|
+
"options?: AiOperationOptions"
|
|
644
|
+
],
|
|
645
|
+
"returns": "any"
|
|
646
|
+
},
|
|
647
|
+
{
|
|
648
|
+
"name": "executeToolCall",
|
|
649
|
+
"async": true,
|
|
650
|
+
"params": [
|
|
651
|
+
"toolCall: ToolCall"
|
|
652
|
+
],
|
|
653
|
+
"returns": "Promise<ToolCallResult>"
|
|
654
|
+
},
|
|
655
|
+
{
|
|
656
|
+
"name": "forget",
|
|
657
|
+
"async": true,
|
|
658
|
+
"params": [
|
|
659
|
+
"options: object"
|
|
660
|
+
],
|
|
661
|
+
"returns": "Promise<void>"
|
|
662
|
+
},
|
|
663
|
+
{
|
|
664
|
+
"name": "forgetScope",
|
|
665
|
+
"async": true,
|
|
666
|
+
"params": [
|
|
667
|
+
"options: object"
|
|
668
|
+
],
|
|
669
|
+
"returns": "Promise<number>"
|
|
670
|
+
},
|
|
671
|
+
{
|
|
672
|
+
"name": "generateEmbeddings",
|
|
673
|
+
"async": true,
|
|
674
|
+
"params": [
|
|
675
|
+
"options?: GenerateEmbeddingsOptions"
|
|
676
|
+
],
|
|
677
|
+
"returns": "Promise<void>"
|
|
678
|
+
},
|
|
679
|
+
{
|
|
680
|
+
"name": "getAvailableTools",
|
|
681
|
+
"returns": "AITool[]"
|
|
682
|
+
},
|
|
683
|
+
{
|
|
684
|
+
"name": "getEmbedding",
|
|
685
|
+
"async": true,
|
|
686
|
+
"params": [
|
|
687
|
+
"fieldName: string",
|
|
688
|
+
"model?: string"
|
|
689
|
+
],
|
|
690
|
+
"returns": "Promise<number[] | null>"
|
|
691
|
+
},
|
|
692
|
+
{
|
|
693
|
+
"name": "getFields",
|
|
694
|
+
"async": true,
|
|
695
|
+
"returns": "Promise<any>"
|
|
696
|
+
},
|
|
697
|
+
{
|
|
698
|
+
"name": "getId",
|
|
699
|
+
"async": true,
|
|
700
|
+
"returns": "any"
|
|
701
|
+
},
|
|
702
|
+
{
|
|
703
|
+
"name": "getRelated",
|
|
704
|
+
"async": true,
|
|
705
|
+
"params": [
|
|
706
|
+
"fieldName: string",
|
|
707
|
+
"opts?: LoadRelatedOptions"
|
|
708
|
+
],
|
|
709
|
+
"returns": "Promise<any>"
|
|
710
|
+
},
|
|
711
|
+
{
|
|
712
|
+
"name": "getSavedId",
|
|
713
|
+
"async": true,
|
|
714
|
+
"returns": "any"
|
|
715
|
+
},
|
|
716
|
+
{
|
|
717
|
+
"name": "getSlug",
|
|
718
|
+
"async": true,
|
|
719
|
+
"returns": "any"
|
|
720
|
+
},
|
|
721
|
+
{
|
|
722
|
+
"name": "hasStaleEmbeddings",
|
|
723
|
+
"async": true,
|
|
724
|
+
"returns": "Promise<boolean>"
|
|
725
|
+
},
|
|
726
|
+
{
|
|
727
|
+
"name": "initialize",
|
|
728
|
+
"async": true,
|
|
729
|
+
"returns": "Promise"
|
|
730
|
+
},
|
|
731
|
+
{
|
|
732
|
+
"name": "is",
|
|
733
|
+
"async": true,
|
|
734
|
+
"params": [
|
|
735
|
+
"criteria: string",
|
|
736
|
+
"options?: AiOperationOptions"
|
|
737
|
+
],
|
|
738
|
+
"returns": "any"
|
|
739
|
+
},
|
|
740
|
+
{
|
|
741
|
+
"name": "isRelatedLoaded",
|
|
742
|
+
"params": [
|
|
743
|
+
"fieldName: string"
|
|
744
|
+
],
|
|
745
|
+
"returns": "boolean"
|
|
746
|
+
},
|
|
747
|
+
{
|
|
748
|
+
"name": "isSaved",
|
|
749
|
+
"async": true,
|
|
750
|
+
"returns": "any"
|
|
751
|
+
},
|
|
752
|
+
{
|
|
753
|
+
"name": "loadDataFromDb",
|
|
754
|
+
"async": true,
|
|
755
|
+
"params": [
|
|
756
|
+
"data: Record<string>"
|
|
757
|
+
],
|
|
758
|
+
"returns": "any"
|
|
759
|
+
},
|
|
760
|
+
{
|
|
761
|
+
"name": "loadFromId",
|
|
762
|
+
"async": true,
|
|
763
|
+
"returns": "any"
|
|
764
|
+
},
|
|
765
|
+
{
|
|
766
|
+
"name": "loadFromSlug",
|
|
767
|
+
"async": true,
|
|
768
|
+
"returns": "any"
|
|
769
|
+
},
|
|
770
|
+
{
|
|
771
|
+
"name": "loadRelated",
|
|
772
|
+
"async": true,
|
|
773
|
+
"params": [
|
|
774
|
+
"fieldName: string",
|
|
775
|
+
"opts?: LoadRelatedOptions"
|
|
776
|
+
],
|
|
777
|
+
"returns": "Promise<any>"
|
|
778
|
+
},
|
|
779
|
+
{
|
|
780
|
+
"name": "loadRelatedMany",
|
|
781
|
+
"async": true,
|
|
782
|
+
"params": [
|
|
783
|
+
"fieldName: string",
|
|
784
|
+
"opts?: LoadRelatedOptions"
|
|
785
|
+
],
|
|
786
|
+
"returns": "Promise<any[]>"
|
|
787
|
+
},
|
|
788
|
+
{
|
|
789
|
+
"name": "markAsPersisted",
|
|
790
|
+
"returns": "void"
|
|
791
|
+
},
|
|
792
|
+
{
|
|
793
|
+
"name": "recall",
|
|
794
|
+
"async": true,
|
|
795
|
+
"params": [
|
|
796
|
+
"options: object"
|
|
797
|
+
],
|
|
798
|
+
"returns": "Promise"
|
|
799
|
+
},
|
|
800
|
+
{
|
|
801
|
+
"name": "recallAll",
|
|
802
|
+
"async": true,
|
|
803
|
+
"params": [
|
|
804
|
+
"options?: object"
|
|
805
|
+
],
|
|
806
|
+
"returns": "Promise<Map<string>>"
|
|
807
|
+
},
|
|
808
|
+
{
|
|
809
|
+
"name": "remember",
|
|
810
|
+
"async": true,
|
|
811
|
+
"params": [
|
|
812
|
+
"options: object"
|
|
813
|
+
],
|
|
814
|
+
"returns": "Promise<void>"
|
|
815
|
+
},
|
|
816
|
+
{
|
|
817
|
+
"name": "requireInsertOnSave",
|
|
818
|
+
"returns": "void"
|
|
819
|
+
},
|
|
820
|
+
{
|
|
821
|
+
"name": "save",
|
|
822
|
+
"async": true,
|
|
823
|
+
"returns": "any"
|
|
824
|
+
},
|
|
825
|
+
{
|
|
826
|
+
"name": "toJSON",
|
|
827
|
+
"returns": "any"
|
|
828
|
+
},
|
|
829
|
+
{
|
|
830
|
+
"name": "toPlainObject",
|
|
831
|
+
"returns": "Record<string>"
|
|
832
|
+
},
|
|
833
|
+
{
|
|
834
|
+
"name": "toPublicJSON",
|
|
835
|
+
"params": [
|
|
836
|
+
"options?: PublicJsonOptions"
|
|
837
|
+
],
|
|
838
|
+
"returns": "Record<string>"
|
|
839
|
+
}
|
|
840
|
+
],
|
|
268
841
|
"surfaces": [],
|
|
269
842
|
"relationshipFeatures": [
|
|
270
843
|
"uuidColumns"
|
|
@@ -297,13 +870,21 @@
|
|
|
297
870
|
{
|
|
298
871
|
"name": "sortOrder",
|
|
299
872
|
"type": "integer",
|
|
300
|
-
"required": false
|
|
873
|
+
"required": false,
|
|
874
|
+
"default": 0
|
|
301
875
|
}
|
|
302
876
|
],
|
|
303
877
|
"relationships": [],
|
|
304
878
|
"methods": [
|
|
305
879
|
"hydrate"
|
|
306
880
|
],
|
|
881
|
+
"methodSignatures": [
|
|
882
|
+
{
|
|
883
|
+
"name": "hydrate",
|
|
884
|
+
"async": true,
|
|
885
|
+
"returns": "Promise<T | null>"
|
|
886
|
+
}
|
|
887
|
+
],
|
|
307
888
|
"surfaces": [],
|
|
308
889
|
"relationshipFeatures": [
|
|
309
890
|
"SmrtPolymorphicAssociation"
|
|
@@ -330,7 +911,7 @@
|
|
|
330
911
|
"polymorphicAssociations": 1,
|
|
331
912
|
"uuidColumns": 3
|
|
332
913
|
},
|
|
333
|
-
"agentDoc": "# @happyvertical/smrt-core\n\nORM, code generation, AI integration, and the DispatchBus. Everything else builds on this.\n\nKey surfaces are `SmrtObject`, `SmrtCollection`, `ObjectRegistry`,\n`DispatchBus`, `GlobalInterceptors`, and `LearningMemory`; this file documents\ntheir invariants and source locations, and the module docs below cover the\nper-subsystem semantics.\n\n## Modules\n\nSubsystem semantics live in sibling module docs — read the one for the\nsubsystem you are editing. This file keeps what holds across all of them.\n\n| Module | Scope | Module doc |\n|---|---|---|\n| `src/change-feed.ts` | the adapter-agnostic change-observation spine — `_smrt_changes`, cursors, table versions, generated `_changes` routes, retention | [agents/change-feed.md](agents/change-feed.md) |\n| `src/change-signals.ts` + the generated `_events` SSE route | the push companion to the change feed — the signal bus, cross-replica fan-out, the SSE route, and its documented gaps | [agents/change-signals.md](agents/change-signals.md) |\n| `src/generators/` + `src/vite-plugin/web-collections.ts` | REST/CLI/MCP/web-collection generation, the `manifestHash` emission sites, and generated conditional-GET / ETag v2 semantics | [agents/generators.md](agents/generators.md) |\n\n## SmrtObject Lifecycle\n\n`constructor(options)` → `initialize()` → ready for `save()`/`delete()`/`loadFromId()`\n\n- `initialize()`: loads field initializers, applies option values (options override initializers), loads from DB if id/slug provided\n- `save()`: upsert with STI validation, interceptor execution, auto-embeddings. Persisted objects (`isPersisted` — set by DB hydration and successful saves) upsert on `['id']` so natural-key edits (e.g. slug renames) update in place; new objects upsert on the natural-key conflict columns for ingestion-style dedup (#1472)\n- `is(criteria)` / `do(instructions)` / `describe()`: AI operations via function calling. They inject the object's own `toPublicJSON()` (sensitive fields stripped) as a \"content body\" so the model reasons over the instance. Options: `includeData: false` skips injection (for callers that already curate the relevant fields into the instruction); `maxDataLength` overrides the truncation budget. Neither key is forwarded to `ai.message()`. (#1567)\n- `getSlug()`: auto-generates from name → title → label → id\n- `loadRelated(fieldName)`: lazy-loads relationships (cached in `_loadedRelationships` Map)\n\n## LearningMemory (#1886)\n\n`LearningMemory` provides tenant-isolated, confidence-scored recall over\n`_smrt_contexts` plus optional injected semantic search. `capture()` reinforces\nsuccesses and decays failures while updating outcome counters; `recall()`\napplies confidence, expiry, time-decay, and hierarchical-scope filters and\nrefreshes `last_used_at`. Keep semantic search behind the\n`SmrtCollection.semanticSearch`-compatible injection boundary.\n\n## SmrtCollection Query\n\n```typescript\nawait collection.list({\n where: { status: 'active', 'price >': 10 },\n limit: 50, offset: 0, orderBy: 'created_at DESC'\n});\n```\n\nProjection primitive (#1902): pass `select: ['id', 'title', 'tenantId']` to\n`list()` when an admin/list workflow needs compact rows. `select` uses SMRT\nfield names, maps them to DB columns internally, and returns plain objects keyed\nby the same SMRT field names without hydrating `SmrtObject` instances. It\ncomposes with `where`, `orderBy`, `limit`, and `offset`; `beforeList`\ninterceptors still run. It is for column-backed fields only and cannot combine\nwith `include`/relationship eager loading.\n\n`list()` and `query()` hydrate model instances serially in result order because\nan `initialize()` hook may query through the same transaction-bound PostgreSQL\nclient. Keep this serialization invariant; use `select` when callers need plain\nrows without model hydration.\n\n**WHERE operators**: `=`, `>`, `<`, `>=`, `<=`, `!=`, `in`, `not in`, `like`.\nArrays auto-detect `IN`. NULL is a value, not an operator: `{ deletedAt: null }`\nrenders `IS NULL` and `{ 'deletedAt !=': null }` renders `IS NOT NULL`.\n\nThis list is the set `@happyvertical/sql`'s `buildWhere` can execute, and\n`convertWhereKeys` accepts nothing outside it — an operator accepted here but\nunknown there fails inside the query builder, after the API said the query was\nvalid (#2276). Two entries were removed for that reason and now reject at the\nAPI boundary: `contains` (never existed in the SQL layer; use `like` with\nexplicit wildcards) and dot-notation JSON paths such as `metadata.userId` (never\nrewritten into an extraction expression, so they reached SQL as qualified column\nreferences). Re-adding either requires the query builder to support it first;\n`src/__tests__/issue-2276-where-contract.test.ts` executes every accepted\noperator against a database to keep the two in step.\n\nSTI child collections auto-filter by `_meta_type`.\n\n## Bounded Collection Read Plans\n\nUse `executeCollectionReadPlan()` when one operation needs several independent\ncollections. It bounds top-level `collection.list()` concurrency while keeping\nall reads on the normal registry/collection path. Callers must choose an\nexplicit positive `maxConcurrency` and pass their normal shared\n`collectionOptions` when database or tenant context matters.\n\nThe executor deliberately does not compose SQL, cache the plan, or change pool\ndefaults. On failure it stops starting queued entries, drains operations already\nin flight, and rethrows the first error.\n\n## Object Memory & Semantic Search\n\nTwo persistence primitives every `SmrtObject`/`SmrtCollection` inherits — load-bearing for learning agents, usable by any object. Full guide: `docs/content/core.md` → \"Context Memory System\".\n\n- **Context memory** (`remember`/`recall`/`recallAll`/`forget`/`forgetScope`, table `_smrt_contexts`): stores any JSON value keyed by `(owner_class, owner_id, scope, key, version)` with a `confidence` score (0–1) and a stored `expiresAt` (metadata — `recall()` does **not** filter expired rows; expiry is caller-managed). `recall()` returns the highest-confidence match with an optional `minConfidence` floor and **opt-in** hierarchical scope fallback (`includeAncestors: true` → `'a/b/c' → 'a/b' → 'a' → 'global'`; default off); `recallAll()` returns a `Map`. Typical use: cache a learned strategy (e.g. a working selector per host) and reuse it across sessions. `success_count`/`failure_count` columns exist for outcome-weighting: `SmrtObject.remember()` leaves them untouched, `SmrtCollection.remember()` resets them to zero, and neither recall path updates them. `LearningMemory` is the layer that maintains them (and that does filter expired rows).\n- **Semantic search** (on `SmrtCollection`, table `_smrt_embeddings`): `semanticSearch(query)`, `findSimilar(object)`, `findSimilarToEmbedding(vector)` — cosine ranking over embeddings of the fields declared in `@smrt({ embeddings })`. Native pgvector/HNSW when configured, in-memory `CosineSimilarity` fallback otherwise; default local model `Xenova/bge-base-en-v1.5` (768-dim) or AI `text-embedding-3-small`. Hits hydrate via `list({ 'id in': … })`, so `@TenantScoped` isolation applies to results.\n\n## @smrt() Decorator Options\n\nKey options: `tableName`, `tableStrategy` ('cti'|'sti'), `conflictColumns`, `api`/`mcp`/`cli` (generation config), `ai` (callable methods), `hooks` (beforeSave/afterSave/beforeDelete/afterDelete), `embeddings` (auto-generate), `tenantScoped`, `agent`, `ui` (`{ icon, label, description }` — nav/help hints round-tripped through the manifest as plain data; `description` is the object-level seed for form-level help, #2046).\n\nRegistration sets `SMRT_TABLE_NAME` static property (survives minification).\n\n## @field() UI hints (#2046)\n\n`@field({ ui: { basic, group, order, locked } })` — a static, presentation-only\nseed for the field-policy rail (epic #2045). Carried in the manifest under the\nfield's `_meta.ui` (never a top-level `FieldDefinition` key), readable at\nruntime via `getAllFields()` at `field._meta.ui`, and emitted (sanitized) with\n`description` into generated web-collection definitions and browser MCP tool\nschemas. No schema/persistence/security effect — `sensitive`/`readPermission`\nstay the security rail, and `sensitive`/`transient` fields never emit to the\nclient at all.\n\n## Domain Knowledge Artifacts\n\n`smrtPlugin()` writes runtime manifests and agent/developer knowledge artifacts:\n\n- local dev/build: `.smrt/manifest.json` and `.smrt/smrt-knowledge.json`\n- package build: `dist/manifest.json` and `dist/smrt-knowledge.json`\n\nKeep `manifest.json` runtime-focused. `smrt-knowledge.json` is the deterministic\nagent contract for downstream review and architecture tools.\n\nConfig precedence for knowledge is defaults → top-level `knowledge` in\n`smrt.config.ts` → `packages[packageName].knowledge` → plugin option →\nobject-level `@smrt({ knowledge })`.\n\nObject-level `knowledge: false` excludes an object from authored context only;\nit must not change runtime manifest registration. Use\n`knowledge: { tags, summary, risks }` for review-sensitive domain objects.\n\nHTTP knowledge routes are disabled by default. If `knowledge.api.enabled` is\ntrue, generated SvelteKit routes must stay GET-only and guarded by dev mode or\nadmin auth.\n\n## DispatchBus\n\n- `emit(signalType, payload, metadata)` → creates persistent Dispatch record\n- `on(pattern, handler)` → in-memory handler (immediate)\n- `subscribe({ signalType, subscriber })` → persistent subscription (survives restarts)\n- `process(subscriberName, handler)` → process pending dispatches\n- Wildcards: `campaign.*` matches `campaign.completed` (single segment only)\n- Tables: `_smrt_dispatch`, `_smrt_dispatch_subscriptions`\n- Status: `pending → processing → completed` (or `failed`)\n\n## Single Table Inheritance (STI)\n\n- Base: `@smrt({ tableStrategy: 'sti' })` — children inherit, share one table\n- Discriminator: `_meta_type` column with qualified names (`@happyvertical/smrt-content:Article`)\n- Child fields: `@meta()` decorator → stored in `_meta_data` JSONB (not as columns)\n- Polymorphic queries: collection loads `_meta_type`, creates correct subclass dynamically\n- Validation: fail-fast on save if `_meta_type` missing or mismatched\n\n## Child Accessors (R10)\n\n`src/child-accessors.ts` installs a consistent `get<FieldName>()` instance method for every `@oneToMany` field at `@smrt()` registration time (e.g. `@oneToMany('OrderItem') items` → `order.getItems()`), delegating to `loadRelatedMany`. Two invariants:\n\n- **Additive** — never overwrites a hand-rolled method of the same name (checks the whole prototype chain). `Profile.getMetadata()` (key-value) and `ProfileRelationship.getTerms()` are preserved.\n- **Runtime-only** — attached to the prototype, invisible to the build-time manifest, so it never leaks into the REST/CLI/MCP surface.\n\nWhen the target declares multiple FKs back to the parent, annotate `@oneToMany(Target, { foreignKey: '<inverseField>' })`; `loadRelatedMany` and the eager `include:` loader both honor it (else first-match).\n\n## Vite Plugin\n\n```typescript\n// vite.config.ts — required for @smrt() decorators (Vite 8+, oxc transform)\nexport default defineConfig({\n oxc: {\n decorator: {\n legacy: true,\n emitDecoratorMetadata: true,\n },\n },\n});\n```\n\nUnder Vite 8 the oxc transform does not honor the pre-Vite-8 `esbuild.tsconfigRaw`\nrecipe (or tsconfig `experimentalDecorators` reached through SvelteKit's\n`extends \"./.svelte-kit/tsconfig.json\"` chain), so that recipe throws\n`SyntaxError: Invalid or unexpected token` on the first SSR request. Configure\ndecorators through `oxc.decorator` instead. Consumers still pinned on vite<8 need\nthe legacy `esbuild.tsconfigRaw` form with `experimentalDecorators: true,\nemitDecoratorMetadata: true`.\n\n## Gotchas\n\n- **Filesystem support is a lazy boundary (#1979)**: `SmrtClass` acquires `options.fs` adapters via `createFilesystemAdapter()` (`src/filesystem-loader.ts`), never a static `@happyvertical/files` import — the files SDK statically pulls @aws-sdk/client-s3 and reaches googleapis, and a static edge here would land it in every downstream SSR bundle. Node/tsx/vite-dev runtimes resolve it on first use; fully-bundled deployments import `@happyvertical/smrt-core/filesystem` at startup. Use `importOptionalDependency()` (`src/lazy-external.ts`) for any similar optional heavyweight dependency.\n- **Never override toJSON()** — handles STI discriminator + meta field extraction. Use `transformJSON()`\n- **Property init order**: TypeScript initializers run first, then `initialize()` applies option values (options win)\n- **No runtime schema creation**: application tables must be prepared explicitly via migrations/tooling; runtime only verifies and fails clearly\n- **Retry logic**: `db.get()` (3 retries, 250ms) and `db.upsert()` (3 retries, 500ms) have built-in retry\n- **Field caching**: `_cachedFields` populated during `Collection.create()` — eliminates async `getFields()` per query\n- **Smart cloning**: arrays/objects shallow-cloned in property init to prevent aliasing (Issue #22)\n- **Table verification cache**: `isTableVerified(dbUrl, tableName)` avoids redundant `tableExists()` calls\n- **Manifest required**: build-time AST scanning creates manifest. Without vitest plugin → \"No field metadata\"\n- **ManifestBuilder fails on scanner errors**: every production manifest path\n must abort before adapting partial scan results. A syntax error or unresolved\n `@smrt()` config spread cannot be allowed to emit a default-open manifest.\n- **Vite plugin loads scanner from `dist/` first**: `src/vite-plugin/import-build-aware.ts` prefers `dist/` when it exists on disk; it only falls back to `src/` on fresh clones. So if you edit `src/scanner/*.ts` or `src/schema/generator.ts` and want those edits reflected in consumer manifest generation, you must rebuild (`pnpm build` or have `pnpm dev` / `pnpm build:watch` running in core). This is intentional — sniffing `.ts` vs `.js` via `import.meta.url` was non-deterministic under tsx and broke 12–13 publishes (#1139).\n- **Bundled registry ownership**: flattened production bundles can rewrite constructor names and make decorator-time stack inference attribute provider code to the consumer. Generated registration repairs identity only from the exact imported constructor plus an explicit package and isolated one-object manifest; never infer ownership from output paths, simple names, or table names. Distinct packages may export the same simple name under qualified keys. The production-consumer gate lives in `packages/bundle-gate/src/__tests__/registry-identity.spec.ts` (#2308).\n",
|
|
914
|
+
"agentDoc": "# @happyvertical/smrt-core\n\nORM, code generation, AI integration, and the DispatchBus. Everything else builds on this.\n\nKey surfaces are `SmrtObject`, `SmrtCollection`, `ObjectRegistry`,\n`DispatchBus`, `GlobalInterceptors`, and `LearningMemory`; this file documents\ntheir invariants and source locations, and the module docs below cover the\nper-subsystem semantics.\n\n## Modules\n\nSubsystem semantics live in sibling module docs — read the one for the\nsubsystem you are editing. This file keeps what holds across all of them.\n\n| Module | Scope | Module doc |\n|---|---|---|\n| `src/change-feed.ts` | the adapter-agnostic change-observation spine — `_smrt_changes`, cursors, table versions, generated `_changes` routes, retention | [agents/change-feed.md](agents/change-feed.md) |\n| `src/change-signals.ts` + the generated `_events` SSE route | the push companion to the change feed — the signal bus, cross-replica fan-out, the SSE route, and its documented gaps | [agents/change-signals.md](agents/change-signals.md) |\n| `src/generators/` + `src/vite-plugin/web-collections.ts` | REST/CLI/MCP/web-collection generation, the `manifestHash` emission sites, and generated conditional-GET / ETag v2 semantics | [agents/generators.md](agents/generators.md) |\n\n## SmrtObject Lifecycle\n\n`constructor(options)` → `initialize()` → ready for `save()`/`delete()`/`loadFromId()`\n\n- `initialize()`: loads field initializers, applies option values (options override initializers), loads from DB if id/slug provided\n- `save()`: upsert with STI validation, interceptor execution, auto-embeddings. Persisted objects (`isPersisted` — set by DB hydration and successful saves) upsert on `['id']` so natural-key edits (e.g. slug renames) update in place; new objects upsert on the natural-key conflict columns for ingestion-style dedup (#1472)\n- `is(criteria)` / `do(instructions)` / `describe()`: AI operations via function calling. They inject the object's own `toPublicJSON()` (sensitive fields stripped) as a \"content body\" so the model reasons over the instance. Options: `includeData: false` skips injection (for callers that already curate the relevant fields into the instruction); `maxDataLength` overrides the truncation budget. Neither key is forwarded to `ai.message()`. (#1567)\n- `getSlug()`: auto-generates from name → title → label → id\n- `loadRelated(fieldName)`: lazy-loads relationships (cached in `_loadedRelationships` Map)\n\n## LearningMemory (#1886)\n\n`LearningMemory` provides tenant-isolated, confidence-scored recall over\n`_smrt_contexts` plus optional injected semantic search. `capture()` reinforces\nsuccesses and decays failures while updating outcome counters; `recall()`\napplies confidence, expiry, time-decay, and hierarchical-scope filters and\nrefreshes `last_used_at`. Keep semantic search behind the\n`SmrtCollection.semanticSearch`-compatible injection boundary.\n\n## SmrtCollection Query\n\n```typescript\nawait collection.list({\n where: { status: 'active', 'price >': 10 },\n limit: 50, offset: 0, orderBy: 'created_at DESC'\n});\n```\n\nProjection primitive (#1902): pass `select: ['id', 'title', 'tenantId']` to\n`list()` when an admin/list workflow needs compact rows. `select` uses SMRT\nfield names, maps them to DB columns internally, and returns plain objects keyed\nby the same SMRT field names without hydrating `SmrtObject` instances. It\ncomposes with `where`, `orderBy`, `limit`, and `offset`; `beforeList`\ninterceptors still run. It is for column-backed fields only and cannot combine\nwith `include`/relationship eager loading.\n\n`list()` and `query()` hydrate model instances serially in result order because\nan `initialize()` hook may query through the same transaction-bound PostgreSQL\nclient. Keep this serialization invariant; use `select` when callers need plain\nrows without model hydration.\n\n**WHERE operators**: `=`, `>`, `<`, `>=`, `<=`, `!=`, `in`, `not in`, `like`.\nArrays auto-detect `IN`. NULL is a value, not an operator: `{ deletedAt: null }`\nrenders `IS NULL` and `{ 'deletedAt !=': null }` renders `IS NOT NULL`.\n\nThis list is the set `@happyvertical/sql`'s `buildWhere` can execute, and\n`convertWhereKeys` accepts nothing outside it — an operator accepted here but\nunknown there fails inside the query builder, after the API said the query was\nvalid (#2276). Two entries were removed for that reason and now reject at the\nAPI boundary: `contains` (never existed in the SQL layer; use `like` with\nexplicit wildcards) and dot-notation JSON paths such as `metadata.userId` (never\nrewritten into an extraction expression, so they reached SQL as qualified column\nreferences). Re-adding either requires the query builder to support it first;\n`src/__tests__/issue-2276-where-contract.test.ts` executes every accepted\noperator against a database to keep the two in step.\n\nSTI child collections auto-filter by `_meta_type`.\n\n## Bounded Collection Read Plans\n\nUse `executeCollectionReadPlan()` when one operation needs several independent\ncollections. It bounds top-level `collection.list()` concurrency while keeping\nall reads on the normal registry/collection path. Callers must choose an\nexplicit positive `maxConcurrency` and pass their normal shared\n`collectionOptions` when database or tenant context matters.\n\nThe executor deliberately does not compose SQL, cache the plan, or change pool\ndefaults. On failure it stops starting queued entries, drains operations already\nin flight, and rethrows the first error.\n\n## Object Memory & Semantic Search\n\nTwo persistence primitives every `SmrtObject`/`SmrtCollection` inherits — load-bearing for learning agents, usable by any object. Full guide: `docs/content/core.md` → \"Context Memory System\".\n\n- **Context memory** (`remember`/`recall`/`recallAll`/`forget`/`forgetScope`, table `_smrt_contexts`): stores any JSON value keyed by `(owner_class, owner_id, scope, key, version)` with a `confidence` score (0–1) and a stored `expiresAt` (metadata — `recall()` does **not** filter expired rows; expiry is caller-managed). `recall()` returns the highest-confidence match with an optional `minConfidence` floor and **opt-in** hierarchical scope fallback (`includeAncestors: true` → `'a/b/c' → 'a/b' → 'a' → 'global'`; default off); `recallAll()` returns a `Map`. Typical use: cache a learned strategy (e.g. a working selector per host) and reuse it across sessions. `success_count`/`failure_count` columns exist for outcome-weighting: `SmrtObject.remember()` leaves them untouched, `SmrtCollection.remember()` resets them to zero, and neither recall path updates them. `LearningMemory` is the layer that maintains them (and that does filter expired rows).\n- **Semantic search** (on `SmrtCollection`, table `_smrt_embeddings`): `semanticSearch(query)`, `findSimilar(object)`, `findSimilarToEmbedding(vector)` — cosine ranking over embeddings of the fields declared in `@smrt({ embeddings })`. Native pgvector/HNSW when configured, in-memory `CosineSimilarity` fallback otherwise; default local model `Xenova/bge-base-en-v1.5` (768-dim) or AI `text-embedding-3-small`. Hits hydrate via `list({ 'id in': … })`, so `@TenantScoped` isolation applies to results.\n\n## @smrt() Decorator Options\n\nKey options: `tableName`, `tableStrategy` ('cti'|'sti'), `conflictColumns`, `api`/`mcp`/`cli` (generation config), `ai` (callable methods), `hooks` (beforeSave/afterSave/beforeDelete/afterDelete), `embeddings` (auto-generate), `tenantScoped`, `agent`, `ui` (`{ icon, label, description }` — nav/help hints round-tripped through the manifest as plain data; `description` is the object-level seed for form-level help, #2046).\n\nRegistration sets `SMRT_TABLE_NAME` static property (survives minification).\n\n## @field() UI hints (#2046)\n\n`@field({ ui: { basic, group, order, locked } })` — a static, presentation-only\nseed for the field-policy rail (epic #2045). Carried in the manifest under the\nfield's `_meta.ui` (never a top-level `FieldDefinition` key), readable at\nruntime via `getAllFields()` at `field._meta.ui`, and emitted (sanitized) with\n`description` into generated web-collection definitions and browser MCP tool\nschemas. No schema/persistence/security effect — `sensitive`/`readPermission`\nstay the security rail, and `sensitive`/`transient` fields never emit to the\nclient at all.\n\n## Domain Knowledge Artifacts\n\n`smrtPlugin()` writes runtime manifests and agent/developer knowledge artifacts:\n\n- local dev/build: `.smrt/manifest.json` and `.smrt/smrt-knowledge.json`\n- package build: `dist/manifest.json` and `dist/smrt-knowledge.json`\n\nKeep `manifest.json` runtime-focused. `smrt-knowledge.json` is the deterministic\nagent contract for downstream review and architecture tools.\n\nThe schema-version-1 object projection is additive and high-signal: it retains\nnormalized tenant mode/field, explicit `cti`/`sti` strategy, conflict columns,\nmethod signatures, and field defaults/constraints/readonly/transient flags.\nSensitive fields are removed before both `fields` and `relationships` are\nderived, including legacy flags stored under `_meta`; matching field and\nsnake-case column names are also removed from projected conflict columns, and a\nsensitive custom tenant field is omitted while retaining scope and mode.\nGenerated artifacts assert this boundary with `sensitiveFieldsExcluded: true`;\nthe optional marker keeps schema version 1 additive while letting readers\nidentify older artifacts that require raw-manifest corroboration.\n\nConfig precedence for knowledge is defaults → top-level `knowledge` in\n`smrt.config.ts` → `packages[packageName].knowledge` → plugin option →\nobject-level `@smrt({ knowledge })`.\n\nObject-level `knowledge: false` excludes an object from authored context only;\nit must not change runtime manifest registration. Use\n`knowledge: { tags, summary, risks }` for review-sensitive domain objects.\n\nHTTP knowledge routes are disabled by default. If `knowledge.api.enabled` is\ntrue, generated SvelteKit routes must stay GET-only and guarded by dev mode or\nadmin auth.\n\n## DispatchBus\n\n- `emit(signalType, payload, metadata)` → creates persistent Dispatch record\n- `on(pattern, handler)` → in-memory handler (immediate)\n- `subscribe({ signalType, subscriber })` → persistent subscription (survives restarts)\n- `process(subscriberName, handler)` → process pending dispatches\n- Wildcards: `campaign.*` matches `campaign.completed` (single segment only)\n- Tables: `_smrt_dispatch`, `_smrt_dispatch_subscriptions`\n- Status: `pending → processing → completed` (or `failed`)\n\n## Single Table Inheritance (STI)\n\n- Base: `@smrt({ tableStrategy: 'sti' })` — children inherit, share one table\n- Discriminator: `_meta_type` column with qualified names (`@happyvertical/smrt-content:Article`)\n- Child fields: `@meta()` decorator → stored in `_meta_data` JSONB (not as columns)\n- Polymorphic queries: collection loads `_meta_type`, creates correct subclass dynamically\n- Validation: fail-fast on save if `_meta_type` missing or mismatched\n\n## Child Accessors (R10)\n\n`src/child-accessors.ts` installs a consistent `get<FieldName>()` instance method for every `@oneToMany` field at `@smrt()` registration time (e.g. `@oneToMany('OrderItem') items` → `order.getItems()`), delegating to `loadRelatedMany`. Two invariants:\n\n- **Additive** — never overwrites a hand-rolled method of the same name (checks the whole prototype chain). `Profile.getMetadata()` (key-value) and `ProfileRelationship.getTerms()` are preserved.\n- **Runtime-only** — attached to the prototype, invisible to the build-time manifest, so it never leaks into the REST/CLI/MCP surface.\n\nWhen the target declares multiple FKs back to the parent, annotate `@oneToMany(Target, { foreignKey: '<inverseField>' })`; `loadRelatedMany` and the eager `include:` loader both honor it (else first-match).\n\n## Vite Plugin\n\n```typescript\n// vite.config.ts — required for @smrt() decorators (Vite 8+, oxc transform)\nexport default defineConfig({\n oxc: {\n decorator: {\n legacy: true,\n emitDecoratorMetadata: true,\n },\n },\n});\n```\n\nUnder Vite 8 the oxc transform does not honor the pre-Vite-8 `esbuild.tsconfigRaw`\nrecipe (or tsconfig `experimentalDecorators` reached through SvelteKit's\n`extends \"./.svelte-kit/tsconfig.json\"` chain), so that recipe throws\n`SyntaxError: Invalid or unexpected token` on the first SSR request. Configure\ndecorators through `oxc.decorator` instead. Consumers still pinned on vite<8 need\nthe legacy `esbuild.tsconfigRaw` form with `experimentalDecorators: true,\nemitDecoratorMetadata: true`.\n\n## Gotchas\n\n- **Filesystem support is a lazy boundary (#1979)**: `SmrtClass` acquires `options.fs` adapters via `createFilesystemAdapter()` (`src/filesystem-loader.ts`), never a static `@happyvertical/files` import — the files SDK statically pulls @aws-sdk/client-s3 and reaches googleapis, and a static edge here would land it in every downstream SSR bundle. Node/tsx/vite-dev runtimes resolve it on first use; fully-bundled deployments import `@happyvertical/smrt-core/filesystem` at startup. Use `importOptionalDependency()` (`src/lazy-external.ts`) for any similar optional heavyweight dependency.\n- **Never override toJSON()** — handles STI discriminator + meta field extraction. Use `transformJSON()`\n- **Property init order**: TypeScript initializers run first, then `initialize()` applies option values (options win)\n- **No runtime schema creation**: application tables must be prepared explicitly via migrations/tooling; runtime only verifies and fails clearly\n- **Retry logic**: `db.get()` (3 retries, 250ms) and `db.upsert()` (3 retries, 500ms) have built-in retry\n- **Field caching**: `_cachedFields` populated during `Collection.create()` — eliminates async `getFields()` per query\n- **Smart cloning**: arrays/objects shallow-cloned in property init to prevent aliasing (Issue #22)\n- **Table verification cache**: `isTableVerified(dbUrl, tableName)` avoids redundant `tableExists()` calls\n- **Manifest required**: build-time AST scanning creates manifest. Without vitest plugin → \"No field metadata\"\n- **ManifestBuilder fails on scanner errors**: every production manifest path\n must abort before adapting partial scan results. A syntax error or unresolved\n `@smrt()` config spread cannot be allowed to emit a default-open manifest.\n- **Vite plugin loads scanner from `dist/` first**: `src/vite-plugin/import-build-aware.ts` prefers `dist/` when it exists on disk; it only falls back to `src/` on fresh clones. So if you edit `src/scanner/*.ts` or `src/schema/generator.ts` and want those edits reflected in consumer manifest generation, you must rebuild (`pnpm build` or have `pnpm dev` / `pnpm build:watch` running in core). This is intentional — sniffing `.ts` vs `.js` via `import.meta.url` was non-deterministic under tsx and broke 12–13 publishes (#1139).\n- **Bundled registry ownership**: flattened production bundles can rewrite constructor names and make decorator-time stack inference attribute provider code to the consumer. Generated registration repairs identity only from the exact imported constructor plus an explicit package and isolated one-object manifest; never infer ownership from output paths, simple names, or table names. Distinct packages may export the same simple name under qualified keys. The production-consumer gate lives in `packages/bundle-gate/src/__tests__/registry-identity.spec.ts` (#2308).\n",
|
|
334
915
|
"moduleDocs": [
|
|
335
916
|
{
|
|
336
917
|
"path": "agents/change-feed.md",
|