@remnic/core 9.3.768 → 9.3.770

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 (162) hide show
  1. package/dist/access-admin-ops-surface.js +29 -29
  2. package/dist/access-boundary.d.ts +2 -1
  3. package/dist/access-boundary.js +30 -30
  4. package/dist/access-cli.js +85 -83
  5. package/dist/access-cli.js.map +1 -1
  6. package/dist/access-errors.d.ts +5 -0
  7. package/dist/access-errors.js +8 -0
  8. package/dist/access-errors.js.map +1 -0
  9. package/dist/access-http.d.ts +51 -1
  10. package/dist/access-http.js +38 -36
  11. package/dist/access-identity-continuity-surface.js +29 -29
  12. package/dist/access-lcm-surface.js +29 -29
  13. package/dist/access-mcp.d.ts +7 -1
  14. package/dist/access-mcp.js +41 -37
  15. package/dist/access-observe-write-surface.js +29 -29
  16. package/dist/access-operations-batch.js +34 -32
  17. package/dist/access-operations.d.ts +4 -4
  18. package/dist/access-operations.js +36 -34
  19. package/dist/access-recall-surface.js +29 -29
  20. package/dist/access-schema.d.ts +68 -68
  21. package/dist/access-service.js +29 -29
  22. package/dist/access-surface-catalog.js +1 -0
  23. package/dist/access-surface-catalog.js.map +1 -1
  24. package/dist/active-recall.js +5 -5
  25. package/dist/auto-sync-2SOUW4JW.js +1 -1
  26. package/dist/briefing.js +7 -7
  27. package/dist/causal-behavior.js +5 -5
  28. package/dist/causal-chain.js +3 -3
  29. package/dist/causal-consolidation.js +11 -11
  30. package/dist/causal-retrieval.js +3 -3
  31. package/dist/causal-trajectory.js +1 -1
  32. package/dist/{chunk-R3K4CXPR.js → chunk-3JOFWTQD.js} +2 -2
  33. package/dist/{chunk-QOGXUNWL.js → chunk-3O3BZNSH.js} +4 -4
  34. package/dist/{chunk-SFNQDXXL.js → chunk-3YYWUHA7.js} +3 -3
  35. package/dist/{chunk-GLERZDM7.js → chunk-52TEPNL7.js} +29 -7
  36. package/dist/chunk-52TEPNL7.js.map +1 -0
  37. package/dist/{chunk-N4ZA2I7M.js → chunk-5ACKQLGA.js} +2 -2
  38. package/dist/{chunk-YDYC6PIS.js → chunk-5QJZLJ7Q.js} +2 -2
  39. package/dist/{chunk-ORAK3LNZ.js → chunk-6SHAUM5S.js} +5 -5
  40. package/dist/{chunk-CKNAVW34.js → chunk-7OSULYN2.js} +2 -2
  41. package/dist/{chunk-PA5ALD3S.js → chunk-7XGF5HCC.js} +106 -86
  42. package/dist/chunk-7XGF5HCC.js.map +1 -0
  43. package/dist/{chunk-6T4LTI2F.js → chunk-7XH7VJN4.js} +4 -4
  44. package/dist/{chunk-OX272PBW.js → chunk-CSHUSYUM.js} +2 -2
  45. package/dist/{chunk-UG274TNV.js → chunk-E2SPGGUI.js} +13 -8
  46. package/dist/chunk-E2SPGGUI.js.map +1 -0
  47. package/dist/{chunk-HBOPSFQQ.js → chunk-E6LXM2GE.js} +41 -41
  48. package/dist/{chunk-OAREUC7N.js → chunk-EWGMA5W5.js} +28 -28
  49. package/dist/{chunk-YNDLCWXS.js → chunk-EZ25VE3G.js} +4 -4
  50. package/dist/chunk-FTYDWKO6.js +101 -0
  51. package/dist/chunk-FTYDWKO6.js.map +1 -0
  52. package/dist/{chunk-2RLECZ6J.js → chunk-IOENSSZC.js} +2 -2
  53. package/dist/{chunk-VKHZFF5P.js → chunk-KFIAFHOC.js} +2 -2
  54. package/dist/{chunk-NDXJJKT2.js → chunk-KMKBD66B.js} +2 -2
  55. package/dist/{chunk-SQNED75R.js → chunk-KYC3RLYJ.js} +1 -1
  56. package/dist/{chunk-V5RVMULT.js → chunk-MLDAD27I.js} +7 -7
  57. package/dist/{chunk-IGVKWKR2.js → chunk-O5EKTMOJ.js} +6 -6
  58. package/dist/{chunk-TVLN5EZZ.js → chunk-OP43P53G.js} +83 -8
  59. package/dist/chunk-OP43P53G.js.map +1 -0
  60. package/dist/{chunk-4HYFKIGH.js → chunk-PSNMICC2.js} +4 -4
  61. package/dist/{chunk-IVFIYAIP.js → chunk-QKUWPSU3.js} +5 -5
  62. package/dist/{chunk-4DLFJJOQ.js → chunk-QMN3CIFS.js} +2 -2
  63. package/dist/chunk-RANHFI3P.js +8 -0
  64. package/dist/chunk-RANHFI3P.js.map +1 -0
  65. package/dist/{chunk-AS2NRB45.js → chunk-RZ3KJZYE.js} +2 -2
  66. package/dist/{chunk-4JG55YV3.js → chunk-SRSPVFSJ.js} +3 -3
  67. package/dist/{chunk-DTTVX6EO.js → chunk-STN5KMSS.js} +12 -12
  68. package/dist/{chunk-J3UJJZKI.js → chunk-TGROC2UP.js} +108 -7
  69. package/dist/chunk-TGROC2UP.js.map +1 -0
  70. package/dist/{chunk-QPTP6SKC.js → chunk-U72WWTLR.js} +2 -2
  71. package/dist/{chunk-U5GFYMV7.js → chunk-W7VA5667.js} +3 -3
  72. package/dist/{chunk-X7HTU4HO.js → chunk-WB4CFKZ4.js} +2 -2
  73. package/dist/{chunk-NFWTMM2M.js → chunk-XDRJQMYL.js} +2 -2
  74. package/dist/{chunk-CVINPTKG.js → chunk-ZG4FT6IT.js} +5 -5
  75. package/dist/{chunk-MSGPLITO.js → chunk-ZT34X56N.js} +2 -2
  76. package/dist/{chunk-MSGPLITO.js.map → chunk-ZT34X56N.js.map} +1 -1
  77. package/dist/cli.js +58 -56
  78. package/dist/compounding/engine.js +7 -7
  79. package/dist/config.js +2 -2
  80. package/dist/connectors/codex-materialize-runner.js +7 -7
  81. package/dist/connectors/index.js +9 -9
  82. package/dist/consolidation-provenance-check.js +2 -2
  83. package/dist/dashboard-runtime.js +2 -2
  84. package/dist/entity-retrieval.js +7 -7
  85. package/dist/extraction.js +3 -3
  86. package/dist/index.d.ts +1 -1
  87. package/dist/index.js +141 -133
  88. package/dist/lcm/engine.js +3 -3
  89. package/dist/lcm/index.js +11 -11
  90. package/dist/maintenance/memory-governance.js +8 -8
  91. package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +7 -7
  92. package/dist/maintenance/rebuild-memory-projection.js +9 -9
  93. package/dist/namespaces/migrate.js +12 -12
  94. package/dist/namespaces/search.js +4 -4
  95. package/dist/namespaces/storage.js +7 -7
  96. package/dist/operator-toolkit.js +17 -17
  97. package/dist/orchestration/maintenance.js +9 -9
  98. package/dist/orchestrator.js +85 -83
  99. package/dist/recall-timings.d.ts +26 -0
  100. package/dist/recall-timings.js +16 -0
  101. package/dist/recall-timings.js.map +1 -0
  102. package/dist/resume-bundles.js +3 -3
  103. package/dist/schemas.d.ts +84 -84
  104. package/dist/search/factory.js +3 -3
  105. package/dist/search/index.js +7 -7
  106. package/dist/semantic-consolidation.js +10 -10
  107. package/dist/semantic-rule-promotion.js +7 -7
  108. package/dist/semantic-rule-verifier.js +8 -8
  109. package/dist/shared-context/manager.d.ts +8 -8
  110. package/dist/storage.js +8 -8
  111. package/dist/tokens.d.ts +3 -1
  112. package/dist/tokens.js +3 -1
  113. package/dist/transfer/types.d.ts +66 -66
  114. package/dist/verified-recall.js +8 -8
  115. package/package.json +2 -2
  116. package/src/access-boundary.ts +2 -0
  117. package/src/access-errors.ts +2 -0
  118. package/src/access-http.test.ts +350 -0
  119. package/src/access-http.ts +192 -7
  120. package/src/access-mcp.ts +120 -3
  121. package/src/access-operations-batch.ts +19 -0
  122. package/src/access-surface-catalog.ts +1 -0
  123. package/src/index.ts +3 -0
  124. package/src/orchestration/recall-internal.ts +21 -3
  125. package/src/recall-timings-access.test.ts +301 -0
  126. package/src/recall-timings.ts +141 -0
  127. package/src/tokens.test.ts +58 -0
  128. package/src/tokens.ts +19 -8
  129. package/dist/chunk-GLERZDM7.js.map +0 -1
  130. package/dist/chunk-J3UJJZKI.js.map +0 -1
  131. package/dist/chunk-PA5ALD3S.js.map +0 -1
  132. package/dist/chunk-TVLN5EZZ.js.map +0 -1
  133. package/dist/chunk-UG274TNV.js.map +0 -1
  134. /package/dist/{chunk-R3K4CXPR.js.map → chunk-3JOFWTQD.js.map} +0 -0
  135. /package/dist/{chunk-QOGXUNWL.js.map → chunk-3O3BZNSH.js.map} +0 -0
  136. /package/dist/{chunk-SFNQDXXL.js.map → chunk-3YYWUHA7.js.map} +0 -0
  137. /package/dist/{chunk-N4ZA2I7M.js.map → chunk-5ACKQLGA.js.map} +0 -0
  138. /package/dist/{chunk-YDYC6PIS.js.map → chunk-5QJZLJ7Q.js.map} +0 -0
  139. /package/dist/{chunk-ORAK3LNZ.js.map → chunk-6SHAUM5S.js.map} +0 -0
  140. /package/dist/{chunk-CKNAVW34.js.map → chunk-7OSULYN2.js.map} +0 -0
  141. /package/dist/{chunk-6T4LTI2F.js.map → chunk-7XH7VJN4.js.map} +0 -0
  142. /package/dist/{chunk-OX272PBW.js.map → chunk-CSHUSYUM.js.map} +0 -0
  143. /package/dist/{chunk-HBOPSFQQ.js.map → chunk-E6LXM2GE.js.map} +0 -0
  144. /package/dist/{chunk-OAREUC7N.js.map → chunk-EWGMA5W5.js.map} +0 -0
  145. /package/dist/{chunk-YNDLCWXS.js.map → chunk-EZ25VE3G.js.map} +0 -0
  146. /package/dist/{chunk-2RLECZ6J.js.map → chunk-IOENSSZC.js.map} +0 -0
  147. /package/dist/{chunk-VKHZFF5P.js.map → chunk-KFIAFHOC.js.map} +0 -0
  148. /package/dist/{chunk-NDXJJKT2.js.map → chunk-KMKBD66B.js.map} +0 -0
  149. /package/dist/{chunk-SQNED75R.js.map → chunk-KYC3RLYJ.js.map} +0 -0
  150. /package/dist/{chunk-V5RVMULT.js.map → chunk-MLDAD27I.js.map} +0 -0
  151. /package/dist/{chunk-IGVKWKR2.js.map → chunk-O5EKTMOJ.js.map} +0 -0
  152. /package/dist/{chunk-4HYFKIGH.js.map → chunk-PSNMICC2.js.map} +0 -0
  153. /package/dist/{chunk-IVFIYAIP.js.map → chunk-QKUWPSU3.js.map} +0 -0
  154. /package/dist/{chunk-4DLFJJOQ.js.map → chunk-QMN3CIFS.js.map} +0 -0
  155. /package/dist/{chunk-AS2NRB45.js.map → chunk-RZ3KJZYE.js.map} +0 -0
  156. /package/dist/{chunk-4JG55YV3.js.map → chunk-SRSPVFSJ.js.map} +0 -0
  157. /package/dist/{chunk-DTTVX6EO.js.map → chunk-STN5KMSS.js.map} +0 -0
  158. /package/dist/{chunk-QPTP6SKC.js.map → chunk-U72WWTLR.js.map} +0 -0
  159. /package/dist/{chunk-U5GFYMV7.js.map → chunk-W7VA5667.js.map} +0 -0
  160. /package/dist/{chunk-X7HTU4HO.js.map → chunk-WB4CFKZ4.js.map} +0 -0
  161. /package/dist/{chunk-NFWTMM2M.js.map → chunk-XDRJQMYL.js.map} +0 -0
  162. /package/dist/{chunk-CVINPTKG.js.map → chunk-ZG4FT6IT.js.map} +0 -0
