daftari 3.7.0 → 3.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (248) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/README.md +4 -0
  3. package/dist/access/rbac.d.ts +1 -0
  4. package/dist/access/rbac.d.ts.map +1 -1
  5. package/dist/access/rbac.js +8 -0
  6. package/dist/access/rbac.js.map +1 -1
  7. package/dist/board/board.d.ts +37 -0
  8. package/dist/board/board.d.ts.map +1 -0
  9. package/dist/board/board.js +233 -0
  10. package/dist/board/board.js.map +1 -0
  11. package/dist/board/board.test.d.ts +2 -0
  12. package/dist/board/board.test.d.ts.map +1 -0
  13. package/dist/board/board.test.js +753 -0
  14. package/dist/board/board.test.js.map +1 -0
  15. package/dist/board/dormancy.test.d.ts +2 -0
  16. package/dist/board/dormancy.test.d.ts.map +1 -0
  17. package/dist/board/dormancy.test.js +79 -0
  18. package/dist/board/dormancy.test.js.map +1 -0
  19. package/dist/board/identity.d.ts +5 -0
  20. package/dist/board/identity.d.ts.map +1 -0
  21. package/dist/board/identity.js +146 -0
  22. package/dist/board/identity.js.map +1 -0
  23. package/dist/board/identity.test.d.ts +2 -0
  24. package/dist/board/identity.test.d.ts.map +1 -0
  25. package/dist/board/identity.test.js +291 -0
  26. package/dist/board/identity.test.js.map +1 -0
  27. package/dist/board/ledger.d.ts +41 -0
  28. package/dist/board/ledger.d.ts.map +1 -0
  29. package/dist/board/ledger.js +197 -0
  30. package/dist/board/ledger.js.map +1 -0
  31. package/dist/board/ledger.test.d.ts +2 -0
  32. package/dist/board/ledger.test.d.ts.map +1 -0
  33. package/dist/board/ledger.test.js +873 -0
  34. package/dist/board/ledger.test.js.map +1 -0
  35. package/dist/board/principals.d.ts +4 -0
  36. package/dist/board/principals.d.ts.map +1 -0
  37. package/dist/board/principals.js +37 -0
  38. package/dist/board/principals.js.map +1 -0
  39. package/dist/board/principals.test.d.ts +2 -0
  40. package/dist/board/principals.test.d.ts.map +1 -0
  41. package/dist/board/principals.test.js +296 -0
  42. package/dist/board/principals.test.js.map +1 -0
  43. package/dist/board/reconcile.d.ts +12 -0
  44. package/dist/board/reconcile.d.ts.map +1 -0
  45. package/dist/board/reconcile.js +293 -0
  46. package/dist/board/reconcile.js.map +1 -0
  47. package/dist/board/reconcile.test.d.ts +2 -0
  48. package/dist/board/reconcile.test.d.ts.map +1 -0
  49. package/dist/board/reconcile.test.js +788 -0
  50. package/dist/board/reconcile.test.js.map +1 -0
  51. package/dist/board/sources/index.d.ts +24 -0
  52. package/dist/board/sources/index.d.ts.map +1 -0
  53. package/dist/board/sources/index.js +64 -0
  54. package/dist/board/sources/index.js.map +1 -0
  55. package/dist/board/sources/lint.d.ts +3 -0
  56. package/dist/board/sources/lint.d.ts.map +1 -0
  57. package/dist/board/sources/lint.js +218 -0
  58. package/dist/board/sources/lint.js.map +1 -0
  59. package/dist/board/sources/lint.test.d.ts +2 -0
  60. package/dist/board/sources/lint.test.d.ts.map +1 -0
  61. package/dist/board/sources/lint.test.js +616 -0
  62. package/dist/board/sources/lint.test.js.map +1 -0
  63. package/dist/board/sources/staged.d.ts +3 -0
  64. package/dist/board/sources/staged.d.ts.map +1 -0
  65. package/dist/board/sources/staged.js +116 -0
  66. package/dist/board/sources/staged.js.map +1 -0
  67. package/dist/board/sources/staged.test.d.ts +2 -0
  68. package/dist/board/sources/staged.test.d.ts.map +1 -0
  69. package/dist/board/sources/staged.test.js +418 -0
  70. package/dist/board/sources/staged.test.js.map +1 -0
  71. package/dist/board/sources/staleness.d.ts +43 -0
  72. package/dist/board/sources/staleness.d.ts.map +1 -0
  73. package/dist/board/sources/staleness.js +346 -0
  74. package/dist/board/sources/staleness.js.map +1 -0
  75. package/dist/board/sources/staleness.test.d.ts +2 -0
  76. package/dist/board/sources/staleness.test.d.ts.map +1 -0
  77. package/dist/board/sources/staleness.test.js +923 -0
  78. package/dist/board/sources/staleness.test.js.map +1 -0
  79. package/dist/board/sources/tension.d.ts +3 -0
  80. package/dist/board/sources/tension.d.ts.map +1 -0
  81. package/dist/board/sources/tension.js +152 -0
  82. package/dist/board/sources/tension.js.map +1 -0
  83. package/dist/board/sources/tension.test.d.ts +2 -0
  84. package/dist/board/sources/tension.test.d.ts.map +1 -0
  85. package/dist/board/sources/tension.test.js +440 -0
  86. package/dist/board/sources/tension.test.js.map +1 -0
  87. package/dist/board/sources/tier2.d.ts +17 -0
  88. package/dist/board/sources/tier2.d.ts.map +1 -0
  89. package/dist/board/sources/tier2.js +233 -0
  90. package/dist/board/sources/tier2.js.map +1 -0
  91. package/dist/board/sources/tier2.test.d.ts +2 -0
  92. package/dist/board/sources/tier2.test.d.ts.map +1 -0
  93. package/dist/board/sources/tier2.test.js +480 -0
  94. package/dist/board/sources/tier2.test.js.map +1 -0
  95. package/dist/board/types.d.ts +161 -0
  96. package/dist/board/types.d.ts.map +1 -0
  97. package/dist/board/types.js +37 -0
  98. package/dist/board/types.js.map +1 -0
  99. package/dist/canon/index.d.ts +3 -1
  100. package/dist/canon/index.d.ts.map +1 -1
  101. package/dist/canon/index.js +35 -8
  102. package/dist/canon/index.js.map +1 -1
  103. package/dist/canon/types.d.ts +3 -0
  104. package/dist/canon/types.d.ts.map +1 -1
  105. package/dist/cli.d.ts.map +1 -1
  106. package/dist/cli.js +9 -0
  107. package/dist/cli.js.map +1 -1
  108. package/dist/consolidate/birth.d.ts +1 -1
  109. package/dist/consolidate/birth.d.ts.map +1 -1
  110. package/dist/consolidate/birth.js +22 -0
  111. package/dist/consolidate/birth.js.map +1 -1
  112. package/dist/consolidate/edge-write.d.ts +11 -0
  113. package/dist/consolidate/edge-write.d.ts.map +1 -1
  114. package/dist/consolidate/edge-write.js +41 -0
  115. package/dist/consolidate/edge-write.js.map +1 -1
  116. package/dist/consolidate/index.js +5 -2
  117. package/dist/consolidate/index.js.map +1 -1
  118. package/dist/consolidate/revision.d.ts +4 -2
  119. package/dist/consolidate/revision.d.ts.map +1 -1
  120. package/dist/consolidate/revision.js +23 -0
  121. package/dist/consolidate/revision.js.map +1 -1
  122. package/dist/curation/edge-staleness.d.ts +4 -2
  123. package/dist/curation/edge-staleness.d.ts.map +1 -1
  124. package/dist/curation/edge-staleness.js +36 -3
  125. package/dist/curation/edge-staleness.js.map +1 -1
  126. package/dist/curation/edges.d.ts +7 -0
  127. package/dist/curation/edges.d.ts.map +1 -1
  128. package/dist/curation/edges.js +13 -7
  129. package/dist/curation/edges.js.map +1 -1
  130. package/dist/curation/tension-access.d.ts +1 -0
  131. package/dist/curation/tension-access.d.ts.map +1 -1
  132. package/dist/curation/tension-access.js +18 -1
  133. package/dist/curation/tension-access.js.map +1 -1
  134. package/dist/curation/tension.d.ts +3 -0
  135. package/dist/curation/tension.d.ts.map +1 -1
  136. package/dist/curation/tension.js +36 -0
  137. package/dist/curation/tension.js.map +1 -1
  138. package/dist/curation/vault-docs.d.ts +1 -0
  139. package/dist/curation/vault-docs.d.ts.map +1 -1
  140. package/dist/curation/vault-docs.js +1 -0
  141. package/dist/curation/vault-docs.js.map +1 -1
  142. package/dist/distill/cli.d.ts.map +1 -1
  143. package/dist/distill/cli.js +6 -0
  144. package/dist/distill/cli.js.map +1 -1
  145. package/dist/distill/cost.d.ts +6 -0
  146. package/dist/distill/cost.d.ts.map +1 -1
  147. package/dist/distill/cost.js +2 -3
  148. package/dist/distill/cost.js.map +1 -1
  149. package/dist/distill/extract.d.ts +52 -0
  150. package/dist/distill/extract.d.ts.map +1 -1
  151. package/dist/distill/extract.js +24 -2
  152. package/dist/distill/extract.js.map +1 -1
  153. package/dist/distill/propose.d.ts +44 -1
  154. package/dist/distill/propose.d.ts.map +1 -1
  155. package/dist/distill/propose.js +84 -2
  156. package/dist/distill/propose.js.map +1 -1
  157. package/dist/distill/reader-fingerprint.d.ts +69 -0
  158. package/dist/distill/reader-fingerprint.d.ts.map +1 -0
  159. package/dist/distill/reader-fingerprint.js +145 -0
  160. package/dist/distill/reader-fingerprint.js.map +1 -0
  161. package/dist/distill/receipt-store.d.ts +5 -0
  162. package/dist/distill/receipt-store.d.ts.map +1 -0
  163. package/dist/distill/receipt-store.js +24 -0
  164. package/dist/distill/receipt-store.js.map +1 -0
  165. package/dist/eval/llm-openrouter.d.ts.map +1 -1
  166. package/dist/eval/llm-openrouter.js +4 -0
  167. package/dist/eval/llm-openrouter.js.map +1 -1
  168. package/dist/eval/llm.d.ts +22 -0
  169. package/dist/eval/llm.d.ts.map +1 -1
  170. package/dist/eval/llm.js +94 -24
  171. package/dist/eval/llm.js.map +1 -1
  172. package/dist/federation/classification.d.ts.map +1 -1
  173. package/dist/federation/classification.js +3 -0
  174. package/dist/federation/classification.js.map +1 -1
  175. package/dist/index.d.ts.map +1 -1
  176. package/dist/index.js +31 -0
  177. package/dist/index.js.map +1 -1
  178. package/dist/search/coverage.d.ts +5 -1
  179. package/dist/search/coverage.d.ts.map +1 -1
  180. package/dist/search/coverage.js +47 -15
  181. package/dist/search/coverage.js.map +1 -1
  182. package/dist/search/hybrid.d.ts +7 -1
  183. package/dist/search/hybrid.d.ts.map +1 -1
  184. package/dist/search/hybrid.js +31 -8
  185. package/dist/search/hybrid.js.map +1 -1
  186. package/dist/search/retrieval-metrics.d.ts +5 -0
  187. package/dist/search/retrieval-metrics.d.ts.map +1 -0
  188. package/dist/search/retrieval-metrics.js +60 -0
  189. package/dist/search/retrieval-metrics.js.map +1 -0
  190. package/dist/search/suppression.d.ts +9 -0
  191. package/dist/search/suppression.d.ts.map +1 -0
  192. package/dist/search/suppression.js +107 -0
  193. package/dist/search/suppression.js.map +1 -0
  194. package/dist/serve/index.d.ts +11 -0
  195. package/dist/serve/index.d.ts.map +1 -1
  196. package/dist/serve/index.js +547 -8
  197. package/dist/serve/index.js.map +1 -1
  198. package/dist/serve/session.d.ts +9 -0
  199. package/dist/serve/session.d.ts.map +1 -0
  200. package/dist/serve/session.js +65 -0
  201. package/dist/serve/session.js.map +1 -0
  202. package/dist/server.d.ts.map +1 -1
  203. package/dist/server.js +4 -6
  204. package/dist/server.js.map +1 -1
  205. package/dist/tools/board.d.ts +32 -0
  206. package/dist/tools/board.d.ts.map +1 -0
  207. package/dist/tools/board.js +615 -0
  208. package/dist/tools/board.js.map +1 -0
  209. package/dist/tools/board.test.d.ts +2 -0
  210. package/dist/tools/board.test.d.ts.map +1 -0
  211. package/dist/tools/board.test.js +964 -0
  212. package/dist/tools/board.test.js.map +1 -0
  213. package/dist/tools/edge-staleness.d.ts.map +1 -1
  214. package/dist/tools/edge-staleness.js +18 -4
  215. package/dist/tools/edge-staleness.js.map +1 -1
  216. package/dist/tools/read.d.ts +2 -0
  217. package/dist/tools/read.d.ts.map +1 -1
  218. package/dist/tools/read.js +43 -13
  219. package/dist/tools/read.js.map +1 -1
  220. package/dist/tools/search.d.ts.map +1 -1
  221. package/dist/tools/search.js +79 -17
  222. package/dist/tools/search.js.map +1 -1
  223. package/dist/tools/write.d.ts.map +1 -1
  224. package/dist/tools/write.js +172 -2
  225. package/dist/tools/write.js.map +1 -1
  226. package/dist/utils/config.d.ts +24 -0
  227. package/dist/utils/config.d.ts.map +1 -1
  228. package/dist/utils/config.js +151 -1
  229. package/dist/utils/config.js.map +1 -1
  230. package/dist/version.d.ts +2 -0
  231. package/dist/version.d.ts.map +1 -0
  232. package/dist/version.js +8 -0
  233. package/dist/version.js.map +1 -0
  234. package/dist/view/board-page.d.ts +4 -0
  235. package/dist/view/board-page.d.ts.map +1 -0
  236. package/dist/view/board-page.js +339 -0
  237. package/dist/view/board-page.js.map +1 -0
  238. package/dist/view/board-page.test.d.ts +2 -0
  239. package/dist/view/board-page.test.d.ts.map +1 -0
  240. package/dist/view/board-page.test.js +548 -0
  241. package/dist/view/board-page.test.js.map +1 -0
  242. package/dist/view/pages.d.ts.map +1 -1
  243. package/dist/view/pages.js +13 -2
  244. package/dist/view/pages.js.map +1 -1
  245. package/dist/view/render.d.ts.map +1 -1
  246. package/dist/view/render.js +2 -1
  247. package/dist/view/render.js.map +1 -1
  248. package/package.json +2 -2
