@guren/server 2.23.3 → 2.24.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 (71) hide show
  1. package/dist/DailyFileChannel-CTTPA0EF.js +114 -0
  2. package/dist/{DocsViewerServiceProvider-DWnlXx_y.js → DocsViewerServiceProvider-CIRNHQ2I.js} +2 -2
  3. package/dist/{authorization-0mCGUFoI.js → Gate-Cn1E6JnO.js} +3 -217
  4. package/dist/{Job-BVvaY-7p.js → Job-BVRCYuVY.js} +4 -10
  5. package/dist/McpServiceProvider-B-LioPSz.js +43 -0
  6. package/dist/Resource-BJhY4aF8.js +1035 -0
  7. package/dist/{loopback-guard-DT9gHF0F.js → ServiceProvider-DDW3MqQJ.js} +10 -68
  8. package/dist/agent/audit-file.d.ts +3 -0
  9. package/dist/agent/audit-sink.d.ts +16 -0
  10. package/dist/agent/call-budget.d.ts +22 -0
  11. package/dist/agent/events.d.ts +6 -6
  12. package/dist/api-token-BbgDEd6j.js +298 -0
  13. package/dist/audit-file-DocumbCr.js +29 -0
  14. package/dist/auth/index.js +2 -1
  15. package/dist/auth/oauth/index.d.ts +7 -0
  16. package/dist/{auth-Jp_MB8Il.js → auth-vFeem6uM.js} +8 -298
  17. package/dist/authorization/index.js +2 -1
  18. package/dist/authorization-BsMTG8P1.js +217 -0
  19. package/dist/broadcasting/index.js +1 -1
  20. package/dist/{broadcasting-DVfG2vgN.js → broadcasting-6o_CCfF0.js} +2 -1
  21. package/dist/config/define.d.ts +50 -0
  22. package/dist/config/env-reads.d.ts +12 -0
  23. package/dist/config/env.d.ts +122 -0
  24. package/dist/container/Container.d.ts +13 -2
  25. package/dist/container/ServiceProvider.d.ts +7 -0
  26. package/dist/container/bindings.d.ts +8 -0
  27. package/dist/{default-application-Chbrul_m.js → default-application-CMuAAsdf.js} +20 -31
  28. package/dist/deprecate-rL8jNpKX.js +31 -0
  29. package/dist/encryption/index.js +1 -1
  30. package/dist/{encryption-BRjZnshr.js → encryption-_GiNb0Ol.js} +2 -1
  31. package/dist/{endpoint-BXipU2Jj.js → endpoint-CTIzcagh.js} +1 -1
  32. package/dist/{endpoint-Dsw3Acvq.js → endpoint-Coq0K_6I.js} +1 -1
  33. package/dist/events/index.js +1 -1
  34. package/dist/{events-CaJKZ2qk.js → events-swsyfCzt.js} +1 -1
  35. package/dist/http/Application.d.ts +22 -0
  36. package/dist/http/vite-manifest.d.ts +5 -1
  37. package/dist/i18n/index.js +1 -1
  38. package/dist/i18n/injected-translations.d.ts +8 -0
  39. package/dist/i18n/loaders/JsonLoader.d.ts +3 -2
  40. package/dist/{i18n-DRo1g0AN.js → i18n-0bOJqFpX.js} +5 -3
  41. package/dist/index.d.ts +11 -0
  42. package/dist/index.js +526 -1075
  43. package/dist/inertia-defaults-BjrcT7za.js +30 -0
  44. package/dist/internal/request.d.ts +4 -3
  45. package/dist/internal/request.js +2 -1
  46. package/dist/internal/testing.d.ts +17 -0
  47. package/dist/internal/testing.js +6 -0
  48. package/dist/lambda/index.js +1 -1
  49. package/dist/logging/index.js +2 -1
  50. package/dist/{logging-CXotojgW.js → logging-DshkpIkj.js} +4 -113
  51. package/dist/loopback-guard-CG8xB4v0.js +68 -0
  52. package/dist/mail/index.js +1 -1
  53. package/dist/{mail-zMjQimaJ.js → mail-CQlxrjYp.js} +4 -2
  54. package/dist/mcp/McpServiceProvider.d.ts +21 -4
  55. package/dist/mcp/create-mcp-server.d.ts +6 -0
  56. package/dist/mcp/index.js +434 -1
  57. package/dist/mvc/Controller.d.ts +11 -1
  58. package/dist/mvc/Router.d.ts +6 -0
  59. package/dist/mvc/inertia/InertiaEngine.d.ts +2 -0
  60. package/dist/mvc/validated-input.d.ts +55 -0
  61. package/dist/notifications/index.js +1 -1
  62. package/dist/{notifications-BLid0Y6M.js → notifications-DmyJZGM2.js} +3 -2
  63. package/dist/providers/ConfigServiceProvider.d.ts +19 -0
  64. package/dist/queue/index.js +2 -2
  65. package/dist/{queue-IdJjqbyJ.js → queue-CdwHlFXE.js} +1 -1
  66. package/dist/resolve-optional-ax6gPWTp.js +9 -0
  67. package/dist/runtime/index.js +2 -1
  68. package/dist/validated-input-D84J8wcC.js +25 -0
  69. package/dist/{vite-manifest-DeWRFXTm.js → vite-manifest-DAqhhZZ9.js} +7 -32
  70. package/package.json +6 -2
  71. package/dist/McpServiceProvider-BvJRcDOm.js +0 -458
