@remnic/core 1.1.1 → 1.1.2

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.
Files changed (80) hide show
  1. package/dist/access-cli.js +20 -20
  2. package/dist/access-http.js +5 -5
  3. package/dist/access-mcp.js +4 -4
  4. package/dist/access-service.js +3 -2
  5. package/dist/briefing.js +2 -1
  6. package/dist/calibration.js +2 -2
  7. package/dist/causal-consolidation.js +4 -4
  8. package/dist/{chunk-VYM3VWOF.js → chunk-3YGHKTBF.js} +24 -18
  9. package/dist/chunk-3YGHKTBF.js.map +1 -0
  10. package/dist/{chunk-YNQKWQT4.js → chunk-4HQS2HPX.js} +5 -5
  11. package/dist/{chunk-B5WXLVDY.js → chunk-6YJHX2DL.js} +7 -7
  12. package/dist/{chunk-3GXCSUXR.js → chunk-AYXIPSZO.js} +2 -2
  13. package/dist/{chunk-BK2EFTE2.js → chunk-BECYBZLX.js} +8 -8
  14. package/dist/chunk-BECYBZLX.js.map +1 -0
  15. package/dist/{chunk-ZEM3OK2K.js → chunk-DG6YMRDC.js} +3 -3
  16. package/dist/{chunk-S3EEFKNY.js → chunk-DIXB44VE.js} +3 -3
  17. package/dist/{chunk-EPQJM2GC.js → chunk-GA5P7RST.js} +4 -4
  18. package/dist/{chunk-WVVA7F5A.js → chunk-L7IXWRYE.js} +9 -4
  19. package/dist/chunk-L7IXWRYE.js.map +1 -0
  20. package/dist/{chunk-INXV5JBT.js → chunk-LOIMBRDE.js} +13 -13
  21. package/dist/{chunk-7I7FKFZH.js → chunk-NBVAS5MT.js} +3 -3
  22. package/dist/{chunk-HK3FGIEW.js → chunk-OC5OXUQ4.js} +6 -6
  23. package/dist/{chunk-LK6SGL53.js → chunk-OR64ZGRZ.js} +3 -2
  24. package/dist/chunk-OR64ZGRZ.js.map +1 -0
  25. package/dist/{chunk-BGJGXLZ7.js → chunk-PVICZTKG.js} +7 -4
  26. package/dist/chunk-PVICZTKG.js.map +1 -0
  27. package/dist/{chunk-JL2PU6AI.js → chunk-R2XRID2N.js} +2 -2
  28. package/dist/{chunk-GKFXUTJ2.js → chunk-STGWEHYR.js} +2 -2
  29. package/dist/{chunk-KUB6JU6H.js → chunk-TMYO7B5P.js} +2 -2
  30. package/dist/{chunk-DFTTJYSO.js → chunk-UWB5LMWY.js} +3 -3
  31. package/dist/{chunk-O5ETUNBT.js → chunk-VTU2B4VF.js} +7 -3
  32. package/dist/chunk-VTU2B4VF.js.map +1 -0
  33. package/dist/{chunk-RGLL5SPU.js → chunk-XXVWLXSG.js} +1 -1
  34. package/dist/{chunk-XZ2TIKGC.js → chunk-Y7R2XJ5Q.js} +25 -9
  35. package/dist/chunk-Y7R2XJ5Q.js.map +1 -0
  36. package/dist/{chunk-ALXMCZEU.js → chunk-Z2E7VW55.js} +6 -3
  37. package/dist/chunk-Z2E7VW55.js.map +1 -0
  38. package/dist/cli.js +13 -13
  39. package/dist/config.js +2 -2
  40. package/dist/embedding-fallback.js +2 -1
  41. package/dist/{engine-F3GOXGE5.js → engine-72LSIWQP.js} +2 -2
  42. package/dist/extraction.js +6 -6
  43. package/dist/fallback-llm.js +2 -2
  44. package/dist/index.js +57 -50
  45. package/dist/index.js.map +1 -1
  46. package/dist/local-llm.js +2 -2
  47. package/dist/operator-toolkit.js +6 -6
  48. package/dist/orchestrator.js +14 -14
  49. package/dist/qmd.js +3 -3
  50. package/dist/resolve-provider-secret.d.ts +5 -1
  51. package/dist/resolve-provider-secret.js +3 -1
  52. package/dist/resume-bundles.js +3 -3
  53. package/dist/schemas.d.ts +22 -22
  54. package/dist/semantic-consolidation.js +2 -1
  55. package/dist/summarizer.js +5 -5
  56. package/dist/tokens.js +2 -1
  57. package/package.json +1 -1
  58. package/dist/chunk-ALXMCZEU.js.map +0 -1
  59. package/dist/chunk-BGJGXLZ7.js.map +0 -1
  60. package/dist/chunk-BK2EFTE2.js.map +0 -1
  61. package/dist/chunk-LK6SGL53.js.map +0 -1
  62. package/dist/chunk-O5ETUNBT.js.map +0 -1
  63. package/dist/chunk-VYM3VWOF.js.map +0 -1
  64. package/dist/chunk-WVVA7F5A.js.map +0 -1
  65. package/dist/chunk-XZ2TIKGC.js.map +0 -1
  66. /package/dist/{chunk-YNQKWQT4.js.map → chunk-4HQS2HPX.js.map} +0 -0
  67. /package/dist/{chunk-B5WXLVDY.js.map → chunk-6YJHX2DL.js.map} +0 -0
  68. /package/dist/{chunk-3GXCSUXR.js.map → chunk-AYXIPSZO.js.map} +0 -0
  69. /package/dist/{chunk-ZEM3OK2K.js.map → chunk-DG6YMRDC.js.map} +0 -0
  70. /package/dist/{chunk-S3EEFKNY.js.map → chunk-DIXB44VE.js.map} +0 -0
  71. /package/dist/{chunk-EPQJM2GC.js.map → chunk-GA5P7RST.js.map} +0 -0
  72. /package/dist/{chunk-INXV5JBT.js.map → chunk-LOIMBRDE.js.map} +0 -0
  73. /package/dist/{chunk-7I7FKFZH.js.map → chunk-NBVAS5MT.js.map} +0 -0
  74. /package/dist/{chunk-HK3FGIEW.js.map → chunk-OC5OXUQ4.js.map} +0 -0
  75. /package/dist/{chunk-JL2PU6AI.js.map → chunk-R2XRID2N.js.map} +0 -0
  76. /package/dist/{chunk-GKFXUTJ2.js.map → chunk-STGWEHYR.js.map} +0 -0
  77. /package/dist/{chunk-KUB6JU6H.js.map → chunk-TMYO7B5P.js.map} +0 -0
  78. /package/dist/{chunk-DFTTJYSO.js.map → chunk-UWB5LMWY.js.map} +0 -0
  79. /package/dist/{chunk-RGLL5SPU.js.map → chunk-XXVWLXSG.js.map} +0 -0
  80. /package/dist/{engine-F3GOXGE5.js.map → engine-72LSIWQP.js.map} +0 -0