@@ -22,7 +22,7 @@
22
22
  // - once auth is configured, a missing/unmatched bearer token is rejected
23
23
  // (401) on EVERY request on every bind — never downgraded to guest;
24
24
  // - the deny-all guest exists only in the no-auth loopback configuration.
25
- import { timingSafeEqual } from "node:crypto";
25
+ import { randomBytes, timingSafeEqual } from "node:crypto";
26
26
  import { createServer as createHttpServer, } from "node:http";
27
27
  import { resolve } from "node:path";
28
28
  import { toNodeHandler } from "@modelcontextprotocol/node";
@@ -30,17 +30,24 @@ import { createMcpHandler } from "@modelcontextprotocol/server";
30
30
  import { createRemoteJWKSet, jwtVerify } from "jose";
31
31
  import { GUEST_ROLE, resolveAccess } from "../access/rbac.js";
32
32
  import { loadAttestKey } from "../attest/sign.js";
33
+ import { listBoard } from "../board/board.js";
33
34
  import { ok } from "../frontmatter/types.js";
34
35
  import { installShutdownHandlers, parseFlag, startVaultServices } from "../index.js";
35
36
  import { acquireLock } from "../lifecycle/lock.js";
37
+ import { setCoverageEnabled } from "../search/coverage.js";
38
+ import { setDefaultWeights, setVecKnnK } from "../search/hybrid.js";
39
+ import { setSuppressSuperseded } from "../search/suppression.js";
36
40
  import { setProvider } from "../search/vector.js";
