@remnic/core 10.0.194 → 10.0.195
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/access-admin-ops-surface.js +58 -59
- package/dist/access-cli.js +58 -59
- package/dist/access-cli.js.map +1 -1
- package/dist/access-extraction-force-flush-preempt.js +58 -59
- package/dist/access-extraction-force-flush.js +58 -59
- package/dist/access-http-briefing.js +58 -59
- package/dist/access-http-query.js +58 -59
- package/dist/access-http.js +58 -59
- package/dist/access-identity-continuity-surface.js +58 -59
- package/dist/access-lcm-surface.js +58 -59
- package/dist/access-mcp.js +58 -59
- package/dist/access-observe-write-surface.js +58 -59
- package/dist/access-operations-batch.js +58 -59
- package/dist/access-operations.js +58 -59
- package/dist/access-recall-concurrency.js +58 -59
- package/dist/access-recall-diagnostics.js +2 -2
- package/dist/access-recall-response.js +58 -59
- package/dist/access-recall-surface.js +58 -59
- package/dist/access-service.js +58 -59
- package/dist/active-recall.js +7 -6
- package/dist/active-recall.js.map +1 -1
- package/dist/{auto-sync-BJUAGKI5.js → auto-sync-BEW65FDT.js} +6 -5
- package/dist/{auto-sync-BJUAGKI5.js.map → auto-sync-BEW65FDT.js.map} +1 -1
- package/dist/briefing.js +7 -6
- package/dist/buffer.d.ts +1 -0
- package/dist/buffer.d.ts.map +1 -1
- package/dist/buffer.js +3 -3
- package/dist/calibration.js +5 -4
- package/dist/calibration.js.map +1 -1
- package/dist/causal-consolidation.js +8 -7
- package/dist/causal-consolidation.js.map +1 -1
- package/dist/{chunk-FZU62GIV.js → chunk-2X5I5C3M.js} +27 -10
- package/dist/chunk-2X5I5C3M.js.map +1 -0
- package/dist/{chunk-DYUPSTCV.js → chunk-3EXG2KPK.js} +3 -3
- package/dist/{chunk-FGFU6J26.js → chunk-4FTYKZ77.js} +3 -3
- package/dist/{chunk-4EAVEDLG.js → chunk-4GVSMPBP.js} +8 -8
- package/dist/{chunk-QIPRDRGM.js → chunk-4HEJDVPU.js} +1 -1
- package/dist/chunk-4HEJDVPU.js.map +1 -0
- package/dist/{chunk-EEA2RM4B.js → chunk-4I6A3SDL.js} +2 -2
- package/dist/{chunk-SKJM4PKE.js → chunk-4JI5PPFW.js} +2 -2
- package/dist/{chunk-TDG5NZAZ.js → chunk-65JA7LWV.js} +2 -2
- package/dist/{chunk-3YID7KZ6.js → chunk-6QMKUWXH.js} +2 -2
- package/dist/{chunk-7SOKOEAZ.js → chunk-6RRHTHKQ.js} +2 -2
- package/dist/{chunk-VHQNJW4Q.js → chunk-6W62D4MC.js} +2 -2
- package/dist/{chunk-2QW5HPKU.js → chunk-76LBLH62.js} +35 -28
- package/dist/chunk-76LBLH62.js.map +1 -0
- package/dist/{chunk-NN3LMWKA.js → chunk-7TQ3EDQ3.js} +1 -1
- package/dist/chunk-7TQ3EDQ3.js.map +1 -0
- package/dist/{chunk-KJ65WZHB.js → chunk-A7DIZOTF.js} +2 -2
- package/dist/{chunk-TZ7ZA2LM.js → chunk-AD3JOG2Q.js} +2 -2
- package/dist/{chunk-KZ4BJRGQ.js → chunk-BD26CK6T.js} +2 -2
- package/dist/{chunk-BDFSVUUZ.js → chunk-C3H2QZOZ.js} +2 -1
- package/dist/chunk-C3H2QZOZ.js.map +1 -0
- package/dist/{chunk-7EP4FURO.js → chunk-C72YQM7E.js} +2 -2
- package/dist/{chunk-CJSTQNE5.js → chunk-CTOMDCCA.js} +2 -2
- package/dist/{chunk-PSQ347YP.js → chunk-DSKII2W4.js} +3 -3
- package/dist/{chunk-KOVQZJ27.js → chunk-E7LDTUWK.js} +2 -2
- package/dist/{chunk-SPAKBUJY.js → chunk-EWLMEYLF.js} +2 -2
- package/dist/{chunk-3BICT225.js → chunk-FGNBUUPX.js} +2 -2
- package/dist/{chunk-QZMGZBTF.js → chunk-HBG6CQEX.js} +2 -2
- package/dist/{chunk-FKHXXL42.js → chunk-HD7M55OI.js} +2 -2
- package/dist/{chunk-7V6GNQC2.js → chunk-HINQENZG.js} +2 -2
- package/dist/{chunk-WRVKI6ZO.js → chunk-HLQXSX4F.js} +2 -2
- package/dist/{chunk-T765HQ5U.js → chunk-IIDAN7XJ.js} +2 -2
- package/dist/{chunk-G2MS56KM.js → chunk-IT4G6HTG.js} +2 -2
- package/dist/{chunk-M7Q7Z6V5.js → chunk-JDZ5JPYG.js} +38 -8
- package/dist/chunk-JDZ5JPYG.js.map +1 -0
- package/dist/{chunk-MMRTPH3J.js → chunk-KQYGUFMQ.js} +5 -3
- package/dist/chunk-KQYGUFMQ.js.map +1 -0
- package/dist/{chunk-TWYYUMYO.js → chunk-KXAGZRJV.js} +2 -2
- package/dist/{chunk-JITK24KX.js → chunk-LJNCJK7B.js} +10 -10
- package/dist/{chunk-Z6EFSXU3.js → chunk-LMM2LRVQ.js} +2 -2
- package/dist/{chunk-V65H7MI6.js → chunk-M42UFQZY.js} +51 -4
- package/dist/chunk-M42UFQZY.js.map +1 -0
- package/dist/{chunk-VSLV3EEP.js → chunk-ME63JKWJ.js} +59 -57
- package/dist/{chunk-VSLV3EEP.js.map → chunk-ME63JKWJ.js.map} +1 -1
- package/dist/{chunk-AALJHIKH.js → chunk-OHJ5PNYB.js} +3 -3
- package/dist/{chunk-XZMQLON4.js → chunk-OK726OF4.js} +7 -5
- package/dist/chunk-OK726OF4.js.map +1 -0
- package/dist/{chunk-Q6S67LHR.js → chunk-OOMFFMX3.js} +2 -2
- package/dist/{chunk-VMNX2UV7.js → chunk-Q2GDUJSK.js} +5 -5
- package/dist/{chunk-JNDMIAJ4.js → chunk-QEVZKJM6.js} +2 -2
- package/dist/{chunk-ZNCCX7P6.js → chunk-QW5LZTKA.js} +2 -2
- package/dist/{chunk-5GIYIYJI.js → chunk-QZPAOOU7.js} +2 -2
- package/dist/{chunk-NKHRIDYP.js → chunk-RTXW6E6X.js} +3 -3
- package/dist/{chunk-5WDUY2ZZ.js → chunk-S4QWAWR6.js} +4 -4
- package/dist/{chunk-STSORBX5.js → chunk-SFUS2V2V.js} +1 -1
- package/dist/{chunk-HEJFE3BC.js → chunk-SJCN7ESG.js} +2 -2
- package/dist/{chunk-AJ7JHHRY.js → chunk-SPPWVMP4.js} +2 -2
- package/dist/{chunk-QSF5SJAM.js → chunk-STQNKDKZ.js} +9 -3
- package/dist/chunk-STQNKDKZ.js.map +1 -0
- package/dist/{chunk-QFKNIKUF.js → chunk-SXR7L57Z.js} +2 -2
- package/dist/{chunk-GYCUX3N4.js → chunk-TGMIJABS.js} +2 -2
- package/dist/{chunk-GH7IKABD.js → chunk-UFJJMQDV.js} +2 -2
- package/dist/{chunk-UH2VY2QQ.js → chunk-WCW7I7ZM.js} +2 -2
- package/dist/{chunk-3RZ4GDOH.js → chunk-XDNVWY7I.js} +93 -23
- package/dist/chunk-XDNVWY7I.js.map +1 -0
- package/dist/{chunk-LR6LWX33.js → chunk-XXDIPAUE.js} +2 -2
- package/dist/{chunk-YCJJODER.js → chunk-YCTD3XET.js} +10 -3
- package/dist/chunk-YCTD3XET.js.map +1 -0
- package/dist/{chunk-WEI6HEUX.js → chunk-YXAH5TSN.js} +2 -2
- package/dist/{chunk-75K6DRPN.js → chunk-ZAVFAGBE.js} +2 -2
- package/dist/{chunk-7KTORRIK.js → chunk-ZNJU3NBJ.js} +2 -2
- package/dist/cli.js +58 -59
- package/dist/coding/export-okf-codegraph.js +6 -5
- package/dist/coding/export-okf-codegraph.js.map +1 -1
- package/dist/compounding/engine.js +8 -7
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +7 -6
- package/dist/connectors/codex-materialize-runner.js +7 -6
- package/dist/connectors/index.js +7 -6
- package/dist/convergence-refresh.js +9 -8
- package/dist/corpus-watermark.js +9 -8
- package/dist/deep-recall-policy-llm.js +4 -3
- package/dist/entity-retrieval.js +7 -6
- package/dist/explicit-capture.js +58 -59
- package/dist/extraction-error-classification.d.ts +40 -5
- package/dist/extraction-error-classification.d.ts.map +1 -1
- package/dist/extraction-error-classification.js +5 -2
- package/dist/extraction-faithfulness.js +4 -3
- package/dist/extraction-judge.js +4 -3
- package/dist/extraction.d.ts.map +1 -1
- package/dist/extraction.js +17 -18
- package/dist/fallback-llm-codex-subscription.d.ts +3 -1
- package/dist/fallback-llm-codex-subscription.d.ts.map +1 -1
- package/dist/fallback-llm-codex-subscription.js +2 -1
- package/dist/fallback-llm.d.ts.map +1 -1
- package/dist/fallback-llm.js +3 -2
- package/dist/harmonic-retrieval.js +7 -6
- package/dist/index.js +58 -59
- package/dist/live-connectors-runner.js +1 -2
- package/dist/local-llm-helpers.d.ts +1 -0
- package/dist/local-llm-helpers.d.ts.map +1 -1
- package/dist/local-llm-helpers.js +1 -1
- package/dist/local-llm.d.ts.map +1 -1
- package/dist/local-llm.js +4 -3
- package/dist/location/index.js +8 -7
- package/dist/maintenance/memory-governance.js +7 -6
- package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +7 -6
- package/dist/maintenance/rebuild-memory-projection-runner.js +9 -8
- package/dist/maintenance/rebuild-memory-projection.js +8 -7
- package/dist/memory-browse.js +3 -3
- package/dist/namespaces/migrate.js +8 -7
- package/dist/namespaces/storage.js +7 -6
- package/dist/operator-doctor-corpus.js +10 -9
- package/dist/operator-toolkit.js +14 -13
- package/dist/orchestration/backlog-scheduler.js +59 -60
- package/dist/orchestration/backlog-scheduler.js.map +1 -1
- package/dist/orchestration/buffer-drain-runner.js +59 -60
- package/dist/orchestration/extraction-drain.d.ts +1 -0
- package/dist/orchestration/extraction-drain.d.ts.map +1 -1
- package/dist/orchestration/extraction-run-helpers.d.ts +41 -4
- package/dist/orchestration/extraction-run-helpers.d.ts.map +1 -1
- package/dist/orchestration/extraction-run.d.ts +4 -0
- package/dist/orchestration/extraction-run.d.ts.map +1 -1
- package/dist/orchestration/maintenance.js +17 -16
- package/dist/orchestrator.js +58 -59
- package/dist/recall-explain-renderer.js +3 -3
- package/dist/recall-navigate-access.js +2 -2
- package/dist/recall-navigate-disclosure.js +2 -2
- package/dist/recall-navigate.js +2 -2
- package/dist/recall-navigation.js +58 -59
- package/dist/recall-planner-llm.js +3 -2
- package/dist/recall-planner-llm.js.map +1 -1
- package/dist/recall-state-view-admission.js +3 -3
- package/dist/recall-why-service.js +3 -3
- package/dist/recall-xray-cli.js +4 -4
- package/dist/recall-xray-renderer.js +3 -3
- package/dist/recall-xray.js +2 -2
- package/dist/resume-bundles.js +8 -7
- package/dist/semantic-consolidation.js +8 -7
- package/dist/semantic-rule-promotion.js +7 -6
- package/dist/semantic-rule-verifier.js +7 -6
- package/dist/source-agent-qualifier.js +10 -9
- package/dist/standup/build.js +7 -6
- package/dist/storage.d.ts.map +1 -1
- package/dist/storage.js +6 -5
- package/dist/summarizer.js +6 -5
- package/dist/support-passport/index.js +6 -5
- package/dist/transfer/export-okf.js +7 -6
- package/dist/types-extraction-failure.d.ts +7 -1
- package/dist/types-extraction-failure.d.ts.map +1 -1
- package/dist/types.d.ts +6 -6
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -1
- package/dist/verified-recall.js +7 -6
- package/dist/who-knows-cli.js +8 -7
- package/dist/who-knows.js +7 -6
- package/package.json +2 -2
- package/src/buffer-incremental-persistence.test.ts +23 -0
- package/src/buffer.ts +30 -28
- package/src/config.ts +2 -0
- package/src/extraction-error-classification.ts +88 -8
- package/src/extraction-local-failure-class.test.ts +117 -3
- package/src/extraction-reply-diagnostic-wiring.test.ts +3 -1
- package/src/extraction.test.ts +73 -3
- package/src/extraction.ts +26 -25
- package/src/fallback-llm-codex-subscription.ts +17 -3
- package/src/fallback-llm.test.ts +70 -0
- package/src/fallback-llm.ts +17 -18
- package/src/local-llm-headers-timeout.test.ts +151 -0
- package/src/local-llm-helpers.ts +1 -1
- package/src/local-llm.ts +44 -43
- package/src/orchestration/extraction-drain.ts +11 -5
- package/src/orchestration/extraction-run-helpers.ts +110 -4
- package/src/orchestration/extraction-run.test.ts +408 -3
- package/src/orchestration/extraction-run.ts +75 -75
- package/src/storage.ts +5 -4
- package/src/types-extraction-failure.ts +12 -1
- package/src/types.ts +6 -6
- package/dist/chunk-2QW5HPKU.js.map +0 -1
- package/dist/chunk-3RZ4GDOH.js.map +0 -1
- package/dist/chunk-BDFSVUUZ.js.map +0 -1
- package/dist/chunk-C7SRUWBW.js +0 -54
- package/dist/chunk-C7SRUWBW.js.map +0 -1
- package/dist/chunk-FZU62GIV.js.map +0 -1
- package/dist/chunk-M7Q7Z6V5.js.map +0 -1
- package/dist/chunk-MMRTPH3J.js.map +0 -1
- package/dist/chunk-NN3LMWKA.js.map +0 -1
- package/dist/chunk-QIPRDRGM.js.map +0 -1
- package/dist/chunk-QSF5SJAM.js.map +0 -1
- package/dist/chunk-V65H7MI6.js.map +0 -1
- package/dist/chunk-XZMQLON4.js.map +0 -1
- package/dist/chunk-YCJJODER.js.map +0 -1
- /package/dist/{chunk-DYUPSTCV.js.map → chunk-3EXG2KPK.js.map} +0 -0
- /package/dist/{chunk-FGFU6J26.js.map → chunk-4FTYKZ77.js.map} +0 -0
- /package/dist/{chunk-4EAVEDLG.js.map → chunk-4GVSMPBP.js.map} +0 -0
- /package/dist/{chunk-EEA2RM4B.js.map → chunk-4I6A3SDL.js.map} +0 -0
- /package/dist/{chunk-SKJM4PKE.js.map → chunk-4JI5PPFW.js.map} +0 -0
- /package/dist/{chunk-TDG5NZAZ.js.map → chunk-65JA7LWV.js.map} +0 -0
- /package/dist/{chunk-3YID7KZ6.js.map → chunk-6QMKUWXH.js.map} +0 -0
- /package/dist/{chunk-7SOKOEAZ.js.map → chunk-6RRHTHKQ.js.map} +0 -0
- /package/dist/{chunk-VHQNJW4Q.js.map → chunk-6W62D4MC.js.map} +0 -0
- /package/dist/{chunk-KJ65WZHB.js.map → chunk-A7DIZOTF.js.map} +0 -0
- /package/dist/{chunk-TZ7ZA2LM.js.map → chunk-AD3JOG2Q.js.map} +0 -0
- /package/dist/{chunk-KZ4BJRGQ.js.map → chunk-BD26CK6T.js.map} +0 -0
- /package/dist/{chunk-7EP4FURO.js.map → chunk-C72YQM7E.js.map} +0 -0
- /package/dist/{chunk-CJSTQNE5.js.map → chunk-CTOMDCCA.js.map} +0 -0
- /package/dist/{chunk-PSQ347YP.js.map → chunk-DSKII2W4.js.map} +0 -0
- /package/dist/{chunk-KOVQZJ27.js.map → chunk-E7LDTUWK.js.map} +0 -0
- /package/dist/{chunk-SPAKBUJY.js.map → chunk-EWLMEYLF.js.map} +0 -0
- /package/dist/{chunk-3BICT225.js.map → chunk-FGNBUUPX.js.map} +0 -0
- /package/dist/{chunk-QZMGZBTF.js.map → chunk-HBG6CQEX.js.map} +0 -0
- /package/dist/{chunk-FKHXXL42.js.map → chunk-HD7M55OI.js.map} +0 -0
- /package/dist/{chunk-7V6GNQC2.js.map → chunk-HINQENZG.js.map} +0 -0
- /package/dist/{chunk-WRVKI6ZO.js.map → chunk-HLQXSX4F.js.map} +0 -0
- /package/dist/{chunk-T765HQ5U.js.map → chunk-IIDAN7XJ.js.map} +0 -0
- /package/dist/{chunk-G2MS56KM.js.map → chunk-IT4G6HTG.js.map} +0 -0
- /package/dist/{chunk-TWYYUMYO.js.map → chunk-KXAGZRJV.js.map} +0 -0
- /package/dist/{chunk-JITK24KX.js.map → chunk-LJNCJK7B.js.map} +0 -0
- /package/dist/{chunk-Z6EFSXU3.js.map → chunk-LMM2LRVQ.js.map} +0 -0
- /package/dist/{chunk-AALJHIKH.js.map → chunk-OHJ5PNYB.js.map} +0 -0
- /package/dist/{chunk-Q6S67LHR.js.map → chunk-OOMFFMX3.js.map} +0 -0
- /package/dist/{chunk-VMNX2UV7.js.map → chunk-Q2GDUJSK.js.map} +0 -0
- /package/dist/{chunk-JNDMIAJ4.js.map → chunk-QEVZKJM6.js.map} +0 -0
- /package/dist/{chunk-ZNCCX7P6.js.map → chunk-QW5LZTKA.js.map} +0 -0
- /package/dist/{chunk-5GIYIYJI.js.map → chunk-QZPAOOU7.js.map} +0 -0
- /package/dist/{chunk-NKHRIDYP.js.map → chunk-RTXW6E6X.js.map} +0 -0
- /package/dist/{chunk-5WDUY2ZZ.js.map → chunk-S4QWAWR6.js.map} +0 -0
- /package/dist/{chunk-STSORBX5.js.map → chunk-SFUS2V2V.js.map} +0 -0
- /package/dist/{chunk-HEJFE3BC.js.map → chunk-SJCN7ESG.js.map} +0 -0
- /package/dist/{chunk-AJ7JHHRY.js.map → chunk-SPPWVMP4.js.map} +0 -0
- /package/dist/{chunk-QFKNIKUF.js.map → chunk-SXR7L57Z.js.map} +0 -0
- /package/dist/{chunk-GYCUX3N4.js.map → chunk-TGMIJABS.js.map} +0 -0
- /package/dist/{chunk-GH7IKABD.js.map → chunk-UFJJMQDV.js.map} +0 -0
- /package/dist/{chunk-UH2VY2QQ.js.map → chunk-WCW7I7ZM.js.map} +0 -0
- /package/dist/{chunk-LR6LWX33.js.map → chunk-XXDIPAUE.js.map} +0 -0
- /package/dist/{chunk-WEI6HEUX.js.map → chunk-YXAH5TSN.js.map} +0 -0
- /package/dist/{chunk-75K6DRPN.js.map → chunk-ZAVFAGBE.js.map} +0 -0
- /package/dist/{chunk-7KTORRIK.js.map → chunk-ZNJU3NBJ.js.map} +0 -0
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
} from "./chunk-ZAJLJ35W.js";
|
|
12
12
|
import {
|
|
13
13
|
parseConfig
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-C3H2QZOZ.js";
|
|
15
15
|
import {
|
|
16
16
|
resolveObjectiveStateStoreDir,
|
|
17
17
|
validateObjectiveStateSnapshot
|
|
@@ -268,4 +268,4 @@ export {
|
|
|
268
268
|
recordResumeBundle,
|
|
269
269
|
getResumeBundleStatus
|
|
270
270
|
};
|
|
271
|
-
//# sourceMappingURL=chunk-
|
|
271
|
+
//# sourceMappingURL=chunk-C72YQM7E.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
listNamespaces
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-SJCN7ESG.js";
|
|
4
4
|
import {
|
|
5
5
|
corpusScanWorker
|
|
6
6
|
} from "./chunk-4LZ7SVKM.js";
|
|
@@ -292,4 +292,4 @@ export {
|
|
|
292
292
|
computeServiceCorpusWatermarks,
|
|
293
293
|
computeServiceCorpusCensus
|
|
294
294
|
};
|
|
295
|
-
//# sourceMappingURL=chunk-
|
|
295
|
+
//# sourceMappingURL=chunk-CTOMDCCA.js.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
parseXrayFormat
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-65JA7LWV.js";
|
|
4
4
|
import {
|
|
5
5
|
RECALL_DISCLOSURE_LEVELS,
|
|
6
6
|
isRecallDisclosure
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-4HEJDVPU.js";
|
|
8
8
|
|
|
9
9
|
// src/recall-xray-cli.ts
|
|
10
10
|
function parseXrayDisclosureFlag(value) {
|
|
@@ -50,4 +50,4 @@ export {
|
|
|
50
50
|
parseXrayBudgetFlag,
|
|
51
51
|
parseXrayCliOptions
|
|
52
52
|
};
|
|
53
|
-
//# sourceMappingURL=chunk-
|
|
53
|
+
//# sourceMappingURL=chunk-DSKII2W4.js.map
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
} from "./chunk-EKUI7I2X.js";
|
|
11
11
|
import {
|
|
12
12
|
StorageManager
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-OK726OF4.js";
|
|
14
14
|
import {
|
|
15
15
|
normalizeEntityName
|
|
16
16
|
} from "./chunk-YXZG5TVN.js";
|
|
@@ -974,4 +974,4 @@ export {
|
|
|
974
974
|
resolveBriefingSaveDir,
|
|
975
975
|
briefingFilename
|
|
976
976
|
};
|
|
977
|
-
//# sourceMappingURL=chunk-
|
|
977
|
+
//# sourceMappingURL=chunk-E7LDTUWK.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
gatewayTaskChainOptions
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-KQYGUFMQ.js";
|
|
4
4
|
import {
|
|
5
5
|
isAbortError,
|
|
6
6
|
throwIfAborted
|
|
@@ -70,4 +70,4 @@ export {
|
|
|
70
70
|
DEEP_RECALL_POLICY_SYSTEM_PROMPT,
|
|
71
71
|
callDeepRecallPolicyLlm
|
|
72
72
|
};
|
|
73
|
-
//# sourceMappingURL=chunk-
|
|
73
|
+
//# sourceMappingURL=chunk-EWLMEYLF.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
resolveDefaultNamespaceRoot,
|
|
3
3
|
resolveNamespaceStorageRoot
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-SPPWVMP4.js";
|
|
5
5
|
import {
|
|
6
6
|
getConfiguredNamespaces
|
|
7
7
|
} from "./chunk-Y6FJDJUK.js";
|
|
@@ -2308,4 +2308,4 @@ export {
|
|
|
2308
2308
|
runNamespaceMaintenancePlan,
|
|
2309
2309
|
runNamespaceMaintenanceBatchPlan
|
|
2310
2310
|
};
|
|
2311
|
-
//# sourceMappingURL=chunk-
|
|
2311
|
+
//# sourceMappingURL=chunk-FGNBUUPX.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
StorageManager
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-OK726OF4.js";
|
|
4
4
|
import {
|
|
5
5
|
composeMemoryEnvelope
|
|
6
6
|
} from "./chunk-X26YOFGS.js";
|
|
@@ -546,4 +546,4 @@ export {
|
|
|
546
546
|
setSemanticRulePromotionTestHooks,
|
|
547
547
|
promoteSemanticRuleFromMemory
|
|
548
548
|
};
|
|
549
|
-
//# sourceMappingURL=chunk-
|
|
549
|
+
//# sourceMappingURL=chunk-HBG6CQEX.js.map
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
} from "./chunk-ULLGI6XR.js";
|
|
9
9
|
import {
|
|
10
10
|
deriveSourceConnector
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-XDNVWY7I.js";
|
|
12
12
|
import {
|
|
13
13
|
resolvePipelineProcessingCapabilities
|
|
14
14
|
} from "./chunk-MOWZCAKS.js";
|
|
@@ -130,4 +130,4 @@ export {
|
|
|
130
130
|
renderExtractionConversation,
|
|
131
131
|
applyGroundingWithConnector
|
|
132
132
|
};
|
|
133
|
-
//# sourceMappingURL=chunk-
|
|
133
|
+
//# sourceMappingURL=chunk-HD7M55OI.js.map
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-2LWXBERZ.js";
|
|
4
4
|
import {
|
|
5
5
|
isRecallDisclosure
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-4HEJDVPU.js";
|
|
7
7
|
import {
|
|
8
8
|
EngramAccessInputError
|
|
9
9
|
} from "./chunk-MGKCKY7X.js";
|
|
@@ -165,4 +165,4 @@ export {
|
|
|
165
165
|
handleRecallWhyHttpQuery,
|
|
166
166
|
handleRecallXrayHttpQuery
|
|
167
167
|
};
|
|
168
|
-
//# sourceMappingURL=chunk-
|
|
168
|
+
//# sourceMappingURL=chunk-HINQENZG.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
RECALL_DISCLOSURE_LEVELS
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-4HEJDVPU.js";
|
|
4
4
|
|
|
5
5
|
// src/recall-navigate.ts
|
|
6
6
|
var RECALL_NAV_LINK_TYPES = [
|
|
@@ -48,4 +48,4 @@ export {
|
|
|
48
48
|
expandRecallNode,
|
|
49
49
|
traverseRecallLink
|
|
50
50
|
};
|
|
51
|
-
//# sourceMappingURL=chunk-
|
|
51
|
+
//# sourceMappingURL=chunk-HLQXSX4F.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
StorageManager
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-OK726OF4.js";
|
|
4
4
|
import {
|
|
5
5
|
countRecallTokenOverlap,
|
|
6
6
|
normalizeRecallTokens
|
|
@@ -119,4 +119,4 @@ export {
|
|
|
119
119
|
compareVerifiedSemanticRuleResults,
|
|
120
120
|
searchVerifiedSemanticRules
|
|
121
121
|
};
|
|
122
|
-
//# sourceMappingURL=chunk-
|
|
122
|
+
//# sourceMappingURL=chunk-IIDAN7XJ.js.map
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-5HFVWYHL.js";
|
|
4
4
|
import {
|
|
5
5
|
isGenericRecallExcludedPath
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-QW5LZTKA.js";
|
|
7
7
|
import {
|
|
8
8
|
planRecallMode
|
|
9
9
|
} from "./chunk-CSAKJVXW.js";
|
|
@@ -132,4 +132,4 @@ async function findExpectedMemory(orchestrator, namespaces, expect) {
|
|
|
132
132
|
export {
|
|
133
133
|
runRecallWhy
|
|
134
134
|
};
|
|
135
|
-
//# sourceMappingURL=chunk-
|
|
135
|
+
//# sourceMappingURL=chunk-IT4G6HTG.js.map
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
isTransientHttpError
|
|
3
|
-
} from "./chunk-C7SRUWBW.js";
|
|
4
|
-
|
|
5
1
|
// src/extraction-error-classification.ts
|
|
6
2
|
function httpStatusFromError(err) {
|
|
7
3
|
if (!err || typeof err !== "object") return void 0;
|
|
@@ -15,12 +11,37 @@ function classifyExtractionThrownError(err) {
|
|
|
15
11
|
try {
|
|
16
12
|
const status = httpStatusFromError(err);
|
|
17
13
|
if (status === 401 || status === 403) return "auth_config";
|
|
18
|
-
if (
|
|
14
|
+
if (status !== void 0) {
|
|
15
|
+
if (status === 400 && isParameterConfigRejection(err)) return "auth_config";
|
|
16
|
+
if (status === 400 || status === 413 || status === 422) {
|
|
17
|
+
return err instanceof Object && "transientAttemptSeen" in err && err.transientAttemptSeen === true ? "provider_retryable" : "provider_permanent";
|
|
18
|
+
}
|
|
19
|
+
return status === 408 || status === 429 || status >= 500 ? "provider_retryable" : "auth_config";
|
|
20
|
+
}
|
|
19
21
|
return "provider_retryable";
|
|
20
22
|
} catch {
|
|
21
23
|
return "provider_retryable";
|
|
22
24
|
}
|
|
23
25
|
}
|
|
26
|
+
function downgradePermanentOnTransientAttempt(cls, transientAttemptSeen) {
|
|
27
|
+
return transientAttemptSeen && cls === "provider_permanent" ? "provider_retryable" : cls;
|
|
28
|
+
}
|
|
29
|
+
var PARAMETER_CONFIG_CODE = /^(?:unsupported_parameter|unsupported_value|unknown_parameter|invalid_parameter|parameter_not_supported|http_4xx_parameter)$/i;
|
|
30
|
+
var PARAMETER_CONFIG_MESSAGE = /(?:unsupported|unknown|unexpected|unrecognized) (?:parameter|param|field|option)\b|not supported (?:with|for|by) this model|additional propert(?:y|ies) (?:are )?not allowed/i;
|
|
31
|
+
function isParameterConfigRejection(cause) {
|
|
32
|
+
try {
|
|
33
|
+
if (!(cause instanceof Object)) return false;
|
|
34
|
+
if ("code" in cause && PARAMETER_CONFIG_CODE.test(String(cause.code))) return true;
|
|
35
|
+
if ("type" in cause && PARAMETER_CONFIG_CODE.test(String(cause.type))) return true;
|
|
36
|
+
if ("errorClass" in cause && PARAMETER_CONFIG_CODE.test(String(cause.errorClass))) return true;
|
|
37
|
+
const nested = "error" in cause && cause.error instanceof Object ? cause.error : void 0;
|
|
38
|
+
if (nested && "code" in nested && PARAMETER_CONFIG_CODE.test(String(nested.code))) return true;
|
|
39
|
+
const msg = "message" in cause ? String(cause.message) : void 0;
|
|
40
|
+
return msg !== void 0 && PARAMETER_CONFIG_MESSAGE.test(msg);
|
|
41
|
+
} catch {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
24
45
|
var CONTEXT_LIMIT_MESSAGE = /maximum context|context length|context window|request entity/i;
|
|
25
46
|
var SIZE_LIMIT_PHRASE = /too large|too long|exceed/i;
|
|
26
47
|
var INPUT_SUBJECT_TERM = /\b(?:input|prompt|request|payload|body|messages?|content|context|size|length|tokens?)\b/i;
|
|
@@ -77,17 +98,24 @@ function formatExtractionParseFailureLog(input) {
|
|
|
77
98
|
].join(" ");
|
|
78
99
|
}
|
|
79
100
|
var LocalLlmRejectedError = class extends Error {
|
|
80
|
-
constructor(httpStatus, finishReason) {
|
|
101
|
+
constructor(httpStatus, finishReason, parameterRefusal, sawTransientAttempt) {
|
|
81
102
|
super(httpStatus === void 0 ? "local LLM answered with unusable content" : `local LLM rejected the input (HTTP ${httpStatus})`);
|
|
82
103
|
this.httpStatus = httpStatus;
|
|
83
104
|
this.finishReason = finishReason;
|
|
105
|
+
this.parameterRefusal = parameterRefusal;
|
|
106
|
+
this.sawTransientAttempt = sawTransientAttempt;
|
|
84
107
|
this.name = "LocalLlmRejectedError";
|
|
85
108
|
}
|
|
86
109
|
httpStatus;
|
|
87
110
|
finishReason;
|
|
111
|
+
parameterRefusal;
|
|
112
|
+
sawTransientAttempt;
|
|
88
113
|
};
|
|
89
114
|
function classifyLocalLlmRejected(err) {
|
|
90
|
-
|
|
115
|
+
if (err.finishReason === "length") return "output_truncated";
|
|
116
|
+
if (err.parameterRefusal) return "auth_config";
|
|
117
|
+
if (err.sawTransientAttempt === true && err.httpStatus !== void 0) return "provider_retryable";
|
|
118
|
+
return err.httpStatus !== void 0 ? "provider_permanent" : "parse_empty";
|
|
91
119
|
}
|
|
92
120
|
function localRejectionStatus(diag) {
|
|
93
121
|
const status = httpStatusFromError(diag.lastError);
|
|
@@ -96,6 +124,8 @@ function localRejectionStatus(diag) {
|
|
|
96
124
|
|
|
97
125
|
export {
|
|
98
126
|
classifyExtractionThrownError,
|
|
127
|
+
downgradePermanentOnTransientAttempt,
|
|
128
|
+
isParameterConfigRejection,
|
|
99
129
|
isRequestTooLargeError,
|
|
100
130
|
directInputTooLargeResult,
|
|
101
131
|
formatDirectInputTooLargeLog,
|
|
@@ -105,4 +135,4 @@ export {
|
|
|
105
135
|
classifyLocalLlmRejected,
|
|
106
136
|
localRejectionStatus
|
|
107
137
|
};
|
|
108
|
-
//# sourceMappingURL=chunk-
|
|
138
|
+
//# sourceMappingURL=chunk-JDZ5JPYG.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/extraction-error-classification.ts"],"sourcesContent":["import type { ExtractionFailureClass, ExtractionResult } from \"./types.js\";\n\n/**\n * Read a numeric HTTP status off a thrown error without re-implementing the\n * shared transient classifier. Uses `in`/typeof narrowing (no inline casts).\n */\nfunction httpStatusFromError(err: unknown): number | undefined {\n if (!err || typeof err !== \"object\") return undefined;\n if (\"status\" in err && typeof err.status === \"number\" && Number.isFinite(err.status)) return err.status;\n if (\"statusCode\" in err && typeof err.statusCode === \"number\" && Number.isFinite(err.statusCode)) {\n return err.statusCode;\n }\n return undefined;\n}\n\n/**\n * Map a thrown extraction error to a coarse failure class for the retry/breaker\n * layer. Never throws.\n *\n * - 401/403 → `auth_config` (misconfigured provider, open the breaker).\n * - transient (429/5xx/network, per the shared `isTransientHttpError`) →\n * `provider_retryable` (back off; a provider that comes back drains the window).\n * - a terminal status that refuses THIS input (400/413/422 — the same droppable\n * set `localRejectionStatus` uses) → `provider_permanent`: a resend of the\n * identical request can never succeed, so the fingerprint dead-letters after\n * `extractionProviderPermanentMaxAttempts` instead of looping the drain forever.\n * EXCEPTION: a 400 that refuses a request PARAMETER (`unsupported parameter:\n * temperature`, `unknown field`, `…not supported with this model`) is the\n * setup's problem — the identical request fails for every future window, so\n * it is `auth_config` (retained), not the chunk's.\n * - any other terminal status (404/405/410/…) → `auth_config`: a missing route or\n * model is the endpoint setup's problem, not the chunk's — innocent windows are\n * never dropped for it.\n * - no status and not transient → `provider_retryable` (unknown failure; fail\n * open toward retry rather than silently dead-lettering a buffered window).\n */\nexport function classifyExtractionThrownError(err: unknown): ExtractionFailureClass {\n try {\n const status = httpStatusFromError(err);\n if (status === 401 || status === 403) return \"auth_config\";\n // A recognized status resolves retryability directly: `isTransientHttpError`\n // cannot read every status property name (e.g. `statusCode`), so deferring to\n // it would mis-bucket terminal local statuses (404/405/410) as retryable.\n if (status !== undefined) {\n if (status === 400 && isParameterConfigRejection(err)) return \"auth_config\";\n if (status === 400 || status === 413 || status === 422) {\n // A permanent-looking refusal alongside a transient sibling attempt is\n // not conclusive proof the window is unextractable — retry under the\n // drain's own bound instead of dead-lettering (#3757).\n return err instanceof Object && \"transientAttemptSeen\" in err && err.transientAttemptSeen === true\n ? \"provider_retryable\"\n : \"provider_permanent\";\n }\n return status === 408 || status === 429 || status >= 500 ? \"provider_retryable\" : \"auth_config\";\n }\n return \"provider_retryable\";\n } catch {\n return \"provider_retryable\";\n }\n}\n\n/**\n * A refusal that classifies `provider_permanent` is inconclusive when a\n * transient attempt was seen elsewhere in the request chain (a timeout/5xx\n * primary before a 400 gateway refusal proves nothing about the window) —\n * downgrade it to `provider_retryable` so the drain's own bound applies\n * instead of the dead-letter cap (#3757).\n */\nexport function downgradePermanentOnTransientAttempt(cls: ExtractionFailureClass, transientAttemptSeen: boolean): ExtractionFailureClass {\n return transientAttemptSeen && cls === \"provider_permanent\" ? \"provider_retryable\" : cls;\n}\n\n/** Provider error codes that name a rejected request parameter rather than the payload. `http_4xx_parameter` is the fallback transport's own token. */\nconst PARAMETER_CONFIG_CODE =\n /^(?:unsupported_parameter|unsupported_value|unknown_parameter|invalid_parameter|parameter_not_supported|http_4xx_parameter)$/i;\n/** Provider message shapes that blame the request shape/setup, not the content. `value` is deliberately not a subject — a content refusal like `unexpected value in messages[0].content` must stay an input refusal, not park the window as a config problem (#3757). */\nconst PARAMETER_CONFIG_MESSAGE =\n /(?:unsupported|unknown|unexpected|unrecognized) (?:parameter|param|field|option)\\b|not supported (?:with|for|by) this model|additional propert(?:y|ies) (?:are )?not allowed/i;\n\n/**\n * True when a provider 400 refuses the request's configuration — an unsupported\n * or unknown parameter/field (`temperature` on a model that forbids it, an\n * extra property the schema rejects) — rather than this input. Reads `code`,\n * `type`, `errorClass`, a nested `error.code`, and the message; never throws.\n * An ambiguous 400 stays an input refusal, so genuinely refused content still\n * dead-letters instead of parking the drain forever.\n */\nexport function isParameterConfigRejection(cause: unknown): boolean {\n try {\n if (!(cause instanceof Object)) return false;\n if (\"code\" in cause && PARAMETER_CONFIG_CODE.test(String(cause.code))) return true;\n if (\"type\" in cause && PARAMETER_CONFIG_CODE.test(String(cause.type))) return true;\n if (\"errorClass\" in cause && PARAMETER_CONFIG_CODE.test(String(cause.errorClass))) return true;\n const nested = \"error\" in cause && cause.error instanceof Object ? cause.error : undefined;\n if (nested && \"code\" in nested && PARAMETER_CONFIG_CODE.test(String(nested.code))) return true;\n const msg = \"message\" in cause ? String(cause.message) : undefined;\n return msg !== undefined && PARAMETER_CONFIG_MESSAGE.test(msg);\n } catch {\n return false;\n }\n}\n\nconst CONTEXT_LIMIT_MESSAGE = /maximum context|context length|context window|request entity/i;\nconst SIZE_LIMIT_PHRASE = /too large|too long|exceed/i;\nconst INPUT_SUBJECT_TERM =\n /\\b(?:input|prompt|request|payload|body|messages?|content|context|size|length|tokens?)\\b/i;\nconst REQUEST_TOO_LARGE_EXCLUDE =\n /\\b(?:max_tokens|max_completion_tokens|temperature|top_p|quota|rate limit|spending|billing)\\b/i;\n\n/**\n * True when a provider refused the request because the input is too big: HTTP\n * 413, or HTTP 400 whose message names a size or context limit (OpenAI-style\n * \"maximum context length\", \"total text input size exceeds 8 MB\"). \"too large\",\n * \"too long\" and \"exceed\" count only beside an input subject and never beside\n * an output, quota or sampling term (`max_tokens exceeds limit`,\n * `temperature is too large`, `quota exceeded` are different failures).\n * Resending the same atomic request can never succeed (#3531). Never throws.\n */\n\n/** An Error or SDK error object; the HTTP status is sniffed off it when present. */\nexport interface HttpThrowable {\n readonly status?: number;\n readonly message?: string;\n}\n\nexport function isRequestTooLargeError(err: HttpThrowable): boolean {\n try {\n const status = httpStatusFromError(err);\n if (status === 413) return true;\n if (status !== 400 || !(err instanceof Error)) return false;\n const message = err.message;\n if (CONTEXT_LIMIT_MESSAGE.test(message)) return true;\n if (REQUEST_TOO_LARGE_EXCLUDE.test(message)) return false;\n return SIZE_LIMIT_PHRASE.test(message) && INPUT_SUBJECT_TERM.test(message);\n } catch {\n return false;\n }\n}\n\n/**\n * Result when the provider refused the window as too large (#3531). Retryable\n * on purpose: the retained turns are never parked or dropped, and\n * `remnic buffer drain` can still extract them in budget-sized chunks.\n */\nexport function directInputTooLargeResult(): ExtractionResult {\n return {\n facts: [],\n profileUpdates: [],\n entities: [],\n questions: [],\n extractionFailure: \"direct_input_too_large\",\n extractionFailureClass: \"provider_retryable\",\n };\n}\n\nexport function formatDirectInputTooLargeLog(chars: number): string {\n return (\n `extraction: direct client refused a ${chars}-char request as too large; an atomic flush is never ` +\n \"split, so any turns the gateway fallback does not extract stay buffered for `remnic buffer drain`\"\n );\n}\n\n/**\n * Map the gateway fallback's discriminated parse-failure reason to a coarse\n * extraction failure class. \"no models configured\" is an auth/config problem;\n * an HTTP/transport failure backs off; an unparseable-but-present response is a\n * genuine empty-parse.\n */\nexport function classifyFallbackParseFailure(\n reason: \"no_models\" | \"empty\" | \"http_error\" | \"schema_rejection\" | \"timeout\",\n): ExtractionFailureClass {\n switch (reason) {\n case \"no_models\":\n return \"auth_config\";\n case \"http_error\":\n case \"timeout\":\n return \"provider_retryable\";\n case \"empty\":\n case \"schema_rejection\":\n return \"parse_empty\";\n }\n}\n\n/**\n * Operator-visible extraction parse-failure line. Keeps the historical\n * greppable prefix and appends the fields that used to live only at debug.\n */\nexport function formatExtractionParseFailureLog(input: {\n failureReason: string;\n attemptedModel?: string;\n httpStatus?: number;\n errorClass?: string;\n traceId: string;\n}): string {\n const modelUsed =\n typeof input.attemptedModel === \"string\" && input.attemptedModel.length > 0\n ? input.attemptedModel\n : \"unknown\";\n const errorClass =\n typeof input.errorClass === \"string\" && input.errorClass.length > 0\n ? input.errorClass\n : \"none\";\n const httpStatus =\n typeof input.httpStatus === \"number\" && Number.isFinite(input.httpStatus)\n ? String(input.httpStatus)\n : \"none\";\n return [\n \"extraction fallback returned no parsed output\",\n `failureReason=${input.failureReason}`,\n `modelUsed=${modelUsed}`,\n `errorClass=${errorClass}`,\n `httpStatus=${httpStatus}`,\n `traceId=${input.traceId}`,\n ].join(\" \");\n}\n\n/**\n * The local endpoint answered, and what it said rejects this input (unusable content, or a client error that is not\n * auth, timeout or rate limiting): the chunk's problem, not an outage. A `finish_reason=length` reply classifies as\n * `output_truncated` (#3521); every other rejection retries like an empty parse, and a trigger-drain\n * chunk that keeps drawing it is dropped after its recovery copy is saved.\n */\nexport class LocalLlmRejectedError extends Error {\n constructor(readonly httpStatus?: number, readonly finishReason?: string, readonly parameterRefusal?: boolean, readonly sawTransientAttempt?: boolean) {\n super(httpStatus === undefined ? \"local LLM answered with unusable content\" : `local LLM rejected the input (HTTP ${httpStatus})`);\n this.name = \"LocalLlmRejectedError\";\n }\n}\n\n/**\n * Map a local-endpoint rejection to its failure class: a reply cut off at the\n * output ceiling (`finish_reason=length`) is `output_truncated` — retries at\n * the same `maxOutputTokens` can never complete (#3521). Every other unusable\n * or refused reply stays `parse_empty`.\n */\nexport function classifyLocalLlmRejected(err: LocalLlmRejectedError): ExtractionFailureClass {\n if (err.finishReason === \"length\") return \"output_truncated\";\n // A 400 that refuses a request PARAMETER is the endpoint setup's problem, not\n // the chunk's — retain it parked instead of dead-lettering valid turns.\n if (err.parameterRefusal) return \"auth_config\";\n // A status-bearing rejection after a transient sibling attempt is inconclusive:\n // the window is not proven unextractable, so it stays retryable (#3757).\n if (err.sawTransientAttempt === true && err.httpStatus !== undefined) return \"provider_retryable\";\n // A status-bearing rejection refuses THIS input (400/413/422 — `localRejectionStatus`\n // already filtered the droppable set): dead-letter at the permanent cap instead\n // of parking at the parse_empty cap. Only the statusless unusable reply stays parse_empty.\n return err.httpStatus !== undefined ? \"provider_permanent\" : \"parse_empty\";\n}\n\n/** What the local client recorded about a failed call (`failureDiag`). */\nexport interface LocalFailureDiag {\n lastError?: unknown;\n /** The completion's `finish_reason` as the client received it (validated before it is logged). */\n finishReason?: string;\n /** A transient attempt (timeout, network error, 408/429/5xx) was consumed inside the local retry loop before the final failure. */\n sawTransientAttempt?: boolean;\n}\n\n/** The HTTP status when the local endpoint answered and refuses this input (400, 413, 422); else undefined. A wrong model name or route (404, 405, 410), auth, timeout and rate limiting are the setup's problem, not the chunk's. */\nexport function localRejectionStatus(diag: LocalFailureDiag): number | undefined {\n const status = httpStatusFromError(diag.lastError);\n return status !== undefined && [400, 413, 422].includes(status) ? status : undefined;\n}\n"],"mappings":";AAMA,SAAS,oBAAoB,KAAkC;AAC7D,MAAI,CAAC,OAAO,OAAO,QAAQ,SAAU,QAAO;AAC5C,MAAI,YAAY,OAAO,OAAO,IAAI,WAAW,YAAY,OAAO,SAAS,IAAI,MAAM,EAAG,QAAO,IAAI;AACjG,MAAI,gBAAgB,OAAO,OAAO,IAAI,eAAe,YAAY,OAAO,SAAS,IAAI,UAAU,GAAG;AAChG,WAAO,IAAI;AAAA,EACb;AACA,SAAO;AACT;AAuBO,SAAS,8BAA8B,KAAsC;AAClF,MAAI;AACF,UAAM,SAAS,oBAAoB,GAAG;AACtC,QAAI,WAAW,OAAO,WAAW,IAAK,QAAO;AAI7C,QAAI,WAAW,QAAW;AACxB,UAAI,WAAW,OAAO,2BAA2B,GAAG,EAAG,QAAO;AAC9D,UAAI,WAAW,OAAO,WAAW,OAAO,WAAW,KAAK;AAItD,eAAO,eAAe,UAAU,0BAA0B,OAAO,IAAI,yBAAyB,OAC1F,uBACA;AAAA,MACN;AACA,aAAO,WAAW,OAAO,WAAW,OAAO,UAAU,MAAM,uBAAuB;AAAA,IACpF;AACA,WAAO;AAAA,EACT,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AASO,SAAS,qCAAqC,KAA6B,sBAAuD;AACvI,SAAO,wBAAwB,QAAQ,uBAAuB,uBAAuB;AACvF;AAGA,IAAM,wBACJ;AAEF,IAAM,2BACJ;AAUK,SAAS,2BAA2B,OAAyB;AAClE,MAAI;AACF,QAAI,EAAE,iBAAiB,QAAS,QAAO;AACvC,QAAI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,SAAS;AAC7E;","names":[]}
|
|
@@ -26,7 +26,7 @@ import {
|
|
|
26
26
|
readGatewayWorkspaceDir,
|
|
27
27
|
tryCodexSubscriptionProvider,
|
|
28
28
|
withCodexRuntimeShutdown
|
|
29
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-STQNKDKZ.js";
|
|
30
30
|
import {
|
|
31
31
|
extractJsonCandidates
|
|
32
32
|
} from "./chunk-YBA52OKG.js";
|
|
@@ -113,7 +113,9 @@ var FallbackLlmClient = class {
|
|
|
113
113
|
failureReason: "http_error",
|
|
114
114
|
errorClass: "network"
|
|
115
115
|
};
|
|
116
|
+
let sawTransientAttempt = false;
|
|
116
117
|
const recordFailure = (failure, attemptedModel) => {
|
|
118
|
+
sawTransientAttempt ||= failure.failureReason === "timeout" || failure.errorClass === "network" || failure.errorClass === "http_5xx" || failure.httpStatus === 408 || failure.httpStatus === 429;
|
|
117
119
|
lastFailure = attemptedModel ? { ...failure, attemptedModel } : failure;
|
|
118
120
|
};
|
|
119
121
|
const throwIfCallerAborted = (signal) => {
|
|
@@ -229,7 +231,7 @@ var FallbackLlmClient = class {
|
|
|
229
231
|
};
|
|
230
232
|
const toOutcome = (response) => {
|
|
231
233
|
if (response) return { ok: true, response };
|
|
232
|
-
return { ok: false, failure: lastFailure };
|
|
234
|
+
return { ok: false, failure: sawTransientAttempt ? { ...lastFailure, sawTransientAttempt: true } : lastFailure };
|
|
233
235
|
};
|
|
234
236
|
if (typeof options.timeoutMs === "number") {
|
|
235
237
|
if (options.timeoutMs <= 0) {
|
|
@@ -843,4 +845,4 @@ export {
|
|
|
843
845
|
gatewayTaskChainOptions,
|
|
844
846
|
FallbackLlmClient
|
|
845
847
|
};
|
|
846
|
-
//# sourceMappingURL=chunk-
|
|
848
|
+
//# sourceMappingURL=chunk-KQYGUFMQ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/fallback-llm.ts"],"sourcesContent":["import { log } from \"./logger.js\";\nimport type { AgentPersonaModelConfig, GatewayConfig, ModelProviderConfig, PluginConfig } from \"./types.js\";\nimport { extractJsonCandidates } from \"./json-extract.js\";\nimport {\n buildChatCompletionTemperature,\n buildChatCompletionTokenLimit,\n shouldAssumeOpenAiChatCompletions,\n} from \"./openai-chat-compat.js\";\nimport {\n resolveProviderApiKey,\n getGatewayRuntimeAuthForModel,\n} from \"./resolve-provider-secret.js\";\nimport {\n CODEX_SUBSCRIPTION_PROVIDER_ID,\n codexSubscriptionBuiltinProviderConfig,\n} from \"./providers/codex-subscription.js\";\nimport { loadModelsJsonProviders } from \"./models-json.js\";\nimport {\n abortReason,\n classifyThrownProviderError,\n codexDeadlineHeadroomMs,\n defaultOpenClawWorkspaceDir,\n extractResponsesOutputText,\n fallbackLlmRuntimeContextFromConfig,\n isTerminalCodexSubscriptionError,\n isTimeoutError,\n isUnsupportedJsonSchemaError,\n normalizeRuntimePath,\n raceFallbackLlmDeadline,\n readGatewayWorkspaceDir,\n tryCodexSubscriptionProvider,\n withCodexRuntimeShutdown,\n type FallbackLlmRuntimeContext,\n type StructuredParseFailure,\n type StructuredParseResult,\n} from \"./fallback-llm-codex-subscription.js\";\n\nexport {\n fallbackLlmRuntimeContextFromConfig,\n type FallbackLlmRuntimeContext,\n type StructuredParseFailure,\n type StructuredParseFailureReason,\n type StructuredParseResult,\n} from \"./fallback-llm-codex-subscription.js\";\n\nexport interface FallbackLlmOptions {\n temperature?: number;\n maxTokens?: number;\n reasoningHeadroomTokens?: number; // Responses API only: extra max_output_tokens for reasoning (they count against it); unset adds none\n timeoutMs?: number;\n signal?: AbortSignal;\n /** Set the Responses API storage policy. Other transports ignore this value. */\n store?: boolean;\n /** Request strict JSON output when a route uses the Responses API. */\n responsesJsonSchema?: { name: string; schema: Record<string, unknown> };\n /** Request provider-native structured output on supported JSON transports. */\n jsonSchema?: { name: string; schema: Record<string, unknown>; strict?: boolean };\n /** Hide provider error details that could echo private request content. */\n redactProviderErrors?: boolean;\n /** Explicit \"provider/model\" override to try before the configured chain. */\n model?: string;\n /** Explicit model chain override to use instead of the configured agent/default chain. */\n modelChain?: AgentPersonaModelConfig;\n /** Append the gateway default chain after an explicit model chain. */\n includeDefaultModelFallback?: boolean;\n /** Override which agent persona's model chain to use (by ID from agents.list[]). */\n agentId?: string;\n /** Reject a transport-successful response and continue through the configured model chain. */\n acceptResponse?: (response: FallbackLlmResponse) => boolean;\n /**\n * Optional out-box for the terminal failure cause (issue #2891): when every\n * model in the chain fails, the last thrown provider error is recorded here\n * so callers can classify it (e.g. HTTP 429 → rate-limited) in memory\n * instead of seeing only null. Never logged.\n */\n failureDiag?: { lastError?: unknown };\n}\n\nexport interface FallbackLlmAvailabilityOptions {\n agentId?: string;\n modelChain?: AgentPersonaModelConfig;\n}\n\n/**\n * Resolve the gateway routing options Remnic's background tasks should pass to\n * FallbackLlmClient — extraction, fact/profile/identity consolidation,\n * summarization, calibration, and causal/semantic consolidation. Single source\n * of truth so every task path stays consistent and can't diverge (gotcha #22):\n * in gateway mode an explicit `taskModelChain` wins over the gateway agent\n * persona; otherwise the persona (if any) is used. Returns `{}` in plugin mode\n * because the chain resolves through gateway providers only. Issue #1365.\n */\nexport function gatewayTaskChainOptions(\n config: Pick<PluginConfig, \"modelSource\" | \"taskModelChain\" | \"gatewayAgentId\">,\n): Pick<FallbackLlmOptions, \"modelChain\" | \"agentId\"> {\n if (config.modelSource !== \"gateway\") return {};\n if (config.taskModelChain) return { modelChain: config.taskModelChain };\n return config.gatewayAgentId ? { agentId: config.gatewayAgentId } : {};\n}\n\nexport interface FallbackLlmResponse {\n content: string;\n modelUsed: string;\n usage?: {\n inputTokens?: number;\n outputTokens?: number;\n totalTokens?: number;\n };\n}\n\ntype ChatCompletionOutcome =\n | { ok: true; response: FallbackLlmResponse }\n | { ok: false; failure: Omit<StructuredParseFailure, \"result\"> };\n\ninterface ModelRef {\n providerId: string;\n modelId: string;\n providerConfig: ModelProviderConfig;\n modelString: string;\n}\n\nconst PROVIDER_ALIASES: Record<string, readonly string[]> = {\n \"openai-codex\": [\"codex\"],\n codex: [\"openai-codex\"],\n \"claude-cli\": [\"anthropic\"],\n};\n\nconst LEGACY_PROVIDER_IDS = new Set([\"openai-codex\", \"claude-cli\"]);\n\nconst MANAGED_SECRETREF_MARKER = [\"secretref\", \"managed\"].join(\"-\");\nconst PROVIDER_API_KEY_FIELD = [\"api\", \"Key\"].join(\"\") as keyof ModelProviderConfig;\n\n/** Built-in OAuth/managed-auth providers so resolveProviderConfig reaches runtime auth. */\nconst BUILT_IN_PROVIDER_FALLBACKS: Record<string, ModelProviderConfig> = {\n anthropic: {\n baseUrl: \"https://api.anthropic.com/v1\",\n api: \"anthropic-messages\",\n models: [],\n [PROVIDER_API_KEY_FIELD]: MANAGED_SECRETREF_MARKER,\n },\n openai: {\n baseUrl: \"https://api.openai.com/v1\",\n api: \"openai-responses\",\n models: [],\n [PROVIDER_API_KEY_FIELD]: MANAGED_SECRETREF_MARKER,\n },\n // Subscription-OAuth extraction provider (issue #2784): no apiKey — the\n // codex CLI login authenticates, via the runner the codex-subscription\n // module registers on this same seam.\n [CODEX_SUBSCRIPTION_PROVIDER_ID]: codexSubscriptionBuiltinProviderConfig(),\n};\n\n/**\n * Gateway/task LLM client. In `modelSource: \"gateway\"` this is the primary\n * configured path (taskModelChain / agent persona), not a secondary recovery\n * client. The class name stays `FallbackLlmClient` because it is imported\n * widely; prefer the `TaskLlmClient` alias in new code. Issue #2967.\n */\nexport class FallbackLlmClient {\n private gatewayConfig: GatewayConfig | undefined;\n private runtimeContext: FallbackLlmRuntimeContext;\n\n constructor(\n gatewayConfig?: GatewayConfig,\n runtimeContext: FallbackLlmRuntimeContext = {},\n ) {\n this.gatewayConfig = gatewayConfig;\n this.runtimeContext = {\n ...runtimeContext,\n workspaceDir:\n normalizeRuntimePath(runtimeContext.workspaceDir) ??\n readGatewayWorkspaceDir(gatewayConfig) ??\n defaultOpenClawWorkspaceDir(),\n };\n }\n\n /**\n * Check if fallback is available (gateway config has at least one model).\n */\n isAvailable(agentIdOrOptions?: string | FallbackLlmAvailabilityOptions): boolean {\n const options = typeof agentIdOrOptions === \"string\"\n ? { agentId: agentIdOrOptions }\n : (agentIdOrOptions ?? {});\n const models = this.getModelChain(options.agentId, undefined, options.modelChain);\n return models.length > 0;\n }\n\n /**\n * Make a chat completion request using the gateway's default AI chain.\n * Tries primary first, then each fallback in order.\n * When agentId is provided, uses that agent persona's model chain instead of defaults.\n */\n async chatCompletion(\n messages: Array<{ role: \"system\" | \"user\" | \"assistant\"; content: string }>,\n options: FallbackLlmOptions = {},\n ): Promise<FallbackLlmResponse | null> {\n const outcome = await this.completeChat(messages, options);\n return outcome.ok ? outcome.response : null;\n }\n\n /**\n * Same transport walk as chatCompletion, but tagged so structured parse can\n * tell timeout / empty / HTTP error apart instead of collapsing them to null.\n */\n private async completeChat(\n messages: Array<{ role: \"system\" | \"user\" | \"assistant\"; content: string }>,\n options: FallbackLlmOptions = {},\n ): Promise<ChatCompletionOutcome> {\n const models = this.getModelChain(\n options.agentId,\n options.model,\n options.modelChain,\n options.includeDefaultModelFallback,\n );\n if (models.length === 0) {\n log.warn(\"task LLM: no models configured in gateway\");\n return { ok: false, failure: { failureReason: \"no_models\", errorClass: \"no_models\" } };\n }\n options = withCodexRuntimeShutdown(options, this.runtimeContext.codexSubscriptionRunner);\n\n let lastFailure: Omit<StructuredParseFailure, \"result\"> = {\n failureReason: \"http_error\",\n errorClass: \"network\",\n };\n\n let sawTransientAttempt = false;\n const recordFailure = (\n failure: Omit<StructuredParseFailure, \"result\">,\n attemptedModel?: string,\n ): void => {\n // A transient sibling attempt (5xx/408/429/timeout/network) means the surviving\n // last failure — even a permanent-looking refusal — is inconclusive (#3757).\n sawTransientAttempt ||= failure.failureReason === \"timeout\" || failure.errorClass === \"network\" ||\n failure.errorClass === \"http_5xx\" || failure.httpStatus === 408 || failure.httpStatus === 429;\n lastFailure = attemptedModel ? { ...failure, attemptedModel } : failure;\n };\n\n const throwIfCallerAborted = (signal: AbortSignal | undefined): void => {\n if (!signal?.aborted) return;\n const reason = abortReason(signal);\n if (isTimeoutError(reason) && !options.signal?.aborted) {\n recordFailure({ failureReason: \"timeout\", errorClass: \"timeout\" });\n return;\n }\n throw reason;\n };\n\n const runChain = async (\n initialOptions: FallbackLlmOptions,\n ): Promise<FallbackLlmResponse | null> => {\n let runOptions = initialOptions;\n let lastRejectedResponse: FallbackLlmResponse | null = null;\n let lastError: unknown;\n let terminalError: unknown;\n // Try each model in the chain\n for (let i = 0; i < models.length; i++) {\n if (runOptions.signal?.aborted) {\n throwIfCallerAborted(runOptions.signal);\n if (lastFailure.failureReason === \"timeout\") return null;\n }\n const model = models[i];\n const isFallback = i > 0;\n\n try {\n const result = await this.tryModel(model, messages, runOptions);\n if (result?.content) {\n const response = {\n content: result.content,\n modelUsed: model.modelString,\n usage: result.usage,\n };\n if (runOptions.acceptResponse && !runOptions.acceptResponse(response)) {\n lastRejectedResponse = response;\n log.debug(`task LLM: ${model.modelString} returned rejected output, trying next...`);\n continue;\n }\n if (isFallback) {\n log.debug(`task LLM: succeeded using ${model.modelString} (fallback ${i})`);\n }\n return response;\n }\n recordFailure({ failureReason: \"empty\", errorClass: \"empty\" }, model.modelString);\n } catch (err) {\n if (isTerminalCodexSubscriptionError(err) && runOptions.signal?.aborted) {\n throw err;\n }\n if (runOptions.signal?.aborted) {\n throwIfCallerAborted(runOptions.signal);\n if (lastFailure.failureReason === \"timeout\") return null;\n }\n lastError = err;\n if (\n (runOptions.jsonSchema || runOptions.responsesJsonSchema) &&\n isUnsupportedJsonSchemaError(err)\n ) {\n log.debug(`task LLM: ${model.modelString} rejected native JSON schema; retrying without it`);\n // Degrade to prompt-only for the REST of the chain too, so an\n // N-model chain where every provider rejects structured output\n // costs N+1 requests instead of 2N.\n runOptions = {\n ...runOptions,\n jsonSchema: undefined,\n responsesJsonSchema: undefined,\n };\n try {\n const result = await this.tryModel(model, messages, runOptions);\n if (result?.content) {\n const response = {\n content: result.content,\n modelUsed: model.modelString,\n usage: result.usage,\n };\n if (!runOptions.acceptResponse || runOptions.acceptResponse(response)) {\n return response;\n }\n lastRejectedResponse = response;\n log.debug(`task LLM: ${model.modelString} unstructured retry output rejected by acceptResponse, trying next model...`);\n continue;\n }\n recordFailure({ failureReason: \"empty\", errorClass: \"empty\" }, model.modelString);\n } catch (retryError) {\n if (isTerminalCodexSubscriptionError(retryError) && runOptions.signal?.aborted) {\n throw retryError;\n }\n if (runOptions.signal?.aborted) {\n throwIfCallerAborted(runOptions.signal);\n if (lastFailure.failureReason === \"timeout\") return null;\n }\n lastError = retryError;\n const retryClassified = classifyThrownProviderError(retryError);\n recordFailure(retryClassified, model.modelString);\n const retryErrorMsg = runOptions.redactProviderErrors\n ? \"provider error details redacted\"\n : retryError instanceof Error\n ? retryError.message\n : String(retryError);\n log.debug(\n `task LLM: ${model.modelString} unstructured retry failed (${retryErrorMsg})`,\n );\n if (isTerminalCodexSubscriptionError(retryError)) {\n terminalError = retryError;\n }\n }\n continue;\n }\n const classified = classifyThrownProviderError(err);\n recordFailure(classified, model.modelString);\n const errorMsg = runOptions.redactProviderErrors\n ? \"provider error details redacted\"\n : err instanceof Error\n ? err.message\n : String(err);\n log.debug(`task LLM: ${model.modelString} failed (${errorMsg}), trying next...`);\n if (isTerminalCodexSubscriptionError(err)) {\n terminalError = err;\n }\n // Continue to next model in chain\n }\n }\n\n log.warn(`task LLM: all ${models.length} models in chain failed`);\n if (options.failureDiag && lastError !== undefined && !lastRejectedResponse) {\n options.failureDiag.lastError = lastError;\n }\n // A terminal typed provider failure must reach the caller when the\n // chain is exhausted — the documented timeout/re-login guidance\n // depends on it (issue #2833).\n if (terminalError !== undefined) {\n throw terminalError;\n }\n return lastRejectedResponse;\n };\n\n const toOutcome = (response: FallbackLlmResponse | null): ChatCompletionOutcome => {\n if (response) return { ok: true, response };\n return { ok: false, failure: sawTransientAttempt ? { ...lastFailure, sawTransientAttempt: true } : lastFailure };\n };\n\n if (typeof options.timeoutMs === \"number\") {\n if (options.timeoutMs <= 0) {\n log.warn(\"task LLM: timed out before request started\");\n return { ok: false, failure: { failureReason: \"timeout\", errorClass: \"timeout\" } };\n }\n const controller = new AbortController();\n const onCallerAbort = (): void => {\n controller.abort(abortReason(options.signal));\n };\n options.signal?.addEventListener(\"abort\", onCallerAbort, { once: true });\n if (options.signal?.aborted) onCallerAbort();\n const timedOptions = { ...options, signal: controller.signal };\n const chain = runChain(timedOptions);\n const guarded = chain.catch((err) => {\n if (isTerminalCodexSubscriptionError(err)) throw err;\n return null;\n });\n try {\n const timeoutError = Object.assign(\n new Error(`task LLM timed out after ${options.timeoutMs}ms`),\n { name: \"TimeoutError\" },\n );\n const outcome = await raceFallbackLlmDeadline(\n guarded,\n options.timeoutMs,\n () => {\n log.warn(`task LLM: timed out after ${options.timeoutMs}ms`);\n recordFailure({ failureReason: \"timeout\", errorClass: \"timeout\" });\n controller.abort(timeoutError);\n if (options.failureDiag) options.failureDiag.lastError = timeoutError;\n },\n models.some((m) => m.providerConfig.api === \"codex-cli\") ? codexDeadlineHeadroomMs(options.timeoutMs) : 0,\n );\n if (outcome.timedOut) {\n return { ok: false, failure: { failureReason: \"timeout\", errorClass: \"timeout\" } };\n }\n return toOutcome(outcome.value);\n } finally {\n options.signal?.removeEventListener(\"abort\", onCallerAbort);\n }\n }\n\n return toOutcome(await runChain(options));\n }\n\n /**\n * Make a request with structured output (Zod schema).\n * Returns parsed JSON or null on failure.\n */\n async parseWithSchema<T>(\n messages: Array<{ role: \"system\" | \"user\" | \"assistant\"; content: string }>,\n schema: { parse: (data: unknown) => T },\n options: FallbackLlmOptions = {},\n ): Promise<T | null> {\n const detailed = await this.parseWithSchemaDetailed(messages, schema, options);\n return detailed?.result ?? null;\n }\n\n /**\n * Like parseWithSchema but also returns the model that was used,\n * so callers can emit accurate trace events.\n */\n async parseWithSchemaDetailed<T>(\n messages: Array<{ role: \"system\" | \"user\" | \"assistant\"; content: string }>,\n schema: { parse: (data: unknown) => T },\n options: FallbackLlmOptions = {},\n ): Promise<StructuredParseResult<T>> {\n let outcome: ChatCompletionOutcome;\n try {\n outcome = await this.completeChat(messages, options);\n } catch (err) {\n // Caller aborts and terminal codex-subscription failures propagate (the\n // TimeoutError/auth guidance is their documented contract) — swallowing\n // them as provider failures would lose abort-driven cancellation.\n if (options.signal?.aborted || isTerminalCodexSubscriptionError(err)) throw err;\n if (isTimeoutError(err)) {\n return { result: null, failureReason: \"timeout\", errorClass: \"timeout\" };\n }\n log.warn(\"task LLM: chatCompletion threw during structured parse:\", err);\n return { result: null, ...classifyThrownProviderError(err) };\n }\n if (!outcome.ok) {\n return { result: null, ...outcome.failure };\n }\n const response = outcome.response;\n if (!response.content) {\n return {\n result: null,\n failureReason: \"empty\",\n attemptedModel: response.modelUsed,\n errorClass: \"empty\",\n };\n }\n\n try {\n const candidates = extractJsonCandidates(response.content);\n let sawJson = false;\n let sawSchemaReject = false;\n for (const c of candidates) {\n let parsed: unknown;\n try {\n parsed = JSON.parse(c);\n sawJson = true;\n } catch {\n continue;\n }\n try {\n return { result: schema.parse(parsed), modelUsed: response.modelUsed };\n } catch {\n sawSchemaReject = true;\n }\n }\n if (sawSchemaReject) {\n return {\n result: null,\n failureReason: \"schema_rejection\",\n attemptedModel: response.modelUsed,\n errorClass: \"schema_rejection\",\n };\n }\n return {\n result: null,\n failureReason: \"empty\",\n attemptedModel: response.modelUsed,\n errorClass: \"empty\",\n };\n } catch (err) {\n log.warn(\"task LLM: failed to parse structured output:\", err);\n return {\n result: null,\n failureReason: \"empty\",\n attemptedModel: response.modelUsed,\n errorClass: \"empty\",\n };\n }\n }\n\n /**\n * Get the full model chain from gateway config.\n * Returns array of models in order: [primary, fallback1, fallback2, ...]\n *\n * When modelChainOverride is provided, uses it instead of any configured\n * agent/default chain. Otherwise, when agentId is provided, looks up the\n * matching entry in agents.list[] and uses that persona's model chain.\n * Falls back to agents.defaults.model if agentId is not found or not provided.\n */\n private getModelChain(\n agentId?: string,\n modelOverride?: string,\n modelChainOverride?: AgentPersonaModelConfig,\n includeDefaultModelFallback = true,\n ): ModelRef[] {\n const chain: ModelRef[] = [];\n const providers = this.gatewayConfig?.models?.providers ?? {};\n\n // Resolve the model config: explicit task chain, agent persona chain, or global defaults\n let modelConfig: AgentPersonaModelConfig | undefined;\n\n if (modelChainOverride?.primary) {\n modelConfig = modelChainOverride;\n log.debug(\"task LLM: using explicit model chain override\");\n } else if (modelChainOverride) {\n log.warn(\"task LLM: ignoring explicit model chain override without primary model\");\n }\n\n if (!modelConfig && agentId) {\n const persona = this.gatewayConfig?.agents?.list?.find(\n (a) => a.id === agentId,\n );\n if (persona?.model) {\n modelConfig = persona.model;\n log.debug(`task LLM: using agent persona \"${agentId}\" model chain`);\n } else {\n log.warn(\n `task LLM: agent persona \"${agentId}\" not found or has no model config, falling back to defaults`,\n );\n }\n }\n\n if (!modelConfig) {\n modelConfig = this.gatewayConfig?.agents?.defaults?.model;\n }\n\n // Build list of model strings: primary + fallbacks\n const modelStrings: string[] = [];\n\n const addModelString = (value: unknown): void => {\n if (typeof value !== \"string\") return;\n const trimmed = value.trim();\n if (trimmed.length > 0 && !modelStrings.includes(trimmed)) {\n modelStrings.push(trimmed);\n }\n };\n\n addModelString(modelOverride);\n addModelString(modelConfig?.primary);\n\n if (Array.isArray(modelConfig?.fallbacks)) {\n for (const fb of modelConfig.fallbacks) {\n addModelString(fb);\n }\n }\n\n // Parse each model string and look up provider config\n for (const modelString of modelStrings) {\n const modelRef = this.parseModelString(modelString, providers);\n if (modelRef) {\n chain.push(modelRef);\n }\n }\n\n // Implicit last-resort: when a task-specific modelChain override is active,\n // append the gateway default model so a stale or exhausted taskModelChain\n // never interrupts a chat on a flush failure. Keyed on `modelChainOverride?.primary`\n // (the same activation condition used above) so a primary-less override falling\n // through to a persona/default chain does NOT get the default appended (gotcha #39). Issue #1365 / PR #1370.\n if (includeDefaultModelFallback && modelChainOverride?.primary && modelStrings.length > 0) {\n // Append the FULL gateway default chain (primary + fallbacks), not just\n // the primary — if the default primary is also unreachable, a listed\n // default fallback may still succeed (cursor review #1425).\n const defaults = this.gatewayConfig?.agents?.defaults?.model;\n const defaultStrings: string[] = [\n ...(typeof defaults?.primary === \"string\" ? [defaults.primary] : []),\n ...(Array.isArray(defaults?.fallbacks) ? defaults.fallbacks : []),\n ];\n for (const candidate of defaultStrings) {\n if (typeof candidate !== \"string\") continue;\n const trimmed = candidate.trim();\n if (trimmed.length === 0 || modelStrings.includes(trimmed)) continue;\n const defaultRef = this.parseModelString(trimmed, providers);\n if (defaultRef) {\n chain.push(defaultRef);\n modelStrings.push(trimmed); // keep dedupe correct for later default fallbacks\n log.debug(\n `task LLM: appended gateway default model \"${trimmed}\" as implicit last resort`,\n );\n }\n }\n }\n\n return chain;\n }\n\n /**\n * Parse a \"provider/model\" string and look up its config.\n */\n private parseModelString(\n modelString: string,\n providers: Record<string, ModelProviderConfig>,\n ): ModelRef | null {\n // Parse \"provider/model\" format (e.g., \"openai/gpt-5.5\", \"anthropic/claude-opus-4-6\")\n const parts = modelString.split(\"/\");\n if (parts.length < 2) {\n log.warn(`task LLM: invalid model format: ${modelString}`);\n return null;\n }\n\n const requestedProviderId = parts[0];\n const modelId = parts.slice(1).join(\"/\"); // Handle cases like \"openai/gpt-5.5\"\n\n // Respect the active gateway config first so profile-local overrides and\n // credentials win; materialized models.json only when the provider is\n // absent from the loaded config (runtime-registered built-ins).\n const resolvedProvider = this.resolveProviderConfig(requestedProviderId, providers);\n const providerConfig = resolvedProvider?.config;\n if (!providerConfig) {\n log.warn(\n `task LLM: provider not found: ${requestedProviderId} ` +\n `(tried: ${this.providerResolutionCandidates(requestedProviderId).join(\", \")})`,\n );\n return null;\n }\n\n return {\n providerId: resolvedProvider.providerId,\n modelId,\n providerConfig,\n modelString,\n };\n }\n\n private resolveProviderConfig(\n providerId: string,\n providers: Record<string, ModelProviderConfig>,\n ): { providerId: string; config: ModelProviderConfig } | null {\n const candidates = this.providerResolutionCandidates(providerId);\n const aliasCandidates = candidates.filter((candidate) => candidate !== providerId);\n const fallbackCandidates = LEGACY_PROVIDER_IDS.has(providerId)\n ? [...aliasCandidates, providerId]\n : [providerId, ...aliasCandidates];\n for (const candidate of candidates) {\n const config = providers[candidate];\n if (config) {\n if (candidate !== providerId) {\n log.debug(`task LLM: provider \"${providerId}\" resolved via alias \"${candidate}\"`);\n }\n return { providerId: candidate, config };\n }\n }\n for (const candidate of fallbackCandidates) {\n const config = this.resolveFromModelsJson(candidate);\n if (config) {\n if (candidate !== providerId) {\n log.debug(`task LLM: provider \"${providerId}\" resolved via models.json alias \"${candidate}\"`);\n }\n return { providerId: candidate, config };\n }\n const builtInConfig = BUILT_IN_PROVIDER_FALLBACKS[candidate];\n if (builtInConfig) {\n if (candidate === providerId) {\n log.debug(`task LLM: provider \"${providerId}\" resolved from built-in defaults`);\n return { providerId, config: builtInConfig };\n }\n log.debug(`task LLM: provider \"${providerId}\" resolved via built-in alias \"${candidate}\"`);\n return { providerId: candidate, config: builtInConfig };\n }\n }\n return null;\n }\n\n private providerResolutionCandidates(providerId: string): string[] {\n const candidates = [providerId, ...(PROVIDER_ALIASES[providerId] ?? [])];\n return [...new Set(candidates)];\n }\n\n /**\n * Look up a provider from the gateway's materialized models.json, which\n * contains all providers including built-in ones (openai-codex, google-vertex,\n * etc.) that aren't in the user's openclaw.json but are registered by\n * gateway plugins. Returns null if the provider isn't found there either.\n */\n private resolveFromModelsJson(providerId: string): ModelProviderConfig | null {\n const allProviders = loadModelsJsonProviders();\n const config = allProviders[providerId];\n if (config) {\n log.debug(`task LLM: resolved provider \"${providerId}\" from models.json (api: ${config.api ?? \"default\"})`);\n return config;\n }\n return null;\n }\n\n /**\n * Try to call a single model.\n *\n * Uses the gateway's native getRuntimeAuthForModel when available — this\n * handles all provider-specific auth transforms (OAuth token exchange,\n * base URL overrides for codex/copilot/etc.) through the same codepath\n * the gateway itself uses. Falls back to resolveProviderApiKey for\n * simpler providers or when the runtime module isn't loaded.\n */\n private async tryModel(\n model: ModelRef,\n messages: Array<{ role: \"system\" | \"user\" | \"assistant\"; content: string }>,\n options: FallbackLlmOptions,\n ): Promise<{ content: string; usage?: FallbackLlmResponse[\"usage\"] } | null> {\n const codexResult = await tryCodexSubscriptionProvider(\n model,\n messages,\n options,\n () => this.resolveFallbackApiKey(model),\n this.runtimeContext.codexSubscriptionRunner,\n );\n if (codexResult !== undefined) return codexResult;\n const runtimeAuth = await this.resolveRuntimeAuth(model);\n const effectiveBaseUrl = runtimeAuth?.baseUrl ?? model.providerConfig.baseUrl;\n const resolvedApiKey = runtimeAuth?.apiKey ?? await this.resolveFallbackApiKey(model);\n\n // If the raw key looks like an unresolved secret ref and resolution fails,\n // skip this provider entirely so the chain falls through to the next.\n const rawKey = model.providerConfig.apiKey;\n const needsResolution = rawKey === \"secretref-managed\" || (typeof rawKey === \"object\" && rawKey !== null);\n if (needsResolution && !resolvedApiKey) {\n throw new Error(`API key for provider \"${model.providerId}\" could not be resolved from secret ref`);\n }\n\n const effectiveConfig: ModelProviderConfig = {\n ...model.providerConfig,\n baseUrl: effectiveBaseUrl,\n ...(resolvedApiKey ? { apiKey: resolvedApiKey } : {}),\n };\n\n if (model.providerConfig.api === \"anthropic-messages\") {\n return await this.callAnthropic(effectiveConfig, model.modelId, messages, options);\n }\n\n if (model.providerConfig.api === \"ollama-chat\") {\n return await this.callOllamaChat(effectiveConfig, model.modelId, messages, options);\n }\n\n const wanted = Math.floor(options.reasoningHeadroomTokens ?? 0);\n const headroom = Number.isFinite(wanted) ? Math.max(0, wanted) : 0; // NaN and Infinity add nothing\n const capped = options.maxTokens === undefined ? options : { ...options, maxTokens: options.maxTokens + headroom };\n\n if (\n model.providerConfig.api === \"openai-responses\" ||\n model.providerConfig.api === \"openai-codex-responses\" ||\n model.providerConfig.api === \"azure-openai-responses\"\n ) {\n return await this.callOpenAIResponses(effectiveConfig, model.modelId, messages, capped);\n }\n\n // For OpenAI-compatible chat-completions APIs (openai-completions, ollama,\n // etc.) and unknown formats, use chat completions — the gateway's runtime\n // auth resolver returns request-ready base URL and credentials for most providers.\n return await this.callOpenAI(\n effectiveConfig,\n model.modelId,\n messages,\n capped,\n shouldAssumeOpenAiChatCompletions(effectiveConfig.baseUrl),\n );\n }\n\n /**\n * Resolve request-ready auth through the gateway's native runtime, which\n * handles provider-specific transforms (OAuth token exchange for codex/copilot,\n * base URL rewrite, etc.). Returns null if the runtime isn't available.\n */\n private async resolveRuntimeAuth(\n model: ModelRef,\n ): Promise<{ apiKey?: string; baseUrl?: string } | null> {\n try {\n const getRuntimeAuth = await getGatewayRuntimeAuthForModel({\n getRuntimeAuthForModel: this.runtimeContext.getRuntimeAuthForModel,\n });\n if (!getRuntimeAuth) return null;\n\n const result = await getRuntimeAuth({\n model: {\n provider: model.providerId,\n id: model.modelId,\n api: model.providerConfig.api,\n baseUrl: model.providerConfig.baseUrl,\n },\n cfg: this.gatewayConfig,\n workspaceDir: this.runtimeContext.workspaceDir,\n });\n\n if (result?.apiKey || result?.baseUrl) {\n log.debug(\n `task LLM: resolved runtime auth for \"${model.modelString}\" (source: ${result.source ?? \"unknown\"}, mode: ${result.mode ?? \"unknown\"})`,\n );\n return { apiKey: result.apiKey, baseUrl: result.baseUrl };\n }\n } catch (err) {\n log.debug(\n `task LLM: gateway runtime auth failed for \"${model.modelString}\": ${err instanceof Error ? err.message : String(err)}`,\n );\n }\n return null;\n }\n\n /**\n * Resolve API key through the existing provider-level resolution (env vars,\n * secret refs, etc.). Used as fallback when gateway runtime auth isn't available.\n */\n private async resolveFallbackApiKey(model: ModelRef): Promise<string | undefined> {\n return resolveProviderApiKey(\n model.providerId,\n model.providerConfig.apiKey,\n this.gatewayConfig,\n this.runtimeContext.agentDir,\n {\n resolveApiKeyForProvider: this.runtimeContext.resolveApiKeyForProvider,\n },\n );\n }\n\n /**\n * Call OpenAI-compatible API.\n */\n private async callOpenAI(\n config: ModelProviderConfig,\n modelId: string,\n messages: Array<{ role: \"system\" | \"user\" | \"assistant\"; content: string }>,\n options: FallbackLlmOptions,\n assumeOpenAI: boolean,\n ): Promise<{ content: string; usage?: FallbackLlmResponse[\"usage\"] } | null> {\n const base = config.baseUrl.replace(/\\/$/, \"\");\n const url = base.endsWith(\"/v1\")\n ? `${base}/chat/completions`\n : `${base}/v1/chat/completions`;\n\n const headers: Record<string, string> = {\n \"Content-Type\": \"application/json\",\n ...config.headers,\n };\n\n // Handle auth — apiKey is already resolved to a string by tryModel()\n if (config.apiKey && typeof config.apiKey === \"string\") {\n if (config.authHeader !== false) {\n headers[\"Authorization\"] = `Bearer ${config.apiKey}`;\n }\n }\n\n const body = {\n model: modelId,\n messages,\n ...buildChatCompletionTemperature(modelId, options.temperature ?? 0.3, {\n assumeOpenAI,\n }),\n ...buildChatCompletionTokenLimit(modelId, options.maxTokens ?? 4096, {\n assumeOpenAI,\n }),\n ...(options.jsonSchema\n ? {\n response_format: {\n type: \"json_schema\",\n json_schema: {\n name: options.jsonSchema.name,\n strict: options.jsonSchema.strict ?? false,\n schema: options.jsonSchema.schema,\n },\n },\n }\n : {}),\n };\n\n const response = await fetch(url, {\n method: \"POST\",\n headers,\n signal: options.signal,\n body: JSON.stringify(body),\n });\n\n if (!response.ok) {\n const error = await response.text();\n throw Object.assign(new Error(`OpenAI API error: ${response.status} ${error}`), { status: response.status });\n }\n\n const data = (await response.json()) as {\n choices: Array<{\n message: {\n content: string;\n };\n }>;\n usage?: {\n prompt_tokens?: number;\n completion_tokens?: number;\n total_tokens?: number;\n };\n };\n\n const content = data.choices?.[0]?.message?.content;\n if (!content) {\n throw new Error(\"Empty response from OpenAI API\");\n }\n\n return {\n content,\n usage: data.usage\n ? {\n inputTokens: data.usage.prompt_tokens,\n outputTokens: data.usage.completion_tokens,\n totalTokens: data.usage.total_tokens,\n }\n : undefined,\n };\n }\n\n /**\n * Call Ollama's native /api/chat transport. This lets benchmark-isolated\n * gateway configs route Remnic's own internal LLM calls to Ollama Cloud\n * without requiring an OpenAI-compatible shim.\n */\n private async callOllamaChat(\n config: ModelProviderConfig,\n modelId: string,\n messages: Array<{ role: \"system\" | \"user\" | \"assistant\"; content: string }>,\n options: FallbackLlmOptions,\n ): Promise<{ content: string; usage?: FallbackLlmResponse[\"usage\"] } | null> {\n const base = config.baseUrl.replace(/\\/$/, \"\");\n const url = base.endsWith(\"/api\") ? `${base}/chat` : `${base}/api/chat`;\n const headers: Record<string, string> = {\n \"Content-Type\": \"application/json\",\n ...config.headers,\n };\n if (config.apiKey && typeof config.apiKey === \"string\" && config.authHeader !== false) {\n headers.Authorization = `Bearer ${config.apiKey}`;\n }\n\n const response = await fetch(url, {\n method: \"POST\",\n headers,\n signal: options.signal,\n body: JSON.stringify({\n model: modelId,\n messages,\n stream: false,\n ...(config.disableThinking ? { think: false } : {}),\n options: {\n temperature: options.temperature ?? 0.3,\n num_predict: options.maxTokens ?? 4096,\n },\n }),\n });\n\n if (!response.ok) {\n const error = await response.text();\n throw Object.assign(new Error(`Ollama API error: ${response.status} ${error}`), { status: response.status });\n }\n\n const data = (await response.json()) as {\n message?: { content?: string };\n response?: string;\n prompt_eval_count?: number;\n eval_count?: number;\n };\n const content = data.message?.content ?? data.response;\n if (!content) {\n throw new Error(\"Empty response from Ollama API\");\n }\n\n const inputTokens = data.prompt_eval_count ?? 0;\n const outputTokens = data.eval_count ?? 0;\n return {\n content,\n usage: {\n inputTokens,\n outputTokens,\n totalTokens: inputTokens + outputTokens,\n },\n };\n }\n\n /**\n * Call an OpenAI-compatible Responses API.\n */\n private async callOpenAIResponses(\n config: ModelProviderConfig,\n modelId: string,\n messages: Array<{ role: \"system\" | \"user\" | \"assistant\"; content: string }>,\n options: FallbackLlmOptions,\n ): Promise<{ content: string; usage?: FallbackLlmResponse[\"usage\"] } | null> {\n const base = config.baseUrl.replace(/\\/$/, \"\");\n const url = base.endsWith(\"/v1\")\n ? `${base}/responses`\n : `${base}/v1/responses`;\n\n const headers: Record<string, string> = {\n \"Content-Type\": \"application/json\",\n ...config.headers,\n };\n\n if (config.apiKey && typeof config.apiKey === \"string\" && config.authHeader !== false) {\n headers[\"Authorization\"] = `Bearer ${config.apiKey}`;\n }\n\n const instructions = messages\n .filter((message) => message.role === \"system\")\n .map((message) => message.content)\n .join(\"\\n\\n\")\n .trim();\n const input = messages\n .filter((message) => message.role !== \"system\")\n .map((message) => ({\n role: message.role,\n content: [{\n type: message.role === \"assistant\" ? \"output_text\" : \"input_text\",\n text: message.content,\n }],\n }));\n\n const body: Record<string, unknown> = {\n model: modelId,\n input,\n max_output_tokens: Math.max(0, Math.floor(options.maxTokens ?? 4096)),\n ...buildChatCompletionTemperature(modelId, options.temperature ?? 0.3, {\n assumeOpenAI: shouldAssumeOpenAiChatCompletions(config.baseUrl),\n }),\n ...(options.store === undefined ? {} : { store: options.store }),\n ...(options.jsonSchema || options.responsesJsonSchema\n ? {\n text: {\n format: {\n type: \"json_schema\",\n name: (options.jsonSchema ?? options.responsesJsonSchema)!.name,\n strict: (options.jsonSchema?.strict ?? (options.responsesJsonSchema ? true : false)),\n schema: (options.jsonSchema ?? options.responsesJsonSchema)!.schema,\n },\n },\n }\n : {}),\n };\n if (instructions.length > 0) {\n body.instructions = instructions;\n }\n\n const response = await fetch(url, {\n method: \"POST\",\n headers,\n signal: options.signal,\n body: JSON.stringify(body),\n });\n\n if (!response.ok) {\n const error = await response.text();\n throw Object.assign(new Error(`OpenAI Responses API error: ${response.status} ${error}`), { status: response.status });\n }\n\n const data = (await response.json()) as {\n output_text?: string;\n output?: Array<{\n type?: string;\n text?: string;\n content?: Array<{\n type?: string;\n text?: string;\n }>;\n }>;\n usage?: {\n input_tokens?: number;\n output_tokens?: number;\n total_tokens?: number;\n };\n };\n\n const outputText = extractResponsesOutputText(data);\n if (!outputText) {\n throw new Error(\"Empty response from OpenAI Responses API\");\n }\n\n return {\n content: outputText,\n usage: data.usage\n ? {\n inputTokens: data.usage.input_tokens,\n outputTokens: data.usage.output_tokens,\n totalTokens: data.usage.total_tokens,\n }\n : undefined,\n };\n }\n\n /**\n * Call Anthropic Messages API.\n */\n private async callAnthropic(\n config: ModelProviderConfig,\n modelId: string,\n messages: Array<{ role: \"system\" | \"user\" | \"assistant\"; content: string }>,\n options: FallbackLlmOptions,\n ): Promise<{ content: string; usage?: FallbackLlmResponse[\"usage\"] } | null> {\n const base = config.baseUrl.replace(/\\/$/, \"\");\n const url = base.endsWith(\"/v1\")\n ? `${base}/messages`\n : `${base}/v1/messages`;\n\n const headers: Record<string, string> = {\n \"Content-Type\": \"application/json\",\n \"anthropic-version\": \"2023-06-01\",\n ...config.headers,\n };\n\n // Handle auth - Anthropic uses x-api-key header (apiKey resolved by tryModel)\n if (config.apiKey && typeof config.apiKey === \"string\") {\n headers[\"x-api-key\"] = config.apiKey;\n }\n\n // Extract system message (Anthropic handles it separately)\n const systemMessage = messages.find((m) => m.role === \"system\")?.content;\n const nonSystemMessages = messages.filter((m) => m.role !== \"system\");\n\n // Convert messages to Anthropic format\n const anthropicMessages = nonSystemMessages.map((m) => ({\n role: m.role,\n content: m.content,\n }));\n\n const body: Record<string, unknown> = {\n model: modelId,\n messages: anthropicMessages,\n max_tokens: options.maxTokens ?? 4096,\n temperature: options.temperature ?? 0.3,\n };\n\n if (systemMessage) {\n body.system = systemMessage;\n }\n\n const response = await fetch(url, {\n method: \"POST\",\n headers,\n signal: options.signal,\n body: JSON.stringify(body),\n });\n\n if (!response.ok) {\n const error = await response.text();\n throw Object.assign(new Error(`Anthropic API error: ${response.status} ${error}`), { status: response.status });\n }\n\n const data = (await response.json()) as {\n content: Array<{\n type: string;\n text: string;\n }>;\n usage?: {\n input_tokens?: number;\n output_tokens?: number;\n };\n };\n\n const content = data.content?.[0]?.text;\n if (!content) {\n throw new Error(\"Empty response from Anthropic API\");\n }\n\n return {\n content,\n usage: data.usage\n ? {\n inputTokens: data.usage.input_tokens,\n outputTokens: data.usage.output_tokens,\n totalTokens: (data.usage.input_tokens ?? 0) + (data.usage.output_tokens ?? 0),\n }\n : undefined,\n };\n }\n}\n\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;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;AAAA,EACF;AACF;","names":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
parseEntityFile
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-OK726OF4.js";
|
|
4
4
|
import {
|
|
5
5
|
inferMemoryStatus
|
|
6
6
|
} from "./chunk-7RJUVTVF.js";
|
|
@@ -253,4 +253,4 @@ export {
|
|
|
253
253
|
WHO_KNOWS_MCP_TOOLS,
|
|
254
254
|
handleWhoKnowsHttpQuery
|
|
255
255
|
};
|
|
256
|
-
//# sourceMappingURL=chunk-
|
|
256
|
+
//# sourceMappingURL=chunk-KXAGZRJV.js.map
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
rebuildMemoryLifecycleLedger
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-4JI5PPFW.js";
|
|
4
4
|
import {
|
|
5
5
|
PROJECTION_REBUILD_RUNNER_FLAG
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-A7DIZOTF.js";
|
|
7
7
|
import {
|
|
8
8
|
startLocationAutoSync
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-OHJ5PNYB.js";
|
|
10
10
|
import {
|
|
11
11
|
ensureContradictionScanCron,
|
|
12
12
|
ensureDaySummaryCron,
|
|
@@ -21,17 +21,17 @@ import {
|
|
|
21
21
|
isIsoWeekId,
|
|
22
22
|
msUntilNextIsoWeek,
|
|
23
23
|
previousIsoWeekId
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-4FTYKZ77.js";
|
|
25
25
|
import {
|
|
26
26
|
planNamespaceMaintenance,
|
|
27
27
|
runNamespaceMaintenanceBatchPlan
|
|
28
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-FGNBUUPX.js";
|
|
29
29
|
import {
|
|
30
30
|
rebuildMemoryProjection
|
|
31
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-3EXG2KPK.js";
|
|
32
32
|
import {
|
|
33
33
|
LocalLlmClient
|
|
34
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-2X5I5C3M.js";
|
|
35
35
|
import {
|
|
36
36
|
DEFAULT_TIMELINE_CATEGORIES,
|
|
37
37
|
TIMELINE_RESERVED_IDLE,
|
|
@@ -48,10 +48,10 @@ import {
|
|
|
48
48
|
} from "./chunk-EWMRFW3F.js";
|
|
49
49
|
import {
|
|
50
50
|
FallbackLlmClient
|
|
51
|
-
} from "./chunk-
|
|
51
|
+
} from "./chunk-KQYGUFMQ.js";
|
|
52
52
|
import {
|
|
53
53
|
fallbackLlmRuntimeContextFromConfig
|
|
54
|
-
} from "./chunk-
|
|
54
|
+
} from "./chunk-STQNKDKZ.js";
|
|
55
55
|
import {
|
|
56
56
|
activityDateInTimezone,
|
|
57
57
|
activityDayWindow,
|
|
@@ -2874,4 +2874,4 @@ export {
|
|
|
2874
2874
|
ActivitySyncScheduler,
|
|
2875
2875
|
MaintenanceScheduler
|
|
2876
2876
|
};
|
|
2877
|
-
//# sourceMappingURL=chunk-
|
|
2877
|
+
//# sourceMappingURL=chunk-LJNCJK7B.js.map
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
} from "./chunk-ZCUTSMR2.js";
|
|
14
14
|
import {
|
|
15
15
|
StorageManager
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-OK726OF4.js";
|
|
17
17
|
import {
|
|
18
18
|
excludeSupportPassportPrivateMemories
|
|
19
19
|
} from "./chunk-TSUSHXBW.js";
|
|
@@ -134,4 +134,4 @@ export {
|
|
|
134
134
|
runCodexMaterialize,
|
|
135
135
|
runPostConsolidationMaterialize
|
|
136
136
|
};
|
|
137
|
-
//# sourceMappingURL=chunk-
|
|
137
|
+
//# sourceMappingURL=chunk-LMM2LRVQ.js.map
|