package/dist/local-llm.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  LocalLlmClient
3
- } from "./chunk-JL2PU6AI.js";
4
- import "./chunk-LK6SGL53.js";
3
+ } from "./chunk-R2XRID2N.js";
4
+ import "./chunk-OR64ZGRZ.js";
5
5
  import "./chunk-MARWOCVP.js";
6
6
  import "./chunk-2ODBA7MQ.js";
7
7
  export {
@@ -8,21 +8,20 @@ import {
8
8
  summarizeBufferSurpriseDistribution,
9
9
  summarizeConsolidationProvenance,
10
10
  summarizeMemoryWorthLegacyCounters
11
- } from "./chunk-B5WXLVDY.js";
11
+ } from "./chunk-6YJHX2DL.js";
12
12
  import "./chunk-ULYOGL6R.js";
13
13
  import "./chunk-ASAITVLA.js";
14
- import "./chunk-7I7FKFZH.js";
14
+ import "./chunk-NBVAS5MT.js";
15
15
  import "./chunk-YRMVARQP.js";
16
- import "./chunk-YNQKWQT4.js";
16
+ import "./chunk-4HQS2HPX.js";
17
17
  import "./chunk-U66YHYC7.js";
18
- import "./chunk-LK6SGL53.js";
18
+ import "./chunk-OR64ZGRZ.js";
19
19
  import "./chunk-7SEAZFFB.js";
20
20
  import "./chunk-K6WK37A6.js";
21
- import "./chunk-BK2EFTE2.js";
21
+ import "./chunk-BECYBZLX.js";
22
22
  import "./chunk-Z5LAYHGJ.js";
23
23
  import "./chunk-C2EFFULQ.js";
24
24
  import "./chunk-PVGDJXVK.js";
25
- import "./chunk-MARWOCVP.js";
26
25
  import "./chunk-3OGMS3PE.js";
27
26
  import "./chunk-2LGMW3DJ.js";
28
27
  import "./chunk-TBBDFYXW.js";
@@ -39,6 +38,7 @@ import "./chunk-M62O4P4T.js";
39
38
  import "./chunk-4DJQYKMN.js";
40
39
  import "./chunk-X6GF3FX2.js";
41
40
  import "./chunk-FAAFWE4G.js";
41
+ import "./chunk-MARWOCVP.js";
42
42
  import "./chunk-2ODBA7MQ.js";
43
43
  import "./chunk-LPSF4OQH.js";
44
44
  export {
@@ -26,8 +26,8 @@ import {
26
26
  sanitizeSessionKeyForFilename,
27
27
  shouldFilterLifecycleRecallCandidate,
28
28
  summarizeGraphShadowComparison
29
- } from "./chunk-VYM3VWOF.js";
30
- import "./chunk-RGLL5SPU.js";
29
+ } from "./chunk-3YGHKTBF.js";
30
+ import "./chunk-XXVWLXSG.js";
31
31
  import "./chunk-UHGBNIOS.js";
32
32
  import "./chunk-FSFEQI74.js";
33
33
  import "./chunk-W6SL7OFG.js";
@@ -35,7 +35,7 @@ import "./chunk-Z5AAYHUC.js";
35
35
  import "./chunk-S75M5ZRK.js";
36
36
  import "./chunk-TPB3I2AC.js";
37
37
  import "./chunk-JR4ZC3G4.js";
38
- import "./chunk-ZEM3OK2K.js";
38
+ import "./chunk-DG6YMRDC.js";
39
39
  import "./chunk-ETOW6ACV.js";
40
40
  import "./chunk-5NPGSAVB.js";
41
41
  import "./chunk-C7VW7C3F.js";
@@ -58,19 +58,19 @@ import "./chunk-YAZNBMNF.js";
58
58
  import "./chunk-AJU4PJGY.js";
59
59
  import "./chunk-DF3RVK3X.js";
60
60
  import "./chunk-C4SQJZAF.js";
61
- import "./chunk-S3EEFKNY.js";
61
+ import "./chunk-DIXB44VE.js";
62
62
  import "./chunk-NZLQTHS5.js";
63
63
  import "./chunk-54V4BZWP.js";
64
64
  import "./chunk-NBNN5GOB.js";
65
65
  import "./chunk-FEMOX5AD.js";
66
- import "./chunk-JL2PU6AI.js";
66
+ import "./chunk-R2XRID2N.js";
67
67
  import "./chunk-VEWZZM3H.js";
68
68
  import "./chunk-6AUUAZEX.js";
69
69
  import "./chunk-Y4FHOFJ2.js";
70
- import "./chunk-ALXMCZEU.js";
70
+ import "./chunk-Z2E7VW55.js";
71
71
  import "./chunk-FVA6TGI3.js";
72
72
  import "./chunk-GZCUW5IC.js";
73
- import "./chunk-EPQJM2GC.js";
73
+ import "./chunk-GA5P7RST.js";
74
74
  import "./chunk-PYXS46O7.js";
75
75
  import "./chunk-3QKK7QOS.js";
76
76
  import "./chunk-CUPFXL3J.js";
@@ -78,14 +78,14 @@ import "./chunk-JRNQ3RNA.js";
78
78
  import "./chunk-SPI27QT6.js";
79
79
  import "./chunk-CULXMQJH.js";
80
80
  import "./chunk-E6K4NIEU.js";
81
- import "./chunk-7I7FKFZH.js";
81
+ import "./chunk-NBVAS5MT.js";
82
82
  import "./chunk-YRMVARQP.js";
83
- import "./chunk-YNQKWQT4.js";
83
+ import "./chunk-4HQS2HPX.js";
84
84
  import "./chunk-EABGC2TL.js";
85
85
  import "./chunk-LOBRX7VD.js";
86
86
  import "./chunk-HMDCOMYU.js";
87
87
  import "./chunk-JXS5PDQ7.js";
88
- import "./chunk-LK6SGL53.js";
88
+ import "./chunk-OR64ZGRZ.js";
89
89
  import "./chunk-7SEAZFFB.js";
90
90
  import "./chunk-K6WK37A6.js";
91
91
  import "./chunk-Z5LAYHGJ.js";
@@ -97,10 +97,10 @@ import "./chunk-2NMMFZ5T.js";
97
97
  import "./chunk-KVE7R4CG.js";