37
41
  import { createServer, resolveToolExposure, SERVER_VERSION } from "../server.js";
38
42
  import { createBackend } from "../storage/backend.js";
39
43
  import { directoryExists } from "../storage/local.js";
40
44
  import { syncVault } from "../storage/sync.js";
45
+ import { vaultBoardDispose, vaultBoardResolve } from "../tools/board.js";
41
46
  import { loadConfig } from "../utils/config.js";
47
+ import { renderBoardPage } from "../view/board-page.js";
42
48
  import { appendAuthEvent, tokenHint } from "./auth-log.js";
43
49
  import { chargePenalty, makeBucket, makePenaltyBox, makeSlotGate, penaltyAllows, releaseSlot, tryAcquireSlot, tryTake, } from "./limits.js";
50
+ import { signSession, verifySession } from "./session.js";
44
51
  export const DEFAULT_PORT = 8787;
45
52
  export const DEFAULT_BIND = "127.0.0.1";
46
53
  const HELP = `daftari serve — server mode over Streamable HTTP (spec 2026-07-20).
@@ -78,6 +85,9 @@ as the deny-all guest.
78
85
 
79
86
  Exit codes: 2 config/usage error, 3 runtime error.
80
87
  `;
88
+ // Minimum HMAC signing-key length. A short key weakens the session MAC; refuse
89
+ // startup rather than mint forgeable cookies.
90
+ const MIN_SESSION_KEY_BYTES = 32;
81
91
  const LOOPBACK_BINDS = new Set(["127.0.0.1", "::1", "localhost"]);
82
92
  function remoteOf(req) {
83
93
  return req.socket.remoteAddress ?? "unknown";
@@ -99,7 +109,9 @@ export function validateServeStartup(config, bind, env) {
99
109
  error: "federation is stdio-only in v1; remove the federation block or run stdio",
100
110
  };
101
111
  }