@@ -1,3 +1,6 @@
1
+ import {
2
+ LanceDbBackend
3
+ } from "./chunk-K2I3AWBR.js";
1
4
  import {
2
5
  MeilisearchBackend
3
6
  } from "./chunk-DMKMQTBH.js";
@@ -13,9 +16,6 @@ import {
13
16
  import {
14
17
  EmbedHelper
15
18
  } from "./chunk-HM6UJPPO.js";
16
- import {
17
- LanceDbBackend
18
- } from "./chunk-K2I3AWBR.js";
19
19
  import {
20
20
  createConversationIndexBackend
21
21
  } from "./chunk-DCWIQFNA.js";
@@ -175,4 +175,4 @@ export {
175
175
  createConversationSearchBackend,
176
176
  createConversationIndexRuntime
177
177
  };
178
- //# sourceMappingURL=chunk-4HYFKIGH.js.map
178
+ //# sourceMappingURL=chunk-PSNMICC2.js.map
@@ -1,15 +1,15 @@
1
1
  import {
2
2
  StorageManager
3
- } from "./chunk-DTTVX6EO.js";
3
+ } from "./chunk-STN5KMSS.js";
4
4
  import {
5
5
  assertPathInsideRoot
6
6
  } from "./chunk-5GPPACXK.js";