@@ -0,0 +1,114 @@
1
+ import * as path$1 from "node:path";
2
+ import * as fs from "node:fs";
3
+ //#region src/logging/types.ts
4
+ /** Log level priority (lower = more severe). */
5
+ const LOG_LEVEL_PRIORITY = {
6
+ emergency: 0,
7
+ alert: 1,
8
+ critical: 2,
9
+ error: 3,
10
+ warning: 4,
11
+ notice: 5,
12
+ info: 6,
13
+ debug: 7
14
+ };
15
+ //#endregion
16
+ //#region src/logging/daily-file-path.ts
17
+ /**
18
+ * The one rule for what a daily-rotated log file is called:
19
+ * `dir/name-YYYY-MM-DD.ext`. {@link DailyFileChannel} names what it appends to
20
+ * through this module, and the audit reader behind `guren tool:log` decides
21
+ * what to read through the same one; a second copy drifts silently, leaving an
22
+ * empty audit trail rather than an error. Naming only — nothing here touches
23
+ * the filesystem, so a caller keeps "missing" and "unreadable" apart itself.
24
+ */
25
+ /**
26
+ * The `YYYY-MM-DD` stamp a file rotated at `date` carries. UTC, because the
27
+ * rotation boundary must be the same instant for every process appending to one
28
+ * directory — a fleet across time zones would write two files for one day.
29
+ */
30
+ function dailyFileDateStamp(date) {
31
+ return date.toISOString().slice(0, 10);
32
+ }
33
+ /** The dated file a base path rotates to on `date`. */
34
+ function dailyFilePath(basePath, date) {
35
+ const { dir, name, ext } = path$1.parse(basePath);
36
+ return path$1.join(dir, `${name}-${dailyFileDateStamp(date)}${ext}`);
37
+ }
38
+ /**
39
+ * The date stamp of `fileName` if it is one of `basePath`'s dated files, else
40
+ * `null` — the inverse of {@link dailyFilePath}. The base name and extension
41
+ * are escaped first: `app.v1.log` would otherwise match another app's files
42
+ * into this rotation set, which for the cleanup consuming it means deleting them.
43
+ */
44
+ function matchDailyFileDate(basePath, fileName) {
45
+ const { name, ext } = path$1.parse(basePath);
46
+ return new RegExp(`^${escapeRegExp(name)}-(\\d{4}-\\d{2}-\\d{2})${escapeRegExp(ext)}$`, "u").exec(fileName)?.[1] ?? null;
47
+ }
48
+ /** Every character with meaning inside a regular expression, made literal. */
49
+ function escapeRegExp(text) {
50
+ return text.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&");
51
+ }
52
+ //#endregion
53
+ //#region src/logging/channels/DailyFileChannel.ts
54
+ /** Daily rotating file log channel. */
55
+ var DailyFileChannel = class {
56
+ config;
57
+ minLevel;
58
+ currentDate = null;
59
+ currentFilePath = null;
60
+ constructor(config) {
61
+ this.config = {
62
+ days: 14,
63
+ format: "text",
64
+ ...config
65
+ };
66
+ this.minLevel = LOG_LEVEL_PRIORITY[this.config.level ?? "debug"];
67
+ }
68
+ log(entry) {
69
+ if (LOG_LEVEL_PRIORITY[entry.level] > this.minLevel) return;
70
+ const dateStr = dailyFileDateStamp(entry.timestamp);
71
+ if (this.currentDate !== dateStr) this.rotate(entry.timestamp, dateStr);
72
+ const line = this.format(entry) + "\n";
73
+ this.write(line);
74
+ }
75
+ write(data) {
76
+ if (this.currentFilePath) fs.appendFileSync(this.currentFilePath, data);
77
+ }
78
+ rotate(date, dateStr) {
79
+ this.currentDate = dateStr;
80
+ this.currentFilePath = dailyFilePath(this.config.path, date);
81
+ this.ensureDirectory(this.currentFilePath);
82
+ this.cleanup();
83
+ }
84
+ ensureDirectory(filePath) {
85
+ const dir = path$1.dirname(filePath);
86
+ if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
87
+ }
88
+ cleanup() {
89
+ const dir = path$1.dirname(this.config.path);
90
+ if (!fs.existsSync(dir)) return;
91
+ const files = fs.readdirSync(dir);
92
+ const cutoff = /* @__PURE__ */ new Date();
93
+ cutoff.setDate(cutoff.getDate() - (this.config.days ?? 14));
94
+ for (const file of files) {
95
+ const stamp = matchDailyFileDate(this.config.path, file);
96
+ if (stamp !== null && new Date(stamp) < cutoff) fs.unlinkSync(path$1.join(dir, file));
97
+ }
98
+ }
99
+ format(entry) {
100
+ if (this.config.format === "json") return JSON.stringify({
101
+ timestamp: entry.timestamp.toISOString(),
102
+ level: entry.level,
103
+ message: entry.message,
104
+ ...entry.context
105
+ });
106
+ const timestamp = entry.timestamp.toISOString();
107
+ const level = entry.level.toUpperCase().padEnd(9);
108
+ const context = Object.keys(entry.context).length > 0 ? " " + JSON.stringify(entry.context) : "";
109
+ return `[${timestamp}] ${level} ${entry.message}${context}`;
110
+ }
111
+ close() {}
112
+ };
113
+ //#endregion
114
+ export { LOG_LEVEL_PRIORITY as a, matchDailyFileDate as i, dailyFileDateStamp as n, dailyFilePath as r, DailyFileChannel as t };
@@ -1,5 +1,5 @@
1
- import { r as ServiceProvider } from "./loopback-guard-DT9gHF0F.js";
2
- import { n as createDocsViewerAccessGuard, r as isDocsViewerEnabled, t as DOCS_VIEWER_PATH } from "./endpoint-BXipU2Jj.js";
1
+ import { n as ServiceProvider } from "./ServiceProvider-DDW3MqQJ.js";
2
+ import { n as createDocsViewerAccessGuard, r as isDocsViewerEnabled, t as DOCS_VIEWER_PATH } from "./endpoint-CTIzcagh.js";
3
3
  import { createRequire } from "node:module";
