@graphrefly/graphrefly 0.47.1 → 0.48.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/base/composition/index.cjs +28 -19
- package/dist/base/composition/index.cjs.map +1 -1
- package/dist/base/composition/index.d.cts +14 -5
- package/dist/base/composition/index.d.ts +14 -5
- package/dist/base/composition/index.js +9 -9
- package/dist/base/index.cjs +294 -164
- package/dist/base/index.cjs.map +1 -1
- package/dist/base/index.d.cts +2 -2
- package/dist/base/index.d.ts +2 -2
- package/dist/base/index.js +77 -72
- package/dist/base/io/index.cjs +145 -85
- package/dist/base/io/index.cjs.map +1 -1
- package/dist/base/io/index.d.cts +32 -5
- package/dist/base/io/index.d.ts +32 -5
- package/dist/base/io/index.js +5 -5
- package/dist/base/mutation/index.cjs +21 -0
- package/dist/base/mutation/index.cjs.map +1 -1
- package/dist/base/mutation/index.d.cts +23 -1
- package/dist/base/mutation/index.d.ts +23 -1
- package/dist/base/mutation/index.js +3 -1
- package/dist/base/sources/browser/index.cjs +18 -12
- package/dist/base/sources/browser/index.cjs.map +1 -1
- package/dist/base/sources/browser/index.d.cts +20 -2
- package/dist/base/sources/browser/index.d.ts +20 -2
- package/dist/base/sources/browser/index.js +18 -12
- package/dist/base/sources/browser/index.js.map +1 -1
- package/dist/base/sources/event/index.cjs +29 -1
- package/dist/base/sources/event/index.cjs.map +1 -1
- package/dist/base/sources/event/index.d.cts +67 -3
- package/dist/base/sources/event/index.d.ts +67 -3
- package/dist/base/sources/event/index.js +5 -2
- package/dist/base/sources/index.cjs +96 -50
- package/dist/base/sources/index.cjs.map +1 -1
- package/dist/base/sources/index.d.cts +1 -1
- package/dist/base/sources/index.d.ts +1 -1
- package/dist/base/sources/index.js +7 -4
- package/dist/base/sources/node/index.cjs +43 -37
- package/dist/base/sources/node/index.cjs.map +1 -1
- package/dist/base/sources/node/index.js +43 -37
- package/dist/base/sources/node/index.js.map +1 -1
- package/dist/{chunk-J5WFUEO4.js → chunk-23MAWVOJ.js} +3 -3
- package/dist/{chunk-YXCPV26R.js → chunk-3REMCHSS.js} +39 -27
- package/dist/chunk-3REMCHSS.js.map +1 -0
- package/dist/{chunk-CEVNQ74M.js → chunk-3YGXPUHW.js} +2 -2
- package/dist/{chunk-CEVNQ74M.js.map → chunk-3YGXPUHW.js.map} +1 -1
- package/dist/{chunk-EVYY4X5A.js → chunk-46X2EFQH.js} +16 -5
- package/dist/chunk-46X2EFQH.js.map +1 -0
- package/dist/{chunk-NY2PYHNC.js → chunk-5UY3PNFY.js} +12 -5
- package/dist/chunk-5UY3PNFY.js.map +1 -0
- package/dist/{chunk-RGMTUZCL.js → chunk-65OM4XLQ.js} +50 -4
- package/dist/chunk-65OM4XLQ.js.map +1 -0
- package/dist/{chunk-3PSLNJDU.js → chunk-6DQYBIHW.js} +314 -49
- package/dist/chunk-6DQYBIHW.js.map +1 -0
- package/dist/{chunk-LDCSZ72P.js → chunk-6YBER5UP.js} +3 -3
- package/dist/{chunk-LDCSZ72P.js.map → chunk-6YBER5UP.js.map} +1 -1
- package/dist/{chunk-7EGRP2VX.js → chunk-7BULJTL6.js} +2 -2
- package/dist/{chunk-7EGRP2VX.js.map → chunk-7BULJTL6.js.map} +1 -1
- package/dist/{chunk-VLAGJZSL.js → chunk-7T7WLEPM.js} +25 -4
- package/dist/chunk-7T7WLEPM.js.map +1 -0
- package/dist/{chunk-PKPO3JTZ.js → chunk-AQAKDE7F.js} +29 -11
- package/dist/chunk-AQAKDE7F.js.map +1 -0
- package/dist/{chunk-2OB3CEJS.js → chunk-B5Y5GPD5.js} +2 -2
- package/dist/{chunk-BXGZFGZ4.js → chunk-C5QD5DQX.js} +22 -1
- package/dist/chunk-C5QD5DQX.js.map +1 -0
- package/dist/{chunk-4XCHZRUJ.js → chunk-D5YGR4TP.js} +58 -7
- package/dist/chunk-D5YGR4TP.js.map +1 -0
- package/dist/{chunk-NPRP3MCV.js → chunk-DHDCOOJU.js} +2 -2
- package/dist/chunk-DHDCOOJU.js.map +1 -0
- package/dist/{chunk-MTTRCEJT.js → chunk-DVTDF5OI.js} +2 -2
- package/dist/{chunk-SOOKUYVM.js → chunk-F7EKHR32.js} +13 -9
- package/dist/chunk-F7EKHR32.js.map +1 -0
- package/dist/{chunk-A7KV5UK4.js → chunk-G7H6PN7P.js} +2 -2
- package/dist/{chunk-OCUDSN63.js → chunk-GGKHHG5Y.js} +110 -64
- package/dist/chunk-GGKHHG5Y.js.map +1 -0
- package/dist/{chunk-RAGGHLCV.js → chunk-GUNIRPEJ.js} +8 -6
- package/dist/{chunk-RAGGHLCV.js.map → chunk-GUNIRPEJ.js.map} +1 -1
- package/dist/{chunk-YJ4U2D2C.js → chunk-J5TBZFBD.js} +9 -7
- package/dist/chunk-J5TBZFBD.js.map +1 -0
- package/dist/{chunk-Y52CS6YA.js → chunk-JA67ZQG2.js} +2 -2
- package/dist/{chunk-Y52CS6YA.js.map → chunk-JA67ZQG2.js.map} +1 -1
- package/dist/{chunk-U225SKB4.js → chunk-K4ZYJ4EM.js} +569 -424
- package/dist/chunk-K4ZYJ4EM.js.map +1 -0
- package/dist/{chunk-Z4YXAUDN.js → chunk-KUFXLAEY.js} +11 -7
- package/dist/{chunk-Z4YXAUDN.js.map → chunk-KUFXLAEY.js.map} +1 -1
- package/dist/{chunk-IHTWQEDR.js → chunk-LTSI7ULC.js} +3 -3
- package/dist/{chunk-IHTWQEDR.js.map → chunk-LTSI7ULC.js.map} +1 -1
- package/dist/{chunk-DKNHAICT.js → chunk-MMHGYX44.js} +25 -9
- package/dist/chunk-MMHGYX44.js.map +1 -0
- package/dist/{chunk-K7PDZYQE.js → chunk-MQMTRKY3.js} +129 -50
- package/dist/chunk-MQMTRKY3.js.map +1 -0
- package/dist/{chunk-42FQ27MQ.js → chunk-MTODGQBR.js} +44 -179
- package/dist/chunk-MTODGQBR.js.map +1 -0
- package/dist/{chunk-O3MT7DYI.js → chunk-N6MNJNHB.js} +2 -2
- package/dist/{chunk-FVINAAKA.js → chunk-NBK6QQMG.js} +14 -13
- package/dist/{chunk-FVINAAKA.js.map → chunk-NBK6QQMG.js.map} +1 -1
- package/dist/{chunk-DM4OMPWK.js → chunk-NSA5K5G2.js} +2 -2
- package/dist/{chunk-MLTPJMH6.js → chunk-QQYULEZL.js} +2 -2
- package/dist/chunk-QSW4DFKE.js +31 -0
- package/dist/chunk-QSW4DFKE.js.map +1 -0
- package/dist/{chunk-PZWISPIQ.js → chunk-S7HN5FHL.js} +17 -11
- package/dist/chunk-S7HN5FHL.js.map +1 -0
- package/dist/{chunk-4S53H2KR.js → chunk-SUNCHMML.js} +2 -2
- package/dist/{chunk-4GYMCUDZ.js → chunk-T2U6N3FV.js} +7 -7
- package/dist/{chunk-RJOG4IJU.js → chunk-T5URUIIY.js} +50 -35
- package/dist/chunk-T5URUIIY.js.map +1 -0
- package/dist/{chunk-B4AKFXGE.js → chunk-TPTZZV25.js} +6 -6
- package/dist/chunk-TPTZZV25.js.map +1 -0
- package/dist/{chunk-BU3SEFA5.js → chunk-V46JWFGV.js} +7 -6
- package/dist/chunk-V46JWFGV.js.map +1 -0
- package/dist/{chunk-IJRR6YAI.js → chunk-VLDRAMP7.js} +18 -12
- package/dist/chunk-VLDRAMP7.js.map +1 -0
- package/dist/{chunk-6XZYT4SW.js → chunk-X6ESZDR6.js} +8 -9
- package/dist/chunk-X6ESZDR6.js.map +1 -0
- package/dist/{chunk-E5OZPDIW.js → chunk-X7BA5PWG.js} +7 -5
- package/dist/chunk-X7BA5PWG.js.map +1 -0
- package/dist/{chunk-CXANAIZU.js → chunk-XEWV254I.js} +3 -3
- package/dist/{chunk-CXANAIZU.js.map → chunk-XEWV254I.js.map} +1 -1
- package/dist/{chunk-V4Y3TM7U.js → chunk-YBJVKMTM.js} +38 -16
- package/dist/chunk-YBJVKMTM.js.map +1 -0
- package/dist/{chunk-7ADWWI2T.js → chunk-ZW32BPXV.js} +17 -6
- package/dist/chunk-ZW32BPXV.js.map +1 -0
- package/dist/compat/index.cjs +52 -5
- package/dist/compat/index.cjs.map +1 -1
- package/dist/compat/index.d.cts +1 -1
- package/dist/compat/index.d.ts +1 -1
- package/dist/compat/index.js +7 -7
- package/dist/compat/nestjs/index.cjs +52 -5
- package/dist/compat/nestjs/index.cjs.map +1 -1
- package/dist/compat/nestjs/index.d.cts +1 -1
- package/dist/compat/nestjs/index.d.ts +1 -1
- package/dist/compat/nestjs/index.js +4 -4
- package/dist/{fallback-Bx46zqky.d.cts → fallback-BROR6ZhO.d.cts} +1 -1
- package/dist/{fallback-pIWW8A2d.d.ts → fallback-DO80aM_3.d.ts} +1 -1
- package/dist/{index-B_p8tnvf.d.cts → index-D1z3XcF9.d.cts} +1 -0
- package/dist/{index-_HDSmPyp.d.ts → index-DZ6yua0Q.d.ts} +1 -0
- package/dist/index.cjs +2387 -1707
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -10
- package/dist/index.d.ts +10 -10
- package/dist/index.js +173 -150
- package/dist/index.js.map +1 -1
- package/dist/presets/ai/index.cjs +88 -26
- package/dist/presets/ai/index.cjs.map +1 -1
- package/dist/presets/ai/index.js +14 -14
- package/dist/presets/harness/index.cjs +183 -51
- package/dist/presets/harness/index.cjs.map +1 -1
- package/dist/presets/harness/index.d.cts +15 -5
- package/dist/presets/harness/index.d.ts +15 -5
- package/dist/presets/harness/index.js +26 -26
- package/dist/presets/index.cjs +298 -101
- package/dist/presets/index.cjs.map +1 -1
- package/dist/presets/index.d.cts +2 -2
- package/dist/presets/index.d.ts +2 -2
- package/dist/presets/index.js +49 -49
- package/dist/presets/inspect/index.cjs +63 -14
- package/dist/presets/inspect/index.cjs.map +1 -1
- package/dist/presets/inspect/index.d.cts +1 -1
- package/dist/presets/inspect/index.d.ts +1 -1
- package/dist/presets/inspect/index.js +6 -6
- package/dist/presets/resilience/index.cjs +64 -44
- package/dist/presets/resilience/index.cjs.map +1 -1
- package/dist/presets/resilience/index.d.cts +12 -8
- package/dist/presets/resilience/index.d.ts +12 -8
- package/dist/presets/resilience/index.js +6 -6
- package/dist/{rate-limiter-DpVbSYdH.d.cts → rate-limiter-DC26FM8J.d.cts} +10 -1
- package/dist/{rate-limiter-CEALq4N1.d.ts → rate-limiter-DyWpwpQP.d.ts} +10 -1
- package/dist/{reactive-layout-fswlBUvX.d.ts → reactive-layout-BBBWH0V_.d.cts} +85 -4
- package/dist/{reactive-layout-fswlBUvX.d.cts → reactive-layout-BBBWH0V_.d.ts} +85 -4
- package/dist/solutions/index.cjs +239 -92
- package/dist/solutions/index.cjs.map +1 -1
- package/dist/solutions/index.d.cts +2 -2
- package/dist/solutions/index.d.ts +2 -2
- package/dist/solutions/index.js +32 -32
- package/dist/{spawnable-5mDY501F.d.cts → spawnable-B2IlW60f.d.cts} +23 -2
- package/dist/{spawnable-D3lR0oQu.d.ts → spawnable-tttFz2Nh.d.ts} +23 -2
- package/dist/testing/index.cjs +94 -0
- package/dist/testing/index.cjs.map +1 -0
- package/dist/testing/index.d.cts +59 -0
- package/dist/testing/index.d.ts +59 -0
- package/dist/testing/index.js +73 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/{timeout-U5O4ESK3.js → timeout-BEABACRP.js} +2 -2
- package/dist/utils/ai/browser.cjs.map +1 -1
- package/dist/utils/ai/browser.d.cts +2 -2
- package/dist/utils/ai/browser.d.ts +2 -2
- package/dist/utils/ai/browser.js +10 -10
- package/dist/utils/ai/browser.js.map +1 -1
- package/dist/utils/ai/index.cjs +291 -191
- package/dist/utils/ai/index.cjs.map +1 -1
- package/dist/utils/ai/index.d.cts +108 -12
- package/dist/utils/ai/index.d.ts +108 -12
- package/dist/utils/ai/index.js +23 -21
- package/dist/utils/ai/node.cjs.map +1 -1
- package/dist/utils/ai/node.d.cts +5 -5
- package/dist/utils/ai/node.d.ts +5 -5
- package/dist/utils/ai/node.js +3 -3
- package/dist/utils/ai/node.js.map +1 -1
- package/dist/utils/cqrs/index.cjs +29 -3
- package/dist/utils/cqrs/index.cjs.map +1 -1
- package/dist/utils/cqrs/index.d.cts +12 -7
- package/dist/utils/cqrs/index.d.ts +12 -7
- package/dist/utils/cqrs/index.js +2 -2
- package/dist/utils/demo-shell/index.cjs +45 -19
- package/dist/utils/demo-shell/index.cjs.map +1 -1
- package/dist/utils/demo-shell/index.d.cts +1 -1
- package/dist/utils/demo-shell/index.d.ts +1 -1
- package/dist/utils/demo-shell/index.js +2 -2
- package/dist/utils/domain-templates/index.cjs +1 -1
- package/dist/utils/domain-templates/index.cjs.map +1 -1
- package/dist/utils/domain-templates/index.js +3 -3
- package/dist/utils/graphspec/index.cjs +1 -1
- package/dist/utils/graphspec/index.cjs.map +1 -1
- package/dist/utils/graphspec/index.js +3 -3
- package/dist/utils/harness/index.cjs +16 -10
- package/dist/utils/harness/index.cjs.map +1 -1
- package/dist/utils/harness/index.js +1 -1
- package/dist/utils/index.cjs +1692 -1192
- package/dist/utils/index.cjs.map +1 -1
- package/dist/utils/index.d.cts +7 -7
- package/dist/utils/index.d.ts +7 -7
- package/dist/utils/index.js +77 -59
- package/dist/utils/inspect/index.cjs +52 -4
- package/dist/utils/inspect/index.cjs.map +1 -1
- package/dist/utils/inspect/index.d.cts +32 -3
- package/dist/utils/inspect/index.d.ts +32 -3
- package/dist/utils/inspect/index.js +4 -4
- package/dist/utils/job-queue/index.cjs +46 -9
- package/dist/utils/job-queue/index.cjs.map +1 -1
- package/dist/utils/job-queue/index.d.cts +33 -3
- package/dist/utils/job-queue/index.d.ts +33 -3
- package/dist/utils/job-queue/index.js +2 -2
- package/dist/utils/memory/index.cjs +570 -425
- package/dist/utils/memory/index.cjs.map +1 -1
- package/dist/utils/memory/index.d.cts +261 -33
- package/dist/utils/memory/index.d.ts +261 -33
- package/dist/utils/memory/index.js +10 -2
- package/dist/utils/messaging/index.cjs.map +1 -1
- package/dist/utils/messaging/index.d.cts +4 -3
- package/dist/utils/messaging/index.d.ts +4 -3
- package/dist/utils/messaging/index.js +2 -2
- package/dist/utils/orchestration/index.cjs +14 -3
- package/dist/utils/orchestration/index.cjs.map +1 -1
- package/dist/utils/orchestration/index.js +3 -3
- package/dist/utils/process/index.cjs +32 -2
- package/dist/utils/process/index.cjs.map +1 -1
- package/dist/utils/process/index.d.cts +4 -3
- package/dist/utils/process/index.d.ts +4 -3
- package/dist/utils/process/index.js +3 -3
- package/dist/utils/reactive-layout/index.cjs +184 -55
- package/dist/utils/reactive-layout/index.cjs.map +1 -1
- package/dist/utils/reactive-layout/index.d.cts +128 -3
- package/dist/utils/reactive-layout/index.d.ts +128 -3
- package/dist/utils/reactive-layout/index.js +16 -8
- package/dist/utils/reduction/index.cjs +1 -1
- package/dist/utils/reduction/index.cjs.map +1 -1
- package/dist/utils/reduction/index.js +2 -2
- package/dist/utils/resilience/index.cjs +64 -43
- package/dist/utils/resilience/index.cjs.map +1 -1
- package/dist/utils/resilience/index.d.cts +1 -1
- package/dist/utils/resilience/index.d.ts +1 -1
- package/dist/utils/resilience/index.js +5 -5
- package/dist/utils/surface/index.cjs +1 -1
- package/dist/utils/surface/index.cjs.map +1 -1
- package/dist/utils/surface/index.js +4 -4
- package/package.json +15 -3
- package/dist/chunk-3PSLNJDU.js.map +0 -1
- package/dist/chunk-42FQ27MQ.js.map +0 -1
- package/dist/chunk-4XCHZRUJ.js.map +0 -1
- package/dist/chunk-6XZYT4SW.js.map +0 -1
- package/dist/chunk-7ADWWI2T.js.map +0 -1
- package/dist/chunk-B4AKFXGE.js.map +0 -1
- package/dist/chunk-BU3SEFA5.js.map +0 -1
- package/dist/chunk-BXGZFGZ4.js.map +0 -1
- package/dist/chunk-DKNHAICT.js.map +0 -1
- package/dist/chunk-E5OZPDIW.js.map +0 -1
- package/dist/chunk-EVYY4X5A.js.map +0 -1
- package/dist/chunk-IJRR6YAI.js.map +0 -1
- package/dist/chunk-K7PDZYQE.js.map +0 -1
- package/dist/chunk-NPRP3MCV.js.map +0 -1
- package/dist/chunk-NY2PYHNC.js.map +0 -1
- package/dist/chunk-OCUDSN63.js.map +0 -1
- package/dist/chunk-PKPO3JTZ.js.map +0 -1
- package/dist/chunk-PZWISPIQ.js.map +0 -1
- package/dist/chunk-RGMTUZCL.js.map +0 -1
- package/dist/chunk-RJOG4IJU.js.map +0 -1
- package/dist/chunk-SOOKUYVM.js.map +0 -1
- package/dist/chunk-U225SKB4.js.map +0 -1
- package/dist/chunk-V4Y3TM7U.js.map +0 -1
- package/dist/chunk-VLAGJZSL.js.map +0 -1
- package/dist/chunk-W2BOPXTI.js +0 -1
- package/dist/chunk-YJ4U2D2C.js.map +0 -1
- package/dist/chunk-YXCPV26R.js.map +0 -1
- package/dist/timeout-U5O4ESK3.js.map +0 -1
- /package/dist/{chunk-J5WFUEO4.js.map → chunk-23MAWVOJ.js.map} +0 -0
- /package/dist/{chunk-2OB3CEJS.js.map → chunk-B5Y5GPD5.js.map} +0 -0
- /package/dist/{chunk-MTTRCEJT.js.map → chunk-DVTDF5OI.js.map} +0 -0
- /package/dist/{chunk-A7KV5UK4.js.map → chunk-G7H6PN7P.js.map} +0 -0
- /package/dist/{chunk-O3MT7DYI.js.map → chunk-N6MNJNHB.js.map} +0 -0
- /package/dist/{chunk-DM4OMPWK.js.map → chunk-NSA5K5G2.js.map} +0 -0
- /package/dist/{chunk-MLTPJMH6.js.map → chunk-QQYULEZL.js.map} +0 -0
- /package/dist/{chunk-4S53H2KR.js.map → chunk-SUNCHMML.js.map} +0 -0
- /package/dist/{chunk-4GYMCUDZ.js.map → chunk-T2U6N3FV.js.map} +0 -0
- /package/dist/{chunk-W2BOPXTI.js.map → timeout-BEABACRP.js.map} +0 -0
package/dist/utils/ai/index.cjs
CHANGED
|
@@ -202,6 +202,7 @@ __export(ai_exports, {
|
|
|
202
202
|
tier: () => tier,
|
|
203
203
|
toolCallExtractor: () => toolCallExtractor,
|
|
204
204
|
toolExecution: () => toolExecution,
|
|
205
|
+
toolInterceptor: () => toolInterceptor,
|
|
205
206
|
toolRegistry: () => toolRegistry,
|
|
206
207
|
toolSelector: () => toolSelector,
|
|
207
208
|
validateGraphDef: () => validateGraphDef,
|
|
@@ -2606,9 +2607,11 @@ function _retrySource(source, opts, emitState) {
|
|
|
2606
2607
|
const merged = makeMergedOptsMirror(opts);
|
|
2607
2608
|
const getCfg = () => resolveRetryConfig(merged.current());
|
|
2608
2609
|
const inner = _runRetryStateMachine(getCfg, () => source, a, emitState);
|
|
2609
|
-
return
|
|
2610
|
-
|
|
2611
|
-
|
|
2610
|
+
return {
|
|
2611
|
+
onDeactivation: () => {
|
|
2612
|
+
inner();
|
|
2613
|
+
merged.unsub();
|
|
2614
|
+
}
|
|
2612
2615
|
};
|
|
2613
2616
|
},
|
|
2614
2617
|
{
|
|
@@ -2632,9 +2635,11 @@ function _retryFactory(factory, opts, emitState) {
|
|
|
2632
2635
|
const merged = makeMergedOptsMirror(opts);
|
|
2633
2636
|
const getCfg = () => resolveRetryConfig(merged.current());
|
|
2634
2637
|
const inner = _runRetryStateMachine(getCfg, factory, a, emitState);
|
|
2635
|
-
return
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
+
return {
|
|
2639
|
+
onDeactivation: () => {
|
|
2640
|
+
inner();
|
|
2641
|
+
merged.unsub();
|
|
2642
|
+
}
|
|
2638
2643
|
};
|
|
2639
2644
|
},
|
|
2640
2645
|
{
|
|
@@ -4171,8 +4176,10 @@ function promptNode(adapter, deps, prompt, opts) {
|
|
|
4171
4176
|
} catch (err) {
|
|
4172
4177
|
done = true;
|
|
4173
4178
|
actions.down([[import_core23.ERROR, err]]);
|
|
4174
|
-
return
|
|
4175
|
-
|
|
4179
|
+
return {
|
|
4180
|
+
onDeactivation: () => {
|
|
4181
|
+
abortDispose?.();
|
|
4182
|
+
}
|
|
4176
4183
|
};
|
|
4177
4184
|
}
|
|
4178
4185
|
const callNode = (0, import_extra18.fromAny)(invokeResult);
|
|
@@ -4230,11 +4237,13 @@ function promptNode(adapter, deps, prompt, opts) {
|
|
|
4230
4237
|
}
|
|
4231
4238
|
}
|
|
4232
4239
|
});
|
|
4233
|
-
return
|
|
4234
|
-
|
|
4235
|
-
|
|
4236
|
-
|
|
4237
|
-
|
|
4240
|
+
return {
|
|
4241
|
+
onDeactivation: () => {
|
|
4242
|
+
cancelled = true;
|
|
4243
|
+
sub();
|
|
4244
|
+
abortDispose?.();
|
|
4245
|
+
abortDispose = void 0;
|
|
4246
|
+
}
|
|
4238
4247
|
};
|
|
4239
4248
|
},
|
|
4240
4249
|
{
|
|
@@ -4747,6 +4756,10 @@ var PipelineGraph = class extends import_graph3.Graph {
|
|
|
4747
4756
|
{
|
|
4748
4757
|
name,
|
|
4749
4758
|
describeKind: "derived",
|
|
4759
|
+
// Spec §2.7 R2.7.1 (DS-2.7.A). fn must fire on
|
|
4760
|
+
// upstream-COMPLETE/ERROR-only-without-DATA so the
|
|
4761
|
+
// teardown-decision record + downstream terminal forward run.
|
|
4762
|
+
terminalAsRealInput: true,
|
|
4750
4763
|
meta: meta("approval_gate", opts.meta)
|
|
4751
4764
|
}
|
|
4752
4765
|
);
|
|
@@ -4964,6 +4977,11 @@ var PipelineGraph = class extends import_graph3.Graph {
|
|
|
4964
4977
|
describeKind: "derived",
|
|
4965
4978
|
completeWhenDepsComplete: opts.completeWhenDepsComplete ?? !(mode === "completed" || mode === "terminal"),
|
|
4966
4979
|
errorWhenDepsError: !(mode === "errored" || mode === "terminal"),
|
|
4980
|
+
// Spec §2.7 R2.7.1 (DS-2.7.A). `catch` exists to fire on a
|
|
4981
|
+
// source terminal — its whole job is `recover(cause, …)` on a
|
|
4982
|
+
// terminal-only wave. Without this opt-in the gate holds and
|
|
4983
|
+
// the recover branch never runs.
|
|
4984
|
+
terminalAsRealInput: true,
|
|
4967
4985
|
meta: meta("catch", opts.meta)
|
|
4968
4986
|
}
|
|
4969
4987
|
);
|
|
@@ -5780,9 +5798,83 @@ function executeOne(call, tools, retryCount, onError) {
|
|
|
5780
5798
|
}));
|
|
5781
5799
|
}
|
|
5782
5800
|
|
|
5783
|
-
// src/utils/ai/agents/tool-
|
|
5801
|
+
// src/utils/ai/agents/tool-interceptor.ts
|
|
5784
5802
|
var import_core39 = require("@graphrefly/pure-ts/core");
|
|
5785
5803
|
var import_extra26 = require("@graphrefly/pure-ts/extra");
|
|
5804
|
+
function toolInterceptor(opts = {}) {
|
|
5805
|
+
return (calls) => {
|
|
5806
|
+
const enabledNode = opts.enabled != null ? (0, import_extra26.fromAny)(opts.enabled) : void 0;
|
|
5807
|
+
const predNodes = (opts.allow ?? []).map((p) => (0, import_extra26.fromAny)(p));
|
|
5808
|
+
const deps = [calls, ...enabledNode ? [enabledNode] : [], ...predNodes];
|
|
5809
|
+
return (0, import_core39.node)(
|
|
5810
|
+
deps,
|
|
5811
|
+
(batchData, actions, ctx) => {
|
|
5812
|
+
const callsBatch = batchData[0];
|
|
5813
|
+
if (callsBatch == null || callsBatch.length === 0) {
|
|
5814
|
+
actions.down([[import_core39.RESOLVED]]);
|
|
5815
|
+
return;
|
|
5816
|
+
}
|
|
5817
|
+
const data = batchData.map(
|
|
5818
|
+
(batch8, i) => batch8 != null && batch8.length > 0 ? batch8.at(-1) : ctx.prevData[i]
|
|
5819
|
+
);
|
|
5820
|
+
const incoming = data[0] ?? [];
|
|
5821
|
+
let cursor = 1;
|
|
5822
|
+
if (enabledNode) {
|
|
5823
|
+
const enabled = data[cursor++];
|
|
5824
|
+
if (enabled === false) {
|
|
5825
|
+
actions.down([[import_core39.RESOLVED]]);
|
|
5826
|
+
return;
|
|
5827
|
+
}
|
|
5828
|
+
}
|
|
5829
|
+
const preds = data.slice(cursor);
|
|
5830
|
+
const kept = incoming.filter((call) => {
|
|
5831
|
+
for (const pred of preds) {
|
|
5832
|
+
if (pred == null) continue;
|
|
5833
|
+
try {
|
|
5834
|
+
if (!pred(call)) return false;
|
|
5835
|
+
} catch {
|
|
5836
|
+
return false;
|
|
5837
|
+
}
|
|
5838
|
+
}
|
|
5839
|
+
return true;
|
|
5840
|
+
});
|
|
5841
|
+
if (kept.length === 0) {
|
|
5842
|
+
actions.down([[import_core39.RESOLVED]]);
|
|
5843
|
+
return;
|
|
5844
|
+
}
|
|
5845
|
+
actions.emit(kept);
|
|
5846
|
+
},
|
|
5847
|
+
{
|
|
5848
|
+
name: opts.name ?? "tool-interceptor",
|
|
5849
|
+
describeKind: "derived",
|
|
5850
|
+
// NON-partial (no `partial: true`) — deliberate. A seeded
|
|
5851
|
+
// `enabled`/predicate (with an `initial`) emits on activation,
|
|
5852
|
+
// so it is honoured before any tool call flows (the contract
|
|
5853
|
+
// callers must follow — see `allow` JSDoc). `partial: true`
|
|
5854
|
+
// was tried and REJECTED: it un-gates the node so `calls`
|
|
5855
|
+
// races ahead of a slower seeded policy dep on the activation
|
|
5856
|
+
// wave and leaks denied calls fail-OPEN. A *never-seeded*
|
|
5857
|
+
// (pure SENTINEL) policy has unspecified gating under either
|
|
5858
|
+
// setting — callers must seed an `initial`; not relied on.
|
|
5859
|
+
// Cross-ref `tool-selector.ts` (same non-partial shape).
|
|
5860
|
+
meta: { ...aiMeta("tool_interceptor"), ...(0, import_core39.factoryTag)("toolInterceptor") },
|
|
5861
|
+
equals: (a, b) => {
|
|
5862
|
+
const la = a;
|
|
5863
|
+
const lb = b;
|
|
5864
|
+
if (la.length !== lb.length) return false;
|
|
5865
|
+
for (let i = 0; i < la.length; i++) {
|
|
5866
|
+
if (la[i] !== lb[i]) return false;
|
|
5867
|
+
}
|
|
5868
|
+
return true;
|
|
5869
|
+
}
|
|
5870
|
+
}
|
|
5871
|
+
);
|
|
5872
|
+
};
|
|
5873
|
+
}
|
|
5874
|
+
|
|
5875
|
+
// src/utils/ai/agents/tool-registry.ts
|
|
5876
|
+
var import_core40 = require("@graphrefly/pure-ts/core");
|
|
5877
|
+
var import_extra27 = require("@graphrefly/pure-ts/extra");
|
|
5786
5878
|
var import_graph5 = require("@graphrefly/pure-ts/graph");
|
|
5787
5879
|
var ToolRegistryGraph = class extends import_graph5.Graph {
|
|
5788
5880
|
definitions;
|
|
@@ -5790,12 +5882,12 @@ var ToolRegistryGraph = class extends import_graph5.Graph {
|
|
|
5790
5882
|
_bundle;
|
|
5791
5883
|
constructor(name, opts = {}) {
|
|
5792
5884
|
super(name, opts.graph);
|
|
5793
|
-
this._bundle = (0,
|
|
5885
|
+
this._bundle = (0, import_extra27.reactiveMap)({
|
|
5794
5886
|
name: "definitions"
|
|
5795
5887
|
});
|
|
5796
5888
|
this.definitions = this._bundle.entries;
|
|
5797
5889
|
this.add(this.definitions, { name: "definitions" });
|
|
5798
|
-
this.schemas = (0,
|
|
5890
|
+
this.schemas = (0, import_core40.node)(
|
|
5799
5891
|
[this.definitions],
|
|
5800
5892
|
(batchData, actions, ctx) => {
|
|
5801
5893
|
const data = batchData.map(
|
|
@@ -5812,7 +5904,7 @@ var ToolRegistryGraph = class extends import_graph5.Graph {
|
|
|
5812
5904
|
}
|
|
5813
5905
|
);
|
|
5814
5906
|
this.add(this.schemas, { name: "schemas" });
|
|
5815
|
-
this.addDisposer((0,
|
|
5907
|
+
this.addDisposer((0, import_extra27.keepalive)(this.schemas));
|
|
5816
5908
|
}
|
|
5817
5909
|
register(tool) {
|
|
5818
5910
|
this._bundle.set(tool.name, tool);
|
|
@@ -5847,7 +5939,7 @@ var ToolRegistryGraph = class extends import_graph5.Graph {
|
|
|
5847
5939
|
executeReactive(name, args) {
|
|
5848
5940
|
const tool = this._bundle.get(name);
|
|
5849
5941
|
if (!tool) throw new Error(`toolRegistry: unknown tool "${name}"`);
|
|
5850
|
-
return (0,
|
|
5942
|
+
return (0, import_core40.node)(
|
|
5851
5943
|
[],
|
|
5852
5944
|
(_data, actions) => {
|
|
5853
5945
|
const ac = new AbortController();
|
|
@@ -5856,17 +5948,21 @@ var ToolRegistryGraph = class extends import_graph5.Graph {
|
|
|
5856
5948
|
const raw = tool.handler(args, { signal: ac.signal });
|
|
5857
5949
|
inner = handlerResultToNode(raw, ac.signal);
|
|
5858
5950
|
} catch (err) {
|
|
5859
|
-
actions.down([[
|
|
5860
|
-
return
|
|
5861
|
-
|
|
5951
|
+
actions.down([[import_core40.ERROR, err]]);
|
|
5952
|
+
return {
|
|
5953
|
+
onDeactivation: () => {
|
|
5954
|
+
ac.abort();
|
|
5955
|
+
}
|
|
5862
5956
|
};
|
|
5863
5957
|
}
|
|
5864
5958
|
const unsub = inner.subscribe((batch8) => {
|
|
5865
5959
|
actions.down(batch8);
|
|
5866
5960
|
});
|
|
5867
|
-
return
|
|
5868
|
-
|
|
5869
|
-
|
|
5961
|
+
return {
|
|
5962
|
+
onDeactivation: () => {
|
|
5963
|
+
ac.abort();
|
|
5964
|
+
unsub();
|
|
5965
|
+
}
|
|
5870
5966
|
};
|
|
5871
5967
|
},
|
|
5872
5968
|
{
|
|
@@ -5888,22 +5984,22 @@ function handlerResultToNode(raw, signal) {
|
|
|
5888
5984
|
return raw;
|
|
5889
5985
|
}
|
|
5890
5986
|
if (raw != null && typeof raw.then === "function") {
|
|
5891
|
-
return (0,
|
|
5987
|
+
return (0, import_extra27.fromPromise)(raw, { signal });
|
|
5892
5988
|
}
|
|
5893
5989
|
if (raw != null && typeof raw === "object" && Symbol.asyncIterator in raw) {
|
|
5894
|
-
return (0,
|
|
5990
|
+
return (0, import_extra27.fromAsyncIter)(raw, { signal });
|
|
5895
5991
|
}
|
|
5896
|
-
return (0,
|
|
5992
|
+
return (0, import_extra27.fromPromise)(Promise.resolve(raw), { signal });
|
|
5897
5993
|
}
|
|
5898
5994
|
|
|
5899
5995
|
// src/utils/ai/agents/tool-selector.ts
|
|
5900
|
-
var
|
|
5901
|
-
var
|
|
5996
|
+
var import_core41 = require("@graphrefly/pure-ts/core");
|
|
5997
|
+
var import_extra28 = require("@graphrefly/pure-ts/extra");
|
|
5902
5998
|
function toolSelector(allTools, constraints, opts) {
|
|
5903
|
-
const allToolsNode = (0,
|
|
5904
|
-
const constraintNodes = constraints.map((c) => (0,
|
|
5999
|
+
const allToolsNode = (0, import_extra28.fromAny)(allTools);
|
|
6000
|
+
const constraintNodes = constraints.map((c) => (0, import_extra28.fromAny)(c));
|
|
5905
6001
|
const deps = [allToolsNode, ...constraintNodes];
|
|
5906
|
-
return (0,
|
|
6002
|
+
return (0, import_core41.node)(
|
|
5907
6003
|
deps,
|
|
5908
6004
|
(batchData, actions, ctx) => {
|
|
5909
6005
|
const data = batchData.map(
|
|
@@ -5924,7 +6020,7 @@ function toolSelector(allTools, constraints, opts) {
|
|
|
5924
6020
|
{
|
|
5925
6021
|
name: opts?.name ?? "tool-selector",
|
|
5926
6022
|
describeKind: "derived",
|
|
5927
|
-
meta: { ...aiMeta("tool_selector"), ...(0,
|
|
6023
|
+
meta: { ...aiMeta("tool_selector"), ...(0, import_core41.factoryTag)("toolSelector") },
|
|
5928
6024
|
equals: (a, b) => {
|
|
5929
6025
|
const la = a;
|
|
5930
6026
|
const lb = b;
|
|
@@ -5971,20 +6067,20 @@ function admissionFilter3D(opts) {
|
|
|
5971
6067
|
}
|
|
5972
6068
|
|
|
5973
6069
|
// src/utils/ai/memory/memory-composers.ts
|
|
5974
|
-
var
|
|
5975
|
-
var
|
|
6070
|
+
var import_core45 = require("@graphrefly/pure-ts/core");
|
|
6071
|
+
var import_extra33 = require("@graphrefly/pure-ts/extra");
|
|
5976
6072
|
var import_graph7 = require("@graphrefly/pure-ts/graph");
|
|
5977
6073
|
|
|
5978
6074
|
// src/base/composition/distill.ts
|
|
5979
|
-
var
|
|
5980
|
-
var
|
|
6075
|
+
var import_core43 = require("@graphrefly/pure-ts/core");
|
|
6076
|
+
var import_extra31 = require("@graphrefly/pure-ts/extra");
|
|
5981
6077
|
|
|
5982
6078
|
// src/base/sources/async.ts
|
|
5983
|
-
var
|
|
5984
|
-
var import_extra28 = require("@graphrefly/pure-ts/extra");
|
|
6079
|
+
var import_core42 = require("@graphrefly/pure-ts/core");
|
|
5985
6080
|
var import_extra29 = require("@graphrefly/pure-ts/extra");
|
|
6081
|
+
var import_extra30 = require("@graphrefly/pure-ts/extra");
|
|
5986
6082
|
function forEach(source, fn, opts) {
|
|
5987
|
-
const inner = (0,
|
|
6083
|
+
const inner = (0, import_core42.node)(
|
|
5988
6084
|
[source],
|
|
5989
6085
|
(data, _actions) => {
|
|
5990
6086
|
const batch0 = data[0];
|
|
@@ -6002,8 +6098,8 @@ function forEach(source, fn, opts) {
|
|
|
6002
6098
|
function isNodeLike2(value) {
|
|
6003
6099
|
return typeof value === "object" && value !== null && "cache" in value && typeof value.subscribe === "function";
|
|
6004
6100
|
}
|
|
6005
|
-
function keepalive9(
|
|
6006
|
-
|
|
6101
|
+
function keepalive9(node39) {
|
|
6102
|
+
node39.subscribe(() => void 0);
|
|
6007
6103
|
}
|
|
6008
6104
|
function mapFromSnapshot(snapshot) {
|
|
6009
6105
|
if (snapshot instanceof Map) return snapshot;
|
|
@@ -6013,7 +6109,7 @@ function applyExtraction(store, extraction) {
|
|
|
6013
6109
|
if (!Array.isArray(extraction.upsert)) {
|
|
6014
6110
|
throw new TypeError("distill extraction requires upsert: Array<{ key, value }>");
|
|
6015
6111
|
}
|
|
6016
|
-
(0,
|
|
6112
|
+
(0, import_core43.batch)(() => {
|
|
6017
6113
|
for (const { key, value } of extraction.upsert) {
|
|
6018
6114
|
store.set(key, value);
|
|
6019
6115
|
}
|
|
@@ -6023,12 +6119,12 @@ function applyExtraction(store, extraction) {
|
|
|
6023
6119
|
});
|
|
6024
6120
|
}
|
|
6025
6121
|
function distill(source, extractFn, opts) {
|
|
6026
|
-
const sourceNode = (0,
|
|
6027
|
-
const store = (0,
|
|
6122
|
+
const sourceNode = (0, import_extra31.fromAny)(source);
|
|
6123
|
+
const store = (0, import_extra31.reactiveMap)(opts.mapOptions ?? {});
|
|
6028
6124
|
const budget = opts.budget ?? 2e3;
|
|
6029
6125
|
const hasContext = opts.context !== void 0 && opts.context !== null;
|
|
6030
|
-
const contextNode = hasContext ? (0,
|
|
6031
|
-
const extractionStream = (0,
|
|
6126
|
+
const contextNode = hasContext ? (0, import_extra31.fromAny)(opts.context) : (0, import_core43.node)([], { initial: null });
|
|
6127
|
+
const extractionStream = (0, import_extra31.fromAny)(
|
|
6032
6128
|
extractFn(sourceNode, store.entries)
|
|
6033
6129
|
);
|
|
6034
6130
|
forEach(extractionStream, (extraction) => {
|
|
@@ -6036,7 +6132,7 @@ function distill(source, extractFn, opts) {
|
|
|
6036
6132
|
});
|
|
6037
6133
|
if (opts.evict) {
|
|
6038
6134
|
const verdictUnsubs = /* @__PURE__ */ new Map();
|
|
6039
|
-
const evictionKeys = (0,
|
|
6135
|
+
const evictionKeys = (0, import_core43.node)(
|
|
6040
6136
|
[store.entries],
|
|
6041
6137
|
(batchData, actions, ctx) => {
|
|
6042
6138
|
const batch0 = batchData[0];
|
|
@@ -6078,12 +6174,12 @@ function distill(source, extractFn, opts) {
|
|
|
6078
6174
|
}
|
|
6079
6175
|
const hasConsolidateTrigger = opts.consolidateTrigger !== void 0 && opts.consolidateTrigger !== null;
|
|
6080
6176
|
if (opts.consolidate && hasConsolidateTrigger) {
|
|
6081
|
-
const consolidateTriggerNode = (0,
|
|
6082
|
-
const consolidatePaired = (0,
|
|
6177
|
+
const consolidateTriggerNode = (0, import_extra31.fromAny)(opts.consolidateTrigger);
|
|
6178
|
+
const consolidatePaired = (0, import_extra31.withLatestFrom)(
|
|
6083
6179
|
consolidateTriggerNode,
|
|
6084
6180
|
store.entries
|
|
6085
6181
|
);
|
|
6086
|
-
const consolidationStream = (0,
|
|
6182
|
+
const consolidationStream = (0, import_extra31.switchMap)(
|
|
6087
6183
|
consolidatePaired,
|
|
6088
6184
|
([, entries]) => opts.consolidate(mapFromSnapshot(entries))
|
|
6089
6185
|
);
|
|
@@ -6091,7 +6187,7 @@ function distill(source, extractFn, opts) {
|
|
|
6091
6187
|
applyExtraction(store, extraction);
|
|
6092
6188
|
});
|
|
6093
6189
|
}
|
|
6094
|
-
const compact = (0,
|
|
6190
|
+
const compact = (0, import_core43.node)(
|
|
6095
6191
|
[store.entries, contextNode],
|
|
6096
6192
|
(batchData, actions, ctx) => {
|
|
6097
6193
|
const data = batchData.map(
|
|
@@ -6117,9 +6213,9 @@ function distill(source, extractFn, opts) {
|
|
|
6117
6213
|
}
|
|
6118
6214
|
actions.emit(packed);
|
|
6119
6215
|
},
|
|
6120
|
-
{ describeKind: "derived", meta: { ...(0,
|
|
6216
|
+
{ describeKind: "derived", meta: { ...(0, import_core43.factoryTag)("distill", { budget }) } }
|
|
6121
6217
|
);
|
|
6122
|
-
const size = (0,
|
|
6218
|
+
const size = (0, import_core43.node)(
|
|
6123
6219
|
[store.entries],
|
|
6124
6220
|
(batchData, actions, ctx) => {
|
|
6125
6221
|
const batch0 = batchData[0];
|
|
@@ -6144,16 +6240,16 @@ function decay(baseScore, ageSeconds2, ratePerSecond, minScore = 0) {
|
|
|
6144
6240
|
}
|
|
6145
6241
|
|
|
6146
6242
|
// src/utils/memory/index.ts
|
|
6147
|
-
var
|
|
6148
|
-
var
|
|
6243
|
+
var import_core44 = require("@graphrefly/pure-ts/core");
|
|
6244
|
+
var import_extra32 = require("@graphrefly/pure-ts/extra");
|
|
6149
6245
|
var import_graph6 = require("@graphrefly/pure-ts/graph");
|
|
6150
6246
|
var NS_PER_SEC2 = 1e9;
|
|
6151
6247
|
function memoryMeta(kind, extra) {
|
|
6152
6248
|
return domainMeta("memory", kind, extra);
|
|
6153
6249
|
}
|
|
6154
6250
|
function toNode(v, name) {
|
|
6155
|
-
if (v instanceof
|
|
6156
|
-
return (0,
|
|
6251
|
+
if (v instanceof import_core44.NodeImpl) return v;
|
|
6252
|
+
return (0, import_core44.node)([], { initial: v, ...name ? { name } : void 0 });
|
|
6157
6253
|
}
|
|
6158
6254
|
function ageSeconds(now, lastNs) {
|
|
6159
6255
|
return (now - lastNs) / NS_PER_SEC2;
|
|
@@ -6207,14 +6303,14 @@ function collection(name, opts = {}) {
|
|
|
6207
6303
|
}
|
|
6208
6304
|
const scoreFnDefault = () => ranked ? 1 : 0;
|
|
6209
6305
|
const scoreInput = opts.score ?? scoreFnDefault;
|
|
6210
|
-
const scoreNode = ranked && scoreInput instanceof
|
|
6306
|
+
const scoreNode = ranked && scoreInput instanceof import_core44.NodeImpl ? scoreInput : void 0;
|
|
6211
6307
|
const readScoreFn = () => {
|
|
6212
6308
|
if (scoreNode) return scoreNode.cache ?? scoreFnDefault;
|
|
6213
6309
|
return scoreInput;
|
|
6214
6310
|
};
|
|
6215
6311
|
const graph = new import_graph6.Graph(name);
|
|
6216
|
-
const retentionScore = (_k, v) => ranked ? decay(v.baseScore, ageSeconds((0,
|
|
6217
|
-
const items = (0,
|
|
6312
|
+
const retentionScore = (_k, v) => ranked ? decay(v.baseScore, ageSeconds((0, import_core44.monotonicNs)(), v.lastAccessNs), decayRate, minScore) : v.lastAccessNs;
|
|
6313
|
+
const items = (0, import_extra32.reactiveMap)({
|
|
6218
6314
|
name: "items",
|
|
6219
6315
|
...maxSize !== void 0 ? { retention: { score: retentionScore, maxSize } } : {}
|
|
6220
6316
|
});
|
|
@@ -6222,16 +6318,16 @@ function collection(name, opts = {}) {
|
|
|
6222
6318
|
let refreshTick;
|
|
6223
6319
|
if (ranked && decayRate > 0) {
|
|
6224
6320
|
const intervalMs = opts.refreshIntervalMs ?? Math.max(1, 1e3 * Math.LN2 / (10 * decayRate));
|
|
6225
|
-
const tickCounter = (0,
|
|
6226
|
-
refreshTick = (0,
|
|
6321
|
+
const tickCounter = (0, import_extra32.fromTimer)(intervalMs, { period: intervalMs });
|
|
6322
|
+
refreshTick = (0, import_core44.node)(
|
|
6227
6323
|
[tickCounter],
|
|
6228
6324
|
(_batchData, actions) => {
|
|
6229
|
-
actions.emit((0,
|
|
6325
|
+
actions.emit((0, import_core44.monotonicNs)());
|
|
6230
6326
|
},
|
|
6231
6327
|
{
|
|
6232
6328
|
name: "refresh_tick_ns",
|
|
6233
6329
|
describeKind: "derived",
|
|
6234
|
-
initial: (0,
|
|
6330
|
+
initial: (0, import_core44.monotonicNs)(),
|
|
6235
6331
|
meta: memoryMeta("clock")
|
|
6236
6332
|
}
|
|
6237
6333
|
);
|
|
@@ -6242,7 +6338,7 @@ function collection(name, opts = {}) {
|
|
|
6242
6338
|
const rankedDeps = [items.entries];
|
|
6243
6339
|
if (refreshTick) rankedDeps.push(refreshTick);
|
|
6244
6340
|
if (scoreNode) rankedDeps.push(scoreNode);
|
|
6245
|
-
rankedNode = (0,
|
|
6341
|
+
rankedNode = (0, import_core44.node)(
|
|
6246
6342
|
rankedDeps,
|
|
6247
6343
|
(batchData, actions, ctx) => {
|
|
6248
6344
|
const values = batchData.map(
|
|
@@ -6252,9 +6348,9 @@ function collection(name, opts = {}) {
|
|
|
6252
6348
|
let now;
|
|
6253
6349
|
if (refreshTick) {
|
|
6254
6350
|
const tickValue = values[1];
|
|
6255
|
-
now = typeof tickValue === "number" ? tickValue : (0,
|
|
6351
|
+
now = typeof tickValue === "number" ? tickValue : (0, import_core44.monotonicNs)();
|
|
6256
6352
|
} else {
|
|
6257
|
-
now = (0,
|
|
6353
|
+
now = (0, import_core44.monotonicNs)();
|
|
6258
6354
|
}
|
|
6259
6355
|
if (!snapshot || snapshot.size === 0) {
|
|
6260
6356
|
actions.emit([]);
|
|
@@ -6279,7 +6375,7 @@ function collection(name, opts = {}) {
|
|
|
6279
6375
|
);
|
|
6280
6376
|
graph.add(rankedNode, { name: "ranked" });
|
|
6281
6377
|
} else {
|
|
6282
|
-
rankedNode = (0,
|
|
6378
|
+
rankedNode = (0, import_core44.node)([], {
|
|
6283
6379
|
initial: [],
|
|
6284
6380
|
name: "ranked",
|
|
6285
6381
|
describeKind: "state",
|
|
@@ -6287,7 +6383,7 @@ function collection(name, opts = {}) {
|
|
|
6287
6383
|
});
|
|
6288
6384
|
graph.add(rankedNode, { name: "ranked" });
|
|
6289
6385
|
}
|
|
6290
|
-
const size = (0,
|
|
6386
|
+
const size = (0, import_core44.node)(
|
|
6291
6387
|
[items.entries],
|
|
6292
6388
|
(batchData, actions, ctx) => {
|
|
6293
6389
|
const data = batchData.map(
|
|
@@ -6304,7 +6400,7 @@ function collection(name, opts = {}) {
|
|
|
6304
6400
|
}
|
|
6305
6401
|
);
|
|
6306
6402
|
graph.add(size, { name: "size" });
|
|
6307
|
-
graph.addDisposer((0,
|
|
6403
|
+
graph.addDisposer((0, import_extra32.keepalive)(size));
|
|
6308
6404
|
const events = createAuditLog({
|
|
6309
6405
|
name: "events",
|
|
6310
6406
|
retainedLimit: 1024,
|
|
@@ -6312,7 +6408,7 @@ function collection(name, opts = {}) {
|
|
|
6312
6408
|
});
|
|
6313
6409
|
const seqCursor = registerCursor(graph, "seq", 0);
|
|
6314
6410
|
const upsertImpl = (id, value, _opts) => {
|
|
6315
|
-
const now = (0,
|
|
6411
|
+
const now = (0, import_core44.monotonicNs)();
|
|
6316
6412
|
const prev = items.get(id);
|
|
6317
6413
|
const baseScore = _opts?.score ?? readScoreFn()(value);
|
|
6318
6414
|
items.set(id, {
|
|
@@ -6368,7 +6464,7 @@ function collection(name, opts = {}) {
|
|
|
6368
6464
|
});
|
|
6369
6465
|
function itemNode(id) {
|
|
6370
6466
|
const idN = toNode(id, "id");
|
|
6371
|
-
return (0,
|
|
6467
|
+
return (0, import_core44.node)(
|
|
6372
6468
|
[items.entries, idN],
|
|
6373
6469
|
(batchData, actions, ctx) => {
|
|
6374
6470
|
const data = batchData.map(
|
|
@@ -6386,7 +6482,7 @@ function collection(name, opts = {}) {
|
|
|
6386
6482
|
}
|
|
6387
6483
|
function hasNode(id) {
|
|
6388
6484
|
const idN = toNode(id, "id");
|
|
6389
|
-
return (0,
|
|
6485
|
+
return (0, import_core44.node)(
|
|
6390
6486
|
[items.entries, idN],
|
|
6391
6487
|
(batchData, actions, ctx) => {
|
|
6392
6488
|
const data = batchData.map(
|
|
@@ -6461,7 +6557,7 @@ function vectorIndex(opts = {}) {
|
|
|
6461
6557
|
graph
|
|
6462
6558
|
});
|
|
6463
6559
|
const seqCursor = registerCursor(graph, "seq", 0);
|
|
6464
|
-
const entries = (0,
|
|
6560
|
+
const entries = (0, import_extra32.reactiveMap)({
|
|
6465
6561
|
name: "entries",
|
|
6466
6562
|
...maxSize !== void 0 ? {
|
|
6467
6563
|
retention: {
|
|
@@ -6473,7 +6569,7 @@ function vectorIndex(opts = {}) {
|
|
|
6473
6569
|
events.append({
|
|
6474
6570
|
action: "evict",
|
|
6475
6571
|
id: key,
|
|
6476
|
-
t_ns: (0,
|
|
6572
|
+
t_ns: (0, import_core44.wallClockNs)(),
|
|
6477
6573
|
seq: bumpCursor(seqCursor)
|
|
6478
6574
|
});
|
|
6479
6575
|
}
|
|
@@ -6481,7 +6577,7 @@ function vectorIndex(opts = {}) {
|
|
|
6481
6577
|
} : {}
|
|
6482
6578
|
});
|
|
6483
6579
|
graph.add(entries.entries, { name: "entries" });
|
|
6484
|
-
graph.addDisposer((0,
|
|
6580
|
+
graph.addDisposer((0, import_extra32.keepalive)(entries.entries));
|
|
6485
6581
|
if (hnsw?.dispose) {
|
|
6486
6582
|
const disposeAdapter = hnsw.dispose.bind(hnsw);
|
|
6487
6583
|
graph.addDisposer(() => disposeAdapter());
|
|
@@ -6498,7 +6594,7 @@ function vectorIndex(opts = {}) {
|
|
|
6498
6594
|
id,
|
|
6499
6595
|
vector: [...vector],
|
|
6500
6596
|
...copiedMeta !== void 0 ? { meta: copiedMeta } : {},
|
|
6501
|
-
upsertedAtNs: (0,
|
|
6597
|
+
upsertedAtNs: (0, import_core44.monotonicNs)()
|
|
6502
6598
|
};
|
|
6503
6599
|
entries.set(id, record);
|
|
6504
6600
|
};
|
|
@@ -6554,7 +6650,7 @@ function vectorIndex(opts = {}) {
|
|
|
6554
6650
|
});
|
|
6555
6651
|
function searchNode(query, k = 5) {
|
|
6556
6652
|
const kN = toNode(k, "k");
|
|
6557
|
-
return (0,
|
|
6653
|
+
return (0, import_core44.node)(
|
|
6558
6654
|
[entries.entries, query, kN],
|
|
6559
6655
|
(batchData, actions, ctx) => {
|
|
6560
6656
|
const values = batchData.map(
|
|
@@ -6660,17 +6756,17 @@ function knowledgeGraph(name, opts = {}) {
|
|
|
6660
6756
|
throw new RangeError("knowledgeGraph: edgesMaxSize must be >= 1");
|
|
6661
6757
|
}
|
|
6662
6758
|
const graph = new import_graph6.Graph(name);
|
|
6663
|
-
const entitiesMap = (0,
|
|
6759
|
+
const entitiesMap = (0, import_extra32.reactiveMap)({
|
|
6664
6760
|
name: "entities",
|
|
6665
6761
|
...opts.entitiesMaxSize !== void 0 ? { maxSize: opts.entitiesMaxSize } : {}
|
|
6666
6762
|
});
|
|
6667
|
-
const edgesMap = (0,
|
|
6763
|
+
const edgesMap = (0, import_extra32.reactiveMap)({
|
|
6668
6764
|
name: "edges",
|
|
6669
6765
|
...opts.edgesMaxSize !== void 0 ? { maxSize: opts.edgesMaxSize } : {}
|
|
6670
6766
|
});
|
|
6671
6767
|
graph.add(entitiesMap.entries, { name: "entities" });
|
|
6672
6768
|
graph.add(edgesMap.entries, { name: "edges" });
|
|
6673
|
-
const adjacencyOut = (0,
|
|
6769
|
+
const adjacencyOut = (0, import_core44.node)(
|
|
6674
6770
|
[edgesMap.entries],
|
|
6675
6771
|
(batchData, actions, ctx) => {
|
|
6676
6772
|
const data = batchData.map(
|
|
@@ -6687,7 +6783,7 @@ function knowledgeGraph(name, opts = {}) {
|
|
|
6687
6783
|
meta: memoryMeta("adjacency_out")
|
|
6688
6784
|
}
|
|
6689
6785
|
);
|
|
6690
|
-
const adjacencyIn = (0,
|
|
6786
|
+
const adjacencyIn = (0, import_core44.node)(
|
|
6691
6787
|
[edgesMap.entries],
|
|
6692
6788
|
(batchData, actions, ctx) => {
|
|
6693
6789
|
const data = batchData.map(
|
|
@@ -6706,9 +6802,9 @@ function knowledgeGraph(name, opts = {}) {
|
|
|
6706
6802
|
);
|
|
6707
6803
|
graph.add(adjacencyOut, { name: "adjacencyOut" });
|
|
6708
6804
|
graph.add(adjacencyIn, { name: "adjacencyIn" });
|
|
6709
|
-
graph.addDisposer((0,
|
|
6710
|
-
graph.addDisposer((0,
|
|
6711
|
-
const entityCount = (0,
|
|
6805
|
+
graph.addDisposer((0, import_extra32.keepalive)(adjacencyOut));
|
|
6806
|
+
graph.addDisposer((0, import_extra32.keepalive)(adjacencyIn));
|
|
6807
|
+
const entityCount = (0, import_core44.node)(
|
|
6712
6808
|
[entitiesMap.entries],
|
|
6713
6809
|
(batchData, actions, ctx) => {
|
|
6714
6810
|
const data = batchData.map(
|
|
@@ -6719,7 +6815,7 @@ function knowledgeGraph(name, opts = {}) {
|
|
|
6719
6815
|
},
|
|
6720
6816
|
{ name: "entityCount", describeKind: "derived", initial: 0, meta: memoryMeta("entity_count") }
|
|
6721
6817
|
);
|
|
6722
|
-
const edgeCount = (0,
|
|
6818
|
+
const edgeCount = (0, import_core44.node)(
|
|
6723
6819
|
[edgesMap.entries],
|
|
6724
6820
|
(batchData, actions, ctx) => {
|
|
6725
6821
|
const data = batchData.map(
|
|
@@ -6732,8 +6828,8 @@ function knowledgeGraph(name, opts = {}) {
|
|
|
6732
6828
|
);
|
|
6733
6829
|
graph.add(entityCount, { name: "entityCount" });
|
|
6734
6830
|
graph.add(edgeCount, { name: "edgeCount" });
|
|
6735
|
-
graph.addDisposer((0,
|
|
6736
|
-
graph.addDisposer((0,
|
|
6831
|
+
graph.addDisposer((0, import_extra32.keepalive)(entityCount));
|
|
6832
|
+
graph.addDisposer((0, import_extra32.keepalive)(edgeCount));
|
|
6737
6833
|
const events = createAuditLog({
|
|
6738
6834
|
name: "events",
|
|
6739
6835
|
retainedLimit: 1024,
|
|
@@ -6756,7 +6852,7 @@ function knowledgeGraph(name, opts = {}) {
|
|
|
6756
6852
|
events.append({
|
|
6757
6853
|
action: "orphanRemove",
|
|
6758
6854
|
id: candidate,
|
|
6759
|
-
t_ns: (0,
|
|
6855
|
+
t_ns: (0, import_core44.wallClockNs)(),
|
|
6760
6856
|
seq: bumpCursor(seqCursor)
|
|
6761
6857
|
});
|
|
6762
6858
|
}
|
|
@@ -6851,7 +6947,7 @@ function knowledgeGraph(name, opts = {}) {
|
|
|
6851
6947
|
const idN = toNode(id, "id");
|
|
6852
6948
|
const relN = relation !== void 0 ? toNode(relation, "relation") : void 0;
|
|
6853
6949
|
const deps = relN ? [adjacencyOut, adjacencyIn, idN, relN] : [adjacencyOut, adjacencyIn, idN];
|
|
6854
|
-
return (0,
|
|
6950
|
+
return (0, import_core44.node)(
|
|
6855
6951
|
deps,
|
|
6856
6952
|
(batchData, actions, ctx) => {
|
|
6857
6953
|
const values = batchData.map(
|
|
@@ -6927,7 +7023,7 @@ var MemoryWithVectorsGraph = class extends import_graph7.Graph {
|
|
|
6927
7023
|
this.mount("vectorIndex", this.vectors);
|
|
6928
7024
|
const embedFn = opts.embedFn;
|
|
6929
7025
|
const vectorsRef = this.vectors;
|
|
6930
|
-
const indexer = (0,
|
|
7026
|
+
const indexer = (0, import_core45.node)(
|
|
6931
7027
|
[opts.store.store.entries],
|
|
6932
7028
|
(batchData, _actions, ctx) => {
|
|
6933
7029
|
const data = batchData.map(
|
|
@@ -6942,7 +7038,7 @@ var MemoryWithVectorsGraph = class extends import_graph7.Graph {
|
|
|
6942
7038
|
{ name: "indexer", describeKind: "effect" }
|
|
6943
7039
|
);
|
|
6944
7040
|
this.add(indexer, { name: "indexer" });
|
|
6945
|
-
this.addDisposer((0,
|
|
7041
|
+
this.addDisposer((0, import_extra33.keepalive)(indexer));
|
|
6946
7042
|
}
|
|
6947
7043
|
};
|
|
6948
7044
|
function memoryWithVectors(opts) {
|
|
@@ -6960,7 +7056,7 @@ var MemoryWithKGGraph = class extends import_graph7.Graph {
|
|
|
6960
7056
|
if (!opts.entityFn) return;
|
|
6961
7057
|
const entityFn = opts.entityFn;
|
|
6962
7058
|
const kgRef = this.kg;
|
|
6963
|
-
const indexer = (0,
|
|
7059
|
+
const indexer = (0, import_core45.node)(
|
|
6964
7060
|
[opts.store.store.entries],
|
|
6965
7061
|
(batchData, _actions, ctx) => {
|
|
6966
7062
|
const data = batchData.map(
|
|
@@ -6981,7 +7077,7 @@ var MemoryWithKGGraph = class extends import_graph7.Graph {
|
|
|
6981
7077
|
{ name: "indexer", describeKind: "effect" }
|
|
6982
7078
|
);
|
|
6983
7079
|
this.add(indexer, { name: "indexer" });
|
|
6984
|
-
this.addDisposer((0,
|
|
7080
|
+
this.addDisposer((0, import_extra33.keepalive)(indexer));
|
|
6985
7081
|
}
|
|
6986
7082
|
};
|
|
6987
7083
|
function memoryWithKG(opts) {
|
|
@@ -7003,20 +7099,20 @@ var MemoryWithTiersGraph = class extends import_graph7.Graph {
|
|
|
7003
7099
|
const permanentFilter = opts.permanentFilter ?? (() => false);
|
|
7004
7100
|
this.permanent = collection("permanent", { ranked: false });
|
|
7005
7101
|
this.mount("permanent", this.permanent);
|
|
7006
|
-
this.permanentKeys = (0,
|
|
7102
|
+
this.permanentKeys = (0, import_extra33.reactiveMap)({ name: "permanentKeys" });
|
|
7007
7103
|
this.add(this.permanentKeys.entries, { name: "permanentKeys" });
|
|
7008
|
-
this.entryCreatedAtNs = (0,
|
|
7104
|
+
this.entryCreatedAtNs = (0, import_extra33.reactiveMap)({ name: "entryCreatedAtNs" });
|
|
7009
7105
|
this.add(this.entryCreatedAtNs.entries, { name: "entryCreatedAtNs" });
|
|
7010
7106
|
let contextNode;
|
|
7011
7107
|
if (opts.context) {
|
|
7012
|
-
contextNode = (0,
|
|
7108
|
+
contextNode = (0, import_extra33.fromAny)(opts.context);
|
|
7013
7109
|
} else {
|
|
7014
|
-
contextNode = (0,
|
|
7110
|
+
contextNode = (0, import_core45.node)([], { initial: null });
|
|
7015
7111
|
this.add(contextNode, { name: "context" });
|
|
7016
7112
|
}
|
|
7017
7113
|
let latestCtx = contextNode.cache;
|
|
7018
7114
|
const ctxUnsub = contextNode.subscribe((msgs) => {
|
|
7019
|
-
for (const m of msgs) if (m[0] ===
|
|
7115
|
+
for (const m of msgs) if (m[0] === import_core45.DATA) latestCtx = m[1];
|
|
7020
7116
|
});
|
|
7021
7117
|
this.addDisposer(ctxUnsub);
|
|
7022
7118
|
const permanentKeysRef = this.permanentKeys;
|
|
@@ -7026,7 +7122,7 @@ var MemoryWithTiersGraph = class extends import_graph7.Graph {
|
|
|
7026
7122
|
score: (key, value) => {
|
|
7027
7123
|
if (permanentFilter(key, value)) return Number.POSITIVE_INFINITY;
|
|
7028
7124
|
if (permanentKeysRef.has(key)) return Number.POSITIVE_INFINITY;
|
|
7029
|
-
const nowNs = (0,
|
|
7125
|
+
const nowNs = (0, import_core45.monotonicNs)();
|
|
7030
7126
|
const createdNs = entryCreatedAtNsRef.get(key) ?? nowNs;
|
|
7031
7127
|
const ageSeconds2 = Number(nowNs - createdNs) / 1e9;
|
|
7032
7128
|
return decay(score(value, latestCtx), ageSeconds2, decayRate);
|
|
@@ -7061,20 +7157,20 @@ var MemoryWithTiersGraph = class extends import_graph7.Graph {
|
|
|
7061
7157
|
permanentKeysRef.set(key, true);
|
|
7062
7158
|
permanentRef.upsert(key, value);
|
|
7063
7159
|
};
|
|
7064
|
-
const syncCreatedAt = (0,
|
|
7160
|
+
const syncCreatedAt = (0, import_core45.node)(
|
|
7065
7161
|
[this.store.store.entries],
|
|
7066
7162
|
(batchData, _actions, ctx) => {
|
|
7067
7163
|
const data = batchData.map(
|
|
7068
7164
|
(b, i) => b != null && b.length > 0 ? b.at(-1) : ctx.prevData[i]
|
|
7069
7165
|
);
|
|
7070
7166
|
const map = data[0] ?? /* @__PURE__ */ new Map();
|
|
7071
|
-
const nowNs = (0,
|
|
7167
|
+
const nowNs = (0, import_core45.monotonicNs)();
|
|
7072
7168
|
const toAdd = [];
|
|
7073
7169
|
for (const key of map.keys()) {
|
|
7074
7170
|
if (!entryCreatedAtNsRef.has(key)) toAdd.push(key);
|
|
7075
7171
|
}
|
|
7076
7172
|
if (toAdd.length > 0) {
|
|
7077
|
-
(0,
|
|
7173
|
+
(0, import_core45.batch)(() => {
|
|
7078
7174
|
for (const key of toAdd) entryCreatedAtNsRef.set(key, nowNs);
|
|
7079
7175
|
});
|
|
7080
7176
|
}
|
|
@@ -7082,10 +7178,10 @@ var MemoryWithTiersGraph = class extends import_graph7.Graph {
|
|
|
7082
7178
|
{ name: "entryCreatedAtNs/sync", describeKind: "effect" }
|
|
7083
7179
|
);
|
|
7084
7180
|
this.add(syncCreatedAt, { name: "entryCreatedAtNs/sync" });
|
|
7085
|
-
this.addDisposer((0,
|
|
7181
|
+
this.addDisposer((0, import_extra33.keepalive)(syncCreatedAt));
|
|
7086
7182
|
const entriesUnsub = this.store.store.entries.subscribe((msgs) => {
|
|
7087
7183
|
for (const m of msgs) {
|
|
7088
|
-
if (m[0] !==
|
|
7184
|
+
if (m[0] !== import_core45.DATA) continue;
|
|
7089
7185
|
const map = m[1];
|
|
7090
7186
|
const created = entryCreatedAtNsRef.entries.cache;
|
|
7091
7187
|
if (created == null) continue;
|
|
@@ -7094,14 +7190,14 @@ var MemoryWithTiersGraph = class extends import_graph7.Graph {
|
|
|
7094
7190
|
if (!map.has(key)) toDelete.push(key);
|
|
7095
7191
|
}
|
|
7096
7192
|
if (toDelete.length > 0) {
|
|
7097
|
-
(0,
|
|
7193
|
+
(0, import_core45.batch)(() => {
|
|
7098
7194
|
for (const key of toDelete) entryCreatedAtNsRef.delete(key);
|
|
7099
7195
|
});
|
|
7100
7196
|
}
|
|
7101
7197
|
}
|
|
7102
7198
|
});
|
|
7103
7199
|
this.addDisposer(entriesUnsub);
|
|
7104
|
-
const promoter = (0,
|
|
7200
|
+
const promoter = (0, import_core45.node)(
|
|
7105
7201
|
[this.store.store.entries],
|
|
7106
7202
|
(batchData, _actions, ctx) => {
|
|
7107
7203
|
const data = batchData.map(
|
|
@@ -7111,7 +7207,7 @@ var MemoryWithTiersGraph = class extends import_graph7.Graph {
|
|
|
7111
7207
|
for (const [key, mem] of map) {
|
|
7112
7208
|
if (permanentKeysRef.has(key)) continue;
|
|
7113
7209
|
if (permanentFilter(key, mem)) {
|
|
7114
|
-
(0,
|
|
7210
|
+
(0, import_core45.batch)(() => {
|
|
7115
7211
|
markPermanent(key, mem);
|
|
7116
7212
|
});
|
|
7117
7213
|
}
|
|
@@ -7120,7 +7216,7 @@ var MemoryWithTiersGraph = class extends import_graph7.Graph {
|
|
|
7120
7216
|
{ name: "promoter", describeKind: "effect" }
|
|
7121
7217
|
);
|
|
7122
7218
|
this.add(promoter, { name: "promoter" });
|
|
7123
|
-
this.addDisposer((0,
|
|
7219
|
+
this.addDisposer((0, import_extra33.keepalive)(promoter));
|
|
7124
7220
|
let archiveHandle = null;
|
|
7125
7221
|
if (opts.archiveTier) {
|
|
7126
7222
|
archiveHandle = this.attachSnapshotStorage(
|
|
@@ -7176,7 +7272,7 @@ var MemoryRetrievalGraph = class extends import_graph7.Graph {
|
|
|
7176
7272
|
this._budget = opts.budget ?? 2e3;
|
|
7177
7273
|
this._contextWeight = opts.contextWeight ?? 0;
|
|
7178
7274
|
if (opts.context) {
|
|
7179
|
-
this._contextNode = (0,
|
|
7275
|
+
this._contextNode = (0, import_extra33.fromAny)(opts.context);
|
|
7180
7276
|
} else {
|
|
7181
7277
|
this._contextNode = this.state("_context", null);
|
|
7182
7278
|
}
|
|
@@ -7322,7 +7418,7 @@ var MemoryRetrievalGraph = class extends import_graph7.Graph {
|
|
|
7322
7418
|
const id = ++this._retrieveSeq;
|
|
7323
7419
|
const segment = `retrieve_${id}`;
|
|
7324
7420
|
const sub = new import_graph7.Graph(segment);
|
|
7325
|
-
const inputNode = (0,
|
|
7421
|
+
const inputNode = (0, import_extra33.fromAny)(queryInput);
|
|
7326
7422
|
const localContext = sub.derived(
|
|
7327
7423
|
"context",
|
|
7328
7424
|
[inputNode],
|
|
@@ -7367,7 +7463,7 @@ var MemoryRetrievalGraph = class extends import_graph7.Graph {
|
|
|
7367
7463
|
initial: { packed: [], trace: null }
|
|
7368
7464
|
}
|
|
7369
7465
|
);
|
|
7370
|
-
const projection = (0,
|
|
7466
|
+
const projection = (0, import_core45.node)(
|
|
7371
7467
|
[result],
|
|
7372
7468
|
(batchData, actions, ctx) => {
|
|
7373
7469
|
const data = batchData.map(
|
|
@@ -7407,18 +7503,18 @@ function gaugesAsContext(graph, actor, options) {
|
|
|
7407
7503
|
const separator = options?.separator ?? "\n";
|
|
7408
7504
|
const entries = [];
|
|
7409
7505
|
const sinceVersion = options?.sinceVersion;
|
|
7410
|
-
for (const [path,
|
|
7411
|
-
const meta2 =
|
|
7506
|
+
for (const [path, node39] of Object.entries(described.nodes)) {
|
|
7507
|
+
const meta2 = node39.meta ?? {};
|
|
7412
7508
|
const desc = meta2.description;
|
|
7413
7509
|
const format = meta2.format;
|
|
7414
7510
|
if (!desc && !format) continue;
|
|
7415
|
-
if (sinceVersion != null &&
|
|
7511
|
+
if (sinceVersion != null && node39.v != null) {
|
|
7416
7512
|
const lastSeen = sinceVersion.get(path);
|
|
7417
|
-
if (lastSeen != null && lastSeen.id ===
|
|
7513
|
+
if (lastSeen != null && lastSeen.id === node39.v.id && node39.v.version <= lastSeen.version)
|
|
7418
7514
|
continue;
|
|
7419
7515
|
}
|
|
7420
7516
|
const label = desc ?? path;
|
|
7421
|
-
const value =
|
|
7517
|
+
const value = node39.value;
|
|
7422
7518
|
const unit = meta2.unit;
|
|
7423
7519
|
let formatted;
|
|
7424
7520
|
if (format === "currency" && typeof value === "number") {
|
|
@@ -7440,8 +7536,8 @@ function gaugesAsContext(graph, actor, options) {
|
|
|
7440
7536
|
const tagGroups = /* @__PURE__ */ new Map();
|
|
7441
7537
|
const ungrouped = [];
|
|
7442
7538
|
for (const entry of entries) {
|
|
7443
|
-
const
|
|
7444
|
-
const tags =
|
|
7539
|
+
const node39 = described.nodes[entry.path];
|
|
7540
|
+
const tags = node39.meta?.tags;
|
|
7445
7541
|
if (tags && tags.length > 0) {
|
|
7446
7542
|
const tag = tags[0];
|
|
7447
7543
|
let group = tagGroups.get(tag);
|
|
@@ -7472,25 +7568,25 @@ function gaugesAsContext(graph, actor, options) {
|
|
|
7472
7568
|
}
|
|
7473
7569
|
|
|
7474
7570
|
// src/utils/ai/graph-integration/graph-from-spec.ts
|
|
7475
|
-
var
|
|
7476
|
-
var
|
|
7571
|
+
var import_core48 = require("@graphrefly/pure-ts/core");
|
|
7572
|
+
var import_extra36 = require("@graphrefly/pure-ts/extra");
|
|
7477
7573
|
|
|
7478
7574
|
// src/utils/graphspec/index.ts
|
|
7479
|
-
var
|
|
7575
|
+
var import_core47 = require("@graphrefly/pure-ts/core");
|
|
7480
7576
|
var import_graph9 = require("@graphrefly/pure-ts/graph");
|
|
7481
7577
|
|
|
7482
7578
|
// src/utils/reduction/index.ts
|
|
7483
|
-
var
|
|
7484
|
-
var import_extra33 = require("@graphrefly/pure-ts/extra");
|
|
7485
|
-
var import_graph8 = require("@graphrefly/pure-ts/graph");
|
|
7579
|
+
var import_core46 = require("@graphrefly/pure-ts/core");
|
|
7486
7580
|
var import_extra34 = require("@graphrefly/pure-ts/extra");
|
|
7581
|
+
var import_graph8 = require("@graphrefly/pure-ts/graph");
|
|
7582
|
+
var import_extra35 = require("@graphrefly/pure-ts/extra");
|
|
7487
7583
|
function baseMeta(kind, meta2) {
|
|
7488
7584
|
return domainMeta("reduction", kind, meta2);
|
|
7489
7585
|
}
|
|
7490
7586
|
function feedback(graph, condition, reentry, opts) {
|
|
7491
7587
|
const maxIter = opts?.maxIterations ?? 10;
|
|
7492
7588
|
const counterName = `__feedback_${condition}`;
|
|
7493
|
-
const counter = (0,
|
|
7589
|
+
const counter = (0, import_core46.node)([], {
|
|
7494
7590
|
...{
|
|
7495
7591
|
meta: baseMeta("feedback_counter", {
|
|
7496
7592
|
maxIterations: maxIter,
|
|
@@ -7504,27 +7600,27 @@ function feedback(graph, condition, reentry, opts) {
|
|
|
7504
7600
|
const condNode = graph.resolve(condition);
|
|
7505
7601
|
const reentryNode = graph.resolve(reentry);
|
|
7506
7602
|
const feedbackEffectName = `__feedback_effect_${condition}`;
|
|
7507
|
-
const feedbackEffect = (0,
|
|
7603
|
+
const feedbackEffect = (0, import_core46.node)(
|
|
7508
7604
|
[],
|
|
7509
7605
|
(_data, _feedbackActions) => {
|
|
7510
7606
|
const unsub = condNode.subscribe((msgs) => {
|
|
7511
7607
|
for (const msg of msgs) {
|
|
7512
7608
|
const t = msg[0];
|
|
7513
|
-
if (t ===
|
|
7609
|
+
if (t === import_core46.DATA) {
|
|
7514
7610
|
const condValue = msg[1];
|
|
7515
7611
|
if (condValue == null) return;
|
|
7516
|
-
(0,
|
|
7612
|
+
(0, import_core46.batch)(() => {
|
|
7517
7613
|
if (tryIncrementBounded(counter, maxIter)) {
|
|
7518
7614
|
reentryNode.emit(condValue);
|
|
7519
7615
|
}
|
|
7520
7616
|
});
|
|
7521
|
-
} else if (t ===
|
|
7522
|
-
const terminal = t ===
|
|
7617
|
+
} else if (t === import_core46.COMPLETE || t === import_core46.ERROR) {
|
|
7618
|
+
const terminal = t === import_core46.ERROR && msg.length > 1 ? [import_core46.ERROR, msg[1]] : [t];
|
|
7523
7619
|
counter.down([terminal]);
|
|
7524
7620
|
}
|
|
7525
7621
|
}
|
|
7526
7622
|
});
|
|
7527
|
-
return () => unsub();
|
|
7623
|
+
return { onDeactivation: () => unsub() };
|
|
7528
7624
|
},
|
|
7529
7625
|
{
|
|
7530
7626
|
name: feedbackEffectName,
|
|
@@ -7539,23 +7635,23 @@ function feedback(graph, condition, reentry, opts) {
|
|
|
7539
7635
|
}
|
|
7540
7636
|
);
|
|
7541
7637
|
graph.add(feedbackEffect, { name: feedbackEffectName });
|
|
7542
|
-
graph.addDisposer((0,
|
|
7638
|
+
graph.addDisposer((0, import_extra35.keepalive)(feedbackEffect));
|
|
7543
7639
|
return graph;
|
|
7544
7640
|
}
|
|
7545
7641
|
|
|
7546
7642
|
// src/utils/graphspec/index.ts
|
|
7547
|
-
function readFactory(
|
|
7548
|
-
const f =
|
|
7643
|
+
function readFactory(node39) {
|
|
7644
|
+
const f = node39.meta?.factory;
|
|
7549
7645
|
return typeof f === "string" ? f : void 0;
|
|
7550
7646
|
}
|
|
7551
|
-
function readFactoryArgs(
|
|
7552
|
-
const a =
|
|
7647
|
+
function readFactoryArgs(node39) {
|
|
7648
|
+
const a = node39.meta?.factoryArgs;
|
|
7553
7649
|
return a != null && typeof a === "object" ? a : {};
|
|
7554
7650
|
}
|
|
7555
|
-
function readStateInitial(
|
|
7556
|
-
const args = readFactoryArgs(
|
|
7651
|
+
function readStateInitial(node39) {
|
|
7652
|
+
const args = readFactoryArgs(node39);
|
|
7557
7653
|
if ("initial" in args) return args.initial;
|
|
7558
|
-
return
|
|
7654
|
+
return node39.value;
|
|
7559
7655
|
}
|
|
7560
7656
|
function isRichFnEntry(entry) {
|
|
7561
7657
|
return typeof entry === "object" && entry !== null && "factory" in entry;
|
|
@@ -7575,11 +7671,11 @@ function validateSpecAgainstCatalog(spec, catalog) {
|
|
|
7575
7671
|
const sourceNames = new Set(Object.keys(catalog.sources ?? {}));
|
|
7576
7672
|
for (const [nodeName, nodeRaw] of Object.entries(spec.nodes)) {
|
|
7577
7673
|
if (nodeRaw.type === "template") continue;
|
|
7578
|
-
const
|
|
7579
|
-
const factoryName = readFactory(
|
|
7674
|
+
const node39 = nodeRaw;
|
|
7675
|
+
const factoryName = readFactory(node39);
|
|
7580
7676
|
if (factoryName == null) continue;
|
|
7581
|
-
const isProducer =
|
|
7582
|
-
if (
|
|
7677
|
+
const isProducer = node39.type === "producer";
|
|
7678
|
+
if (node39.type === "state" && factoryName === "state") continue;
|
|
7583
7679
|
if (isProducer) {
|
|
7584
7680
|
const inSources = sourceNames.has(factoryName);
|
|
7585
7681
|
const inFns = fnNames.has(factoryName);
|
|
@@ -7603,7 +7699,7 @@ function validateSpecAgainstCatalog(spec, catalog) {
|
|
|
7603
7699
|
}
|
|
7604
7700
|
}
|
|
7605
7701
|
}
|
|
7606
|
-
const factoryArgs = readFactoryArgs(
|
|
7702
|
+
const factoryArgs = readFactoryArgs(node39);
|
|
7607
7703
|
if (!isProducer && catalog.fns?.[factoryName]) {
|
|
7608
7704
|
const entry = catalog.fns[factoryName];
|
|
7609
7705
|
if (isRichFnEntry(entry) && entry.configSchema) {
|
|
@@ -7643,11 +7739,11 @@ function validateSpecAgainstCatalog(spec, catalog) {
|
|
|
7643
7739
|
}
|
|
7644
7740
|
if (spec.templates) {
|
|
7645
7741
|
for (const [tName, template] of Object.entries(spec.templates)) {
|
|
7646
|
-
for (const [nodeName,
|
|
7647
|
-
const factoryName = readFactory(
|
|
7742
|
+
for (const [nodeName, node39] of Object.entries(template.nodes)) {
|
|
7743
|
+
const factoryName = readFactory(node39);
|
|
7648
7744
|
if (factoryName == null) continue;
|
|
7649
|
-
if (
|
|
7650
|
-
if (
|
|
7745
|
+
if (node39.type === "state" && factoryName === "state") continue;
|
|
7746
|
+
if (node39.type === "producer") continue;
|
|
7651
7747
|
if (fnNames.size > 0 && !fnNames.has(factoryName)) {
|
|
7652
7748
|
const suggestion = findClosest(factoryName, fnNames);
|
|
7653
7749
|
errors.push(
|
|
@@ -7915,7 +8011,7 @@ ${catalogValidation.errors.join("\n")}`
|
|
|
7915
8011
|
const factoryArgs = readFactoryArgs(n);
|
|
7916
8012
|
if (n.type === "state") {
|
|
7917
8013
|
const initial = readStateInitial(n);
|
|
7918
|
-
const nd = (0,
|
|
8014
|
+
const nd = (0, import_core47.node)([], {
|
|
7919
8015
|
name,
|
|
7920
8016
|
initial,
|
|
7921
8017
|
meta: stripFactoryMeta(n.meta)
|
|
@@ -7935,7 +8031,7 @@ ${catalogValidation.errors.join("\n")}`
|
|
|
7935
8031
|
created.set(name, nd);
|
|
7936
8032
|
} else {
|
|
7937
8033
|
if (factoryName) recordMissing(name, "source", factoryName);
|
|
7938
|
-
const nd = (0,
|
|
8034
|
+
const nd = (0, import_core47.node)([], () => {
|
|
7939
8035
|
}, {
|
|
7940
8036
|
name,
|
|
7941
8037
|
describeKind: "producer",
|
|
@@ -7964,11 +8060,11 @@ ${catalogValidation.errors.join("\n")}`
|
|
|
7964
8060
|
nd = fnFactory(resolvedDeps, factoryArgs);
|
|
7965
8061
|
} else if (n.type === "effect") {
|
|
7966
8062
|
if (factoryName) recordMissing(name, "fn", factoryName);
|
|
7967
|
-
nd = (0,
|
|
8063
|
+
nd = (0, import_core47.node)(resolvedDeps, () => {
|
|
7968
8064
|
}, { describeKind: "effect" });
|
|
7969
8065
|
} else {
|
|
7970
8066
|
if (factoryName) recordMissing(name, "fn", factoryName);
|
|
7971
|
-
nd = (0,
|
|
8067
|
+
nd = (0, import_core47.node)(
|
|
7972
8068
|
resolvedDeps,
|
|
7973
8069
|
(batchData, actions, ctx) => {
|
|
7974
8070
|
const data = batchData.map(
|
|
@@ -8008,7 +8104,7 @@ ${catalogValidation.errors.join("\n")}`
|
|
|
8008
8104
|
const factoryArgs = readFactoryArgs(nSpec);
|
|
8009
8105
|
if (nSpec.type === "state") {
|
|
8010
8106
|
const initial = readStateInitial(nSpec);
|
|
8011
|
-
const nd = (0,
|
|
8107
|
+
const nd = (0, import_core47.node)([], {
|
|
8012
8108
|
name: nName,
|
|
8013
8109
|
initial,
|
|
8014
8110
|
meta: stripFactoryMeta(nSpec.meta)
|
|
@@ -8028,7 +8124,7 @@ ${catalogValidation.errors.join("\n")}`
|
|
|
8028
8124
|
subCreated.set(nName, nd);
|
|
8029
8125
|
} else {
|
|
8030
8126
|
if (factoryName) recordMissing(`${name}.${nName}`, "source", factoryName);
|
|
8031
|
-
const nd = (0,
|
|
8127
|
+
const nd = (0, import_core47.node)([], () => {
|
|
8032
8128
|
}, {
|
|
8033
8129
|
name: nName,
|
|
8034
8130
|
describeKind: "producer",
|
|
@@ -8058,11 +8154,11 @@ ${catalogValidation.errors.join("\n")}`
|
|
|
8058
8154
|
nd = fnFactory(resolvedDeps, factoryArgs);
|
|
8059
8155
|
} else if (nSpec.type === "effect") {
|
|
8060
8156
|
if (factoryName) recordMissing(`${name}.${nName}`, "fn", factoryName);
|
|
8061
|
-
nd = (0,
|
|
8157
|
+
nd = (0, import_core47.node)(resolvedDeps, () => {
|
|
8062
8158
|
}, { describeKind: "effect" });
|
|
8063
8159
|
} else {
|
|
8064
8160
|
if (factoryName) recordMissing(`${name}.${nName}`, "fn", factoryName);
|
|
8065
|
-
nd = (0,
|
|
8161
|
+
nd = (0, import_core47.node)(
|
|
8066
8162
|
resolvedDeps,
|
|
8067
8163
|
(batchData, actions, ctx) => {
|
|
8068
8164
|
const data = batchData.map(
|
|
@@ -8183,12 +8279,12 @@ ${opts.systemPromptExtra}` : GRAPH_FROM_SPEC_SYSTEM_PROMPT;
|
|
|
8183
8279
|
return compileSpec(parsed, { catalog: opts?.catalog });
|
|
8184
8280
|
}
|
|
8185
8281
|
function graphFromSpecReactive(input, adapter, opts) {
|
|
8186
|
-
const inputNode = (0,
|
|
8187
|
-
return (0,
|
|
8282
|
+
const inputNode = (0, import_extra36.fromAny)(input);
|
|
8283
|
+
return (0, import_extra36.switchMap)(inputNode, (nl) => {
|
|
8188
8284
|
if (!nl || typeof nl !== "string" || nl.trim().length === 0) {
|
|
8189
|
-
return (0,
|
|
8285
|
+
return (0, import_core48.node)([], { initial: null });
|
|
8190
8286
|
}
|
|
8191
|
-
return (0,
|
|
8287
|
+
return (0, import_core48.node)(
|
|
8192
8288
|
(_data, actions) => {
|
|
8193
8289
|
const controller = new AbortController();
|
|
8194
8290
|
let cancelled = false;
|
|
@@ -8198,14 +8294,16 @@ function graphFromSpecReactive(input, adapter, opts) {
|
|
|
8198
8294
|
return;
|
|
8199
8295
|
}
|
|
8200
8296
|
actions.emit(g);
|
|
8201
|
-
actions.down([[
|
|
8297
|
+
actions.down([[import_core48.COMPLETE]]);
|
|
8202
8298
|
}).catch((err) => {
|
|
8203
8299
|
if (cancelled) return;
|
|
8204
|
-
actions.down([[
|
|
8300
|
+
actions.down([[import_core48.ERROR, err]]);
|
|
8205
8301
|
});
|
|
8206
|
-
return
|
|
8207
|
-
|
|
8208
|
-
|
|
8302
|
+
return {
|
|
8303
|
+
onDeactivation: () => {
|
|
8304
|
+
cancelled = true;
|
|
8305
|
+
controller.abort();
|
|
8306
|
+
}
|
|
8209
8307
|
};
|
|
8210
8308
|
},
|
|
8211
8309
|
{ describeKind: "producer", ...{ name: "graphFromSpec::call" } }
|
|
@@ -8252,11 +8350,11 @@ function knobsAsTools(graph, actor) {
|
|
|
8252
8350
|
const openai = [];
|
|
8253
8351
|
const mcp = [];
|
|
8254
8352
|
const definitions = [];
|
|
8255
|
-
for (const [path,
|
|
8256
|
-
if (
|
|
8353
|
+
for (const [path, node39] of Object.entries(described.nodes)) {
|
|
8354
|
+
if (node39.type !== "state") continue;
|
|
8257
8355
|
if (path.includes("::__meta__::")) continue;
|
|
8258
|
-
if (
|
|
8259
|
-
const meta2 =
|
|
8356
|
+
if (node39.status === "completed" || node39.status === "errored") continue;
|
|
8357
|
+
const meta2 = node39.meta ?? {};
|
|
8260
8358
|
const access = meta2.access;
|
|
8261
8359
|
if (access === "human" || access === "system") continue;
|
|
8262
8360
|
const description = meta2.description ?? `Set the value of ${path}`;
|
|
@@ -8285,7 +8383,7 @@ function knobsAsTools(graph, actor) {
|
|
|
8285
8383
|
});
|
|
8286
8384
|
const graphRef = graph;
|
|
8287
8385
|
const actorRef = actor;
|
|
8288
|
-
const nv =
|
|
8386
|
+
const nv = node39.v;
|
|
8289
8387
|
definitions.push({
|
|
8290
8388
|
name: path,
|
|
8291
8389
|
description,
|
|
@@ -8301,8 +8399,8 @@ function knobsAsTools(graph, actor) {
|
|
|
8301
8399
|
}
|
|
8302
8400
|
|
|
8303
8401
|
// src/utils/ai/graph-integration/suggest-strategy.ts
|
|
8304
|
-
var
|
|
8305
|
-
var
|
|
8402
|
+
var import_core49 = require("@graphrefly/pure-ts/core");
|
|
8403
|
+
var import_extra37 = require("@graphrefly/pure-ts/extra");
|
|
8306
8404
|
var SUGGEST_STRATEGY_SYSTEM_PROMPT = `You are a reactive graph optimizer for GraphReFly.
|
|
8307
8405
|
|
|
8308
8406
|
Given a graph's current structure (from describe()) and a problem statement, suggest topology and parameter changes to solve the problem.
|
|
@@ -8371,30 +8469,32 @@ async function suggestStrategy(graph, problem, adapter, opts) {
|
|
|
8371
8469
|
};
|
|
8372
8470
|
}
|
|
8373
8471
|
function suggestStrategyReactive(graph, problem, adapter, opts) {
|
|
8374
|
-
const problemNode = (0,
|
|
8375
|
-
const paired = (0,
|
|
8376
|
-
return (0,
|
|
8377
|
-
if (pair == null) return (0,
|
|
8472
|
+
const problemNode = (0, import_extra37.fromAny)(problem);
|
|
8473
|
+
const paired = (0, import_extra37.withLatestFrom)(problemNode, graph);
|
|
8474
|
+
return (0, import_extra37.switchMap)(paired, (pair) => {
|
|
8475
|
+
if (pair == null) return (0, import_core49.node)([], { initial: null });
|
|
8378
8476
|
const [pText, g] = pair;
|
|
8379
8477
|
if (!g || !pText || typeof pText !== "string" || pText.trim().length === 0) {
|
|
8380
|
-
return (0,
|
|
8478
|
+
return (0, import_core49.node)([], { initial: null });
|
|
8381
8479
|
}
|
|
8382
|
-
if (g.destroyed) return (0,
|
|
8383
|
-
return (0,
|
|
8480
|
+
if (g.destroyed) return (0, import_core49.node)([], { initial: null });
|
|
8481
|
+
return (0, import_core49.node)(
|
|
8384
8482
|
(_data, actions) => {
|
|
8385
8483
|
const controller = new AbortController();
|
|
8386
8484
|
let cancelled = false;
|
|
8387
8485
|
suggestStrategy(g, pText, adapter, { ...opts, signal: controller.signal }).then((plan) => {
|
|
8388
8486
|
if (cancelled) return;
|
|
8389
8487
|
actions.emit(plan);
|
|
8390
|
-
actions.down([[
|
|
8488
|
+
actions.down([[import_core49.COMPLETE]]);
|
|
8391
8489
|
}).catch((err) => {
|
|
8392
8490
|
if (cancelled) return;
|
|
8393
|
-
actions.down([[
|
|
8491
|
+
actions.down([[import_core49.ERROR, err]]);
|
|
8394
8492
|
});
|
|
8395
|
-
return
|
|
8396
|
-
|
|
8397
|
-
|
|
8493
|
+
return {
|
|
8494
|
+
onDeactivation: () => {
|
|
8495
|
+
cancelled = true;
|
|
8496
|
+
controller.abort();
|
|
8497
|
+
}
|
|
8398
8498
|
};
|
|
8399
8499
|
},
|
|
8400
8500
|
{ describeKind: "producer", ...{ name: "suggestStrategy::call" } }
|
|
@@ -8423,14 +8523,14 @@ function validateGraphDef(def) {
|
|
|
8423
8523
|
errors.push(`Node "${name}": must be an object`);
|
|
8424
8524
|
continue;
|
|
8425
8525
|
}
|
|
8426
|
-
const
|
|
8427
|
-
if (typeof
|
|
8526
|
+
const node39 = raw;
|
|
8527
|
+
if (typeof node39.type !== "string" || !VALID_NODE_TYPES2.has(node39.type)) {
|
|
8428
8528
|
errors.push(
|
|
8429
|
-
`Node "${name}": invalid type "${String(
|
|
8529
|
+
`Node "${name}": invalid type "${String(node39.type)}" (expected: ${[...VALID_NODE_TYPES2].join(", ")})`
|
|
8430
8530
|
);
|
|
8431
8531
|
}
|
|
8432
|
-
if (Array.isArray(
|
|
8433
|
-
for (const dep of
|
|
8532
|
+
if (Array.isArray(node39.deps)) {
|
|
8533
|
+
for (const dep of node39.deps) {
|
|
8434
8534
|
if (typeof dep === "string" && !nodeNames.has(dep)) {
|
|
8435
8535
|
errors.push(`Node "${name}": dep "${dep}" does not reference an existing node`);
|
|
8436
8536
|
}
|