@graphrefly/ts 0.0.1 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +197 -117
- package/dist/actions-types-CH-XCU9O.d.cts +657 -0
- package/dist/actions-types-w2iPQTkv.d.ts +657 -0
- package/dist/adapters/index.cjs +5157 -2951
- package/dist/adapters/index.cjs.map +1 -1
- package/dist/adapters/index.d.cts +207 -70
- package/dist/adapters/index.d.ts +207 -70
- package/dist/adapters/index.js +3738 -1688
- package/dist/adapters/index.js.map +1 -1
- package/dist/adapters/nestjs/microservices.cjs +841 -0
- package/dist/adapters/nestjs/microservices.cjs.map +1 -0
- package/dist/adapters/nestjs/microservices.d.cts +45 -0
- package/dist/adapters/nestjs/microservices.d.ts +45 -0
- package/dist/adapters/nestjs/microservices.js +206 -0
- package/dist/adapters/nestjs/microservices.js.map +1 -0
- package/dist/adapters/nestjs/native.cjs +1391 -0
- package/dist/adapters/nestjs/native.cjs.map +1 -0
- package/dist/adapters/nestjs/native.d.cts +111 -0
- package/dist/adapters/nestjs/native.d.ts +111 -0
- package/dist/adapters/nestjs/native.js +577 -0
- package/dist/adapters/nestjs/native.js.map +1 -0
- package/dist/adapters/nestjs/websockets.cjs +924 -0
- package/dist/adapters/nestjs/websockets.cjs.map +1 -0
- package/dist/adapters/nestjs/websockets.d.cts +47 -0
- package/dist/adapters/nestjs/websockets.d.ts +47 -0
- package/dist/adapters/nestjs/websockets.js +286 -0
- package/dist/adapters/nestjs/websockets.js.map +1 -0
- package/dist/adapters/nestjs.cjs +1085 -0
- package/dist/adapters/nestjs.cjs.map +1 -0
- package/dist/adapters/nestjs.d.cts +385 -0
- package/dist/adapters/nestjs.d.ts +385 -0
- package/dist/adapters/nestjs.js +112 -0
- package/dist/adapters/nestjs.js.map +1 -0
- package/dist/adapters/observe-storage.d.cts +3 -3
- package/dist/adapters/observe-storage.d.ts +3 -3
- package/dist/adapters/observe-storage.js +4 -4
- package/dist/adapters/react.cjs.map +1 -1
- package/dist/adapters/react.d.cts +2 -2
- package/dist/adapters/react.d.ts +2 -2
- package/dist/adapters/react.js +1 -1
- package/dist/adapters/solid.cjs.map +1 -1
- package/dist/adapters/solid.d.cts +2 -2
- package/dist/adapters/solid.d.ts +2 -2
- package/dist/adapters/solid.js +1 -1
- package/dist/adapters/svelte.cjs.map +1 -1
- package/dist/adapters/svelte.d.cts +2 -2
- package/dist/adapters/svelte.d.ts +2 -2
- package/dist/adapters/svelte.js +1 -1
- package/dist/adapters/vue.cjs.map +1 -1
- package/dist/adapters/vue.d.cts +2 -2
- package/dist/adapters/vue.d.ts +2 -2
- package/dist/adapters/vue.js +1 -1
- package/dist/{agent-runtime-BesGDZcB.d.ts → agent-runtime-types-core-CKwrBDyi.d.ts} +171 -320
- package/dist/{agent-runtime-DZTJ3C-p.d.cts → agent-runtime-types-core-bfl4m0vM.d.cts} +171 -320
- package/dist/agent-runtime-types-tool-BLPV3azj.d.cts +695 -0
- package/dist/agent-runtime-types-tool-hwqvVqNt.d.ts +695 -0
- package/dist/agentic-memory-retention-CLwI76JK.d.ts +14 -0
- package/dist/agentic-memory-retention-Cz8GR6ie.d.cts +14 -0
- package/dist/{agentic-memory-DfuVZ-lY.d.cts → agentic-memory-types-JDr7MPhh.d.cts} +13 -57
- package/dist/{agentic-memory-BmRCvh0d.d.ts → agentic-memory-types-khYJgzKL.d.ts} +13 -57
- package/dist/{capability-admission-B0BzqAm5.d.cts → capability-admission-B8RNFyaZ.d.cts} +3 -3
- package/dist/{capability-admission-g0mn9hpq.d.ts → capability-admission-Dkw1Xz3r.d.ts} +3 -3
- package/dist/chunk-2KUAG2GZ.js +9693 -0
- package/dist/chunk-2KUAG2GZ.js.map +1 -0
- package/dist/{chunk-CZNV3VXM.js → chunk-3J7UPZL5.js} +11 -11
- package/dist/{chunk-HKK2JD7Z.js → chunk-3LYI6ADX.js} +12 -125
- package/dist/chunk-3LYI6ADX.js.map +1 -0
- package/dist/{chunk-YXMZ2N6J.js → chunk-4M37FH2I.js} +1071 -1025
- package/dist/chunk-4M37FH2I.js.map +1 -0
- package/dist/{chunk-YDSIVHRR.js → chunk-4NWSNI4K.js} +1598 -1584
- package/dist/chunk-4NWSNI4K.js.map +1 -0
- package/dist/{chunk-Z2ANQ6JW.js → chunk-4Q77MMJY.js} +2 -2
- package/dist/{chunk-SS2A464I.js → chunk-54WPEODM.js} +3 -3
- package/dist/chunk-54WPEODM.js.map +1 -0
- package/dist/chunk-6E76H4OU.js +132 -0
- package/dist/chunk-6E76H4OU.js.map +1 -0
- package/dist/chunk-7GOTIIQ7.js +819 -0
- package/dist/chunk-7GOTIIQ7.js.map +1 -0
- package/dist/{chunk-V7CIJE4B.js → chunk-DKFWDTVY.js} +92 -9
- package/dist/chunk-DKFWDTVY.js.map +1 -0
- package/dist/{chunk-FBUU43PM.js → chunk-E4QCH32M.js} +448 -446
- package/dist/chunk-E4QCH32M.js.map +1 -0
- package/dist/{chunk-XKXWK2KP.js → chunk-GXU6WFEJ.js} +1157 -1021
- package/dist/chunk-GXU6WFEJ.js.map +1 -0
- package/dist/{chunk-K3FXTC3I.js → chunk-HJACH5PU.js} +3 -3
- package/dist/{chunk-GTPCOEOZ.js → chunk-IDMLXLLG.js} +3 -3
- package/dist/{chunk-DKP56CSW.js → chunk-JKAYLDQV.js} +2 -2
- package/dist/{chunk-4VLAQHZI.js → chunk-K7FB3JTD.js} +17 -1
- package/dist/chunk-K7FB3JTD.js.map +1 -0
- package/dist/{chunk-43BKLFZU.js → chunk-KFURM6FM.js} +10 -10
- package/dist/{chunk-H75VXTGT.js → chunk-L6LDXRWE.js} +3 -3
- package/dist/{chunk-H75VXTGT.js.map → chunk-L6LDXRWE.js.map} +1 -1
- package/dist/chunk-MCOFHMUU.js +4131 -0
- package/dist/chunk-MCOFHMUU.js.map +1 -0
- package/dist/chunk-MQEQMS7B.js +1009 -0
- package/dist/chunk-MQEQMS7B.js.map +1 -0
- package/dist/chunk-MTELVIYR.js +1421 -0
- package/dist/chunk-MTELVIYR.js.map +1 -0
- package/dist/{chunk-3JR3EDB2.js → chunk-NNDIFUKX.js} +121 -115
- package/dist/chunk-NNDIFUKX.js.map +1 -0
- package/dist/{chunk-2747WN4Y.js → chunk-PUSRRALM.js} +3 -3
- package/dist/{chunk-QFY4AFY4.js → chunk-PVC7WDKI.js} +58 -52
- package/dist/chunk-PVC7WDKI.js.map +1 -0
- package/dist/{chunk-VTHLCFN4.js → chunk-RAHNUYA5.js} +2 -2
- package/dist/chunk-TQPCAIQI.js +612 -0
- package/dist/chunk-TQPCAIQI.js.map +1 -0
- package/dist/{chunk-IXZBUWSP.js → chunk-UEMN5URK.js} +2 -2
- package/dist/chunk-WOS7RJYZ.js +1320 -0
- package/dist/chunk-WOS7RJYZ.js.map +1 -0
- package/dist/{chunk-6PHB5CJS.js → chunk-ZLFRB6FI.js} +2 -2
- package/dist/composition/index.cjs +1228 -1076
- package/dist/composition/index.cjs.map +1 -1
- package/dist/composition/index.d.cts +3 -3
- package/dist/composition/index.d.ts +3 -3
- package/dist/composition/index.js +4 -4
- package/dist/core/index.cjs +1198 -1046
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +23 -2
- package/dist/core/index.d.ts +23 -2
- package/dist/core/index.js +2 -2
- package/dist/cqrs/index.d.cts +3 -3
- package/dist/cqrs/index.d.ts +3 -3
- package/dist/cqrs/messaging.d.cts +4 -4
- package/dist/cqrs/messaging.d.ts +4 -4
- package/dist/cqrs/work-queue.d.cts +5 -5
- package/dist/cqrs/work-queue.d.ts +5 -5
- package/dist/data-structures/index.cjs +1226 -1074
- package/dist/data-structures/index.cjs.map +1 -1
- package/dist/data-structures/index.d.cts +8 -7
- package/dist/data-structures/index.d.ts +8 -7
- package/dist/data-structures/index.js +6 -5
- package/dist/{describe-DYMw_l1C.d.cts → describe-BumQ-3_0.d.cts} +1 -1
- package/dist/{describe-BpyJuWkw.d.ts → describe-cYr_Z5zm.d.ts} +1 -1
- package/dist/executors/tool-provider-adapters.cjs +3091 -0
- package/dist/executors/tool-provider-adapters.cjs.map +1 -0
- package/dist/executors/tool-provider-adapters.d.cts +174 -0
- package/dist/executors/tool-provider-adapters.d.ts +174 -0
- package/dist/executors/tool-provider-adapters.js +1336 -0
- package/dist/executors/tool-provider-adapters.js.map +1 -0
- package/dist/executors/tool-provider-runtime.cjs +5178 -0
- package/dist/executors/tool-provider-runtime.cjs.map +1 -0
- package/dist/executors/tool-provider-runtime.d.cts +17 -0
- package/dist/executors/tool-provider-runtime.d.ts +17 -0
- package/dist/executors/tool-provider-runtime.js +15 -0
- package/dist/executors/tool-provider-runtime.js.map +1 -0
- package/dist/executors/tool-provider.cjs +6392 -0
- package/dist/executors/tool-provider.cjs.map +1 -0
- package/dist/executors/tool-provider.d.cts +60 -0
- package/dist/executors/tool-provider.d.ts +60 -0
- package/dist/executors/tool-provider.js +89 -0
- package/dist/executors/tool-provider.js.map +1 -0
- package/dist/executors/work-queue.d.cts +6 -6
- package/dist/executors/work-queue.d.ts +6 -6
- package/dist/graph/index.cjs +1499 -1341
- package/dist/graph/index.cjs.map +1 -1
- package/dist/graph/index.d.cts +9 -8
- package/dist/graph/index.d.ts +9 -8
- package/dist/graph/index.js +23 -22
- package/dist/{graph-DCEWh4T2.d.cts → graph-C1C-wb0L.d.cts} +266 -137
- package/dist/{graph-D-1-SQeC.d.ts → graph-CS0b4V9B.d.ts} +266 -137
- package/dist/{index-72VZC0-E.d.cts → index-DLrNopda.d.cts} +151 -10
- package/dist/{index-Bmxeu0nK.d.ts → index-DzJni3_6.d.ts} +151 -10
- package/dist/index.cjs +3397 -3140
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -9
- package/dist/index.d.ts +12 -9
- package/dist/index.js +110 -109
- package/dist/inspection/boundary.d.cts +4 -4
- package/dist/inspection/boundary.d.ts +4 -4
- package/dist/measurements-BWAnochv.d.ts +294 -0
- package/dist/measurements-B_gJfD8h.d.cts +294 -0
- package/dist/messaging/index.cjs +57 -51
- package/dist/messaging/index.cjs.map +1 -1
- package/dist/messaging/index.d.cts +11 -276
- package/dist/messaging/index.d.ts +11 -276
- package/dist/messaging/index.js +1 -1
- package/dist/operators/index.cjs +1228 -1076
- package/dist/operators/index.cjs.map +1 -1
- package/dist/operators/index.d.cts +5 -5
- package/dist/operators/index.d.ts +5 -5
- package/dist/operators/index.js +5 -5
- package/dist/orchestration/index.cjs +8844 -6071
- package/dist/orchestration/index.cjs.map +1 -1
- package/dist/orchestration/index.d.cts +171 -224
- package/dist/orchestration/index.d.ts +171 -224
- package/dist/orchestration/index.js +42 -991
- package/dist/orchestration/index.js.map +1 -1
- package/dist/orchestration/messaging.d.cts +5 -8
- package/dist/orchestration/messaging.d.ts +5 -8
- package/dist/orchestration/work-queue.cjs +1243 -5
- package/dist/orchestration/work-queue.cjs.map +1 -1
- package/dist/orchestration/work-queue.d.cts +121 -10
- package/dist/orchestration/work-queue.d.ts +121 -10
- package/dist/orchestration/work-queue.js +1067 -4
- package/dist/orchestration/work-queue.js.map +1 -1
- package/dist/patterns/event-flow.cjs +6 -20
- package/dist/patterns/event-flow.cjs.map +1 -1
- package/dist/patterns/event-flow.d.cts +4 -4
- package/dist/patterns/event-flow.d.ts +4 -4
- package/dist/patterns/event-flow.js +2 -2
- package/dist/patterns/index.cjs +453 -465
- package/dist/patterns/index.cjs.map +1 -1
- package/dist/patterns/index.d.cts +6 -5
- package/dist/patterns/index.d.ts +6 -5
- package/dist/patterns/index.js +3 -3
- package/dist/process-types-BB7oRhX3.d.cts +200 -0
- package/dist/process-types-QNhyoYJ8.d.ts +200 -0
- package/dist/{reactive-collection-DNV0-gFi.d.cts → reactive-collection-BYlWvtnp.d.cts} +4 -34
- package/dist/{reactive-collection-BAmfrGjd.d.ts → reactive-collection-efOEdGFN.d.ts} +4 -34
- package/dist/{reactive-collection-storage-BNEldDyi.d.cts → reactive-collection-storage-BjoLsoiC.d.cts} +5 -5
- package/dist/{reactive-collection-storage-YZsAQsWK.d.ts → reactive-collection-storage-DwW6UuK_.d.ts} +5 -5
- package/dist/{reactive-map-DRD1LJ2H.d.cts → reactive-map-BHacbIqz.d.cts} +7 -2
- package/dist/{reactive-map-EsDiCmJk.d.ts → reactive-map-DN4Jyqnf.d.ts} +7 -2
- package/dist/render/index.d.cts +2 -2
- package/dist/render/index.d.ts +2 -2
- package/dist/scheduled-readiness-BmqXxnzX.d.ts +91 -0
- package/dist/scheduled-readiness-CYSw7KDE.d.cts +91 -0
- package/dist/semantic-memory-graph-B_LwbM-E.d.cts +30 -0
- package/dist/semantic-memory-graph-rsFNNhwn.d.ts +30 -0
- package/dist/{semantic-memory-graph-DKuNzuWw.d.cts → semantic-memory-graph-types-Y73bbwVI.d.cts} +2 -28
- package/dist/{semantic-memory-graph-uwbwJdhe.d.ts → semantic-memory-graph-types-safmPkuX.d.ts} +2 -28
- package/dist/solutions/index.cjs +6353 -6169
- package/dist/solutions/index.cjs.map +1 -1
- package/dist/solutions/index.d.cts +12 -10
- package/dist/solutions/index.d.ts +12 -10
- package/dist/solutions/index.js +5 -5
- package/dist/solutions/reactive-layout/browser/index.cjs +116 -108
- package/dist/solutions/reactive-layout/browser/index.cjs.map +1 -1
- package/dist/solutions/reactive-layout/browser/index.d.cts +4 -4
- package/dist/solutions/reactive-layout/browser/index.d.ts +4 -4
- package/dist/solutions/reactive-layout/browser/index.js +3 -3
- package/dist/solutions/reactive-layout/index.cjs +3578 -3350
- package/dist/solutions/reactive-layout/index.cjs.map +1 -1
- package/dist/solutions/reactive-layout/index.d.cts +32 -576
- package/dist/solutions/reactive-layout/index.d.ts +32 -576
- package/dist/solutions/reactive-layout/index.js +65 -5
- package/dist/solutions/reactive-layout/node-canvas/index.cjs +127 -117
- package/dist/solutions/reactive-layout/node-canvas/index.cjs.map +1 -1
- package/dist/solutions/reactive-layout/node-canvas/index.d.cts +4 -4
- package/dist/solutions/reactive-layout/node-canvas/index.d.ts +4 -4
- package/dist/solutions/reactive-layout/node-canvas/index.js +3 -3
- package/dist/solutions/reactive-layout/react-native/index.cjs +127 -117
- package/dist/solutions/reactive-layout/react-native/index.cjs.map +1 -1
- package/dist/solutions/reactive-layout/react-native/index.d.cts +4 -4
- package/dist/solutions/reactive-layout/react-native/index.d.ts +4 -4
- package/dist/solutions/reactive-layout/react-native/index.js +3 -3
- package/dist/solutions/reactive-layout/skia/index.cjs +127 -117
- package/dist/solutions/reactive-layout/skia/index.cjs.map +1 -1
- package/dist/solutions/reactive-layout/skia/index.d.cts +4 -4
- package/dist/solutions/reactive-layout/skia/index.d.ts +4 -4
- package/dist/solutions/reactive-layout/skia/index.js +3 -3
- package/dist/solutions/work-item/actions.cjs +1609 -1428
- package/dist/solutions/work-item/actions.cjs.map +1 -1
- package/dist/solutions/work-item/actions.d.cts +23 -184
- package/dist/solutions/work-item/actions.d.ts +23 -184
- package/dist/solutions/work-item/actions.js +1558 -934
- package/dist/solutions/work-item/actions.js.map +1 -1
- package/dist/solutions/work-item/scheduling.cjs +9181 -1838
- package/dist/solutions/work-item/scheduling.cjs.map +1 -1
- package/dist/solutions/work-item/scheduling.d.cts +1763 -328
- package/dist/solutions/work-item/scheduling.d.ts +1763 -328
- package/dist/solutions/work-item/scheduling.js +117 -3
- package/dist/solutions/work-item/work-queue.d.cts +7 -7
- package/dist/solutions/work-item/work-queue.d.ts +7 -7
- package/dist/sources/browser.cjs +1318 -1083
- package/dist/sources/browser.cjs.map +1 -1
- package/dist/sources/browser.d.cts +22 -6
- package/dist/sources/browser.d.ts +22 -6
- package/dist/sources/browser.js +4 -4
- package/dist/sources/browser.js.map +1 -1
- package/dist/sources/index.cjs +1318 -1083
- package/dist/sources/index.cjs.map +1 -1
- package/dist/sources/index.d.cts +4 -4
- package/dist/sources/index.d.ts +4 -4
- package/dist/sources/index.js +4 -4
- package/dist/sources/node.d.cts +3 -3
- package/dist/sources/node.d.ts +3 -3
- package/dist/storage/browser.cjs +16 -0
- package/dist/storage/browser.cjs.map +1 -1
- package/dist/storage/browser.js +3 -3
- package/dist/storage/index.cjs +16 -0
- package/dist/storage/index.cjs.map +1 -1
- package/dist/storage/index.d.cts +5 -4
- package/dist/storage/index.d.ts +5 -4
- package/dist/storage/index.js +6 -6
- package/dist/storage/node.cjs +16 -0
- package/dist/storage/node.cjs.map +1 -1
- package/dist/storage/node.js +3 -3
- package/dist/{store-C-joM4gh.d.ts → store-6_CHF6Ge.d.ts} +1 -1
- package/dist/{store-CNJwmT-h.d.cts → store-BljX8RkQ.d.cts} +1 -1
- package/dist/types-BAw2QVVE.d.cts +274 -0
- package/dist/types-BUbbbh4f.d.cts +34 -0
- package/dist/types-CMnzoL54.d.cts +457 -0
- package/dist/{types-CcPIn7sy.d.cts → types-CTN3XoMl.d.cts} +57 -108
- package/dist/types-CV_ohy5T.d.cts +357 -0
- package/dist/{types-BsJvElYZ.d.ts → types-DChxk1vK.d.ts} +57 -108
- package/dist/types-DRu7SnLV.d.ts +274 -0
- package/dist/types-DeID_FRl.d.ts +34 -0
- package/dist/types-IhKH0hGW.d.ts +357 -0
- package/dist/types-ePlD2uyT.d.ts +457 -0
- package/dist/{work-item-runtime-qaVgsL0T.d.cts → work-item-runtime-types-BTxLskN5.d.cts} +3 -93
- package/dist/{work-item-runtime-C3M79vE9.d.ts → work-item-runtime-types-DAsZbb2y.d.ts} +3 -93
- package/dist/work-queue/index.cjs +957 -953
- package/dist/work-queue/index.cjs.map +1 -1
- package/dist/work-queue/index.d.cts +9 -357
- package/dist/work-queue/index.d.ts +9 -357
- package/dist/work-queue/index.js +957 -953
- package/dist/work-queue/index.js.map +1 -1
- package/package.json +611 -513
- package/dist/chunk-3JR3EDB2.js.map +0 -1
- package/dist/chunk-4VLAQHZI.js.map +0 -1
- package/dist/chunk-6XAIOL3X.js +0 -2407
- package/dist/chunk-6XAIOL3X.js.map +0 -1
- package/dist/chunk-FBUU43PM.js.map +0 -1
- package/dist/chunk-HKK2JD7Z.js.map +0 -1
- package/dist/chunk-PC3BTTBE.js +0 -3217
- package/dist/chunk-PC3BTTBE.js.map +0 -1
- package/dist/chunk-QFY4AFY4.js.map +0 -1
- package/dist/chunk-SS2A464I.js.map +0 -1
- package/dist/chunk-V7CIJE4B.js.map +0 -1
- package/dist/chunk-XKXWK2KP.js.map +0 -1
- package/dist/chunk-YDSIVHRR.js.map +0 -1
- package/dist/chunk-YXMZ2N6J.js.map +0 -1
- /package/dist/{chunk-CZNV3VXM.js.map → chunk-3J7UPZL5.js.map} +0 -0
- /package/dist/{chunk-Z2ANQ6JW.js.map → chunk-4Q77MMJY.js.map} +0 -0
- /package/dist/{chunk-K3FXTC3I.js.map → chunk-HJACH5PU.js.map} +0 -0
- /package/dist/{chunk-GTPCOEOZ.js.map → chunk-IDMLXLLG.js.map} +0 -0
- /package/dist/{chunk-DKP56CSW.js.map → chunk-JKAYLDQV.js.map} +0 -0
- /package/dist/{chunk-43BKLFZU.js.map → chunk-KFURM6FM.js.map} +0 -0
- /package/dist/{chunk-2747WN4Y.js.map → chunk-PUSRRALM.js.map} +0 -0
- /package/dist/{chunk-VTHLCFN4.js.map → chunk-RAHNUYA5.js.map} +0 -0
- /package/dist/{chunk-IXZBUWSP.js.map → chunk-UEMN5URK.js.map} +0 -0
- /package/dist/{chunk-6PHB5CJS.js.map → chunk-ZLFRB6FI.js.map} +0 -0
package/dist/patterns/index.cjs
CHANGED
|
@@ -55,7 +55,12 @@ function depLatest(ctx, depIndex) {
|
|
|
55
55
|
return ctx[CTX_DEP_CACHE]?.latest[depIndex];
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
// src/messaging/
|
|
58
|
+
// src/messaging/utils.ts
|
|
59
|
+
function isObjectRecord(value) {
|
|
60
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// src/messaging/event-message.ts
|
|
59
64
|
function eventMessageIssue(value) {
|
|
60
65
|
if (!isObjectRecord(value)) {
|
|
61
66
|
return eventIssue("event message must be an object");
|
|
@@ -80,25 +85,6 @@ function eventIssue(message) {
|
|
|
80
85
|
source: "messageBus.eventMessage"
|
|
81
86
|
};
|
|
82
87
|
}
|
|
83
|
-
var PROMPTS_TOPIC = "prompts";
|
|
84
|
-
var RESPONSES_TOPIC = "responses";
|
|
85
|
-
var INJECTIONS_TOPIC = "injections";
|
|
86
|
-
var DEFERRED_TOPIC = "deferred";
|
|
87
|
-
var SPAWNS_TOPIC = "spawns";
|
|
88
|
-
var CONTEXT_TOPIC = "context";
|
|
89
|
-
var TODOS_TOPIC = "todos";
|
|
90
|
-
var STANDARD_TOPICS = Object.freeze([
|
|
91
|
-
PROMPTS_TOPIC,
|
|
92
|
-
RESPONSES_TOPIC,
|
|
93
|
-
INJECTIONS_TOPIC,
|
|
94
|
-
DEFERRED_TOPIC,
|
|
95
|
-
SPAWNS_TOPIC,
|
|
96
|
-
CONTEXT_TOPIC,
|
|
97
|
-
TODOS_TOPIC
|
|
98
|
-
]);
|
|
99
|
-
function isObjectRecord(value) {
|
|
100
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
101
|
-
}
|
|
102
88
|
|
|
103
89
|
// src/patterns/event-flow.ts
|
|
104
90
|
function eventFlow(graph, opts) {
|
|
@@ -624,466 +610,158 @@ function scoreAtLeast(score, min) {
|
|
|
624
610
|
return Number.isFinite(score) && score >= min;
|
|
625
611
|
}
|
|
626
612
|
|
|
627
|
-
// src/patterns/semantic-memory-graph.ts
|
|
628
|
-
function
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
const rawQuery = depLatest(ctx, 1);
|
|
638
|
-
const queryValidation = validateMemoryRetrievalQuery(rawQuery);
|
|
639
|
-
const currentQuery = queryValidation.query;
|
|
640
|
-
const valid = [];
|
|
641
|
-
const seenIds = /* @__PURE__ */ new Set();
|
|
642
|
-
const errors = [...queryValidation.errors];
|
|
643
|
-
if (!Array.isArray(rawFragments)) {
|
|
644
|
-
errors.push({
|
|
645
|
-
code: "invalid-fragments-input",
|
|
646
|
-
message: "memoryRetrievalBundle: fragments input must be an array",
|
|
647
|
-
fragment: rawFragments
|
|
648
|
-
});
|
|
649
|
-
} else {
|
|
650
|
-
const length = safeArrayLength(rawFragments);
|
|
651
|
-
if (length === void 0) {
|
|
652
|
-
errors.push({
|
|
653
|
-
code: "invalid-fragments-input",
|
|
654
|
-
message: "memoryRetrievalBundle: fragments input length could not be read",
|
|
655
|
-
fragment: rawFragments
|
|
656
|
-
});
|
|
613
|
+
// src/patterns/semantic-memory-graph-utils.ts
|
|
614
|
+
function validateKnowledgeGraphPolicy(value) {
|
|
615
|
+
if (value === void 0) return { policy: void 0, errors: [] };
|
|
616
|
+
if (!isPlainObject(value)) {
|
|
617
|
+
return {
|
|
618
|
+
errors: [
|
|
619
|
+
{
|
|
620
|
+
code: "invalid-policy",
|
|
621
|
+
message: "knowledgeGraphReducerBundle: policy must be an object",
|
|
622
|
+
assertion: value
|
|
657
623
|
}
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
624
|
+
]
|
|
625
|
+
};
|
|
626
|
+
}
|
|
627
|
+
const errors = [];
|
|
628
|
+
const policy = value;
|
|
629
|
+
if (policy.allowedPredicates !== void 0 && !isDenseArrayOf2(policy.allowedPredicates, (item) => typeof item === "string")) {
|
|
630
|
+
errors.push("allowedPredicates must be a readonly string array");
|
|
631
|
+
}
|
|
632
|
+
if (policy.requireEntityTypes !== void 0 && typeof policy.requireEntityTypes !== "boolean") {
|
|
633
|
+
errors.push("requireEntityTypes must be a boolean when present");
|
|
634
|
+
}
|
|
635
|
+
if (errors.length > 0) {
|
|
636
|
+
return {
|
|
637
|
+
errors: [
|
|
638
|
+
{
|
|
639
|
+
code: "invalid-policy",
|
|
640
|
+
message: "knowledgeGraphReducerBundle: policy is invalid",
|
|
641
|
+
assertion: value,
|
|
642
|
+
validationErrors: Object.freeze(errors)
|
|
677
643
|
}
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
644
|
+
]
|
|
645
|
+
};
|
|
646
|
+
}
|
|
647
|
+
return {
|
|
648
|
+
policy: Object.freeze({
|
|
649
|
+
...policy.allowedPredicates === void 0 ? {} : { allowedPredicates: Object.freeze([...policy.allowedPredicates]) },
|
|
650
|
+
...policy.requireEntityTypes === void 0 ? {} : { requireEntityTypes: policy.requireEntityTypes }
|
|
651
|
+
}),
|
|
652
|
+
errors: []
|
|
653
|
+
};
|
|
654
|
+
}
|
|
655
|
+
function reduceKnowledgeAssertions(value, policy) {
|
|
656
|
+
const assertions = [];
|
|
657
|
+
const errors = [];
|
|
658
|
+
const seenAssertions = /* @__PURE__ */ new Set();
|
|
659
|
+
if (!Array.isArray(value)) {
|
|
660
|
+
return {
|
|
661
|
+
assertions,
|
|
662
|
+
entities: [],
|
|
663
|
+
relations: [],
|
|
664
|
+
topics: [],
|
|
665
|
+
index: emptyKnowledgeGraphIndex(),
|
|
666
|
+
errors: [
|
|
667
|
+
{
|
|
668
|
+
code: "invalid-assertions-input",
|
|
669
|
+
message: "knowledgeGraphReducerBundle: assertions input must be an array",
|
|
670
|
+
assertion: value
|
|
671
|
+
}
|
|
672
|
+
],
|
|
673
|
+
invalidAssertions: 0
|
|
674
|
+
};
|
|
675
|
+
}
|
|
676
|
+
const length = safeArrayLength(value);
|
|
677
|
+
if (length === void 0) {
|
|
678
|
+
return {
|
|
679
|
+
assertions,
|
|
680
|
+
entities: [],
|
|
681
|
+
relations: [],
|
|
682
|
+
topics: [],
|
|
683
|
+
index: emptyKnowledgeGraphIndex(),
|
|
684
|
+
errors: [
|
|
685
|
+
{
|
|
686
|
+
code: "invalid-assertions-input",
|
|
687
|
+
message: "knowledgeGraphReducerBundle: assertions input length could not be read",
|
|
688
|
+
assertion: value
|
|
689
|
+
}
|
|
690
|
+
],
|
|
691
|
+
invalidAssertions: 0
|
|
692
|
+
};
|
|
693
|
+
}
|
|
694
|
+
for (let i = 0; i < length; i += 1) {
|
|
695
|
+
const result = validateKnowledgeAssertion(value[i], i, policy);
|
|
696
|
+
if (result.error !== void 0) {
|
|
697
|
+
errors.push(result.error);
|
|
698
|
+
continue;
|
|
699
|
+
}
|
|
700
|
+
const assertion = result.assertion;
|
|
701
|
+
if (seenAssertions.has(assertion.id)) {
|
|
702
|
+
errors.push({
|
|
703
|
+
code: "duplicate-assertion-id",
|
|
704
|
+
message: "knowledgeGraphReducerBundle: duplicate assertion id",
|
|
705
|
+
index: i,
|
|
706
|
+
assertionId: assertion.id,
|
|
707
|
+
assertion,
|
|
708
|
+
validationErrors: Object.freeze([`duplicate assertion id '${assertion.id}'`])
|
|
702
709
|
});
|
|
703
|
-
|
|
704
|
-
errors.map(
|
|
705
|
-
(error) => Object.freeze({
|
|
706
|
-
...error,
|
|
707
|
-
...error.validationErrors === void 0 ? {} : { validationErrors: Object.freeze([...error.validationErrors]) },
|
|
708
|
-
cursor
|
|
709
|
-
})
|
|
710
|
-
)
|
|
711
|
-
);
|
|
712
|
-
ctx.down([
|
|
713
|
-
[
|
|
714
|
-
"DATA",
|
|
715
|
-
Object.freeze({
|
|
716
|
-
fragments: Object.freeze([...valid]),
|
|
717
|
-
indexed,
|
|
718
|
-
ranked: answer,
|
|
719
|
-
status,
|
|
720
|
-
errors: errorFacts,
|
|
721
|
-
cursor
|
|
722
|
-
})
|
|
723
|
-
]
|
|
724
|
-
]);
|
|
725
|
-
},
|
|
726
|
-
{
|
|
727
|
-
name: `${name}/snapshot`,
|
|
728
|
-
factory: "memoryRetrievalSnapshot",
|
|
729
|
-
completeWhenDepsComplete: false,
|
|
730
|
-
errorWhenDepsError: false
|
|
710
|
+
continue;
|
|
731
711
|
}
|
|
732
|
-
|
|
712
|
+
seenAssertions.add(assertion.id);
|
|
713
|
+
assertions.push(assertion);
|
|
714
|
+
}
|
|
715
|
+
const materialized = materializeKnowledgeGraph(assertions);
|
|
733
716
|
return {
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
snapshot,
|
|
739
|
-
`${name}/fragments`,
|
|
740
|
-
"memoryRetrievalFragments",
|
|
741
|
-
(fact) => fact.fragments
|
|
742
|
-
),
|
|
743
|
-
indexed: retrievalProjection(
|
|
744
|
-
graph,
|
|
745
|
-
snapshot,
|
|
746
|
-
`${name}/indexed`,
|
|
747
|
-
"memoryRetrievalIndexed",
|
|
748
|
-
(fact) => fact.indexed
|
|
749
|
-
),
|
|
750
|
-
ranked: retrievalProjection(
|
|
751
|
-
graph,
|
|
752
|
-
snapshot,
|
|
753
|
-
`${name}/ranked`,
|
|
754
|
-
"memoryRetrievalRanked",
|
|
755
|
-
(fact) => fact.ranked
|
|
756
|
-
),
|
|
757
|
-
status: retrievalProjection(
|
|
758
|
-
graph,
|
|
759
|
-
snapshot,
|
|
760
|
-
`${name}/status`,
|
|
761
|
-
"memoryRetrievalStatus",
|
|
762
|
-
(fact) => fact.status
|
|
763
|
-
),
|
|
764
|
-
errors: retrievalProjection(
|
|
765
|
-
graph,
|
|
766
|
-
snapshot,
|
|
767
|
-
`${name}/errors`,
|
|
768
|
-
"memoryRetrievalErrors",
|
|
769
|
-
(fact) => fact.errors
|
|
770
|
-
),
|
|
771
|
-
cursor: retrievalProjection(
|
|
772
|
-
graph,
|
|
773
|
-
snapshot,
|
|
774
|
-
`${name}/cursor`,
|
|
775
|
-
"memoryRetrievalCursor",
|
|
776
|
-
(fact) => fact.cursor
|
|
777
|
-
)
|
|
717
|
+
assertions: Object.freeze(assertions),
|
|
718
|
+
...materialized,
|
|
719
|
+
errors,
|
|
720
|
+
invalidAssertions: errors.filter((error) => error.code !== "invalid-policy").length
|
|
778
721
|
};
|
|
779
722
|
}
|
|
780
|
-
function
|
|
781
|
-
const name = opts.name ?? "knowledgeGraph";
|
|
782
|
-
const deps = opts.policy === void 0 ? [opts.assertions] : [opts.assertions, opts.policy];
|
|
783
|
-
const snapshot = graph.node(
|
|
784
|
-
deps,
|
|
785
|
-
(ctx) => {
|
|
786
|
-
const state = ctx.state.get() ?? { evaluation: 0 };
|
|
787
|
-
state.evaluation += 1;
|
|
788
|
-
const policy = validateKnowledgeGraphPolicy(
|
|
789
|
-
opts.policy === void 0 ? void 0 : depLatest(ctx, 1)
|
|
790
|
-
);
|
|
791
|
-
const reduced = reduceKnowledgeAssertions(depLatest(ctx, 0), policy.policy);
|
|
792
|
-
const pendingErrors = [...policy.errors, ...reduced.errors];
|
|
793
|
-
const cursor = Object.freeze({
|
|
794
|
-
evaluation: state.evaluation,
|
|
795
|
-
validAssertions: reduced.assertions.length,
|
|
796
|
-
invalidAssertions: reduced.invalidAssertions,
|
|
797
|
-
entityCount: reduced.entities.length,
|
|
798
|
-
relationCount: reduced.relations.length,
|
|
799
|
-
predicateCount: reduced.topics.length
|
|
800
|
-
});
|
|
801
|
-
const errors = Object.freeze(
|
|
802
|
-
pendingErrors.map(
|
|
803
|
-
(error) => Object.freeze({
|
|
804
|
-
...error,
|
|
805
|
-
...error.validationErrors === void 0 ? {} : { validationErrors: Object.freeze([...error.validationErrors]) },
|
|
806
|
-
cursor
|
|
807
|
-
})
|
|
808
|
-
)
|
|
809
|
-
);
|
|
810
|
-
const status = Object.freeze({
|
|
811
|
-
state: reduced.assertions.length === 0 && errors.length === 0 ? "empty" : errors.length === 0 ? "ready" : reduced.assertions.length > 0 ? "partial" : "error",
|
|
812
|
-
cursor
|
|
813
|
-
});
|
|
814
|
-
ctx.state.set(state);
|
|
815
|
-
ctx.down([
|
|
816
|
-
[
|
|
817
|
-
"DATA",
|
|
818
|
-
Object.freeze({
|
|
819
|
-
assertions: Object.freeze(reduced.assertions),
|
|
820
|
-
entities: Object.freeze(reduced.entities),
|
|
821
|
-
relations: Object.freeze(reduced.relations),
|
|
822
|
-
topics: Object.freeze(reduced.topics),
|
|
823
|
-
index: reduced.index,
|
|
824
|
-
status,
|
|
825
|
-
errors,
|
|
826
|
-
cursor
|
|
827
|
-
})
|
|
828
|
-
]
|
|
829
|
-
]);
|
|
830
|
-
},
|
|
831
|
-
{
|
|
832
|
-
name: `${name}/snapshot`,
|
|
833
|
-
factory: "knowledgeGraphReducerSnapshot",
|
|
834
|
-
completeWhenDepsComplete: false,
|
|
835
|
-
errorWhenDepsError: false
|
|
836
|
-
}
|
|
837
|
-
);
|
|
838
|
-
return {
|
|
839
|
-
input: {
|
|
840
|
-
assertions: opts.assertions,
|
|
841
|
-
...opts.policy === void 0 ? {} : { policy: opts.policy }
|
|
842
|
-
},
|
|
843
|
-
snapshot,
|
|
844
|
-
assertions: kgProjection(
|
|
845
|
-
graph,
|
|
846
|
-
snapshot,
|
|
847
|
-
`${name}/assertions`,
|
|
848
|
-
"knowledgeGraphAssertions",
|
|
849
|
-
(fact) => fact.assertions
|
|
850
|
-
),
|
|
851
|
-
entities: kgProjection(
|
|
852
|
-
graph,
|
|
853
|
-
snapshot,
|
|
854
|
-
`${name}/entities`,
|
|
855
|
-
"knowledgeGraphEntities",
|
|
856
|
-
(fact) => fact.entities
|
|
857
|
-
),
|
|
858
|
-
relations: kgProjection(
|
|
859
|
-
graph,
|
|
860
|
-
snapshot,
|
|
861
|
-
`${name}/relations`,
|
|
862
|
-
"knowledgeGraphRelations",
|
|
863
|
-
(fact) => fact.relations
|
|
864
|
-
),
|
|
865
|
-
topics: kgProjection(
|
|
866
|
-
graph,
|
|
867
|
-
snapshot,
|
|
868
|
-
`${name}/topics`,
|
|
869
|
-
"knowledgeGraphTopics",
|
|
870
|
-
(fact) => fact.topics
|
|
871
|
-
),
|
|
872
|
-
index: kgProjection(
|
|
873
|
-
graph,
|
|
874
|
-
snapshot,
|
|
875
|
-
`${name}/index`,
|
|
876
|
-
"knowledgeGraphIndex",
|
|
877
|
-
(fact) => fact.index
|
|
878
|
-
),
|
|
879
|
-
status: kgProjection(
|
|
880
|
-
graph,
|
|
881
|
-
snapshot,
|
|
882
|
-
`${name}/status`,
|
|
883
|
-
"knowledgeGraphStatus",
|
|
884
|
-
(fact) => fact.status
|
|
885
|
-
),
|
|
886
|
-
errors: kgProjection(
|
|
887
|
-
graph,
|
|
888
|
-
snapshot,
|
|
889
|
-
`${name}/errors`,
|
|
890
|
-
"knowledgeGraphErrors",
|
|
891
|
-
(fact) => fact.errors
|
|
892
|
-
),
|
|
893
|
-
cursor: kgProjection(
|
|
894
|
-
graph,
|
|
895
|
-
snapshot,
|
|
896
|
-
`${name}/cursor`,
|
|
897
|
-
"knowledgeGraphCursor",
|
|
898
|
-
(fact) => fact.cursor
|
|
899
|
-
)
|
|
900
|
-
};
|
|
901
|
-
}
|
|
902
|
-
function retrievalProjection(graph, snapshot, name, factory, select) {
|
|
903
|
-
return graph.node(
|
|
904
|
-
[snapshot],
|
|
905
|
-
(ctx) => {
|
|
906
|
-
for (const raw of depBatch(ctx, 0) ?? []) {
|
|
907
|
-
const fact = raw;
|
|
908
|
-
const selected = select(fact);
|
|
909
|
-
if (selected !== void 0) ctx.down([["DATA", selected]]);
|
|
910
|
-
}
|
|
911
|
-
},
|
|
912
|
-
{
|
|
913
|
-
name,
|
|
914
|
-
factory,
|
|
915
|
-
completeWhenDepsComplete: false,
|
|
916
|
-
errorWhenDepsError: false
|
|
917
|
-
}
|
|
918
|
-
);
|
|
919
|
-
}
|
|
920
|
-
function kgProjection(graph, snapshot, name, factory, select) {
|
|
921
|
-
return graph.node(
|
|
922
|
-
[snapshot],
|
|
923
|
-
(ctx) => {
|
|
924
|
-
for (const raw of depBatch(ctx, 0) ?? []) {
|
|
925
|
-
ctx.down([["DATA", select(raw)]]);
|
|
926
|
-
}
|
|
927
|
-
},
|
|
928
|
-
{
|
|
929
|
-
name,
|
|
930
|
-
factory,
|
|
931
|
-
completeWhenDepsComplete: false,
|
|
932
|
-
errorWhenDepsError: false
|
|
933
|
-
}
|
|
934
|
-
);
|
|
935
|
-
}
|
|
936
|
-
function validateKnowledgeGraphPolicy(value) {
|
|
937
|
-
if (value === void 0) return { policy: void 0, errors: [] };
|
|
723
|
+
function validateKnowledgeAssertion(value, index, policy) {
|
|
938
724
|
if (!isPlainObject(value)) {
|
|
939
|
-
return
|
|
940
|
-
errors: [
|
|
941
|
-
{
|
|
942
|
-
code: "invalid-policy",
|
|
943
|
-
message: "knowledgeGraphReducerBundle: policy must be an object",
|
|
944
|
-
assertion: value
|
|
945
|
-
}
|
|
946
|
-
]
|
|
947
|
-
};
|
|
725
|
+
return invalidKnowledgeAssertion(index, value, ["assertion must be an object"]);
|
|
948
726
|
}
|
|
727
|
+
const raw = value;
|
|
949
728
|
const errors = [];
|
|
950
|
-
|
|
951
|
-
if (
|
|
952
|
-
|
|
729
|
+
if (!isNonEmptyString(raw.id)) errors.push("id must be a non-empty string");
|
|
730
|
+
if (!isKnowledgeSubject(raw.subject)) errors.push("subject.id must be a non-empty string");
|
|
731
|
+
if (!isNonEmptyString(raw.predicate)) errors.push("predicate must be a non-empty string");
|
|
732
|
+
if (!isKnowledgeObject(raw.object)) errors.push("object shape is invalid");
|
|
733
|
+
if (raw.confidence !== void 0 && (!Number.isFinite(raw.confidence) || raw.confidence < 0 || raw.confidence > 1)) {
|
|
734
|
+
errors.push("confidence must be a finite number in [0, 1] when present");
|
|
953
735
|
}
|
|
954
|
-
if (
|
|
955
|
-
errors.push("
|
|
736
|
+
if (raw.sources !== void 0 && !isDenseArrayOf2(raw.sources, isNonEmptyString)) {
|
|
737
|
+
errors.push("sources must be a readonly non-empty string array when present");
|
|
738
|
+
}
|
|
739
|
+
if (policy?.allowedPredicates !== void 0 && !policy.allowedPredicates.includes(raw.predicate ?? "")) {
|
|
740
|
+
errors.push(`predicate '${String(raw.predicate)}' is not allowed by policy`);
|
|
741
|
+
}
|
|
742
|
+
if (policy?.requireEntityTypes === true) {
|
|
743
|
+
if (isKnowledgeSubject(raw.subject) && raw.subject.type === void 0) {
|
|
744
|
+
errors.push("subject.type is required by policy");
|
|
745
|
+
}
|
|
746
|
+
if (isKnowledgeObject(raw.object) && raw.object.kind === "entity" && raw.object.type === void 0) {
|
|
747
|
+
errors.push("object.type is required by policy for entity objects");
|
|
748
|
+
}
|
|
956
749
|
}
|
|
957
750
|
if (errors.length > 0) {
|
|
958
|
-
return
|
|
959
|
-
errors: [
|
|
960
|
-
{
|
|
961
|
-
code: "invalid-policy",
|
|
962
|
-
message: "knowledgeGraphReducerBundle: policy is invalid",
|
|
963
|
-
assertion: value,
|
|
964
|
-
validationErrors: Object.freeze(errors)
|
|
965
|
-
}
|
|
966
|
-
]
|
|
967
|
-
};
|
|
751
|
+
return invalidKnowledgeAssertion(index, value, errors, raw.id);
|
|
968
752
|
}
|
|
969
753
|
return {
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
...
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
if (!Array.isArray(value)) {
|
|
982
|
-
return {
|
|
983
|
-
assertions,
|
|
984
|
-
entities: [],
|
|
985
|
-
relations: [],
|
|
986
|
-
topics: [],
|
|
987
|
-
index: emptyKnowledgeGraphIndex(),
|
|
988
|
-
errors: [
|
|
989
|
-
{
|
|
990
|
-
code: "invalid-assertions-input",
|
|
991
|
-
message: "knowledgeGraphReducerBundle: assertions input must be an array",
|
|
992
|
-
assertion: value
|
|
993
|
-
}
|
|
994
|
-
],
|
|
995
|
-
invalidAssertions: 0
|
|
996
|
-
};
|
|
997
|
-
}
|
|
998
|
-
const length = safeArrayLength(value);
|
|
999
|
-
if (length === void 0) {
|
|
1000
|
-
return {
|
|
1001
|
-
assertions,
|
|
1002
|
-
entities: [],
|
|
1003
|
-
relations: [],
|
|
1004
|
-
topics: [],
|
|
1005
|
-
index: emptyKnowledgeGraphIndex(),
|
|
1006
|
-
errors: [
|
|
1007
|
-
{
|
|
1008
|
-
code: "invalid-assertions-input",
|
|
1009
|
-
message: "knowledgeGraphReducerBundle: assertions input length could not be read",
|
|
1010
|
-
assertion: value
|
|
1011
|
-
}
|
|
1012
|
-
],
|
|
1013
|
-
invalidAssertions: 0
|
|
1014
|
-
};
|
|
1015
|
-
}
|
|
1016
|
-
for (let i = 0; i < length; i += 1) {
|
|
1017
|
-
const result = validateKnowledgeAssertion(value[i], i, policy);
|
|
1018
|
-
if (result.error !== void 0) {
|
|
1019
|
-
errors.push(result.error);
|
|
1020
|
-
continue;
|
|
1021
|
-
}
|
|
1022
|
-
const assertion = result.assertion;
|
|
1023
|
-
if (seenAssertions.has(assertion.id)) {
|
|
1024
|
-
errors.push({
|
|
1025
|
-
code: "duplicate-assertion-id",
|
|
1026
|
-
message: "knowledgeGraphReducerBundle: duplicate assertion id",
|
|
1027
|
-
index: i,
|
|
1028
|
-
assertionId: assertion.id,
|
|
1029
|
-
assertion,
|
|
1030
|
-
validationErrors: Object.freeze([`duplicate assertion id '${assertion.id}'`])
|
|
1031
|
-
});
|
|
1032
|
-
continue;
|
|
1033
|
-
}
|
|
1034
|
-
seenAssertions.add(assertion.id);
|
|
1035
|
-
assertions.push(assertion);
|
|
1036
|
-
}
|
|
1037
|
-
const materialized = materializeKnowledgeGraph(assertions);
|
|
1038
|
-
return {
|
|
1039
|
-
assertions: Object.freeze(assertions),
|
|
1040
|
-
...materialized,
|
|
1041
|
-
errors,
|
|
1042
|
-
invalidAssertions: errors.filter((error) => error.code !== "invalid-policy").length
|
|
1043
|
-
};
|
|
1044
|
-
}
|
|
1045
|
-
function validateKnowledgeAssertion(value, index, policy) {
|
|
1046
|
-
if (!isPlainObject(value)) {
|
|
1047
|
-
return invalidKnowledgeAssertion(index, value, ["assertion must be an object"]);
|
|
1048
|
-
}
|
|
1049
|
-
const raw = value;
|
|
1050
|
-
const errors = [];
|
|
1051
|
-
if (!isNonEmptyString(raw.id)) errors.push("id must be a non-empty string");
|
|
1052
|
-
if (!isKnowledgeSubject(raw.subject)) errors.push("subject.id must be a non-empty string");
|
|
1053
|
-
if (!isNonEmptyString(raw.predicate)) errors.push("predicate must be a non-empty string");
|
|
1054
|
-
if (!isKnowledgeObject(raw.object)) errors.push("object shape is invalid");
|
|
1055
|
-
if (raw.confidence !== void 0 && (!Number.isFinite(raw.confidence) || raw.confidence < 0 || raw.confidence > 1)) {
|
|
1056
|
-
errors.push("confidence must be a finite number in [0, 1] when present");
|
|
1057
|
-
}
|
|
1058
|
-
if (raw.sources !== void 0 && !isDenseArrayOf2(raw.sources, isNonEmptyString)) {
|
|
1059
|
-
errors.push("sources must be a readonly non-empty string array when present");
|
|
1060
|
-
}
|
|
1061
|
-
if (policy?.allowedPredicates !== void 0 && !policy.allowedPredicates.includes(raw.predicate ?? "")) {
|
|
1062
|
-
errors.push(`predicate '${String(raw.predicate)}' is not allowed by policy`);
|
|
1063
|
-
}
|
|
1064
|
-
if (policy?.requireEntityTypes === true) {
|
|
1065
|
-
if (isKnowledgeSubject(raw.subject) && raw.subject.type === void 0) {
|
|
1066
|
-
errors.push("subject.type is required by policy");
|
|
1067
|
-
}
|
|
1068
|
-
if (isKnowledgeObject(raw.object) && raw.object.kind === "entity" && raw.object.type === void 0) {
|
|
1069
|
-
errors.push("object.type is required by policy for entity objects");
|
|
1070
|
-
}
|
|
1071
|
-
}
|
|
1072
|
-
if (errors.length > 0) {
|
|
1073
|
-
return invalidKnowledgeAssertion(index, value, errors, raw.id);
|
|
1074
|
-
}
|
|
1075
|
-
return {
|
|
1076
|
-
assertion: Object.freeze({
|
|
1077
|
-
id: raw.id,
|
|
1078
|
-
...raw.recordId === void 0 ? {} : { recordId: raw.recordId },
|
|
1079
|
-
...raw.fragmentId === void 0 ? {} : { fragmentId: raw.fragmentId },
|
|
1080
|
-
subject: snapshotSubject(raw.subject),
|
|
1081
|
-
predicate: raw.predicate,
|
|
1082
|
-
object: snapshotObject(raw.object),
|
|
1083
|
-
...raw.confidence === void 0 ? {} : { confidence: raw.confidence },
|
|
1084
|
-
sources: Object.freeze([...raw.sources ?? []]),
|
|
1085
|
-
...raw.provenance === void 0 ? {} : { provenance: raw.provenance }
|
|
1086
|
-
})
|
|
754
|
+
assertion: Object.freeze({
|
|
755
|
+
id: raw.id,
|
|
756
|
+
...raw.recordId === void 0 ? {} : { recordId: raw.recordId },
|
|
757
|
+
...raw.fragmentId === void 0 ? {} : { fragmentId: raw.fragmentId },
|
|
758
|
+
subject: snapshotSubject(raw.subject),
|
|
759
|
+
predicate: raw.predicate,
|
|
760
|
+
object: snapshotObject(raw.object),
|
|
761
|
+
...raw.confidence === void 0 ? {} : { confidence: raw.confidence },
|
|
762
|
+
sources: Object.freeze([...raw.sources ?? []]),
|
|
763
|
+
...raw.provenance === void 0 ? {} : { provenance: raw.provenance }
|
|
764
|
+
})
|
|
1087
765
|
};
|
|
1088
766
|
}
|
|
1089
767
|
function invalidKnowledgeAssertion(index, assertion, validationErrors, assertionId) {
|
|
@@ -1430,6 +1108,316 @@ function compareBigIntDesc2(a, b) {
|
|
|
1430
1108
|
if (a === b) return 0;
|
|
1431
1109
|
return a > b ? -1 : 1;
|
|
1432
1110
|
}
|
|
1111
|
+
|
|
1112
|
+
// src/patterns/semantic-memory-graph.ts
|
|
1113
|
+
function memoryRetrievalBundle(graph, opts) {
|
|
1114
|
+
const name = opts.name ?? "memoryRetrieval";
|
|
1115
|
+
const { fragments, query } = opts;
|
|
1116
|
+
const snapshot = graph.node(
|
|
1117
|
+
[fragments, query],
|
|
1118
|
+
(ctx) => {
|
|
1119
|
+
const state = ctx.state.get() ?? { evaluation: 0 };
|
|
1120
|
+
state.evaluation += 1;
|
|
1121
|
+
const rawFragments = depLatest(ctx, 0);
|
|
1122
|
+
const rawQuery = depLatest(ctx, 1);
|
|
1123
|
+
const queryValidation = validateMemoryRetrievalQuery(rawQuery);
|
|
1124
|
+
const currentQuery = queryValidation.query;
|
|
1125
|
+
const valid = [];
|
|
1126
|
+
const seenIds = /* @__PURE__ */ new Set();
|
|
1127
|
+
const errors = [...queryValidation.errors];
|
|
1128
|
+
if (!Array.isArray(rawFragments)) {
|
|
1129
|
+
errors.push({
|
|
1130
|
+
code: "invalid-fragments-input",
|
|
1131
|
+
message: "memoryRetrievalBundle: fragments input must be an array",
|
|
1132
|
+
fragment: rawFragments
|
|
1133
|
+
});
|
|
1134
|
+
} else {
|
|
1135
|
+
const length = safeArrayLength(rawFragments);
|
|
1136
|
+
if (length === void 0) {
|
|
1137
|
+
errors.push({
|
|
1138
|
+
code: "invalid-fragments-input",
|
|
1139
|
+
message: "memoryRetrievalBundle: fragments input length could not be read",
|
|
1140
|
+
fragment: rawFragments
|
|
1141
|
+
});
|
|
1142
|
+
}
|
|
1143
|
+
for (let i = 0; i < (length ?? 0); i += 1) {
|
|
1144
|
+
const result = validateAndSnapshotFragment(rawFragments, i);
|
|
1145
|
+
if (result.error !== void 0) {
|
|
1146
|
+
errors.push(result.error);
|
|
1147
|
+
continue;
|
|
1148
|
+
}
|
|
1149
|
+
const fragment = result.fragment;
|
|
1150
|
+
if (seenIds.has(fragment.id)) {
|
|
1151
|
+
errors.push({
|
|
1152
|
+
code: "duplicate-fragment-id",
|
|
1153
|
+
message: "memoryRetrievalBundle: duplicate fragment id",
|
|
1154
|
+
index: i,
|
|
1155
|
+
fragment,
|
|
1156
|
+
validationErrors: [`duplicate fragment id '${fragment.id}'`]
|
|
1157
|
+
});
|
|
1158
|
+
continue;
|
|
1159
|
+
}
|
|
1160
|
+
seenIds.add(fragment.id);
|
|
1161
|
+
valid.push(fragment);
|
|
1162
|
+
}
|
|
1163
|
+
}
|
|
1164
|
+
const ranked = errors.some((error) => !isRecoverableFragmentError(error)) ? [] : rankFragments(valid, currentQuery);
|
|
1165
|
+
const cursor = Object.freeze({
|
|
1166
|
+
evaluation: state.evaluation,
|
|
1167
|
+
validFragments: valid.length,
|
|
1168
|
+
invalidFragments: errors.filter(
|
|
1169
|
+
(error) => error.code === "invalid-fragment" || error.code === "duplicate-fragment-id"
|
|
1170
|
+
).length,
|
|
1171
|
+
resultCount: ranked.length
|
|
1172
|
+
});
|
|
1173
|
+
ctx.state.set(state);
|
|
1174
|
+
const answer = Object.freeze({
|
|
1175
|
+
query: currentQuery,
|
|
1176
|
+
results: Object.freeze(ranked)
|
|
1177
|
+
});
|
|
1178
|
+
const status = Object.freeze({
|
|
1179
|
+
state: statusState(errors, ranked.length),
|
|
1180
|
+
query: currentQuery,
|
|
1181
|
+
cursor
|
|
1182
|
+
});
|
|
1183
|
+
const indexed = Object.freeze({
|
|
1184
|
+
ids: Object.freeze(valid.map((fragment) => fragment.id)),
|
|
1185
|
+
byId: indexById(valid),
|
|
1186
|
+
cursor
|
|
1187
|
+
});
|
|
1188
|
+
const errorFacts = Object.freeze(
|
|
1189
|
+
errors.map(
|
|
1190
|
+
(error) => Object.freeze({
|
|
1191
|
+
...error,
|
|
1192
|
+
...error.validationErrors === void 0 ? {} : { validationErrors: Object.freeze([...error.validationErrors]) },
|
|
1193
|
+
cursor
|
|
1194
|
+
})
|
|
1195
|
+
)
|
|
1196
|
+
);
|
|
1197
|
+
ctx.down([
|
|
1198
|
+
[
|
|
1199
|
+
"DATA",
|
|
1200
|
+
Object.freeze({
|
|
1201
|
+
fragments: Object.freeze([...valid]),
|
|
1202
|
+
indexed,
|
|
1203
|
+
ranked: answer,
|
|
1204
|
+
status,
|
|
1205
|
+
errors: errorFacts,
|
|
1206
|
+
cursor
|
|
1207
|
+
})
|
|
1208
|
+
]
|
|
1209
|
+
]);
|
|
1210
|
+
},
|
|
1211
|
+
{
|
|
1212
|
+
name: `${name}/snapshot`,
|
|
1213
|
+
factory: "memoryRetrievalSnapshot",
|
|
1214
|
+
completeWhenDepsComplete: false,
|
|
1215
|
+
errorWhenDepsError: false
|
|
1216
|
+
}
|
|
1217
|
+
);
|
|
1218
|
+
return {
|
|
1219
|
+
input: { fragments, query },
|
|
1220
|
+
snapshot,
|
|
1221
|
+
fragments: retrievalProjection(
|
|
1222
|
+
graph,
|
|
1223
|
+
snapshot,
|
|
1224
|
+
`${name}/fragments`,
|
|
1225
|
+
"memoryRetrievalFragments",
|
|
1226
|
+
(fact) => fact.fragments
|
|
1227
|
+
),
|
|
1228
|
+
indexed: retrievalProjection(
|
|
1229
|
+
graph,
|
|
1230
|
+
snapshot,
|
|
1231
|
+
`${name}/indexed`,
|
|
1232
|
+
"memoryRetrievalIndexed",
|
|
1233
|
+
(fact) => fact.indexed
|
|
1234
|
+
),
|
|
1235
|
+
ranked: retrievalProjection(
|
|
1236
|
+
graph,
|
|
1237
|
+
snapshot,
|
|
1238
|
+
`${name}/ranked`,
|
|
1239
|
+
"memoryRetrievalRanked",
|
|
1240
|
+
(fact) => fact.ranked
|
|
1241
|
+
),
|
|
1242
|
+
status: retrievalProjection(
|
|
1243
|
+
graph,
|
|
1244
|
+
snapshot,
|
|
1245
|
+
`${name}/status`,
|
|
1246
|
+
"memoryRetrievalStatus",
|
|
1247
|
+
(fact) => fact.status
|
|
1248
|
+
),
|
|
1249
|
+
errors: retrievalProjection(
|
|
1250
|
+
graph,
|
|
1251
|
+
snapshot,
|
|
1252
|
+
`${name}/errors`,
|
|
1253
|
+
"memoryRetrievalErrors",
|
|
1254
|
+
(fact) => fact.errors
|
|
1255
|
+
),
|
|
1256
|
+
cursor: retrievalProjection(
|
|
1257
|
+
graph,
|
|
1258
|
+
snapshot,
|
|
1259
|
+
`${name}/cursor`,
|
|
1260
|
+
"memoryRetrievalCursor",
|
|
1261
|
+
(fact) => fact.cursor
|
|
1262
|
+
)
|
|
1263
|
+
};
|
|
1264
|
+
}
|
|
1265
|
+
function knowledgeGraphReducerBundle(graph, opts) {
|
|
1266
|
+
const name = opts.name ?? "knowledgeGraph";
|
|
1267
|
+
const deps = opts.policy === void 0 ? [opts.assertions] : [opts.assertions, opts.policy];
|
|
1268
|
+
const snapshot = graph.node(
|
|
1269
|
+
deps,
|
|
1270
|
+
(ctx) => {
|
|
1271
|
+
const state = ctx.state.get() ?? { evaluation: 0 };
|
|
1272
|
+
state.evaluation += 1;
|
|
1273
|
+
const policy = validateKnowledgeGraphPolicy(
|
|
1274
|
+
opts.policy === void 0 ? void 0 : depLatest(ctx, 1)
|
|
1275
|
+
);
|
|
1276
|
+
const reduced = reduceKnowledgeAssertions(depLatest(ctx, 0), policy.policy);
|
|
1277
|
+
const pendingErrors = [...policy.errors, ...reduced.errors];
|
|
1278
|
+
const cursor = Object.freeze({
|
|
1279
|
+
evaluation: state.evaluation,
|
|
1280
|
+
validAssertions: reduced.assertions.length,
|
|
1281
|
+
invalidAssertions: reduced.invalidAssertions,
|
|
1282
|
+
entityCount: reduced.entities.length,
|
|
1283
|
+
relationCount: reduced.relations.length,
|
|
1284
|
+
predicateCount: reduced.topics.length
|
|
1285
|
+
});
|
|
1286
|
+
const errors = Object.freeze(
|
|
1287
|
+
pendingErrors.map(
|
|
1288
|
+
(error) => Object.freeze({
|
|
1289
|
+
...error,
|
|
1290
|
+
...error.validationErrors === void 0 ? {} : { validationErrors: Object.freeze([...error.validationErrors]) },
|
|
1291
|
+
cursor
|
|
1292
|
+
})
|
|
1293
|
+
)
|
|
1294
|
+
);
|
|
1295
|
+
const status = Object.freeze({
|
|
1296
|
+
state: reduced.assertions.length === 0 && errors.length === 0 ? "empty" : errors.length === 0 ? "ready" : reduced.assertions.length > 0 ? "partial" : "error",
|
|
1297
|
+
cursor
|
|
1298
|
+
});
|
|
1299
|
+
ctx.state.set(state);
|
|
1300
|
+
ctx.down([
|
|
1301
|
+
[
|
|
1302
|
+
"DATA",
|
|
1303
|
+
Object.freeze({
|
|
1304
|
+
assertions: Object.freeze(reduced.assertions),
|
|
1305
|
+
entities: Object.freeze(reduced.entities),
|
|
1306
|
+
relations: Object.freeze(reduced.relations),
|
|
1307
|
+
topics: Object.freeze(reduced.topics),
|
|
1308
|
+
index: reduced.index,
|
|
1309
|
+
status,
|
|
1310
|
+
errors,
|
|
1311
|
+
cursor
|
|
1312
|
+
})
|
|
1313
|
+
]
|
|
1314
|
+
]);
|
|
1315
|
+
},
|
|
1316
|
+
{
|
|
1317
|
+
name: `${name}/snapshot`,
|
|
1318
|
+
factory: "knowledgeGraphReducerSnapshot",
|
|
1319
|
+
completeWhenDepsComplete: false,
|
|
1320
|
+
errorWhenDepsError: false
|
|
1321
|
+
}
|
|
1322
|
+
);
|
|
1323
|
+
return {
|
|
1324
|
+
input: {
|
|
1325
|
+
assertions: opts.assertions,
|
|
1326
|
+
...opts.policy === void 0 ? {} : { policy: opts.policy }
|
|
1327
|
+
},
|
|
1328
|
+
snapshot,
|
|
1329
|
+
assertions: kgProjection(
|
|
1330
|
+
graph,
|
|
1331
|
+
snapshot,
|
|
1332
|
+
`${name}/assertions`,
|
|
1333
|
+
"knowledgeGraphAssertions",
|
|
1334
|
+
(fact) => fact.assertions
|
|
1335
|
+
),
|
|
1336
|
+
entities: kgProjection(
|
|
1337
|
+
graph,
|
|
1338
|
+
snapshot,
|
|
1339
|
+
`${name}/entities`,
|
|
1340
|
+
"knowledgeGraphEntities",
|
|
1341
|
+
(fact) => fact.entities
|
|
1342
|
+
),
|
|
1343
|
+
relations: kgProjection(
|
|
1344
|
+
graph,
|
|
1345
|
+
snapshot,
|
|
1346
|
+
`${name}/relations`,
|
|
1347
|
+
"knowledgeGraphRelations",
|
|
1348
|
+
(fact) => fact.relations
|
|
1349
|
+
),
|
|
1350
|
+
topics: kgProjection(
|
|
1351
|
+
graph,
|
|
1352
|
+
snapshot,
|
|
1353
|
+
`${name}/topics`,
|
|
1354
|
+
"knowledgeGraphTopics",
|
|
1355
|
+
(fact) => fact.topics
|
|
1356
|
+
),
|
|
1357
|
+
index: kgProjection(
|
|
1358
|
+
graph,
|
|
1359
|
+
snapshot,
|
|
1360
|
+
`${name}/index`,
|
|
1361
|
+
"knowledgeGraphIndex",
|
|
1362
|
+
(fact) => fact.index
|
|
1363
|
+
),
|
|
1364
|
+
status: kgProjection(
|
|
1365
|
+
graph,
|
|
1366
|
+
snapshot,
|
|
1367
|
+
`${name}/status`,
|
|
1368
|
+
"knowledgeGraphStatus",
|
|
1369
|
+
(fact) => fact.status
|
|
1370
|
+
),
|
|
1371
|
+
errors: kgProjection(
|
|
1372
|
+
graph,
|
|
1373
|
+
snapshot,
|
|
1374
|
+
`${name}/errors`,
|
|
1375
|
+
"knowledgeGraphErrors",
|
|
1376
|
+
(fact) => fact.errors
|
|
1377
|
+
),
|
|
1378
|
+
cursor: kgProjection(
|
|
1379
|
+
graph,
|
|
1380
|
+
snapshot,
|
|
1381
|
+
`${name}/cursor`,
|
|
1382
|
+
"knowledgeGraphCursor",
|
|
1383
|
+
(fact) => fact.cursor
|
|
1384
|
+
)
|
|
1385
|
+
};
|
|
1386
|
+
}
|
|
1387
|
+
function retrievalProjection(graph, snapshot, name, factory, select) {
|
|
1388
|
+
return graph.node(
|
|
1389
|
+
[snapshot],
|
|
1390
|
+
(ctx) => {
|
|
1391
|
+
for (const raw of depBatch(ctx, 0) ?? []) {
|
|
1392
|
+
const fact = raw;
|
|
1393
|
+
const selected = select(fact);
|
|
1394
|
+
if (selected !== void 0) ctx.down([["DATA", selected]]);
|
|
1395
|
+
}
|
|
1396
|
+
},
|
|
1397
|
+
{
|
|
1398
|
+
name,
|
|
1399
|
+
factory,
|
|
1400
|
+
completeWhenDepsComplete: false,
|
|
1401
|
+
errorWhenDepsError: false
|
|
1402
|
+
}
|
|
1403
|
+
);
|
|
1404
|
+
}
|
|
1405
|
+
function kgProjection(graph, snapshot, name, factory, select) {
|
|
1406
|
+
return graph.node(
|
|
1407
|
+
[snapshot],
|
|
1408
|
+
(ctx) => {
|
|
1409
|
+
for (const raw of depBatch(ctx, 0) ?? []) {
|
|
1410
|
+
ctx.down([["DATA", select(raw)]]);
|
|
1411
|
+
}
|
|
1412
|
+
},
|
|
1413
|
+
{
|
|
1414
|
+
name,
|
|
1415
|
+
factory,
|
|
1416
|
+
completeWhenDepsComplete: false,
|
|
1417
|
+
errorWhenDepsError: false
|
|
1418
|
+
}
|
|
1419
|
+
);
|
|
1420
|
+
}
|
|
1433
1421
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1434
1422
|
0 && (module.exports = {
|
|
1435
1423
|
admissionFilter3D,
|