4
4
  import { createHash } from "node:crypto";
5
5
  import { join } from "node:path";
@@ -1,51 +1,7 @@
1
1
  import { t as HttpException } from "./HttpException-BlQ2yEmT.js";
2
- import { h as warnDeprecatedSetter, i as bindAmbient, m as warnDeprecatedGetter, n as ambientBinding } from "./default-application-Chbrul_m.js";
2
+ import { n as warnDeprecatedGetter, r as warnDeprecatedSetter } from "./deprecate-rL8jNpKX.js";
3
+ import { i as bindAmbient, n as ambientBinding } from "./default-application-CMuAAsdf.js";
3
4
  import { r as getAuthContext } from "./context-af2n5abO.js";
4
- //#region src/http/middleware/capabilities.ts
5
- /**
6
- * Internal security-capability marker (RFC 0007): built-in middleware
7
- * factories stamp their handlers so tooling can read what a chain enforces
8
- * without name heuristics. `Symbol.for()` keeps the key identical across
9
- * duplicated `@guren/server` copies in one process. Not public API — the
10
- * shape may change in any release.
11
- */
12
- const CAPABILITIES = Symbol.for("guren.capabilities");
13
- /**
14
- * Folds one middleware's stamp into an accumulating aggregate. Mutates `into`
15
- * and never `stamp`. Every call counts as an independent check, so folding the
16
- * *same* stamp twice degrades an `'any'` to `'mixed'` — de-duplicating handlers
17
- * that appear more than once in a chain is the caller's job.
18
- */
19
- function mergeCapabilities(into, stamp) {
20
- const auth = stamp.authentication;
21
- if (auth && (!into.authentication || auth.mode === "required")) into.authentication = { ...auth };
22
- const authz = stamp.authorization;
23
- if (!authz) return;
24
- const current = into.authorization;
25
- if (!current) {
26
- into.authorization = {
27
- abilities: [...authz.abilities],
28
- mode: authz.mode,
29
- ...authz.resource ? { resource: { ...authz.resource } } : {}
30
- };
31
- return;
32
- }
33
- for (const ability of authz.abilities) if (!current.abilities.includes(ability)) current.abilities.push(ability);
34
- current.mode = current.mode === "all" && authz.mode === "all" ? "all" : "mixed";
35
- if (authz.resource) current.resource = { fromMethodMap: (current.resource?.fromMethodMap ?? true) && authz.resource.fromMethodMap };
36
- }
37
- function stampCapabilities(handler, capabilities) {
38
- Object.defineProperty(handler, CAPABILITIES, {
39
- value: capabilities,
40
- enumerable: false
41
- });
42
- return handler;
43
- }
44
- function capabilitiesOf(handler) {
45
- if (typeof handler !== "function") return void 0;
46
- return handler[CAPABILITIES];
47
- }
48
- //#endregion
49
5
  //#region src/http/request-container.ts