7
- import {
8
- decideLifecycleTransition
9
- } from "./chunk-TBBDFYXW.js";
10
7
  import {
11
8
  RECALL_FALLBACK_DIRS
12
9
  } from "./chunk-VS2IYZRU.js";
10
+ import {
11
+ decideLifecycleTransition
12
+ } from "./chunk-TBBDFYXW.js";
13
13
 
14
14
  // src/maintenance/memory-governance.ts
15
15
  import path from "path";
@@ -751,4 +751,4 @@ export {
751
751
  listMemoryGovernanceRuns,
752
752
  readMemoryGovernanceRunArtifact
753
753
  };
754
- //# sourceMappingURL=chunk-IVFIYAIP.js.map
754
+ //# sourceMappingURL=chunk-QKUWPSU3.js.map
@@ -5,7 +5,7 @@ import {
5
5
  loadTokenStore,
6
6
  revokeToken,
7
7
  saveTokenStore
8
- } from "./chunk-UG274TNV.js";
8
+ } from "./chunk-E2SPGGUI.js";
9
9
  import {
10
10
  getConnectorsDir,
11
11
  getRegistryPath
@@ -2257,4 +2257,4 @@ export {
2257
2257
  resolveWeCloneProxyConfigPath,
2258
2258
  buildWeCloneProxyConfig
2259
2259
  };
2260
- //# sourceMappingURL=chunk-4DLFJJOQ.js.map
2260
+ //# sourceMappingURL=chunk-QMN3CIFS.js.map
@@ -0,0 +1,8 @@
1
+ // src/access-errors.ts
2
+ var EngramAccessForbiddenError = class extends Error {
3
+ };
4
+
5
+ export {
6
+ EngramAccessForbiddenError
7
+ };
8
+ //# sourceMappingURL=chunk-RANHFI3P.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/access-errors.ts"],"sourcesContent":["/** Authenticated caller lacks the required authorization (HTTP 403). */\nexport class EngramAccessForbiddenError extends Error {}\n"],"mappings":";AACO,IAAM,6BAAN,cAAyC,MAAM;AAAC;","names":[]}
@@ -4,7 +4,7 @@ import {
4
4
  import {
5
5
  compareEntityTimestamps,
6
6
  normalizeEntityName
7
- } from "./chunk-DTTVX6EO.js";
7
+ } from "./chunk-STN5KMSS.js";
8
8
  import {
9
9
  resolveNamespaceCapabilities
10
10
  } from "./chunk-VSF7AAGE.js";
@@ -682,4 +682,4 @@ export {
682
682
  entityIndexVersion,
683
683
  entityRecentTranscriptLookbackHours
684
684
  };
685
- //# sourceMappingURL=chunk-AS2NRB45.js.map
685
+ //# sourceMappingURL=chunk-RZ3KJZYE.js.map
@@ -3,14 +3,14 @@ import {
3
3
  } from "./chunk-2MR3MFQB.js";
4
4
  import {
5
5
  defineOperation
6
- } from "./chunk-MSGPLITO.js";
6
+ } from "./chunk-ZT34X56N.js";
7
7
  import {
8
8
  CorrectionContractError,
9
9
  DECISION_SUBCOMMANDS,
10
10
  DELTA_SUBCOMMANDS,
11
11
  EngramAccessInputError,
12
12
  isCodegraphToolName
13
- } from "./chunk-OAREUC7N.js";
13
+ } from "./chunk-EWGMA5W5.js";
14
14
 