98
98
  import "./chunk-4WMCPJWX.js";
99
99
  import "./chunk-JBMSGZEQ.js";
100
- import "./chunk-BGJGXLZ7.js";
100
+ import "./chunk-PVICZTKG.js";
101
101
  import "./chunk-EJI5XIBB.js";
102
- import "./chunk-3GXCSUXR.js";
103
- import "./chunk-XZ2TIKGC.js";
102
+ import "./chunk-AYXIPSZO.js";
103
+ import "./chunk-Y7R2XJ5Q.js";
104
104
  import "./chunk-ODWDQNRE.js";
105
105
  import "./chunk-Y27UJK6V.js";
106
106
  import "./chunk-UZB5KHKX.js";
@@ -111,7 +111,6 @@ import "./chunk-XYIK4LF6.js";
111
111
  import "./chunk-URB2WSKZ.js";
112
112
  import "./chunk-PVGDJXVK.js";
113
113
  import "./chunk-NGAVDO7E.js";
114
- import "./chunk-MARWOCVP.js";
115
114
  import "./chunk-EQINRHYR.js";
116
115
  import "./chunk-EEQLFRUM.js";
117
116
  import "./chunk-QDW3E4RD.js";
@@ -134,6 +133,7 @@ import "./chunk-M62O4P4T.js";
134
133
  import "./chunk-4DJQYKMN.js";
135
134
  import "./chunk-X6GF3FX2.js";
136
135
  import "./chunk-FAAFWE4G.js";
136
+ import "./chunk-MARWOCVP.js";
137
137
  import "./chunk-2ODBA7MQ.js";
138
138
  import "./chunk-DGXUHMOV.js";
139
139
  import "./chunk-LPSF4OQH.js";
package/dist/qmd.js CHANGED
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  QmdClient,
3
3
  parseQmdExplain
4
- } from "./chunk-YNQKWQT4.js";
5
- import "./chunk-LK6SGL53.js";
4
+ } from "./chunk-4HQS2HPX.js";
5
+ import "./chunk-OR64ZGRZ.js";
6
6
  import "./chunk-PVGDJXVK.js";
7
- import "./chunk-MARWOCVP.js";
8
7
  import "./chunk-6PFRXT4K.js";
8
+ import "./chunk-MARWOCVP.js";
9
9
  import "./chunk-2ODBA7MQ.js";