102
- const authConfigured = config.server.tokens.length > 0 || config.server.oauth !== undefined;
112
+ const authConfigured = config.server.tokens.length > 0 ||
113
+ config.server.oauth !== undefined ||
114
+ config.server.session !== undefined;
103
115
  if (!isLoopbackBind(bind)) {
104
116
  if (!authConfigured) {
105
117
  return {
@@ -185,7 +197,47 @@ export function validateServeStartup(config, bind, env) {
185
197
  }
186
198
  }
187
199
  }
188
- return { ok: true, tokens };
200
+ // Session (bead 7q9): resolve the signing key + login password from env and
201
+ // check the mapped role is declared — the same loud posture as the tokens.
202
+ let session = null;
203
+ const sessionCfg = config.server.session;
204
+ if (sessionCfg) {
205
+ const keyValue = env[sessionCfg.signingKeyEnv];
206
+ if (typeof keyValue !== "string" || keyValue.length === 0) {
207
+ return {
208
+ ok: false,
209
+ error: `server.auth.session names env var ${sessionCfg.signingKeyEnv}, which is not set`,
210
+ };
211
+ }
212
+ if (Buffer.byteLength(keyValue, "utf-8") < MIN_SESSION_KEY_BYTES) {
213
+ return {
214
+ ok: false,
215
+ error: `server.auth.session signing key (${sessionCfg.signingKeyEnv}) must be at least ${MIN_SESSION_KEY_BYTES} bytes`,
216
+ };
217
+ }
218
+ const credValue = env[sessionCfg.credentialEnv];
219
+ if (typeof credValue !== "string" || credValue.length === 0) {
220
+ return {
221
+ ok: false,
222
+ error: `server.auth.session names env var ${sessionCfg.credentialEnv}, which is not set`,
223
+ };
224
+ }
225
+ if (!(sessionCfg.mapsTo.role in config.roles)) {
226
+ return {
227
+ ok: false,
228
+ error: `server.auth.session maps to role '${sessionCfg.mapsTo.role}', ` +
229
+ `which is not declared in config roles`,
230
+ };
231
+ }
232
+ session = {
233
+ key: Buffer.from(keyValue, "utf-8"),
234
+ credential: Buffer.from(credValue, "utf-8"),
235
+ user: sessionCfg.mapsTo.user,
236
+ roleName: sessionCfg.mapsTo.role,
237
+ lifetimeMs: sessionCfg.lifetimeHours * 3_600_000,
238
+ };
239
+ }
240
+ return { ok: true, tokens, session };
189
241
  }
190
242
  // Constant-time match of the presented bearer against every configured
191
243
  // secret. Iterates the FULL list regardless of an early match, so response
@@ -210,10 +262,168 @@ function bearerFrom(req) {
210
262
  const m = /^Bearer\s+(.+)$/.exec(header);
211
263
  return m ? m[1] : null;
212
264
  }
265
+ // Board-login cookie names (bead 7q9). The CSRF cookie is deliberately NOT
266
+ // HttpOnly — the board page's script reads it to echo the value in a header
267
+ // (double-submit), which is the whole point.
268
+ export const SESSION_COOKIE = "daftari_session";
269
+ export const CSRF_COOKIE = "daftari_csrf";
270
+ // Minimal, allocation-light cookie parse: the Cookie header is a
271
+ // "; "-delimited list of name=value pairs. Values are used verbatim (our own
272
+ // tokens are base64url / hex, no encoding needed).
273
+ function cookiesFrom(req) {
274
+ const out = new Map();
275
+ const header = req.headers.cookie;
276
+ if (typeof header !== "string")
277
+ return out;
278
+ for (const part of header.split(";")) {
279
+ const eq = part.indexOf("=");
280
+ if (eq <= 0)
281
+ continue;
282
+ const name = part.slice(0, eq).trim();
283
+ const value = part.slice(eq + 1).trim();
284
+ if (name.length > 0 && !out.has(name))
285
+ out.set(name, value);
286
+ }
287
+ return out;
288
+ }
289
+ function acceptsHtml(req) {
290
+ const accept = req.headers.accept;
291
+ return typeof accept === "string" && accept.includes("text/html");
292
+ }
293
+ // Double-submit CSRF check (bead 7q9): a cookie-authed state-changing request
294
+ // must echo the non-HttpOnly CSRF cookie back in an X-CSRF-Token header. A
295
+ // cross-site page can send the cookie automatically but cannot read it to set
296
+ // the header (it is same-origin to the board), and cannot set a custom header
297
+ // on a simple form post. Returns an error string on failure, null when valid.
298
+ function checkCsrf(req) {
299
+ const cookie = cookiesFrom(req).get(CSRF_COOKIE);
300
+ const raw = req.headers["x-csrf-token"];
301
+ const header = typeof raw === "string" ? raw : Array.isArray(raw) ? raw[0] : undefined;
302
+ if (cookie === undefined || cookie.length === 0 || header === undefined || header.length === 0) {
303
+ return "missing CSRF token";
304
+ }
305
+ const a = Buffer.from(cookie, "utf-8");
306
+ const b = Buffer.from(header, "utf-8");
307
+ const sameLength = a.length === b.length;
308
+ const equal = timingSafeEqual(sameLength ? a : b, b);
309
+ return sameLength && equal ? null : "CSRF token mismatch";
310
+ }
213
311
  function writeJson(res, status, body) {
214
312
  res.writeHead(status, { "content-type": "application/json" });
215
313
  res.end(JSON.stringify(body));
216
314
  }