15
15
  // src/access-operations.ts
16
16
  import { z } from "zod";
@@ -463,4 +463,4 @@ export {
463
463
  codegraphIngestTracesOperation,
464
464
  REGISTERED_OPERATIONS
465
465
  };
466
- //# sourceMappingURL=chunk-4JG55YV3.js.map
466
+ //# sourceMappingURL=chunk-SRSPVFSJ.js.map
@@ -1,18 +1,21 @@
1
- import {
2
- WEARABLES_DIR_NAME,
3
- isValidTranscriptDate
4
- } from "./chunk-M7XQSUBB.js";
5
1
  import {
6
2
  TombstoneStore,
7
3
  buildRetiredFactTombstoneInputs,
8
4
  collectRetiredMemoriesForRebuild
9
5
  } from "./chunk-L2B3EE7B.js";
6
+ import {
7
+ WEARABLES_DIR_NAME,
8
+ isValidTranscriptDate
9
+ } from "./chunk-M7XQSUBB.js";
10
10
  import {
11
11
  isErrnoCode
12
12
  } from "./chunk-5UZXUTVO.js";
13
13
  import {
14
14
  assertPathInsideRoot
15
15
  } from "./chunk-5GPPACXK.js";
16
+ import {
17
+ stripAttributesSuffix
18
+ } from "./chunk-SVOZFLIQ.js";
16
19
  import {
17
20
  supersessionKeysForFact
18
21
  } from "./chunk-TKZ3AL5V.js";