10
10
  export {
11
11
  QmdClient,
@@ -40,6 +40,10 @@ type GetRuntimeAuthForModelFn = (params: {
40
40
  mode?: string;
41
41
  profileId?: string;
42
42
  } | null>;
43
+ declare function findExecutableOnPath(executableName: string, access: (path: string, mode?: number) => void, stat: (path: string) => {
44
+ isFile(): boolean;
45
+ }, executableMode: number): string | undefined;
46
+ declare const __findExecutableOnPathForTest: typeof findExecutableOnPath;
43
47
  /**
44
48
  * Resolve a provider API key from various OpenClaw formats.
45
49
  *
@@ -64,4 +68,4 @@ declare function getGatewayRuntimeAuthForModel(): Promise<GetRuntimeAuthForModel
64
68
  declare function clearSecretCache(): void;
65
69
  declare function __setGatewayResolverForTest(resolver: ResolveApiKeyFn | null): void;
66
70
 
67
- export { type GetRuntimeAuthForModelFn, __setGatewayResolverForTest, clearSecretCache, getGatewayRuntimeAuthForModel, resolveProviderApiKey };
71
+ export { type GetRuntimeAuthForModelFn, __findExecutableOnPathForTest, __setGatewayResolverForTest, clearSecretCache, getGatewayRuntimeAuthForModel, resolveProviderApiKey };
@@ -1,12 +1,14 @@
1
1
  import {
2
+ __findExecutableOnPathForTest,
2
3
  __setGatewayResolverForTest,
3
4
  clearSecretCache,
4
5
  getGatewayRuntimeAuthForModel,
5
6
  resolveProviderApiKey
6
- } from "./chunk-XZ2TIKGC.js";
7
+ } from "./chunk-Y7R2XJ5Q.js";
7
8
  import "./chunk-MARWOCVP.js";
8
9
  import "./chunk-2ODBA7MQ.js";
9
10
  export {
11
+ __findExecutableOnPathForTest,
10
12
  __setGatewayResolverForTest,
11
13
  clearSecretCache,
12
14
  getGatewayRuntimeAuthForModel,
@@ -4,17 +4,17 @@ import {
4
4
  recordResumeBundle,
5
5
  resolveResumeBundleDir,
6
6
  validateResumeBundle
7
- } from "./chunk-KUB6JU6H.js";
7
+ } from "./chunk-TMYO7B5P.js";
8
8
  import "./chunk-CULXMQJH.js";
9
9
  import "./chunk-E6K4NIEU.js";
10
10
  import "./chunk-YRMVARQP.js";
11
11
  import "./chunk-LOBRX7VD.js";
12
- import "./chunk-BK2EFTE2.js";
12
+ import "./chunk-BECYBZLX.js";
13
13
  import "./chunk-Z5LAYHGJ.js";
14
14
  import "./chunk-FYIYMQ5N.js";
15
- import "./chunk-MARWOCVP.js";
16
15
  import "./chunk-DT5TVLJE.js";
17
16
  import "./chunk-4DJQYKMN.js";
17
+ import "./chunk-MARWOCVP.js";
18
18
  import "./chunk-2ODBA7MQ.js";
19
19
  import "./chunk-DGXUHMOV.js";
20
20
  import "./chunk-LPSF4OQH.js";
package/dist/schemas.d.ts CHANGED
@@ -214,12 +214,12 @@ declare const EntityMentionSchema: z.ZodObject<{
214
214
  title: z.ZodString;
215
215
  facts: z.ZodArray<z.ZodString, "many">;
216
216
  }, "strip", z.ZodTypeAny, {
217
- key: string;
218
217
  title: string;
218
+ key: string;
219
219
  facts: string[];
220
220
  }, {
221
- key: string;
222
221
  title: string;
222
+ key: string;
223
223
  facts: string[];
224
224
  }>, "many">>>;
225
225
  }, "strip", z.ZodTypeAny, {
@@ -227,8 +227,8 @@ declare const EntityMentionSchema: z.ZodObject<{
227
227
  name: string;
228
228
  type: "project" | "person" | "tool" | "company" | "place" | "other";
229
229
  structuredSections?: {
230
- key: string;
231
230
  title: string;
231
+ key: string;
232
232
  facts: string[];
233
233
  }[] | null | undefined;
234
234
  promptedByQuestion?: string | null | undefined;
@@ -237,8 +237,8 @@ declare const EntityMentionSchema: z.ZodObject<{
237
237
  name: string;
238
238
  type: "project" | "person" | "tool" | "company" | "place" | "other";
239
239
  structuredSections?: {
240
- key: string;
241
240
  title: string;
241
+ key: string;
242
242
  facts: string[];
243
243
  }[] | null | undefined;
244
244
  promptedByQuestion?: string | null | undefined;
@@ -462,12 +462,12 @@ declare const ProactiveExtractionResultSchema: z.ZodObject<{
462
462
  title: z.ZodString;
463
463
  facts: z.ZodArray<z.ZodString, "many">;
464
464
  }, "strip", z.ZodTypeAny, {
465
- key: string;
466
465
  title: string;
466
+ key: string;
467
467
  facts: string[];
468
468
  }, {
469
- key: string;
470
469
  title: string;
470
+ key: string;
471
471
  facts: string[];
472
472
  }>, "many">>>;
473
473
  }, "strip", z.ZodTypeAny, {
@@ -475,8 +475,8 @@ declare const ProactiveExtractionResultSchema: z.ZodObject<{
475
475
  name: string;
476
476
  type: "project" | "person" | "tool" | "company" | "place" | "other";
477
477
  structuredSections?: {
478
- key: string;
479
478
  title: string;
479
+ key: string;
480
480
  facts: string[];
481
481
  }[] | null | undefined;
482
482
  promptedByQuestion?: string | null | undefined;
@@ -485,8 +485,8 @@ declare const ProactiveExtractionResultSchema: z.ZodObject<{
485
485
  name: string;
486
486
  type: "project" | "person" | "tool" | "company" | "place" | "other";
487
487
  structuredSections?: {
488
- key: string;
489
488
  title: string;
489
+ key: string;
490
490
  facts: string[];
491
491
  }[] | null | undefined;
492
492
  promptedByQuestion?: string | null | undefined;
@@ -542,8 +542,8 @@ declare const ProactiveExtractionResultSchema: z.ZodObject<{
542
542
  name: string;
543
543
  type: "project" | "person" | "tool" | "company" | "place" | "other";
544
544
  structuredSections?: {
545
- key: string;
546
545
  title: string;
546
+ key: string;
547
547
  facts: string[];
548
548
  }[] | null | undefined;
549
549
  promptedByQuestion?: string | null | undefined;
@@ -590,8 +590,8 @@ declare const ProactiveExtractionResultSchema: z.ZodObject<{
590
590
  name: string;
591
591
  type: "project" | "person" | "tool" | "company" | "place" | "other";
592
592
  structuredSections?: {
593
- key: string;
594
593
  title: string;
594
+ key: string;
595
595
  facts: string[];
596
596
  }[] | null | undefined;
597
597
  promptedByQuestion?: string | null | undefined;
@@ -767,12 +767,12 @@ declare const ExtractionResultSchema: z.ZodObject<{
767
767
  title: z.ZodString;
768
768
  facts: z.ZodArray<z.ZodString, "many">;
769
769
  }, "strip", z.ZodTypeAny, {
770
- key: string;
771
770
  title: string;
771
+ key: string;
772
772
  facts: string[];
773
773
  }, {
774
- key: string;
775
774
  title: string;
775
+ key: string;
776
776
  facts: string[];
777
777
  }>, "many">>>;
778
778
  }, "strip", z.ZodTypeAny, {
@@ -780,8 +780,8 @@ declare const ExtractionResultSchema: z.ZodObject<{
780
780
  name: string;
781
781
  type: "project" | "person" | "tool" | "company" | "place" | "other";
782
782
  structuredSections?: {
783
- key: string;
784
783
  title: string;
784
+ key: string;
785
785
  facts: string[];
786
786
  }[] | null | undefined;
787
787
  promptedByQuestion?: string | null | undefined;
@@ -790,8 +790,8 @@ declare const ExtractionResultSchema: z.ZodObject<{
790
790
  name: string;
791
791
  type: "project" | "person" | "tool" | "company" | "place" | "other";
792
792
  structuredSections?: {
793
- key: string;
794
793
  title: string;
794
+ key: string;
795
795
  facts: string[];
796
796
  }[] | null | undefined;
797
797
  promptedByQuestion?: string | null | undefined;
@@ -861,8 +861,8 @@ declare const ExtractionResultSchema: z.ZodObject<{
861
861
  name: string;
862
862
  type: "project" | "person" | "tool" | "company" | "place" | "other";
863
863
  structuredSections?: {
864
- key: string;
865
864
  title: string;
865
+ key: string;
866
866
  facts: string[];
867
867
  }[] | null | undefined;
868
868
  promptedByQuestion?: string | null | undefined;
@@ -915,8 +915,8 @@ declare const ExtractionResultSchema: z.ZodObject<{
915
915
  name: string;
916
916
  type: "project" | "person" | "tool" | "company" | "place" | "other";
917
917
  structuredSections?: {
918
- key: string;
919
918
  title: string;
919
+ key: string;
920
920
  facts: string[];
921
921
  }[] | null | undefined;
922
922
  promptedByQuestion?: string | null | undefined;
@@ -985,12 +985,12 @@ declare const ConsolidationResultSchema: z.ZodObject<{
985
985
  title: z.ZodString;
986
986
  facts: z.ZodArray<z.ZodString, "many">;
987
987
  }, "strip", z.ZodTypeAny, {
988
- key: string;
989
988
  title: string;
989
+ key: string;
990
990
  facts: string[];
991
991
  }, {
992
- key: string;
993
992
  title: string;
993
+ key: string;
994
994
  facts: string[];
995
995
  }>, "many">>>;
996
996
  }, "strip", z.ZodTypeAny, {
@@ -998,8 +998,8 @@ declare const ConsolidationResultSchema: z.ZodObject<{
998
998
  name: string;
999
999
  type: "project" | "person" | "tool" | "company" | "place" | "other";
1000
1000
  structuredSections?: {
1001
- key: string;
1002
1001
  title: string;
1002
+ key: string;
1003
1003
  facts: string[];
1004
1004
  }[] | null | undefined;
1005
1005
  promptedByQuestion?: string | null | undefined;
@@ -1008,8 +1008,8 @@ declare const ConsolidationResultSchema: z.ZodObject<{
1008
1008
  name: string;
1009
1009
  type: "project" | "person" | "tool" | "company" | "place" | "other";
1010
1010
  structuredSections?: {
1011
- key: string;
1012
1011
  title: string;
1012
+ key: string;
1013
1013
  facts: string[];
1014
1014
  }[] | null | undefined;
1015
1015
  promptedByQuestion?: string | null | undefined;
@@ -1028,8 +1028,8 @@ declare const ConsolidationResultSchema: z.ZodObject<{
1028
1028
  name: string;
1029
1029
  type: "project" | "person" | "tool" | "company" | "place" | "other";
1030
1030
  structuredSections?: {
1031
- key: string;
1032
1031
  title: string;
1032
+ key: string;
1033
1033
  facts: string[];
1034
1034
  }[] | null | undefined;
1035
1035
  promptedByQuestion?: string | null | undefined;
@@ -1048,8 +1048,8 @@ declare const ConsolidationResultSchema: z.ZodObject<{
1048
1048
  name: string;
1049
1049
  type: "project" | "person" | "tool" | "company" | "place" | "other";
1050
1050
  structuredSections?: {
1051
- key: string;
1052
1051
  title: string;
1052
+ key: string;
1053
1053
  facts: string[];
1054
1054
  }[] | null | undefined;
1055
1055
  promptedByQuestion?: string | null | undefined;
@@ -7,7 +7,7 @@ import {
7
7
  materializeAfterSemanticConsolidation,
8
8
  parseConsolidationResponse,
9
9
  parseOperatorAwareConsolidationResponse
10
- } from "./chunk-BGJGXLZ7.js";
10
+ } from "./chunk-PVICZTKG.js";
11
11
  import {
12
12
  resolveExtensionsRoot
13
13
  } from "./chunk-EJI5XIBB.js";
@@ -29,6 +29,7 @@ import {
29
29
  isValidDerivedFromEntry
30
30
  } from "./chunk-X6GF3FX2.js";
31
31
  import "./chunk-FAAFWE4G.js";
32
+ import "./chunk-MARWOCVP.js";
32
33
  import "./chunk-2ODBA7MQ.js";
33
34
  export {
34
35
  CONSOLIDATION_OPERATORS,
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  HourlySummarizer
3
- } from "./chunk-ZEM3OK2K.js";
3
+ } from "./chunk-DG6YMRDC.js";
4
4
  import "./chunk-ETOW6ACV.js";
5
5
  import "./chunk-FEMOX5AD.js";
6
- import "./chunk-JL2PU6AI.js";
7
- import "./chunk-LK6SGL53.js";
8
- import "./chunk-3GXCSUXR.js";
9
- import "./chunk-XZ2TIKGC.js";
6
+ import "./chunk-R2XRID2N.js";
7
+ import "./chunk-OR64ZGRZ.js";
8
+ import "./chunk-AYXIPSZO.js";
9
+ import "./chunk-Y7R2XJ5Q.js";
10
10
  import "./chunk-ODWDQNRE.js";
11
11
  import "./chunk-Y27UJK6V.js";
12
12
  import "./chunk-UZB5KHKX.js";
package/dist/tokens.js CHANGED
@@ -9,7 +9,8 @@ import {
9
9
  resolveConnectorFromToken,
10
10
  revokeToken,
11
11
  saveTokenStore
12
- } from "./chunk-O5ETUNBT.js";
12
+ } from "./chunk-VTU2B4VF.js";
13
+ import "./chunk-MARWOCVP.js";
13
14
  export {
14
15
  buildTokenEntry,
15
16
  commitTokenEntry,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remnic/core",
3
- "version": "1.1.1",
3
+ "version": "1.1.2",
4
4
  "description": "Framework-agnostic Remnic memory engine — orchestrator, storage, extraction, search, trust zones",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/embedding-fallback.ts"],"sourcesContent":["import path from \"node:path\";\nimport { mkdir, readFile, writeFile } from \"node:fs/promises\";\nimport { log } from \"./logger.js\";\nimport type { PluginConfig } from \"./types.js\";\n\ntype EmbeddingProviderType = \"openai\" | \"local\";\n\ntype ProviderConfig = {\n type: EmbeddingProviderType;\n model: string;\n endpoint: string;\n headers: Record<string, string>;\n};\n\ntype EmbeddingIndexEntry = {\n vector: number[];\n path: string;\n};\n\ntype EmbeddingIndexFile = {\n version: 1;\n provider: EmbeddingProviderType;\n model: string;\n entries: Record<string, EmbeddingIndexEntry>;\n};\n\nconst DEFAULT_OPENAI_MODEL = \"text-embedding-3-small\";\n\n/**\n * Thrown by `EmbeddingFallback.search()` (via `embed()`) when the embedding\n * backend is effectively unavailable on the lookup path — either because the\n * HTTP fetch exceeded its deadline OR because the endpoint returned a non-2xx\n * status code. Callers that need to distinguish a backend outage from \"no\n * candidates\" can `instanceof`-check against this class.\n *\n * Round 9 fix (Finding UZqB): previously a timeout returned null from embed(),\n * which caused search() to return [] silently. decideSemanticDedup then\n * classified the result as no_candidates instead of backend_unavailable, so\n * the per-batch batchBackendUnavailable short-circuit never activated and\n * batches of N facts each paid a full timeout roundtrip.\n *\n * Round 10 fix (Findings Ui1J + Ui1L): search() now only re-throws this error\n * when the caller explicitly passes `{ throwOnTimeout: true }`. Without that\n * flag search() catches it and returns [] instead, preserving fail-open\n * semantics for recall-path callers (searchEmbeddingFallback) that have no\n * try/catch. Only the semantic-dedup path (semanticDedupLookup) passes the\n * flag so it can still reach decideSemanticDedup's backend_unavailable branch.\n *\n * Round 11 fix (Finding Ur_J): `embed()` now also throws this error from the\n * lookup path when the HTTP response is non-2xx (e.g. 429, 500, 503). Without\n * this, repeated 5xx outages would each return null → [] → no_candidates and\n * subsequent facts in the same batch would all pay full roundtrips instead of\n * tripping the per-batch backend_unavailable short-circuit.\n *\n * The class name is kept for backward compatibility — `EmbeddingTimeoutError`\n * now signals \"lookup backend unavailable\" rather than strictly \"timed out\".\n */\nexport class EmbeddingTimeoutError extends Error {\n override readonly name = \"EmbeddingTimeoutError\" as const;\n constructor(message: string) {\n super(message);\n }\n}\n\n/**\n * Maximum time to wait for an embedding HTTP request on the LOOKUP/query\n * path before giving up.\n *\n * The write-time semantic dedup guard in orchestrator.persistExtraction()\n * blocks each candidate fact on an embedding lookup. If the embedding\n * endpoint hangs (degraded OpenAI, stalled local gateway, DNS timeout),\n * extraction would otherwise stall indefinitely — a single bad backend\n * could freeze the entire persist loop. Bounding the fetch here ensures\n * the decision path fails open (returns null) within a predictable window\n * and writes proceed as non-duplicates.\n *\n * Tests can override via REMNIC_EMBEDDING_FETCH_TIMEOUT_MS so they don't\n * have to wait the full default on hung-fetch assertions.\n *\n * Related: joshuaswarren/remnic#373, PR #399 P1/P2 review.\n */\nconst DEFAULT_EMBEDDING_LOOKUP_TIMEOUT_MS = 5000;\n\n/**\n * Maximum time to wait for an embedding HTTP request on the INDEX path.\n *\n * Indexing runs asynchronously after a memory has already been persisted\n * to disk. It does not block extraction or writes — it only updates the\n * embedding index used by later semantic dedup lookups. A slow local\n * CPU-backed embedding model can legitimately take tens of seconds per\n * call, so applying the short lookup timeout here silently dropped index\n * updates and caused later dedup lookups to miss recently persisted\n * memories. Use a much larger budget on this path.\n *\n * Tests can override via REMNIC_EMBEDDING_INDEX_TIMEOUT_MS.\n */\nconst DEFAULT_EMBEDDING_INDEX_TIMEOUT_MS = 120_000;\n\nfunction resolveEmbeddingLookupTimeoutMs(): number {\n const raw = process.env.REMNIC_EMBEDDING_FETCH_TIMEOUT_MS;\n if (raw) {\n const parsed = Number(raw);\n if (Number.isFinite(parsed) && parsed > 0) {\n return Math.floor(parsed);\n }\n }\n return DEFAULT_EMBEDDING_LOOKUP_TIMEOUT_MS;\n}\n\nfunction resolveEmbeddingIndexTimeoutMs(): number {\n const raw = process.env.REMNIC_EMBEDDING_INDEX_TIMEOUT_MS;\n if (raw) {\n const parsed = Number(raw);\n if (Number.isFinite(parsed) && parsed > 0) {\n return Math.floor(parsed);\n }\n }\n return DEFAULT_EMBEDDING_INDEX_TIMEOUT_MS;\n}\n\n/**\n * Options for the low-level embed() call.\n *\n * `mode` selects the timeout profile:\n * - \"lookup\" (default): bounded by the short lookup budget; fails open fast.\n * - \"index\": bounded by a much longer budget so slow backends can still\n * index newly persisted memories.\n */\nexport type EmbedMode = \"lookup\" | \"index\";\n\nexport class EmbeddingFallback {\n private readonly indexPath: string;\n private loaded: EmbeddingIndexFile | null = null;\n\n constructor(private readonly config: PluginConfig) {\n this.indexPath = path.join(config.memoryDir, \"state\", \"embeddings.json\");\n }\n\n async isAvailable(): Promise<boolean> {\n return (await this.resolveProvider()) !== null;\n }\n\n /**\n * Embed an array of texts and return their embedding vectors.\n *\n * This is the public batch-embed interface used by semantic chunking\n * (Finding 1, PR #420 post-merge). Texts are grouped into batches of\n * `embeddingBatchSize` (from `semanticChunkingConfig`, default 32) and\n * each batch is dispatched concurrently via `Promise.all()`. This\n * preserves the semantic intent of `embeddingBatchSize` — without batching,\n * every text incurred a sequential HTTP round-trip, making the batch size\n * config ineffective. (PR #439 post-merge Finding 2.)\n *\n * If the provider is unavailable or any single embedding fails, the method\n * throws so the caller can fall back to recursive chunking.\n */\n async embedTexts(texts: string[]): Promise<number[][]> {\n const provider = await this.resolveProvider();\n if (!provider) {\n throw new Error(\"Embedding provider is not available\");\n }\n\n const batchSize = Math.max(\n 1,\n this.config.semanticChunkingConfig?.embeddingBatchSize ?? 32,\n );\n\n const vectors: number[][] = [];\n for (let i = 0; i < texts.length; i += batchSize) {\n const batch = texts.slice(i, i + batchSize);\n const batchResults = await Promise.all(\n batch.map((text) => this.embed(text, provider, { mode: \"lookup\" })),\n );\n for (const vec of batchResults) {\n if (!vec) {\n throw new Error(\"Embedding returned null for input text\");\n }\n vectors.push(vec);\n }\n }\n return vectors;\n }\n\n /**\n * Nearest-neighbor search against the embedding index.\n *\n * @param query The query string to embed and search for.\n * @param limit Max number of hits to return.\n * @param options Optional filters.\n * - `pathPrefix` Restrict candidates to entries whose indexed `path`\n * starts with this prefix (relative to `memoryDir`).\n * Used by the semantic dedup guard to scope lookups\n * to the target namespace so a high-similarity hit\n * from a different namespace can't suppress a write\n * in the target namespace. Default: no filter.\n * - `pathExcludePrefixes`\n * Exclude any entry whose indexed `path` starts with\n * any of these prefixes. Used for the default\n * namespace case: when the default namespace lives at\n * `memoryDir` root (legacy layout) we still want to\n * exclude `namespaces/<other>/…` entries.\n */\n async search(\n query: string,\n limit: number,\n options: {\n pathPrefix?: string;\n pathExcludePrefixes?: readonly string[];\n /**\n * When true, an `EmbeddingTimeoutError` from the embedding backend is\n * re-thrown to the caller. Use this on the semantic-dedup path so\n * `decideSemanticDedup`'s catch block can classify the result as\n * `reason=\"backend_unavailable\"` and activate the per-batch\n * short-circuit.\n *\n * When false (the default), a timeout is caught here and search()\n * returns [] instead — preserving fail-open semantics for the recall\n * path (`searchEmbeddingFallback`) which has no surrounding try/catch.\n * Without this gate a timed-out embedding request on the recall path\n * would propagate as an unhandled rejection and abort recall entirely.\n * (Round 10 fix, Findings Ui1J + Ui1L.)\n */\n throwOnTimeout?: boolean;\n } = {},\n ): Promise<Array<{ id: string; score: number; path: string }>> {\n const provider = await this.resolveProvider();\n if (!provider) return [];\n\n const index = await this.loadIndex(provider);\n const ids = Object.keys(index.entries);\n if (ids.length === 0) return [];\n\n let queryVector: number[] | null;\n try {\n queryVector = await this.embed(query, provider, { mode: \"lookup\" });\n } catch (err) {\n if (err instanceof EmbeddingTimeoutError) {\n if (options.throwOnTimeout) {\n throw err;\n }\n // Fail-open: recall-path callers get an empty result rather than an\n // unhandled rejection that would abort recall entirely.\n log.debug(\"embedding fallback search: timeout on lookup, returning [] (throwOnTimeout=false)\");\n return [];\n }\n throw err;\n }\n if (!queryVector) return [];\n\n const includePrefix = normalizePathPrefix(options.pathPrefix);\n const excludePrefixes = (options.pathExcludePrefixes ?? [])\n .map((p) => normalizePathPrefix(p))\n .filter((p): p is string => typeof p === \"string\");\n\n const scored = ids\n .map((id) => {\n const entry = index.entries[id];\n return {\n id,\n path: entry.path,\n score: cosineSimilarity(queryVector, entry.vector),\n };\n })\n .filter((r) => {\n if (!Number.isFinite(r.score)) return false;\n const normalized = normalizeEntryPath(r.path);\n if (includePrefix !== undefined && !normalized.startsWith(includePrefix)) {\n return false;\n }\n for (const excl of excludePrefixes) {\n if (normalized.startsWith(excl)) return false;\n }\n return true;\n })\n .sort((a, b) => b.score - a.score)\n .slice(0, Math.max(1, limit));\n\n return scored;\n }\n\n async indexFile(memoryId: string, content: string, filePath: string): Promise<void> {\n const provider = await this.resolveProvider();\n if (!provider) return;\n // Indexing is not on the write-critical path: a newly persisted memory\n // has already been written to disk by the time we reach this call. Use\n // the long \"index\" timeout so slow local embedding backends can still\n // add the entry to the index. Previously this used the short lookup\n // budget and silently dropped updates, leaving later dedup lookups\n // blind to the memory. Related: PR #399 P2.\n const vector = await this.embed(content, provider, { mode: \"index\" });\n if (!vector) return;\n\n const index = await this.loadIndex(provider);\n const relPath = toMemoryRelativePath(this.config.memoryDir, filePath);\n index.entries[memoryId] = {\n vector,\n path: relPath,\n };\n await this.saveIndex(index);\n }\n\n async removeFromIndex(memoryId: string): Promise<void> {\n const provider = await this.resolveProvider();\n if (!provider) return;\n\n const index = await this.loadIndex(provider);\n if (!index.entries[memoryId]) return;\n delete index.entries[memoryId];\n await this.saveIndex(index);\n }\n\n private async resolveProvider(): Promise<ProviderConfig | null> {\n if (!this.config.embeddingFallbackEnabled) return null;\n\n const preferred = this.config.embeddingFallbackProvider;\n const providers = preferred === \"auto\" ? [\"openai\", \"local\"] : [preferred];\n\n for (const p of providers) {\n if (p === \"openai\" && this.config.openaiApiKey) {\n const baseUrl = this.config.openaiBaseUrl ?? \"https://api.openai.com/v1\";\n return {\n type: \"openai\",\n model: DEFAULT_OPENAI_MODEL,\n endpoint: `${baseUrl.replace(/\\/$/, \"\")}/embeddings`,\n headers: {\n \"Content-Type\": \"application/json\",\n Authorization: `Bearer ${this.config.openaiApiKey}`,\n },\n };\n }\n\n if (p === \"local\" && this.config.localLlmEnabled && this.config.localLlmUrl) {\n const base = this.config.localLlmUrl.replace(/\\/$/, \"\");\n const endpoint = /\\/v1$/i.test(base) ? `${base}/embeddings` : `${base}/v1/embeddings`;\n const headers: Record<string, string> = {\n \"Content-Type\": \"application/json\",\n ...(this.config.localLlmHeaders ?? {}),\n };\n if (this.config.localLlmApiKey && this.config.localLlmAuthHeader !== false) {\n headers.Authorization = `Bearer ${this.config.localLlmApiKey}`;\n }\n return {\n type: \"local\",\n model: this.config.localLlmModel || DEFAULT_OPENAI_MODEL,\n endpoint,\n headers,\n };\n }\n }\n\n return null;\n }\n\n private async embed(\n input: string,\n provider: ProviderConfig,\n options: { mode?: EmbedMode } = {},\n ): Promise<number[] | null> {\n // Bound the fetch so a hung embedding endpoint cannot stall callers.\n // The lookup path uses a short budget (see DEFAULT_EMBEDDING_LOOKUP_TIMEOUT_MS\n // docblock) so semantic dedup fails open fast. The index path uses a\n // much longer budget because slow local backends (CPU embedding models)\n // otherwise drop index updates and blind later dedup lookups. See\n // DEFAULT_EMBEDDING_INDEX_TIMEOUT_MS docblock and PR #399 P2 review.\n const mode: EmbedMode = options.mode ?? \"lookup\";\n const timeoutMs =\n mode === \"index\"\n ? resolveEmbeddingIndexTimeoutMs()\n : resolveEmbeddingLookupTimeoutMs();\n try {\n const res = await fetch(provider.endpoint, {\n method: \"POST\",\n headers: provider.headers,\n body: JSON.stringify({\n model: provider.model,\n input: input.slice(0, 8000),\n encoding_format: \"float\",\n }),\n signal: AbortSignal.timeout(timeoutMs),\n });\n if (!res.ok) {\n log.debug(`embedding fallback request failed: ${provider.type} ${res.status}`);\n // Round 11 fix (Finding Ur_J): on the LOOKUP path, a non-2xx response\n // means the embedding backend is effectively unavailable. Throw the\n // tagged error so search() (when called with throwOnTimeout) propagates\n // to decideSemanticDedup's backend_unavailable branch, activating the\n // per-batch short-circuit. Without this, repeated 429/5xx responses\n // would silently return [] for every fact in the batch.\n //\n // On the INDEX path a non-2xx is non-fatal (the memory is already\n // persisted; index update can be skipped) — return null there.\n if (mode === \"lookup\") {\n throw new EmbeddingTimeoutError(\n `embedding backend returned ${res.status} (${provider.type})`,\n );\n }\n return null;\n }\n const payload = (await res.json()) as any;\n const vector = payload?.data?.[0]?.embedding;\n if (!Array.isArray(vector)) return null;\n return vector.map((n: unknown) => Number(n)).filter((n: number) => Number.isFinite(n));\n } catch (err) {\n // Round 11 (Finding Ur_J): the !res.ok branch above throws\n // EmbeddingTimeoutError directly. Re-throw it here so the catch does\n // not swallow our own intentional signal back into a null return.\n if (err instanceof EmbeddingTimeoutError) {\n throw err;\n }\n // AbortSignal.timeout throws a DOMException with name \"TimeoutError\";\n // surface at warn level so operators can distinguish slow backends from\n // generic errors.\n const isTimeout =\n err instanceof Error &&\n (err.name === \"TimeoutError\" || err.name === \"AbortError\");\n if (isTimeout) {\n log.warn(\n `embedding fallback fetch timed out after ${timeoutMs}ms (${provider.type}, mode=${mode})`,\n );\n // Round 9 fix (Finding UZqB): on the LOOKUP path a timeout means the\n // embedding backend is effectively unavailable — re-throw so that\n // search() propagates the error to semanticDedupLookup, which lets it\n // reach decideSemanticDedup's catch block and return\n // reason=\"backend_unavailable\". Without this, search() would silently\n // return [] and the per-batch batchBackendUnavailable flag would never\n // flip, causing subsequent facts in the same batch to each pay a full\n // timeout roundtrip (N × timeout instead of 1 × timeout).\n //\n // On the INDEX path a timeout is not fatal (the memory is already\n // persisted; index update can be skipped) — return null there so\n // indexFile() stays non-blocking.\n if (mode === \"lookup\") {\n throw new EmbeddingTimeoutError(\n `embedding backend timed out after ${timeoutMs}ms (${provider.type})`,\n );\n }\n } else {\n // Round 12 fix (PR #399 thread PRRT_kwDORJXyws56U6Gi): non-timeout\n // transport failures (ECONNREFUSED, DNS errors, TLS failures) are just\n // as fatal as timeouts on the LOOKUP path — the embedding backend is\n // effectively unreachable. Throw EmbeddingTimeoutError so that\n // search() (when called with throwOnTimeout:true) propagates the error\n // to decideSemanticDedup's backend_unavailable branch, activating the\n // per-batch short-circuit. Without this, each fact in the batch would\n // pay a full ECONNREFUSED roundtrip and return null → [] → no_candidates,\n // preventing batchBackendUnavailable from ever being set.\n //\n // On the INDEX path a transport failure is non-fatal — the memory is\n // already persisted; index update can be safely skipped.\n if (mode === \"lookup\") {\n log.warn(\n `embedding fallback transport error on lookup path (${provider.type}): ${err}`,\n );\n throw new EmbeddingTimeoutError(\n `embedding backend transport failure (${provider.type}): ${err instanceof Error ? err.message : String(err)}`,\n );\n }\n log.debug(`embedding fallback error: ${err}`);\n }\n return null;\n }\n }\n\n private async loadIndex(provider: ProviderConfig): Promise<EmbeddingIndexFile> {\n if (this.loaded && this.loaded.provider === provider.type && this.loaded.model === provider.model) {\n return this.loaded;\n }\n\n try {\n const raw = await readFile(this.indexPath, \"utf-8\");\n const parsed = JSON.parse(raw) as EmbeddingIndexFile;\n if (parsed && parsed.version === 1 && parsed.entries && typeof parsed.entries === \"object\") {\n this.loaded = {\n version: 1,\n provider: provider.type,\n model: provider.model,\n entries: parsed.entries,\n };\n return this.loaded;\n }\n } catch {\n // ignore and create a new index\n }\n\n this.loaded = {\n version: 1,\n provider: provider.type,\n model: provider.model,\n entries: {},\n };\n return this.loaded;\n }\n\n private async saveIndex(index: EmbeddingIndexFile): Promise<void> {\n await mkdir(path.dirname(this.indexPath), { recursive: true });\n await writeFile(this.indexPath, JSON.stringify(index), \"utf-8\");\n this.loaded = index;\n }\n}\n\nfunction toMemoryRelativePath(memoryDir: string, filePath: string): string {\n if (!path.isAbsolute(filePath)) return filePath;\n const rel = path.relative(memoryDir, filePath);\n return rel.startsWith(\"..\") ? filePath : rel;\n}\n\n/**\n * Normalize an index entry path to forward-slashes for stable prefix\n * comparison. Entries are stored as `path.relative(memoryDir, …)` output,\n * which on Windows uses back-slashes. Normalize both sides so prefix\n * matching is OS-independent.\n *\n * Also strip a leading `./` so this helper's output is symmetric with\n * `normalizePathPrefix` below. `toMemoryRelativePath` is a pass-through for\n * non-absolute filePath inputs, so an index entry could legitimately carry a\n * stored path like `\"./namespaces/alpha/facts/f.md\"`. Without this strip, a\n * caller-supplied prefix `\"./namespaces/alpha\"` (which `normalizePathPrefix`\n * rewrites to `\"namespaces/alpha/\"`) would silently miss that entry and\n * namespace-scoped dedup would either let a near-duplicate through or fail\n * to exclude a cross-namespace hit.\n */\nfunction normalizeEntryPath(p: string): string {\n let out = p.replace(/\\\\/g, \"/\");\n if (out.startsWith(\"./\")) out = out.slice(2);\n return out;\n}\n\n/**\n * Normalize a caller-supplied path prefix:\n * - Return `undefined` for nullish/empty input (no filter).\n * - Replace back-slashes with forward-slashes.\n * - Strip a leading `./`.\n * - Ensure a trailing `/` so `\"namespaces/a\"` doesn't accidentally match\n * `\"namespaces/another/…\"`.\n */\nfunction normalizePathPrefix(prefix: string | undefined): string | undefined {\n if (prefix === undefined || prefix === null) return undefined;\n let p = String(prefix).replace(/\\\\/g, \"/\");\n if (p.startsWith(\"./\")) p = p.slice(2);\n if (p.length === 0) return undefined;\n if (!p.endsWith(\"/\")) p = `${p}/`;\n return p;\n}\n\nfunction cosineSimilarity(a: number[], b: number[]): number {\n const n = Math.min(a.length, b.length);\n if (n === 0) return 0;\n let dot = 0;\n let normA = 0;\n let normB = 0;\n for (let i = 0; i < n; i++) {\n const av = a[i] ?? 0;\n const bv = b[i] ?? 0;\n dot += av * bv;\n normA += av * av;\n normB += bv * bv;\n }\n const denom = Math.sqrt(normA) * Math.sqrt(normB);\n if (denom === 0) return 0;\n return dot / denom;\n}\n\n"],"mappings":";;;;;AAAA,OAAO,UAAU;AACjB,SAAS,OAAO,UAAU,iBAAiB;AAyB3C,IAAM,uBAAuB;AA+BtB,IAAM,wBAAN,cAAoC,MAAM;AAAA,EAC7B,OAAO;AAAA,EACzB,YAAY,SAAiB;AAC3B,UAAM,OAAO;AAAA,EACf;AACF;AAmBA,IAAM,sCAAsC;AAe5C,IAAM,qCAAqC;AAE3C,SAAS,kCAA0C;AACjD,QAA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