315
+ function writeHtml(res, status, body) {
316
+ res.writeHead(status, { "content-type": "text/html; charset=utf-8" });
317
+ res.end(body);
318
+ }
319
+ // Build a Set-Cookie value for a board-login cookie (bead 7q9). HttpOnly is
320
+ // caller-controlled (the session cookie is HttpOnly; the CSRF cookie is not,
321
+ // so the board page can echo it). SameSite=Strict blocks cross-site sends,
322
+ // the primary CSRF defense; the double-submit token is defense-in-depth.
323
+ // Secure is set only when the operator declared transport_security: external —
324
+ // a loopback http server cannot set Secure or the browser drops the cookie.
325
+ function buildCookie(name, value, opts) {
326
+ const parts = [`${name}=${value}`, "Path=/", "SameSite=Strict", `Max-Age=${opts.maxAgeSec}`];
327
+ if (opts.httpOnly)
328
+ parts.push("HttpOnly");
329
+ if (opts.secure)
330
+ parts.push("Secure");
331
+ return parts.join("; ");
332
+ }
333
+ function writeRedirect(res, location, setCookies) {
334
+ res.writeHead(302, {
335
+ location,
336
+ ...(setCookies.length > 0 ? { "set-cookie": setCookies } : {}),
337
+ });
338
+ res.end();
339
+ }
340
+ // Minimal, self-contained login page (bead 7q9). No external assets; a single
341
+ // password field POSTing form-encoded to /board/login. `error` renders a
342
+ // message after a failed attempt.
343
+ function renderLoginPage(error) {
344
+ const errorHtml = error
345
+ ? `<p class="err">${error.replace(/[<>&]/g, (c) => ({ "<": "&lt;", ">": "&gt;", "&": "&amp;" })[c])}</p>`
346
+ : "";
347
+ return (`<!doctype html><html lang="en"><head><meta charset="utf-8">` +
348
+ `<meta name="viewport" content="width=device-width,initial-scale=1">` +
349
+ `<title>Board — sign in</title><style>` +
350
+ `body{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;background:#0d1117;color:#c9d1d9;` +
351
+ `display:flex;min-height:100vh;align-items:center;justify-content:center;margin:0}` +
352
+ `form{background:#161b22;border:1px solid #30363d;border-radius:10px;padding:28px 30px;width:280px}` +
353
+ `h1{font-size:15px;margin:0 0 4px;letter-spacing:.04em;text-transform:uppercase}` +
354
+ `p.sub{font-size:11px;color:#8b949e;margin:0 0 18px}` +
355
+ `input{width:100%;box-sizing:border-box;background:#0d1117;border:1px solid #30363d;border-radius:7px;` +
356
+ `color:#c9d1d9;padding:9px 11px;font:inherit;margin-bottom:14px}` +
357
+ `button{width:100%;background:#238636;border:0;border-radius:7px;color:#fff;padding:9px;font:inherit;cursor:pointer}` +
358
+ `p.err{color:#f85149;font-size:12px;margin:0 0 12px}` +
359
+ `</style></head><body><form method="post" action="/board/login">` +
360
+ `<h1>Vault Board</h1><p class="sub">Enter the board password to continue.</p>` +
361
+ errorHtml +
362
+ `<input type="password" name="password" autofocus autocomplete="current-password" aria-label="Board password">` +
363
+ `<button type="submit">Sign in</button></form></body></html>`);
364
+ }
365
+ // Read the full request body as a UTF-8 string. Returns null if reading fails
366
+ // or body exceeds the 1 MiB safety limit.
367
+ function readBody(req) {
368
+ return new Promise((resolve) => {
369
+ const chunks = [];
370
+ let total = 0;
371
+ let settled = false;
372
+ const LIMIT = 1_048_576; // 1 MiB
373
+ req.on("data", (chunk) => {
374
+ total += chunk.length;
375
+ if (total > LIMIT) {
376
+ if (settled)
377
+ return; // size-limit path: prevent double-resolve
378
+ settled = true;
379
+ resolve(null);
380
+ req.destroy();
381
+ }
382
+ else {
383
+ chunks.push(chunk);
384
+ }
385
+ });
386
+ req.on("end", () => {
387
+ if (settled)
388
+ return;
389
+ settled = true;
390
+ resolve(Buffer.concat(chunks).toString("utf-8"));
391
+ });
392
+ req.on("error", () => {
393
+ if (settled)
394
+ return;
395
+ settled = true;
396
+ resolve(null);
397
+ });
398
+ });
399
+ }
400
+ // Parse BoardFilters from a URLSearchParams instance (query string).
401
+ function filtersFromQuery(query) {
402
+ const filters = {};
403
+ const collection = query.get("collection");
404
+ if (collection)
405
+ filters.collection = collection;
406
+ const check = query.get("check");
407
+ if (check)
408
+ filters.check = check;
409
+ const certainty = query.get("certainty");
410
+ if (certainty === "low" || certainty === "medium" || certainty === "high") {
411
+ filters.certainty = certainty;
412
+ }
413
+ const owner = query.get("owner");
414
+ if (owner)
415
+ filters.owner = owner;
416
+ const minAgeDays = query.get("minAgeDays");
417
+ if (minAgeDays !== null) {
418
+ const n = Number(minAgeDays);
419
+ if (Number.isFinite(n) && n >= 0)
420
+ filters.minAgeDays = Math.floor(n);
421
+ }
422
+ const document = query.get("document");
423
+ if (document)
424
+ filters.document = document;
425
+ return filters;
426
+ }
217
427
  export function makeLoopbackGuard(port) {
218
428
  const spellings = ["127.0.0.1", "localhost", "[::1]"];
219
429
  return {
@@ -232,7 +442,8 @@ export function violatesLoopbackGuard(guard, host, origin) {
232
442
  }
233
443
  export function startHttpServer(vaultRoot, config, tokens, bind, port, opts = {}) {
234
444
  const oauth = config.server.oauth;
235
- const authConfigured = tokens.length > 0 || oauth !== undefined;
445
+ const session = opts.session ?? null;
446
+ const authConfigured = tokens.length > 0 || oauth !== undefined || session !== null;
236
447
  // The ops floor (multi-user item 6). Process-local in-memory state is
237
448
  // correct by construction: one serve process per vault is the invariant
238
449
  // (.daftari/process.lock), the principal set is config-declared and
@@ -240,6 +451,10 @@ export function startHttpServer(vaultRoot, config, tokens, bind, port, opts = {}
240
451
  const limits = config.server.limits;
241
452
  const penaltyBox = makePenaltyBox(limits.authFailureBurst, limits.authFailuresPerMinute);
242
453
  const principalBuckets = new Map();
454
+ // Marks requests authenticated via the browser-session COOKIE (bead 7q9).
455
+ // CSRF enforcement (double-submit) applies only to these — bearer-authed
456
+ // requests carry no ambient credential a cross-site page could ride.
457
+ const cookieAuthedReqs = new WeakSet();
243
458
  const slotGate = opts.slotGate ?? makeSlotGate(limits.maxInFlight);
244
459
  // Fire-and-forget: an audit write must never add latency or failure to a
245
460
  // response. Errors surface once per failure on stderr.
@@ -268,7 +483,17 @@ export function startHttpServer(vaultRoot, config, tokens, bind, port, opts = {}
268
483
  // (authenticated, not authorized), NEVER guest;
269
484
  // - anything else is 401. With no auth at all (startup gating
270
485
  // guarantees loopback) every request runs as the deny-all guest.
271
- const authenticate = async (req, res) => {
486
+ //
487
+ // `auditPath` is the route pathname threaded in by the caller so that
488
+ // board-route auth failures log the actual board path (e.g. "/api/board")
489
+ // rather than the hardcoded "/mcp". Defaults to the request's own URL path.
490
+ const authenticate = async (req, res, auditPath,
491
+ // When set and the request is a browser (Accept: text/html) that fails
492
+ // authentication with a 401 (missing/invalid credential — NOT a 403
493
+ // unmapped-subject), redirect there instead of writing the JSON 401. Lets
494
+ // GET /board send a browser to the login page (bead 7q9, U6).
495
+ htmlRedirectTo) => {
496
+ const effectiveAuditPath = auditPath ?? new URL(req.url ?? "/", "http://localhost").pathname;
272
497
  if (!authConfigured) {
273
498
  return resolveAccess(config, "guest", GUEST_ROLE);
274
499
  }
@@ -301,7 +526,7 @@ export function startHttpServer(vaultRoot, config, tokens, bind, port, opts = {}
301
526
  ...(subject !== undefined ? { subject } : {}),
302
527
  remote: remoteOf(req),
303
528
  method: req.method ?? "",
304
- path: "/mcp",
529
+ path: effectiveAuditPath,
305
530
  });
306
531
  writeJson(res, 403, {
307
532
  error: "forbidden",
@@ -317,6 +542,22 @@ export function startHttpServer(vaultRoot, config, tokens, bind, port, opts = {}
317
542
  }
318
543
  }
319
544
  }
545
+ // Browser-session cookie (bead 7q9): consulted ONLY when no valid bearer
546
+ // matched. A verifying cookie whose role is still declared authenticates
547
+ // the request; anything else falls through to the 401 below (an invalid
548
+ // cookie is never a guest downgrade). The double-submit CSRF check is NOT
549
+ // done here — authentication and CSRF are separate concerns; the board
550
+ // route layer enforces CSRF on cookie-authed state-changing requests.
551
+ if (session !== null) {
552
+ const cookie = cookiesFrom(req).get(SESSION_COOKIE);
553
+ if (cookie !== undefined) {
554
+ const verified = verifySession(cookie, session.key, Math.floor(Date.now() / 1000));
555
+ if (verified.ok && verified.value.role in config.roles) {
556
+ cookieAuthedReqs.add(req);
557
+ return resolveAccess(config, verified.value.user, verified.value.role);
558
+ }
559
+ }
560
+ }
320
561
  chargePenalty(penaltyBox, remoteOf(req), Date.now());
321
562
  audit({
322
563
  outcome: "deny-401",
@@ -325,8 +566,14 @@ export function startHttpServer(vaultRoot, config, tokens, bind, port, opts = {}
325
566
  ...(bearerFrom(req) !== null ? { token_hint: tokenHint(bearerFrom(req)) } : {}),
326
567
  remote: remoteOf(req),
327
568
  method: req.method ?? "",
328
- path: "/mcp",
569
+ path: effectiveAuditPath,
329
570
  });
571
+ if (htmlRedirectTo !== undefined && acceptsHtml(req)) {
572
+ // Browser hitting a protected page with no session → send it to login
573
+ // (penalty + audit already charged above, same as the JSON 401).
574
+ writeRedirect(res, htmlRedirectTo, []);
575
+ return null;
576
+ }
330
577
  writeJson(res, 401, {
331
578
  error: "unauthorized",
332
579
  message: "a valid bearer token is required",
@@ -380,6 +627,291 @@ export function startHttpServer(vaultRoot, config, tokens, bind, port, opts = {}
380
627
  }
381
628
  }
382
629
  const url = new URL(req.url ?? "/", `http://${req.headers.host ?? "localhost"}`);
630
+ // ---------------------------------------------------------------------------
631
+ // Board login shim (bead 7q9, U5) — mounted BEFORE authenticate(): the login
632
+ // page and credential POST must be reachable WITHOUT a session. Present only
633
+ // when a server.auth.session block is configured; otherwise these paths 404
634
+ // like any unknown route. The rebinding/Origin guard above already ran.
635
+ // GET /board/login → login form
636
+ // POST /board/login → verify password → set session+csrf cookies → 302 /board
637
+ // POST /board/logout → clear cookies → 302 /board/login (CSRF-checked)
638
+ // ---------------------------------------------------------------------------
639
+ if (url.pathname === "/board/login" || url.pathname === "/board/logout") {
640
+ if (session === null) {
641
+ writeJson(res, 404, { error: "not_found" });
642
+ return;
643
+ }
644
+ const loginRemote = remoteOf(req);
645
+ const secure = config.server.transportSecurity === "external";
646
+ if (url.pathname === "/board/login" && req.method === "GET") {
647
+ writeHtml(res, 200, renderLoginPage());
648
+ return;
649
+ }
650
+ if (url.pathname === "/board/login" && req.method === "POST") {
651
+ // Brute-force lockout shares the pre-auth penalty box, keyed on remote.
652
+ const gate = penaltyAllows(penaltyBox, loginRemote, Date.now());
653
+ if (!gate.allowed) {
654
+ res.setHeader("Retry-After", String(gate.retryAfterSeconds));
655
+ writeJson(res, 429, {
656
+ error: "rate_limited",
657
+ message: "too many failed sign-in attempts",
658
+ });
659
+ return;
660
+ }
661
+ const rawBody = await readBody(req);
662
+ if (rawBody === null) {
663
+ writeJson(res, 400, {
664
+ error: "bad_request",
665
+ message: "request body too large or unreadable",
666
+ });
667
+ return;
668
+ }
669
+ const submitted = new URLSearchParams(rawBody).get("password") ?? "";
670
+ const submittedBuf = Buffer.from(submitted, "utf-8");
671
+ const sameLength = submittedBuf.length === session.credential.length;
672
+ const equal = timingSafeEqual(sameLength ? submittedBuf : session.credential, session.credential);
673
+ if (!sameLength || !equal) {
674
+ chargePenalty(penaltyBox, loginRemote, Date.now());
675
+ audit({ outcome: "deny-401", remote: loginRemote, method: "POST", path: "/board/login" });
676
+ writeHtml(res, 401, renderLoginPage("Incorrect password."));
677
+ return;
678
+ }
679
+ const nowSec = Math.floor(Date.now() / 1000);
680
+ const maxAgeSec = Math.floor(session.lifetimeMs / 1000);
681
+ const token = signSession({ user: session.user, role: session.roleName, exp: nowSec + maxAgeSec }, session.key);
682
+ const csrf = randomBytes(18).toString("base64url");
683
+ writeRedirect(res, "/board", [
684
+ buildCookie(SESSION_COOKIE, token, { httpOnly: true, maxAgeSec, secure }),
685
+ buildCookie(CSRF_COOKIE, csrf, { httpOnly: false, maxAgeSec, secure }),
686
+ ]);
687
+ return;
688
+ }
689
+ if (url.pathname === "/board/logout" && req.method === "POST") {
690
+ // Logout mutates session state → CSRF-checked (double-submit). No valid
691
+ // token → 403; the browser UI always sends it, so this only bites forced
692
+ // cross-site logout attempts.
693
+ const csrfError = checkCsrf(req);
694
+ if (csrfError !== null) {
695
+ writeJson(res, 403, { error: "forbidden", message: csrfError });
696
+ return;
697
+ }
698
+ writeRedirect(res, "/board/login", [
699
+ buildCookie(SESSION_COOKIE, "", { httpOnly: true, maxAgeSec: 0, secure }),
700
+ buildCookie(CSRF_COOKIE, "", { httpOnly: false, maxAgeSec: 0, secure }),
701
+ ]);
702
+ return;
703
+ }
704
+ writeJson(res, 405, { error: "method_not_allowed" });
705
+ return;
706
+ }
707
+ // ---------------------------------------------------------------------------
708
+ // Board routes (U12) — mounted BEFORE the /mcp 404 gate so they are
709
+ // reachable, and AFTER authenticate() so every request carries a real
710
+ // AccessContext. The DNS-rebinding / Origin guard above already ran.
711
+ //
712
+ // Route list:
713
+ // GET /board → renderBoardPage HTML (R25/R26/R29)
714
+ // GET /api/board → listBoard JSON (R25/R26/R29)
715
+ // POST /api/board/dispose → vaultBoardDispose (R30/R32)
716
+ // POST /api/board/resolve → vaultBoardResolve (R30/R32)
717
+ //
718
+ // Non-disclosure (R20): dispose/resolve return 403 for both "not found"
719
+ // and "not permitted" — identical status+body so the HTTP layer adds no
720
+ // existence oracle beyond what the tools carefully hide.
721
+ // ---------------------------------------------------------------------------
722
+ const isBoardPath = url.pathname === "/board" ||
723
+ url.pathname === "/api/board" ||
724
+ url.pathname === "/api/board/dispose" ||
725
+ url.pathname === "/api/board/resolve";
726
+ if (isBoardPath) {
727
+ // Board routes share the SAME pre-auth penalty-box and per-principal
728
+ // rate-limit admission as /mcp — a flood of invalid-bearer requests to
729
+ // /api/board/* is penalised and locked out exactly as /mcp is.
730
+ //
731
+ // Layer A (pre-auth): penalty box keyed on socket address. An
732
+ // unauthenticated flood cannot spend CPU on constant-time token matching
733
+ // or JWT verification. Charged only by a 401/403 outcome inside
734
+ // authenticate, so a legitimate client never touches it.
735
+ const boardRemote = remoteOf(req);
736
+ const boardPenalty = penaltyAllows(penaltyBox, boardRemote, Date.now());
737
+ if (!boardPenalty.allowed) {
738
+ res.setHeader("Retry-After", String(boardPenalty.retryAfterSeconds));
739
+ audit({
740
+ outcome: "rate-limited",
741
+ remote: boardRemote,
742
+ method: req.method ?? "",
743
+ path: url.pathname,
744
+ });
745
+ writeJson(res, 429, {
746
+ error: "rate_limited",
747
+ message: "too many failed authentication attempts",
748
+ });
749
+ return;
750
+ }
751
+ // authenticate() charges the penalty box on 401/403 and logs the real
752
+ // board path (not "/mcp") via the auditPath argument. For a browser
753
+ // hitting GET /board with no session, redirect to the login page instead
754
+ // of a JSON 401 (U6) — only meaningful when a session block is configured.
755
+ const htmlRedirectTo = url.pathname === "/board" && req.method === "GET" && session !== null
756
+ ? "/board/login"
757
+ : undefined;
758
+ const boardAccess = await authenticate(req, res, url.pathname, htmlRedirectTo);
759
+ if (boardAccess === null)
760
+ return; // authenticate() already wrote the rejection
761
+ // Layer B (post-auth): per-principal token-bucket, same as /mcp.
762
+ let boardBucket = principalBuckets.get(boardAccess.user);
763
+ if (!boardBucket) {
764
+ boardBucket = makeBucket(limits.burst, limits.ratePerMinute, Date.now());
765
+ principalBuckets.set(boardAccess.user, boardBucket);
766
+ }
767
+ const boardTake = tryTake(boardBucket, Date.now());
768
+ if (!boardTake.allowed) {
769
+ res.setHeader("Retry-After", String(boardTake.retryAfterSeconds));
770
+ audit({
771
+ outcome: "rate-limited",
772
+ principal: boardAccess.user,
773
+ remote: boardRemote,
774
+ method: req.method ?? "",
775
+ path: url.pathname,
776
+ });
777
+ writeJson(res, 429, {
778
+ error: "rate_limited",
779
+ message: "per-principal rate limit reached",
780
+ });
781
+ return;
782
+ }
783
+ const filters = filtersFromQuery(url.searchParams);
784
+ const hasFilters = Object.keys(filters).length > 0;
785
+ if (url.pathname === "/api/board" && req.method === "GET") {
786
+ // GET /api/board → JSON board result
787
+ const result = await listBoard(vaultRoot, boardAccess, hasFilters ? filters : undefined);
788
+ writeJson(res, 200, result);
789
+ return;
790
+ }
791
+ if (url.pathname === "/board" && req.method === "GET") {
792
+ // GET /board → rendered HTML page
793
+ const result = await listBoard(vaultRoot, boardAccess, hasFilters ? filters : undefined);
794
+ const html = renderBoardPage(result, hasFilters ? filters : undefined);
795
+ writeHtml(res, 200, html);
796
+ return;
797
+ }
798
+ if (url.pathname === "/api/board/dispose" && req.method === "POST") {
799
+ // POST /api/board/dispose → vaultBoardDispose
800
+ // CSRF (U7): a cookie-authed browser must echo the double-submit token.
801
+ // Bearer-authed callers carry no ambient credential and are exempt.
802
+ if (cookieAuthedReqs.has(req)) {
803
+ const csrfError = checkCsrf(req);
804
+ if (csrfError !== null) {
805
+ writeJson(res, 403, { error: "forbidden", message: csrfError });
806
+ return;
807
+ }
808
+ }
809
+ const rawBody = await readBody(req);
810
+ if (rawBody === null) {
811
+ writeJson(res, 400, {
812
+ error: "bad_request",
813
+ message: "request body too large or unreadable",
814
+ });
815
+ return;
816
+ }
817
+ let args;
818
+ try {
819
+ args = JSON.parse(rawBody);
820
+ }
821
+ catch {
822
+ writeJson(res, 400, { error: "bad_request", message: "request body is not valid JSON" });
823
+ return;
824
+ }
825
+ const disposeResult = await vaultBoardDispose(vaultRoot, boardAccess, config, {
826
+ finding_id: typeof args.finding_id === "string" ? args.finding_id : "",
827
+ event: typeof args.event === "string" ? args.event : "",
828
+ ...(typeof args.rationale === "string" ? { rationale: args.rationale } : {}),
829
+ ...(typeof args.expiry === "string" ? { expiry: args.expiry } : {}),
830
+ ...(typeof args.owner === "string" ? { owner: args.owner } : {}),
831
+ });
832
+ if (!disposeResult.ok) {
833
+ // Non-disclosure: use 403 for both "not found" and "not permitted"
834
+ // so the HTTP status code does not become an existence oracle.
835
+ // Input-validation errors (missing/invalid event, missing finding_id)
836
+ // are 400 — they expose no finding existence.
837
+ const msg = disposeResult.error.message;
838
+ const isInputError = msg.includes("finding_id is required") ||
839
+ msg.includes("invalid event") ||
840
+ msg.includes("reassign requires");
841
+ const isCapabilityError = msg.includes("permission denied") || msg.includes("lacks the dispose capability");
842
+ if (isInputError) {
843
+ writeJson(res, 400, { error: "bad_request", message: msg });
844
+ }
845
+ else if (isCapabilityError) {
846
+ // Capability check fires BEFORE any finding lookup (Gate 1 in
847
+ // vaultBoardDispose). The role-naming message here is therefore
848
+ // identical whether the finding exists or not — it carries no
849
+ // existence information, so emitting it does not create an oracle.
850
+ // This is deliberately different from the non-disclosure branch
851
+ // below, which emits the fixed "not found or not permitted" body
852
+ // for both "finding absent" and "RBAC-hidden" to prevent those
853
+ // two outcomes from being distinguished by their HTTP bodies.
854
+ writeJson(res, 403, { error: "forbidden", message: msg });
855
+ }
856
+ else {
857
+ // "not found or not permitted" — the non-disclosing error from the tool.
858
+ // Always 403, never 404, so existence (present-but-hidden vs absent)
859
+ // is indistinguishable to the caller.
860
+ writeJson(res, 403, { error: "forbidden", message: msg });
861
+ }
862
+ return;
863
+ }
864
+ writeJson(res, 200, disposeResult.value);
865
+ return;
866
+ }
867
+ if (url.pathname === "/api/board/resolve" && req.method === "POST") {
868
+ // POST /api/board/resolve → vaultBoardResolve
869
+ // CSRF (U7): cookie-authed browsers must echo the double-submit token.
870
+ if (cookieAuthedReqs.has(req)) {
871
+ const csrfError = checkCsrf(req);
872
+ if (csrfError !== null) {
873
+ writeJson(res, 403, { error: "forbidden", message: csrfError });
874
+ return;
875
+ }
876
+ }
877
+ const rawBody = await readBody(req);
878
+ if (rawBody === null) {
879
+ writeJson(res, 400, {
880
+ error: "bad_request",
881
+ message: "request body too large or unreadable",
882
+ });
883
+ return;
884
+ }
885
+ let args;
886
+ try {
887
+ args = JSON.parse(rawBody);
888
+ }
889
+ catch {
890
+ writeJson(res, 400, { error: "bad_request", message: "request body is not valid JSON" });
891
+ return;
892
+ }
893
+ const resolveResult = await vaultBoardResolve(vaultRoot, boardAccess, config, {
894
+ finding_id: typeof args.finding_id === "string" ? args.finding_id : "",
895
+ });
896
+ if (!resolveResult.ok) {
897
+ const msg = resolveResult.error.message;
898
+ const isInputError = msg.includes("finding_id is required");
899
+ if (isInputError) {
900
+ writeJson(res, 400, { error: "bad_request", message: msg });
901
+ }
902
+ else {
903
+ // Non-disclosure: 403 for both not-found and not-permitted.
904
+ writeJson(res, 403, { error: "forbidden", message: msg });
905
+ }
906
+ return;
907
+ }
908
+ writeJson(res, 200, resolveResult.value);
909
+ return;
910
+ }
911
+ // Method not allowed on a known board path (e.g. POST /board)
912
+ writeJson(res, 405, { error: "method_not_allowed" });
913
+ return;
914
+ }
383
915
  if (url.pathname !== "/mcp") {
384
916
  writeJson(res, 404, { error: "not_found" });
385
917
  return;
@@ -400,7 +932,7 @@ export function startHttpServer(vaultRoot, config, tokens, bind, port, opts = {}
400
932
  });
401
933
  return;
402
934
  }
403
- const access = await authenticate(req, res);
935
+ const access = await authenticate(req, res, "/mcp");
404
936
  if (access === null)
405
937
  return;
406
938
  // Layer B — the per-principal bucket, keyed on the VERIFIED identity.
@@ -584,6 +1116,12 @@ export async function runServe(argv) {
584
1116
  process.stderr.write(`daftari serve: ${e instanceof Error ? e.message : String(e)}\n`);
585
1117
  return 3;
586
1118
  }
1119
+ // Retrieval tuning (`search` block): validated by loadConfig, applied once
1120
+ // per process, same lifecycle as the provider above.
1121
+ setCoverageEnabled(config.value.search.coverage);
1122
+ setVecKnnK(config.value.search.vecKnnK);
1123
+ setDefaultWeights(config.value.search.weights);
1124
+ setSuppressSuperseded(config.value.search.suppressSuperseded);
587
1125
  // Startup warnings mirror stdio's: unknown tool names in the tools block.
588
1126
  for (const name of resolveToolExposure(config.value.tools).unknown) {
589
1127
  process.stderr.write(`daftari: warning: tools.include/exclude names unknown tool '${name}' — ignored\n`);
@@ -591,6 +1129,7 @@ export async function runServe(argv) {
591
1129
  try {
592
1130
  handle = await startHttpServer(vaultRoot, config.value, gate.tokens, bind, port, {
593
1131
  legacyHttp,
1132
+ session: gate.session,
594
1133
  });
595
1134
  }
596
1135
  catch (e) {