@@ -25,9 +28,6 @@ import {
25
28
  assertMemoryFrontmatterId,
26
29
  warnProjectionFallback
27
30
  } from "./chunk-DQC3ZZYM.js";
28
- import {
29
- stripAttributesSuffix
30
- } from "./chunk-SVOZFLIQ.js";
31
31
  import {
32
32
  SPECULATIVE_TTL_DAYS,
33
33
  confidenceTier
@@ -71,6 +71,10 @@ import {
71
71
  parseFaithfulnessField,
72
72
  serializeFaithfulnessFields
73
73
  } from "./chunk-YTU7WKYN.js";
74
+ import {
75
+ isConsolidationOperator,
76
+ isValidDerivedFromEntry
77
+ } from "./chunk-G7D6GZ5J.js";
74
78
  import {
75
79
  createVersion
76
80
  } from "./chunk-VF4XKTX3.js";
@@ -78,10 +82,6 @@ import {
78
82
  computeContentHash,
79
83
  normalizeContent
80
84
  } from "./chunk-W5H6ZRPT.js";
81
- import {
82
- isConsolidationOperator,
83
- isValidDerivedFromEntry
84
- } from "./chunk-G7D6GZ5J.js";
85
85
  import {
86
86
  parseProvenanceSources,
87
87
  parseProvenanceTag,
@@ -6154,4 +6154,4 @@ export {
6154
6154
  isValidBufferSurpriseEvent,
6155
6155
  StorageManager3 as StorageManager
6156
6156
  };
6157
- //# sourceMappingURL=chunk-DTTVX6EO.js.map
6157
+ //# sourceMappingURL=chunk-STN5KMSS.js.map
@@ -6,22 +6,23 @@ import {
6
6
  } from "./chunk-JBPKEARU.js";
7
7
  import {
8
8
  EngramMcpServer,
9
+ MCP_SUPPORTED_PROTOCOL_VERSIONS,
9
10
  cleanupExpiredChatSessions,
10
11
  loadChatSession,
11
12
  processChatMessage,
12
13
  sessionBelongsToPrincipal,
13
14
  subscribeChatTranscript
14
- } from "./chunk-TVLN5EZZ.js";
15
+ } from "./chunk-OP43P53G.js";
15
16
  import {
16
17
  validateRequest
17
18
  } from "./chunk-2MR3MFQB.js";
18
19
  import {
19
20
  getOperation
20
- } from "./chunk-MSGPLITO.js";
21
+ } from "./chunk-ZT34X56N.js";
21
22
  import {
22
23
  CorrectionContractError,
23
24
  EngramAccessInputError
24
- } from "./chunk-OAREUC7N.js";
25
+ } from "./chunk-EWGMA5W5.js";
25
26
  import {
26
27
  isTrustZoneName
27
28
  } from "./chunk-JGSKJHF7.js";