50
6
  /**
51
7
  * Context variable the serving Application's container is stamped under
@@ -325,174 +281,4 @@ async function authorize(ability, ...args) {
325
281
  return resolveGate().authorize(ability, ...args);
326
282
  }
327
283
  //#endregion
328
- //#region src/authorization/Policy.ts
329
- /**
330
- * Base policy class for model authorization. Ability methods are looked up on
331
- * the subclass by name (`viewAny`, `view`, `create`, `update`, `delete`,
332
- * `restore`, `forceDelete`, or any custom ability), each taking
333
- * `(user, model?, ...args)`.
334
- */
335
- var Policy = class {
336
- allow(message) {
337
- return Response.allow(message);
338
- }
339
- deny(message, code) {
340
- return Response.deny(message, code);
341
- }
342
- denyWithStatus(status, message) {
343
- return Response.denyWithStatus(status, message);
344
- }
345
- denyAsNotFound(message) {
346
- return Response.denyAsNotFound(message);
347
- }
348
- };
349
- /** Create a policy class from an object of ability functions. */
350
- function definePolicy(definition) {
351
- return class extends Policy {
352
- before = definition.before;
353
- viewAny(user) {
354
- return definition.viewAny?.(user) ?? false;
355
- }
356
- view(user, model) {
357
- return definition.view?.(user, model) ?? false;
358
- }
359
- create(user) {
360
- return definition.create?.(user) ?? false;
361
- }
362
- update(user, model) {
363
- return definition.update?.(user, model) ?? false;
364
- }
365
- delete(user, model) {
366
- return definition.delete?.(user, model) ?? false;
367
- }
368
- restore(user, model) {
369
- return definition.restore?.(user, model) ?? false;
370
- }
371
- forceDelete(user, model) {
372
- return definition.forceDelete?.(user, model) ?? false;
373
- }
374
- };
375
- }
376
- //#endregion
377
- //#region src/authorization/middleware.ts
378
- /** The gate of the app serving `ctx` (RFC 0023 §2); the ambient one on a bare Hono app. */
379
- function gateFor(ctx) {
380
- return tryGetRequestContainer(ctx)?.makeOptional("gate") ?? resolveGate();
381
- }
382
- /**
383
- * Middleware to authorize an ability. An array argument is snapshotted at
384
- * creation, and a one-element array behaves exactly like the bare ability.
385
- * An empty array denies every request (`Gate.any([])` is false) — fail-closed,
386
- * so it is left to run rather than rejected.
387
- */
388
- function authorizeMiddleware(ability, modelResolver, options = {}) {
389
- const abilities = Array.isArray(ability) ? [...ability] : [ability];
390
- const anyOf = abilities.length !== 1;
391
- return stampCapabilities(async (ctx, next) => {
392
- const gate = gateFor(ctx);
393
- const user = await gate.resolveUser(ctx);
394
- const gateForUser = gate.forUser(user);
395
- const model = modelResolver ? await modelResolver(ctx) : void 0;
396
- if (anyOf) {
397
- if (!await gateForUser.any(abilities, model)) throw new AuthorizationException(options.message ?? "This action is unauthorized.");
398
- } else {
399
- const response = await gateForUser.checkResponse(abilities[0], user, model);
400
- if (!response.allowed) throw denialToException(options.message ? {
401
- ...response,
402
- message: options.message
403
- } : response);
404
- }
405
- await next();
406
- }, { authorization: {
407
- abilities,
408
- mode: anyOf ? "any" : "all"
409
- } });
410
- }
411
- /**
412
- * Middleware to authorize all given abilities. The array is snapshotted at creation.
413
- *
414
- * @throws if no ability is given: `Gate.all([])` is vacuously true, so an empty
415
- * list would advertise authorization and enforce none (RFC 0016).
416
- */
417
- function authorizeAllMiddleware(input, modelResolver, options = {}) {
418
- const abilities = [...input];
419
- if (abilities.length === 0) throw new Error("authorizeAllMiddleware() requires at least one ability: an empty list authorizes every request while claiming to authorize.");
420
- return stampCapabilities(async (ctx, next) => {
421
- const gate = gateFor(ctx);
422
- const user = await gate.resolveUser(ctx);
423
- const gateForUser = gate.forUser(user);
424
- const model = modelResolver ? await modelResolver(ctx) : void 0;
425
- if (!await gateForUser.all(abilities, model)) throw new AuthorizationException(options.message ?? "This action is unauthorized.");
426
- await next();
427
- }, { authorization: {
428
- abilities,
429
- mode: "all"
430
- } });
431
- }
432
- const RESOURCE_ABILITY_BY_METHOD = {
433
- GET: "view",
434
- HEAD: "view",
435
- QUERY: "view",
436
- POST: "create",
437
- PUT: "update",
438
- PATCH: "update",
439
- DELETE: "delete"
440
- };
441
- /**
442
- * The single source of the verb → ability mapping; `undefined` for a method it
443
- * refuses to guess at. A consumer resolving a route's ability from its stamped
444
- * `authorization.resource` capability calls this rather than restating the
445
- * table, and may only do so when `resource.fromMethodMap` is true. Internal
446
- * contract (RFC 0007): not re-exported from the package root.
447
- */
448
- function resourceAbilityForMethod(method) {
449
- return RESOURCE_ABILITY_BY_METHOD[method.toUpperCase()];
450
- }
451
- /**
452
- * Maps HTTP methods to policy abilities. A method outside the built-in mapping
453
- * (a custom verb via `router.on()`) is denied with a 403 rather than downgraded
454
- * to `view`: guessing would let a view-only user reach a mutating handler. Map
455
- * custom verbs explicitly with `options.abilityFor`.
456
- */
457
- function authorizeResourceMiddleware(modelResolver, options = {}) {
458
- const abilityFor = options.abilityFor;
459
- return stampCapabilities(async (ctx, next) => {
460
- const method = ctx.req.method.toUpperCase();
461
- const ability = abilityFor?.(method) ?? resourceAbilityForMethod(method);
462
- if (ability === void 0) throw new AuthorizationException(options.message ?? "This action is unauthorized.");
463
- const gate = gateFor(ctx);
464
- const user = await gate.resolveUser(ctx);
465
- const gateForUser = gate.forUser(user);
466
- const model = await modelResolver(ctx);
467
- const response = await gateForUser.checkResponse(ability, user, model);
468
- if (!response.allowed) throw denialToException(options.message ? {
469
- ...response,
470
- message: options.message
471
- } : response);
472
- await next();
473
- }, { authorization: {
474
- abilities: [],
475
- mode: "all",
476
- resource: { fromMethodMap: abilityFor === void 0 }
477
- } });
478
- }
479
- /** Create a gate-aware context with authorization helpers. */
480
- function withAuthorization(gate) {
481
- return async (ctx, next) => {
482
- const user = await gate.resolveUser(ctx);
483
- const gateForUser = gate.forUser(user);
484
- ctx.set("gate", gateForUser);
485
- ctx.set("can", async (ability, ...args) => {
486
- return gateForUser.allows(ability, ...args);
487
- });
488
- ctx.set("cannot", async (ability, ...args) => {
489
- return gateForUser.denies(ability, ...args);
490
- });
491
- ctx.set("authorize", async (ability, ...args) => {
492
- return gateForUser.authorize(ability, ...args);
493
- });
494
- await next();
495
- };
496
- }
497
- //#endregion
498
- export { capabilitiesOf as C, tryGetRequestContainer as S, stampCapabilities as T, resolveGate as _, withAuthorization as a, CONTAINER_CONTEXT_KEY as b, Gate as c, can as d, cannot as f, isAuthorizationResponse as g, getGate as h, resourceAbilityForMethod as i, Response as l, defineGate as m, authorizeMiddleware as n, Policy as o, createGate as p, authorizeResourceMiddleware as r, definePolicy as s, authorizeAllMiddleware as t, authorize as u, setGate as v, mergeCapabilities as w, getRequestContainer as x, AuthorizationException as y };
284
+ export { cannot as a, denialToException as c, resolveGate as d, setGate as f, tryGetRequestContainer as g, getRequestContainer as h, can as i, getGate as l, CONTAINER_CONTEXT_KEY as m, Response as n, createGate as o, AuthorizationException as p, authorize as r, defineGate as s, Gate as t, isAuthorizationResponse as u };
@@ -1,13 +1,7 @@
1
- import { h as warnDeprecatedSetter, m as warnDeprecatedGetter, n as ambientBinding, o as defaultContainer, r as ambientContainer } from "./default-application-Chbrul_m.js";
1
+ import { t as resolveOptional } from "./resolve-optional-ax6gPWTp.js";
2
+ import { n as warnDeprecatedGetter, r as warnDeprecatedSetter } from "./deprecate-rL8jNpKX.js";
3
+ import { n as ambientBinding, o as defaultContainer, r as ambientContainer } from "./default-application-CMuAAsdf.js";
2
4
  import { randomBytes } from "node:crypto";
