@graphrefly/graphrefly 0.47.2 → 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 +4 -3
- 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 +8 -8
- package/dist/base/index.cjs +152 -78
- 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 +75 -70
- package/dist/base/io/index.cjs +31 -17
- 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 +1 -1
- 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 +5 -3
- 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 +5 -3
- package/dist/base/sources/browser/index.js.map +1 -1
- package/dist/base/sources/event/index.cjs +28 -0
- 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 +4 -1
- package/dist/base/sources/index.cjs +75 -37
- 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 +5 -2
- package/dist/{chunk-R6ZCSXKX.js → chunk-23MAWVOJ.js} +3 -3
- package/dist/{chunk-MS3WPRJR.js → chunk-3REMCHSS.js} +6 -6
- 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-6ZLCPUXS.js → chunk-46X2EFQH.js} +15 -4
- 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-FQSQONOU.js → chunk-65OM4XLQ.js} +49 -3
- 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-3O3NKZJW.js → chunk-7T7WLEPM.js} +24 -3
- 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-6MRSX3YK.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-VP3TIUDF.js → chunk-DVTDF5OI.js} +2 -2
- package/dist/{chunk-OXD5LFQP.js → chunk-G7H6PN7P.js} +2 -2
- package/dist/{chunk-EL5VHUGK.js → chunk-GGKHHG5Y.js} +32 -18
- package/dist/chunk-GGKHHG5Y.js.map +1 -0
- package/dist/{chunk-446I4EGD.js → chunk-J5TBZFBD.js} +2 -2
- package/dist/{chunk-7AVQIGF6.js → chunk-K4ZYJ4EM.js} +554 -460
- package/dist/chunk-K4ZYJ4EM.js.map +1 -0
- package/dist/{chunk-QFE5BQH7.js → chunk-LTSI7ULC.js} +2 -2
- package/dist/{chunk-5GVURVIG.js → chunk-MMHGYX44.js} +12 -2
- package/dist/{chunk-5GVURVIG.js.map → chunk-MMHGYX44.js.map} +1 -1
- package/dist/{chunk-KRFGO5QH.js → chunk-MQMTRKY3.js} +118 -43
- 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-FVINAAKA.js → chunk-NBK6QQMG.js} +14 -13
- package/dist/{chunk-FVINAAKA.js.map → chunk-NBK6QQMG.js.map} +1 -1
- package/dist/{chunk-KNU73RZW.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-VAZXUK6G.js → chunk-SUNCHMML.js} +2 -2
- package/dist/{chunk-EP4WVQLX.js → chunk-T2U6N3FV.js} +6 -6
- package/dist/{chunk-T7SP3EYR.js → chunk-T5URUIIY.js} +33 -24
- package/dist/chunk-T5URUIIY.js.map +1 -0
- package/dist/{chunk-VNXAF2KE.js → chunk-TPTZZV25.js} +6 -6
- package/dist/chunk-TPTZZV25.js.map +1 -0
- package/dist/{chunk-IOJDYUA7.js → chunk-V46JWFGV.js} +6 -5
- package/dist/chunk-V46JWFGV.js.map +1 -0
- package/dist/{chunk-WGDEBIP4.js → chunk-X6ESZDR6.js} +5 -6
- package/dist/chunk-X6ESZDR6.js.map +1 -0
- package/dist/{chunk-N65E26UL.js → chunk-XEWV254I.js} +2 -2
- package/dist/{chunk-N65E26UL.js.map → chunk-XEWV254I.js.map} +1 -1
- package/dist/{chunk-PTWADEH3.js → chunk-YBJVKMTM.js} +34 -14
- package/dist/chunk-YBJVKMTM.js.map +1 -0
- package/dist/{chunk-DDTS7F5O.js → chunk-ZW32BPXV.js} +12 -3
- package/dist/chunk-ZW32BPXV.js.map +1 -0
- package/dist/compat/index.cjs +51 -4
- 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 +6 -6
- package/dist/compat/nestjs/index.cjs +51 -4
- 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 +3 -3
- 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 +2215 -1676
- 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 +169 -146
- package/dist/index.js.map +1 -1
- package/dist/presets/ai/index.cjs +46 -0
- package/dist/presets/ai/index.cjs.map +1 -1
- package/dist/presets/ai/index.js +12 -12
- package/dist/presets/harness/index.cjs +130 -18
- 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 +22 -22
- package/dist/presets/index.cjs +222 -53
- 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 +45 -45
- 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 +29 -21
- 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 +3 -3
- 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 +168 -47
- 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 +28 -28
- 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/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 +6 -6
- package/dist/utils/ai/browser.js.map +1 -1
- package/dist/utils/ai/index.cjs +250 -166
- 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 +21 -19
- 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 +2 -2
- 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.map +1 -1
- package/dist/utils/domain-templates/index.js +3 -3
- package/dist/utils/graphspec/index.cjs.map +1 -1
- package/dist/utils/graphspec/index.js +3 -3
- package/dist/utils/index.cjs +1642 -1225
- 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 +72 -54
- 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 +556 -462
- package/dist/utils/memory/index.cjs.map +1 -1
- package/dist/utils/memory/index.d.cts +203 -24
- package/dist/utils/memory/index.d.ts +203 -24
- 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 +9 -0
- 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 +2 -2
- 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.map +1 -1
- package/dist/utils/reduction/index.js +2 -2
- package/dist/utils/resilience/index.cjs +29 -20
- 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 +2 -2
- 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-3O3NKZJW.js.map +0 -1
- 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-6ZLCPUXS.js.map +0 -1
- package/dist/chunk-7AVQIGF6.js.map +0 -1
- package/dist/chunk-BXGZFGZ4.js.map +0 -1
- package/dist/chunk-DDTS7F5O.js.map +0 -1
- package/dist/chunk-EL5VHUGK.js.map +0 -1
- package/dist/chunk-FQSQONOU.js.map +0 -1
- package/dist/chunk-IOJDYUA7.js.map +0 -1
- package/dist/chunk-KRFGO5QH.js.map +0 -1
- package/dist/chunk-MS3WPRJR.js.map +0 -1
- package/dist/chunk-NPRP3MCV.js.map +0 -1
- package/dist/chunk-NY2PYHNC.js.map +0 -1
- package/dist/chunk-PKPO3JTZ.js.map +0 -1
- package/dist/chunk-PTWADEH3.js.map +0 -1
- package/dist/chunk-T7SP3EYR.js.map +0 -1
- package/dist/chunk-VNXAF2KE.js.map +0 -1
- package/dist/chunk-W2BOPXTI.js +0 -1
- package/dist/chunk-W2BOPXTI.js.map +0 -1
- package/dist/chunk-WGDEBIP4.js.map +0 -1
- /package/dist/{chunk-R6ZCSXKX.js.map → chunk-23MAWVOJ.js.map} +0 -0
- /package/dist/{chunk-6MRSX3YK.js.map → chunk-B5Y5GPD5.js.map} +0 -0
- /package/dist/{chunk-VP3TIUDF.js.map → chunk-DVTDF5OI.js.map} +0 -0
- /package/dist/{chunk-OXD5LFQP.js.map → chunk-G7H6PN7P.js.map} +0 -0
- /package/dist/{chunk-446I4EGD.js.map → chunk-J5TBZFBD.js.map} +0 -0
- /package/dist/{chunk-QFE5BQH7.js.map → chunk-LTSI7ULC.js.map} +0 -0
- /package/dist/{chunk-KNU73RZW.js.map → chunk-NSA5K5G2.js.map} +0 -0
- /package/dist/{chunk-MLTPJMH6.js.map → chunk-QQYULEZL.js.map} +0 -0
- /package/dist/{chunk-VAZXUK6G.js.map → chunk-SUNCHMML.js.map} +0 -0
- /package/dist/{chunk-EP4WVQLX.js.map → chunk-T2U6N3FV.js.map} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { k as agentLoop, l as agentMemory } from '../agents-C0Ji9ldU.cjs';
|
|
2
|
-
export { r as harnessLoop, s as refineLoop, t as spawnable } from '../spawnable-
|
|
2
|
+
export { r as harnessLoop, s as refineLoop, t as spawnable } from '../spawnable-B2IlW60f.cjs';
|
|
3
3
|
export { g as guardedExecution } from '../guarded-execution-C-3hnP6A.cjs';
|
|
4
4
|
export { resilientPipeline } from '../presets/resilience/index.cjs';
|
|
5
5
|
import '@graphrefly/pure-ts/extra';
|
|
@@ -19,5 +19,5 @@ import '../audit-C_bPfkqS.cjs';
|
|
|
19
19
|
import '../retry-DWuhjvsA.cjs';
|
|
20
20
|
import '../backoff-Bnb9OoPh.cjs';
|
|
21
21
|
import '../status-U-rUI79b.cjs';
|
|
22
|
-
import '../rate-limiter-
|
|
22
|
+
import '../rate-limiter-DC26FM8J.cjs';
|
|
23
23
|
import '../breaker-ugSdq54q.cjs';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { k as agentLoop, l as agentMemory } from '../agents-C9zexT7I.js';
|
|
2
|
-
export { r as harnessLoop, s as refineLoop, t as spawnable } from '../spawnable-
|
|
2
|
+
export { r as harnessLoop, s as refineLoop, t as spawnable } from '../spawnable-tttFz2Nh.js';
|
|
3
3
|
export { g as guardedExecution } from '../guarded-execution-BcdtxeBk.js';
|
|
4
4
|
export { resilientPipeline } from '../presets/resilience/index.js';
|
|
5
5
|
import '@graphrefly/pure-ts/extra';
|
|
@@ -19,5 +19,5 @@ import '../audit-BAXb3VOg.js';
|
|
|
19
19
|
import '../retry-BDbRZ_gx.js';
|
|
20
20
|
import '../backoff-Bnb9OoPh.js';
|
|
21
21
|
import '../status-U-rUI79b.js';
|
|
22
|
-
import '../rate-limiter-
|
|
22
|
+
import '../rate-limiter-DyWpwpQP.js';
|
|
23
23
|
import '../breaker-C9skL3d8.js';
|
package/dist/solutions/index.js
CHANGED
|
@@ -1,47 +1,47 @@
|
|
|
1
1
|
import "../chunk-3CEXCBN6.js";
|
|
2
|
+
import {
|
|
3
|
+
harnessLoop,
|
|
4
|
+
refineLoop,
|
|
5
|
+
spawnable
|
|
6
|
+
} from "../chunk-YBJVKMTM.js";
|
|
2
7
|
import {
|
|
3
8
|
guardedExecution
|
|
4
|
-
} from "../chunk-
|
|
9
|
+
} from "../chunk-NBK6QQMG.js";
|
|
5
10
|
import {
|
|
6
11
|
resilientPipeline
|
|
7
|
-
} from "../chunk-
|
|
12
|
+
} from "../chunk-X6ESZDR6.js";
|
|
8
13
|
import {
|
|
9
14
|
agentMemory
|
|
10
|
-
} from "../chunk-
|
|
11
|
-
import {
|
|
12
|
-
harnessLoop,
|
|
13
|
-
refineLoop,
|
|
14
|
-
spawnable
|
|
15
|
-
} from "../chunk-PTWADEH3.js";
|
|
15
|
+
} from "../chunk-23MAWVOJ.js";
|
|
16
16
|
import {
|
|
17
17
|
agentLoop
|
|
18
|
-
} from "../chunk-
|
|
19
|
-
import "../chunk-CEVNQ74M.js";
|
|
18
|
+
} from "../chunk-65OM4XLQ.js";
|
|
20
19
|
import "../chunk-OIWU3NYV.js";
|
|
21
|
-
import "../chunk-
|
|
22
|
-
import "../chunk-
|
|
23
|
-
import "../chunk-
|
|
24
|
-
import "../chunk-
|
|
25
|
-
import "../chunk-
|
|
26
|
-
import "../chunk-
|
|
20
|
+
import "../chunk-AQAKDE7F.js";
|
|
21
|
+
import "../chunk-3YGXPUHW.js";
|
|
22
|
+
import "../chunk-MQMTRKY3.js";
|
|
23
|
+
import "../chunk-B5Y5GPD5.js";
|
|
24
|
+
import "../chunk-LTSI7ULC.js";
|
|
25
|
+
import "../chunk-ZW32BPXV.js";
|
|
26
|
+
import "../chunk-T2U6N3FV.js";
|
|
27
|
+
import "../chunk-T5URUIIY.js";
|
|
27
28
|
import "../chunk-GUNIRPEJ.js";
|
|
28
|
-
import "../chunk-
|
|
29
|
-
import "../chunk-
|
|
30
|
-
import "../chunk-
|
|
31
|
-
import "../chunk-
|
|
32
|
-
import "../chunk-NPRP3MCV.js";
|
|
33
|
-
import "../chunk-QMBYUVRL.js";
|
|
34
|
-
import "../chunk-FMPF42Q4.js";
|
|
35
|
-
import "../chunk-BXGZFGZ4.js";
|
|
36
|
-
import "../chunk-IOJDYUA7.js";
|
|
37
|
-
import "../chunk-OXD5LFQP.js";
|
|
38
|
-
import "../chunk-5GVURVIG.js";
|
|
39
|
-
import "../chunk-N6MNJNHB.js";
|
|
29
|
+
import "../chunk-XEWV254I.js";
|
|
30
|
+
import "../chunk-3REMCHSS.js";
|
|
31
|
+
import "../chunk-K4ZYJ4EM.js";
|
|
32
|
+
import "../chunk-DHDCOOJU.js";
|
|
40
33
|
import "../chunk-F7EKHR32.js";
|
|
41
34
|
import "../chunk-JA67ZQG2.js";
|
|
42
35
|
import "../chunk-KUFXLAEY.js";
|
|
43
36
|
import "../chunk-TSBFTJKM.js";
|
|
44
37
|
import "../chunk-P5LBT622.js";
|
|
38
|
+
import "../chunk-QMBYUVRL.js";
|
|
39
|
+
import "../chunk-FMPF42Q4.js";
|
|
40
|
+
import "../chunk-C5QD5DQX.js";
|
|
41
|
+
import "../chunk-V46JWFGV.js";
|
|
42
|
+
import "../chunk-G7H6PN7P.js";
|
|
43
|
+
import "../chunk-MMHGYX44.js";
|
|
44
|
+
import "../chunk-N6MNJNHB.js";
|
|
45
45
|
import "../chunk-AZDQPQ3V.js";
|
|
46
46
|
export {
|
|
47
47
|
agentLoop,
|
|
@@ -209,7 +209,17 @@ interface RefineLoopOptions extends ConvergenceOptions {
|
|
|
209
209
|
* / `this._iteration` instead of factory-local closures.
|
|
210
210
|
*/
|
|
211
211
|
declare class RefineLoopGraph<T> extends Graph {
|
|
212
|
-
|
|
212
|
+
/**
|
|
213
|
+
* Best candidate so far. **SENTINEL until the first iteration settles** —
|
|
214
|
+
* `loop.best.cache` is `undefined` (not `null`) before any iteration
|
|
215
|
+
* produces a best, and a degenerate empty-candidate iteration leaves the
|
|
216
|
+
* prior best in place rather than wiping it. Consumers guard with
|
|
217
|
+
* `=== undefined` (spec §3 SENTINEL), not `== null`. (Anti-pattern sweep
|
|
218
|
+
* 2026-05-18: dropped the `initial: null` eager-placeholder; `null` is
|
|
219
|
+
* reserved for the per-iteration {@link Iteration.best} data field where an
|
|
220
|
+
* empty batch is a valid domain value.)
|
|
221
|
+
*/
|
|
222
|
+
readonly best: Node<T>;
|
|
213
223
|
/**
|
|
214
224
|
* Best score so far. Pseudo-private (`_score`) to avoid colliding with any
|
|
215
225
|
* future `Graph.prototype.score` method (B5d forward-compat hazard
|
|
@@ -502,7 +512,18 @@ declare class HarnessGraph<A = unknown> extends Graph {
|
|
|
502
512
|
* (use {@link unrouted}), and the internal `triage-output` fan-in.
|
|
503
513
|
*/
|
|
504
514
|
readonly queueTopics: ReadonlyMap<QueueRoute, TopicGraph<TriagedItem>>;
|
|
505
|
-
/**
|
|
515
|
+
/**
|
|
516
|
+
* Strategy model — `auditedSuccessTracker` keyed by `StrategyKey`.
|
|
517
|
+
*
|
|
518
|
+
* **Ownership (EC10/EC15).** Owned by the harness: it is mounted as a
|
|
519
|
+
* child subgraph (`harness.mount("strategy", strategy)`), so its disposal
|
|
520
|
+
* cascades from `harness.destroy()` via the mount lifecycle. Do **not**
|
|
521
|
+
* call `strategy.destroy()` independently — the harness's `triage-input`
|
|
522
|
+
* node and (when `opts.priority` is set) `buildPriorityScores` hold
|
|
523
|
+
* cross-graph deps on `strategy.entries`; destroying the strategy out of
|
|
524
|
+
* band staleness those nodes while the rest of the loop keeps running.
|
|
525
|
+
* Read/subscribe freely; let the harness own the lifecycle.
|
|
526
|
+
*/
|
|
506
527
|
readonly strategy: StrategyModelGraph;
|
|
507
528
|
/** Global retry count across all items (circuit breaker). Reactive — subscribable. */
|
|
508
529
|
readonly totalRetries: Node<number>;
|
|
@@ -209,7 +209,17 @@ interface RefineLoopOptions extends ConvergenceOptions {
|
|
|
209
209
|
* / `this._iteration` instead of factory-local closures.
|
|
210
210
|
*/
|
|
211
211
|
declare class RefineLoopGraph<T> extends Graph {
|
|
212
|
-
|
|
212
|
+
/**
|
|
213
|
+
* Best candidate so far. **SENTINEL until the first iteration settles** —
|
|
214
|
+
* `loop.best.cache` is `undefined` (not `null`) before any iteration
|
|
215
|
+
* produces a best, and a degenerate empty-candidate iteration leaves the
|
|
216
|
+
* prior best in place rather than wiping it. Consumers guard with
|
|
217
|
+
* `=== undefined` (spec §3 SENTINEL), not `== null`. (Anti-pattern sweep
|
|
218
|
+
* 2026-05-18: dropped the `initial: null` eager-placeholder; `null` is
|
|
219
|
+
* reserved for the per-iteration {@link Iteration.best} data field where an
|
|
220
|
+
* empty batch is a valid domain value.)
|
|
221
|
+
*/
|
|
222
|
+
readonly best: Node<T>;
|
|
213
223
|
/**
|
|
214
224
|
* Best score so far. Pseudo-private (`_score`) to avoid colliding with any
|
|
215
225
|
* future `Graph.prototype.score` method (B5d forward-compat hazard
|
|
@@ -502,7 +512,18 @@ declare class HarnessGraph<A = unknown> extends Graph {
|
|
|
502
512
|
* (use {@link unrouted}), and the internal `triage-output` fan-in.
|
|
503
513
|
*/
|
|
504
514
|
readonly queueTopics: ReadonlyMap<QueueRoute, TopicGraph<TriagedItem>>;
|
|
505
|
-
/**
|
|
515
|
+
/**
|
|
516
|
+
* Strategy model — `auditedSuccessTracker` keyed by `StrategyKey`.
|
|
517
|
+
*
|
|
518
|
+
* **Ownership (EC10/EC15).** Owned by the harness: it is mounted as a
|
|
519
|
+
* child subgraph (`harness.mount("strategy", strategy)`), so its disposal
|
|
520
|
+
* cascades from `harness.destroy()` via the mount lifecycle. Do **not**
|
|
521
|
+
* call `strategy.destroy()` independently — the harness's `triage-input`
|
|
522
|
+
* node and (when `opts.priority` is set) `buildPriorityScores` hold
|
|
523
|
+
* cross-graph deps on `strategy.entries`; destroying the strategy out of
|
|
524
|
+
* band staleness those nodes while the rest of the loop keeps running.
|
|
525
|
+
* Read/subscribe freely; let the harness own the lifecycle.
|
|
526
|
+
*/
|
|
506
527
|
readonly strategy: StrategyModelGraph;
|
|
507
528
|
/** Global retry count across all items (circuit breaker). Reactive — subscribable. */
|
|
508
529
|
readonly totalRetries: Node<number>;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/testing/index.ts
|
|
21
|
+
var testing_exports = {};
|
|
22
|
+
__export(testing_exports, {
|
|
23
|
+
mockLLM: () => mockLLM
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(testing_exports);
|
|
26
|
+
|
|
27
|
+
// src/testing/mock-llm.ts
|
|
28
|
+
var STAGE_KEYWORDS = [
|
|
29
|
+
["execute", ["implementation agent", "produce a fix"]],
|
|
30
|
+
["verify", ["qa reviewer", "verify whether"]],
|
|
31
|
+
["triage", ["triage classifier", "intake item"]]
|
|
32
|
+
];
|
|
33
|
+
function detectStage(text, customStages) {
|
|
34
|
+
const lower = text.toLowerCase();
|
|
35
|
+
for (const [stage, keywords] of STAGE_KEYWORDS) {
|
|
36
|
+
if (keywords.some((kw) => lower.includes(kw))) return stage;
|
|
37
|
+
}
|
|
38
|
+
if (customStages) {
|
|
39
|
+
for (const stage of Object.keys(customStages)) {
|
|
40
|
+
if (lower.includes(stage.toLowerCase())) return stage;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return "unknown";
|
|
44
|
+
}
|
|
45
|
+
function mockLLM(script = {}) {
|
|
46
|
+
const calls = [];
|
|
47
|
+
const stageCounts = /* @__PURE__ */ new Map();
|
|
48
|
+
const stageIndices = /* @__PURE__ */ new Map();
|
|
49
|
+
function getResponse(stage) {
|
|
50
|
+
const stageScript = script.stages?.[stage];
|
|
51
|
+
if (!stageScript) return script.fallback ?? {};
|
|
52
|
+
const idx = stageIndices.get(stage) ?? 0;
|
|
53
|
+
const responses = stageScript.responses;
|
|
54
|
+
const response = responses[Math.min(idx, responses.length - 1)];
|
|
55
|
+
stageIndices.set(stage, idx + 1);
|
|
56
|
+
return response;
|
|
57
|
+
}
|
|
58
|
+
function invoke(messages) {
|
|
59
|
+
const text = messages.map((m) => m.content).join(" ");
|
|
60
|
+
const stage = detectStage(text, script.stages);
|
|
61
|
+
const count = stageCounts.get(stage) ?? 0;
|
|
62
|
+
stageCounts.set(stage, count + 1);
|
|
63
|
+
const responseData = getResponse(stage);
|
|
64
|
+
const response = {
|
|
65
|
+
content: typeof responseData === "string" ? responseData : JSON.stringify(responseData),
|
|
66
|
+
usage: { input: { regular: 0 }, output: { regular: 0 } }
|
|
67
|
+
};
|
|
68
|
+
calls.push({ stage, messages, response });
|
|
69
|
+
return Promise.resolve(response);
|
|
70
|
+
}
|
|
71
|
+
async function* stream() {
|
|
72
|
+
yield { type: "token", delta: "mock stream" };
|
|
73
|
+
yield { type: "usage", usage: { input: { regular: 0 }, output: { regular: 0 } } };
|
|
74
|
+
yield { type: "finish", reason: "stop" };
|
|
75
|
+
}
|
|
76
|
+
return {
|
|
77
|
+
provider: "mock",
|
|
78
|
+
calls,
|
|
79
|
+
get stageCounts() {
|
|
80
|
+
return stageCounts;
|
|
81
|
+
},
|
|
82
|
+
callsFor(stage) {
|
|
83
|
+
return calls.filter((c) => c.stage === stage);
|
|
84
|
+
},
|
|
85
|
+
reset() {
|
|
86
|
+
calls.length = 0;
|
|
87
|
+
stageCounts.clear();
|
|
88
|
+
stageIndices.clear();
|
|
89
|
+
},
|
|
90
|
+
invoke,
|
|
91
|
+
stream
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/testing/index.ts","../../src/testing/mock-llm.ts"],"sourcesContent":["/**\n * `@graphrefly/graphrefly/testing` — public test utilities.\n *\n * Universal tier (browser + Node safe). Test-time helpers for exercising\n * GraphReFly AI / harness patterns without a real LLM wire call.\n *\n * @module\n */\n\nexport * from \"./mock-llm.js\";\n","/**\n * Scenario-scripted mock LLM adapter for harness and AI pattern testing.\n *\n * Detects the calling stage from prompt content and returns scripted responses.\n * Records all calls for assertions.\n *\n * @module\n */\n\nimport type { ChatMessage, LLMAdapter, LLMResponse } from \"../utils/ai/index.js\";\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\n/** A single recorded call to the mock adapter. */\nexport interface MockCall {\n\tstage: string;\n\tmessages: readonly ChatMessage[];\n\tresponse: LLMResponse;\n}\n\n/** Per-stage response script. Cycles through responses on each call. */\nexport interface StageScript {\n\t/** Ordered responses — each call consumes the next; last one repeats. */\n\tresponses: unknown[];\n}\n\n/** Configuration for {@link mockLLM}. */\nexport interface MockScript {\n\t/** Stage-aware response scripts. Stage is detected from prompt keywords. */\n\tstages?: Record<string, StageScript>;\n\t/** Fallback response for unmatched prompts. */\n\tfallback?: unknown;\n}\n\n/** Extended LLM adapter with call recording and inspection. */\nexport interface MockLLMAdapter extends LLMAdapter {\n\t/** All calls recorded in order. */\n\treadonly calls: MockCall[];\n\t/** Per-stage call counts. */\n\treadonly stageCounts: ReadonlyMap<string, number>;\n\t/** Calls filtered by stage name. */\n\tcallsFor(stage: string): MockCall[];\n\t/** Reset all counters and call history. */\n\treset(): void;\n}\n\n// ---------------------------------------------------------------------------\n// Stage detection\n// ---------------------------------------------------------------------------\n\n/**\n * Default stage detection keywords (matched against lowercased prompt text).\n * Order matters: more specific phrases checked first to avoid substring\n * collisions (e.g. \"triaged issue\" in execute prompt matching \"triage\").\n */\nconst STAGE_KEYWORDS: [string, string[]][] = [\n\t[\"execute\", [\"implementation agent\", \"produce a fix\"]],\n\t[\"verify\", [\"qa reviewer\", \"verify whether\"]],\n\t[\"triage\", [\"triage classifier\", \"intake item\"]],\n];\n\nfunction detectStage(text: string, customStages?: Record<string, StageScript>): string {\n\tconst lower = text.toLowerCase();\n\n\t// Check built-in multi-word keywords first (more specific, avoids substring collisions\n\t// like \"triaged\" matching \"triage\")\n\tfor (const [stage, keywords] of STAGE_KEYWORDS) {\n\t\tif (keywords.some((kw) => lower.includes(kw))) return stage;\n\t}\n\n\t// Fall back to custom stage names as keywords\n\tif (customStages) {\n\t\tfor (const stage of Object.keys(customStages)) {\n\t\t\tif (lower.includes(stage.toLowerCase())) return stage;\n\t\t}\n\t}\n\n\treturn \"unknown\";\n}\n\n// ---------------------------------------------------------------------------\n// Factory\n// ---------------------------------------------------------------------------\n\n/**\n * Create a scenario-scripted mock LLM adapter.\n *\n * ```ts\n * const mock = mockLLM({\n * stages: {\n * triage: { responses: [{ rootCause: \"missing-fn\", intervention: \"catalog-fn\", route: \"auto-fix\", priority: 80 }] },\n * execute: { responses: [{ outcome: \"success\", detail: \"Fixed\" }] },\n * verify: { responses: [{ verified: false, findings: [\"err\"], errorClass: \"self-correctable\" },\n * { verified: true, findings: [\"ok\"] }] },\n * },\n * });\n * ```\n */\nexport function mockLLM(script: MockScript = {}): MockLLMAdapter {\n\tconst calls: MockCall[] = [];\n\tconst stageCounts = new Map<string, number>();\n\tconst stageIndices = new Map<string, number>();\n\n\tfunction getResponse(stage: string): unknown {\n\t\tconst stageScript = script.stages?.[stage];\n\t\tif (!stageScript) return script.fallback ?? {};\n\n\t\tconst idx = stageIndices.get(stage) ?? 0;\n\t\tconst responses = stageScript.responses;\n\t\tconst response = responses[Math.min(idx, responses.length - 1)];\n\t\tstageIndices.set(stage, idx + 1);\n\t\treturn response;\n\t}\n\n\tfunction invoke(messages: readonly ChatMessage[]): Promise<LLMResponse> {\n\t\tconst text = messages.map((m) => m.content).join(\" \");\n\t\tconst stage = detectStage(text, script.stages);\n\n\t\tconst count = stageCounts.get(stage) ?? 0;\n\t\tstageCounts.set(stage, count + 1);\n\n\t\tconst responseData = getResponse(stage);\n\t\tconst response: LLMResponse = {\n\t\t\tcontent: typeof responseData === \"string\" ? responseData : JSON.stringify(responseData),\n\t\t\tusage: { input: { regular: 0 }, output: { regular: 0 } },\n\t\t};\n\n\t\tcalls.push({ stage, messages, response });\n\t\treturn Promise.resolve(response);\n\t}\n\n\tasync function* stream(): AsyncIterable<\n\t\timport(\"../utils/ai/adapters/core/types.js\").StreamDelta\n\t> {\n\t\tyield { type: \"token\", delta: \"mock stream\" };\n\t\tyield { type: \"usage\", usage: { input: { regular: 0 }, output: { regular: 0 } } };\n\t\tyield { type: \"finish\", reason: \"stop\" };\n\t}\n\n\treturn {\n\t\tprovider: \"mock\",\n\t\tcalls,\n\t\tget stageCounts() {\n\t\t\treturn stageCounts as ReadonlyMap<string, number>;\n\t\t},\n\t\tcallsFor(stage: string) {\n\t\t\treturn calls.filter((c) => c.stage === stage);\n\t\t},\n\t\treset() {\n\t\t\tcalls.length = 0;\n\t\t\tstageCounts.clear();\n\t\t\tstageIndices.clear();\n\t\t},\n\t\tinvoke,\n\t\tstream,\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACyDA,IAAM,iBAAuC;AAAA,EAC5C,CAAC,WAAW,CAAC,wBAAwB,eAAe,CAAC;AAAA,EACrD,CAAC,UAAU,CAAC,eAAe,gBAAgB,CAAC;AAAA,EAC5C,CAAC,UAAU,CAAC,qBAAqB,aAAa,CAAC;AAChD;AAEA,SAAS,YAAY,MAAc,cAAoD;AACtF,QAAM,QAAQ,KAAK,YAAY;AAI/B,aAAW,CAAC,OAAO,QAAQ,KAAK,gBAAgB;AAC/C,QAAI,SAAS,KAAK,CAAC,OAAO,MAAM,SAAS,EAAE,CAAC,EAAG,QAAO;AAAA,EACvD;AAGA,MAAI,cAAc;AACjB,eAAW,SAAS,OAAO,KAAK,YAAY,GAAG;AAC9C,UAAI,MAAM,SAAS,MAAM,YAAY,CAAC,EAAG,QAAO;AAAA,IACjD;AAAA,EACD;AAEA,SAAO;AACR;AAoBO,SAAS,QAAQ,SAAqB,CAAC,GAAmB;AAChE,QAAM,QAAoB,CAAC;AAC3B,QAAM,cAAc,oBAAI,IAAoB;AAC5C,QAAM,eAAe,oBAAI,IAAoB;AAE7C,WAAS,YAAY,OAAwB;AAC5C,UAAM,cAAc,OAAO,SAAS,KAAK;AACzC,QAAI,CAAC,YAAa,QAAO,OAAO,YAAY,CAAC;AAE7C,UAAM,MAAM,aAAa,IAAI,KAAK,KAAK;AACvC,UAAM,YAAY,YAAY;AAC9B,UAAM,WAAW,UAAU,KAAK,IAAI,KAAK,UAAU,SAAS,CAAC,CAAC;AAC9D,iBAAa,IAAI,OAAO,MAAM,CAAC;AAC/B,WAAO;AAAA,EACR;AAEA,WAAS,OAAO,UAAwD;AACvE,UAAM,OAAO,SAAS,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,GAAG;AACpD,UAAM,QAAQ,YAAY,MAAM,OAAO,MAAM;AAE7C,UAAM,QAAQ,YAAY,IAAI,KAAK,KAAK;AACxC,gBAAY,IAAI,OAAO,QAAQ,CAAC;AAEhC,UAAM,eAAe,YAAY,KAAK;AACtC,UAAM,WAAwB;AAAA,MAC7B,SAAS,OAAO,iBAAiB,WAAW,eAAe,KAAK,UAAU,YAAY;AAAA,MACtF,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,QAAQ,EAAE,SAAS,EAAE,EAAE;AAAA,IACxD;AAEA,UAAM,KAAK,EAAE,OAAO,UAAU,SAAS,CAAC;AACxC,WAAO,QAAQ,QAAQ,QAAQ;AAAA,EAChC;AAEA,kBAAgB,SAEd;AACD,UAAM,EAAE,MAAM,SAAS,OAAO,cAAc;AAC5C,UAAM,EAAE,MAAM,SAAS,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,QAAQ,EAAE,SAAS,EAAE,EAAE,EAAE;AAChF,UAAM,EAAE,MAAM,UAAU,QAAQ,OAAO;AAAA,EACxC;AAEA,SAAO;AAAA,IACN,UAAU;AAAA,IACV;AAAA,IACA,IAAI,cAAc;AACjB,aAAO;AAAA,IACR;AAAA,IACA,SAAS,OAAe;AACvB,aAAO,MAAM,OAAO,CAAC,MAAM,EAAE,UAAU,KAAK;AAAA,IAC7C;AAAA,IACA,QAAQ;AACP,YAAM,SAAS;AACf,kBAAY,MAAM;AAClB,mBAAa,MAAM;AAAA,IACpB;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACD;","names":[]}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { a as ChatMessage, c as LLMResponse, L as LLMAdapter } from '../types-BB5Lw-pB.cjs';
|
|
2
|
+
import '@graphrefly/pure-ts/core';
|
|
3
|
+
import '@graphrefly/pure-ts/extra';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Scenario-scripted mock LLM adapter for harness and AI pattern testing.
|
|
7
|
+
*
|
|
8
|
+
* Detects the calling stage from prompt content and returns scripted responses.
|
|
9
|
+
* Records all calls for assertions.
|
|
10
|
+
*
|
|
11
|
+
* @module
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/** A single recorded call to the mock adapter. */
|
|
15
|
+
interface MockCall {
|
|
16
|
+
stage: string;
|
|
17
|
+
messages: readonly ChatMessage[];
|
|
18
|
+
response: LLMResponse;
|
|
19
|
+
}
|
|
20
|
+
/** Per-stage response script. Cycles through responses on each call. */
|
|
21
|
+
interface StageScript {
|
|
22
|
+
/** Ordered responses — each call consumes the next; last one repeats. */
|
|
23
|
+
responses: unknown[];
|
|
24
|
+
}
|
|
25
|
+
/** Configuration for {@link mockLLM}. */
|
|
26
|
+
interface MockScript {
|
|
27
|
+
/** Stage-aware response scripts. Stage is detected from prompt keywords. */
|
|
28
|
+
stages?: Record<string, StageScript>;
|
|
29
|
+
/** Fallback response for unmatched prompts. */
|
|
30
|
+
fallback?: unknown;
|
|
31
|
+
}
|
|
32
|
+
/** Extended LLM adapter with call recording and inspection. */
|
|
33
|
+
interface MockLLMAdapter extends LLMAdapter {
|
|
34
|
+
/** All calls recorded in order. */
|
|
35
|
+
readonly calls: MockCall[];
|
|
36
|
+
/** Per-stage call counts. */
|
|
37
|
+
readonly stageCounts: ReadonlyMap<string, number>;
|
|
38
|
+
/** Calls filtered by stage name. */
|
|
39
|
+
callsFor(stage: string): MockCall[];
|
|
40
|
+
/** Reset all counters and call history. */
|
|
41
|
+
reset(): void;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Create a scenario-scripted mock LLM adapter.
|
|
45
|
+
*
|
|
46
|
+
* ```ts
|
|
47
|
+
* const mock = mockLLM({
|
|
48
|
+
* stages: {
|
|
49
|
+
* triage: { responses: [{ rootCause: "missing-fn", intervention: "catalog-fn", route: "auto-fix", priority: 80 }] },
|
|
50
|
+
* execute: { responses: [{ outcome: "success", detail: "Fixed" }] },
|
|
51
|
+
* verify: { responses: [{ verified: false, findings: ["err"], errorClass: "self-correctable" },
|
|
52
|
+
* { verified: true, findings: ["ok"] }] },
|
|
53
|
+
* },
|
|
54
|
+
* });
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
declare function mockLLM(script?: MockScript): MockLLMAdapter;
|
|
58
|
+
|
|
59
|
+
export { type MockCall, type MockLLMAdapter, type MockScript, type StageScript, mockLLM };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { a as ChatMessage, c as LLMResponse, L as LLMAdapter } from '../types-BB5Lw-pB.js';
|
|
2
|
+
import '@graphrefly/pure-ts/core';
|
|
3
|
+
import '@graphrefly/pure-ts/extra';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Scenario-scripted mock LLM adapter for harness and AI pattern testing.
|
|
7
|
+
*
|
|
8
|
+
* Detects the calling stage from prompt content and returns scripted responses.
|
|
9
|
+
* Records all calls for assertions.
|
|
10
|
+
*
|
|
11
|
+
* @module
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/** A single recorded call to the mock adapter. */
|
|
15
|
+
interface MockCall {
|
|
16
|
+
stage: string;
|
|
17
|
+
messages: readonly ChatMessage[];
|
|
18
|
+
response: LLMResponse;
|
|
19
|
+
}
|
|
20
|
+
/** Per-stage response script. Cycles through responses on each call. */
|
|
21
|
+
interface StageScript {
|
|
22
|
+
/** Ordered responses — each call consumes the next; last one repeats. */
|
|
23
|
+
responses: unknown[];
|
|
24
|
+
}
|
|
25
|
+
/** Configuration for {@link mockLLM}. */
|
|
26
|
+
interface MockScript {
|
|
27
|
+
/** Stage-aware response scripts. Stage is detected from prompt keywords. */
|
|
28
|
+
stages?: Record<string, StageScript>;
|
|
29
|
+
/** Fallback response for unmatched prompts. */
|
|
30
|
+
fallback?: unknown;
|
|
31
|
+
}
|
|
32
|
+
/** Extended LLM adapter with call recording and inspection. */
|
|
33
|
+
interface MockLLMAdapter extends LLMAdapter {
|
|
34
|
+
/** All calls recorded in order. */
|
|
35
|
+
readonly calls: MockCall[];
|
|
36
|
+
/** Per-stage call counts. */
|
|
37
|
+
readonly stageCounts: ReadonlyMap<string, number>;
|
|
38
|
+
/** Calls filtered by stage name. */
|
|
39
|
+
callsFor(stage: string): MockCall[];
|
|
40
|
+
/** Reset all counters and call history. */
|
|
41
|
+
reset(): void;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Create a scenario-scripted mock LLM adapter.
|
|
45
|
+
*
|
|
46
|
+
* ```ts
|
|
47
|
+
* const mock = mockLLM({
|
|
48
|
+
* stages: {
|
|
49
|
+
* triage: { responses: [{ rootCause: "missing-fn", intervention: "catalog-fn", route: "auto-fix", priority: 80 }] },
|
|
50
|
+
* execute: { responses: [{ outcome: "success", detail: "Fixed" }] },
|
|
51
|
+
* verify: { responses: [{ verified: false, findings: ["err"], errorClass: "self-correctable" },
|
|
52
|
+
* { verified: true, findings: ["ok"] }] },
|
|
53
|
+
* },
|
|
54
|
+
* });
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
declare function mockLLM(script?: MockScript): MockLLMAdapter;
|
|
58
|
+
|
|
59
|
+
export { type MockCall, type MockLLMAdapter, type MockScript, type StageScript, mockLLM };
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import "../chunk-AZDQPQ3V.js";
|
|
2
|
+
|
|
3
|
+
// src/testing/mock-llm.ts
|
|
4
|
+
var STAGE_KEYWORDS = [
|
|
5
|
+
["execute", ["implementation agent", "produce a fix"]],
|
|
6
|
+
["verify", ["qa reviewer", "verify whether"]],
|
|
7
|
+
["triage", ["triage classifier", "intake item"]]
|
|
8
|
+
];
|
|
9
|
+
function detectStage(text, customStages) {
|
|
10
|
+
const lower = text.toLowerCase();
|
|
11
|
+
for (const [stage, keywords] of STAGE_KEYWORDS) {
|
|
12
|
+
if (keywords.some((kw) => lower.includes(kw))) return stage;
|
|
13
|
+
}
|
|
14
|
+
if (customStages) {
|
|
15
|
+
for (const stage of Object.keys(customStages)) {
|
|
16
|
+
if (lower.includes(stage.toLowerCase())) return stage;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return "unknown";
|
|
20
|
+
}
|
|
21
|
+
function mockLLM(script = {}) {
|
|
22
|
+
const calls = [];
|
|
23
|
+
const stageCounts = /* @__PURE__ */ new Map();
|
|
24
|
+
const stageIndices = /* @__PURE__ */ new Map();
|
|
25
|
+
function getResponse(stage) {
|
|
26
|
+
const stageScript = script.stages?.[stage];
|
|
27
|
+
if (!stageScript) return script.fallback ?? {};
|
|
28
|
+
const idx = stageIndices.get(stage) ?? 0;
|
|
29
|
+
const responses = stageScript.responses;
|
|
30
|
+
const response = responses[Math.min(idx, responses.length - 1)];
|
|
31
|
+
stageIndices.set(stage, idx + 1);
|
|
32
|
+
return response;
|
|
33
|
+
}
|
|
34
|
+
function invoke(messages) {
|
|
35
|
+
const text = messages.map((m) => m.content).join(" ");
|
|
36
|
+
const stage = detectStage(text, script.stages);
|
|
37
|
+
const count = stageCounts.get(stage) ?? 0;
|
|
38
|
+
stageCounts.set(stage, count + 1);
|
|
39
|
+
const responseData = getResponse(stage);
|
|
40
|
+
const response = {
|
|
41
|
+
content: typeof responseData === "string" ? responseData : JSON.stringify(responseData),
|
|
42
|
+
usage: { input: { regular: 0 }, output: { regular: 0 } }
|
|
43
|
+
};
|
|
44
|
+
calls.push({ stage, messages, response });
|
|
45
|
+
return Promise.resolve(response);
|
|
46
|
+
}
|
|
47
|
+
async function* stream() {
|
|
48
|
+
yield { type: "token", delta: "mock stream" };
|
|
49
|
+
yield { type: "usage", usage: { input: { regular: 0 }, output: { regular: 0 } } };
|
|
50
|
+
yield { type: "finish", reason: "stop" };
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
provider: "mock",
|
|
54
|
+
calls,
|
|
55
|
+
get stageCounts() {
|
|
56
|
+
return stageCounts;
|
|
57
|
+
},
|
|
58
|
+
callsFor(stage) {
|
|
59
|
+
return calls.filter((c) => c.stage === stage);
|
|
60
|
+
},
|
|
61
|
+
reset() {
|
|
62
|
+
calls.length = 0;
|
|
63
|
+
stageCounts.clear();
|
|
64
|
+
stageIndices.clear();
|
|
65
|
+
},
|
|
66
|
+
invoke,
|
|
67
|
+
stream
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
export {
|
|
71
|
+
mockLLM
|
|
72
|
+
};
|
|
73
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/testing/mock-llm.ts"],"sourcesContent":["/**\n * Scenario-scripted mock LLM adapter for harness and AI pattern testing.\n *\n * Detects the calling stage from prompt content and returns scripted responses.\n * Records all calls for assertions.\n *\n * @module\n */\n\nimport type { ChatMessage, LLMAdapter, LLMResponse } from \"../utils/ai/index.js\";\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\n/** A single recorded call to the mock adapter. */\nexport interface MockCall {\n\tstage: string;\n\tmessages: readonly ChatMessage[];\n\tresponse: LLMResponse;\n}\n\n/** Per-stage response script. Cycles through responses on each call. */\nexport interface StageScript {\n\t/** Ordered responses — each call consumes the next; last one repeats. */\n\tresponses: unknown[];\n}\n\n/** Configuration for {@link mockLLM}. */\nexport interface MockScript {\n\t/** Stage-aware response scripts. Stage is detected from prompt keywords. */\n\tstages?: Record<string, StageScript>;\n\t/** Fallback response for unmatched prompts. */\n\tfallback?: unknown;\n}\n\n/** Extended LLM adapter with call recording and inspection. */\nexport interface MockLLMAdapter extends LLMAdapter {\n\t/** All calls recorded in order. */\n\treadonly calls: MockCall[];\n\t/** Per-stage call counts. */\n\treadonly stageCounts: ReadonlyMap<string, number>;\n\t/** Calls filtered by stage name. */\n\tcallsFor(stage: string): MockCall[];\n\t/** Reset all counters and call history. */\n\treset(): void;\n}\n\n// ---------------------------------------------------------------------------\n// Stage detection\n// ---------------------------------------------------------------------------\n\n/**\n * Default stage detection keywords (matched against lowercased prompt text).\n * Order matters: more specific phrases checked first to avoid substring\n * collisions (e.g. \"triaged issue\" in execute prompt matching \"triage\").\n */\nconst STAGE_KEYWORDS: [string, string[]][] = [\n\t[\"execute\", [\"implementation agent\", \"produce a fix\"]],\n\t[\"verify\", [\"qa reviewer\", \"verify whether\"]],\n\t[\"triage\", [\"triage classifier\", \"intake item\"]],\n];\n\nfunction detectStage(text: string, customStages?: Record<string, StageScript>): string {\n\tconst lower = text.toLowerCase();\n\n\t// Check built-in multi-word keywords first (more specific, avoids substring collisions\n\t// like \"triaged\" matching \"triage\")\n\tfor (const [stage, keywords] of STAGE_KEYWORDS) {\n\t\tif (keywords.some((kw) => lower.includes(kw))) return stage;\n\t}\n\n\t// Fall back to custom stage names as keywords\n\tif (customStages) {\n\t\tfor (const stage of Object.keys(customStages)) {\n\t\t\tif (lower.includes(stage.toLowerCase())) return stage;\n\t\t}\n\t}\n\n\treturn \"unknown\";\n}\n\n// ---------------------------------------------------------------------------\n// Factory\n// ---------------------------------------------------------------------------\n\n/**\n * Create a scenario-scripted mock LLM adapter.\n *\n * ```ts\n * const mock = mockLLM({\n * stages: {\n * triage: { responses: [{ rootCause: \"missing-fn\", intervention: \"catalog-fn\", route: \"auto-fix\", priority: 80 }] },\n * execute: { responses: [{ outcome: \"success\", detail: \"Fixed\" }] },\n * verify: { responses: [{ verified: false, findings: [\"err\"], errorClass: \"self-correctable\" },\n * { verified: true, findings: [\"ok\"] }] },\n * },\n * });\n * ```\n */\nexport function mockLLM(script: MockScript = {}): MockLLMAdapter {\n\tconst calls: MockCall[] = [];\n\tconst stageCounts = new Map<string, number>();\n\tconst stageIndices = new Map<string, number>();\n\n\tfunction getResponse(stage: string): unknown {\n\t\tconst stageScript = script.stages?.[stage];\n\t\tif (!stageScript) return script.fallback ?? {};\n\n\t\tconst idx = stageIndices.get(stage) ?? 0;\n\t\tconst responses = stageScript.responses;\n\t\tconst response = responses[Math.min(idx, responses.length - 1)];\n\t\tstageIndices.set(stage, idx + 1);\n\t\treturn response;\n\t}\n\n\tfunction invoke(messages: readonly ChatMessage[]): Promise<LLMResponse> {\n\t\tconst text = messages.map((m) => m.content).join(\" \");\n\t\tconst stage = detectStage(text, script.stages);\n\n\t\tconst count = stageCounts.get(stage) ?? 0;\n\t\tstageCounts.set(stage, count + 1);\n\n\t\tconst responseData = getResponse(stage);\n\t\tconst response: LLMResponse = {\n\t\t\tcontent: typeof responseData === \"string\" ? responseData : JSON.stringify(responseData),\n\t\t\tusage: { input: { regular: 0 }, output: { regular: 0 } },\n\t\t};\n\n\t\tcalls.push({ stage, messages, response });\n\t\treturn Promise.resolve(response);\n\t}\n\n\tasync function* stream(): AsyncIterable<\n\t\timport(\"../utils/ai/adapters/core/types.js\").StreamDelta\n\t> {\n\t\tyield { type: \"token\", delta: \"mock stream\" };\n\t\tyield { type: \"usage\", usage: { input: { regular: 0 }, output: { regular: 0 } } };\n\t\tyield { type: \"finish\", reason: \"stop\" };\n\t}\n\n\treturn {\n\t\tprovider: \"mock\",\n\t\tcalls,\n\t\tget stageCounts() {\n\t\t\treturn stageCounts as ReadonlyMap<string, number>;\n\t\t},\n\t\tcallsFor(stage: string) {\n\t\t\treturn calls.filter((c) => c.stage === stage);\n\t\t},\n\t\treset() {\n\t\t\tcalls.length = 0;\n\t\t\tstageCounts.clear();\n\t\t\tstageIndices.clear();\n\t\t},\n\t\tinvoke,\n\t\tstream,\n\t};\n}\n"],"mappings":";;;AAyDA,IAAM,iBAAuC;AAAA,EAC5C,CAAC,WAAW,CAAC,wBAAwB,eAAe,CAAC;AAAA,EACrD,CAAC,UAAU,CAAC,eAAe,gBAAgB,CAAC;AAAA,EAC5C,CAAC,UAAU,CAAC,qBAAqB,aAAa,CAAC;AAChD;AAEA,SAAS,YAAY,MAAc,cAAoD;AACtF,QAAM,QAAQ,KAAK,YAAY;AAI/B,aAAW,CAAC,OAAO,QAAQ,KAAK,gBAAgB;AAC/C,QAAI,SAAS,KAAK,CAAC,OAAO,MAAM,SAAS,EAAE,CAAC,EAAG,QAAO;AAAA,EACvD;AAGA,MAAI,cAAc;AACjB,eAAW,SAAS,OAAO,KAAK,YAAY,GAAG;AAC9C,UAAI,MAAM,SAAS,MAAM,YAAY,CAAC,EAAG,QAAO;AAAA,IACjD;AAAA,EACD;AAEA,SAAO;AACR;AAoBO,SAAS,QAAQ,SAAqB,CAAC,GAAmB;AAChE,QAAM,QAAoB,CAAC;AAC3B,QAAM,cAAc,oBAAI,IAAoB;AAC5C,QAAM,eAAe,oBAAI,IAAoB;AAE7C,WAAS,YAAY,OAAwB;AAC5C,UAAM,cAAc,OAAO,SAAS,KAAK;AACzC,QAAI,CAAC,YAAa,QAAO,OAAO,YAAY,CAAC;AAE7C,UAAM,MAAM,aAAa,IAAI,KAAK,KAAK;AACvC,UAAM,YAAY,YAAY;AAC9B,UAAM,WAAW,UAAU,KAAK,IAAI,KAAK,UAAU,SAAS,CAAC,CAAC;AAC9D,iBAAa,IAAI,OAAO,MAAM,CAAC;AAC/B,WAAO;AAAA,EACR;AAEA,WAAS,OAAO,UAAwD;AACvE,UAAM,OAAO,SAAS,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,GAAG;AACpD,UAAM,QAAQ,YAAY,MAAM,OAAO,MAAM;AAE7C,UAAM,QAAQ,YAAY,IAAI,KAAK,KAAK;AACxC,gBAAY,IAAI,OAAO,QAAQ,CAAC;AAEhC,UAAM,eAAe,YAAY,KAAK;AACtC,UAAM,WAAwB;AAAA,MAC7B,SAAS,OAAO,iBAAiB,WAAW,eAAe,KAAK,UAAU,YAAY;AAAA,MACtF,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,QAAQ,EAAE,SAAS,EAAE,EAAE;AAAA,IACxD;AAEA,UAAM,KAAK,EAAE,OAAO,UAAU,SAAS,CAAC;AACxC,WAAO,QAAQ,QAAQ,QAAQ;AAAA,EAChC;AAEA,kBAAgB,SAEd;AACD,UAAM,EAAE,MAAM,SAAS,OAAO,cAAc;AAC5C,UAAM,EAAE,MAAM,SAAS,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,QAAQ,EAAE,SAAS,EAAE,EAAE,EAAE;AAChF,UAAM,EAAE,MAAM,UAAU,QAAQ,OAAO;AAAA,EACxC;AAEA,SAAO;AAAA,IACN,UAAU;AAAA,IACV;AAAA,IACA,IAAI,cAAc;AACjB,aAAO;AAAA,IACR;AAAA,IACA,SAAS,OAAe;AACvB,aAAO,MAAM,OAAO,CAAC,MAAM,EAAE,UAAU,KAAK;AAAA,IAC7C;AAAA,IACA,QAAQ;AACP,YAAM,SAAS;AACf,kBAAY,MAAM;AAClB,mBAAa,MAAM;AAAA,IACpB;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACD;","names":[]}
|