@@ -49,6 +50,9 @@ import {
49
50
  abortError,
50
51
  isAbortError
51
52
  } from "./chunk-PVGDJXVK.js";
53
+ import {
54
+ EngramAccessForbiddenError
55
+ } from "./chunk-RANHFI3P.js";
52
56
 
53
57
  // src/access-http.ts
54
58
  import { createServer } from "http";
@@ -272,6 +276,23 @@ function parseHttpServerPort(port) {
272
276
  }
273
277
  return port;
274
278
  }
279
+ function assertResourceMetadataUrl(value) {
280
+ if (value === void 0) return void 0;
281
+ let parsed;
282
+ try {
283
+ parsed = new URL(value);
284
+ } catch {
285
+ throw new Error(
286
+ `access HTTP resourceMetadataUrl must be an absolute http(s) URL, got: ${value}`
287
+ );
288
+ }
289
+ if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
290
+ throw new Error(
291
+ `access HTTP resourceMetadataUrl must use http or https, got: ${parsed.protocol}`
292
+ );
293
+ }
294
+ return value;
295
+ }
275
296
  function parseTrustZoneKindFilter(raw) {
276
297
  if (raw === null) return void 0;
277
298
  if (TRUST_ZONE_RECORD_KINDS.includes(raw)) {
@@ -343,6 +364,8 @@ var EngramAccessHttpServer = class {
343
364
  authToken;
344
365
  authTokens;
345
366
  authTokensGetter;
367
+ authTokenEntriesGetter;
368
+ tokenPathPolicy;
346
369
  authenticatedPrincipal;
347
370
  maxBodyBytes;
348
371
  adminConsoleEnabled;
@@ -352,6 +375,8 @@ var EngramAccessHttpServer = class {
352
375
  trustPrincipalHeader;
353
376
  adapterRegistry;
354
377
  readiness;
378
+ resourceMetadataUrl;
379
+ externalRequestHandler;
355
380
  writeRequestTimestamps = [];
356
381
  mcpServer;
357
382
  server = null;
@@ -381,6 +406,8 @@ var EngramAccessHttpServer = class {
381
406
  this.authToken = options.authToken?.trim() || void 0;
382
407
  this.authTokens = (options.authTokens ?? []).map((t) => t.trim()).filter(Boolean);
383
408
  this.authTokensGetter = options.authTokensGetter;
409
+ this.authTokenEntriesGetter = options.authTokenEntriesGetter;
410
+ this.tokenPathPolicy = options.tokenPathPolicy;
384
411
  this.authenticatedPrincipal = options.principal?.trim() || void 0;
385
412
  this.maxBodyBytes = Number.isFinite(options.maxBodyBytes) ? Math.max(1, Math.floor(options.maxBodyBytes ?? 131072)) : 131072;
386
413
  this.adminConsoleEnabled = options.adminConsoleEnabled !== false;
@@ -389,6 +416,8 @@ var EngramAccessHttpServer = class {
389
416
  this.adminControls = options.adminControls;
390
417
  this.trustPrincipalHeader = options.trustPrincipalHeader === true;
391
418
  this.readiness = options.readiness ?? (() => ({ ready: true, warmupAttempts: 0 }));
419
+ this.resourceMetadataUrl = assertResourceMetadataUrl(options.resourceMetadataUrl);
420
+ this.externalRequestHandler = options.externalRequestHandler;
392
421
  this.adapterRegistry = options.enableAdapters !== false ? options.adapterRegistry ?? new AdapterRegistry() : null;
393
422
  this.mcpServer = new EngramMcpServer(this.service, {
394
423
  principal: options.principal,
@@ -404,7 +433,7 @@ var EngramAccessHttpServer = class {
404
433
  });
405
434
  }
406
435
  async start() {
407
- if (!this.authToken && this.authTokens.length === 0 && !this.authTokensGetter) {
436
+ if (!this.authToken && this.authTokens.length === 0 && !this.authTokensGetter && !this.authTokenEntriesGetter) {
408
437
  throw new Error("engram access HTTP requires authToken or authTokens");
409
438
  }
410
439
  if (this.server) return this.status();
@@ -437,6 +466,10 @@ var EngramAccessHttpServer = class {
437
466
  this.respondJson(res, 400, { error: err.message, code: "input_error" });
438
467
  return;
439
468
  }
469
+ if (err instanceof EngramAccessForbiddenError) {
470
+ this.respondJson(res, 403, { error: err.message, code: "forbidden" });
471
+ return;
472
+ }
440
473
  if (err instanceof CorrectionContractError) {
441
474
  this.respondJson(res, 400, { error: err.message, code: "correction_contract_error" });
442
475
  return;
@@ -647,11 +680,27 @@ var EngramAccessHttpServer = class {
647
680
  return;
648
681
  }
649
682
  }
683
+ if (this.externalRequestHandler) {
684
+ const authorized = this.isAuthorized(req, pathname);
685
+ if (await this.externalRequestHandler(req, res, { authorized })) {
686
+ return;
687
+ }
688
+ }
650
689
  if (!this.isAuthorized(req, pathname)) {
651
690
  const body = JSON.stringify({ error: "unauthorized", code: "unauthorized" });
652
691
  res.writeHead(401, {
653
692
  "content-type": "application/json; charset=utf-8",
654
- "www-authenticate": "Bearer",
693
+ "www-authenticate": this.bearerChallenge(),
694
+ "x-request-id": correlationId
695
+ });
696
+ res.end(body);
697
+ return;
698
+ }
699
+ if (pathname === "/mcp" && (req.method === "GET" || req.method === "DELETE")) {
700
+ const body = JSON.stringify({ error: "method_not_allowed", code: "method_not_allowed" });
701
+ res.writeHead(405, {
702
+ "content-type": "application/json; charset=utf-8",
703
+ allow: "POST",
655
704
  "x-request-id": correlationId
656
705
  });
657
706
  res.end(body);
@@ -1416,6 +1465,20 @@ var EngramAccessHttpServer = class {
1416
1465
  this.respondJson(res, 200, response);
1417
1466
  return;
1418
1467
  }
1468
+ if (req.method === "GET" && pathname === "/engram/v1/recall/timings") {
1469
+ const op = getOperation("recall_timings");
1470
+ if (!op) {
1471
+ throw new Error("access-boundary: operation not registered: recall_timings");
1472
+ }
1473
+ res.setHeader("cache-control", "no-store");
1474
+ const output = await op.run({}, {
1475
+ service: this.service,
1476
+ authenticatedPrincipal: this.resolveRequestPrincipal(req),
1477
+ operatorPrincipal: this.authenticatedPrincipal
1478
+ });
1479
+ this.respondJson(res, 200, output.result);
1480
+ return;
1481
+ }
1419
1482
  const memoryMatch = pathname.match(/^\/engram\/v1\/memories\/([^/]+)$/);
1420
1483
  if (req.method === "GET" && memoryMatch) {
1421
1484
  const memoryId = decodeURIComponent(memoryMatch[1] ?? "");
@@ -2253,6 +2316,20 @@ var EngramAccessHttpServer = class {
2253
2316
  req.once("error", cleanup);
2254
2317
  }
2255
2318
  async handleMcpRequest(req, res) {
2319
+ const headerVersion = req.headers["mcp-protocol-version"];
2320
+ if (typeof headerVersion === "string" && headerVersion.length > 0) {
2321
+ if (!MCP_SUPPORTED_PROTOCOL_VERSIONS.includes(headerVersion)) {
2322
+ this.respondJson(res, 400, {
2323
+ jsonrpc: "2.0",
2324
+ id: null,
2325
+ error: {
2326
+ code: -32e3,
2327
+ message: `unsupported MCP-Protocol-Version: ${headerVersion}; supported: ${MCP_SUPPORTED_PROTOCOL_VERSIONS.join(", ")}`
2328
+ }
2329
+ });
2330
+ return;
2331
+ }
2332
+ }
2256
2333
  const body = await this.readJsonBody(req);
2257
2334
  const request = body;
2258
2335
  const toolName = typeof request.params?.name === "string" ? request.params.name : "";
@@ -2552,8 +2629,23 @@ var EngramAccessHttpServer = class {
2552
2629
  }
2553
2630
  return result.data;
2554
2631
  }
2632
+ /**
2633
+ * Build the WWW-Authenticate challenge string for 401 responses.
2634
+ * When `resourceMetadataUrl` is configured, includes the RFC 9728
2635
+ * `resource_metadata` parameter so MCP clients (e.g. ChatGPT) can
2636
+ * discover the OAuth 2.0 protected-resource metadata document.
2637
+ * Otherwise the bare `Bearer` challenge is returned (unchanged).
2638
+ */
2639
+ bearerChallenge() {
2640
+ if (this.resourceMetadataUrl) {
2641
+ return `Bearer resource_metadata="${this.resourceMetadataUrl}"`;
2642
+ }
2643
+ return "Bearer";
2644
+ }
2555
2645
  isAuthorized(req, pathname) {
2556
- if (!this.authToken && this.authTokens.length === 0 && !this.authTokensGetter) return false;
2646
+ if (!this.authToken && this.authTokens.length === 0 && !this.authTokensGetter && !this.authTokenEntriesGetter) {
2647
+ return false;
2648
+ }
2557
2649
  const raw = req.headers.authorization;
2558
2650
  let candidate = null;
2559
2651
  if (raw) {
@@ -2581,6 +2673,15 @@ var EngramAccessHttpServer = class {
2581
2673
  for (const valid of this.authTokens) {
2582
2674
  if (this.timingSafeStringEqual(token, valid)) return true;
2583
2675
  }
2676
+ if (this.authTokenEntriesGetter) {
2677
+ for (const entry of this.authTokenEntriesGetter()) {
2678
+ if (!this.timingSafeStringEqual(token, entry.token)) continue;
2679
+ if (!this.tokenPathPolicy) return true;
2680
+ if (typeof entry.connector !== "string" || entry.connector.length === 0) return false;
2681
+ return this.tokenPathPolicy(entry.connector, pathname);
2682
+ }
2683
+ return false;
2684
+ }
2584
2685
  if (this.authTokensGetter) {
2585
2686
  for (const valid of this.authTokensGetter()) {
2586
2687
  if (this.timingSafeStringEqual(token, valid)) return true;
@@ -2664,4 +2765,4 @@ function positiveIntQueryParam(value, label) {
2664
2765
  export {
2665
2766
  EngramAccessHttpServer
2666
2767
  };
2667
- //# sourceMappingURL=chunk-J3UJJZKI.js.map
2768
+ //# sourceMappingURL=chunk-TGROC2UP.js.map