3
- //#region src/container/resolve-optional.ts
4
- function resolveOptional(container, key) {
5
- if (!container) return;
6
- const optional = container.makeOptional;
7
- if (typeof optional === "function") return optional.call(container, key);
8
- return container.has?.(key) ? container.make(key) : void 0;
9
- }
10
- //#endregion
11
5
  //#region src/queue/Job.ts
12
6
  /**
13
7
  * The pin `setQueueDriver()` writes, and nothing else does. A manager that
@@ -162,4 +156,4 @@ function clearJobRegistry() {
162
156
  jobRegistry.clear();
163
157
  }
164
158
  //#endregion
165
- export { getJob as a, pinnedQueueDriver as c, resolveQueueDriver as d, setQueueDriver as f, enqueueJob as i, registerJob as l, clearJobRegistry as n, getQueueDriver as o, resolveOptional as p, clearQueueDriver as r, getRegisteredJobs as s, Job as t, resolveJobName as u };
159
+ export { getJob as a, pinnedQueueDriver as c, resolveQueueDriver as d, setQueueDriver as f, enqueueJob as i, registerJob as l, clearJobRegistry as n, getQueueDriver as o, clearQueueDriver as r, getRegisteredJobs as s, Job as t, resolveJobName as u };
@@ -0,0 +1,43 @@
1
+ import { t as __exportAll } from "./rolldown-runtime-B4FMCO8f.js";
2
+ import { n as ServiceProvider } from "./ServiceProvider-DDW3MqQJ.js";
3
+ import { n as createMcpAccessGuard, r as isMcpEndpointEnabled, t as MCP_ENDPOINT_PATH } from "./endpoint-Coq0K_6I.js";
4
+ //#region src/mcp/McpServiceProvider.ts
5
+ var McpServiceProvider_exports = /* @__PURE__ */ __exportAll({
6
+ DEV_MCP_CLI_TOO_OLD: () => DEV_MCP_CLI_TOO_OLD,
7
+ McpServiceProvider: () => McpServiceProvider,
8
+ canServeDevMcp: () => canServeDevMcp
9
+ });
10
+ const DEV_MCP_CLI_TOO_OLD = "GUREN_MCP=1 but the installed @guren/cli predates the 2026-07-28 MCP endpoint, so /_guren/mcp is not mounted. Upgrade it to 2.24.0 or later (bunx guren upgrade).";
11
+ /** Whether this CLI ships the Dev MCP factory; `DEV_MCP_CLI_TOO_OLD` says what to do when it does not. */
12
+ function canServeDevMcp(cli) {
13
+ return typeof cli.createDevMcpHandler === "function";
14
+ }
15
+ /**
16
+ * Mounts the Dev MCP endpoint at /_guren/mcp while `isMcpEndpointEnabled()` holds.
17
+ * The server lives in @guren/cli (RFC 0028 §1), which every deploy target stubs, so
18
+ * this package imports no MCP SDK code.
19
+ * @experimental
20
+ */
21
+ var McpServiceProvider = class extends ServiceProvider {
22
+ register() {}
23
+ async boot() {
24
+ if (!isMcpEndpointEnabled()) return;
25
+ const { hono } = this.container.make("app");
26
+ let cli;
27
+ try {
28
+ cli = await import("@guren/cli");
29
+ } catch (error) {
30
+ console.warn(`[guren] GUREN_MCP=1 but @guren/cli could not be loaded, so /_guren/mcp is not mounted: ${error instanceof Error ? error.message : String(error)}`);
31
+ return;
32
+ }
33
+ if (!canServeDevMcp(cli)) {
34
+ console.warn(`[guren] ${DEV_MCP_CLI_TOO_OLD}`);
35
+ return;
36
+ }
37
+ const handler = cli.createDevMcpHandler({ cwd: process.cwd() });
38
+ hono.use(MCP_ENDPOINT_PATH, createMcpAccessGuard());
39
+ hono.all(MCP_ENDPOINT_PATH, (c) => handler.fetch(c.req.raw));
40
+ }
41
+ };
42
+ //#endregion
43
+ export { McpServiceProvider_exports as n, McpServiceProvider as t };